diff --git a/build/icn3d.js b/build/icn3d.js index fbe6e4e4..c125cdcc 100644 --- a/build/icn3d.js +++ b/build/icn3d.js @@ -11589,7 +11589,7 @@ var icn3d = (function (exports) { html += me.htmlCls.divStr + "dl_mmdbafid' class='" + dialogClass + "' style='max-width:600px'>"; html += "List of PDB, MMDB, or AlphaFold UniProt structures: " + me.htmlCls.inputTextStr + "id='" + me.pre + "mmdbafid' placeholder='e.g., 1HHO,4N7N,P69905,P01942' size=30>

"; html += "
" + me.htmlCls.buttonStr + "reload_mmdbaf' style='width:150px'>Load Biological Unit" + me.htmlCls.buttonStr + "reload_mmdbaf_asym' style='margin-left:30px; width:250px'>Load Asymmetric Unit (All Chains)" + "

"; - html += "
or
" + me.htmlCls.buttonStr + "reload_mmdbaf_append' style='width:150px'>Append Biological Unit" + me.htmlCls.buttonStr + "reload_mmdbaf_asym_append' style='margin-left:30px; width:250px'>Append Asymmetric ; Unit (All Chains)" + "

"; + html += "
or
" + me.htmlCls.buttonStr + "reload_mmdbaf_append' style='width:150px'>Append Biological Unit" + me.htmlCls.buttonStr + "reload_mmdbaf_asym_append' style='margin-left:30px; width:250px'>Append Asymmetric Unit (All Chains)" + "

"; html += 'Note: The "biological unit" is the biochemically active form of a biomolecule,
0.0 ){"," cameraPos = rayDirection * posT + rayOrigin;"," interior = true;"," flag2 = true;"," return false;","}else{"," cameraNormal = normalize( cameraPos - cameraSpherePos );","}"," #else","if( calcDepth( cameraPos ) <= 0.0 ){"," cameraPos = rayDirection * posT + rayOrigin;"," interior = true;"," return false;","}else{"," cameraNormal = normalize( cameraPos - cameraSpherePos );","}"," #endif",""," cameraNormal = normalize( cameraPos - cameraSpherePos );"," cameraNormal *= float(!interior) * 2.0 - 1.0;"," return !interior;","","}","","void main(void){",""," bool flag = Impostor( cameraPos, cameraNormal );",""," #ifdef NEAR_CLIP"," if( calcClip( cameraPos ) > 0.0 )"," discard;"," #endif",""," // FIXME not compatible with custom clipping plane"," //Set the depth based on the new cameraPos."," gl_FragDepthEXT = calcDepth( cameraPos );"," if( !flag ){",""," // clamp to near clipping plane and add a tiny value to"," // make spheres with a greater radius occlude smaller ones"," #ifdef NEAR_CLIP","if( flag2 ){"," gl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( nearClip - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );","}else if( gl_FragDepthEXT >= 0.0 ){"," gl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );","}"," #else","if( gl_FragDepthEXT >= 0.0 ){"," gl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );","}"," #endif",""," }",""," // bugfix (mac only?)"," if (gl_FragDepthEXT < 0.0)"," discard;"," if (gl_FragDepthEXT > 1.0)"," discard;",""," #ifdef PICKING",""," gl_FragColor = vec4( vPickingColor, objectId );",""," #else",""," vec3 vNormal = cameraNormal;"," vec3 vViewPosition = -cameraPos;",""," vec4 diffuseColor = vec4( diffuse, opacity );"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveLight = emissive;",""," #include color_fragment"," #include roughnessmap_fragment"," #include metalnessmap_fragment",""," // don't use include normal_fragment"," vec3 normal = normalize( vNormal );",""," #include lights_physical_fragment"," //include lights_template"," #include lights_fragment_begin"," #include lights_fragment_end",""," vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;",""," gl_FragColor = vec4( outgoingLight, diffuseColor.a );"," //gl_FragColor = vec4( reflectedLight.directSpecular, diffuseColor.a );",""," #include premultiplied_alpha_fragment"," #include tonemapping_fragment"," #include encodings_fragment"," //include fog_fragment"," #ifdef USE_FOG"," #ifdef USE_LOGDEPTHBUF_EXT"," float depth = gl_FragDepthEXT / gl_FragCoord.w;"," #else"," float depth = gl_FragCoord.z / gl_FragCoord.w;"," #endif"," #ifdef FOG_EXP2"," float fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );"," #else"," float fogFactor = smoothstep( fogNear, fogFar, depth );"," #endif"," gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );"," #endif",""," #endif","","}"].join("\n"),$NGL_shaderTextHash["SphereImpostor.vert"]=["uniform mat4 projectionMatrixInverse;","uniform float nearClip;","","varying float vRadius;","varying float vRadiusSq;","varying vec3 vPoint;","varying vec3 vPointViewPosition;","varying float fogDepth;","varying float fogNear;","varying float fogFar;","","attribute vec2 mapping;","//attribute vec3 position;","attribute float radius;","","#ifdef PICKING"," #include unpack_clr"," attribute float primitiveId;"," varying vec3 vPickingColor;","#else"," #include color_pars_vertex","#endif","","//include matrix_scale","float matrixScale( in mat4 m ){"," vec4 r = m[ 0 ];"," return sqrt( r[ 0 ] * r[ 0 ] + r[ 1 ] * r[ 1 ] + r[ 2 ] * r[ 2 ] );","}","","const mat4 D = mat4("," 1.0, 0.0, 0.0, 0.0,"," 0.0, 1.0, 0.0, 0.0,"," 0.0, 0.0, 1.0, 0.0,"," 0.0, 0.0, 0.0, -1.0",");","","mat4 transposeTmp( in mat4 inMatrix ) {"," vec4 i0 = inMatrix[0];"," vec4 i1 = inMatrix[1];"," vec4 i2 = inMatrix[2];"," vec4 i3 = inMatrix[3];",""," mat4 outMatrix = mat4("," vec4(i0.x, i1.x, i2.x, i3.x),"," vec4(i0.y, i1.y, i2.y, i3.y),"," vec4(i0.z, i1.z, i2.z, i3.z),"," vec4(i0.w, i1.w, i2.w, i3.w)"," );"," return outMatrix;","}","","//------------------------------------------------------------------------------","// Compute point size and center using the technique described in:","// 'GPU-Based Ray-Casting of Quadratic Surfaces'","// by Christian Sigg, Tim Weyrich, Mario Botsch, Markus Gross.","//","// Code based on","/*=========================================================================",""," Program: Visualization Toolkit"," Module: Quadrics_fs.glsl and Quadrics_vs.glsl",""," Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen"," All rights reserved."," See Copyright.txt or http://www.kitware.com/Copyright.htm for details.",""," This software is distributed WITHOUT ANY WARRANTY; without even"," the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR"," PURPOSE. See the above copyright notice for more information.",""," =========================================================================*/","","// .NAME Quadrics_fs.glsl and Quadrics_vs.glsl","// .SECTION Thanks","// ","//","// This file is part of the PointSprites plugin developed and contributed by","//","// Copyright (c) CSCS - Swiss National Supercomputing Centre","// EDF - Electricite de France","//","// John Biddiscombe, Ugo Varetto (CSCS)","// Stephane Ploix (EDF)","//","// ","//","// Contributions by Alexander Rose","// - ported to WebGL","// - adapted to work with quads","void ComputePointSizeAndPositionInClipCoordSphere(){",""," vec2 xbc;"," vec2 ybc;",""," mat4 T = mat4("," radius, 0.0, 0.0, 0.0,"," 0.0, radius, 0.0, 0.0,"," 0.0, 0.0, radius, 0.0,"," position.x, position.y, position.z, 1.0"," );",""," mat4 R = transposeTmp( projectionMatrix * modelViewMatrix * T );"," float A = dot( R[ 3 ], D * R[ 3 ] );"," float B = -2.0 * dot( R[ 0 ], D * R[ 3 ] );"," float C = dot( R[ 0 ], D * R[ 0 ] );"," xbc[ 0 ] = ( -B - sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," xbc[ 1 ] = ( -B + sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," float sx = abs( xbc[ 0 ] - xbc[ 1 ] ) * 0.5;",""," A = dot( R[ 3 ], D * R[ 3 ] );"," B = -2.0 * dot( R[ 1 ], D * R[ 3 ] );"," C = dot( R[ 1 ], D * R[ 1 ] );"," ybc[ 0 ] = ( -B - sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," ybc[ 1 ] = ( -B + sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," float sy = abs( ybc[ 0 ] - ybc[ 1 ] ) * 0.5;",""," gl_Position.xy = vec2( 0.5 * ( xbc.x + xbc.y ), 0.5 * ( ybc.x + ybc.y ) );"," gl_Position.xy -= mapping * vec2( sx, sy );"," gl_Position.xy *= gl_Position.w;","","}","","void main(void){",""," #ifdef PICKING"," vPickingColor = unpackColor( primitiveId );"," #else"," #include color_vertex"," #endif",""," vRadius = radius * matrixScale( modelViewMatrix );",""," vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );"," // avoid clipping, added again in fragment shader"," mvPosition.z -= vRadius;",""," gl_Position = projectionMatrix * vec4( mvPosition.xyz, 1.0 );"," ComputePointSizeAndPositionInClipCoordSphere();","",""," vRadiusSq = vRadius * vRadius;"," vec4 vPoint4 = projectionMatrixInverse * gl_Position;"," vPoint = vPoint4.xyz / vPoint4.w;"," vPointViewPosition = -mvPosition.xyz / mvPosition.w;","","}"].join("\n"),$NGL_shaderTextHash["CylinderImpostor.frag"]=["#define STANDARD","#define IMPOSTOR","","// Open-Source PyMOL is Copyright (C) Schrodinger, LLC.","//","// All Rights Reserved","//","// Permission to use, copy, modify, distribute, and distribute modified","// versions of this software and its built-in documentation for any","// purpose and without fee is hereby granted, provided that the above","// copyright notice appears in all copies and that both the copyright","// notice and this permission notice appear in supporting documentation,","// and that the name of Schrodinger, LLC not be used in advertising or","// publicity pertaining to distribution of the software without specific,","// written prior permission.","//","// SCHRODINGER, LLC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,","// INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN","// NO EVENT SHALL SCHRODINGER, LLC BE LIABLE FOR ANY SPECIAL, INDIRECT OR","// CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS","// OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE","// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE","// USE OR PERFORMANCE OF THIS SOFTWARE.","","// Contributions by Alexander Rose","// - ported to WebGL","// - dual color","// - pk color","// - custom clipping","// - three.js lighting","","uniform vec3 diffuse;","uniform vec3 emissive;","uniform float roughness;","uniform float metalness;","uniform float opacity;","uniform float nearClip;","uniform mat4 projectionMatrix;","uniform float ortho;","","varying vec3 axis;","varying vec4 base_radius;","varying vec4 end_b;","varying vec3 U;","varying vec3 V;","varying vec4 w;","","#ifdef PICKING"," uniform float objectId;"," varying vec3 vPickingColor;","#else"," varying vec3 vColor1;"," varying vec3 vColor2;"," #include common"," #include fog_pars_fragment"," #include bsdfs"," #include lights_pars_begin"," #include lights_physical_pars_fragment","#endif","","bool interior = false;","","float distSq3( vec3 v3a, vec3 v3b ){"," return ("," ( v3a.x - v3b.x ) * ( v3a.x - v3b.x ) +"," ( v3a.y - v3b.y ) * ( v3a.y - v3b.y ) +"," ( v3a.z - v3b.z ) * ( v3a.z - v3b.z )"," );","}","","// Calculate depth based on the given camera position.","float calcDepth( in vec3 cameraPos ){"," vec2 clipZW = cameraPos.z * projectionMatrix[2].zw + projectionMatrix[3].zw;"," return 0.5 + 0.5 * clipZW.x / clipZW.y;","}","","float calcClip( vec3 cameraPos ){"," return dot( vec4( cameraPos, 1.0 ), vec4( 0.0, 0.0, 1.0, nearClip - 0.5 ) );","}","","void main(){",""," vec3 point = w.xyz / w.w;",""," // unpacking"," vec3 base = base_radius.xyz;"," float vRadius = base_radius.w;"," vec3 end = end_b.xyz;"," float b = end_b.w;",""," vec3 end_cyl = end;"," vec3 surface_point = point;",""," vec3 ray_target = surface_point;"," vec3 ray_origin = vec3(0.0);"," vec3 ray_direction = mix(normalize(ray_origin - ray_target), vec3(0.0, 0.0, 1.0), ortho);"," mat3 basis = mat3( U, V, axis );",""," vec3 diff = ray_target - 0.5 * (base + end_cyl);"," vec3 P = diff * basis;",""," // angle (cos) between cylinder cylinder_axis and ray direction"," float dz = dot( axis, ray_direction );",""," float radius2 = vRadius*vRadius;",""," // calculate distance to the cylinder from ray origin"," vec3 D = vec3(dot(U, ray_direction),"," dot(V, ray_direction),"," dz);"," float a0 = P.x*P.x + P.y*P.y - radius2;"," float a1 = P.x*D.x + P.y*D.y;"," float a2 = D.x*D.x + D.y*D.y;",""," // calculate a dicriminant of the above quadratic equation"," float d = a1*a1 - a0*a2;"," if (d < 0.0)"," // outside of the cylinder"," discard;",""," float dist = (-a1 + sqrt(d)) / a2;",""," // point of intersection on cylinder surface"," vec3 new_point = ray_target + dist * ray_direction;",""," vec3 tmp_point = new_point - base;"," vec3 _normal = normalize( tmp_point - axis * dot(tmp_point, axis) );",""," ray_origin = mix( ray_origin, surface_point, ortho );",""," // test caps"," float front_cap_test = dot( tmp_point, axis );"," float end_cap_test = dot((new_point - end_cyl), axis);",""," // to calculate caps, simply check the angle between"," // the point of intersection - cylinder end vector"," // and a cap plane normal (which is the cylinder cylinder_axis)"," // if the angle < 0, the point is outside of cylinder"," // test front cap",""," #ifndef CAP"," vec3 new_point2 = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;"," vec3 tmp_point2 = new_point2 - base;"," #endif",""," // flat"," if (front_cap_test < 0.0)"," {"," // ray-plane intersection"," float dNV = dot(-axis, ray_direction);"," if (dNV < 0.0)"," discard;"," float near = dot(-axis, (base)) / dNV;"," vec3 front_point = ray_direction * near + ray_origin;"," // within the cap radius?"," if (dot(front_point - base, front_point-base) > radius2)"," discard;",""," #ifdef CAP"," new_point = front_point;"," _normal = axis;"," #else"," new_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;"," dNV = dot(-axis, ray_direction);"," near = dot(axis, end_cyl) / dNV;"," new_point2 = ray_direction * near + ray_origin;"," if (dot(new_point2 - end_cyl, new_point2-base) < radius2)"," discard;"," interior = true;"," #endif"," }",""," // test end cap","",""," // flat"," if( end_cap_test > 0.0 )"," {"," // ray-plane intersection"," float dNV = dot(axis, ray_direction);"," if (dNV < 0.0)"," discard;"," float near = dot(axis, end_cyl) / dNV;"," vec3 end_point = ray_direction * near + ray_origin;"," // within the cap radius?"," if( dot(end_point - end_cyl, end_point-base) > radius2 )"," discard;",""," #ifdef CAP"," new_point = end_point;"," _normal = axis;"," #else"," new_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;"," dNV = dot(-axis, ray_direction);"," near = dot(-axis, (base)) / dNV;"," new_point2 = ray_direction * near + ray_origin;"," if (dot(new_point2 - base, new_point2-base) < radius2)"," discard;"," interior = true;"," #endif"," }",""," gl_FragDepthEXT = calcDepth( new_point );",""," #ifdef NEAR_CLIP"," if( calcClip( new_point ) > 0.0 ){"," dist = (-a1 - sqrt(d)) / a2;"," new_point = ray_target + dist * ray_direction;"," if( calcClip( new_point ) > 0.0 )"," discard;"," interior = true;"," gl_FragDepthEXT = calcDepth( new_point );"," if( gl_FragDepthEXT >= 0.0 ){"," gl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( nearClip - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );"," }"," }else if( gl_FragDepthEXT <= 0.0 ){"," dist = (-a1 - sqrt(d)) / a2;"," new_point = ray_target + dist * ray_direction;"," interior = true;"," gl_FragDepthEXT = calcDepth( new_point );"," if( gl_FragDepthEXT >= 0.0 ){"," gl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );"," }"," }"," #else"," if( gl_FragDepthEXT <= 0.0 ){"," dist = (-a1 - sqrt(d)) / a2;"," new_point = ray_target + dist * ray_direction;"," interior = true;"," gl_FragDepthEXT = calcDepth( new_point );"," if( gl_FragDepthEXT >= 0.0 ){"," gl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );"," }"," }"," #endif",""," // this is a workaround necessary for Mac"," // otherwise the modified fragment won't clip properly"," if (gl_FragDepthEXT < 0.0)"," discard;"," if (gl_FragDepthEXT > 1.0)"," discard;",""," #ifdef PICKING",""," gl_FragColor = vec4( vPickingColor, objectId );",""," #else",""," vec3 vViewPosition = -new_point;"," vec3 vNormal = _normal;"," vec3 vColor;",""," if( distSq3( new_point, end_cyl ) < distSq3( new_point, base ) ){"," if( b < 0.0 ){"," vColor = vColor1;"," }else{"," vColor = vColor2;"," }"," }else{"," if( b > 0.0 ){"," vColor = vColor1;"," }else{"," vColor = vColor2;"," }"," }",""," vec4 diffuseColor = vec4( diffuse, opacity );"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveLight = emissive;",""," #include color_fragment"," //ifdef USE_COLOR"," //diffuseColor.r *= vColor[0];"," //diffuseColor.g *= vColor[1];"," //diffuseColor.b *= vColor[2];"," //endif"," #include roughnessmap_fragment"," #include metalnessmap_fragment",""," // don't use include normal_fragment"," vec3 normal = normalize( vNormal );",""," #include lights_physical_fragment"," //include lights_template"," #include lights_fragment_begin"," #include lights_fragment_end",""," vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;",""," gl_FragColor = vec4( outgoingLight, diffuseColor.a );"," //gl_FragColor = vec4( reflectedLight.directSpecular, diffuseColor.a );",""," #include premultiplied_alpha_fragment"," #include tonemapping_fragment"," #include encodings_fragment"," //include fog_fragment"," #ifdef USE_FOG"," #ifdef USE_LOGDEPTHBUF_EXT"," float depth = gl_FragDepthEXT / gl_FragCoord.w;"," #else"," float depth = gl_FragCoord.z / gl_FragCoord.w;"," #endif"," #ifdef FOG_EXP2"," float fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );"," #else"," float fogFactor = smoothstep( fogNear, fogFar, depth );"," #endif"," gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );"," #endif",""," #endif","","}"].join("\n"),$NGL_shaderTextHash["CylinderImpostor.vert"]=["// Open-Source PyMOL is Copyright (C) Schrodinger, LLC.","//","// All Rights Reserved","//","// Permission to use, copy, modify, distribute, and distribute modified","// versions of this software and its built-in documentation for any","// purpose and without fee is hereby granted, provided that the above","// copyright notice appears in all copies and that both the copyright","// notice and this permission notice appear in supporting documentation,","// and that the name of Schrodinger, LLC not be used in advertising or","// publicity pertaining to distribution of the software without specific,","// written prior permission.","//","// SCHRODINGER, LLC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,","// INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN","// NO EVENT SHALL SCHRODINGER, LLC BE LIABLE FOR ANY SPECIAL, INDIRECT OR","// CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS","// OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE","// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE","// USE OR PERFORMANCE OF THIS SOFTWARE.","","// Contributions by Alexander Rose","// - ported to WebGL","// - dual color","// - pk color","// - shift","","attribute vec3 mapping;","attribute vec3 position1;","attribute vec3 position2;","attribute float radius;","","varying vec3 axis;","varying vec4 base_radius;","varying vec4 end_b;","varying vec3 U;","varying vec3 V;","varying vec4 w;","varying float fogDepth;","varying float fogNear;","varying float fogFar;","","#ifdef PICKING"," #include unpack_clr"," attribute float primitiveId;"," varying vec3 vPickingColor;","#else"," //attribute vec3 color;"," attribute vec3 color2;"," varying vec3 vColor1;"," varying vec3 vColor2;","#endif","","uniform mat4 modelViewMatrixInverse;","uniform float ortho;","","//include matrix_scale","float matrixScale( in mat4 m ){"," vec4 r = m[ 0 ];"," return sqrt( r[ 0 ] * r[ 0 ] + r[ 1 ] * r[ 1 ] + r[ 2 ] * r[ 2 ] );","}","","void main(){",""," #ifdef PICKING"," vPickingColor = unpackColor( primitiveId );"," #else"," vColor1 = color;"," vColor2 = color2;"," #endif",""," // vRadius = radius;"," base_radius.w = radius * matrixScale( modelViewMatrix );",""," //vec3 center = position;"," vec3 center = ( position2 + position1 ) / 2.0;"," vec3 dir = normalize( position2 - position1 );"," float ext = length( position2 - position1 ) / 2.0;",""," // using cameraPosition fails on some machines, not sure why"," // vec3 cam_dir = normalize( cameraPosition - mix( center, vec3( 0.0 ), ortho ) );"," vec3 cam_dir;"," if( ortho == 0.0 ){"," cam_dir = ( modelViewMatrixInverse * vec4( 0, 0, 0, 1 ) ).xyz - center;"," }else{"," cam_dir = ( modelViewMatrixInverse * vec4( 0, 0, 1, 0 ) ).xyz;"," }"," cam_dir = normalize( cam_dir );",""," vec3 ldir;",""," float b = dot( cam_dir, dir );"," end_b.w = b;"," // direction vector looks away, so flip"," if( b < 0.0 )"," ldir = -ext * dir;"," // direction vector already looks in my direction"," else"," ldir = ext * dir;",""," vec3 left = normalize( cross( cam_dir, ldir ) );"," left = radius * left;"," vec3 up = radius * normalize( cross( left, ldir ) );",""," // transform to modelview coordinates"," axis = normalize( normalMatrix * ldir );"," U = normalize( normalMatrix * up );"," V = normalize( normalMatrix * left );",""," vec4 base4 = modelViewMatrix * vec4( center - ldir, 1.0 );"," base_radius.xyz = base4.xyz / base4.w;",""," vec4 top_position = modelViewMatrix * vec4( center + ldir, 1.0 );"," vec4 end4 = top_position;"," end_b.xyz = end4.xyz / end4.w;",""," w = modelViewMatrix * vec4("," center + mapping.x*ldir + mapping.y*left + mapping.z*up, 1.0"," );",""," gl_Position = projectionMatrix * w;",""," // avoid clipping (1.0 seems to induce flickering with some drivers)"," gl_Position.z = 0.99;","","}"].join("\n"),$NGL_shaderTextHash["SphereInstancing.frag"]=$NGL_shaderTextHash["SphereImpostor.frag"],$NGL_shaderTextHash["SphereInstancing.vert"]=["uniform mat4 projectionMatrixInverse;","uniform float nearClip;","","varying float vRadius;","varying float vRadiusSq;","varying vec3 vPoint;","varying vec3 vPointViewPosition;","varying float fogDepth;","varying float fogNear;","varying float fogFar;","","attribute vec2 mapping;","//attribute vec3 position;","attribute float radius;","attribute vec4 matrix1;","attribute vec4 matrix2;","attribute vec4 matrix3;","attribute vec4 matrix4;","","#ifdef PICKING"," #include unpack_clr"," attribute float primitiveId;"," varying vec3 vPickingColor;","#else"," #include color_pars_vertex","#endif","","//include matrix_scale","float matrixScale( in mat4 m ){"," vec4 r = m[ 0 ];"," return sqrt( r[ 0 ] * r[ 0 ] + r[ 1 ] * r[ 1 ] + r[ 2 ] * r[ 2 ] );","}","","const mat4 D = mat4("," 1.0, 0.0, 0.0, 0.0,"," 0.0, 1.0, 0.0, 0.0,"," 0.0, 0.0, 1.0, 0.0,"," 0.0, 0.0, 0.0, -1.0",");","","mat4 transposeTmp( in mat4 inMatrix ) {"," vec4 i0 = inMatrix[0];"," vec4 i1 = inMatrix[1];"," vec4 i2 = inMatrix[2];"," vec4 i3 = inMatrix[3];",""," mat4 outMatrix = mat4("," vec4(i0.x, i1.x, i2.x, i3.x),"," vec4(i0.y, i1.y, i2.y, i3.y),"," vec4(i0.z, i1.z, i2.z, i3.z),"," vec4(i0.w, i1.w, i2.w, i3.w)"," );"," return outMatrix;","}","","//------------------------------------------------------------------------------","// Compute point size and center using the technique described in:","// 'GPU-Based Ray-Casting of Quadratic Surfaces'","// by Christian Sigg, Tim Weyrich, Mario Botsch, Markus Gross.","//","// Code based on","/*=========================================================================",""," Program: Visualization Toolkit"," Module: Quadrics_fs.glsl and Quadrics_vs.glsl",""," Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen"," All rights reserved."," See Copyright.txt or http://www.kitware.com/Copyright.htm for details.",""," This software is distributed WITHOUT ANY WARRANTY; without even"," the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR"," PURPOSE. See the above copyright notice for more information.",""," =========================================================================*/","","// .NAME Quadrics_fs.glsl and Quadrics_vs.glsl","// .SECTION Thanks","// ","//","// This file is part of the PointSprites plugin developed and contributed by","//","// Copyright (c) CSCS - Swiss National Supercomputing Centre","// EDF - Electricite de France","//","// John Biddiscombe, Ugo Varetto (CSCS)","// Stephane Ploix (EDF)","//","// ","//","// Contributions by Alexander Rose","// - ported to WebGL","// - adapted to work with quads","void ComputePointSizeAndPositionInClipCoordSphere(vec4 updatePosition){",""," vec2 xbc;"," vec2 ybc;",""," mat4 T = mat4("," radius, 0.0, 0.0, 0.0,"," 0.0, radius, 0.0, 0.0,"," 0.0, 0.0, radius, 0.0,"," updatePosition.x, updatePosition.y, updatePosition.z, 1.0"," );",""," mat4 R = transposeTmp( projectionMatrix * modelViewMatrix * T );"," float A = dot( R[ 3 ], D * R[ 3 ] );"," float B = -2.0 * dot( R[ 0 ], D * R[ 3 ] );"," float C = dot( R[ 0 ], D * R[ 0 ] );"," xbc[ 0 ] = ( -B - sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," xbc[ 1 ] = ( -B + sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," float sx = abs( xbc[ 0 ] - xbc[ 1 ] ) * 0.5;",""," A = dot( R[ 3 ], D * R[ 3 ] );"," B = -2.0 * dot( R[ 1 ], D * R[ 3 ] );"," C = dot( R[ 1 ], D * R[ 1 ] );"," ybc[ 0 ] = ( -B - sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," ybc[ 1 ] = ( -B + sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," float sy = abs( ybc[ 0 ] - ybc[ 1 ] ) * 0.5;",""," gl_Position.xy = vec2( 0.5 * ( xbc.x + xbc.y ), 0.5 * ( ybc.x + ybc.y ) );"," gl_Position.xy -= mapping * vec2( sx, sy );"," gl_Position.xy *= gl_Position.w;","","}",""," mat4 computeMat(vec4 v1, vec4 v2, vec4 v3, vec4 v4) {"," return mat4("," v1.x, v1.y, v1.z, v1.w,"," v2.x, v2.y, v2.z, v2.w,"," v3.x, v3.y, v3.z, v3.w,"," v4.x, v4.y, v4.z, v4.w"," );"," }","","void main(void){",""," #ifdef PICKING"," vPickingColor = unpackColor( primitiveId );"," #else"," #include color_vertex"," #endif",""," vRadius = radius * matrixScale( modelViewMatrix );",""," mat4 matrix = computeMat(matrix1, matrix2, matrix3, matrix4);"," vec4 updatePosition = matrix * vec4(position, 1.0);","","// vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );"," vec4 mvPosition = modelViewMatrix * vec4( updatePosition.xyz, 1.0 );"," // avoid clipping, added again in fragment shader"," mvPosition.z -= vRadius;","","// gl_Position = projectionMatrix * vec4( mvPosition.xyz, 1.0 );"," gl_Position = projectionMatrix * vec4( mvPosition.xyz, 1.0 );"," ComputePointSizeAndPositionInClipCoordSphere(updatePosition);","",""," vRadiusSq = vRadius * vRadius;"," vec4 vPoint4 = projectionMatrixInverse * gl_Position;"," vPoint = vPoint4.xyz / vPoint4.w;"," vPointViewPosition = -mvPosition.xyz / mvPosition.w;","","}"].join("\n"),$NGL_shaderTextHash["CylinderInstancing.frag"]=$NGL_shaderTextHash["CylinderImpostor.frag"],$NGL_shaderTextHash["CylinderInstancing.vert"]=["// Open-Source PyMOL is Copyright (C) Schrodinger, LLC.","//","// All Rights Reserved","//","// Permission to use, copy, modify, distribute, and distribute modified","// versions of this software and its built-in documentation for any","// purpose and without fee is hereby granted, provided that the above","// copyright notice appears in all copies and that both the copyright","// notice and this permission notice appear in supporting documentation,","// and that the name of Schrodinger, LLC not be used in advertising or","// publicity pertaining to distribution of the software without specific,","// written prior permission.","//","// SCHRODINGER, LLC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,","// INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN","// NO EVENT SHALL SCHRODINGER, LLC BE LIABLE FOR ANY SPECIAL, INDIRECT OR","// CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS","// OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE","// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE","// USE OR PERFORMANCE OF THIS SOFTWARE.","","// Contributions by Alexander Rose","// - ported to WebGL","// - dual color","// - pk color","// - shift","","attribute vec3 mapping;","attribute vec3 position1;","attribute vec3 position2;","attribute float radius;","attribute vec4 matrix1;","attribute vec4 matrix2;","attribute vec4 matrix3;","attribute vec4 matrix4;","","varying vec3 axis;","varying vec4 base_radius;","varying vec4 end_b;","varying vec3 U;","varying vec3 V;","varying vec4 w;","varying float fogDepth;","varying float fogNear;","varying float fogFar;","","#ifdef PICKING"," #include unpack_clr"," attribute float primitiveId;"," varying vec3 vPickingColor;","#else"," //attribute vec3 color;"," attribute vec3 color2;"," varying vec3 vColor1;"," varying vec3 vColor2;","#endif","","uniform mat4 modelViewMatrixInverse;","uniform float ortho;","","//include matrix_scale","float matrixScale( in mat4 m ){"," vec4 r = m[ 0 ];"," return sqrt( r[ 0 ] * r[ 0 ] + r[ 1 ] * r[ 1 ] + r[ 2 ] * r[ 2 ] );","}",""," mat4 computeMat(vec4 v1, vec4 v2, vec4 v3, vec4 v4) {"," return mat4("," v1.x, v1.y, v1.z, v1.w,"," v2.x, v2.y, v2.z, v2.w,"," v3.x, v3.y, v3.z, v3.w,"," v4.x, v4.y, v4.z, v4.w"," );"," }","","void main(){",""," #ifdef PICKING"," vPickingColor = unpackColor( primitiveId );"," #else"," vColor1 = color;"," vColor2 = color2;"," #endif",""," // vRadius = radius;"," base_radius.w = radius * matrixScale( modelViewMatrix );",""," //vec3 center = ( position2 + position1 ) / 2.0;",""," mat4 matrix = computeMat(matrix1, matrix2, matrix3, matrix4);"," vec4 updatePosition1 = matrix * vec4(position1, 1.0);"," vec4 updatePosition2 = matrix * vec4(position2, 1.0);"," vec3 center = ( updatePosition2.xyz + updatePosition1.xyz ) / 2.0;",""," //vec3 dir = normalize( position2 - position1 );"," vec3 dir = normalize( updatePosition2.xyz - updatePosition1.xyz );"," float ext = length( position2 - position1 ) / 2.0;",""," // using cameraPosition fails on some machines, not sure why"," // vec3 cam_dir = normalize( cameraPosition - mix( center, vec3( 0.0 ), ortho ) );"," vec3 cam_dir;"," if( ortho == 0.0 ){"," cam_dir = ( modelViewMatrixInverse * vec4( 0, 0, 0, 1 ) ).xyz - center;"," }else{"," cam_dir = ( modelViewMatrixInverse * vec4( 0, 0, 1, 0 ) ).xyz;"," }"," cam_dir = normalize( cam_dir );",""," vec3 ldir;",""," float b = dot( cam_dir, dir );"," end_b.w = b;"," // direction vector looks away, so flip"," if( b < 0.0 )"," ldir = -ext * dir;"," // direction vector already looks in my direction"," else"," ldir = ext * dir;",""," vec3 left = normalize( cross( cam_dir, ldir ) );"," left = radius * left;"," vec3 up = radius * normalize( cross( left, ldir ) );",""," // transform to modelview coordinates"," axis = normalize( normalMatrix * ldir );"," U = normalize( normalMatrix * up );"," V = normalize( normalMatrix * left );",""," vec4 base4 = modelViewMatrix * vec4( center - ldir, 1.0 );"," base_radius.xyz = base4.xyz / base4.w;",""," vec4 top_position = modelViewMatrix * vec4( center + ldir, 1.0 );"," vec4 end4 = top_position;"," end_b.xyz = end4.xyz / end4.w;",""," w = modelViewMatrix * vec4("," center + mapping.x*ldir + mapping.y*left + mapping.z*up, 1.0"," );",""," gl_Position = projectionMatrix * w;",""," // avoid clipping (1.0 seems to induce flickering with some drivers)"," gl_Position.z = 0.99;","","}"].join("\n"),$NGL_shaderTextHash["Instancing.frag"]=["#define STANDARD","uniform vec3 diffuse;","uniform vec3 emissive;","uniform float roughness;","uniform float metalness;","uniform float opacity;","uniform float nearClip;","uniform float clipRadius;","uniform mat4 projectionMatrix;","uniform float ortho;","varying float bCylinder;","","#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || ( !defined( PICKING ) && !defined( NOLIGHT ) )"," varying vec3 vViewPosition;","#endif","","#if defined( RADIUS_CLIP )"," varying vec3 vClipCenter;","#endif","","#if defined( PICKING )"," uniform float objectId;"," varying vec3 vPickingColor;","#elif defined( NOLIGHT )"," varying vec3 vColor;","#else"," #ifndef FLAT_SHADED"," varying vec3 vNormal;"," #endif"," #include common"," #include color_pars_fragment"," #include fog_pars_fragment"," #include bsdfs"," #include lights_pars_begin"," #include lights_physical_pars_fragment","#endif","","void main(){"," #include nearclip_fragment"," #include radiusclip_fragment",""," #if defined( PICKING )",""," gl_FragColor = vec4( vPickingColor, objectId );",""," #elif defined( NOLIGHT )",""," gl_FragColor = vec4( vColor, opacity );",""," #else",""," vec4 diffuseColor = vec4( diffuse, opacity );"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveLight = emissive;",""," #include color_fragment"," #include roughnessmap_fragment"," #include metalnessmap_fragment"," #include normal_flip"," #include normal_fragment_begin",""," //include dull_interior_fragment",""," #include lights_physical_fragment"," //include lights_template"," #include lights_fragment_begin"," #include lights_fragment_end",""," vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;",""," #include interior_fragment",""," gl_FragColor = vec4( outgoingLight, diffuseColor.a );",""," #include premultiplied_alpha_fragment"," #include tonemapping_fragment"," #include encodings_fragment"," #include fog_fragment",""," #include opaque_back_fragment",""," #endif","","}"].join("\n"),$NGL_shaderTextHash["Instancing.vert"]=["#define STANDARD","","uniform mat4 projectionMatrixInverse;","uniform float nearClip;","uniform vec3 clipCenter;","attribute vec4 matrix1;","attribute vec4 matrix2;","attribute vec4 matrix3;","attribute vec4 matrix4;","attribute float cylinder;","varying float bCylinder;","","#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || ( !defined( PICKING ) && !defined( NOLIGHT ) )"," varying vec3 vViewPosition;","#endif","","#if defined( RADIUS_CLIP )"," varying vec3 vClipCenter;","#endif","","#if defined( PICKING )"," #include unpack_color"," attribute float primitiveId;"," varying vec3 vPickingColor;","#elif defined( NOLIGHT )"," varying vec3 vColor;","#else"," #include color_pars_vertex"," #ifndef FLAT_SHADED"," varying vec3 vNormal;"," #endif","#endif","","#include common",""," mat4 computeMat(vec4 v1, vec4 v2, vec4 v3, vec4 v4) {"," return mat4("," v1.x, v1.y, v1.z, v1.w,"," v2.x, v2.y, v2.z, v2.w,"," v3.x, v3.y, v3.z, v3.w,"," v4.x, v4.y, v4.z, v4.w"," );"," }","","void main(){"," bCylinder = cylinder;",""," mat4 matrix = computeMat(matrix1, matrix2, matrix3, matrix4);"," vec4 updatePosition = matrix * vec4(position, 1.0);",""," #if defined( PICKING )"," vPickingColor = unpackColor( primitiveId );"," #elif defined( NOLIGHT )"," vColor = color;"," #else"," #include color_vertex"," //include beginnormal_vertex"," //vec3 objectNormal = vec3( normal );"," vec3 objectNormal = vec3(matrix * vec4(normal,0.0));"," #include defaultnormal_vertex"," // Normal computed with derivatives when FLAT_SHADED"," #ifndef FLAT_SHADED"," vNormal = normalize( transformedNormal );"," #endif"," #endif",""," //include begin_vertex"," vec3 transformed = updatePosition.xyz;"," //include project_vertex"," vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );"," gl_Position = projectionMatrix * mvPosition;",""," #if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || ( !defined( PICKING ) && !defined( NOLIGHT ) )"," vViewPosition = -mvPosition.xyz;"," #endif",""," #if defined( RADIUS_CLIP )"," vClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;"," #endif",""," #include nearclip_vertex","","}"].join("\n"),THREE.RenderableObject=function(){"use strict";this.id=0,this.object=null,this.z=0},THREE.RenderableFace=function(){"use strict";this.id=0,this.v1=new THREE.RenderableVertex,this.v2=new THREE.RenderableVertex,this.v3=new THREE.RenderableVertex,this.normalModel=new THREE.Vector3,this.vertexNormalsModel=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3],this.vertexNormalsLength=0,this.color=new THREE.Color,this.material=null,this.uvs=[new THREE.Vector2,new THREE.Vector2,new THREE.Vector2],this.z=0},THREE.RenderableVertex=function(){"use strict";this.position=new THREE.Vector3,this.positionWorld=new THREE.Vector3,this.positionScreen=new THREE.Vector4,this.visible=!0},THREE.RenderableVertex.prototype.copy=function(e){"use strict";this.positionWorld.copy(e.positionWorld),this.positionScreen.copy(e.positionScreen)},THREE.RenderableLine=function(){"use strict";this.id=0,this.v1=new THREE.RenderableVertex,this.v2=new THREE.RenderableVertex,this.vertexColors=[new THREE.Color,new THREE.Color],this.material=null,this.z=0},THREE.RenderableSprite=function(){"use strict";this.id=0,this.object=null,this.x=0,this.y=0,this.z=0,this.rotation=0,this.scale=new THREE.Vector2,this.material=null},THREE.Projector=function(){"use strict";var e,t,i,o,n,r,a,s,c,d,l,u=[],p=0,f=[],v=0,h=[],m=0,g=[],y=0,E=[],_=0,b={objects:[],lights:[],elements:[]},w=(new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3),T=new THREE.Vector4,x=new THREE.Box3(new THREE.Vector3(-1,-1,-1),new THREE.Vector3(1,1,1)),C=new THREE.Box3,R=new Array(3),S=(new Array(4),new THREE.Matrix4),L=new THREE.Matrix4,A=(new THREE.Matrix4,new THREE.Matrix3,new THREE.Frustum);new THREE.Vector4,new THREE.Vector4;this.projectVector=function(e,t){console.warn("THREE.Projector: .projectVector() is now vector.project()."),e.project(t)},this.unprojectVector=function(e,t){console.warn("THREE.Projector: .unprojectVector() is now vector.unproject()."),e.unproject(t)},this.pkRay=function(e,t){console.error("THREE.Projector: .pkRay() is now raycaster.setFromCamera().")};var I=new function(){var e=[],t=[],c=null,d=null,u=new THREE.Matrix3,p=function(e){var t=e.position,i=e.positionWorld,o=e.positionScreen;i.copy(t).applyMatrix4(l),o.copy(i).applyMatrix4(L);var n=1/o.w;o.x*=n,o.y*=n,o.z*=n,e.visible=o.x>=-1&&o.x<=1&&o.y>=-1&&o.y<=1&&o.z>=-1&&o.z<=1},E=function(e,t,i){return!0===e.visible||!0===t.visible||!0===i.visible||(R[0]=e.positionScreen,R[1]=t.positionScreen,R[2]=i.positionScreen,x.isIntersectionBox(C.setFromPoints(R)))},_=function(e,t,i){return(i.positionScreen.x-e.positionScreen.x)*(t.positionScreen.y-e.positionScreen.y)-(i.positionScreen.y-e.positionScreen.y)*(t.positionScreen.x-e.positionScreen.x)<0};return{setObject:function(i){d=(c=i).material,u.getNormalMatrix(c.matrixWorld),e.length=0,t.length=0},projectVertex:p,checkTriangleVisibility:E,checkBackfaceCulling:_,pushVertex:function(e,t,n){(i=function(){if(o===v){var e=new THREE.RenderableVertex;return f.push(e),v++,o++,e}return f[o++]}()).position.set(e,t,n),p(i)},pushNormal:function(t,i,o){e.push(t,i,o)},pushUv:function(e,i){t.push(e,i)},pushLine:function(e,t){var i=f[e],o=f[t];(a=function(){if(s===y){var e=new THREE.RenderableLine;return g.push(e),y++,s++,e}return g[s++]}()).id=c.id,a.v1.copy(i),a.v2.copy(o),a.z=(i.positionScreen.z+o.positionScreen.z)/2,a.material=c.material,b.elements.push(a)},pushTriangle:function(i,o,a){var s=f[i],l=f[o],p=f[a];if(!1!==E(s,l,p)&&(d.side===THREE.DoubleSide||!0===_(s,l,p))){(n=function(){if(r===m){var e=new THREE.RenderableFace;return h.push(e),m++,r++,e}return h[r++]}()).id=c.id,n.v1.copy(s),n.v2.copy(l),n.v3.copy(p),n.z=(s.positionScreen.z+l.positionScreen.z+p.positionScreen.z)/3;for(var v=0;v<3;v++){var g=3*arguments[v],y=n.vertexNormalsModel[v];y.set(e[g],e[g+1],e[g+2]),y.applyMatrix3(u).normalize();var w=2*arguments[v];n.uvs[v].set(t[w],t[w+1])}n.vertexNormalsLength=3,n.material=c.material,b.elements.push(n)}}}};function O(){if(d===_){var e=new THREE.RenderableSprite;return E.push(e),_++,d++,e}return E[d++]}function N(e,t){return e.z!==t.z?t.z-e.z:e.id!==t.id?e.id-t.id:0}this.projectScene=function(i,n,a,f){r=0,s=0,d=0,b.elements.length=0,!0===i.autoUpdate&&i.updateMatrixWorld(),void 0===n.parent&&n.updateMatrixWorld(),S.copy(n.matrixWorldInverse.copy(n.matrixWorld).invert()),L.multiplyMatrices(n.projectionMatrix,S),A.setFromMatrix(L),t=0,b.objects.length=0,b.lights.length=0,i.traverseVisible(function(i){if(i instanceof THREE.Light)b.lights.push(i);else if(i instanceof THREE.Mesh||i instanceof THREE.Line||i instanceof THREE.Sprite){if(!1===i.material.visible)return;!1!==i.frustumCulled&&!0!==A.intersectsObject(i)||((e=function(){if(t===p){var e=new THREE.RenderableObject;return u.push(e),p++,t++,e}return u[t++]}()).id=i.id,e.object=i,w.setFromMatrixPosition(i.matrixWorld),w.applyProjection(L),e.z=w.z,b.objects.push(e))}}),!0===a&&b.objects.sort(N);for(var v=0,h=b.objects.length;v0)for(v=0;v=-1&&T.z<=1&&((c=O()).id=m.id,c.x=T.x*j,c.y=T.y*j,c.z=T.z,c.object=m,c.rotation=m.rotation,c.scale.x=m.scale.x*Math.abs(c.x-(T.x+n.projectionMatrix.elements[0])/(T.w+n.projectionMatrix.elements[12])),c.scale.y=m.scale.y*Math.abs(c.y-(T.y+n.projectionMatrix.elements[5])/(T.w+n.projectionMatrix.elements[13])),c.material=m.material,b.elements.push(c))}}return!0===f&&b.elements.sort(N),b}},THREE.TrackballControls=function(e,t,i){"use strict";var o=this;this.STATE={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4},this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.screen={left:0,top:0,width:0,height:0},this.rotateSpeed=1,this.zoomSpeed=1.2,this.panSpeed=.3,this.noRotate=!1,this.noZoom=!1,this.noPan=!1,this.noRoll=!1,this.staticMoving=!1,this.dynamicDampingFactor=.2,this.minDistance=0,this.maxDistance=1/0,this.keys=[65,83,68],this.target=new THREE.Vector3;var n=new THREE.Vector3;this._state=this.STATE.NONE;var r=this.STATE.NONE,a=new THREE.Vector3;this._rotateStart=new THREE.Vector3,this._rotateEnd=new THREE.Vector3,this._zoomStart=new THREE.Vector2,this._zoomEnd=new THREE.Vector2;var s=0,c=0;this._panStart=new THREE.Vector2,this._panEnd=new THREE.Vector2,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.up0=this.object.up.clone();var d={type:"change"},l={type:"start"},u={type:"end"};this.handleResize=function(){if(this.domElement===document)this.screen.left=0,this.screen.top=0,this.screen.width=window.innerWidth,this.screen.height=window.innerHeight;else{var e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}},this.handleEvent=function(e){"function"==typeof this[e.type]&&this[e.type](e)};var p,f,v,h,m,g,y,E,_,b=(p=new THREE.Vector2,function(e,t){return p.set((e-o.screen.left)/o.screen.width,(t-o.screen.top)/o.screen.height),p}),w=(f=new THREE.Vector3,v=new THREE.Vector3,h=new THREE.Vector3,function(e,t){h.set((e-.5*o.screen.width-o.screen.left)/(.5*o.screen.width),(.5*o.screen.height+o.screen.top-t)/(.5*o.screen.height),0);var i=h.length();return o.noRoll?i1?h.normalize():h.z=Math.sqrt(1-i*i),a.copy(o.object.position).sub(o.target),f.copy(o.object.up).setLength(h.y),f.add(v.copy(o.object.up).cross(a).setLength(h.x)),f.add(a.setLength(h.z)),f});function T(e){!1===o.enabled||Object.keys(window).length<2||(window.removeEventListener("keydown",T),r=o._state,o._state===o.STATE.NONE&&(e.keyCode!==o.keys[o.STATE.ROTATE]||o.noRotate?e.keyCode!==o.keys[o.STATE.ZOOM]||o.noZoom?e.keyCode!==o.keys[o.STATE.PAN]||o.noPan||(o._state=o.STATE.PAN):o._state=o.STATE.ZOOM:o._state=o.STATE.ROTATE))}function x(e){!1===o.enabled||Object.keys(window).length<2||(e.stopPropagation(),o._state!==o.STATE.ROTATE||o.noRotate?o._state!==o.STATE.ZOOM||o.noZoom?o._state!==o.STATE.PAN||o.noPan||o._panEnd.copy(b(e.pageX,e.pageY)):o._zoomEnd.copy(b(e.pageX,e.pageY)):o._rotateEnd.copy(w(e.pageX,e.pageY)))}function C(e){!1===o.enabled||Object.keys(window).length<2||(e.stopPropagation(),o._state=o.STATE.NONE,document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",C),o.dispatchEvent(u))}function R(e){if(!(!1===o.enabled||Object.keys(window).length<2)){e.stopPropagation();var t=0;e.wheelDelta?t=e.wheelDelta/40:e.detail&&(t=-e.detail/3),o._zoomStart.y=.005*t,o.dispatchEvent(l),o.dispatchEvent(u)}}this.rotateCamera=(m=new THREE.Vector3,g=new THREE.Quaternion,function(e,t){var n;void 0===e&&(n=Math.acos(o._rotateStart.dot(o._rotateEnd)/o._rotateStart.length()/o._rotateEnd.length())),(n||void 0!==e)&&(void 0===e?(m.crossVectors(o._rotateStart,o._rotateEnd).normalize(),n*=o.rotateSpeed,g.setFromAxisAngle(m,-n)):g.copy(e),void 0===i||void 0===i.quaternion||void 0!==t&&!0!==t||i.quaternion.multiplyQuaternions(g,i.quaternion),a.applyQuaternion(g),o.object.up.applyQuaternion(g),o._rotateEnd.applyQuaternion(g),o.staticMoving?o._rotateStart.copy(o._rotateEnd):(g.setFromAxisAngle(m,n*(o.dynamicDampingFactor-1)),o._rotateStart.applyQuaternion(g)))}),this.zoomCamera=function(e,t){var n;o._state===o.STATE.TOUCH_ZOOM_PAN?(void 0!==e?n=e:(n=s/c,s=c),a.multiplyScalar(n),void 0===i||void 0===i._zoomFactor||void 0!==t&&!0!==t||(i._zoomFactor*=n,i.fogCls.setFog())):(n=void 0!==e?e:1+(o._zoomEnd.y-o._zoomStart.y)*o.zoomSpeed,void 0===i||void 0===i._zoomFactor||void 0!==t&&!0!==t||(i._zoomFactor*=n,i.fogCls.setFog()),1!==n&&(a.multiplyScalar(n),o.staticMoving?o._zoomStart.copy(o._zoomEnd):o._zoomStart.y+=(o._zoomEnd.y-o._zoomStart.y)*this.dynamicDampingFactor))},this.panCamera=(y=new THREE.Vector2,E=new THREE.Vector3,_=new THREE.Vector3,function(e,t){void 0!==e?(y=e,void 0===i||void 0===i.mouseChange||void 0!==t&&!0!==t||i.mouseChange.add(e)):(y.copy(o._panEnd).sub(o._panStart),void 0===i||void 0===i.mouseChange||void 0!==t&&!0!==t||i.mouseChange.add(o._panEnd).sub(o._panStart)),y.lengthSq()&&(y.multiplyScalar(a.length()*o.panSpeed),_.copy(a).cross(o.object.up).setLength(y.x),_.add(E.copy(o.object.up).setLength(y.y)),o.object.position.add(_),o.target.add(_),o.staticMoving?o._panStart.copy(o._panEnd):o._panStart.add(y.subVectors(o._panEnd,o._panStart).multiplyScalar(o.dynamicDampingFactor)))}),this.checkDistances=function(){o.noZoom&&o.noPan||(a.lengthSq()>o.maxDistance*o.maxDistance&&o.object.position.addVectors(o.target,a.setLength(o.maxDistance)),a.lengthSq()1e-6&&(o.dispatchEvent(d),n.copy(o.object.position))},this.reset=function(){o._state=o.STATE.NONE,r=o.STATE.NONE,o.target.copy(o.target0),o.object.position.copy(o.position0),o.object.up.copy(o.up0),a.subVectors(o.object.position,o.target),o.object.lookAt(o.target),o.dispatchEvent(d),n.copy(o.object.position)},Object.keys(window).length>=2&&(this.domElement.addEventListener("contextmn",function(e){},!1),this.domElement.addEventListener("mousedown",function(e){!1===o.enabled||Object.keys(window).length<2||(e.stopPropagation(),o._state===o.STATE.NONE&&(o._state=e.button),o._state!==o.STATE.ROTATE||o.noRotate?o._state!==o.STATE.ZOOM||o.noZoom?o._state!==o.STATE.PAN||o.noPan||(o._panStart.copy(b(e.pageX,e.pageY)),o._panEnd.copy(o._panStart)):(o._zoomStart.copy(b(e.pageX,e.pageY)),o._zoomEnd.copy(o._zoomStart)):(o._rotateStart.copy(w(e.pageX,e.pageY)),o._rotateEnd.copy(o._rotateStart)),document.addEventListener("mousemove",x,!1),document.addEventListener("mouseup",C,!1),o.dispatchEvent(l))},!1),this.domElement.addEventListener("mousewheel",R,!1),this.domElement.addEventListener("DOMMouseScroll",R,!1),this.domElement.addEventListener("touchstart",function(e){if(!(!1===o.enabled||Object.keys(window).length<2)){switch(e.touches.length){case 1:o._state=o.STATE.TOUCH_ROTATE,o._rotateStart.copy(w(e.touches[0].pageX,e.touches[0].pageY)),o._rotateEnd.copy(o._rotateStart);break;case 2:o._state=o.STATE.TOUCH_ZOOM_PAN;var t=e.touches[0].pageX-e.touches[1].pageX,i=e.touches[0].pageY-e.touches[1].pageY;c=s=Math.sqrt(t*t+i*i);var n=(e.touches[0].pageX+e.touches[1].pageX)/2,r=(e.touches[0].pageY+e.touches[1].pageY)/2;o._panStart.copy(b(n,r)),o._panEnd.copy(o._panStart);break;default:o._state=o.STATE.NONE}o.dispatchEvent(l)}},!1),this.domElement.addEventListener("touchend",function(e){if(!(!1===o.enabled||Object.keys(window).length<2)){switch(e.touches.length){case 1:o._rotateEnd.copy(w(e.touches[0].pageX,e.touches[0].pageY)),o._rotateStart.copy(o._rotateEnd);break;case 2:s=c=0;var t=(e.touches[0].pageX+e.touches[1].pageX)/2,i=(e.touches[0].pageY+e.touches[1].pageY)/2;o._panEnd.copy(b(t,i)),o._panStart.copy(o._panEnd)}o._state=o.STATE.NONE,o.dispatchEvent(u)}},!1),this.domElement.addEventListener("touchmove",function(e){if(!(!1===o.enabled||Object.keys(window).length<2))switch(e.stopPropagation(),e.touches.length){case 1:o._rotateEnd.copy(w(e.touches[0].pageX,e.touches[0].pageY));break;case 2:var t=e.touches[0].pageX-e.touches[1].pageX,i=e.touches[0].pageY-e.touches[1].pageY;c=Math.sqrt(t*t+i*i);var n=(e.touches[0].pageX+e.touches[1].pageX)/2,r=(e.touches[0].pageY+e.touches[1].pageY)/2;o._panEnd.copy(b(n,r));break;default:o._state=o.STATE.NONE}},!1),Object.keys(window).length>=2&&window.addEventListener("keydown",T,!1),Object.keys(window).length>=2&&window.addEventListener("keyup",function(e){!1===o.enabled||Object.keys(window).length<2||(o._state=r,window.addEventListener("keydown",T,!1))},!1)),this.handleResize(),this.update()},THREE.TrackballControls.prototype=Object.create(THREE.EventDispatcher.prototype),THREE.TrackballControls.prototype.constructor=THREE.TrackballControls,THREE.OrthographicTrackballControls=function(e,t,i){this.icn3d;var o=this,n={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4};this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.screen={left:0,top:0,width:0,height:0},this.rotateSpeed=.5,this.zoomSpeed=1.2;this.zoomSpeed*=.01,this.panSpeed=.03,this.noRotate=!1,this.noZoom=!1,this.noPan=!1,this.noRoll=!1,this.staticMoving=!1,this.dynamicDampingFactor=.2,this.keys=[65,83,68],this.target=new THREE.Vector3;var r=new THREE.Vector3;this._state=n.NONE;var a=n.NONE,s=new THREE.Vector3;this._rotateStart=new THREE.Vector3,this._rotateEnd=new THREE.Vector3,this._zoomStart=new THREE.Vector2,this._zoomEnd=new THREE.Vector2;var c=1,d=0,l=0;this._panStart=new THREE.Vector2,this._panEnd=new THREE.Vector2,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.up0=this.object.up.clone(),this.left0=this.object.left,this.right0=this.object.right,this.top0=this.object.top,this.bottom0=this.object.bottom,this.center0=new THREE.Vector2((this.left0+this.right0)/2,(this.top0+this.bottom0)/2);var u={type:"change"},p={type:"start"},f={type:"end"};this.handleResize=function(){if(this.domElement===document)this.screen.left=0,this.screen.top=0,this.screen.width=window.innerWidth,this.screen.height=window.innerHeight;else{var e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}this.left0=this.object.left,this.right0=this.object.right,this.top0=this.object.top,this.bottom0=this.object.bottom,this.center0.set((this.left0+this.right0)/2,(this.top0+this.bottom0)/2)},this.handleEvent=function(e){"function"==typeof this[e.type]&&this[e.type](e)};var v,h,m,g,y,E,_,b,w,T=(v=new THREE.Vector2,function(e,t){return v.set((e-o.screen.left)/o.screen.width,(t-o.screen.top)/o.screen.height),v}),x=(h=new THREE.Vector3,m=new THREE.Vector3,g=new THREE.Vector3,function(e,t){g.set((e-.5*o.screen.width-o.screen.left)/(.5*o.screen.width),(.5*o.screen.height+o.screen.top-t)/(.5*o.screen.height),0);var i=g.length();return o.noRoll?i1?g.normalize():g.z=Math.sqrt(1-i*i),s.copy(o.object.position).sub(o.target),h.copy(o.object.up).setLength(g.y),h.add(m.copy(o.object.up).cross(s).setLength(g.x)),h.add(s.setLength(g.z)),h});function C(e){!1===o.enabled||Object.keys(window).length<2||(window.removeEventListener("keydown",C),a=o._state,o._state===n.NONE&&(e.keyCode!==o.keys[n.ROTATE]||o.noRotate?e.keyCode!==o.keys[n.ZOOM]||o.noZoom?e.keyCode!==o.keys[n.PAN]||o.noPan||(o._state=n.PAN):o._state=n.ZOOM:o._state=n.ROTATE))}function R(e){!1===o.enabled||Object.keys(window).length<2||(e.stopPropagation(),o._state!==n.ROTATE||o.noRotate?o._state!==n.ZOOM||o.noZoom?o._state!==n.PAN||o.noPan||o._panEnd.copy(T(e.pageX,e.pageY)):o._zoomEnd.copy(T(e.pageX,e.pageY)):o._rotateEnd.copy(x(e.pageX,e.pageY)))}function S(e){!1===o.enabled||Object.keys(window).length<2||(e.stopPropagation(),o._state=n.NONE,document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",S),o.dispatchEvent(f))}function L(e){if(!(!1===o.enabled||Object.keys(window).length<2)){e.stopPropagation();var t=0;e.wheelDelta?t=e.wheelDelta/40:e.detail&&(t=-e.detail/3),o._zoomStart.y=.01*t,o.dispatchEvent(p),o.dispatchEvent(f)}}this.rotateCamera=(y=new THREE.Vector3,E=new THREE.Quaternion,function(e,t){var n;void 0===e&&(n=Math.acos(o._rotateStart.dot(o._rotateEnd)/o._rotateStart.length()/o._rotateEnd.length())),(n||void 0!==e)&&(void 0===e?(y.crossVectors(o._rotateStart,o._rotateEnd).normalize(),n*=o.rotateSpeed,E.setFromAxisAngle(y,-n)):E.copy(e),void 0===i||void 0===i.quaternion||void 0!==t&&!0!==t||i.quaternion.multiplyQuaternions(E,i.quaternion),s.applyQuaternion(E),o.object.up.applyQuaternion(E),o._rotateEnd.applyQuaternion(E),o.staticMoving?o._rotateStart.copy(o._rotateEnd):(E.setFromAxisAngle(y,n*(o.dynamicDampingFactor-1)),o._rotateStart.applyQuaternion(E)))}),this.zoomCamera=function(e,t){var r;o._state===n.TOUCH_ZOOM_PAN?void 0!==e?r=e:(r=d/l,d=l):r=void 0!==e?e:1+(o._zoomEnd.y-o._zoomStart.y)*o.zoomSpeed/.01,void 0===i||void 0===i._zoomFactor||void 0!==t&&!0!==t||(i._zoomFactor*=r),1!==r&&(c=r,o.object.left=c*o.left0+(1-c)*o.center0.x,o.object.right=c*o.right0+(1-c)*o.center0.x,o.object.top=c*o.top0+(1-c)*o.center0.y,o.object.bottom=c*o.bottom0+(1-c)*o.center0.y,o.staticMoving?o._zoomStart.copy(o._zoomEnd):o._zoomStart.y+=(o._zoomEnd.y-o._zoomStart.y)*this.dynamicDampingFactor)},this.panCamera=(_=new THREE.Vector2,b=new THREE.Vector3,w=new THREE.Vector3,function(e,t){void 0!==e?(_=e,void 0===i||void 0===i.mouseChange||void 0!==t&&!0!==t||i.mouseChange.add(e)):(_.copy(o._panEnd).sub(o._panStart),void 0===i||void 0===i.mouseChange||void 0!==t&&!0!==t||i.mouseChange.add(o._panEnd).sub(o._panStart)),_.lengthSq()&&(_.multiplyScalar(s.length()*o.panSpeed),w.copy(s).cross(o.object.up).setLength(_.x),w.add(b.copy(o.object.up).setLength(_.y)),o.object.position.add(w),o.target.add(w),o.staticMoving?o._panStart.copy(o._panEnd):o._panStart.add(_.subVectors(o._panEnd,o._panStart).multiplyScalar(o.dynamicDampingFactor)))}),this.update=function(e){s.subVectors(o.object.position,o.target),o.noRotate||(void 0!==e&&void 0!==e.quaternion?o.rotateCamera(e.quaternion,e.update):o.rotateCamera()),o.noZoom||(void 0!==e&&void 0!==e._zoomFactor?o.zoomCamera(e._zoomFactor,e.update):o.zoomCamera(),o.object.updateProjectionMatrix()),o.noPan||(void 0!==e&&void 0!==e.mouseChange?o.panCamera(e.mouseChange,e.update):o.panCamera()),o.object.position.addVectors(o.target,s),o.object.lookAt(o.target),r.distanceToSquared(o.object.position)>1e-6&&(o.dispatchEvent(u),r.copy(o.object.position))},this.reset=function(){o._state=n.NONE,a=n.NONE,o.target.copy(o.target0),o.object.position.copy(o.position0),o.object.up.copy(o.up0),s.subVectors(o.object.position,o.target),o.object.left=o.left0,o.object.right=o.right0,o.object.top=o.top0,o.object.bottom=o.bottom0,o.object.lookAt(o.target),o.dispatchEvent(u),r.copy(o.object.position)},Object.keys(window).length>=2&&(this.domElement.addEventListener("contextmn",function(e){},!1),this.domElement.addEventListener("mousedown",function(e){!1===o.enabled||Object.keys(window).length<2||(e.stopPropagation(),o._state===n.NONE&&(o._state=e.button),o._state!==n.ROTATE||o.noRotate?o._state!==n.ZOOM||o.noZoom?o._state!==n.PAN||o.noPan||(o._panStart.copy(T(e.pageX,e.pageY)),o._panEnd.copy(o._panStart)):(o._zoomStart.copy(T(e.pageX,e.pageY)),o._zoomEnd.copy(o._zoomStart)):(o._rotateStart.copy(x(e.pageX,e.pageY)),o._rotateEnd.copy(o._rotateStart)),document.addEventListener("mousemove",R,!1),document.addEventListener("mouseup",S,!1),o.dispatchEvent(p))},!1),this.domElement.addEventListener("mousewheel",L,!1),this.domElement.addEventListener("DOMMouseScroll",L,!1),this.domElement.addEventListener("touchstart",function(e){if(!(!1===o.enabled||Object.keys(window).length<2)){switch(e.touches.length){case 1:o._state=n.TOUCH_ROTATE,o._rotateStart.copy(x(e.touches[0].pageX,e.touches[0].pageY)),o._rotateEnd.copy(o._rotateStart);break;case 2:o._state=n.TOUCH_ZOOM_PAN;var t=e.touches[0].pageX-e.touches[1].pageX,i=e.touches[0].pageY-e.touches[1].pageY;l=d=Math.sqrt(t*t+i*i);var r=(e.touches[0].pageX+e.touches[1].pageX)/2,a=(e.touches[0].pageY+e.touches[1].pageY)/2;o._panStart.copy(T(r,a)),o._panEnd.copy(o._panStart);break;default:o._state=n.NONE}o.dispatchEvent(p)}},!1),this.domElement.addEventListener("touchend",function(e){if(!(!1===o.enabled||Object.keys(window).length<2)){switch(e.touches.length){case 1:o._rotateEnd.copy(x(e.touches[0].pageX,e.touches[0].pageY)),o._rotateStart.copy(o._rotateEnd);break;case 2:d=l=0;var t=(e.touches[0].pageX+e.touches[1].pageX)/2,i=(e.touches[0].pageY+e.touches[1].pageY)/2;o._panEnd.copy(T(t,i)),o._panStart.copy(o._panEnd)}o._state=n.NONE,o.dispatchEvent(f)}},!1),this.domElement.addEventListener("touchmove",function(e){if(!(!1===o.enabled||Object.keys(window).length<2))switch(e.stopPropagation(),e.touches.length){case 1:o._rotateEnd.copy(x(e.touches[0].pageX,e.touches[0].pageY));break;case 2:var t=e.touches[0].pageX-e.touches[1].pageX,i=e.touches[0].pageY-e.touches[1].pageY;l=Math.sqrt(t*t+i*i);var r=(e.touches[0].pageX+e.touches[1].pageX)/2,a=(e.touches[0].pageY+e.touches[1].pageY)/2;o._panEnd.copy(T(r,a));break;default:o._state=n.NONE}},!1),window.addEventListener("keydown",C,!1),window.addEventListener("keyup",function(e){!1===o.enabled||Object.keys(window).length<2||(o._state=a,window.addEventListener("keydown",C,!1))},!1)),this.handleResize(),this.update()},THREE.OrthographicTrackballControls.prototype=Object.create(THREE.EventDispatcher.prototype),THREE.OrthographicTrackballControls.prototype.constructor=THREE.OrthographicTrackballControls;var MMTF={};function initIcn3dpyMMTF(e){function t(e,t,i){for(var o=(e.byteLength,0),n=i.length;n>o;o++){var r=i.charCodeAt(o);if(128>r)e.setUint8(t++,r>>>0&127|0);else if(2048>r)e.setUint8(t++,r>>>6&31|192),e.setUint8(t++,r>>>0&63|128);else if(65536>r)e.setUint8(t++,r>>>12&15|224),e.setUint8(t++,r>>>6&63|128),e.setUint8(t++,r>>>0&63|128);else{if(!(1114112>r))throw new Error("bad codepoint "+r);e.setUint8(t++,r>>>18&7|240),e.setUint8(t++,r>>>12&63|128),e.setUint8(t++,r>>>6&63|128),e.setUint8(t++,r>>>0&63|128)}}}function i(e){for(var t=0,i=0,o=e.length;o>i;i++){var n=e.charCodeAt(i);if(128>n)t+=1;else if(2048>n)t+=2;else if(65536>n)t+=3;else{if(!(1114112>n))throw new Error("bad codepoint "+n);t+=4}}return t}function o(e){var o=new ArrayBuffer(function e(t){var o=typeof t;if("string"===o){if(32>(n=i(t)))return 1+n;if(256>n)return 2+n;if(65536>n)return 3+n;if(4294967296>n)return 5+n}if(t instanceof Uint8Array){if(256>(n=t.byteLength))return 2+n;if(65536>n)return 3+n;if(4294967296>n)return 5+n}if("number"===o){if(Math.floor(t)!==t)return 9;if(t>=0){if(128>t)return 1;if(256>t)return 2;if(65536>t)return 3;if(4294967296>t)return 5;throw new Error("Number too big 0x"+t.toString(16))}if(t>=-32)return 1;if(t>=-128)return 2;if(t>=-32768)return 3;if(t>=-2147483648)return 5;throw new Error("Number too small -0x"+t.toString(16).substr(1))}if("boolean"===o||null===t)return 1;if("object"===o){var n,r=0;if(Array.isArray(t)){n=t.length;for(var a=0;n>a;a++)r+=e(t[a])}else{var s=Object.keys(t);for(n=s.length,a=0;n>a;a++){var c=s[a];r+=e(c)+e(t[c])}}if(16>n)return 1+r;if(65536>n)return 3+r;if(4294967296>n)return 5+r;throw new Error("Array or object too long 0x"+n.toString(16))}throw new Error("Unknown type "+o)}(e));return function e(o,n,r){var a=typeof o;if("string"===a){if(32>(s=i(o)))return n.setUint8(r,160|s),t(n,r+1,o),1+s;if(256>s)return n.setUint8(r,217),n.setUint8(r+1,s),t(n,r+2,o),2+s;if(65536>s)return n.setUint8(r,218),n.setUint16(r+1,s),t(n,r+3,o),3+s;if(4294967296>s)return n.setUint8(r,219),n.setUint32(r+1,s),t(n,r+5,o),5+s}if(o instanceof Uint8Array){var s=o.byteLength,c=new Uint8Array(n.buffer);if(256>s)return n.setUint8(r,196),n.setUint8(r+1,s),c.set(o,r+2),2+s;if(65536>s)return n.setUint8(r,197),n.setUint16(r+1,s),c.set(o,r+3),3+s;if(4294967296>s)return n.setUint8(r,198),n.setUint32(r+1,s),c.set(o,r+5),5+s}if("number"===a){if(!isFinite(o))throw new Error("Number not finite: "+o);if(Math.floor(o)!==o)return n.setUint8(r,203),n.setFloat64(r+1,o),9;if(o>=0){if(128>o)return n.setUint8(r,o),1;if(256>o)return n.setUint8(r,204),n.setUint8(r+1,o),2;if(65536>o)return n.setUint8(r,205),n.setUint16(r+1,o),3;if(4294967296>o)return n.setUint8(r,206),n.setUint32(r+1,o),5;throw new Error("Number too big 0x"+o.toString(16))}if(o>=-32)return n.setInt8(r,o),1;if(o>=-128)return n.setUint8(r,208),n.setInt8(r+1,o),2;if(o>=-32768)return n.setUint8(r,209),n.setInt16(r+1,o),3;if(o>=-2147483648)return n.setUint8(r,210),n.setInt32(r+1,o),5;throw new Error("Number too small -0x"+(-o).toString(16).substr(1))}if(null===o)return n.setUint8(r,192),1;if("boolean"===a)return n.setUint8(r,o?195:194),1;if("object"===a){var d=0,l=Array.isArray(o);if(l)s=o.length;else{var u=Object.keys(o);s=u.length}if(16>s?(n.setUint8(r,s|(l?144:128)),d=1):65536>s?(n.setUint8(r,l?220:222),n.setUint16(r+1,s),d=3):4294967296>s&&(n.setUint8(r,l?221:223),n.setUint32(r+1,s),d=5),l)for(var p=0;s>p;p++)d+=e(o[p],n,r+d);else for(p=0;s>p;p++){var f=u[p];d+=e(f,n,r+d),d+=e(o[f],n,r+d)}return d}throw new Error("Unknown type "+a)}(e,new DataView(o),0),new Uint8Array(o)}function n(e,t,i){return t?new e(t.buffer,t.byteOffset,t.byteLength/(i||1)):void 0}function r(e){return n(DataView,e)}function a(e){return n(Uint8Array,e)}function s(e){return n(Int8Array,e)}function c(e){return n(Int32Array,e,4)}function d(e,t){var i=e.length/2;t||(t=new Int16Array(i));for(var o=0,n=0;i>o;++o,n+=2)t[o]=e[n]<<8^e[n+1]<<0;return t}function l(e,t){var i=e.length/4;t||(t=new Int32Array(i));for(var o=0,n=0;i>o;++o,n+=4)t[o]=e[n]<<24^e[n+1]<<16^e[n+2]<<8^e[n+3]<<0;return t}function u(e,t){var i=e.length;t||(t=new Uint8Array(4*i));for(var o=r(t),n=0;i>n;++n)o.setInt32(4*n,e[n]);return a(t)}function p(e,t,i){var o=e.length,n=1/t;i||(i=new Float32Array(o));for(var r=0;o>r;++r)i[r]=e[r]*n;return i}function f(e,t,i){var o=e.length;i||(i=new Int32Array(o));for(var n=0;o>n;++n)i[n]=Math.round(e[n]*t);return i}function v(e,t){var i,o;if(!t){var n=0;for(i=0,o=e.length;o>i;i+=2)n+=e[i+1];t=new e.constructor(n)}var r=0;for(i=0,o=e.length;o>i;i+=2)for(var a=e[i],s=e[i+1],c=0;s>c;++c)t[r]=a,++r;return t}function h(e){if(0===e.length)return new Int32Array;var t,i,o=2;for(t=1,i=e.length;i>t;++t)e[t-1]!==e[t]&&(o+=2);var n=new Int32Array(o),r=0,a=1;for(t=1,i=e.length;i>t;++t)e[t-1]!==e[t]?(n[r]=e[t-1],n[r+1]=a,a=1,r+=2):++a;return n[r]=e[e.length-1],n[r+1]=a,n}function m(e,t){var i=e.length;t||(t=new e.constructor(i)),i&&(t[0]=e[0]);for(var o=1;i>o;++o)t[o]=e[o]+t[o-1];return t}function g(e,t){var i=e.length;t||(t=new e.constructor(i)),t[0]=e[0];for(var o=1;i>o;++o)t[o]=e[o]-e[o-1];return t}function y(e,t){var i,o,n=e instanceof Int8Array?127:32767,r=-n-1,a=e.length;if(!t){var s=0;for(i=0;a>i;++i)e[i]r&&++s;t=new Int32Array(s)}for(i=0,o=0;a>i;){for(var c=0;e[i]===n||e[i]===r;)c+=e[i],++i;c+=e[i],++i,t[o]=c,++o}return t}function E(e,t,i){return p(y(e,c(i)),t,i)}function _(e,t,i){var o,r,a,s=y(e,c(i));return o=s,r=t,a=n(Float32Array,s,4),p(m(o,c(a)),r,a)}function b(e,t,i){return function(e,t){var i,o=t?127:32767,n=-o-1,r=e.length,a=0;for(i=0;r>i;++i)0===(d=e[i])?++a:d>0?(a+=Math.ceil(d/o),d%o==0&&(a+=1)):(a+=Math.ceil(d/n),d%n==0&&(a+=1));var s=t?new Int8Array(a):new Int16Array(a),c=0;for(i=0;r>i;++i){var d;if((d=e[i])>=0)for(;d>=o;)s[c]=o,++c,d-=o;else for(;n>=d;)s[c]=n,++c,d-=n;s[c]=d,++c}return s}(g(f(e,t),o),i);var o}function w(e,t,i,o){var n=new ArrayBuffer(12+o.byteLength),r=new Uint8Array(n),a=new DataView(n);return a.setInt32(0,e),a.setInt32(4,t),i&&r.set(i,8),r.set(o,12),r}function T(e){return w(2,e.length,void 0,a(e))}function x(e){return w(4,e.length,void 0,u(e))}function C(e,t){return w(5,e.length/t,u([t]),a(e))}function R(e){return w(6,e.length,void 0,u(h(e)))}function S(e){return w(8,e.length,void 0,u(h(g(e))))}function L(e,t){return w(9,e.length,u([t]),u(h(f(e,t))))}function A(e,t){return w(10,e.length,u([t]),function(e,t){var i=e.length;t||(t=new Uint8Array(2*i));for(var o=r(t),n=0;i>n;++n)o.setInt16(2*n,e[n]);return a(t)}(b(e,t)))}function I(e){var t={};return D.forEach(function(i){void 0!==e[i]&&(t[i]=e[i])}),e.bondAtomList&&(t.bondAtomList=x(e.bondAtomList)),e.bondOrderList&&(t.bondOrderList=T(e.bondOrderList)),t.xCoordList=A(e.xCoordList,1e3),t.yCoordList=A(e.yCoordList,1e3),t.zCoordList=A(e.zCoordList,1e3),e.bFactorList&&(t.bFactorList=A(e.bFactorList,100)),e.atomIdList&&(t.atomIdList=S(e.atomIdList)),e.altLocList&&(t.altLocList=R(e.altLocList)),e.occupancyList&&(t.occupancyList=L(e.occupancyList,100)),t.groupIdList=S(e.groupIdList),t.groupTypeList=x(e.groupTypeList),e.secStructList&&(t.secStructList=T(e.secStructList)),e.insCodeList&&(t.insCodeList=R(e.insCodeList)),e.sequenceIndexList&&(t.sequenceIndexList=S(e.sequenceIndexList)),t.chainIdList=C(e.chainIdList,4),e.chainNameList&&(t.chainNameList=C(e.chainNameList,4)),t}function O(e){function t(e){for(var t={},i=0;e>i;i++){t[r()]=r()}return t}function i(t){var i=e.subarray(a,a+t);return a+=t,i}function o(t){var i=e.subarray(a,a+t);a+=t;if(t>65535){for(var o=[],n=0;ni;i++)t[i]=r();return t}function r(){var r,c,d=e[a];if(0==(128&d))return a++,d;if(128==(240&d))return a++,t(c=15&d);if(144==(240&d))return a++,n(c=15&d);if(160==(224&d))return a++,o(c=31&d);if(224==(224&d))return r=s.getInt8(a),a++,r;switch(d){case 192:return a++,null;case 194:return a++,!1;case 195:return a++,!0;case 196:return c=s.getUint8(a+1),a+=2,i(c);case 197:return c=s.getUint16(a+1),a+=3,i(c);case 198:return c=s.getUint32(a+1),a+=5,i(c);case 202:return r=s.getFloat32(a+1),a+=5,r;case 203:return r=s.getFloat64(a+1),a+=9,r;case 204:return r=e[a+1],a+=2,r;case 205:return r=s.getUint16(a+1),a+=3,r;case 206:return r=s.getUint32(a+1),a+=5,r;case 208:return r=s.getInt8(a+1),a+=2,r;case 209:return r=s.getInt16(a+1),a+=3,r;case 210:return r=s.getInt32(a+1),a+=5,r;case 217:return c=s.getUint8(a+1),a+=2,o(c);case 218:return c=s.getUint16(a+1),a+=3,o(c);case 219:return c=s.getUint32(a+1),a+=5,o(c);case 220:return c=s.getUint16(a+1),a+=3,n(c);case 221:return c=s.getUint32(a+1),a+=5,n(c);case 222:return c=s.getUint16(a+1),a+=3,t(c);case 223:return c=s.getUint32(a+1),a+=5,t(c)}throw new Error("Unknown type 0x"+d.toString(16))}var a=0,s=new DataView(e.buffer);return r()}function N(e,t,i,o){switch(e){case 1:return function(e,t){var i=e.length;t||(t=new Float32Array(i/4));for(var o=r(t),n=r(e),a=0,s=0,c=i/4;c>a;++a,s+=4)o.setFloat32(s,n.getFloat32(s),!0);return t}(t);case 2:return s(t);case 3:return d(t);case 4:return l(t);case 5:return a(t);case 6:return v(l(t),new Uint8Array(i));case 7:return v(l(t));case 8:return m(v(l(t)),h);case 9:return n=l(t),u=l(o)[0],p(v(n,c(f)),u,f);case 10:return _(d(t),l(o)[0]);case 11:return p(d(t),l(o)[0]);case 12:return E(d(t),l(o)[0]);case 13:return E(s(t),l(o)[0]);case 14:return y(d(t));case 15:return y(s(t))}var n,u,f,h}function P(e,t){var i=(t=t||{}).ignoreFields,o={};return j.forEach(function(t){var n,a,s,c,d,l=!!i&&-1!==i.indexOf(t),u=e[t];l||void 0===u||(u instanceof Uint8Array?o[t]=N.apply(null,(a=r(n=u),s=a.getInt32(0),c=a.getInt32(4),d=n.subarray(8,12),[s,n=n.subarray(12),c,d])):o[t]=u)}),o}function M(e){return String.fromCharCode.apply(null,e).replace(/\0/g,"")}function H(e,t){return e instanceof ArrayBuffer&&(e=new Uint8Array(e)),P(e instanceof Uint8Array?O(e):e,t)}function z(e,t,i,o){var n=new XMLHttpRequest;n.addEventListener("load",function(){try{var e=H(n.response);i(e)}catch(e){o(e)}},!0),n.addEventListener("error",o,!0),n.responseType="arraybuffer",n.open("GET",t+e.toUpperCase()),n.send()}var D=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"],j=D.concat(["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"]),F="//mmtf.rcsb.org/v1.0/",V=F+"full/",U=F+"reduced/";return e.encode=function(e){return o(I(e))},e.decode=H,e.traverse=function(e,t,i){var o,n,r,a,s,c,d=(i=i||{}).firstModelOnly,l=t.onModel,u=t.onChain,p=t.onGroup,f=t.onAtom,v=t.onBond,h=0,m=0,g=0,y=0,E=0,_=-1,b=e.chainNameList,w=e.secStructList,T=e.insCodeList,x=e.sequenceIndexList,C=e.atomIdList,R=e.bFactorList,S=e.altLocList,L=e.occupancyList,A=e.bondAtomList,I=e.bondOrderList;for(o=0,n=e.chainsPerModel.length;n>o&&!(d&&h>0);++o){var O=e.chainsPerModel[h];for(l&&l({chainCount:O,modelIndex:h}),r=0;O>r;++r){var N=e.groupsPerChain[m];if(u){var P=M(e.chainIdList.subarray(4*m,4*m+4)),H=null;b&&(H=M(b.subarray(4*m,4*m+4))),u({groupCount:N,chainIndex:m,modelIndex:h,chainId:P,chainName:H})}for(a=0;N>a;++a){var z=e.groupList[e.groupTypeList[g]],D=z.atomNameList.length;if(p){var j=null;w&&(j=w[g]);var F=null;e.insCodeList&&(F=String.fromCharCode(T[g]));var V=null;x&&(V=x[g]),p({atomCount:D,groupIndex:g,chainIndex:m,modelIndex:h,groupId:e.groupIdList[g],groupType:e.groupTypeList[g],groupName:z.groupName,singleLetterCode:z.singleLetterCode,chemCompType:z.chemCompType,secStruct:j,insCode:F,sequenceIndex:V})}for(s=0;D>s;++s){if(f){var U=null;C&&(U=C[y]);var k=null;R&&(k=R[y]);var G=null;S&&(G=String.fromCharCode(S[y]));var B=null;L&&(B=L[y]),f({atomIndex:y,groupIndex:g,chainIndex:m,modelIndex:h,atomId:U,element:z.elementList[s],atomName:z.atomNameList[s],formalCharge:z.formalChargeList[s],xCoord:e.xCoordList[y],yCoord:e.yCoordList[y],zCoord:e.zCoordList[y],bFactor:k,altLoc:G,occupancy:B})}y+=1}if(v){var X=z.bondAtomList;for(s=0,c=z.bondOrderList.length;c>s;++s)v({atomIndex1:y-D+X[2*s],atomIndex2:y-D+X[2*s+1],bondOrder:z.bondOrderList[s]})}g+=1}m+=1}if(E=_+1,_=y-1,v&&A)for(s=0,c=A.length;c>s;s+=2){var q=A[s],W=A[s+1];(q>=E&&_>=q||W>=E&&_>=W)&&v({atomIndex1:q,atomIndex2:W,bondOrder:I?I[s/2]:null})}h+=1}},e.fetch=function(e,t,i){z(e,V,t,i)},e.fetchReduced=function(e,t,i){z(e,U,t,i)},e.version="v1.0.1",e.fetchUrl=V,e.fetchReducedUrl=U,e.encodeMsgpack=o,e.encodeMmtf=I,e.decodeMsgpack=O,e.decodeMmtf=P,e}MMTF=initIcn3dpyMMTF(MMTF),function(e,t,i){var o,n="__instance__",r="firstChild",a=setTimeout;function s(e){return void 0!==e}function c(e){return"object"==typeof e}function d(e){return Object.keys(e).length}function l(e,t,i){return ei?i:e}function u(e,t){return parseInt(e,t||10)}function p(e){return Math.round(e)}function f(e){var t,i,o,n,r,a,s,c,d=+e[0],l=+e[1],u=+e[2];switch(a=u*(1-l),s=u*(1-(r=6*d-(n=Math.floor(6*d)))*l),c=u*(1-(1-r)*l),n=n||0,s=s||0,c=c||0,n%6){case 0:t=u,i=c,o=a;break;case 1:t=s,i=u,o=a;break;case 2:t=a,i=u,o=c;break;case 3:t=a,i=s,o=u;break;case 4:t=c,i=a,o=u;break;case 5:t=u,i=a,o=s}return[p(255*t),p(255*i),p(255*o)]}function v(e){return m(f(e))}function h(e){var t,i=+e[0],o=+e[1],n=+e[2],r=Math.max(i,o,n),a=Math.min(i,o,n),s=r-a,c=0===r?0:s/r,d=r/255;switch(r){case a:t=0;break;case i:t=o-n+s*(o
';var H,z=_[r].children,D=N([0,1,1]),j=z[0],F=z[1],V=j[r],U=F[r],k=0,G=0,B=0,X=0,q=0,W=0,Y=0,Z=0,Q=v(D);function K(e,t){e&&"h"!==e||M("change:h",t),e&&"sv"!==e||M("change:sv",t),M("change",t)}function $(){return _.parentNode}function J(n,r){n||((u||r||p).appendChild(_),m.visible=!0),Y=O(_).w,Z=O(_).h;var a=O(F),s=O(U),c=O(j).h,d=a.w,h=a.h,g=O(V).h,y=s.w,E=s.h;if(n){function L(e){var t=e.target,o=t===i||A(t,i)===i;o?J():m.exit(),M(o?"enter":"exit",[m])}_.style.left=_.style.top="-9999px",!1!==o&&C(o,i,L),m.create=function(){return J(1),M("create",[m]),m},m.destroy=function(){return!1!==o&&R(o,i,L),m.exit(),P(!1),M("destroy",[m]),m}}else ee();function z(e){f(D);var t=f([D[0],1,1]);F.style.backgroundColor="rgb("+t.join(",")+")",P(D),I(e)}function q(e){var t,i,o,n,r,a;B&&(i=l(S(j,t=e).y,0,c),D[0]=(c-i)/c,V.style.top=i-g/2+"px",z(t),Q=v(D),k||(M("drag:h",[Q,m]),M("drag",[Q,m]),K("h",[Q,m]))),X&&(n=S(F,o=e),r=l(n.x,0,d),a=l(n.y,0,h),D[1]=1-(d-r)/d,D[2]=(h-a)/h,U.style.right=d-r-y/2+"px",U.style.top=a-E/2+"px",z(o),Q=v(D),G||(M("drag:sv",[Q,m]),M("drag",[Q,m]),K("sv",[Q,m]))),k=0,G=0}function W(e){var t=e.target,n=B?"h":"sv",r=[v(D),m],a=t===i||A(t,i)===i,s=t===_||A(t,_)===_;a||s?s&&(M("stop:"+n,r),M("stop",r),K(n,r)):$()&&!1!==o&&(m.exit(),M("exit",[m]),K(0,r)),B=0,X=0}function te(e){k=1,B=1,q(e),I(e),M("start:h",[Q,m]),M("start",[Q,m]),K("h",[Q,m])}function ie(e){G=1,X=1,q(e),I(e),M("start:sv",[Q,m]),M("start",[Q,m]),K("sv",[Q,m])}H=function(){D=N(D),z(),V.style.top=c-g/2-c*+D[0]+"px",U.style.right=d-y/2-d*+D[1]+"px",U.style.top=h-E/2-h*+D[2]+"px"},m.exit=function(i){return $()&&($().removeChild(_),m.visible=!1),R(b,j,te),R(b,F,ie),R(w,t,q),R(T,t,W),R(x,e,ee),m},H(),n||(C(b,j,te),C(b,F,ie),C(w,t,q),C(T,t,W),C(x,e,ee))}function ee(){return m.fit()}return J(1),a(function(){var e=[v(D),m];M("create",e),K(0,e)},0),m.fit=function(t){var o=O(e),n=O(h),r=o.w-n.w,a=o.h-h.clientHeight,d=L(e),u=L(i);if(q=u.l+d.l,W=u.t+d.t+O(i).h,c(t))s(t[0])&&(q=t[0]),s(t[1])&&(W=t[1]);else{var p=d.l,f=d.t,v=d.l+o.w-Y-r,g=d.t+o.h-Z-a;q=l(q,p,v)>>0,W=l(W,f,g)>>0}return _.style.left=q+"px",_.style.top=W+"px",M("fit",[m]),m},m.set=function(e){return s(e)?("string"==typeof e&&(e=g.parse(e)),P(e),H(),m):N()},m.get=function(e){return N(e)},m.target=i,m.picker=_,m.visible=!1,m.on=function(e,t,i){return s(e)?s(t)?(s(E[e])||(E[e]={}),s(i)||(i=d(E[e])),E[e][i]=t,m):E[e]:E},m.off=function(e,t){return s(e)?s(t)?(delete E[e][t],m):(E[e]={},m):(E={},m)},m.fire=M,m.hooks=E,m.enter=function(e){return J(0,e)},m}).version="1.3.9",o[n]={},o.each=function(e,t){return a(function(){var t,i=o[n];for(t in i)e(i[t],t,i)},0===t?0:t||1),o},o.parse=b,o._HSV2RGB=f,o._HSV2HEX=v,o._RGB2HSV=h,o._HEX2HSV=g,o._HEX2RGB=function(e){return[+(t=y(e))[0]/255,+t[1]/255,+t[2]/255];var t},o.HSV2RGB=function(e){return f(E(e))},o.HSV2HEX=function(e){return v(E(e))},o.RGB2HSV=function(e){return _(h(e))},o.RGB2HEX=m,o.HEX2HSV=function(e){return _(g(e))},o.HEX2RGB=y}(window,document);var saveAs=function(e){"use strict";if(!(void 0===e||"undefined"!=typeof navigator&&/MSIE [1-9]\./.test(navigator.userAgent))){var t=function(){return e.URL||e.webkitURL||e},i=e.document.createElementNS("http://www.w3.org/1999/xhtml","a"),o="download"in i,n=/constructor/i.test(e.HTMLElement)||e.safari,r=/CriOS\/[\d]+/.test(navigator.userAgent),a=e.setImmediate||e.setTimeout,s=function(e){a(function(){throw e},0)},c=function(e){setTimeout(function(){"string"==typeof e?t().revokeObjectURL(e):e.remove()},4e4)},d=function(e){return/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob([String.fromCharCode(65279),e],{type:e.type}):e},l=function(l,u,p){p||(l=d(l));var f,v=this,h="application/octet-stream"===(l?l.type:void 0),m=function(){!function(e,t,i){for(var o=(t=[].concat(t)).length;o--;){var n=e["on"+t[o]];if("function"==typeof n)try{n.call(e,i||e)}catch(e){s(e)}}}(v,"writestart progress write writeend".split(" "))};if(v.readyState=v.INIT,o)return f||(f=t().createObjectURL(l)),void a(function(){var e,t;i.href=f,i.download=u,e=i,t=new MouseEvent("click"),e.dispatchEvent(t),m(),c(f),v.readyState=v.DONE},0);!function(){if((r||h&&n)&&e.FileReader){var i=new FileReader;return i.onloadend=function(){var t=r?i.result:i.result.replace(/^data:[^;]*;/,"data:attachment/file;");e.open(t,"_blank")||(e.location.href=t),t=void 0,v.readyState=v.DONE,m()},i.readAsDataURL(l),void(v.readyState=v.INIT)}f||(f=t().createObjectURL(l)),h?e.location.href=f:e.open(f,"_blank")||(e.location.href=f);v.readyState=v.DONE,m(),c(f)}()},u=l.prototype;return"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(e,t,i){return t=t||e.name||"download",i||(e=d(e)),navigator.msSaveOrOpenBlob(e,t)}:(u.abort=function(){},u.readyState=u.INIT=0,u.WRITING=1,u.DONE=2,u.error=u.onwritestart=u.onprogress=u.onwrite=u.onabort=u.onerror=u.onwriteend=null,function(e,t,i){return new l(e,t||e.name||"download",i)})}}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this);!function(e){"use strict";var t=e.HTMLCanvasElement&&e.HTMLCanvasElement.prototype,i=e.Blob&&function(){try{return Boolean(new Blob)}catch(e){return!1}}(),o=i&&e.Uint8Array&&function(){try{return 100===new Blob([new Uint8Array(100)]).size}catch(e){return!1}}(),n=e.BlobBuilder||e.WebKitBlobBuilder||e.MozBlobBuilder||e.MSBlobBuilder,r=/^data:((.*?)(;charset=.*?)?)(;base64)?,/,a=(i||n)&&e.atob&&e.ArrayBuffer&&e.Uint8Array&&function(e){var t,a,s,c,d,l,u,p,f;if(!(t=e.match(r)))throw new Error("invalid data URI");for(a=t[2]?t[1]:"text/plain"+(t[3]||";charset=US-ASCII"),s=!!t[4],c=e.slice(t[0].length),d=s?atob(c):decodeURIComponent(c),l=new ArrayBuffer(d.length),u=new Uint8Array(l),p=0;p0||window.navigator.userAgent.match(/Trident.*rv\:11\./))}isMobile(){return this.icn3dui,/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)}isMac(){return this.icn3dui,/Mac/i.test(window.navigator.userAgent)}isAndroid(){return this.icn3dui,/android/i.test(window.navigator.userAgent.toLowerCase())}isChrome(){return this.icn3dui,navigator.userAgent.includes("Chrome")&&navigator.vendor.includes("Google Inc")}isSessionStorageSupported(){return this.icn3dui,window.sessionStorage}isLocalStorageSupported(){return this.icn3dui,window.localStorage}hexToRgb(e,t){this.icn3dui;let s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return s?{r:parseInt(s[1],16),g:parseInt(s[2],16),b:parseInt(s[3],16),a:t}:null}isCalphaPhosOnly(e){this.icn3dui;let t=!1,s=0,i=0;for(let t in e){if(!(s<100))break;{let s=e[t].name.trim();"CA"!==s&&"P"!==s&&"O3'"!==s&&"O3*"!==s&&++i}++s}return i<.5*s&&(t=!0),t}hasCovalentBond(e,t){let s=this.icn3dui,i=s.parasCls.covalentRadii[e.elem.toUpperCase()]+s.parasCls.covalentRadii[t.elem.toUpperCase()],n=e.coord.x-t.coord.x,l=e.coord.y-t.coord.y,r=e.coord.z-t.coord.z;return n*n+l*l+r*r<("N"==e.elem&&"H"==t.elem.substr(0,1)||"N"==t.elem&&"H"==e.elem.substr(0,1)?2.2:1.3)*i*i}residueName2Abbr(e){this.icn3dui;let t=e.indexOf(" ");switch(t>0&&(e=e.substr(0,t)),e){case" A":case" DA":case"DA":case"ALA":return"A";case" C":case" DC":case"DC":case"CYS":return"C";case" G":case" DG":case"DG":case"GLY":return"G";case" T":case" DT":case"DT":case"THR":return"T";case" U":case" DU":case"DU":case"SEC":return"U";case" I":case" DI":case"DI":case"ILE":return"I";case"ARG":return"R";case"ASN":return"N";case"ASP":return"D";case"GLU":return"E";case"GLN":return"Q";case"HIS":return"H";case"LEU":return"L";case"LYS":return"K";case"MET":return"M";case"PHE":return"F";case"PRO":return"P";case"SER":return"S";case"TRP":return"W";case"TYR":return"Y";case"VAL":return"V";case"HOH":case"WAT":return"O";default:return e.trim()}}residueAbbr2Name(e){if(this.icn3dui,(e=e.toUpperCase()).length>1)return e;switch(e){case"A":return"ALA";case"R":return"ARG";case"N":return"ASN";case"D":return"ASP";case"C":return"CYS";case"E":return"GLU";case"Q":return"GLN";case"G":return"GLY";case"H":return"HIS";case"I":return"ILE";case"L":return"LEU";case"K":return"LYS";case"M":return"MET";case"F":return"PHE";case"P":return"PRO";case"S":return"SER";case"T":return"THR";case"W":return"TRP";case"Y":return"TYR";case"V":return"VAL";case"O":return"HOH";default:return e.trim()}}getJSONFromArray(e){this.icn3dui;let t="";for(let s=0,i=e.length;sd?1:ah?1:cs&&(e.htmlCls.WIDTH=s),i&&e.htmlCls.HEIGHT>i&&(e.htmlCls.HEIGHT=i)}sumArray(e){let t=0;for(let s=0,i=e.length;sRed and blue membranes indicate extracellular and intracellular membranes, respectively.

"}}class i{constructor(e){this.icn3dui=e,this.glycanHash={GLC:{c:"1E90FF",s:"sphere"},BGC:{c:"1E90FF",s:"sphere"},NAG:{c:"1E90FF",s:"cube"},NDG:{c:"1E90FF",s:"cube"},GCS:{c:"1E90FF",s:"cube"},PA1:{c:"1E90FF",s:"cube"},GCU:{c:"1E90FF",s:"cone"},BDP:{c:"1E90FF",s:"cone"},G6D:{c:"1E90FF",s:"cone"},DDA:{c:"1E90FF",s:"cylinder"},B6D:{c:"1E90FF",s:"cylinder"},XXM:{c:"1E90FF",s:"cylinder"},MAN:{c:"00FF00",s:"sphere"},BMA:{c:"00FF00",s:"sphere"},BM3:{c:"00FF00",s:"cube"},"95Z":{c:"00FF00",s:"cube"},MAV:{c:"00FF00",s:"cone"},BEM:{c:"00FF00",s:"cone"},RAM:{c:"00FF00",s:"cone"},RM4:{c:"00FF00",s:"cone"},TYV:{c:"00FF00",s:"cylinder"},ARA:{c:"00FF00",s:"cylinder"},ARB:{c:"00FF00",s:"cylinder"},KDN:{c:"00FF00",s:"cylinder"},KDM:{c:"00FF00",s:"cylinder"},"6PZ":{c:"00FF00",s:"cylinder"},GMH:{c:"00FF00",s:"cylinder"},BDF:{c:"00FF00",s:"cylinder"},GAL:{c:"FFFF00",s:"sphere"},GLA:{c:"FFFF00",s:"sphere"},NGA:{c:"FFFF00",s:"cube"},A2G:{c:"FFFF00",s:"cube"},X6X:{c:"FFFF00",s:"cube"},"1GN":{c:"FFFF00",s:"cube"},ADA:{c:"FFFF00",s:"cone"},GTR:{c:"FFFF00",s:"cone"},LDY:{c:"FFFF00",s:"cylinder"},KDO:{c:"FFFF00",s:"cylinder"},T6T:{c:"FFFF00",s:"cylinder"},GUP:{c:"A52A2A",s:"sphere"},GL0:{c:"A52A2A",s:"sphere"},LGU:{c:"A52A2A",s:"cone"},ABE:{c:"A52A2A",s:"cylinder"},XYS:{c:"A52A2A",s:"cylinder"},XYP:{c:"A52A2A",s:"cylinder"},SOE:{c:"A52A2A",s:"cylinder"},PZU:{c:"FF69B4",s:"cylinder"},RIP:{c:"FF69B4",s:"cylinder"},"0MK":{c:"FF69B4",s:"cylinder"},ALL:{c:"8A2BE2",s:"sphere"},AFD:{c:"8A2BE2",s:"sphere"},NAA:{c:"8A2BE2",s:"cube"},SIA:{c:"8A2BE2",s:"cylinder"},SIB:{c:"8A2BE2",s:"cylinder"},AMU:{c:"8A2BE2",s:"cylinder"},X0X:{c:"1E90FF",s:"cone"},X1X:{c:"1E90FF",s:"cone"},NGC:{c:"1E90FF",s:"cylinder"},NGE:{c:"1E90FF",s:"cylinder"},"4N2":{c:"A0522D",s:"sphere"},HSQ:{c:"A0522D",s:"cube"},IDR:{c:"A0522D",s:"cone"},MUR:{c:"A0522D",s:"cylinder"},FUC:{c:"FF0000",s:"cone"},FUL:{c:"FF0000",s:"cone"}},this.nucleotidesArray=[" G"," A"," T"," C"," U"," DG"," DA"," DT"," DC"," DU","G","A","T","C","U","DG","DA","DT","DC","DU"],this.ionsArray=[" K"," NA"," MG"," AL"," CA"," TI"," MN"," FE"," NI"," CU"," ZN"," AG"," BA"," F"," CL"," BR"," I","K","NA","MG","AL","CA","TI","MN","FE","NI","CU","ZN","AG","BA","F","CL","BR","I"],this.cationsTrimArray=["K","NA","MG","AL","CA","TI","MN","FE","NI","CU","ZN","AG","BA"],this.anionsTrimArray=["F","CL","BR","I"],this.ionCharges={K:1,NA:1,MG:2,AL:3,CA:2,TI:3,MN:2,FE:3,NI:2,CU:2,ZN:2,AG:1,BA:2},this.vdwRadii={H:1.08,HE:1.34,LI:1.75,BE:2.05,B:1.47,C:1.49,N:1.41,O:1.4,F:1.39,NE:1.68,NA:1.84,MG:2.05,AL:2.11,SI:2.07,P:1.92,S:1.82,CL:1.83,AR:1.93,K:2.05,CA:2.21,SC:2.16,TI:1.87,V:1.79,CR:1.89,MN:1.97,FE:1.94,CO:1.92,NI:1.84,CU:1.86,ZN:2.1,GA:2.08,GE:2.15,AS:2.06,SE:1.93,BR:1.98,KR:2.12,RB:2.16,SR:2.24,Y:2.19,ZR:1.86,NB:2.07,MO:2.09,TC:2.09,RU:2.07,RH:1.95,PD:2.02,AG:2.03,CD:2.3,IN:2.36,SN:2.33,SB:2.25,TE:2.23,I:2.23,XE:2.21,CS:2.22,BA:2.51,LA:2.4,CE:2.35,PR:2.39,ND:2.29,PM:2.36,SM:2.29,EU:2.33,GD:2.37,TB:2.21,DY:2.29,HO:2.16,ER:2.35,TM:2.27,YB:2.42,LU:2.21,HF:2.12,TA:2.17,W:2.1,RE:2.17,OS:2.16,IR:2.02,PT:2.09,AU:2.17,HG:2.09,TL:2.35,PB:2.32,BI:2.43,PO:2.29,AT:2.36,RN:2.43,FR:2.56,RA:2.43,AC:2.6,TH:2.37,PA:2.43,U:2.4,NP:2.21,PU:2.56,AM:2.56,CM:2.56,BK:2.56,CF:2.56,ES:2.56,FM:2.56},this.covalentRadii={H:.31,HE:.28,LI:1.28,BE:.96,B:.84,C:.76,N:.71,O:.66,F:.57,NE:.58,NA:1.66,MG:1.41,AL:1.21,SI:1.11,P:1.07,S:1.05,CL:1.02,AR:1.06,K:2.03,CA:1.76,SC:1.7,TI:1.6,V:1.53,CR:1.39,MN:1.39,FE:1.32,CO:1.26,NI:1.24,CU:1.32,ZN:1.22,GA:1.22,GE:1.2,AS:1.19,SE:1.2,BR:1.2,KR:1.16,RB:2.2,SR:1.95,Y:1.9,ZR:1.75,NB:1.64,MO:1.54,TC:1.47,RU:1.46,RH:1.42,PD:1.39,AG:1.45,CD:1.44,IN:1.42,SN:1.39,SB:1.39,TE:1.38,I:1.39,XE:1.4,CS:2.44,BA:2.15,LA:2.07,CE:2.04,PR:2.03,ND:2.01,PM:1.99,SM:1.98,EU:1.98,GD:1.96,TB:1.94,DY:1.92,HO:1.92,ER:1.89,TM:1.9,YB:1.87,LU:1.87,HF:1.75,TA:1.7,W:1.62,RE:1.51,OS:1.44,IR:1.41,PT:1.36,AU:1.36,HG:1.32,TL:1.45,PB:1.46,BI:1.48,PO:1.4,AT:1.5,RN:1.5,FR:2.6,RA:2.21,AC:2.15,TH:2.06,PA:2,U:1.96,NP:1.9,PU:1.87,AM:1.8,CM:1.69},this.atomColors={H:this.thr(16777215),He:this.thr(16761035),HE:this.thr(16761035),Li:this.thr(11674146),LI:this.thr(11674146),B:this.thr(65280),C:this.thr(11184810),N:this.thr(255),O:this.thr(15728640),F:this.thr(14329120),Na:this.thr(255),NA:this.thr(255),Mg:this.thr(2263842),MG:this.thr(2263842),Al:this.thr(8421520),AL:this.thr(8421520),Si:this.thr(14329120),SI:this.thr(14329120),P:this.thr(16753920),S:this.thr(16762930),Cl:this.thr(65280),CL:this.thr(65280),Ca:this.thr(8421520),CA:this.thr(8421520),Ti:this.thr(8421520),TI:this.thr(8421520),Cr:this.thr(8421520),CR:this.thr(8421520),Mn:this.thr(8421520),MN:this.thr(8421520),Fe:this.thr(16753920),FE:this.thr(16753920),Ni:this.thr(10824234),NI:this.thr(10824234),Cu:this.thr(10824234),CU:this.thr(10824234),Zn:this.thr(10824234),ZN:this.thr(10824234),Br:this.thr(10824234),BR:this.thr(10824234),Ag:this.thr(8421520),AG:this.thr(8421520),I:this.thr(10494192),Ba:this.thr(16753920),BA:this.thr(16753920),Au:this.thr(14329120),AU:this.thr(14329120)},this.atomnames={H:"Hydrogen",HE:"Helium",LI:"Lithium",B:"Boron",C:"Carbon",N:"Nitrogen",O:"Oxygen",F:"Fluorine",NA:"Sodium",MG:"Magnesium",AL:"Aluminum",SI:"Silicon",P:"Phosphorus",S:"Sulfur",CL:"Chlorine",CA:"Calcium",TI:"Titanium",CR:"Chromium",MN:"Manganese",FE:"Iron",NI:"Nickel",CU:"Copper",ZN:"Zinc",BR:"Bromine",AG:"Silver",I:"Iodine",BA:"Barium",AU:"Gold"},this.defaultAtomColor=this.thr(13421772),this.stdChainColors=[this.thr(16711935),this.thr(255),this.thr(10053171),this.thr(65433),this.thr(16750848),this.thr(16737894),this.thr(3329330),this.thr(2003199),this.thr(16416882),this.thr(16753920),this.thr(52945),this.thr(16738740),this.thr(65280),this.thr(255),this.thr(16711680),this.thr(16776960),this.thr(65535),this.thr(16711935),this.thr(3978097),this.thr(4620980),this.thr(13458524),this.thr(16770229),this.thr(11529966),this.thr(15631086),this.thr(25600),this.thr(139),this.thr(9109504),this.thr(13468991),this.thr(35723),this.thr(9699539)],this.backgroundColors={black:this.thr(0),grey:this.thr(13421772),white:this.thr(16777215),transparent:this.thr(16777215)},this.residueColors={ALA:this.thr(13158600),ARG:this.thr(1334015),ASN:this.thr(56540),ASP:this.thr(15075850),CYS:this.thr(15132160),GLN:this.thr(56540),GLU:this.thr(15075850),GLY:this.thr(15461355),HIS:this.thr(8553170),ILE:this.thr(1016335),LEU:this.thr(1016335),LYS:this.thr(1334015),MET:this.thr(15132160),PHE:this.thr(3289770),PRO:this.thr(14456450),SER:this.thr(16422400),THR:this.thr(16422400),TRP:this.thr(11819700),TYR:this.thr(3289770),VAL:this.thr(1016335),ASX:this.thr(16738740),GLX:this.thr(16738740),G:this.thr(32768),A:this.thr(6324479),T:this.thr(16744448),C:this.thr(16711680),U:this.thr(16744448),DG:this.thr(32768),DA:this.thr(6324479),DT:this.thr(16744448),DC:this.thr(16711680),DU:this.thr(16744448)},this.residueArea={ALA:247,ARG:366,ASN:290,ASP:285,CYS:271,GLN:336,GLU:325,GLY:217,HIS:340,ILE:324,LEU:328,LYS:373,MET:346,PHE:366,PRO:285,SER:265,THR:288,TRP:414,TYR:387,VAL:293,ASX:290,GLX:336,G:520,A:507,T:515,C:467,U:482,DG:520,DA:507,DT:515,DC:467,DU:482},this.defaultResidueColor=this.thr(12492910),this.chargeColors={" G":this.thr(16711680)," A":this.thr(16711680)," T":this.thr(16711680)," C":this.thr(16711680)," U":this.thr(16711680)," DG":this.thr(16711680)," DA":this.thr(16711680)," DT":this.thr(16711680)," DC":this.thr(16711680)," DU":this.thr(16711680),G:this.thr(16711680),A:this.thr(16711680),T:this.thr(16711680),C:this.thr(16711680),U:this.thr(16711680),DG:this.thr(16711680),DA:this.thr(16711680),DT:this.thr(16711680),DC:this.thr(16711680),DU:this.thr(16711680),ARG:this.thr(255),LYS:this.thr(255),ASP:this.thr(16711680),GLU:this.thr(16711680),HIS:this.thr(8421631),GLY:this.thr(8947848),PRO:this.thr(8947848),ALA:this.thr(8947848),VAL:this.thr(8947848),LEU:this.thr(8947848),ILE:this.thr(8947848),PHE:this.thr(8947848),SER:this.thr(8947848),THR:this.thr(8947848),ASN:this.thr(8947848),GLN:this.thr(8947848),TYR:this.thr(8947848),MET:this.thr(8947848),CYS:this.thr(8947848),TRP:this.thr(8947848)},this.hydrophobicColors={" G":this.thr(16711680)," A":this.thr(16711680)," T":this.thr(16711680)," C":this.thr(16711680)," U":this.thr(16711680)," DG":this.thr(16711680)," DA":this.thr(16711680)," DT":this.thr(16711680)," DC":this.thr(16711680)," DU":this.thr(16711680),G:this.thr(16711680),A:this.thr(16711680),T:this.thr(16711680),C:this.thr(16711680),U:this.thr(16711680),DG:this.thr(16711680),DA:this.thr(16711680),DT:this.thr(16711680),DC:this.thr(16711680),DU:this.thr(16711680),ARG:this.thr(255),LYS:this.thr(255),ASP:this.thr(16711680),GLU:this.thr(16711680),HIS:this.thr(8421631),TRP:this.thr().setHSL(1/3,1,.5),PHE:this.thr().setHSL(1/3,1,.6945945945945946),TYR:this.thr().setHSL(1/3,1,.745945945945946),LEU:this.thr().setHSL(1/3,1,.5+.645/1.85),ILE:this.thr().setHSL(1/3,1,.5+.77/1.85),CYS:this.thr().setHSL(1/3,1,.5+.805/1.85),MET:this.thr().setHSL(1/3,1,.5+.81/1.85),GLY:this.thr().setHSL(1/6,1,.5+.285/.58),VAL:this.thr().setHSL(1/6,1,.5+.255/.58),SER:this.thr().setHSL(1/6,1,.8879310344827587),THR:this.thr().setHSL(1/6,1,.8793103448275862),ALA:this.thr().setHSL(1/6,1,.853448275862069),ASN:this.thr().setHSL(1/6,1,.6379310344827587),PRO:this.thr().setHSL(1/6,1,.6120689655172413),GLN:this.thr().setHSL(1/6,1,.5)},this.normalizedHPColors={" G":this.thr(16777215)," A":this.thr(16777215)," T":this.thr(16777215)," C":this.thr(16777215)," U":this.thr(16777215)," DG":this.thr(16777215)," DA":this.thr(16777215)," DT":this.thr(16777215)," DC":this.thr(16777215)," DU":this.thr(16777215),G:this.thr(16777215),A:this.thr(16777215),T:this.thr(16777215),C:this.thr(16777215),U:this.thr(16777215),DG:this.thr(16777215),DA:this.thr(16777215),DT:this.thr(16777215),DC:this.thr(16777215),DU:this.thr(16777215),ARG:this.thr(16777215),LYS:this.thr(16777215),ASP:this.thr(16777215),GLU:this.thr(16777215),HIS:this.thr(16777215),TRP:this.thr().setHSL(1/3,1,.5),PHE:this.thr().setHSL(1/3,1,.644),TYR:this.thr().setHSL(1/3,1,.682),LEU:this.thr().setHSL(1/3,1,.758),ILE:this.thr().setHSL(1/3,1,.808),CYS:this.thr().setHSL(1/3,1,.5+.322),MET:this.thr().setHSL(1/3,1,.5+.324),GLY:this.thr().setHSL(1/3,1,.872),VAL:this.thr().setHSL(1/3,1,.884),SER:this.thr().setHSL(1/3,1,.896),THR:this.thr().setHSL(1/3,1,.898),ALA:this.thr().setHSL(1/3,1,.904),ASN:this.thr().setHSL(1/3,1,.954),PRO:this.thr().setHSL(1/3,1,.9600000000000001),GLN:this.thr().setHSL(1/3,1,.986)},this.hydrophobicValues={" G":3," A":3," T":3," C":3," U":3," DG":3," DA":3," DT":3," DC":3," DU":3,G:3,A:3,T:3,C:3,U:3,DG:3,DA:3,DT:3,DC:3,DU:3,ARG:1,LYS:1,ASP:3,GLU:3,HIS:2,TRP:-1.85,PHE:-1.13,TYR:-.94,LEU:-.56,ILE:-.31,CYS:-.24,MET:-.23,GLY:.01,VAL:.07,SER:.13,THR:.14,ALA:.17,ASN:.42,PRO:.45,GLN:.58},this.residueAbbrev={ALA:"A (Ala)",ARG:"R (Arg)",ASN:"N (Asn)",ASP:"D (Asp)",CYS:"C (Cys)",GLN:"Q (Gln)",GLU:"E (Glu)",GLY:"G (Gly)",HIS:"H (His)",ILE:"I (Ile)",LEU:"L (Leu)",LYS:"K (Lys)",MET:"M (Met)",PHE:"F (Phe)",PRO:"P (Pro)",SER:"S (Ser)",THR:"T (Thr)",TRP:"W (Trp)",TYR:"Y (Tyr)",VAL:"V (Val)",ASX:"X (Asx)",GLX:"X (Glx)",G:"Guanine",A:"Adenine",T:"Thymine",C:"Cytosine",U:"Uracil",DG:"deoxy-Guanine",DA:"deoxy-Adenine",DT:"deoxy-Thymine",DC:"deoxy-Cytosine",DU:"deoxy-Uracil"},this.ssColors={helix:this.thr(16711680),sheet:this.thr(32768),coil:this.thr(6324479)},this.ssColors2={helix:this.thr(16711680),sheet:this.thr(16762880),coil:this.thr(6324479)},this.resn2restype={ALA:1,ARG:4,ASN:7,ASP:10,CYS:13,GLN:16,GLU:19,GLY:22,HIS:25,ILE:28,LEU:31,LYS:34,MET:37,PHE:40,PRO:43,SER:46,THR:49,TRP:52,TYR:55,VAL:58},this.nuclMainArray=["C1'","C1*","C2'","C2*","C3'","C3*","C4'","C4*","C5'","C5*","O3'","O3*","O4'","O4*","O5'","O5*","P","OP1","O1P","OP2","O2P"],this.b62ResArray=["A","R","N","D","C","Q","E","G","H","I","L","K","M","F","P","S","T","W","Y","V","B","Z","X","*"],this.b62Matrix=[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0,-4],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1,-4],[-2,0,6,1,-3,0,0,0,1,-3,-3,0,-2,-3,-2,1,0,-4,-2,-3,3,0,-1,-4],[-2,-2,1,6,-3,0,2,-1,-1,-3,-4,-1,-3,-3,-1,0,-1,-4,-3,-3,4,1,-1,-4],[0,-3,-3,-3,9,-3,-4,-3,-3,-1,-1,-3,-1,-2,-3,-1,-1,-2,-2,-1,-3,-3,-2,-4],[-1,1,0,0,-3,5,2,-2,0,-3,-2,1,0,-3,-1,0,-1,-2,-1,-2,0,3,-1,-4],[-1,0,0,2,-4,2,5,-2,0,-3,-3,1,-2,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-2,0,-1,-3,-2,-2,6,-2,-4,-4,-2,-3,-3,-2,0,-2,-2,-3,-3,-1,-2,-1,-4],[-2,0,1,-1,-3,0,0,-2,8,-3,-3,-1,-2,-1,-2,-1,-2,-2,2,-3,0,0,-1,-4],[-1,-3,-3,-3,-1,-3,-3,-4,-3,4,2,-3,1,0,-3,-2,-1,-3,-1,3,-3,-3,-1,-4],[-1,-2,-3,-4,-1,-2,-3,-4,-3,2,4,-2,2,0,-3,-2,-1,-2,-1,1,-4,-3,-1,-4],[-1,2,0,-1,-3,1,1,-2,-1,-3,-2,5,-1,-3,-1,0,-1,-3,-2,-2,0,1,-1,-4],[-1,-1,-2,-3,-1,0,-2,-3,-2,1,2,-1,5,0,-2,-1,-1,-1,-1,1,-3,-1,-1,-4],[-2,-3,-3,-3,-2,-3,-3,-3,-1,0,0,-3,0,6,-4,-2,-2,1,3,-1,-3,-3,-1,-4],[-1,-2,-2,-1,-3,-1,-1,-2,-2,-3,-3,-1,-2,-4,7,-1,-1,-4,-3,-2,-2,-1,-2,-4],[1,-1,1,0,-1,0,0,0,-1,-2,-2,0,-1,-2,-1,4,1,-3,-2,-2,0,0,0,-4],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,1,5,-2,-2,0,-1,-1,0,-4],[-3,-3,-4,-4,-2,-2,-3,-2,-2,-3,-2,-3,-1,1,-4,-3,-2,11,2,-3,-4,-3,-2,-4],[-2,-2,-2,-3,-2,-1,-2,-3,2,-1,-1,-2,-1,3,-3,-2,-2,2,7,-1,-3,-2,-1,-4],[0,-3,-3,-3,-1,-2,-2,-3,-3,3,1,-2,1,-1,-2,-2,0,-3,-1,4,-3,-2,-1,-4],[-2,-1,3,4,-3,0,1,-1,0,-3,-4,0,-3,-3,-2,0,-1,-4,-3,-3,4,1,-1,-4],[-1,0,0,1,-3,3,4,-2,0,-3,-3,1,-1,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,0,0,-2,-1,-1,-1,-1,-1,-4],[-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,1]]}thr(e){return this.icn3dui,"#0"==e&&(e="#000"),new THREE.Color(e)}}class n{constructor(e){this.icn3dui=e}onId(e,t,s){if(this.icn3dui,!(Object.keys(window).length<2)&&("#"==e.substr(0,1)&&(e=e.substr(1)),document.getElementById(e))){t.split(" ").forEach((t=>{document.getElementById(e).addEventListener(t,s)}))}}onIds(e,t,s){let i=this.icn3dui;Array.isArray(e)?e.forEach((e=>{i.myEventCls.onId(e,t,s)})):i.myEventCls.onId(e,t,s)}}class l{constructor(e){this.icn3dui=e}getRmsdSuprCls(e,t,s){let i,n,l,r,o,a,d,c,h,p,m,u,g,f=this.icn3dui,b=new Array(9),C=new THREE.Vector3,y=new THREE.Vector3,v=[],w=[],_=new Array(3),S=new Array(3),A=new Array(3),x=new Array(3),k=new Array(3),O=new Array(3);if(i=0,s<=1)return{rot:void 0,trans1:void 0,trans2:void 0,rmsd:999};let R=s;for(n=0;n0?(b[0]=x[0]*_[0]+k[0]*S[0]+O[0]*A[0],b[1]=x[0]*_[1]+k[0]*S[1]+O[0]*A[1],b[2]=x[0]*_[2]+k[0]*S[2]+O[0]*A[2],b[3]=x[1]*_[0]+k[1]*S[0]+O[1]*A[0],b[4]=x[1]*_[1]+k[1]*S[1]+O[1]*A[1],b[5]=x[1]*_[2]+k[1]*S[2]+O[1]*A[2],b[6]=x[2]*_[0]+k[2]*S[0]+O[2]*A[0],b[7]=x[2]*_[1]+k[2]*S[1]+O[2]*A[1],b[8]=x[2]*_[2]+k[2]*S[2]+O[2]*A[2]):(b[0]=x[0]*_[0]+k[0]*S[0]-O[0]*A[0],b[1]=x[0]*_[1]+k[0]*S[1]-O[0]*A[1],b[2]=x[0]*_[2]+k[0]*S[2]-O[0]*A[2],b[3]=x[1]*_[0]+k[1]*S[0]-O[1]*A[0],b[4]=x[1]*_[1]+k[1]*S[1]-O[1]*A[1],b[5]=x[1]*_[2]+k[1]*S[2]-O[1]*A[2],b[6]=x[2]*_[0]+k[2]*S[0]-O[2]*A[0],b[7]=x[2]*_[1]+k[2]*S[1]-O[2]*A[1],b[8]=x[2]*_[2]+k[2]*S[2]-O[2]*A[2]),c=Math.sqrt(c),h=Math.sqrt(h),p=Math.sqrt(p),g=c+h+u*p,m=a+d-2*g,i=m>0?Math.sqrt(m):void 0,{rot:b,trans1:E,trans2:I,rmsd:i})}eigen_values(e){let t,s,i,n,l,r,o,a,d,c,h,p,m,u,g,f,b,C,y,v;if(this.icn3dui,t=e[0],s=e[1],i=e[2],n=e[3],l=e[4],r=e[5],o=e[6],a=e[7],d=e[8],c=-(t+l+d),h=t*l+(t+l)*d-r*a-s*n-i*o,p=-t*l*d+t*r*a+s*n*d-s*r*o-i*n*a+i*l*o,m=-c*c/3+h,u=c*c*c/13.5-c*h/3+p,g=.25*u*u+m*m*m/27,g<0){let e,t;e=Math.sqrt(.25*u*u-g),t=Math.acos(-.5*u/e),C=2*Math.cbrt(e)*Math.cos(t/3)}else f=Math.cbrt(-.5*u+Math.sqrt(g)),b=Math.cbrt(-.5*u-Math.sqrt(g)),C=f+b;return C-=c/3,c+=C,p/=-C,y=.5*(-c+Math.sqrt(c*c-4*p)),v=.5*(-c-Math.sqrt(c*c-4*p)),y_&&(_=Math.abs(d)),Math.abs(c)>_&&(_=Math.abs(c)),Math.abs(h)>_&&(_=Math.abs(h)),Math.abs(p)>_&&(_=Math.abs(p)),Math.abs(m)>_&&(_=Math.abs(m)),Math.abs(u)>_&&(_=Math.abs(u)),Math.abs(g)>_&&(_=Math.abs(g)),Math.abs(f)>_&&(_=Math.abs(f)),_<1e-10)return r=3,{k:r,v1:t,v2:s,v3:i};if(o=0,a/=_,d/=_,c/=_,h/=_,p/=_,m/=_,u/=_,g/=_,f/=_,Math.abs(a)_&&(w=a,a=h,h=w,w=d,d=p,p=w,w=c,c=m,m=w,_=Math.abs(d)),Math.abs(g)>_&&(w=a,a=u,u=w,w=d,d=g,g=w,w=c,c=f,f=w),y=m-p*c/d,v=f-g*c/d,Math.abs(y)_&&(w=a,a=h,h=w,w=d,d=p,p=w,w=c,c=m,m=w,_=Math.abs(a)),Math.abs(c)>_&&(w=a,a=u,u=w,w=d,d=g,g=w,w=c,c=f,f=w),b=p-h*d/a,C=m-h*c/a,y=g-u*d/a,v=f-u*c/a,Math.abs(b)0&&(1==o?(a=s[0],d=s[1],c=s[2],w=Math.sqrt(a*a+d*d+c*c),s[0]=a/w,s[1]=d/w,s[2]=c/w):2==o?(a=t[0],d=t[1],c=t[2],h=s[0],p=s[1],m=s[2],w=a*h+d*p+c*m,Math.abs(w)>=n&&(s[0]=a+w*h,s[1]=d+w*p,s[2]=c+w*m,h=s[0],p=s[1],m=s[2]),w=Math.sqrt(a*a+d*d+c*c),t[0]=a/w,t[1]=d/w,t[2]=c/w,w=Math.sqrt(h*h+p*p+m*m),s[0]=h/w,s[1]=p/w,s[2]=m/w):(a=t[0],d=t[1],c=t[2],w=Math.sqrt(a*a+d*d+c*c),t[0]=a/w,t[1]=d/w,t[2]=c/w)),{k:r,v1:t,v2:s,v3:i}}getEigenForSelection(e,t){let s,i=this.icn3dui,n=new THREE.Vector3,l=[];for(s=0;s0&&Math.abs(l[0].x-e[0].x)<=6&&Math.abs(l[0].y-e[0].y)<=6&&Math.abs(l[0].z-e[0].z)<=6?(p.push(l[0]),m=1):m=0,p.push(e[0]);for(let t=1,s=e.length-1;t0&&Math.abs(r[0].x-e[e.length-1].x)<=6&&Math.abs(r[0].y-e[e.length-1].y)<=6&&Math.abs(r[0].z-e[e.length-1].z)<=6&&(p.push(r[0]),++g),u>1&&Math.abs(r[0].x-r[1].x)<=6&&Math.abs(r[0].y-r[1].y)<=6&&Math.abs(r[0].z-r[1].z)<=6&&(p.push(r[1]),++g);let f=[],b=[],C=[];o&&(g=u>0?u-1:0);let y;for(let e=-1,n=p.length,l=1/s;e<=n-3;++e){y=e-m;let r=p[-1===e?0:e],o=p[e+1],u=p[e+2],v=p[e===n-3?n-1:e+3],w=0,_=a.subdivideCls.getKnot(1,w,r,o),S=a.subdivideCls.getKnot(1,_,o,u),A=a.subdivideCls.getKnot(1,S,u,v);_-w<1e-4&&(_=w+1),S-_<1e-4&&(S=_+1),A-S<1e-4&&(A=S+1),e>-1&&(void 0===i||i[y+1])&&e>=-1+m&&e<=n-3-g+1&&(d=d.concat(f),c=c.concat(b),h=h.concat(C)),f=[],b=[],C=[];let x=(S-_)*l;for(let l=0;l=-1+m&&e<=n-3-g&&i[y+1]&&l<=parseInt(s/2)&&(d.push(new THREE.Vector3(k,O,R)),c.push(i[y+1]),h.push(t[y+1])),e>=-1+m&&e<=n-3-g+1&&i[y+2]&&l>parseInt(s/2)&&(f.push(new THREE.Vector3(k,O,R)),b.push(i[y+2]),C.push(t[y+2]))):e>=-1+m&&e<=n-3-g&&(d.push(new THREE.Vector3(k,O,R)),c.push(y+1),h.push(t[y+1]))}}i&&!i[y+1]||(d=d.concat(f),c=c.concat(b),h=h.concat(C),d.push(p[p.length-1-g]),c.push(p.length-1-g),h.push(t[p.length-1-g])),f=[],b=[],C=[],p=[];let v=[];return v.push(d),v.push(c),v.push(h),v}getKnot(e,t,s,i){return this.icn3dui,s.distanceTo(i)+t}getValueFromKnot(e,t,s,i,n,l,r,o,a){this.icn3dui;let d,c,h=(r-l)/(s-t),p=(o-r)/(i-s),m=(a-o)/(n-i),u=(s+i)*(s+i)-4*(t*s+i*n-t*n);return 0==u?(d=9999,c=9999):(d=6*(3*p*s+2*h*n+m*s-2*h*s-2*p*n-p*i-m*s)/u,c=6*(3*p*i+2*m*t+h*s-2*p*t-2*m*i-h*i-p*s)/u),p*(e-s)+r+((2*d+c)/6/(s-i)*(e-s)*(e-i)*(e-i)+(2*c+d)/6/(i-s)*(e-s)*(e-s)*(e-i))}}class o{constructor(e){this.icn3dui=e}passFloat32(e,t){let s=this.icn3dui,i=e.length;t||(t=new Uint8Array(4*i));let n=s.convertTypeCls.getDataView(t);for(let t=0;t  Very high (pLDDT > 90)
  Confident (90 > pLDDT > 70)
  Low (70 > pLDDT > 50)
  Very low (pLDDT < 50)
'}setLegendHtml(e){let t=this.icn3dui.icn3d,s="
";if(e)s+=this.setAlphaFoldLegend();else{s+="
"+t.startValue+""+t.midValue+""+t.endValue+"
"}return s}SetChainsAdvancedMenu(){let e=this.icn3dui,t=e.icn3d;if(void 0===t.bSetChainsAdvancedMenu||!t.bSetChainsAdvancedMenu){let s=e.hashUtilsCls.cloneHash(t.hAtoms);t.definedSetsCls.setPredefinedInMenu(),t.bSetChainsAdvancedMenu=!0,t.hAtoms=e.hashUtilsCls.cloneHash(s)}}setSetsMenus(e,t){let s=this.icn3dui,i=s.icn3d;this.SetChainsAdvancedMenu();let n=e,l=e+"2",r=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+s.pre+n).length&&$("#"+s.pre+n).html(" "+r),!t&&$("#"+s.pre+l).length&&$("#"+s.pre+l).html(" "+r),$("#"+s.pre+n).resizable(),t||$("#"+s.pre+l).resizable()}applyShownMenus(){let e=this.icn3dui;e.icn3d;let t=[];for(let s in e.htmlCls.allMenus)e.htmlCls.shownMenus.hasOwnProperty(s)?$("#"+e.pre+s).parent().show():($("#"+e.pre+s).parent().hide(),t.push(s));Object.keys(e.htmlCls.shownMenus).length==Object.keys(e.htmlCls.allMenus).length?$(".icn3d-menusep").show():$(".icn3d-menusep").hide(),localStorage&&localStorage.setItem("hiddenmenus",JSON.stringify(t))}getHiddenMenusFromCache(){let e=this.icn3dui;e.icn3d,e.htmlCls.shownMenus={};let t=localStorage?localStorage.getItem("hiddenmenus"):"";if(t&&"[]"!=t){let s=JSON.parse(t);for(let t in e.htmlCls.allMenus)-1==s.indexOf(t)&&(e.htmlCls.shownMenus[t]=1)}else e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.allMenus)}displayShownMenus(){let e=this.icn3dui;e.icn3d;let t="
";t+="",t+="";for(let s in e.htmlCls.allMenusSel){if("uniclr"==s.substr(0,6)||"mn5_opacity"==s.substr(0,11)||"mn6_labelscale"==s.substr(0,14)||"faq_"==s.substr(0,4)||"dev_"==s.substr(0,4))continue;"mn1_searchstru"==s?t+="
FileSelectViewStyleColorAnalysisHelp
":("mn2_definedsets"==s||"mn2_show_selected"==s||"mn3_proteinwrap"==s||e.cfg.cid&&"mn3_ligwrap"==s||"mn4_clrwrap"==s||"mn6_selectannotations"==s||"abouticn3d"==s)&&(t+="");let i=e.htmlCls.shownMenus.hasOwnProperty(s)?"checked":"",n=e.htmlCls.allMenusSel[s];t+=""+e.htmlCls.allMenus[s]+"
"}t+="
",$("#"+e.pre+"menulist").html(t)}clickMenu1(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds("#"+e.pre+"mn1_vastplus","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_vastplus","Please input PDB ID for VAST+")})),e.myEventCls.onIds("#"+e.pre+"mn1_vast","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_vast","Please input chain or PDB file for VAST")})),e.myEventCls.onIds("#"+e.pre+"mn1_foldseek","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_foldseek","Submit your selection to Foldseek")})),e.myEventCls.onIds("#"+e.pre+"mn1_mmtfid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmtfid","Please input MMTF ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_pdbid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pdbid","Please input PDB ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_afid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_afid","Please input AlphaFold UniProt ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_refseqid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_refseqid","Please input NCBI Protein Accession")})),e.myEventCls.onIds("#"+e.pre+"mn1_opmid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_opmid","Please input OPM PDB ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_align","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_align","Align two PDB structures")})),e.myEventCls.onIds("#"+e.pre+"mn1_alignaf","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_alignaf","Align two AlphaFold structures")})),e.myEventCls.onIds("#"+e.pre+"mn1_chainalign","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_chainalign","Align multiple chains by structure alignment")})),e.myEventCls.onIds("#"+e.pre+"mn1_chainalign2","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_chainalign2","Align multiple chains by sequence alignment")})),e.myEventCls.onIds("#"+e.pre+"mn1_chainalign3","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_chainalign3","Align multiple chains residue by residue")})),e.myEventCls.onIds("#"+e.pre+"mn1_mutation","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mutation","Show the mutations in 3D")})),e.myEventCls.onIds("#"+e.pre+"mn1_pdbfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pdbfile","Please input PDB File")})),e.myEventCls.onIds(["#"+e.pre+"mn1_pdbfile_app","#"+e.pre+"tool_pdbfile"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pdbfile_app","Please append PDB Files")})),e.myEventCls.onIds("#"+e.pre+"mn1_mol2file","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mol2file","Please input Mol2 File")})),e.myEventCls.onIds("#"+e.pre+"mn1_sdffile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_sdffile","Please input SDF File")})),e.myEventCls.onIds("#"+e.pre+"mn1_xyzfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_xyzfile","Please input XYZ File")})),e.myEventCls.onIds("#"+e.pre+"mn1_afmapfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_afmapfile","Please input AlphaFold PAE File")})),e.myEventCls.onIds("#"+e.pre+"mn1_urlfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_urlfile","Load data by URL")})),e.myEventCls.onIds("#"+e.pre+"mn1_fixedversion","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_fixedversion","Open Share Link URL in the archived version of iCn3D")})),e.myEventCls.onIds("#"+e.pre+"reload_fixedversion","click",(function(s){let i=e.icn3d,n=$("#"+e.pre+"sharelinkurl").val();t.setLogCmd("open "+n,!1),localStorage.setItem("fixedversion","1");let l=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(n,l)})),e.myEventCls.onIds("#"+e.pre+"mn1_mmciffile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmciffile","Please input mmCIF File")})),e.myEventCls.onIds("#"+e.pre+"mn1_mmcifid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmcifid","Please input mmCIF ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_mmdbid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmdbid","Please input MMDB or PDB ID")})),e.myEventCls.onIds(["#"+e.pre+"mn1_mmdbafid",,"#"+e.pre+"tool_mmdbafid"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmdbafid","Please input PDB/MMDB/AlphaFold UniProt IDs")})),e.myEventCls.onIds("#"+e.pre+"mn1_blast_rep_id","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_blast_rep_id","Align sequence to structure")})),e.myEventCls.onIds("#"+e.pre+"mn1_gi","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_gi","Please input protein gi")})),e.myEventCls.onIds("#"+e.pre+"mn1_cid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_cid","Please input PubChem CID")})),e.myEventCls.onIds("#"+e.pre+"mn1_pngimage","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pngimage","Please input the PNG image")})),e.myEventCls.onIds("#"+e.pre+"mn1_state","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_state","Please input the state file")})),e.myEventCls.onIds("#"+e.pre+"mn1_selection","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_selection","Please input the selection file")})),e.myEventCls.onIds("#"+e.pre+"mn1_dsn6","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_dsn6","Please input the DSN6 file to display electron density map")})),e.myEventCls.onIds(["#"+e.pre+"mn1_delphi","#"+e.pre+"mn1_delphi2","#"+e.pre+"tool_delphi"],"click",(function(t){e.icn3d.loadPhiFrom="delphi",$("#"+e.pre+"dl_delphi_tabs").tabs(),e.htmlCls.dialogCls.openDlg("dl_delphi","Please set parameters to display DelPhi potential map")})),e.myEventCls.onIds("#"+e.pre+"mn1_phi","click",(function(t){e.icn3d.loadPhiFrom="phi",$("#"+e.pre+"dl_phi_tabs").tabs(),$("#"+e.pre+"phitab1_tabs").tabs(),$("#"+e.pre+"phitab2_tabs").tabs(),e.htmlCls.dialogCls.openDlg("dl_phi","Please input local phi or cube file to display DelPhi potential map")})),e.myEventCls.onIds("#"+e.pre+"mn1_phiurl","click",(function(t){e.icn3d.loadPhiFrom="phiurl",$("#"+e.pre+"dl_phiurl_tabs").tabs(),$("#"+e.pre+"phiurltab1_tabs").tabs(),$("#"+e.pre+"phiurltab2_tabs").tabs(),e.htmlCls.dialogCls.openDlg("dl_phiurl","Please input URL phi or cube file to display DelPhi potential map")})),e.myEventCls.onIds("#"+e.pre+"mn1_dsn6url","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_dsn6url","Please input the DSN6 file to display electron density map")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportState","click",(function(s){let i=e.icn3d;t.setLogCmd("export state file",!1);let n=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(n+"_statefile.txt","command")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportPdbRes","click",(function(s){e.icn3d,e.htmlCls.setHtmlCls.exportPdb(),t.setLogCmd("export pdb",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportSecondary","click",(function(s){e.icn3d,e.htmlCls.setHtmlCls.exportSecondary(),t.setLogCmd("export secondary structure",!0)})),e.myEventCls.onIds(["#"+e.pre+"delphipdb","#"+e.pre+"phipdb"],"click",(function(s){let i=e.icn3d,n=i.saveFileCls.getSelectedResiduePDB();t.setLogCmd("export PDB of selected residues",!1);let l=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(l+"_icn3d_residues.pdb","text",[n])})),e.myEventCls.onIds(["#"+e.pre+"delphipqr","#"+e.pre+"phipqr","#"+e.pre+"phiurlpqr"],"click",(async function(s){e.icn3d,await e.htmlCls.setHtmlCls.exportPqr(),t.setLogCmd("export pqr",!0)})),e.myEventCls.onIds("#"+e.pre+"profixpdb","click",(async function(s){let i=e.icn3d;await i.scapCls.exportPdbProfix(!1),t.setLogCmd("export pdb missing atoms",!0)})),e.myEventCls.onIds("#"+e.pre+"profixpdbh","click",(async function(s){let i=e.icn3d;await i.scapCls.exportPdbProfix(!0),t.setLogCmd("export pdb hydrogen",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportStl","click",(function(s){let i=e.icn3d;t.setLogCmd("export stl file",!1),i.export3DCls.exportStlFile("")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportVrml","click",(function(s){let i=e.icn3d;t.setLogCmd("export vrml file",!1),i.export3DCls.exportVrmlFile("")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportStlStab","click",(function(s){let i=e.icn3d;t.setLogCmd("export stl stabilizer file",!1),i.threeDPrintCls.hideStabilizer(),i.threeDPrintCls.resetAfter3Dprint(),i.threeDPrintCls.addStabilizer(),i.export3DCls.exportStlFile("_stab")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportVrmlStab","click",(function(s){let i=e.icn3d;t.setLogCmd("export vrml stabilizer file",!1),i.threeDPrintCls.hideStabilizer(),i.threeDPrintCls.resetAfter3Dprint(),i.threeDPrintCls.addStabilizer(),i.export3DCls.exportVrmlFile("_stab")})),e.myEventCls.onIds("#"+e.pre+"mn6_exportInteraction","click",(async function(s){let i=e.icn3d;t.setLogCmd("export interactions",!1),void 0!==e.cfg.mmdbid&&await i.viewInterPairsCls.retrieveInteractionData(),i.viewInterPairsCls.exportInteractions()})),e.myEventCls.onIds(["#"+e.pre+"mn1_exportCanvas","#"+e.pre+"saveimage"],"click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas",!1);await i.shareLinkCls.shareLink(!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas1","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 1",!0),i.scaleFactor=1,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas2","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 2",!0),i.scaleFactor=2,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas4","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 4",!0),i.scaleFactor=4,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas8","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 8",!0),i.scaleFactor=8,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCounts","click",(function(s){let i=e.icn3d;t.setLogCmd("export counts",!1);let n='

Total Count for atoms with coordinates:
';n+="",n+="
Structure CountChain CountResidue CountAtom Count
"+Object.keys(i.structures).length+""+Object.keys(i.chains).length+""+Object.keys(i.residues).length+""+Object.keys(i.atoms).length+"

",n+="Counts by Chain for atoms with coordinates:
";let l=Object.keys(i.chains);for(let e=0,t=l.length;e"}n+="
StructureChainResidue CountAtom Count
"+r+""+o+""+Object.keys(a).length+""+Object.keys(i.chains[t]).length+"

";let r=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(r+"_counts.html","html",n)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportSelections","click",(function(s){let i=e.icn3d;t.setLogCmd("export all selections",!1),t.SetChainsAdvancedMenu();let n=i.saveFileCls.exportCustomAtoms(),l=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(l+"_selections.txt","text",[n])})),e.myEventCls.onIds("#"+e.pre+"mn1_exportSelDetails","click",(function(s){let i=e.icn3d;t.setLogCmd("export all selections with details",!1),t.SetChainsAdvancedMenu();let n=i.saveFileCls.exportCustomAtoms(!0),l=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(l+"_sel_details.txt","text",[n])})),e.myEventCls.onIds(["#"+e.pre+"mn1_sharelink","#"+e.pre+"tool_sharelink"],"click",(async function(t){let s=e.icn3d;await s.shareLinkCls.shareLink()})),e.myEventCls.onIds("#"+e.pre+"mn1_replayon","click",(async function(s){let i=e.icn3d;await i.resizeCanvasCls.replayon(),t.setLogCmd("replay on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_replayoff","click",(async function(s){let i=e.icn3d;await i.resizeCanvasCls.replayoff(),t.setLogCmd("replay off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_menuall","click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.allMenus),t.applyShownMenus()})),e.myEventCls.onIds("#"+e.pre+"mn1_menusimple","click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.simpleMenus),t.applyShownMenus()})),e.myEventCls.onIds("#"+e.pre+"mn1_menupref","click",(function(s){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_menupref","Select Menus"),t.getHiddenMenusFromCache(),t.displayShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"apply_menupref","#"+e.pre+"apply_menupref2"],"click",(function(s){e.icn3d;var i=document.querySelectorAll('form[name="'+e.pre+'selmenu"] input:checked');for(var n of(e.htmlCls.shownMenus={},i))e.htmlCls.shownMenus[n.value]=1;t.applyShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"reset_menupref","#"+e.pre+"reset_menupref2"],"click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.simpleMenus),t.applyShownMenus(),t.displayShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"reset_menupref_all","#"+e.pre+"reset_menupref_all2"],"click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.allMenus),t.applyShownMenus(),t.displayShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"savepref","#"+e.pre+"savepref2"],"click",(function(t){let s=e.icn3d,i="[";var n=document.querySelectorAll('form[name="'+e.pre+'selmenu"] input:not(:checked)');let l=0;for(var r of n)l>0&&(i+=", "),i+='"'+r.value+'"',++l;i+="]",s.saveFileCls.saveFile("icn3d_menus_pref.txt","text",[i])})),e.myEventCls.onIds("#"+e.pre+"reload_menupreffile","click",(function(s){e.icn3d,e.cfg.notebook||dialog.dialog("close");let i=$("#"+e.pre+"menupreffile")[0].files[0];if(i){e.htmlCls.setHtmlCls.fileSupport();let s=new FileReader;s.onload=function(s){let i=s.target.result,n=JSON.parse(i);e.htmlCls.shownMenus={};for(let t in e.htmlCls.allMenus)-1==n.indexOf(t)&&(e.htmlCls.shownMenus[t]=1);t.applyShownMenus(),t.displayShownMenus()},s.readAsText(i)}else alert("Please select a file before clicking 'Load'")})),e.myEventCls.onIds("#"+e.pre+"mn1_menuloadpref","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_menuloadpref","Please input the menu preference file")})),e.myEventCls.onIds("#"+e.pre+"mn1_link_structure","click",(function(t){let s=e.icn3d,i=s.saveFileCls.getLinkToStructureSummary(!0),n=s.structures&&Object.keys(s.structures).length>0?"_blank":"_self";window.open(i,n)})),e.myEventCls.onIds("#"+e.pre+"mn1_link_bind","click",(function(s){let i=e.icn3d;url="https://www.ncbi.nlm.nih.gov/pccompound?LinkName=pccompound_structure&from_uid="+i.inputid,t.setLogCmd("link to 3D protein structures bound to CID "+i.inputid+": "+url,!1);let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(url,n)})),e.myEventCls.onIds("#"+e.pre+"mn1_link_vast","click",(function(s){let i=e.icn3d;if(void 0===i.inputid)url="https://www.ncbi.nlm.nih.gov/pccompound?term="+i.molTitle,t.setLogCmd("link to compounds "+i.molTitle+": "+url,!1);else{let s;if(void 0!==e.cfg.cid)s="https://www.ncbi.nlm.nih.gov/pccompound?LinkName=pccompound_pccompound_3d&from_uid="+i.inputid,t.setLogCmd("link to compounds with structure similar to CID "+i.inputid+": "+s,!1);else{let n=i.inputid.split("_");1===n.length?(s=e.htmlCls.baseUrl+"vastplus/vastplus.cgi?uid="+i.inputid,t.setLogCmd("link to structures similar to "+i.inputid+": "+s,!1)):2===n.length&&(s=e.htmlCls.baseUrl+"vastplus/vastplus.cgi?uid="+n[0],t.setLogCmd("link to structures similar to "+n[0]+": "+s,!1))}}let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(url,n)})),e.myEventCls.onIds("#"+e.pre+"mn1_link_pubmed","click",(function(s){let i=e.icn3d;if(void 0===i.inputid){let e;e="https://www.ncbi.nlm.nih.gov/pubmed/?term="+i.molTitle,t.setLogCmd("link to literature about "+i.molTitle+": "+e,!1);let s=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(e,s)}else if(i.pmid){let e,s=i.pmid.toString().split("_");1===s.length?(e="https://www.ncbi.nlm.nih.gov/pubmed/"+i.pmid,t.setLogCmd("link to PubMed ID "+i.pmid+": "+e,!1)):2===s.length&&(e="https://www.ncbi.nlm.nih.gov/pubmed/?term="+s[0]+" OR "+s[1],t.setLogCmd("link to PubMed IDs "+s[0]+", "+s[1]+": "+e,!1));let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(e,n)}else if(isNaN(i.inputid)){let e,s=i.inputid.toString().split("_");1===s.length?(e="https://www.ncbi.nlm.nih.gov/pubmed/?term="+i.inputid,t.setLogCmd("link to literature about PDB "+i.inputid+": "+e,!1)):2===s.length&&(e="https://www.ncbi.nlm.nih.gov/pubmed/?term="+s[0]+" OR "+s[1],t.setLogCmd("link to literature about PDB "+s[0]+" OR "+s[1]+": "+e,!1));let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(e,n)}else void 0!==e.cfg.cid?alert("No literature information is available for this compound in the SDF file."):alert("No literature information is available for this structure.")})),e.myEventCls.onIds("#"+e.pre+"mn1_link_protein","click",(function(s){let i=e.icn3d,n=Object.keys(i.structures),l=Object.keys(i.chains),r="";for(let e=0,t=l.length;e0&&(r=r.substr(0,r.length-4));let o="https://www.ncbi.nlm.nih.gov/protein/?term="+r;t.setLogCmd("link to Entrez protein about PDB "+n+": "+o,!1);let a=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(o,a)}))}clickMenu2(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds(["#"+e.pre+"mn6_selectannotations","#"+e.pre+"tool_selectannotations"],"click",(async function(s){let i=e.icn3d;await i.showAnnoCls.showAnnotations(),t.setLogCmd("view annotations",!0)})),e.myEventCls.onIds("#"+e.pre+"mn2_selectall","click",(function(s){let i=e.icn3d;t.setLogCmd("select all",!0),i.selectionCls.selectAll(),i.hlUpdateCls.removeHlAll(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"clearall","click",(function(s){let i=e.icn3d;t.setLogCmd("clear all",!0),i.bSelectResidue=!1,i.selectionCls.selectAll(),i.hlUpdateCls.removeHlAll(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn2_selectdisplayed","click",(function(s){let i=e.icn3d;t.setLogCmd("select displayed set",!0),i.hAtoms=e.hashUtilsCls.cloneHash(i.viewSelectionAtoms),i.hlUpdateCls.updateHlAll()})),e.myEventCls.onIds("#"+e.pre+"mn2_fullstru","click",(function(s){let i=e.icn3d;t.setLogCmd("show all",!0),i.selectionCls.showAll()})),e.myEventCls.onIds("#"+e.pre+"mn2_selectcomplement","click",(function(s){let i=e.icn3d;Object.keys(i.hAtoms).lengthnon-selected"+n),$("#"+e.pre+"atomsCustomSphere2").length&&$("#"+e.pre+"atomsCustomSphere2").html(" "+n),e.htmlCls.dialogCls.openDlg("dl_aroundsphere","Select a sphere around a set of residues"),i.bSphereCalc=!1,$("#"+e.pre+"atomsCustomSphere").resizable(),$("#"+e.pre+"atomsCustomSphere2").resizable()})),e.myEventCls.onIds(["#"+e.pre+"mn2_select_chain","#"+e.pre+"definedSets"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_select_chain","Select Structure/Chain/Custom Selection")}))}clickMenu3(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds(["#"+e.pre+"mn3_proteinsRibbon","#"+e.pre+"tool_proteinsRibbon"],"click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","ribbon"),t.setLogCmd("style proteins ribbon",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsStrand","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","strand"),t.setLogCmd("style proteins strand",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsCylinder","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","cylinder and plate"),t.setLogCmd("style proteins cylinder and plate",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsSchematic","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","schematic"),t.setLogCmd("style proteins schematic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsCalpha","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","c alpha trace"),t.setLogCmd("style proteins c alpha trace",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsBackbone","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","backbone"),t.setLogCmd("style proteins backbone",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsBfactor","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","b factor tube"),t.setLogCmd("style proteins b factor tube",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsLines","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","lines"),t.setLogCmd("style proteins lines",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsStick","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","stick"),t.setLogCmd("style proteins stick",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn3_proteinsBallstick","#"+e.pre+"tool_proteinsBallstick"],"click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","ball and stick"),t.setLogCmd("style proteins ball and stick",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn3_proteinsSphere","#"+e.pre+"tool_proteinsSphere"],"click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","sphere"),t.setLogCmd("style proteins sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsNo","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","nothing"),t.setLogCmd("style proteins nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecLines","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","lines2"),t.setLogCmd("style sidec lines2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecStick","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","stick2"),t.setLogCmd("style sidec stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","ball and stick2"),t.setLogCmd("style sidec ball and stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","sphere2"),t.setLogCmd("style sidec sphere2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecNo","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","nothing"),t.setLogCmd("style sidec nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseLines","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","lines2"),t.setLogCmd("style ntbase lines2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseStick","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","stick2"),t.setLogCmd("style ntbase stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","ball and stick2"),t.setLogCmd("style ntbase ball and stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","sphere2"),t.setLogCmd("style ntbase sphere2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseNo","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","nothing"),t.setLogCmd("style ntbase nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclCartoon","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","nucleotide cartoon"),t.setLogCmd("style nucleotides nucleotide cartoon",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclBackbone","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","backbone"),t.setLogCmd("style nucleotides backbone",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclSchematic","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","schematic"),t.setLogCmd("style nucleotides schematic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclPhos","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","o3 trace"),t.setLogCmd("style nucleotides o3 trace",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclLines","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","lines"),t.setLogCmd("style nucleotides lines",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclStick","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","stick"),t.setLogCmd("style nucleotides stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","ball and stick"),t.setLogCmd("style nucleotides ball and stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","sphere"),t.setLogCmd("style nucleotides sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclNo","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","nothing"),t.setLogCmd("style nucleotides nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligLines","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","lines"),t.setLogCmd("style chemicals lines",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligStick","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","stick"),t.setLogCmd("style chemicals stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","ball and stick"),t.setLogCmd("style chemicals ball and stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligSchematic","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","schematic"),t.setLogCmd("style chemicals schematic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","sphere"),t.setLogCmd("style chemicals sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligNo","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","nothing"),t.setLogCmd("style chemicals nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_glycansCartYes","click",(function(s){let i=e.icn3d;i.bGlycansCartoon=!0,i.drawCls.draw(),t.setLogCmd("glycans cartoon yes",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_glycansCartNo","click",(function(s){let i=e.icn3d;i.bGlycansCartoon=!1,i.drawCls.draw(),t.setLogCmd("glycans cartoon no",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_hydrogensYes","click",(function(s){let i=e.icn3d;i.showInterCls.showHydrogens(),i.drawCls.draw(),t.setLogCmd("hydrogens",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_hydrogensNo","click",(function(s){let i=e.icn3d;i.showInterCls.hideHydrogens(),i.drawCls.draw(),t.setLogCmd("set hydrogens off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ionsSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("ions","sphere"),t.setLogCmd("style ions sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ionsDot","click",(function(s){e.icn3d.setOptionCls.setStyle("ions","dot"),t.setLogCmd("style ions dot",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ionsNo","click",(function(s){e.icn3d.setOptionCls.setStyle("ions","nothing"),t.setLogCmd("style ions nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_waterSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("water","sphere"),t.setLogCmd("style water sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_waterDot","click",(function(s){e.icn3d.setOptionCls.setStyle("water","dot"),t.setLogCmd("style water dot",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_waterNo","click",(function(s){e.icn3d.setOptionCls.setStyle("water","nothing"),t.setLogCmd("style water nothing",!0)}))}clickMenu4(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrum","click",(function(s){e.icn3d.setOptionCls.setOption("color","spectrum"),t.setLogCmd("color spectrum",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrumChain","click",(function(s){e.icn3d.setOptionCls.setOption("color","spectrum for chains"),t.setLogCmd("color spectrum for chains",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrumAcrossSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorSpectrumAcross").length&&$("#"+e.pre+"atomsCustomColorSpectrumAcross").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorspectrumacrosssets","Please select sets to apply spectrum color for sets"),$("#"+e.pre+"atomsCustomColorSpectrumAcross").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrumSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorSpectrum").length&&$("#"+e.pre+"atomsCustomColorSpectrum").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorspectrumbysets","Please select sets to apply spectrum color for residues"),$("#"+e.pre+"atomsCustomColorSpectrum").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrRainbowAcrossSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorRainbowAcross").length&&$("#"+e.pre+"atomsCustomColorRainbowAcross").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorrainbowacrosssets","Please select sets to apply rainbow color for sets"),$("#"+e.pre+"atomsCustomColorRainbowAcross").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrRainbowSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorRainbow").length&&$("#"+e.pre+"atomsCustomColorRainbow").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorrainbowbysets","Please select sets to apply rainbow color for residues"),$("#"+e.pre+"atomsCustomColorRainbow").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrRainbow","click",(function(s){e.icn3d.setOptionCls.setOption("color","rainbow"),t.setLogCmd("color rainbow",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrRainbowChain","#"+e.pre+"tool_clrRainbowChain"],"click",(function(s){e.icn3d.setOptionCls.setOption("color","rainbow for chains"),t.setLogCmd("color rainbow for chains",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrChain","#"+e.pre+"tool_clrChain"],"click",(function(s){e.icn3d.setOptionCls.setOption("color","chain"),t.setLogCmd("color chain",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrStructure","click",(function(s){e.icn3d.setOptionCls.setOption("color","structure"),t.setLogCmd("color structure",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrdomain","click",(function(s){e.icn3d.setOptionCls.setOption("color","domain"),t.setLogCmd("color domain",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrsets","click",(function(s){e.icn3d.setOptionCls.setOption("color","defined sets"),t.setLogCmd("color defined sets",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrSSGreen","#"+e.pre+"tool_clrSSGreen"],"click",(function(s){let i=e.icn3d;i.sheetcolor="green",i.setOptionCls.setOption("color","secondary structure green"),t.setLogCmd("color secondary structure green",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSSYellow","click",(function(s){let i=e.icn3d;i.sheetcolor="yellow",i.setOptionCls.setOption("color","secondary structure yellow"),t.setLogCmd("color secondary structure yellow",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSSSpectrum","click",(function(s){e.icn3d.setOptionCls.setOption("color","secondary structure spectrum"),t.setLogCmd("color secondary structure spectrum",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrResidue","click",(function(s){e.icn3d.setOptionCls.setOption("color","residue"),t.setLogCmd("color residue",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrResidueCustom","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_rescolorfile","Please input the file on residue colors")})),e.myEventCls.onIds("#"+e.pre+"reload_rescolorfile","click",(function(s){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close");let n=$("#"+e.pre+"rescolorfile")[0].files[0];if(n){e.htmlCls.setHtmlCls.fileSupport();let s=new FileReader;s.onload=function(s){let n=s.target.result.replace(/#/g,"");i.customResidueColors=JSON.parse(n);for(let t in i.customResidueColors)i.customResidueColors[t.toUpperCase()]=e.parasCls.thr("#"+i.customResidueColors[t]);i.setOptionCls.setOption("color","residue custom"),t.setLogCmd("color residue custom | "+n,!0)},s.readAsText(n)}else alert("Please select a file before clicking 'Load'")})),e.myEventCls.onIds("#"+e.pre+"reload_customcolorfile","click",(function(s){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close"),i.startColor=$("#"+e.pre+"startColor").val(),i.midColor=$("#"+e.pre+"midColor").val(),i.endColor=$("#"+e.pre+"endColor").val();let n=t.setLegendHtml();$("#"+e.pre+"dl_legend").html(n),e.htmlCls.dialogCls.openDlg("dl_legend","Color range"),i.addTrackCls.setCustomFile("color",i.startColor,i.midColor,i.endColor)})),e.myEventCls.onIds("#"+e.pre+"mn6_customref","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_customref","Set custom reference numbers")})),e.myEventCls.onIds("#"+e.pre+"reload_customreffile","click",(function(s){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close");let n=$("#"+i.pre+"cstreffile")[0].files[0];if(n){e.utilsCls.checkFileAPI();let s=new FileReader;s.onload=async function(e){let s=e.target.result;await i.refnumCls.parseCustomRefFile(s),s=s.replace(/\r/g,"").replace(/\n/g,"\\n"),t.setLogCmd("custom refnum | "+s,!0)},s.readAsText(n)}else alert("Please select a file before clicking 'Apply'")})),e.myEventCls.onIds("#"+e.pre+"remove_legend","click",(function(s){e.icn3d,$("#"+e.pre+"legend").hide(),t.setLogCmd("remove legend",!0)})),e.myEventCls.onIds("#"+e.pre+"reload_customtubefile","click",(function(t){let s=e.icn3d;e.cfg.notebook||dialog.dialog("close"),s.addTrackCls.setCustomFile("tube")})),e.myEventCls.onIds("#"+e.pre+"mn4_clrCharge","click",(function(s){e.icn3d.setOptionCls.setOption("color","charge"),t.setLogCmd("color charge",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrHydrophobic","click",(function(s){e.icn3d.setOptionCls.setOption("color","hydrophobic"),t.setLogCmd("color hydrophobic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrNormalizedHP","click",(function(s){e.icn3d.setOptionCls.setOption("color","normalized hydrophobic"),t.setLogCmd("color normalized hydrophobic",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrAtom","#"+e.pre+"tool_clrAtom"],"click",(function(s){e.icn3d.setOptionCls.setOption("color","atom"),t.setLogCmd("color atom",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrBfactor","click",(function(s){e.icn3d.setOptionCls.setOption("color","b factor"),t.setLogCmd("color b factor",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrConfidence","click",(function(s){e.icn3d.setOptionCls.setOption("color","confidence"),t.setLogCmd("color confidence",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrIgstrand","click",(function(s){e.icn3d.setOptionCls.setOption("color","ig strand"),t.setLogCmd("color ig strand",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrArea","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_colorbyarea","Color based on residue's solvent accessibility")})),e.myEventCls.onIds("#"+e.pre+"applycolorbyarea","click",(function(s){let i=e.icn3d;i.midpercent=$("#"+e.pre+"midpercent").val(),i.setOptionCls.setOption("color","area"),t.setLogCmd("color area | "+i.midpercent,!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrBfactorNorm","click",(function(s){e.icn3d.setOptionCls.setOption("color","b factor percentile"),t.setLogCmd("color b factor percentile",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrIdentity","click",(function(s){e.icn3d.setOptionCls.setOption("color","identity"),t.setLogCmd("color identity",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrConserved","click",(function(s){e.icn3d.setOptionCls.setOption("color","conservation"),t.setLogCmd("color conservation",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrCustom","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_clr","Color picker")})),$(document).on("click",".icn3d-color-rad-text",(function(s){let i=e.icn3d;s.stopImmediatePropagation(),s.preventDefault();let n=$(this).attr("color");i.setOptionCls.setOption("color",n),t.setLogCmd("color "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSave","click",(function(s){e.icn3d.setOptionCls.saveColor(),t.setLogCmd("save color",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrApplySave","click",(function(s){e.icn3d.setOptionCls.applySavedColor(),t.setLogCmd("apply saved color",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_styleSave","click",(function(s){e.icn3d.setOptionCls.saveStyle(),t.setLogCmd("save style",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_styleApplySave","click",(function(s){e.icn3d.setOptionCls.applySavedStyle(),t.setLogCmd("apply saved style",!0)}))}clickMenu5(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds("#"+e.pre+"mn5_neighborsYes","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.applyMapCls.removeLastSurface(),i.applyMapCls.applySurfaceOptions(),i.bRender&&i.drawCls.render(),t.setLogCmd("set surface neighbors on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_neighborsNo","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.applyMapCls.removeLastSurface(),i.applyMapCls.applySurfaceOptions(),i.bRender&&i.drawCls.render(),t.setLogCmd("set surface neighbors off",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn5_surfaceVDW","#"+e.pre+"tool_surfaceVDW"],"click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.setOptionCls.setOption("surface","Van der Waals surface"),t.setLogCmd("set surface Van der Waals surface",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceSAS","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.setOptionCls.setOption("surface","solvent accessible surface"),t.setLogCmd("set surface solvent accessible surface",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceMolecular","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.setOptionCls.setOption("surface","molecular surface"),t.setLogCmd("set surface molecular surface",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceVDWContext","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.setOptionCls.setOption("surface","Van der Waals surface with context"),t.setLogCmd("set surface Van der Waals surface with context",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceSASContext","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.setOptionCls.setOption("surface","solvent accessible surface with context"),t.setLogCmd("set surface solvent accessible surface with context",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceMolecularContext","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.setOptionCls.setOption("surface","molecular surface with context"),t.setLogCmd("set surface molecular surface with context",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceNo","click",(function(s){e.icn3d.setOptionCls.setOption("surface","nothing"),t.setLogCmd("set surface nothing",!0)})),$(document).on("click","."+e.pre+"mn5_opacity",(function(s){let i=e.icn3d;i.transparentRenderOrder=!1;let n=$(this).attr("v");i.setOptionCls.setOption("opacity",n),t.setLogCmd("set surface opacity "+n,!0)})),$(document).on("click","."+e.pre+"mn5_opacityslow",(function(s){let i=e.icn3d;i.transparentRenderOrder=!0;let n=$(this).attr("v");i.setOptionCls.setOption("opacity",n),t.setLogCmd("set surface2 opacity "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_wireframeYes","click",(function(s){e.icn3d.setOptionCls.setOption("wireframe","yes"),t.setLogCmd("set surface wireframe on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_wireframeNo","click",(function(s){e.icn3d.setOptionCls.setOption("wireframe","no"),t.setLogCmd("set surface wireframe off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_elecmap2fofc","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_elecmap2fofc","2Fo-Fc Electron Density Map")})),e.myEventCls.onIds("#"+e.pre+"mn5_elecmapfofc","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_elecmapfofc","Fo-Fc Electron Density Map")})),e.myEventCls.onIds(["#"+e.pre+"mn5_elecmapNo","#"+e.pre+"elecmapNo2","#"+e.pre+"elecmapNo3","#"+e.pre+"elecmapNo4","#"+e.pre+"elecmapNo5"],"click",(function(s){e.icn3d.setOptionCls.setOption("map","nothing"),t.setLogCmd("setoption map nothing",!0)})),e.myEventCls.onIds(["#"+e.pre+"delphimapNo","#"+e.pre+"phimapNo","#"+e.pre+"phiurlmapNo","#"+e.pre+"mn1_phimapNo"],"click",(function(s){e.icn3d.setOptionCls.setOption("phimap","nothing"),t.setLogCmd("setoption phimap nothing",!0)})),e.myEventCls.onIds(["#"+e.pre+"delphimapNo2","#"+e.pre+"phimapNo2","#"+e.pre+"phiurlmapNo2"],"click",(function(s){e.icn3d.setOptionCls.setOption("phisurface","nothing"),t.setLogCmd("setoption phisurface nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"applymap2fofc","click",(function(s){let i=e.icn3d,n=parseFloat($("#"+e.pre+"sigma2fofc").val());i.dsn6ParserCls.dsn6Parser(i.inputid,"2fofc",n),t.setLogCmd("set map 2fofc sigma "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"applymapfofc","click",(function(s){let i=e.icn3d,n=parseFloat($("#"+e.pre+"sigmafofc").val());i.dsn6ParserCls.dsn6Parser(i.inputid,"fofc",n),t.setLogCmd("set map fofc sigma "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_mapwireframeYes","click",(function(s){e.icn3d.setOptionCls.setOption("mapwireframe","yes"),t.setLogCmd("set map wireframe on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_mapwireframeNo","click",(function(s){e.icn3d.setOptionCls.setOption("mapwireframe","no"),t.setLogCmd("set map wireframe off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_emmap","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_emmap","EM Density Map")})),e.myEventCls.onIds(["#"+e.pre+"mn5_emmapNo","#"+e.pre+"emmapNo2"],"click",(function(s){e.icn3d.setOptionCls.setOption("emmap","nothing"),t.setLogCmd("setoption emmap nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"applyemmap","click",(function(s){let i=e.icn3d,n=parseFloat($("#"+e.pre+"empercentage").val());i.densityCifParserCls.densityCifParser(i.inputid,"em",n,i.emd),t.setLogCmd("set emmap percentage "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_emmapwireframeYes","click",(function(s){e.icn3d.setOptionCls.setOption("emmapwireframe","yes"),t.setLogCmd("set emmap wireframe on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_emmapwireframeNo","click",(function(s){e.icn3d.setOptionCls.setOption("emmapwireframe","no"),t.setLogCmd("set emmap wireframe off",!0)}))}clickMenu6(){let e=this.icn3dui,t=e.icn3d;if(e.bNode)return;let s=this;e.myEventCls.onIds("#"+e.pre+"mn6_assemblyYes","click",(function(t){let i=e.icn3d;i.bAssembly=!0,s.setLogCmd("set assembly on",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_assemblyNo","click",(function(t){let i=e.icn3d;i.bAssembly=!1,s.setLogCmd("set assembly off",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_igrefYes","click",(async function(t){let i=e.icn3d;s.setLogCmd("ig refnum on",!0),await i.refnumCls.showIgRefNum()})),e.myEventCls.onIds("#"+e.pre+"mn6_igrefNo","click",(async function(t){let i=e.icn3d;s.setLogCmd("ig refnum off",!0),await i.refnumCls.hideIgRefNum()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelAtoms","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addAtomLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add atom labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelElements","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addAtomLabels(i.hAtoms,!0),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add element labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelResidues","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addResidueLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add residue labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelResnum","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addResidueLabels(i.hAtoms,void 0,void 0,!0),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add residue number labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelChains","click",(function(t){let i=e.icn3d;i.analysisCls.addChainLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add chain labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelTermini","click",(function(t){let i=e.icn3d;i.analysisCls.addTerminiLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add terminal labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelYes","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_addlabel","Add custom labels by selection"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelSelection","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_addlabelselection","Add custom labels by the selected")})),e.myEventCls.onIds("#"+e.pre+"mn6_labelColor","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_labelColor","Change color for all labels")})),e.myEventCls.onIds(["#"+e.pre+"mn2_saveselection","#"+e.pre+"tool_saveselection"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_saveselection","Save the selected")})),e.myEventCls.onIds(["#"+e.pre+"mn6_addlabelNo","#"+e.pre+"removeLabels"],"click",(function(t){let i=e.icn3d;i.labelcolor=void 0,i.pickpair=!1;s.setLogCmd("set labels off",!0);for(let e in i.labels)i.labels[e]=[];i.drawCls.draw()})),$(document).on("click","."+e.pre+"mn6_labelscale",(function(t){let i=e.icn3d,n=$(this).attr("v");i.labelScale=n,i.drawCls.draw(),s.setLogCmd("set label scale "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_distanceYes","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_distance","Measure the distance of atoms"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0,s.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_distTwoSets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_disttwosets","Measure the distance between two sets"),s.setSetsMenus("atomsCustomDist"),i.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_distManySets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_distmanysets","Measure the pairwise distance among many sets"),s.setSetsMenus("atomsCustomDistTable"),i.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_distanceNo","click",(function(t){let i=e.icn3d;i.pickpair=!1;s.setLogCmd("set lines off",!0),i.labels.distance=[],i.lines.distance=[],i.distPnts=[],i.pk=2,i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn5_cartoonshape","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_cartoonshape","Draw cartoon for a set");s.setSetsMenus("cartoonshape",!0),i.bCartoonshape=!0})),e.myEventCls.onIds("#"+e.pre+"mn5_linebtwsets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_linebtwsets","Draw a line between two sets"),s.setSetsMenus("linebtwsets"),i.bLinebtwsets=!0})),e.myEventCls.onIds(["#"+e.pre+"mn2_selectedcenter","#"+e.pre+"zoomin_selection","#"+e.pre+"tool_selectedcenter"],"click",(function(t){let i=e.icn3d;i.transformCls.zoominSelection(),i.drawCls.draw(),s.setLogCmd("zoom selection",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_center","click",(function(t){let i=e.icn3d;i.applyCenterCls.centerSelection(),i.drawCls.draw(),s.setLogCmd("center selection",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_resetOrientation","#"+e.pre+"resetOrientation","#"+e.pre+"tool_resetOrientation"],"click",(function(t){let i=e.icn3d;i.transformCls.resetOrientation(),i.drawCls.draw(),s.setLogCmd("reset orientation",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_chemicalbindingshow","#"+e.pre+"chemicalbindingshow"],"click",(function(t){e.icn3d.setOptionCls.setOption("chemicalbinding","show"),s.setLogCmd("set chemicalbinding show",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_chemicalbindinghide","#"+e.pre+"chemicalbindinghide"],"click",(function(t){e.icn3d.setOptionCls.setOption("chemicalbinding","hide"),s.setLogCmd("set chemicalbinding hide",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_sidebyside","click",(function(t){let i=e.icn3d;if(i.bInputfile)return void alert("Side-by-Side does NOT work when the input is from a local file.");let n=i.shareLinkCls.shareLinkUrl(void 0);n=n.replace("full.html","full2.html"),n+="&closepopup=1";let l=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(n,l),s.setLogCmd("side by side | "+n,!0)})),$(document).on("click","."+e.pre+"mn6_rotate",(function(t){let i=e.icn3d,n=$(this).attr("v").toLowerCase(),l=n.split(" ")[1];s.setLogCmd(n,!0),i.bStopRotate=!1,i.transformCls.rotateCount=0,i.transformCls.rotateCountMax=6e3,i.ROT_DIR=l,i.resizeCanvasCls.rotStruc(l)})),$(document).on("click","."+e.pre+"mn6_rotate90",(function(t){let i,n=e.icn3d,l=$(this).attr("v").toLowerCase(),r=l.split("-")[0];s.setLogCmd(l,!0),"x"==r?i=new THREE.Vector3(1,0,0):"y"==r?i=new THREE.Vector3(0,1,0):"z"==r&&(i=new THREE.Vector3(0,0,1));let o=.5*Math.PI;n.transformCls.setRotation(i,o)})),e.myEventCls.onIds("#"+e.pre+"mn6_cameraPers","click",(function(t){e.icn3d.setOptionCls.setOption("camera","perspective"),s.setLogCmd("set camera perspective",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_cameraOrth","click",(function(t){e.icn3d.setOptionCls.setOption("camera","orthographic"),s.setLogCmd("set camera orthographic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_bkgdBlack","click",(function(t){e.icn3d.setStyleCls.setBackground("black")})),e.myEventCls.onIds("#"+e.pre+"tool_bkgd","click",(function(t){let s=e.icn3d;"black"==s.opts.background?s.setStyleCls.setBackground("white"):s.setStyleCls.setBackground("black")})),e.myEventCls.onIds("#"+e.pre+"mn6_bkgdGrey","click",(function(t){e.icn3d.setStyleCls.setBackground("grey")})),e.myEventCls.onIds(["#"+e.pre+"mn6_bkgdWhite","#"+e.pre+"tool_bkgdWhite"],"click",(function(t){e.icn3d.setStyleCls.setBackground("white")})),e.myEventCls.onIds("#"+e.pre+"mn6_bkgdTransparent","click",(function(t){e.icn3d.setStyleCls.setBackground("transparent")})),e.myEventCls.onIds("#"+e.pre+"mn6_showfogYes","click",(function(t){let i=e.icn3d;i.opts.fog="yes",i.fogCls.setFog(!0),i.drawCls.draw(),s.setLogCmd("set fog on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showfogNo","click",(function(t){let i=e.icn3d;i.opts.fog="no",i.fogCls.setFog(!0),i.drawCls.draw(),s.setLogCmd("set fog off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showslabYes","click",(function(t){e.icn3d.setOptionCls.setOption("slab","yes"),s.setLogCmd("set slab on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showslabNo","click",(function(t){e.icn3d.setOptionCls.setOption("slab","no"),s.setLogCmd("set slab off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showaxisYes","click",(function(t){e.icn3d.setOptionCls.setOption("axis","yes"),s.setLogCmd("set axis on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showaxisSel","click",(function(t){let i=e.icn3d;i.pc1=!0,i.axesCls.setPc1Axes(),s.setLogCmd("set pc1 axis",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showaxisNo","click",(function(t){let i=e.icn3d;i.pc1=!1,i.axes=[],i.setOptionCls.setOption("axis","no"),s.setLogCmd("set axis off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_symmetry","click",(async function(t){let s=e.icn3d;s.bAxisOnly=!1,await s.symdCls.retrieveSymmetry(Object.keys(s.structures)[0])})),e.myEventCls.onIds("#"+e.pre+"mn6_symd","click",(async function(t){let i=e.icn3d;i.bAxisOnly=!1,await i.symdCls.retrieveSymd(),i.bSymd=!0,s.setLogCmd("symd symmetry",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_clear_sym","click",(function(t){let i=e.icn3d;i.symdArray=[],i.drawCls.draw(),s.setLogCmd("clear symd symmetry",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_axes_only","click",(function(t){let i=e.icn3d;i.bAxisOnly=!0,i.drawCls.draw(),s.setLogCmd("show axis",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_area","click",(function(t){e.icn3d.analysisCls.calculateArea(),s.setLogCmd("area",!0)})),e.myEventCls.onIds("#"+e.pre+"applysymmetry","click",(function(t){let i=e.icn3d;i.bAxisOnly=!1;let n=$("#"+e.pre+"selectSymmetry").val();i.symmetrytitle="none"===n?void 0:n,i.drawCls.draw(),s.setLogCmd("symmetry "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"clearsymmetry","click",(function(t){let i=e.icn3d;i.symmetrytitle=void 0,i.drawCls.draw(),s.setLogCmd("symmetry none",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_hbondsYes","#"+e.pre+"hbondsYes"],"click",(function(t){let i=e.icn3d;s.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomHbond").length&&$("#"+e.pre+"atomsCustomHbond").html(" "+n),$("#"+e.pre+"atomsCustomHbond2").length&&$("#"+e.pre+"atomsCustomHbond2").html(" "+n),e.htmlCls.dialogCls.openDlg("dl_hbonds","Hydrogen bonds/interactions between two sets of atoms"),i.bHbondCalc=!1,$("#"+e.pre+"atomsCustomHbond").resizable(),$("#"+e.pre+"atomsCustomHbond2").resizable()})),e.myEventCls.onIds(["#"+e.pre+"mn6_contactmap"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_contact","Set contact map")})),e.myEventCls.onIds("#"+e.pre+"mn6_hbondsNo","click",(function(t){let s=e.icn3d;s.showInterCls.hideHbondsContacts(),s.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerYes","click",(function(t){let i=e.icn3d;i.threeDPrintCls.addStabilizer(),i.threeDPrintCls.prepareFor3Dprint(),s.setLogCmd("stabilizer",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerNo","click",(function(t){let i=e.icn3d;s.setLogCmd("set stabilizer off",!0),i.threeDPrintCls.hideStabilizer(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerOne","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_stabilizer","Add One Stabilizer"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerRmOne","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_stabilizer_rm","Remove One Stabilizer"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0})),e.myEventCls.onIds("#"+e.pre+"mn1_thicknessSet","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_thickness","Set Thickness for 3D Printing")})),e.myEventCls.onIds("#"+e.pre+"mn3_setThickness","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_thickness2","Style Preferences")})),e.myEventCls.onIds("#"+e.pre+"mn6_ssbondsYes","click",(function(t){let i=e.icn3d;s.setLogCmd("disulfide bonds",!0),i.showInterCls.showSsbonds()})),e.myEventCls.onIds("#"+e.pre+"mn6_ssbondsExport","click",(function(t){e.icn3d.viewInterPairsCls.exportSsbondPairs(),s.setLogCmd("export disulfide bond pairs",!1)})),e.myEventCls.onIds("#"+e.pre+"mn6_ssbondsNo","click",(function(t){let i=e.icn3d;i.opts.ssbonds="no";s.setLogCmd("set disulfide bonds off",!0),i.lines.ssbond=[],i.setOptionCls.setStyle("sidec","nothing")})),e.myEventCls.onIds("#"+e.pre+"mn6_clbondsYes","click",(function(t){let i=e.icn3d;s.setLogCmd("cross linkage",!0),i.showInterCls.showClbonds()})),e.myEventCls.onIds("#"+e.pre+"mn6_clbondsExport","click",(function(t){e.icn3d.viewInterPairsCls.exportClbondPairs(),s.setLogCmd("export cross linkage pairs",!1)})),e.myEventCls.onIds("#"+e.pre+"mn6_clbondsNo","click",(function(t){let i=e.icn3d;i.opts.clbonds="no";s.setLogCmd("set cross linkage off",!0),i.lines.clbond=[],i.setOptionCls.setStyle("sidec","nothing")})),$("#"+e.pre+"newvs2").on("submit",(function(){let s=t.saveFileCls.getAtomPDB(t.hAtoms);return $("#"+e.pre+"pdbstr").val(s),!0})),$("#"+e.pre+"fssubmit").on("click",(function(){let e=t.saveFileCls.getAtomPDB(t.hAtoms),s=window.open("","_blank");s.document.body.innerHTML="\n\nLoading Foldseek\n\n\n\n
Foldseek is loading...
\n",$.ajax({url:"https://search.foldseek.com/api/ticket",type:"POST",data:{q:e,database:["afdb50","afdb-swissprot","gmgcl_id","pdb100","afdb-proteome","mgnify_esm30"],mode:"3diaa"},dataType:"text",success:function(e){s.location="https://search.foldseek.com/queue/"+JSON.parse(e).id},error:function(e,t,s){console.log("Error in submitting data to Foldseek...")}})}))}setLogCmd(e,t,s){var i=this.icn3dui,n=i.icn3d;if(""===e.trim())return!1;let l=e.indexOf("|||");-1!==l&&(e=e.substr(0,l));let r={};if(r.factor=n._zoomFactor,r.mouseChange=n.mouseChange,r.quaternion={},r.quaternion._x=parseFloat(n.quaternion._x).toPrecision(5),r.quaternion._y=parseFloat(n.quaternion._y).toPrecision(5),r.quaternion._z=parseFloat(n.quaternion._z).toPrecision(5),r.quaternion._w=parseFloat(n.quaternion._w).toPrecision(5),t&&n.bAddCommands)if(n.STATENUMBER "+n.logs.join("\n> ")+"\n> "),$("#"+i.pre+"logtext")[0]&&$("#"+i.pre+"logtext").scrollTop($("#"+i.pre+"logtext")[0].scrollHeight)}n.setStyleCls.adjustIcon()}}class d{constructor(e){this.icn3dui=e}getLink(e,t,s,i){return this.icn3dui.htmlCls.setHtmlCls.getLink(e,t,s,i)}getMenuText(e,t,s,i,n){return this.icn3dui.htmlCls.setHtmlCls.getMenuText(e,t,s,i,n)}getMenuUrl(e,t,s,i,n){return this.icn3dui.htmlCls.setHtmlCls.getMenuUrl(e,t,s,i,n)}getMenuSep(){return this.icn3dui.htmlCls.setHtmlCls.getMenuSep()}getLinkWrapper(e,t,s,i,n,l){let r=this.icn3dui;return r.icn3d,r.htmlCls.setHtmlCls.getLinkWrapper(e,t,s,i,n,l)}getLinkWrapper2(e,t,s,i,n){let l=this.icn3dui;return l.icn3d,l.htmlCls.setHtmlCls.getLinkWrapper2(e,t,s,i,n)}getRadio(e,t,s,i,n,l){return this.icn3dui.htmlCls.setHtmlCls.getRadio(e,t,s,i,n,l)}getRadClr(e,t,s,i,n,l,r){return this.icn3dui.htmlCls.setHtmlCls.getRadioColor(e,t,s,i,n,l,r)}setTopMenusHtml(e,t,s){let i=this.icn3dui;if(i.bNode)return"";let n="black"==i.htmlCls.opts.background?i.htmlCls.GREYD:"black",l="";l+="
",l+=i.htmlCls.divStr+"popup' class='icn3d-text icn3d-popup'>
",l+=this.setReplayHtml(),l+="\x3c!--https://forum.jquery.com/topic/looking-for-a-jquery-horizontal-menu-bar--\x3e",l+=i.htmlCls.divStr+"mnlist' style='position:absolute; z-index:999; float:left; display:table-row; margin-top: -2px;'>",l+="";let r='",l+=r+this.setMenu2()+"",l+=r+this.setMenu2b()+"",l+=r+this.setMenu3()+"",l+=r+this.setMenu4()+"",l+=r+this.setMenu5()+"",l+=r+this.setMenu6()+"",i.htmlCls.shownMenus=i.hashUtilsCls.cloneHash(i.htmlCls.simpleMenus),l+=r+"
"+t,l+="
"+s,l+=r+'
'+i.htmlCls.space2+'Toolbar '+i.htmlCls.space2+'
",l+=r+'
'+i.htmlCls.space2+' ?
',l+="
",l+="
';if(l+=r+this.setMenu1()+"
",l+="",l+=this.setTools(),l+=i.htmlCls.divStr+"title' class='icn3d-commandTitle' style='font-size:1.2em; font-weight:normal; position:absolute; z-index:1; float:left; display:table-row; margin: 85px 0px 0px 5px; color:"+n+"; width:"+i.htmlCls.WIDTH+"px'>",l+=i.htmlCls.divStr+"viewer' style='position:relative; width:100%; height:100%; background-color: "+i.htmlCls.GREYD+";'>",l+=i.htmlCls.divStr+"mnLogSection'>",l+="
",l+=" ",void 0===i.cfg.mmtfid){let e="top:180px; font-size: 1.8em;";l+=i.htmlCls.divStr+"wait' style='position:absolute; left:50px; "+e+" color: #444444;'>Loading data..."}l+="Your browser does not support WebGL.",(void 0===i.cfg.showcommand||i.cfg.showcommand)&&(l+=this.setLogWindow()),l+="",l+="",l+=i.htmlCls.setDialogCls.setDialogs(),l+=i.htmlCls.setDialogCls.setCustomDialogs(),$("#"+e).html(l),$("accordion").accordion({collapsible:!0,active:!1,heightStyle:"content"}),$("accordion div").removeClass("ui-accordion-content ui-corner-all ui-corner-bottom ui-widget-content"),$(".icn3d-mn-item").menu({position:{my:"left top",at:"right top"}}),$(".icn3d-mn-item").hover((function(){}),(function(){$("accordion").accordion("option","active","none")})),$("#"+i.pre+"accordion1").hover((function(){$("#"+i.pre+"accordion1 div").css("display","block")}),(function(){$("#"+i.pre+"accordion1 div").css("display","none")})),$("#"+i.pre+"accordion2").hover((function(){$("#"+i.pre+"accordion2 div").css("display","block")}),(function(){$("#"+i.pre+"accordion2 div").css("display","none")})),$("#"+i.pre+"accordion2b").hover((function(){$("#"+i.pre+"accordion2b div").css("display","block")}),(function(){$("#"+i.pre+"accordion2b div").css("display","none")})),$("#"+i.pre+"accordion3").hover((function(){$("#"+i.pre+"accordion3 div").css("display","block")}),(function(){$("#"+i.pre+"accordion3 div").css("display","none")})),$("#"+i.pre+"accordion4").hover((function(){$("#"+i.pre+"accordion4 div").css("display","block")}),(function(){$("#"+i.pre+"accordion4 div").css("display","none")})),$("#"+i.pre+"accordion5").hover((function(){$("#"+i.pre+"accordion5 div").css("display","block")}),(function(){$("#"+i.pre+"accordion5 div").css("display","none")})),$("#"+i.pre+"accordion6").hover((function(){$("#"+i.pre+"accordion6 div").css("display","block")}),(function(){$("#"+i.pre+"accordion6 div").css("display","none")}))}setTopMenusHtmlMobile(e,t,s){let i=this.icn3dui;if(i.bNode)return"";let n="black"==i.htmlCls.opts.background?i.htmlCls.GREYD:"black",l="";if(l+="
",l+=i.htmlCls.divStr+"popup' class='icn3d-text icn3d-popup'>
",l+=this.setReplayHtml(),!i.utilsCls.isMobile()){let e=i.htmlCls.WIDTH-40+5;l+=i.htmlCls.buttonStr+"fullscreen' style='position:absolute; z-index:1999; display:block; padding:0px; margin: 12px 0px 0px "+e+"px; width:30px; height:34px; border-radius:4px; border:none; background-color:#f6f6f6;' title='Full screen'>",l+="",l+="",l+="",l+="",l+=""}l+="\x3c!--https://forum.jquery.com/topic/looking-for-a-jquery-horizontal-menu-bar--\x3e",l+=i.htmlCls.divStr+"mnlist' style='position:absolute; z-index:999; float:left; display:block; margin: 5px 0px 0px 5px;'>",l+="
",l+="",i.cfg.notebook?l+="

":l+="

",l+="
";let r="
  • File",l+=this.setMenu1_base(),l+=r+">Select",l+=this.setMenu2_base(),l+=r+">View",l+=this.setMenu2b_base(),l+=r+" id='"+i.pre+"style'>Style",l+=this.setMenu3_base(),l+=r+" id='"+i.pre+"color'>Color",l+=this.setMenu4_base(),l+=r+">Analysis",l+=this.setMenu5_base(),l+=r+">Help",l+=this.setMenu6_base(),i.htmlCls.shownMenus=i.hashUtilsCls.cloneHash(i.htmlCls.simpleMenus),l+="
  • "+t,l+="
    "+s,l+="
  • Alternate",l+="",l+="
  • ",l+="
    ",l+="
    ",l+="",l+=i.htmlCls.divStr+"title' class='icn3d-commandTitle' style='font-size:1.2em; font-weight:normal; position:absolute; z-index:1; float:left; display:block; margin: 12px 0px 0px 40px; color:"+n+"; width:"+(i.htmlCls.WIDTH-40).toString()+"px'>",l+=i.htmlCls.divStr+"viewer' style='position:relative; width:100%; height:100%; background-color: "+i.htmlCls.GREYD+";'>",l+=i.htmlCls.divStr+"mnLogSection'>",l+="
    ",l+="",void 0===i.cfg.mmtfid){let e="top:180px; font-size: 1.8em;";l+=i.htmlCls.divStr+"wait' style='position:absolute; left:50px; "+e+" color: #444444;'>Loading data..."}l+="Your browser does not support WebGL.",(void 0===i.cfg.showcommand||i.cfg.showcommand)&&(l+=this.setLogWindow()),l+="",l+="",l+=i.htmlCls.setDialogCls.setDialogs(),l+=i.htmlCls.setDialogCls.setCustomDialogs(),$("#"+e).html(l),$("accordion").accordion({collapsible:!0,active:!1,heightStyle:"content"}),$("accordion div").removeClass("ui-accordion-content ui-corner-all ui-corner-bottom ui-widget-content"),$(".icn3d-mn-item").menu({position:{my:"left top",at:"right top"}}),$(".icn3d-mn-item").hover((function(){}),(function(){$("accordion").accordion("option","active","none")})),$("#"+i.pre+"accordion0").hover((function(){$("#"+i.pre+"accordion0 div").css("display","block")}),(function(){$("#"+i.pre+"accordion0 div").css("display","none")}))}setReplayHtml(e){let t=this.icn3dui;if(t.bNode)return"";let s="";return s+=t.htmlCls.divStr+"replay' style='display:none; position:absolute; z-index:9999; top:"+parseInt(t.htmlCls.HEIGHT-100).toString()+"px; left:20px;'>",s+="
    ",s+='',s+="",s+='',s+='',s+="",s+="
    ",s+=t.htmlCls.divStr+"replay_menu' style='background-color:#DDDDDD; padding:3px; font-weight:bold;'>",s+=t.htmlCls.divStr+"replay_cmd' style='background-color:#DDDDDD; padding:3px; max-width:250px'>",s+="",s}setTools(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+=e.htmlCls.divStr+"selection' style='display:none;'>
    ",t+="",t+=this.setTools_base(),t+="
    ",t+="
    ",t}setButton(e,t,s,i,n){let l=this.icn3dui;return l.bNode?"":(n=void 0!==n?"color:"+n:"","
    ")}setIcon(e,t,s,i,n,l,r){let o=this.icn3dui;if(o.bNode)return"";let a,d=r?"color:#f8b84e; ":"color:#1c94c4; ",c=" background-color:#EEE; ",h="text"==e?"":"cursor:pointer;";return a=l?'
    '+i+"
    ":'',"link"==e?''+a+"":a}setTools_base(){if(this.icn3dui.bNode)return"";let e="",t="regular",s="",i="";return e+=s+this.setIcon(t,"tool_mmdbafid","Input PDB/MMDB/AlphaFold IDs","id",void 0,!0)+"",e+=s+this.setIcon(t,"tool_pdbfile","Input PDB Files (appendable)","file-alt")+"",e+=s+this.setIcon(t,"tool_sharelink","Get Share Link","link")+"",e+=s+this.setIcon(t,"saveimage","Save iCn3D PNG Image","camera")+"",e+=i+this.setIcon(t,"tool_definedsets","Defined Sets","object-group")+"",e+=s+this.setIcon(t,"tool_aroundsphere","Select by Distance","dot-circle")+"",e+=s+this.setIcon(t,"tool_saveselection","Save Selection as a Set","save")+"",e+=s+this.setIcon(t,"toggleHighlight","Toggle Highlight","highlighter")+"",e+=i+this.setIcon(t,"show_selected","View Selection","eye")+"",e+=s+this.setIcon(t,"tool_selectedcenter","Zoom in Selection","search-plus")+"",e+=s+this.setIcon(t,"alternate","Alternate the Structures by keying the letter 'a'","a",void 0,!0,!0)+"",e+=s+this.setIcon(t,"tool_resetOrientation","Reset Orientation","undo-alt")+"",e+=i+this.setIcon(t,"tool_proteinsRibbon","Style Ribbon for proteins","dna")+"",e+=s+this.setIcon(t,"tool_proteinsSphere","Style Sphere for proteins","volleyball-ball")+"",e+=s+this.setIcon(t,"tool_surfaceVDW","Show Van der Waals Surface","cloud")+"",e+=s+this.setIcon(t,"tool_bkgd","Toggle Background Color","adjust")+"",e+=i+this.setIcon(t,"tool_clrRainbowChain","Color Rainbow for Chains","rainbow")+"",e+=s+this.setIcon(t,"tool_clrSSGreen","Color by Secondary Structures","ring")+"",e+=s+this.setIcon(t,"tool_clrChain","Color by Chains","layer-group")+"",e+=s+this.setIcon(t,"tool_clrAtom","Color by Atoms","atom")+"",e+=i+this.setIcon(t,"tool_selectannotations","Sequences & Annotations","grip-lines")+"",e+=s+this.setIcon(t,"hbondsYes","Interactions","users")+"",e+=s+this.setIcon(t,"tool_delphi","Delphi Potentials","cloud-meatball")+"",e+=s+this.setIcon(t,"removeLabels","Remove Labels","remove-format")+"",e+=i+this.setIcon("link","tool-gallery","Gallery","image","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#gallery")+"",e+=s+this.setIcon("link","tool-video","Videos","file-video","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#videos")+"",e+=s+this.setIcon("link","tool-github","iCn3D GitHub","code","https://github.com/ncbi/icn3d")+"",e+=s+this.setIcon("link","tool-hints","Transform Hints","info-circle","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#useicn3d")+"",e+="",e}setTheme(e){let t,s,i,n,l,r=this.icn3dui;if(r.bNode)return"";r.htmlCls.themecolor=e,"orange"==e?(t="#e78f08",s="#f6a828",i="ui-bg_gloss-wave_35_f6a828_500x100.png",n="ui-icons_ef8c08_256x240.png",l="#eb8f00"):"black"==e?(t="#333333",s="#333333",i="ui-bg_gloss-wave_25_333333_500x100.png",n="ui-icons_222222_256x240.png",l="#222222"):"blue"==e&&(t="#4297d7",s="#5c9ccc",i="ui-bg_gloss-wave_55_5c9ccc_500x100.png",n="ui-icons_228ef1_256x240.png",l="#444"),$(".ui-widget-header").css({border:"1px solid "+t,background:s+' url("https://www.ncbi.nlm.nih.gov/Structure/icn3d/lib/images/'+i+'") 50% 50% repeat-x',color:"#fff","font-weight":"bold"}),$(".ui-button .ui-icon").css({"background-image":"url(https://www.ncbi.nlm.nih.gov/Structure/icn3d/lib/images/"+n+")"}),$(".ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited").css({color:l,"text-decoration":"none"})}setLogWindow(e,t){let s=this.icn3dui;if(s.bNode)return"";let i,n="",l=s.htmlCls.setHtmlCls.getCookie("cmdwindow");return""!=l?(i=void 0!==t?t:parseInt(l),1==i?(s.htmlCls.LOG_HEIGHT=180,s.htmlCls.CMD_HEIGHT=.8*s.htmlCls.LOG_HEIGHT,e||(n+=s.htmlCls.divStr+"cmdlog' style='float:left; margin-top: 5px; width: 100%;'>"),n+=""):(s.htmlCls.LOG_HEIGHT=65,s.htmlCls.CMD_HEIGHT=.8*s.htmlCls.LOG_HEIGHT,e||(n+=s.htmlCls.divStr+"cmdlog' style='float:left; margin-top: 5px; width: 100%;'>"),n+="")):(i=0,s.htmlCls.LOG_HEIGHT=65,s.htmlCls.CMD_HEIGHT=.8*s.htmlCls.LOG_HEIGHT,e||(n+=s.htmlCls.divStr+"cmdlog' style='float:left; margin-top: 5px; width: 100%;'>"),n+=""),e||(n+=""),e&&(s.htmlCls.clickMenuCls.setLogCmd("set cmdwindow "+i,!0),$("#"+s.pre+"cmdlog").html(n)),n}setMenu1(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
    ",t+="",t+="

    File

    ",t+="
    ",t+=this.setMenu1_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu1_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getMenuUrl("mn1_searchstru","https://www.ncbi.nlm.nih.gov/structure","Search Structure "+e.htmlCls.wifiStr,1,1),t+=this.getMenuText("mn1_searchsimilar","Search Similar",void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_vastplus","NCBI VAST+ (PDB Complex)"+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_vast","NCBI VAST (PDB Chain)"+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_foldseek","Foldseek (PDB & AlphaFold)"+e.htmlCls.wifiStr,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn1_retrievebyid","Retrieve by ID",void 0,1,1),t+="
        ",t+=this.getLink("mn1_mmdbafid","PDB/MMDB/AlphaFold IDs"+e.htmlCls.wifiStr,1,2),t+=this.getLink("mn1_mmdbid","NCBI MMDB ID (annotation) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_mmtfid","RCSB MMTF ID (fast) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_pdbid","RCSB PDB ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getMenuText("mn1_afwrap","AlphaFold Structures",void 0,void 0,2),t+="
          ",t+=this.getLink("mn1_afid","UniProt ID "+e.htmlCls.wifiStr,void 0,3),t+=this.getLink("mn1_refseqid","NCBI Protein Accession "+e.htmlCls.wifiStr,void 0,3),t+="
        ",t+=this.getLink("mn1_opmid","OPM PDB ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_mmcifid","RCSB mmCIF ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_cid","PubChem CID "+e.htmlCls.wifiStr,1,2),t+="
      ",t+="",t+=this.getMenuText("mn1_openfile","Open File",void 0,1,1),t+="
        ",t+=this.getLink("mn1_pdbfile_app","PDB Files (appendable)",1,2),t+=this.getLink("mn1_mmciffile","mmCIF File",void 0,2),t+=this.getLink("mn1_mol2file","Mol2 File",void 0,2),t+=this.getLink("mn1_sdffile","SDF File",void 0,2),t+=this.getLink("mn1_xyzfile","XYZ File",void 0,2),t+=this.getLink("mn1_afmapfile","AlphaFold PAE File",void 0,2),t+=this.getLink("mn1_urlfile","URL(CORS) "+e.htmlCls.wifiStr,void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_pngimage","iCn3D PNG Image",1,2),t+=this.getLink("mn1_state","State/Script File",void 0,2),t+=this.getLink("mn1_fixedversion","Share Link in Archived Ver. "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_selection","Selection File",void 0,2),t+=this.getMenuSep(),t+=this.getMenuText("mn1_dsn6wrap","Electron Density(DSN6)",void 0,void 0,2),t+="
          ",t+=this.getLink("mn1_dsn6","Local File",void 0,3),t+=this.getLink("mn1_dsn6url","URL(CORS) "+e.htmlCls.wifiStr,void 0,3),t+="
        ",t+="
      ",t+="",t+=this.getMenuText("mn1_alignwrap","Align",void 0,1,1),t+="
        ",t+=this.getMenuText("mn1_chainalignwrap","Multiple Chains",void 0,1,2),t+="
          ",t+=this.getRadio("mn1_chainalignRad","mn1_chainalign","by Structure Alignment "+e.htmlCls.wifiStr,void 0,1,3),t+=this.getRadio("mn1_chainalignRad","mn1_chainalign2","by Sequence Alignment "+e.htmlCls.wifiStr,void 0,1,3),t+=this.getRadio("mn1_chainalignRad","mn1_chainalign3","Residue by Residue",void 0,void 0,3),t+="
        ",t+="",t+=this.getMenuText("mn1_aligntwostru","Protein Complexes",void 0,void 0,2),t+="
          ",t+=this.getLink("mn1_align","Two PDB Structures "+e.htmlCls.wifiStr,void 0,3),t+=this.getLink("mn1_alignaf","Two AlphaFold Structures "+e.htmlCls.wifiStr,void 0,3),t+="
        ",t+=this.getLink("mn1_blast_rep_id","Sequence to Structure",void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_realignWrap","Realign Selection",void 0,void 0,1),t+="
        ",t+=this.getMenuText("mn2_chainrealignwrap","Multiple Chains",void 0,void 0,2),t+="
          ",t+=this.getRadio("mn2_realign","mn2_realignonstruct","by Structure Alignment "+e.htmlCls.wifiStr,void 0,void 0,3),t+=this.getRadio("mn2_realign","mn2_realignonseqalign","by Sequence Alignment "+e.htmlCls.wifiStr,void 0,void 0,3),t+=this.getRadio("mn2_realign","mn2_realignresbyres","Residue by Residue",void 0,void 0,3),t+="
        ",t+=this.getLink("mn2_realigntwostru","Protein Complexes",void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn1_3dpprint","3D Printing",void 0,1,1),t+="
        ",void 0===e.cfg.cid?(t+=this.getLink("mn1_exportVrmlStab","WRL/VRML(Color, W/ Stab.)",1,2),t+=this.getLink("mn1_exportStlStab","STL(W/ Stabilizers)",1,2),t+=this.getMenuSep(),t+=this.getLink("mn1_exportVrml","WRL/VRML(Color)",void 0,2),t+=this.getLink("mn1_exportStl","STL",void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_stabilizerYes","Add All Stabilizers",void 0,2),t+=this.getLink("mn1_stabilizerNo","Remove All Stabilizers",void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_stabilizerOne","Add One Stabilizer",void 0,2),t+=this.getLink("mn1_stabilizerRmOne","Remove One Stabilizer",void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_thicknessSet","Set Thickness",void 0,2)):(t+=this.getLink("mn1_exportVrml","VRML(Color)",1,2),t+=this.getLink("mn1_exportStl","STL",1,2)),t+="
      ",t+="",t+=this.getMenuText("mn1_savefile","Save File",void 0,1,1),t+="
        ",t+=this.getMenuText("mn1_savepngimage","iCn3D PNG Image",void 0,1,2),t+="
          ",t+=this.getLink("mn1_exportCanvas","Original Size & HTML",1,3),t+=this.getLink("mn1_exportCanvas1","Original Size",void 0,3),t+=this.getLink("mn1_exportCanvas2","2X Large",void 0,3),t+=this.getLink("mn1_exportCanvas4","4X Large",void 0,3),t+=this.getLink("mn1_exportCanvas8","8X Large",void 0,3),t+="
        ",t+="",t+=this.getLink("mn1_exportState","State File",void 0,2),t+=this.getLink("mn1_exportSelections","Selection File",void 0,2),t+=this.getLink("mn1_exportSelDetails","Selection Details",void 0,2),t+=this.getLink("mn1_exportCounts","Residue Counts",void 0,2),t+=this.getLink("mn1_exportPdbRes","PDB",1,2),t+=this.getLink("profixpdb","PDB with Missing Atoms",void 0,2),t+=this.getLink("profixpdbh","PDB with Hydrogens",void 0,2),void 0===e.cfg.cid&&(t+=this.getLink("mn1_exportSecondary","Secondary Structure",void 0,2)),t+="

      • ",t+="
      ",t+="",t+=this.getLink("mn1_sharelink","Share Link "+e.htmlCls.wifiStr,1,1),t+=this.getLink("mn1_replayon","Replay Each Step",void 0,1),t+=this.getMenuSep(),t+=this.getMenuText("mn1_menuwrap","Customize Menus",void 0,1,1),t+="
        ",t+=this.getLink("mn1_menuall","All Menus",1,2),t+=this.getLink("mn1_menusimple","Simple Menus",1,2),t+=this.getMenuSep(),t+=this.getLink("mn1_menupref","Preferences",1,2),t+=this.getLink("mn1_menuloadpref","Load Preferences",1,2),t+="
      ",t+="",t+="

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

    Select

    ",t+="
    ",t+=this.setMenu2_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu2_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getLink("mn2_definedsets","Defined Sets",1,1),t+=this.getLink("mn2_selectall","All",void 0,1),t+=this.getLink("mn2_selectdisplayed","Displayed Set",void 0,1),t+=this.getLink("mn2_aroundsphere","by Distance",1,1),t+=this.getMenuText("mn2_selbyprop","by Property",void 0,void 0,1),t+="
        ",t+=this.getLink("mn2_propPos","Positive",void 0,2),t+=this.getLink("mn2_propNeg","Negative",void 0,2),t+=this.getLink("mn2_propHydro","Hydrophobic",void 0,2),t+=this.getLink("mn2_propPolar","Polar",void 0,2),t+=this.getLink("mn2_propBfactor","B-factor/pLDDT",void 0,2),t+=this.getLink("mn2_propSolAcc","Solvent Accessibility",void 0,2),t+="
      ",t+="",t+=this.getLink("mn2_selectcomplement","Inverse",void 0,1),t+=this.getLink("mn2_selectmainchains","Main Chains",void 0,1),t+=this.getLink("mn2_selectsidechains","Side Chains",void 0,1),t+=this.getLink("mn2_selectmainsidechains","Main & Side Chains",void 0,1),t+=this.getLink("mn2_command","Advanced",void 0,1),void 0===e.cfg.cid?(t+=this.getMenuText("mn2_selon3d","Select on 3D",void 0,1,1),t+="
        ",t+='
      • "Alt"+Click: start selection
      • ',t+='
      • "Ctrl"+Click: union selection
      • ',t+='
      • "Shift"+Click: range Selection
      • ',t+=this.getMenuSep(),t+=this.getRadio("mn2_pk","mn2_pkChain","Chain",void 0,1,2),void 0===e.cfg.mmdbid&&void 0===e.cfg.gi||(t+=this.getRadio("mn2_pk","mn2_pkDomain","3D Domain",void 0,void 0,2)),t+=this.getRadio("mn2_pk","mn2_pkStrand","Strand/Helix",void 0,void 0,2),t+=this.getRadio("mn2_pk","mn2_pkResidue","Residue",!0,1,2),t+=this.getRadio("mn2_pk","mn2_pkYes","Atom",void 0,1,2),t+=this.getRadio("mn2_pk","mn2_pkNo","None",void 0,void 0,2),t+="
      ",t+=""):e.utilsCls.isMobile()?t+="
    • Touch to pick
    • ":t+='
    • Picking with
      "Alt" + Click
    • ',t+=this.getMenuSep(),t+=this.getLink("mn2_saveselection","Save Selection",1,1),t+=this.getLink("clearall","Clear Selection",void 0,1),t+=this.getLink("mn2_saveresidue","Save Res. in Sel.",1,1),t+=this.getMenuSep(),t+=this.getMenuText("mn2_hlcolor","Highlight Color",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn2_hl_clr","mn2_hl_clrYellow","Yellow",!0,void 0,2),t+=this.getRadio("mn2_hl_clr","mn2_hl_clrGreen","Green",void 0,void 0,2),t+=this.getRadio("mn2_hl_clr","mn2_hl_clrRed","Red",void 0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_hlstyle","Highlight Style",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn2_hl_style","mn2_hl_styleOutline","Outline",!0,void 0,2),t+=this.getRadio("mn2_hl_style","mn2_hl_styleObject","3D Objects",void 0,void 0,2),t+="
      ",t+="",t+=this.getLink("toggleHighlight2","Toggle Highlight",1,1),t+="

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

    View

    ",t+="
    ",t+=this.setMenu2b_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu2b_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getLink("mn2_show_selected","View Selection",1,1),t+=this.getLink("mn2_hide_selected","Hide Selection",1,1),t+=this.getLink("mn2_selectedcenter","Zoom in Selection",1,1),t+=this.getLink("mn6_center","Center Selection",1,1),t+=this.getLink("mn2_fullstru","View Full Structure"),t+=this.getLinkWrapper("mn2_alternate",'Alternate(Key "a")',"mn2_alternateWrap",void 0,1),void 0!==e.cfg.opmid?t+=this.getLinkWrapper("togglemem","Toggle Membrane","togglememli",void 0,1):void 0===e.cfg.cid&&(t+=this.getLinkWrapper("togglemem","Toggle Membrane","togglememli",void 0,1,!0)),void 0!==e.cfg.opmid&&(t+=this.getLinkWrapper("adjustmem","Adjust Membrane","adjustmemli",void 0,1),t+=this.getLinkWrapper("selectplane","Select between
      Two X-Y Planes","selectplaneli",void 0,1)),t+=this.getMenuSep(),t+=this.getMenuText("mn2_vrarhints","VR & AR Hints",void 0,1,1),t+="
        ",t+=this.getMenuUrl("vrhint",e.htmlCls.baseUrl+"icn3d/icn3d.html#vr","VR: VR Headsets",1,2),t+=this.getMenuUrl("arhint",e.htmlCls.baseUrl+"icn3d/icn3d.html#ar","AR: Chrome in Android",1,2),t+="
      ",t+="",t+=this.getLink("mn6_sidebyside","Side by Side",1,1),t+=this.getMenuText("mn2_rotate","Rotate",void 0,1,1),t+="
        ",t+=this.getMenuText("mn2_rotate90","Rotate 90°",void 0,void 0,2),t+="
          ",t+=this.getRadio("mn6_rotate90","mn6_rotatex","X-axis(Shift + Key M)",void 0,void 0,2),t+=this.getRadio("mn6_rotate90","mn6_rotatey","Y-axis(Shift + Key J)",void 0,void 0,2),t+=this.getRadio("mn6_rotate90","mn6_rotatez","Z-axis",void 0,void 0,2),t+="
        ",t+="",t+=this.getMenuText("mn2_rotateauto","Auto Rotation",void 0,1,2),t+="
          ",t+=this.getRadio("mn6_rotate","mn6_rotateleft","Rotate Left",void 0,1,3),t+=this.getRadio("mn6_rotate","mn6_rotateright","Rotate Right",void 0,1,3),t+=this.getRadio("mn6_rotate","mn6_rotateup","Rotate Up",void 0,1,3),t+=this.getRadio("mn6_rotate","mn6_rotatedown","Rotate Down",void 0,1,3),t+="
        ",t+="",t+="
      ",t+="",t+=this.getMenuText("mn2_camera","Camera",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_camera","mn6_cameraPers","Perspective",!0,void 0,2),t+=this.getRadio("mn6_camera","mn6_cameraOrth","Orthographic",void 0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_fog","Fog for Selection",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_showfog","mn6_showfogYes","On",void 0,void 0,2),t+=this.getRadio("mn6_showfog","mn6_showfogNo","Off",!0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_slab","Slab for Selection",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_showslab","mn6_showslabYes","On",void 0,void 0,2),t+=this.getRadio("mn6_showslab","mn6_showslabNo","Off",!0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_axes","XYZ-axes",void 0,1),t+="
        ",t+=this.getRadio("mn6_showaxis","mn6_showaxisYes","Original",void 0,void 0,2),t+=this.getRadio("mn6_showaxis","mn6_showaxisSel","Prin. Axes on Sel.",void 0,void 0,2),t+=this.getRadio("mn6_showaxis","mn6_showaxisNo","Hide",!0,void 0,2),t+="
      ",t+="",t+=this.getMenuSep(),t+=this.getMenuText("mn2_resetwrap","Reset",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_reset","reset","All",void 0,1,2),t+=this.getRadio("mn6_reset","mn6_resetOrientation","Orientation",void 0,1,2),t+="
      ",t+="",t+=this.getLink("mn6_back","Undo",void 0,1),t+=this.getLink("mn6_forward","Redo",void 0,1),t+=this.getLink("mn6_fullscreen","Full Screen",void 0,1),t+="

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

    Style

    ",t+="
    ",t+=this.setMenu3_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu3_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";t+="
      ",void 0===e.cfg.cid&&(t+=this.getMenuText("mn3_proteinwrap","Proteins",void 0,1,1),t+="
        ",void 0!==e.cfg.align||void 0!==e.cfg.chainalign?t+=this.getRadio("mn3_proteins","mn3_proteinsRibbon","Ribbon",void 0,1,2):t+=this.getRadio("mn3_proteins","mn3_proteinsRibbon","Ribbon",!0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsStrand","Strand",void 0,void 0,2),t+=this.getRadio("mn3_proteins","mn3_proteinsCylinder","Cylinder and Plate",void 0,void 0,2),t+=this.getRadio("mn3_proteins","mn3_proteinsSchematic","Schematic",void 0,1,2),void 0!==e.cfg.align||void 0!==e.cfg.chainalign?t+=this.getRadio("mn3_proteins","mn3_proteinsCalpha","C Alpha Trace",!0,1,2):t+=this.getRadio("mn3_proteins","mn3_proteinsCalpha","C Alpha Trace",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsBackbone","Backbone",void 0,void 0,2),t+=this.getRadio("mn3_proteins","mn3_proteinsBfactor","B-factor Tube",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsLines","Lines",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsStick","Stick",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsBallstick","Ball and Stick",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_sidecwrap","Side Chains",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_sidec","mn3_sidecLines","Lines",void 0,1,2),t+=this.getRadio("mn3_sidec","mn3_sidecStick","Stick",void 0,1,2),t+=this.getRadio("mn3_sidec","mn3_sidecBallstick","Ball and Stick",void 0,1,2),t+=this.getRadio("mn3_sidec","mn3_sidecSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_sidec","mn3_sidecNo","Hide",!0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_nuclwrap","Nucleotides",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_nucl","mn3_nuclCartoon","Cartoon",!0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclPhos","O3' Trace",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclBackbone","Backbone",void 0,void 0,2),t+=this.getRadio("mn3_nucl","mn3_nuclSchematic","Schematic",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclLines","Lines",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclStick","Stick",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclBallstick","Ball and Stick",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_ntbasewrap","Nucl. Bases",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_ntbase","mn3_ntbaseLines","Lines",void 0,1,2),t+=this.getRadio("mn3_ntbase","mn3_ntbaseStick","Stick",void 0,1,2),t+=this.getRadio("mn3_ntbase","mn3_ntbaseBallstick","Ball and Stick",void 0,1,2),t+=this.getRadio("mn3_ntbase","mn3_ntbaseSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_ntbase","mn3_ntbaseNo","Hide",!0,1,2),t+="
      ",t+=""),t+=this.getMenuText("mn3_ligwrap","Chemicals",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_lig","mn3_ligLines","Lines",void 0,1,2),void 0===e.cfg.cid?(t+=this.getRadio("mn3_lig","mn3_ligStick","Stick",!0,1,2),t+=this.getRadio("mn3_lig","mn3_ligBallstick","Ball and Stick",void 0,1,2)):(t+=this.getRadio("mn3_lig","mn3_ligStick","Stick",void 0,1,2),t+=this.getRadio("mn3_lig","mn3_ligBallstick","BalHydrogensl and Stick",!0,1,2)),t+=this.getRadio("mn3_lig","mn3_ligSchematic","Schematic",void 0,1,2),t+=this.getRadio("mn3_lig","mn3_ligSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_lig","mn3_ligNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_hydrogenswrap","Hydrogens",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_hydrogens","mn3_hydrogensYes","Show",!0,1,2),t+=this.getRadio("mn3_hydrogens","mn3_hydrogensNo","Hide",void 0,1,2),t+="
      ",t+="",void 0===e.cfg.cid&&(t+=this.getMenuText("mn3_glycanwrap","Glycans",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn3_glycansCart","mn3_glycansCartYes","Show Cartoon",void 0,void 0,2),t+=this.getRadio("mn3_glycansCart","mn3_glycansCartNo","Hide Cartoon",!0,void 0,2),t+="
      ",t+=""),t+=this.getMenuText("mn3_ionswrap","Ions",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_ions","mn3_ionsSphere","Sphere",!0,1,2),t+=this.getRadio("mn3_ions","mn3_ionsDot","Dot",void 0,1,2),t+=this.getRadio("mn3_ions","mn3_ionsNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_waterwrap","Water",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_water","mn3_waterSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_water","mn3_waterDot","Dot",void 0,1,2),t+=this.getRadio("mn3_water","mn3_waterNo","Hide",!0,1,2),t+="
      ",t+="",t+=this.getLink("mn3_setThickness","Preferences",void 0,1),t+=this.getMenuSep(),t+=this.getLink("mn3_styleSave","Save Style",void 0,2),t+=this.getLink("mn3_styleApplySave","Apply Saved Style",void 0,2),t+=this.getMenuSep(),t+=this.getMenuText("mn5_surfacewrap","Surface Type",void 0,1,1),t+="
        ",t+=this.getRadio("mn5_surface","mn5_surfaceVDW","Van der Waals",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceVDWContext","VDW with Context",void 0,void 0,2),t+=this.getRadio("mn5_surface","mn5_surfaceMolecular","Molecular Surface",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceMolecularContext","MS with Context",void 0,void 0,2),t+=this.getRadio("mn5_surface","mn5_surfaceSAS","Solvent Accessible",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceSASContext","SA with Context",void 0,void 0,2),t+="
      ",t+="",t+=this.getLink("mn5_surfaceNo","Remove Surface",1,1),t+=this.getMenuText("mn5_surfaceop","Surface Opacity",void 0,1,1),t+="
        ",t+=this.getMenuText("mn5_surfaceopfast","Fast Transparency",void 0,1,2),t+="
          ",t+=this.getRadio("mn5_opacity","mn5_opacity10","1.0",!0,1,3);for(let e=9;e>0;--e)t+=this.getRadio("mn5_opacity","mn5_opacity0"+e,"0."+e,1,3);t+="
        ",t+="",t+=this.getMenuText("mn5_surfaceopslow","Slow Transparency",void 0,void 0,2),t+="
          ",t+=this.getRadio("mn5_opacityslow","mn5_opacityslow10","1.0",!0,void 0,3);for(let e=9;e>0;--e)t+=this.getRadio("mn5_opacityslow","mn5_opacityslow0"+e,"0."+e,void 0,void 0,3);return t+="
        ",t+="",t+="
      ",t+=this.getMenuText("mn5_wireframewrap","Surface Wireframe",void 0,1,1),t+="
        ",t+=this.getRadio("mn5_wireframe","mn5_wireframeYes","Yes",void 0,1,2),t+=this.getRadio("mn5_wireframe","mn5_wireframeNo","No",!0,1,2),t+="
      ",t+="",t+=this.getMenuSep(),t+=this.getLink("mn5_cartoonshape","Cartoon for a Set",void 0,1),t+=this.getLink("mn5_linebtwsets","Line btw. Two Sets",void 0,1),void 0===e.cfg.cid&&void 0===e.cfg.align&&void 0===e.cfg.chainalign&&void 0===e.cfg.mmdbaf&&(t+=this.getMenuSep(),t+=this.getLinkWrapper2("mn5_map","Electron Density","mapWrapper1",void 0,1),t+="
        ",t+=this.getLink("mn5_elecmap2fofc","2Fo-Fc Map",void 0,2),t+=this.getLink("mn5_elecmapfofc","Fo-Fc Map",void 0,2),t+=this.getLinkWrapper("mn5_elecmapNo","Remove Map","mapWrapper2",void 0,2),t+="
      ",t+="",t+=this.getLinkWrapper2("mn5_map3","Map Wireframe","mapWrapper3",void 0,1),t+="
        ",t+=this.getRadio("mn5_mapwireframe","mn5_mapwireframeYes","Yes",!0,void 0,2),t+=this.getRadio("mn5_mapwireframe","mn5_mapwireframeNo","No",void 0,void 0,2),t+="
      ",t+="",void 0===e.cfg.mmtfid&&(t+=this.getLinkWrapper("mn5_emmap","EM Density Map","emmapWrapper1",void 0,1),t+=this.getLinkWrapper("mn5_emmapNo","Remove EM Map","emmapWrapper2",void 0,1),t+=this.getLinkWrapper2("mn5_emmap3","EM Map Wireframe","emmapWrapper3",void 0,1),t+="
        ",t+=this.getRadio("mn5_emmapwireframe","mn5_emmapwireframeYes","Yes",!0,void 0,2),t+=this.getRadio("mn5_emmapwireframe","mn5_emmapwireframeNo","No",void 0,void 0,2),t+="
      ",t+="")),t+=this.getMenuSep(),t+=this.getMenuText("mn6_bkgdwrap","Background",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_bkgd","mn6_bkgdTransparent","Transparent",void 0,1,2),t+=this.getRadio("mn6_bkgd","mn6_bkgdBlack","Black",!0,1,2),t+=this.getRadio("mn6_bkgd","mn6_bkgdGrey","Gray",void 0,1,2),t+=this.getRadio("mn6_bkgd","mn6_bkgdWhite","White",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn6_themewrap","Dialog Color",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_theme","mn6_themeBlue","Blue",!0,void 0,2),t+=this.getRadio("mn6_theme","mn6_themeOrange","Orange",void 0,void 0,2),t+=this.getRadio("mn6_theme","mn6_themeBlack","Black",void 0,void 0,2),t+="
      ",t+="",t+="

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

    Color

    ",t+="
    ",t+=this.setMenu4_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu4_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getMenuText("mn4_clrwrap","Unicolor","icn3d-menupd",1,1),t+="
        ",t+=this.getMenuText("uniclrRedwrap","Red",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrRed1","Red","F00",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed2","Indian Red","CD5C5C",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed3","Light Coral","F08080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed4","Salmon","FA8072",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed5","Dark Salmon","E9967A",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed6","Light Salmon","FFA07A",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed7","Crimson","DC143C",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed8","Fire Brick","B22222",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed9","Dark Red","8B0000",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrPinkwrap","Pink",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrPink1","Pink","FFC0CB",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink2","Light Pink","FFB6C1",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink3","Hot Pink","FF69B4",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink4","Deep Pink","FF1493",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink5","Medium Violet Red","C71585",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink6","Pale Violet Red","DB7093",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrOrangewrap","Orange",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrOran1","Orange","FFA500",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran2","Dark Orange","FF8C00",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran3","Orange Red","FF4500",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran4","Tomato","FF6347",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran5","Coral","FF7F50",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran6","Light Salmon","FFA07A",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrYellowwrap","Yellow",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrYllw1","Yellow","FF0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw2","Gold","FFD700",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw3","Light Yellow","FFFFE0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw4","Lemon Chiffon","FFFACD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw5","Light Golden Rod","FAFAD2",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw6","Papaya Whip","FFEFD5",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw7","Moccasin","FFE4B5",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw8","Peach Puff","FFDAB9",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw9","Pale Golden Rod","EEE8AA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw10","Khaki","F0E68C",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw11","Dark Khaki","BDB76B",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrMagentawrap","Magenta",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrMgnt1","Magenta","F0F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt2","Orchid","DA70D6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt3","Violet","EE82EE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt4","Plum","DDA0DD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt5","Thistle","D8BFD8",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt6","Lavender","E6E6FA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt7","Medium Orchid","BA55D3",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt8","Medium Purple","9370DB",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt9","Rebecca Purple","663399",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt10","Blue Violet","8A2BE2",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt11","Dark Violet","9400D3",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt12","Dark Orchid","9932CC",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt13","Dark Magenta","8B008B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt14","Purple","800080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt15","Indigo","4B0082",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt16","Slat Blue","6A5ACD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt17","Dark Slate Blue","483D8B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt18","Medium Slat Blue","6A5ACD",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrGreenwrap","Green",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrGrn1","Green","0F0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn2","Dark Green","006400",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn3","Yellow Green","9ACD32",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn4","Olive Drab","6B8E23",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn5","Olive","808000",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn6","Dark Olive Green","556B2F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn7","Medium Aquamarine","66CDAA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn8","Dark Sea Green","8FBC8B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn9","Lignt Sea Green","20B2AA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn10","Dark Cyan","008B8B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn11","Teal","008080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn12","Forest Green","228B22",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn13","Sea Green","2E8B57",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn14","Medium Sea Green","3CB371",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn15","Spring Green","00FF7F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn16","Medium Spring","00FA9A",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn17","Light Green","90EE90",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn18","Pale Green","98FB98",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn19","Lime Green","32CD32",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn20","Lawn Green","7CFC00",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn21","Chartreuse","7FFF00",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn22","Green Yellow","ADFF2F",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrCyanwrap","Cyan",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrCyan1","Cyan","0FF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan2","Light Cyan","E0FFFF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan3","Pale Turquoise","AFEEEE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan4","Aquamarine","7FFFD4",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan5","Turquoise","40E0D0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan6","Medium Turquoise","48D1CC",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan7","Dark Turquoise","00CED1",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrBluewrap","Blue",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrBlue1","Blue","00F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue2","Medium Blue","0000CD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue3","Dark Blue","00008B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue4","Navy","000080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue5","Midnight Blue","191970",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue6","Royal Blue","4169E1",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue7","Medium Slate Blue","7B68EE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue8","Corn Flower Blue","6495ED",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue9","Dodger Blue","1E90FF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue10","Deep Sky Blue","00BFFF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue11","Light Sky Blue","87CEFA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue12","Sky Blue","87CEEB",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue13","Light Blue","ADD8E6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue14","Powder Blue","B0E0E6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue15","Light Steel Blue","B0C4DE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue16","Steel Blue","4682B4",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue17","Cadet Blue","5F9EA0",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrBrownwrap","Brown",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrBrown1","Brown","A52A2A",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown2","Maroon","800000",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown3","Sienna","A0522D",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown4","Saddle Brown","8B4513",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown5","Chocolate","D2691E",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown6","Peru","CD853F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown7","Dark Golden Rod","B8860B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown8","Golden Rod","DAA520",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown9","Sandy Brown","F4A460",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown10","Rosy Brown","BC8F8F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown11","Tan","D2B48C",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown12","Burlywood","DEB887",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown13","Wheat","F5DEB3",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown14","Navajo White","FFDEAD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown15","Bisque","FFE4C4",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown16","Blanched Almond","FFEBCD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown17","Corn Silk","FFF8DC",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrWhitewrap","White",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrWhite1","White","FFF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite2","Snow","FFFAFA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite3","Honey Dew","F0FFF0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite4","Mint Cream","F5FFFA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite5","Azure","F0FFFF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite6","Alice Blue","F0F8FF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite7","Ghost White","F8F8FF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite8","White Smoke","F5F5F5",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite9","Sea Shell","FFF5EE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite10","Beige","F5F5DC",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite11","Old Lace","FDF5E6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite12","Floral White","FFFAF0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite13","Ivory","FFFFF0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite14","Antique White","FAEBD7",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite15","Linen","FAF0E6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite16","Lavenderblush","FFF0F5",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite17","Misty Rose","FFE4E1",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrGraywrap","Gray",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrGray1","Gray","808080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray2","Dim Gray","696969",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray3","Light Slate Gray","778899",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray4","Slate Gray","708090",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray5","Dark Slate Gray","2F4F4F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray6","Black","000000",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray7","Dark Gray","A9A9A9",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray8","Silver","C0C0C0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray9","Light Gray","D3D3D3",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray10","Gainsboro","DCDCDC",void 0,1,3),t+="
        ",t+="
      ",t+=this.getRadio("mn4_clr","mn4_clrCustom","Color Picker",void 0,void 0,1),t+=this.getMenuSep(),void 0===e.cfg.cid?(t+=this.getMenuText("mn4_clrRainbowwrap","Rainbow (R-V)","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrRainbow","for Selection",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrRainbowChain","for Chains",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrRainbowSets","for Sets",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrRainbowAcrossSets","across Sets",void 0,void 0,2),t+="
      ",t+=this.getMenuText("mn4_clrSpectrumwrap","Spectrum (V-R)","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrSpectrum","for Selection",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSpectrumChain","for Chains",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSpectrumSets","for Sets",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrSpectrumAcrossSets","across Sets",void 0,void 0,2),t+="
      ",t+=this.getMenuText("mn4_clrSSwrap","Secondary","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrSSGreen","Sheet in Green",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSSYellow","Sheet in Yellow",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSSSpectrum","Spectrum",void 0,void 0,2),t+="
      ",t+=this.getRadio("mn4_clr","mn4_clrCharge","Charge",void 0,1,1),t+=this.getMenuText("mn4_hydrophobicwrap","Hydrophobicity","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrNormalizedHP","Normalized",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrHydrophobic","Wimley-White",void 0,void 0,2),t+="
      ",t+=this.getMenuText("mn4_clrBfactorwrap","B-factor","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrBfactor","Original",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrBfactorNorm","Percentile",void 0,1,2),t+="
      ",t+=this.getRadio("mn4_clr","mn4_clrArea",'Solvent
      Accessibility',void 0,void 0,1),t+=this.getRadio("mn4_clr","mn4_clrStructure","Structure",void 0,1,1),void 0!==e.cfg.align||void 0!==e.cfg.chainalign||void 0!==e.cfg.blast_rep_id?t+=this.getRadio("mn4_clr","mn4_clrChain","Chain",void 0,1,1):t+=this.getRadio("mn4_clr","mn4_clrChain","Chain",!0,1,1),t+=this.getRadio("mn4_clr","mn4_clrdomain","3D Domain",void 0,void 0,1),void 0===e.cfg.cid&&(t+=this.getMenuText("mn4_clrsetswrap","Defined Sets","icn3d-menupd",void 0,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrsets",'Rainbow for Selected Sets
        in "Analysis > Defined Sets"',void 0,void 0,2),t+="
      ",t+=""),t+=this.getMenuText("mn4_clrResiduewrap","Residue","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrResidue","Default",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrResidueCustom","Custom",void 0,void 0,2),t+="
      ",t+=this.getRadio("mn4_clr","mn4_clrAtom","Atom",void 0,1,1),void 0!==e.cfg.align||void 0!==e.cfg.chainalign?(t+=this.getRadio("mn4_clr","mn4_clrIdentity","Identity",!0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrConserved","Conservation",void 0,void 0,2)):void 0!==e.cfg.blast_rep_id?(t+=this.getRadio("mn4_clr","mn4_clrIdentity","Identity",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrConserved","Conservation",!0,void 0,2)):(t+=this.getRadio("mn4_clr","mn4_clrIdentity","Identity",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrConserved","Conservation",void 0,void 0,2)),t+=this.getRadio("mn4_clr","mn4_clrConfidence",'AlphaFold
      Confidence',void 0,1,1)):t+=this.getRadio("mn4_clr","mn4_clrAtom","Atom",!0,1,1),t+=this.getMenuSep(),t+=this.getLink("mn4_clrSave","Save Color",void 0,1),t+=this.getLink("mn4_clrApplySave","Apply Saved Color",void 0,1),t+="

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

     Analysis

    ",t+="
    ",t+=this.setMenu5_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu5_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";t+="
      ",void 0===e.cfg.cid&&(t+=this.getLink("mn6_selectannotations","Seq. & Annotations "+e.htmlCls.wifiStr,1,1),t+=this.getLink("mn2_alignment","Aligned Seq. "+e.htmlCls.wifiStr,void 0,1),void 0===e.cfg.mmdbid&&void 0===e.cfg.gi&&void 0===e.cfg.blast_rep_id&&void 0===e.cfg.align&&void 0===e.cfg.chainalign||(t+=this.getLink("mn2_2ddgm","2D Diagram "+e.htmlCls.wifiStr,1,1)),t+=this.getMenuText("2dctnwrap","2D Cartoon",void 0,void 0,1),t+="
        ",t+=this.getLink("2dctn_chain","Chain Level",void 0,2),t+=this.getLink("2dctn_domain","Domain Level",void 0,2),t+=this.getLink("2dctn_secondary","Helix/Sheet Level",void 0,2),t+="
      ",t+="",t+=this.getLink("definedsets2","Defined Sets",1,1),t+=this.getMenuSep(),t+=this.getLink("mn6_hbondsYes","Interactions",1,1),t+=this.getMenuText("mn1_window","Bring to Front",void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_window_table","Interaction Table",void 0,2),t+=this.getLink("mn1_window_linegraph","2D Interaction Network",void 0,2),t+=this.getLink("mn1_window_scatterplot","2D Interaction Map",void 0,2),t+=this.getLink("mn1_window_graph","2D Graph(Force-Directed)",void 0,2),t+="
      ",t+="",t+=this.getLink("mn6_contactmap","Contact Map",void 0,1),e.cfg.notebook||(t+=this.getLink("mn1_mutation","Mutation "+e.htmlCls.wifiStr,1,1))),e.cfg.notebook||e.cfg.hidelicense||(t+=this.getMenuText("mn1_delphiwrap","DelPhi Potential",void 0,1,1),t+="
        ",t+=this.getLink("mn1_delphi","DelPhi Potential "+e.htmlCls.licenseStr,1,2),t+=this.getMenuText("mn1_phiwrap","Load PQR/Phi",void 0,void 0,2),t+="
          ",t+=this.getLink("mn1_phi","Local PQR/Phi/Cube File",void 0,3),t+=this.getLink("mn1_phiurl","URL PQR/Phi/Cube File",void 0,3),t+="
        ",t+="",t+=this.getLink("delphipqr","Download PQR",void 0,2),t+="
      ",t+=""),t+=this.getMenuSep(),t+=this.getMenuText("mn6_distancewrap","Distance",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_distance","mn6_distanceYes","between Two Atoms",void 0,1,2),t+=this.getRadio("mn6_distance","mn6_distTwoSets","between Two Sets",void 0,void 0,2),t+=this.getRadio("mn6_distance","mn6_distManySets","Among Many Sets",void 0,void 0,2),t+=this.getRadio("mn6_distance","mn6_distanceNo","Hide",!0,1,2),t+="
      ",t+="",t+=this.getLink("mn6_area","Surface Area",1,1),t+=this.getMenuText("mn6_addlabelwrap","Label",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_addlabel","mn6_addlabelYes","by Picking Atoms",void 0,void 0,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelSelection","per Selection",void 0,void 0,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelAtoms","per Atom",void 0,void 0,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelElements","per Atom Element",void 0,1,2),void 0===e.cfg.cid&&(t+=this.getRadio("mn6_addlabel","mn6_addlabelResidues","per Residue",void 0,1,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelResnum","per Residue & Number",void 0,1,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelChains","per Chain",void 0,void 0,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelTermini","N- & C-Termini",void 0,1,2)),t+=this.getMenuSep(),t+=this.getRadio("mn6_addlabel","mn6_labelColor","Change Label Color",void 0,1,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelNo","Remove",!0,1,2),t+="
      ",t+="",t+=this.getMenuText("labelscalewrap","Label Scale",void 0,1,1),t+="
        ";for(let e=1;e<=4;++e){let s=2*e;t+=this.getRadio("mn6_labelscale","mn6_labelscale0"+s,"0."+s,void 0,1,2)}for(let e=1;e<=5;++e)t+=1==e?this.getRadio("mn6_labelscale","mn6_labelscale"+e+"0",e+".0",!0,1,2):this.getRadio("mn6_labelscale","mn6_labelscale"+e+"0",e+".0",void 0,1,2);if(t+="
      ",t+="",t+=this.getMenuSep(),void 0===e.cfg.cid){t+=this.getMenuText("mn6_chemicalbindingwrap","Chem. Binding",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_chemicalbinding","mn6_chemicalbindingshow","Show",void 0,void 0,2),t+=this.getRadio("mn6_chemicalbinding","mn6_chemicalbindinghide","Hide",!0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn6_ssbondswrap","Disulfide Bonds",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_ssbonds","mn6_ssbondsYes","Show",!0,1,2),t+=this.getRadio("mn6_ssbonds","mn6_ssbondsExport","Export Pairs",void 0,void 0,2),t+=this.getRadio("mn6_ssbonds","mn6_ssbondsNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn6_clbondswrap","Cross-Linkages",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_clbonds","mn6_clbondsYes","Show",!0,void 0,2),t+=this.getRadio("mn6_clbonds","mn6_clbondsExport","Export Pairs",void 0,void 0,2),t+=this.getRadio("mn6_clbonds","mn6_clbondsNo","Hide",void 0,void 0,2),t+="
      ",t+="";let s=void 0!==e.cfg.mmtfid||void 0!==e.cfg.pdbid||void 0!==e.cfg.opmid||void 0!==e.cfg.mmcifid||void 0!==e.cfg.mmdbid||void 0!==e.cfg.mmdbafid||void 0!==e.cfg.gi||void 0!==e.cfg.blast_rep_id;s&&(t+=this.getMenuText("assemblyWrapper","Assembly",void 0,1,1),t+="
        ",e.cfg.bu?(t+=this.getRadio("mn6_assembly","mn6_assemblyYes","Biological Assembly",!0,1,2),t+=this.getRadio("mn6_assembly","mn6_assemblyNo","Asymmetric Unit",void 0,1,2)):(t+=this.getRadio("mn6_assembly","mn6_assemblyYes","Biological Assembly",void 0,1,2),t+=this.getRadio("mn6_assembly","mn6_assemblyNo","Asymmetric Unit",!0,1,2)),t+="
      ",t+=""),t+=this.getMenuText("mn6_symmetrywrap","Symmetry",void 0,void 0,1),t+="
        ",s&&(t+=this.getLink("mn6_symmetry","from PDB(precalculated) "+e.htmlCls.wifiStr,void 0,2)),t+=this.getLink("mn6_symd","from SymD(Dynamic) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn6_clear_sym","Clear SymD Symmetry",void 0,2),t+=this.getLink("mn6_axes_only","Show Axes Only",void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn6_igrefwrap","Ref. Number",void 0,void 0,1),t+="
        ",t+=this.getLink("mn6_customref","Custom Ref. Number",void 0,2),t+="
      ",t+="",t+=this.getMenuSep()}return t+=this.getLink("mn6_yournote","Window Title",void 0,1),void 0!==e.cfg.cid?(t+=this.getMenuText("mn1_linkwrap","Links",void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_link_structure","Compound Summary "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_vast","Similar Compounds "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_bind","Structures Bound "+e.htmlCls.wifiStr,void 0,2),t+="
      ",t+=""):(t+=this.getMenuText("mn1_linkwrap","Links",void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_link_structure","Structure Summary "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_vast","Similar Structures "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_pubmed","Literature "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_protein","Protein "+e.htmlCls.wifiStr,void 0,2),t+="
      ",t+=""),t+="

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

    Help

    ",t+="
    ",t+=this.setMenu6_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu6_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getMenuUrl("abouticn3d",e.htmlCls.baseUrl+"icn3d/icn3d.html#about","About iCn3D "+e.REVISION+"",1,1),t+=this.getMenuUrl("gallery",e.htmlCls.baseUrl+"icn3d/icn3d.html#gallery","Live Gallery "+e.htmlCls.wifiStr,1,1),t+=this.getMenuUrl("video",e.htmlCls.baseUrl+"icn3d/icn3d.html#videos","iCn3D Videos",1,1),t+=this.getMenuText("mn6_faq","FAQ",void 0,1,1),t+="
        ",t+=this.getMenuUrl("faq_viewstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#viewstru","View structure",1,2),t+=this.getMenuUrl("faq_tfstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#tfstru","Transform Structure",1,2),t+=this.getMenuUrl("faq_selsubset",e.htmlCls.baseUrl+"icn3d/icn3d.html#selsubset","Select Subsets",1,2),t+=this.getMenuUrl("faq_stylecolor",e.htmlCls.baseUrl+"icn3d/icn3d.html#changestylecolor","Change Style/Color",1,2),t+=this.getMenuUrl("faq_savework",e.htmlCls.baseUrl+"icn3d/icn3d.html#saveview","Save Work",1,2),t+=this.getMenuUrl("faq_showanno",e.htmlCls.baseUrl+"icn3d/icn3d.html#showanno","Show Annotations",1,2),t+=this.getMenuUrl("faq_exportanno",e.htmlCls.baseUrl+"icn3d/icn3d.html#exportanno","Export Annotations",1,2),t+=this.getMenuUrl("faq_interanal",e.htmlCls.baseUrl+"icn3d/icn3d.html#interanalysis","Interaction Analysis",1,2),t+=this.getMenuUrl("faq_mutanal",e.htmlCls.baseUrl+"icn3d/icn3d.html#mutationanalysis","Mutation Analysis",1,2),t+=this.getMenuUrl("faq_elecpot",e.htmlCls.baseUrl+"icn3d/icn3d.html#elecpot","Electrostatic Pot.",1,2),t+=this.getMenuUrl("faq_simipdb",e.htmlCls.baseUrl+"icn3d/icn3d.html#simivast","Similar PDB",1,2),t+=this.getMenuUrl("faq_simialphapdb",e.htmlCls.baseUrl+"icn3d/icn3d.html#simifoldseek","Similar AlphaFold/PDB",1,2),t+=this.getMenuUrl("faq_alnstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#alignmul","Align Multiple Structures",1,2),t+=this.getMenuUrl("faq_batchanal",e.htmlCls.baseUrl+"icn3d/icn3d.html#batchanalysis","Batch Analysis",1,2),t+=this.getMenuUrl("faq_embedicn3d",e.htmlCls.baseUrl+"icn3d/icn3d.html#embedicn3d","Embed iCn3D",1,2),t+="
      ",t+="",t+=this.getMenuUrl("citing",e.htmlCls.baseUrl+"icn3d/icn3d.html#citing","Citing iCn3D",void 0,1),t+=this.getMenuText("mn6_source","Source Code",void 0,1,1),t+="
        ",t+=this.getMenuUrl("github","https://github.com/ncbi/icn3d","GitHub (browser) "+e.htmlCls.wifiStr,1,2),t+=this.getMenuUrl("npm","https://www.npmjs.com/package/icn3d","npm (Node.js) "+e.htmlCls.wifiStr,1,2),t+=this.getMenuUrl("notebook","https://pypi.org/project/icn3dpy","Jupyter Notebook "+e.htmlCls.wifiStr,1,2),t+="
      ",t+="",t+=this.getMenuText("mn6_develop","Develop",void 0,void 0,1),t+="
        ",t+=this.getMenuUrl("dev_embedicn3d2",e.htmlCls.baseUrl+"icn3d/icn3d.html#HowToUse","Embed iCn3D",void 0,2),t+=this.getMenuUrl("dev_urlpara",e.htmlCls.baseUrl+"icn3d/icn3d.html#parameters","URL Parameters",void 0,2),t+=this.getMenuUrl("dev_command",e.htmlCls.baseUrl+"icn3d/icn3d.html#commands","Commands",void 0,2),t+=this.getMenuUrl("dev_datastru",e.htmlCls.baseUrl+"icn3d/icn3d.html#datastructure","Data Structure",void 0,2),t+=this.getMenuUrl("dev_classstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#classstructure","Class Structure",void 0,2),t+=this.getMenuUrl("dev_addclass",e.htmlCls.baseUrl+"icn3d/icn3d.html#addclass","Add New Classes",void 0,2),t+=this.getMenuUrl("dev_modfunc",e.htmlCls.baseUrl+"icn3d/icn3d.html#modifyfunction","Modify Functions",void 0,2),t+=this.getMenuUrl("dev_restful",e.htmlCls.baseUrl+"icn3d/icn3d.html#restfulapi","RESTful APIs",void 0,2),t+=this.getMenuUrl("dev_contributor",e.htmlCls.baseUrl+"icn3d/icn3d.html#contributors","iCn3D Contributors",void 0,2),t+="
      ",t+="",t+=this.getMenuUrl("helpdoc",e.htmlCls.baseUrl+"icn3d/docs/icn3d_help.html","Help Doc "+e.htmlCls.wifiStr,1,1),t+=this.getMenuSep(),t+=this.getMenuText("mn6_tfhint","Transform Hints",void 0,1,1),t+="
        ",t+=this.getMenuText("mn6_rotate","Rotate",void 0,1,2),t+="
          ",t+="
        • Left Mouse (Click & Drag)
        • ",t+="
        • Key l: Left
        • ",t+="
        • Key j: Right
        • ",t+="
        • Key i: Up
        • ",t+="
        • Key m: Down
        • ",t+="
        • Shift + Key l: Left 90°
        • ",t+="
        • Shift + Key j: Right 90°
        • ",t+="
        • Shift + Key i: Up 90°
        • ",t+="
        • Shift + Key m: Down 90°
        • ",t+="
        ",t+="",t+=this.getMenuText("mn6_zoom","Zoom",void 0,1,2),t+="
          ",t+="
        • Middle Mouse
          (Pinch & Spread)
        • ",t+="
        • Key z: Zoom in
        • ",t+="
        • Key x: Zoom out
        • ",t+="
        ",t+="",t+=this.getMenuText("mn6_translate","Translate",void 0,1,2),t+="
          ",t+="
        • Right Mouse
          (Two Finger Click & Drag)
        • ",t+="
        ",t+="",t+="
      ",t+="",t+=this.getMenuUrl("selhints",e.htmlCls.baseUrl+"icn3d/icn3d.html#selsubset","Selection Hints",void 0,1),t+=this.getMenuUrl("helpdesk","https://support.nlm.nih.gov/support/create-case/","Write to Help Desk",1,1),t+="

    • ",t+="
    ",t}hideMenu(){let e=this.icn3dui;e.bNode||(void 0!==$("#"+e.pre+"mnlist")[0]&&($("#"+e.pre+"mnlist")[0].style.display="none"),void 0!==$("#"+e.pre+"mnLogSection")[0]&&($("#"+e.pre+"mnLogSection")[0].style.display="none"),void 0!==$("#"+e.pre+"cmdlog")[0]&&($("#"+e.pre+"cmdlog")[0].style.display="none"),$("#"+e.pre+"title")[0].style.margin="10px 0 0 10px")}showMenu(){let e=this.icn3dui;e.bNode||(void 0!==$("#"+e.pre+"mnlist")[0]&&($("#"+e.pre+"mnlist")[0].style.display="block"),void 0!==$("#"+e.pre+"mnLogSection")[0]&&($("#"+e.pre+"mnLogSection")[0].style.display="block"),void 0!==$("#"+e.pre+"cmdlog")[0]&&($("#"+e.pre+"cmdlog")[0].style.display="block"))}}class c{constructor(e){this.icn3dui=e}openDlg(e,t){let s=this.icn3dui;s.icn3d,s.bNode||(e=s.pre+e,s.cfg.notebook?this.openDlgNotebook(e,t):this.openDlgRegular(e,t),s.htmlCls.themecolor||(s.htmlCls.themecolor="blue"),s.htmlCls.setMenuCls.setTheme(s.htmlCls.themecolor))}addSaveButton(e){let t=this.icn3dui;t.icn3d,t.bNode||void 0!==this.dialogHashSave&&this.dialogHashSave.hasOwnProperty(e)||($("#"+e).parent().children(".ui-dialog-titlebar").append("
    "),void 0===this.dialogHashSave&&(this.dialogHashSave={}),this.dialogHashSave[e]=1)}addHideButton(e){let t=this.icn3dui;t.icn3d,t.bNode||void 0!==this.dialogHashHide&&this.dialogHashHide.hasOwnProperty(e)||($("#"+e).parent().children(".ui-dialog-titlebar").append("
    "),void 0===this.dialogHashHide&&(this.dialogHashHide={}),this.dialogHashHide[e]=1)}getDialogStatus(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t={},s={},i=$("#"+e.pre+"dl_selectannotations").hasClass("ui-dialog-content"),n=$("#"+e.pre+"dl_graph").hasClass("ui-dialog-content"),l=$("#"+e.pre+"dl_linegraph").hasClass("ui-dialog-content"),r=$("#"+e.pre+"dl_scatterplot").hasClass("ui-dialog-content"),o=$("#"+e.pre+"dl_contactmap").hasClass("ui-dialog-content"),a=$("#"+e.pre+"dl_alignerrormap").hasClass("ui-dialog-content"),d=$("#"+e.pre+"dl_interactionsorted").hasClass("ui-dialog-content"),c=$("#"+e.pre+"dl_alignment").hasClass("ui-dialog-content"),h=$("#"+e.pre+"dl_2ddgm").hasClass("ui-dialog-content"),p=$("#"+e.pre+"dl_2dctn").hasClass("ui-dialog-content"),m=$("#"+e.pre+"dl_definedsets").hasClass("ui-dialog-content");return t.bSelectannotationsInit2=!1,t.bGraph2=!1,t.bLineGraph2=!1,t.bScatterplot2=!1,t.bTable2=!1,t.bAlignmentInit2=!1,t.bTwoddgmInit2=!1,t.bTwodctnInit2=!1,t.bSetsInit2=!1,s.dl_selectannotations="bSelectannotationsInit2",s.dl_graph="bGraph2",s.dl_linegraph="bLineGraph2",s.dl_scatterplot="bScatterplot2",s.dl_contactmap="bContactmap2",s.dl_alignerrormap="bAlignerrormap2",s.dl_interactionsorted="bTable2",s.dl_alignment="bAlignmentInit2",s.dl_2ddgm="bTwoddgmInit2",s.dl_2dctn="bTwodctnInit2",s.dl_definedsets="bSetsInit2",i&&(t.bSelectannotationsInit2=$("#"+e.pre+"dl_selectannotations").dialog("isOpen")),n&&(t.bGraph2=$("#"+e.pre+"dl_graph").dialog("isOpen")),l&&(t.bLineGraph2=$("#"+e.pre+"dl_linegraph").dialog("isOpen")),r&&(t.bScatterplot2=$("#"+e.pre+"dl_scatterplot").dialog("isOpen")),o&&(t.bContactmap2=$("#"+e.pre+"dl_contactmap").dialog("isOpen")),a&&(t.bAlignerror2=$("#"+e.pre+"dl_alignerrormap").dialog("isOpen")),d&&(t.bTable2=$("#"+e.pre+"dl_interactionsorted").dialog("isOpen")),c&&(t.bAlignmentInit2=$("#"+e.pre+"dl_alignment").dialog("isOpen")),h&&(t.bTwoddgmInit2=$("#"+e.pre+"dl_2ddgm").dialog("isOpen")),p&&(t.bTwodctnInit2=$("#"+e.pre+"dl_2dctn").dialog("isOpen")),m&&(t.bSetsInit2=$("#"+e.pre+"dl_definedsets").dialog("isOpen")),{status:t,id2flag:s}}openDlgHalfWindow(e,t,s,i){let n=this.icn3dui,l=n.icn3d;if(n.bNode)return;let r=this,o=n.htmlCls.width2d+20;l.resizeCanvasCls.resizeCanvas(n.htmlCls.WIDTH-s,n.htmlCls.HEIGHT,i);let a,d=n.htmlCls.HEIGHT,c=s;a=!n.cfg.showmenu||n.utilsCls.isMobile()||n.cfg.mobilemenu?{my:"left top",at:"right top",of:"#"+n.pre+"viewer",collision:"none"}:{my:"left top",at:"right top+40",of:"#"+n.pre+"viewer",collision:"none"},n.cfg.resize=!1,window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:d,width:c,modal:!1,position:a,close:function(t){let s=r.getDialogStatus(),i=s.status,a=s.id2flag,d=!1;for(let t in a){let s=e===n.pre+t;for(let e in i)i.hasOwnProperty(e)||(s=s&&!i[e]);d=d||s}if(d)if(i.bTwoddgmInit2||i.bTwodctnInit2||i.bSetsInit2){let e=n.utilsCls.isMobile()?n.htmlCls.WIDTH:n.htmlCls.WIDTH-o;l.resizeCanvasCls.resizeCanvas(e,n.htmlCls.HEIGHT,!0),i.bTwoddgmInit2&&r.openDlg2Ddgm(n.pre+"dl_2ddgm",void 0,i.bSetsInit2),i.bTwodctnInit2&&r.openDlg2Ddgm(n.pre+"dl_2dctn",void 0,i.bSetsInit2),i.bSetsInit2&&r.openDlg2Ddgm(n.pre+"dl_definedsets")}else l.resizeCanvasCls.resizeCanvas(n.htmlCls.WIDTH,n.htmlCls.HEIGHT,!0)},resize:function(t){if(e==n.pre+"dl_selectannotations")l.annotationCls.hideFixedTitle();else if(e==n.pre+"dl_graph"){let t=$("#"+e).width(),s=$("#"+e).height();d3.select("#"+n.svgid).attr("width",t).attr("height",s)}else if(e==n.pre+"dl_linegraph"||e==n.pre+"dl_scatterplot"||e==n.pre+"dl_contactmap"||e==n.pre+"dl_alignerrormap"){let t=status.bTwoddgmInit2||status.bSetsInit2?(n.htmlCls.WIDTH-o)/2:n.htmlCls.WIDTH/2,s=$("#"+e).width()/t;if(e==n.pre+"dl_linegraph"){let e=l.linegraphWidth*s;$("#"+n.linegraphid).attr("width",e)}else if(e==n.pre+"dl_scatterplot"){let e=l.scatterplotWidth*s;$("#"+n.scatterplotid).attr("width",e)}else if(e==n.pre+"dl_contactmap"){let e=l.contactmapWidth*s;$("#"+n.contactmapid).attr("width",e)}else if(e==n.pre+"dl_alignerrormap"){let e=l.alignerrormapWidth*s;$("#"+n.alignerrormapid).attr("width",e)}}}}),this.addSaveButton(e),this.addHideButton(e)}openDlg2Ddgm(e,t,s){let i=this.icn3dui,n=i.icn3d;if(i.bNode)return;let l,r,o=this,a=i.htmlCls.width2d+20;e===i.pre+"dl_definedsets"?(l="right top",r="Select sets"):e!==i.pre+"dl_2ddgm"&&e!==i.pre+"dl_2dctn"||(l=s?"right top+240":"right top",r=e===i.pre+"dl_2ddgm"?"2D Diagram":"2D Cartoon");let d={my:"left top+"+i.htmlCls.MENU_HEIGHT,at:l,of:"#"+i.pre+"viewer",collision:"none"};window.dialog=$("#"+e).dialog({autoOpen:!0,title:r,height:"auto",width:a,modal:!1,position:d,close:function(e){let t=o.getDialogStatus().status;t.bSelectannotationsInit2||t.bGraph2||t.bLineGraph2||t.bScatterplot2||t.bTable2||t.bAlignmentInit2||n.resizeCanvasCls.resizeCanvas(i.htmlCls.WIDTH,i.htmlCls.HEIGHT,!0)},resize:function(t,s){e==i.pre+"dl_2dctn"&&(n.resizeRatioX=s.size.width/i.htmlCls.width2d,n.resizeRatioY=s.size.height/(i.htmlCls.width2d+70))},resizeStop:function(e,t){n.resizeRatioX=t.size.width/i.htmlCls.width2d,n.resizeRatioY=t.size.height/(i.htmlCls.width2d+70)}}),this.addSaveButton(e),this.addHideButton(e)}openDlgRegular(e,t){let s=this.icn3dui,i=s.icn3d;if(s.bNode)return;let n=400,l=150,r=s.htmlCls.width2d+20,o=this.getDialogStatus().status;if(e===s.pre+"dl_selectannotations"||e===s.pre+"dl_graph"||e===s.pre+"dl_linegraph"||e===s.pre+"dl_scatterplot"||e===s.pre+"dl_contactmap"||e===s.pre+"dl_alignerrormap"||e===s.pre+"dl_interactionsorted"||e===s.pre+"dl_alignment"){let a=.5*s.htmlCls.WIDTH-.5*r;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)this.openDlgHalfWindow(e,t,a,!0),(o.bTwoddgmInit2||o.bTwodctnInit2||o.bSetsInit2)&&(i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-a-r,s.htmlCls.HEIGHT,!0),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,o.bSetsInit2),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,o.bSetsInit2),o.bSetsInit2&&this.openDlg2Ddgm(s.pre+"dl_definedsets"));else{i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH,.5*s.htmlCls.HEIGHT,!0),l=.5*s.htmlCls.HEIGHT,n=s.htmlCls.WIDTH;let a={my:"left top",at:"left bottom+32",of:"#"+s.pre+"canvas",collision:"none"};window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:l,width:n,modal:!1,position:a,close:function(t){if(!((e!==s.pre+"dl_selectannotations"||o.bAlignmentInit2||o.bGraph2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_graph"||o.bSelectannotationsInit2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_alignment"||o.bSelectannotationsInit2||o.bGraph2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_interactionsorted"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_linegraph"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_scatterplot"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_contactmap"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bAlignerrormap2)&&(e!==s.pre+"dl_alignerrormap"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2)))if(o.bTwoddgmInit2||o.bTwodctnInit2||o.bSetsInit2){let e=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(e,s.htmlCls.HEIGHT,!0),o.bTwoddgmInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,o.bSetsInit2),o.bTwodctnInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,o.bSetsInit2),o.bSetsInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_definedsets")}else i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH,s.htmlCls.HEIGHT,!0)},resize:function(t){if(e==s.pre+"dl_selectannotations")i.annotationCls.hideFixedTitle();else if(e==s.pre+"dl_graph"){let t=$("#"+e).width(),i=$("#"+e).height();d3.select("#"+s.svgid).attr("width",t).attr("height",i)}else if(e==s.pre+"dl_linegraph"||e==s.pre+"dl_scatterplot"||e==s.pre+"dl_contactmap"||e==s.pre+"dl_alignerrormap"){let t=o.bTwoddgmInit2||o.bSetsInit2?(s.htmlCls.WIDTH-r)/2:s.htmlCls.WIDTH/2,n=$("#"+e).width()/t;if(e==s.pre+"dl_linegraph"){let e=i.linegraphWidth*n;$("#"+s.linegraphid).attr("width",e)}else if(e==s.pre+"dl_scatterplot"){let e=i.scatterplotWidth*n;$("#"+s.scatterplotid).attr("width",e)}else if(e==s.pre+"dl_contactmap"){let e=i.contactmapWidth*n;$("#"+s.contactmapid).attr("width",e)}else if(e==s.pre+"dl_alignerrormap"){let e=i.alignerrormapWidth*n;$("#"+s.alignerrormapid).attr("width",e)}}}}),this.addSaveButton(e),this.addHideButton(e)}}else if(e===s.pre+"dl_2ddgm"||e===s.pre+"dl_2dctn"){let t=0;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)(o.bSelectannotationsInit2||o.bGraph2||o.bLineGraph2||o.bScatterplot2||o.bTable2||o.bAlignmentInit2)&&(t=.5*s.htmlCls.WIDTH-.5*r),i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-t-r,s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,void 0,o.bSetsInit2);else{let t=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(t,.5*s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT,o.bSetsInit2)}}else{let a;if(l="auto",n="auto",e===s.pre+"dl_addtrack"?n="50%":e===s.pre+"dl_menupref"&&(n=600,l=500),e===s.pre+"dl_definedsets"){let t=0;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)(o.bSelectannotationsInit2||o.bGraph2||o.bLineGraph2||o.bScatterplot2||o.bTable2||o.bAlignmentInit2)&&(t=.5*s.htmlCls.WIDTH-.5*r),i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-t-r,s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,!0),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,!0);else{let t=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(t,.5*s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",.5*s.htmlCls.HEIGHT,!0),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",.5*s.htmlCls.HEIGHT,!0)}}else s.utilsCls.isMobile()?a={my:"left top",at:"left bottom-50",of:"#"+s.pre+"canvas",collision:"none"}:e===s.pre+"dl_allinteraction"||e===s.pre+"dl_buriedarea"?(a={my:"right top",at:"right top+50",of:"#"+i.divid,collision:"none"},n=700,l=500):a=e===s.pre+"dl_rmsd"||e===s.pre+"dl_legend"?{my:"left bottom",at:"left+20 bottom-20",of:"#"+s.pre+"canvas",collision:"none"}:e===s.pre+"dl_symd"?{my:"left top",at:"right-200 bottom-200",of:"#"+s.pre+"canvas",collision:"none"}:s.cfg.align?{my:"left top",at:"left top+90",of:"#"+s.pre+"canvas",collision:"none"}:{my:"left top",at:"left top+50",of:"#"+s.pre+"canvas",collision:"none"},window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:l,width:n,modal:!1,position:a}),this.addSaveButton(e),this.addHideButton(e)}$(".ui-dialog .ui-button span").removeClass("ui-icon-closethick").addClass("ui-icon-close")}openDlgNotebook(e,t){let s=this.icn3dui,i=s.icn3d;if(s.bNode)return;let n=400,l=150,r=s.htmlCls.width2d+20;e===s.pre+"dl_selectannotations"||e===s.pre+"dl_graph"||e===s.pre+"dl_linegraph"||e===s.pre+"dl_scatterplot"||e===s.pre+"dl_contactmap"||e===s.pre+"dl_alignerrormap"||e===s.pre+"dl_interactionsorted"||e===s.pre+"dl_alignment"?($("#"+e).show(),l=.5*s.htmlCls.HEIGHT,n=s.htmlCls.WIDTH,$("#"+e).width(n),$("#"+e).height(l),$("#"+e).resize((function(t){let n=s.htmlCls.WIDTH/2,l=$("#"+e).width()/n;if(e==s.pre+"dl_selectannotations")i.annotationCls.hideFixedTitle();else if(e==s.pre+"dl_graph"){let t=$("#"+e).width(),i=$("#"+e).height();d3.select("#"+s.svgid).attr("width",t).attr("height",i)}else if(e==s.pre+"dl_linegraph"){let e=i.linegraphWidth*l;$("#"+s.linegraphid).attr("width",e)}else if(e==s.pre+"dl_scatterplot"){let e=i.scatterplotWidth*l;$("#"+s.scatterplotid).attr("width",e)}else if(e==s.pre+"dl_contactmap"){let e=i.contactmapWidth*l;$("#"+s.contactmapid).attr("width",e)}else if(e==s.pre+"dl_alignerrormap"){let e=i.alignerrormapWidth*l;$("#"+s.alignerrormapid).attr("width",e)}}))):(i.bRender&&$("#"+e).show(),l="auto",n="auto",e===s.pre+"dl_addtrack"?n="50%":e===s.pre+"dl_2ddgm"||e===s.pre+"dl_2dctn"||e===s.pre+"dl_definedsets"?n=r:e!==s.pre+"dl_allinteraction"&&e!==s.pre+"dl_buriedarea"||(n=700,l=500),$("#"+e).width(n),$("#"+e).height(l))}}class h{constructor(e){this.icn3dui=e}setCustomDialogs(){let e=this.icn3dui;if(e.icn3d,e.bNode)return"";return""}getHtmlAlignResidueByResidue(e,t,s){let i=this.icn3dui;i.icn3d;let n="";return n+="All chains will be aligned to the first chain in the comma-separated chain IDs. Each chain ID has the form of PDBID_chain (e.g., 1HHO_A, case sensitive) or UniprotID (e.g., P69905 for AlphaFold structures).

    ",n+="Chain IDs: "+i.htmlCls.inputTextStr+"id='"+i.pre+e+"' value='P69905,P01942,1HHO_A' size=50>

    ",n+='Each alignment is defined as " | "-separated residue lists in one line. "10-50" means a range of residues from 10 to 50.

    ",n+=i.htmlCls.buttonStr+s+"'>Align Residue by Residue
    ",n}setDialogs(){let e=this.icn3dui,t=e.icn3d;if(e.bNode)return"";let s="";e.htmlCls.optionStr="":s.htmlCls.optionStr+"'"+l+"'>"+l+""}return i}setColorHints(){let e=this.icn3dui;e.icn3d;let t="";return t+=e.htmlCls.divNowrapStr+'Green: H-Bonds; ',t+='Cyan: Salt Bridge/Ionic; ',t+='Grey: contacts',t+=e.htmlCls.divNowrapStr+'Magenta: Halogen Bonds; ',t+='Red: π-Cation; ',t+='Blue: π-Stacking',t}setThicknessHtml(e){let t=this.icn3dui,s=t.icn3d,i="",n="3dprint"==e?"1":"0.1",l="3dprint"==e?"1.2":"0.3",r="3dprint"==e?"0.8":"0.4",o="3dprint"==e?"0.8":"0.4",a="3dprint"==e?"1":"0.4",d="3dprint"==e?"0.6":"0.3",c="3dprint"==e?"1":"0.2",h="3dprint"==e?"2":"1.3",p="3dprint"==e?"1.4":"0.8",m=40,u=.6,g=.4,f=.2,b=0,C=1,y=0;if("style"==e){if(""!=this.getCookie("shininess")&&(m=parseFloat(this.getCookie("shininess"))),""!=this.getCookie("light1")&&(u=parseFloat(this.getCookie("light1")),g=parseFloat(this.getCookie("light2")),f=parseFloat(this.getCookie("light3"))),""!=this.getCookie("lineRadius")){n=parseFloat(this.getCookie("lineRadius")),l=parseFloat(this.getCookie("coilWidth")),r=parseFloat(this.getCookie("cylinderRadius"));let e=this.getCookie("crosslinkRadius");o=isNaN(e)?s.crosslinkRadius:parseFloat(e),a=parseFloat(this.getCookie("traceRadius")),d=parseFloat(this.getCookie("dotSphereScale")),c=parseFloat(this.getCookie("ribbonthickness")),h=parseFloat(this.getCookie("helixSheetWidth")),p=parseFloat(this.getCookie("nucleicAcidWidth"))}""!=this.getCookie("glycan")&&(b=parseFloat(this.getCookie("glycan"))),""!=this.getCookie("membrane")&&(C=parseFloat(this.getCookie("membrane"))),""!=this.getCookie("cmdwindow")&&(y=parseFloat(this.getCookie("cmdwindow"))),i+="Note: The following parameters will be saved in cache. You just need to set them once.

    ",i+="1. Shininess: "+t.htmlCls.inputTextStr+"id='"+t.pre+"shininess' value='"+m+"' size=4>"+t.htmlCls.space3+"(for the shininess of the 3D objects, default 40)

    ",i+="2. Three directional lights:
    ",i+="Key Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light1' value='"+u+"' size=4>"+t.htmlCls.space3+"(for the light strength of the key light, default 0.6)
    ",i+="Fill Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light2' value='"+g+"' size=4>"+t.htmlCls.space3+"(for the light strength of the fill light, default 0.4)
    ",i+="Back Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light3' value='"+f+"' size=4>"+t.htmlCls.space3+"(for the light strength of the back light, default 0.2)

    ",i+="3. Thickness:
    "}return i+="Line Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"linerad_"+e+"' value='"+n+"' size=4>"+t.htmlCls.space3+"(for stabilizers, hydrogen bonds, distance lines, default 0.1)
    ",i+="Coil Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"coilrad_"+e+"' value='"+l+"' size=4>"+t.htmlCls.space3+"(for coils, default 0.3)
    ",i+="Stick Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"stickrad_"+e+"' value='"+r+"' size=4>"+t.htmlCls.space3+"(for sticks, default 0.4)
    ",i+="Cross-Linkage Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"crosslinkrad_"+e+"' value='"+o+"' size=4>"+t.htmlCls.space3+"(for cross-linkages, default 0.4)
    ",i+="Trace Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"tracerad_"+e+"' value='"+a+"' size=4>"+t.htmlCls.space3+"(for C alpha trace, O3' trace, default 0.4)
    ",i+="Ribbon Thickness: "+t.htmlCls.inputTextStr+"id='"+t.pre+"ribbonthick_"+e+"' value='"+c+"' size=4>"+t.htmlCls.space3+"(for helix and sheet ribbons, nucleotide ribbons, default 0.2)
    ",i+="Protein Ribbon Width: "+t.htmlCls.inputTextStr+"id='"+t.pre+"prtribbonwidth_"+e+"' value='"+h+"' size=4>"+t.htmlCls.space3+"(for helix and sheet ribbons, default 1.3)
    ",i+="Nucleotide Ribbon Width: "+t.htmlCls.inputTextStr+"id='"+t.pre+"nucleotideribbonwidth_"+e+"' value='"+p+"' size=4>"+t.htmlCls.space3+"(for nucleotide ribbons, default 0.8)
    ",i+="Ball Scale: "+t.htmlCls.inputTextStr+"id='"+t.pre+"ballscale_"+e+"' value='"+d+"' size=4>"+t.htmlCls.space3+"(for styles 'Ball and Stick' and 'Dot', default 0.3)
    ","style"==e&&(i+="
    4. Show Glycan Cartoon: "+t.htmlCls.inputTextStr+"id='"+t.pre+"glycan' value='"+b+"' size=4>"+t.htmlCls.space3+"(0: hide, 1: show, default 0)
    ",i+="
    5. Show Membrane: "+t.htmlCls.inputTextStr+"id='"+t.pre+"membrane' value='"+C+"' size=4>"+t.htmlCls.space3+"(0: hide, 1: show, default 1)
    ",i+="
    6. Enlarge Command Window: "+t.htmlCls.inputTextStr+"id='"+t.pre+"cmdwindow' value='"+y+"' size=4>"+t.htmlCls.space3+"(0: Regular, 1: Large, default 0)

    "),i+=t.htmlCls.spanNowrapStr+""+t.htmlCls.buttonStr+"apply_thickness_"+e+"'>Apply   ",i+=t.htmlCls.spanNowrapStr+""+t.htmlCls.buttonStr+"reset_thickness_"+e+"'>Reset",i}getCookie(e){let t=e+"=",s=decodeURIComponent(document.cookie).split(";");for(let e=0;e":(n+='
    ',n+="
    Selection: Name: "+s.htmlCls.inputTextStr+"id='"+s.pre+"seq_command_name"+e+"' value='seq_"+l+"' size='5'> "+s.htmlCls.space2+"

    ",n+=s.htmlCls.divStr+"seqguide"+e+"' style='display:none; white-space:normal;' class='icn3d-box'>"),n+=this.getSelectionHints();return n+="Residue labeling: standard residue with coordinates: UPPER case letter; nonstandard residue with coordinates: the first UPPER case letter plus a period except that water residue uses the letter 'O'; residue missing coordinates: lower case letter."+(s.utilsCls.isMac()&&!s.utilsCls.isMobile()?"

    Turn on scroll bar: System preferences -> General -> show scroll bars -> check Always":"")+"
    ",n}setAlignSequenceGuide(e,t){let s=this.icn3dui,i=s.icn3d,n="";let l=i&&i.defNames2Atoms?Object.keys(i.defNames2Atoms).length:1;n+='
    ',n+="
    Selection: Name: "+s.htmlCls.inputTextStr+"id='"+s.pre+"alignseq_command_name' value='alseq_"+l+"' size='10'> "+s.htmlCls.space2+"

    ",n+=s.htmlCls.divStr+"alignseqguide' style='display:none; white-space:normal;' class='icn3d-box'>",n+=this.getSelectionHints();return n+="Residue labeling: aligned residue with coordinates: UPPER case letter; non-aligned residue with coordinates: lower case letter which can be highlighted; residue missing coordinates: lower case letter which can NOT be highlighted."+(s.utilsCls.isMac()&&!s.utilsCls.isMobile()?"

    Turn on scroll bar: System preferences -> General -> show scroll bars -> check Always":"")+"
    ",n}getSelectionHints(){let e=this.icn3dui;e.icn3d;let t="";if(e.utilsCls.isMobile())t+='Select Aligned Sequences: touch to select, touch again to deselect, multiple selection is allowed without Ctrl key, click "Save Selection" to save the current selection.
    ';else{t+='Select on 1D sequences: drag to select, drag again to deselect, multiple selection is allowed without Ctrl key, click "Save Selection" to save the current selection.

    ',t+="Select on 2D interaction diagram: click on the nodes or lines. The nodes are chains and can be united with the Ctrl key. The lines are interactions and can NOT be united. Each click on the lines selects half of the lines, i.e., select the interacting residues in one of the two chains.

    ",t+="Select on 3D structures: "+(e.utilsCls.isMobile()?"use finger to pick":'hold "Alt" and use mouse to pick')+', click the second time to deselect, hold "Ctrl" to union selection, hold "Shift" to select a range, press the up/down arrow to switch among atom/residue/strand/chain/structure, click "Save Selection" to save the current selection.

    ',t+='Save the current selection(either on 3D structure, 2D interactions, or 1D sequence): open the menu "Select -> Save Selection", specify the name and description for the selection, and click "Save".

    '}return t}addGsizeSalt(e){let t=this.icn3dui;t.icn3d;let s="";s+="Grid Size: ",s+="Salt Concentration: M
    ",s}getFootHtml(e,t){let s=this.icn3dui;s.icn3d;let i="
    ";return"delphi"==e?s.cfg.cid?i+="Note: Partial charges(MMFF94) are from PubChem Compound SDF files.

    ":(i+="Note: Only the selected residues are used for DelPhi potential calculation by solving linear Poisson-Boltzmann equation.",i+='

    ',i+=s.htmlCls.divStr+t+"' style='display:none;'>",i+="
    The hydrogens and partial charges of proteins and nucleotides are added using DelPhiPKa with the Amber charge and size files. The hydrogens of ligands are added using Open Babel. The partial charges of ligands are calculated using Antechamber with the Gasteiger charge method. All partial charges are calculated at pH 7.

    ",i+='Lipids are treated as ligands. Please use "HETATM" instead of "ATOM " for each lipid atom in your PDB file. Each phosphate in lipids is assigned with a charge of -1. You can download PQR and modify it, or prepare your PQR file using other tools. Then load the PQR file at the menu "Analysis > Load PQR/Potential".

    ',i+="
    "):(i+="Note: Always load a PDB file before loading a PQR or DelPhi potential file.",i+='

    ',i+=s.htmlCls.divStr+t+"' style='display:none;'>",i+='The PDB file can be loaded in the URL with "pdbid=" or at "File > Open File". The PQR file can be prepared at the menu "Analysis > Download PQR" with your modification or using other tools. The DelPhi potential file can be calculated at DelPhi Web Server and be exported as a Cube file. ',"url"==e&&(i+="The PQR or potential file can be accessed in a URL if it is located in the same host as iCn3D."),i+="

    ",i+=""),i+="",i}getPotentialHtml(e,t){let s=this.icn3dui;s.icn3d;let i,n,l,r,o,a="";r="Equipotential Map",o="Surface with Potential","delphi"==e?n="delphi":"local"==e?(i="pqr",n="phi",l="cube"):"url"==e&&(i="pqrurl",n="phiurl",l="cubeurl"),a+=s.htmlCls.divStr+"dl_"+n+"' class='"+t+"'>",a+=s.htmlCls.divStr+"dl_"+n+"_tabs' style='border:0px;'>",a+="",a+=s.htmlCls.divStr+n+"tab1'>","delphi"==e&&(a+=this.addGsizeSalt(n)+"
    "),a+="Potential contour at: kT/e(25.6mV at 298K)

    ","delphi"==e?(a+=s.htmlCls.buttonStr+"reload_"+n+"file' style='margin-top: 6px;'>Equipotential Map",a+=s.htmlCls.buttonStr+n+"mapNo' style='margin-left:30px;'>Remove Map
    "):"local"==e?(a+=s.htmlCls.divStr+n+"tab1_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo'>Remove Map",a+=s.htmlCls.divStr+n+"tab1_"+i+"'>",a+=this.addGsizeSalt(i)+"
    ",a+="PQR File: "+s.htmlCls.inputFileStr+"id='"+s.pre+i+"file'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+n+"'>",a+="Phi File: "+s.htmlCls.inputFileStr+"id='"+s.pre+n+"file'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+l+"'>",a+="Cube File: "+s.htmlCls.inputFileStr+"id='"+s.pre+l+"file'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=""):"url"==e&&(a+=s.htmlCls.divStr+n+"tab1_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo'>Remove Map",a+=s.htmlCls.divStr+n+"tab1_"+i+"2'>",a+=this.addGsizeSalt(i)+"
    ",a+="PQR URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+i+"file'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+n+"2'>",a+="Phi URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+n+"file'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+l+"2'>",a+="Cube URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+l+"file'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=""),a+="
    "+this.getFootHtml(e,n+"tab1_foot"),a+="",a+=s.htmlCls.divStr+n+"tab2'>","delphi"==e&&(a+=this.addGsizeSalt(n)+"
    "),a+="Surface with max potential at: kT/e(25.6mV at 298K)

    ",a+="Surface: ",a+="Opacity: ",a+="Wireframe:
    ",a+="
    ","delphi"==e?(a+=s.htmlCls.buttonStr+"reload_"+n+"file2' style='margin-top: 6px;'>Surface with Potential",a+=s.htmlCls.buttonStr+n+"mapNo2' style='margin-left:30px;'>Remove Surface
    "):"local"==e?(a+=s.htmlCls.divStr+n+"tab2_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo2'>Remove Surface",a+=s.htmlCls.divStr+n+"tab2_"+i+"'>",a+=this.addGsizeSalt(i+"2")+"
    ",a+="PQR File: "+s.htmlCls.inputFileStr+"id='"+s.pre+i+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+n+"'>",a+="Phi File: "+s.htmlCls.inputFileStr+"id='"+s.pre+n+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+l+"'>",a+="Cube File: "+s.htmlCls.inputFileStr+"id='"+s.pre+l+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=""):"url"==e&&(a+=s.htmlCls.divStr+n+"tab2_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo2'>Remove Surface",a+=s.htmlCls.divStr+n+"tab2_"+i+"2'>",a+=this.addGsizeSalt(i+"2")+"
    ",a+="PQR URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+i+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+n+"2'>",a+="Phi URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+n+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+l+"2'>",a+="Cube URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+l+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=""),a+="
    "+this.getFootHtml(e,n+"tab2_foot"),a+="",a+="",a+="",a}async exportPqr(e){let t=this.icn3dui,s=t.icn3d,i={},n={},l=t.hashUtilsCls.intHash(s.dAtoms,s.hAtoms);for(let e in l)s.atoms[e],s.ions.hasOwnProperty(e)?i[e]=1:n[e]=1;let r=e?"pdb":"pqr";if(t.cfg.cid){let t="",l=!e;t+=s.saveFileCls.getAtomPDB(n,l)+s.saveFileCls.getAtomPDB(i,l);let o=s.inputid?s.inputid:"custom";s.saveFileCls.saveFile(o+"_icn3d."+r,"text",[t])}else{if(t.utilsCls.isCalphaPhosOnly(t.hashUtilsCls.hash2Atoms(n,s.atoms)))return void alert("The potential will not be shown because the side chains are missing in the structure...");let l="";l+=s.saveFileCls.getAtomPDB(n),l+=s.saveFileCls.getAtomPDB(i,!0,void 0,!0);let o="https://www.ncbi.nlm.nih.gov/Structure/delphi/delphi.fcgi",a={pdb2pqr:l,pdbid:t.cfg.cid?t.cfg.cid:Object.keys(s.structures).toString()},d=await t.getAjaxPostPromise(o,a,!0,void 0,void 0,!0,"text");if(e){let e=d.split("\n"),s="";for(let i=0,n=e.length;i PNG Image" in the Data menu...');else if(-1!=l){let t=e.substr(l+n.length);s.htmlCls.clickMenuCls.setLogCmd("load iCn3D PNG image "+$("#"+s.pre+"pngimage").val(),!1),window.open(t,"_self")}else if(-1!=o){let n="Start of data file======\n",l=e.indexOf(n);i.bInputfile=-1!=l;let a,d=t?t.replace(/;/g,"\n"):"";if(i.bInputfile){let t=e.indexOf("End of data file======\n"),s=e.substr(l+n.length,t-l-n.length);i.InputfileData=i.InputfileData?i.InputfileData+"\nENDMDL\n"+s:s;let c="Start of type file======\n",h=e.indexOf(c),p=e.indexOf("End of type file======\n"),m=e.substr(h+c.length,p-h-c.length-1);i.InputfileType=m;let u=e.indexOf("End of state file======\n");a=e.substr(o+r.length,u-o-r.length),a=decodeURIComponent(a+"\n"+d),"pdb"===m?(await i.pdbParserCls.loadPdbData(s),i.commands=[],i.optsHistory=[]):("mol2"===m?await i.mol2ParserCls.loadMol2Data(s):"sdf"===m?await i.sdfParserCls.loadSdfData(s):"xyz"===m?await i.xyzParserCls.loadXyzData(s):"mmcif"===m&&await i.mmcifParserCls.loadMmcifData(s),i.commands=[],i.optsHistory=[])}else{let t=e.indexOf("End of state file======\n");a=e.substr(o+r.length,t-o-r.length),a=decodeURIComponent(a+"\n"+d),i.commands=[],i.optsHistory=[]}await i.loadScriptCls.loadScript(a,!0),s.htmlCls.clickMenuCls.setLogCmd("load iCn3D PNG image "+$("#"+s.pre+"pngimage").val(),!1)}}fileSupport(){window.File&&window.FileReader&&window.FileList&&window.Blob||alert("The File APIs are not fully supported in this browser.")}getLinkColor(){let e="";return e+=", linkmap: {\n",e+='3: {"type": "peptidebond", "c":""},\n',e+='4: {"type": "ssbond", "c":"FFA500"},\n',e+='5: {"type": "ionic", "c":"0FF"},\n',e+='6: {"type": "ionicInside", "c":"FFF"},\n',e+='11: {"type": "contact", "c":"888"},\n',e+='12: {"type": "contactInside", "c":"FFF"},\n',e+='13: {"type": "hbond", "c":"0F0"},\n',e+='14: {"type": "hbondInside", "c":"FFF"},\n',e+='15: {"type": "clbond", "c":"006400"},\n',e+='17: {"type": "halogen", "c":"F0F"},\n',e+='18: {"type": "halogenInside", "c":"FFF"},\n',e+='19: {"type": "pication", "c":"F00"},\n',e+='20: {"type": "picationInside", "c":"FFF"},\n',e+='21: {"type": "pistacking", "c":"00F"},\n',e+='22: {"type": "pistackingInside", "c":"FFF"}\n',e+="}}\n",', linkmap: {\n3: {"type": "peptidebond", "c":""},\n4: {"type": "ssbond", "c":"FFA500"},\n5: {"type": "ionic", "c":"0FF"},\n6: {"type": "ionicInside", "c":"FFF"},\n11: {"type": "contact", "c":"888"},\n12: {"type": "contactInside", "c":"FFF"},\n13: {"type": "hbond", "c":"0F0"},\n14: {"type": "hbondInside", "c":"FFF"},\n15: {"type": "clbond", "c":"006400"},\n17: {"type": "halogen", "c":"F0F"},\n18: {"type": "halogenInside", "c":"FFF"},\n19: {"type": "pication", "c":"F00"},\n20: {"type": "picationInside", "c":"FFF"},\n21: {"type": "pistacking", "c":"00F"},\n22: {"type": "pistackingInside", "c":"FFF"}\n}}\n'}setCookieForThickness(){let e=this.icn3dui,t=e.icn3d;if(!e.bNode){let e=3650;this.setCookie("lineRadius",t.lineRadius,e),this.setCookie("coilWidth",t.coilWidth,e),this.setCookie("cylinderRadius",t.cylinderRadius,e),this.setCookie("crosslinkRadius",t.crosslinkRadius,e),this.setCookie("traceRadius",t.traceRadius,e),this.setCookie("dotSphereScale",t.dotSphereScale,e),this.setCookie("ribbonthickness",t.ribbonthickness,e),this.setCookie("helixSheetWidth",t.helixSheetWidth,e),this.setCookie("nucleicAcidWidth",t.nucleicAcidWidth,e)}}setLineThickness(e,t){let s=this.icn3dui,i=s.icn3d;if(i.bSetThickness=!0,"style"==e&&(t&&($("#"+s.pre+"shininess").val("40"),$("#"+s.pre+"light1").val("0.6"),$("#"+s.pre+"light2").val("0.4"),$("#"+s.pre+"light3").val("0.2"),$("#"+s.pre+"glycan").val("0"),$("#"+s.pre+"membrane").val("1"),$("#"+s.pre+"cmdwindow").val("0")),i.shininess=parseFloat($("#"+s.pre+"shininess").val()),i.light1=parseFloat($("#"+s.pre+"light1").val()),i.light2=parseFloat($("#"+s.pre+"light2").val()),i.light3=parseFloat($("#"+s.pre+"light3").val()),i.bGlycansCartoon=parseInt($("#"+s.pre+"glycan").val()),i.bMembrane=parseInt($("#"+s.pre+"membrane").val()),i.bCmdWindow=parseInt($("#"+s.pre+"cmdwindow").val())),t&&($("#"+s.pre+"linerad_"+e).val(.1),$("#"+s.pre+"coilrad_"+e).val(.3),$("#"+s.pre+"stickrad_"+e).val(.4),$("#"+s.pre+"crosslinkrad_"+e).val(.4),$("#"+s.pre+"tracerad_"+e).val(.4),$("#"+s.pre+"ballscale_"+e).val(.3),$("#"+s.pre+"ribbonthick_"+e).val(.2),$("#"+s.pre+"prtribbonwidth_"+e).val(1.3),$("#"+s.pre+"nucleotideribbonwidth_"+e).val(.8)),i.lineRadius=parseFloat($("#"+s.pre+"linerad_"+e).val()),i.coilWidth=parseFloat($("#"+s.pre+"coilrad_"+e).val()),i.cylinderRadius=parseFloat($("#"+s.pre+"stickrad_"+e).val()),i.crosslinkRadius=parseFloat($("#"+s.pre+"crosslinkrad_"+e).val()),i.traceRadius=parseFloat($("#"+s.pre+"tracerad_"+e).val()),i.dotSphereScale=parseFloat($("#"+s.pre+"ballscale_"+e).val()),i.ribbonthickness=parseFloat($("#"+s.pre+"ribbonthick_"+e).val()),i.helixSheetWidth=parseFloat($("#"+s.pre+"prtribbonwidth_"+e).val()),i.nucleicAcidWidth=parseFloat($("#"+s.pre+"nucleotideribbonwidth_"+e).val()),!s.bNode){let e=3650;this.setCookie("shininess",i.shininess,e),this.setCookie("light1",i.light1,e),this.setCookie("light2",i.light2,e),this.setCookie("light3",i.light3,e),this.setCookie("glycan",i.bGlycansCartoon,e),this.setCookie("membrane",i.bMembrane,e),this.setCookie("cmdwindow",i.bCmdWindow,e)}if(this.setCookieForThickness(),e=t){let e="reset thickness";s.htmlCls.clickMenuCls.setLogCmd(e,!0),i.bSetThickness=!1,i.threeDPrintCls.resetAfter3Dprint()}else s.htmlCls.clickMenuCls.setLogCmd("set thickness | linerad "+i.lineRadius+" | coilrad "+i.coilWidth+" | stickrad "+i.cylinderRadius+" | crosslinkrad "+i.crosslinkRadius+" | tracerad "+i.traceRadius+" | ribbonthick "+i.ribbonthickness+" | proteinwidth "+i.helixSheetWidth+" | nucleotidewidth "+i.nucleicAcidWidth+" | ballscale "+i.dotSphereScale,!0),s.htmlCls.clickMenuCls.setLogCmd("set glycan "+i.bGlycansCartoon,!0),s.htmlCls.clickMenuCls.setLogCmd("set membrane "+i.bMembrane,!0),s.htmlCls.clickMenuCls.setLogCmd("set cmdwindow "+i.bCmdWindow,!0);i.drawCls.draw()}setCookie(e,t,s){let i=new Date;i.setTime(i.getTime()+24*s*60*60*1e3);let n="expires="+i.toUTCString();document.cookie=e+"="+t+";"+n+";path=/"}updateSurfPara(e){let t=this.icn3dui,s=t.icn3d;s.phisurftype=$("#"+t.pre+e+"surftype").val(),s.phisurfop=$("#"+t.pre+e+"surfop").val(),s.phisurfwf=$("#"+t.pre+e+"surfwf").val()}exportPdb(){let e=this.icn3dui,t=e.icn3d,s="",i=e.hashUtilsCls.intHash(t.dAtoms,t.hAtoms);if(s+=t.saveFileCls.getAtomPDB(i),!e.bNode){let e=t.inputid?t.inputid:"custom";t.saveFileCls.saveFile(e+"_icn3d.pdb","text",[s])}return s}exportSecondary(){let e=this.icn3dui,t=e.icn3d,s="",i=e.hashUtilsCls.intHash(t.dAtoms,t.hAtoms);if(s+=t.saveFileCls.getSecondary(i),!e.bNode){let e=t.inputid?t.inputid:"custom";t.saveFileCls.saveFile(e+"_icn3d_ss.txt","text",[s])}return s}}class g{constructor(e){let t=e;this.icn3dui=e,this.cfg=this.icn3dui.cfg,this.opts={},this.opts.background="black",this.allMenus={},this.allMenusSel={},this.simpleMenus={},this.shownMenus={},this.WIDTH=400,this.HEIGHT=400,this.RESIDUE_WIDTH=10,t.utilsCls.isMobile()||this.cfg.mobilemenu?this.MENU_HEIGHT=0:this.MENU_HEIGHT=40,this.LOG_HEIGHT=65,this.MENU_WIDTH=750,this.LESSWIDTH=20,this.LESSWIDTH_RESIZE=20,this.LESSHEIGHT=20,this.width2d=200,this.CMD_HEIGHT=.8*this.LOG_HEIGHT,this.EXTRAHEIGHT=this.MENU_HEIGHT+this.CMD_HEIGHT,null!=this.cfg.showmenu&&0==this.cfg.showmenu&&(this.EXTRAHEIGHT-=this.MENU_HEIGHT),null!=this.cfg.showcommand&&0==this.cfg.showcommand&&(this.EXTRAHEIGHT-=this.CMD_HEIGHT),this.GREY8="#AAAAAA",this.GREYB="#CCCCCC",this.GREYC="#DDDDDD",this.GREYD="#EEEEEE",this.ORANGE="#FFA500",this.themecolor="blue",this.defaultValue=1,this.ssValue=3,this.coilValue=3,this.contactValue=11,this.contactInsideValue=12,this.hbondValue=13,this.hbondInsideValue=14,this.ssbondValue=4,this.ionicValue=5,this.ionicInsideValue=6,this.clbondValue=15,this.halogenValue=17,this.halogenInsideValue=18,this.picationValue=19,this.picationInsideValue=20,this.pistackingValue=21,this.pistackingInsideValue=22,this.contactColor="888",this.contactInsideColor="FFF",this.hbondColor="0F0",this.hbondInsideColor="FFF",this.ssbondColor="FFA500",this.ionicColor="0FF",this.ionicInsideColor="FFF",this.clbondColor="006400",this.halogenColor="F0F",this.halogenInsideColor="FFF",this.picationColor="F00",this.picationInsideColor="FFF",this.pistackingColor="00F",this.pistackingInsideColor="FFF",this.hideedges=1,this.force=4,this.simulation=void 0,this.baseUrl=window&&window.location&&"structure.ncbi.nlm.nih.gov"==window.location.hostname?"https://structure.ncbi.nlm.nih.gov/Structure/":"https://www.ncbi.nlm.nih.gov/Structure/",this.divStr="
    ",this.spanNowrapStr="",this.inputTextStr="=2.0 are supported.")));const a=new pe(o,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});a.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===r[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}a.setExtensions(l),a.setPlugins(r),a.parse(s,i)}parseAsync(e,t){const s=this;return new Promise((function(i,n){s.parse(e,t,i,n)}))}}function b(){let e={};return{get:function(t){return e[t]},add:function(t,s){e[t]=s},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const C={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class y{constructor(e){this.parser=e,this.name=C.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,i=t.length;s=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,n.source,l)}}class R{constructor(e){this.parser=e,this.name=C.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,i=s.json,n=i.textures[e];if(!n.extensions||!n.extensions[t])return null;const l=n.extensions[t],r=i.images[l.source];let o=s.textureLoader;if(r.uri){const e=s.options.manager.getHandler(r.uri);null!==e&&(o=e)}return this.detectSupport().then((function(n){if(n)return s.loadTextureImage(e,l.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class E{constructor(e){this.name=C.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const e=s.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),n=this.parser.options.meshoptDecoder;if(!n||!n.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([i,n.ready]).then((function(t){const s=e.byteOffset||0,i=e.byteLength||0,l=e.count,r=e.byteStride,o=new ArrayBuffer(l*r),a=new Uint8Array(t[0],s,i);return n.decodeGltfBuffer(new Uint8Array(o),l,r,a,e.mode,e.filter),o}))}return null}}const I="glTF",T=1313821514,M=5130562;class P{constructor(e){this.name=C.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:THREE.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==I)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-12,i=new DataView(e,12);let n=0;for(;n",t).replace("#include ",s).replace("#include ",i).replace("#include ",n).replace("#include ",l)},Object.defineProperties(this,{specular:{get:function(){return r.specular.value},set:function(e){r.specular.value=e}},specularMap:{get:function(){return r.specularMap.value},set:function(e){r.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return r.glossiness.value},set:function(e){r.glossiness.value=e}},glossinessMap:{get:function(){return r.glossinessMap.value},set:function(e){r.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class L{constructor(){this.name=C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity"]}getMaterialType(){return F}extendParams(e,t,s){const i=t.extensions[this.name];e.color=new Color(1,1,1),e.opacity=1;const n=[];if(Array.isArray(i.diffuseFactor)){const t=i.diffuseFactor;e.color.fromArray(t),e.opacity=t[3]}if(void 0!==i.diffuseTexture&&n.push(s.assignTexture(e,"map",i.diffuseTexture,sRGBEncoding)),e.emissive=new Color(0,0,0),e.glossiness=void 0!==i.glossinessFactor?i.glossinessFactor:1,e.specular=new Color(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),void 0!==i.specularGlossinessTexture){const t=i.specularGlossinessTexture;n.push(s.assignTexture(e,"glossinessMap",t)),n.push(s.assignTexture(e,"specularMap",t,sRGBEncoding))}return Promise.all(n)}createMaterial(e){const t=new F(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=TangentSpaceNormalMap,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t}}class N{constructor(){this.name=C.KHR_MESH_QUANTIZATION}}class U extends THREE.Interpolant{constructor(e,t,s,i){super(e,t,s,i)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,i=this.valueSize,n=e*i*3+i;for(let e=0;e!==i;e++)t[e]=s[n+e];return t}}U.prototype.beforeStart_=U.prototype.copySampleValue_,U.prototype.afterEnd_=U.prototype.copySampleValue_,U.prototype.interpolate_=function(e,t,s,i){const n=this.resultBuffer,l=this.sampleValues,r=this.valueSize,o=2*r,a=3*r,d=i-t,c=(s-t)/d,h=c*c,p=h*c,m=e*a,u=m-a,g=-2*p+3*h,f=p-h,b=1-g,C=f-h+c;for(let e=0;e!==r;e++){const t=l[u+e+r],s=l[u+e+o]*d,i=l[m+e+r],a=l[m+e]*d;n[e]=b*t+C*s+g*i+f*a}return n};const q=new THREE.Quaternion;class j extends U{interpolate_(e,t,s,i){const n=super.interpolate_(e,t,s,i);return q.fromArray(n).normalize().toArray(n),n}}const B=0,z=1,G=2,V=3,W=4,Y=5,X=6,K={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Q={9728:THREE.NearestFilter,9729:THREE.LinearFilter,9984:THREE.NearestMipmapNearestFilter,9985:THREE.LinearMipmapNearestFilter,9986:THREE.NearestMipmapLinearFilter,9987:THREE.LinearMipmapLinearFilter},J={33071:THREE.ClampToEdgeWrapping,33648:THREE.MirroredRepeatWrapping,10497:THREE.RepeatWrapping},Z={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ee={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},te={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},se={CUBICSPLINE:void 0,LINEAR:THREE.InterpolateLinear,STEP:THREE.InterpolateDiscrete},ie="OPAQUE",ne="MASK",le="BLEND";function re(e,t,s){for(const i in s.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=s.extensions[i])}function oe(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function ae(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let s=0,i=t.weights.length;s{const s=this.associations.get(e);null!=s&&this.associations.set(t,s);for(const[s,i]of e.children.entries())n(i,t.children[s])};return n(s,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s=2&&m.setY(t,c[e*l+1]),l>=3&&m.setZ(t,c[e*l+2]),l>=4&&m.setW(t,c[e*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m}))}loadTexture(e){const t=this.json,s=this.options,i=t.textures[e].source,n=t.images[i];let l=this.textureLoader;if(n.uri){const e=s.manager.getHandler(n.uri);null!==e&&(l=e)}return this.loadTextureImage(e,i,l)}loadTextureImage(e,t,s){const i=this,n=this.json,l=n.textures[e],r=n.images[t],o=(r.uri||r.bufferView)+":"+l.sampler;if(this.textureCache[o])return this.textureCache[o];const a=this.loadImageSource(t,s).then((function(t){t.flipY=!1,l.name&&(t.name=l.name);const s=(n.samplers||{})[l.sampler]||{};return t.magFilter=Q[s.magFilter]||LinearFilter,t.minFilter=Q[s.minFilter]||LinearMipmapLinearFilter,t.wrapS=J[s.wrapS]||RepeatWrapping,t.wrapT=J[s.wrapT]||RepeatWrapping,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=a,a}loadImageSource(e,t){const s=this,i=this.json,n=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const l=i.images[e],r=self.URL||self.webkitURL;let o=l.uri||"",a=!1;if(void 0!==l.bufferView)o=s.getDependency("bufferView",l.bufferView).then((function(e){a=!0;const t=new Blob([e],{type:l.mimeType});return o=r.createObjectURL(t),o}));else if(void 0===l.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(o).then((function(e){return new Promise((function(s,i){let l=s;!0===t.isImageBitmapLoader&&(l=function(e){const t=new Texture(e);t.needsUpdate=!0,s(t)}),t.load(THREE.LoaderUtils.resolveURL(e,n.path),l,void 0,i)}))})).then((function(e){var t;return!0===a&&r.revokeObjectURL(o),e.userData.mimeType=l.mimeType||((t=l.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),e}));return this.sourceCache[e]=d,d}assignTexture(e,t,s,i){const n=this;return this.getDependency("texture",s.index).then((function(l){if(void 0===s.texCoord||0==s.texCoord||"aoMap"===t&&1==s.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+s.texCoord+" for texture "+t+" not yet supported."),n.extensions[C.KHR_TEXTURE_TRANSFORM]){const e=void 0!==s.extensions?s.extensions[C.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=n.associations.get(l);l=n.extensions[C.KHR_TEXTURE_TRANSFORM].extendTexture(l,e),n.associations.set(l,t)}}return void 0!==i&&(l.encoding=i),e[t]=l,l}))}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const i=void 0===t.attributes.tangent,n=void 0!==t.attributes.color,l=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new PointsMaterial,Material.prototype.copy.call(t,s),t.color.copy(s.color),t.map=s.map,t.sizeAttenuation=!1,this.cache.add(e,t)),s=t}else if(e.isLine){const e="LineBasicMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new LineBasicMaterial,Material.prototype.copy.call(t,s),t.color.copy(s.color),this.cache.add(e,t)),s=t}if(i||n||l){let e="ClonedMaterial:"+s.uuid+":";s.isGLTFSpecularGlossinessMaterial&&(e+="specular-glossiness:"),i&&(e+="derivative-tangents:"),n&&(e+="vertex-colors:"),l&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=s.clone(),n&&(t.vertexColors=!0),l&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(s))),s=t}s.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),e.material=s}getMaterialType(){return MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,i=this.extensions,n=s.materials[e];let l;const r={},o=n.extensions||{},a=[];if(o[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=i[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];l=e.getMaterialType(),a.push(e.extendParams(r,n,t))}else if(o[C.KHR_MATERIALS_UNLIT]){const e=i[C.KHR_MATERIALS_UNLIT];l=e.getMaterialType(),a.push(e.extendParams(r,n,t))}else{const s=n.pbrMetallicRoughness||{};if(r.color=new Color(1,1,1),r.opacity=1,Array.isArray(s.baseColorFactor)){const e=s.baseColorFactor;r.color.fromArray(e),r.opacity=e[3]}void 0!==s.baseColorTexture&&a.push(t.assignTexture(r,"map",s.baseColorTexture,sRGBEncoding)),r.metalness=void 0!==s.metallicFactor?s.metallicFactor:1,r.roughness=void 0!==s.roughnessFactor?s.roughnessFactor:1,void 0!==s.metallicRoughnessTexture&&(a.push(t.assignTexture(r,"metalnessMap",s.metallicRoughnessTexture)),a.push(t.assignTexture(r,"roughnessMap",s.metallicRoughnessTexture))),l=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),a.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,r)}))))}!0===n.doubleSided&&(r.side=DoubleSide);const d=n.alphaMode||ie;if(d===le?(r.transparent=!0,r.depthWrite=!1):(r.transparent=!1,d===ne&&(r.alphaTest=void 0!==n.alphaCutoff?n.alphaCutoff:.5)),void 0!==n.normalTexture&&l!==MeshBasicMaterial&&(a.push(t.assignTexture(r,"normalMap",n.normalTexture)),r.normalScale=new Vector2(1,1),void 0!==n.normalTexture.scale)){const e=n.normalTexture.scale;r.normalScale.set(e,e)}return void 0!==n.occlusionTexture&&l!==MeshBasicMaterial&&(a.push(t.assignTexture(r,"aoMap",n.occlusionTexture)),void 0!==n.occlusionTexture.strength&&(r.aoMapIntensity=n.occlusionTexture.strength)),void 0!==n.emissiveFactor&&l!==MeshBasicMaterial&&(r.emissive=(new Color).fromArray(n.emissiveFactor)),void 0!==n.emissiveTexture&&l!==MeshBasicMaterial&&a.push(t.assignTexture(r,"emissiveMap",n.emissiveTexture,sRGBEncoding)),Promise.all(a).then((function(){let s;return s=l===F?i[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(r):new l(r),n.name&&(s.name=n.name),oe(s,n),t.associations.set(s,{materials:e}),n.extensions&&re(i,s,n),s}))}createUniqueName(e){const t=PropertyBinding.sanitizeNodeName(e||"");let s=t;for(let e=1;this.nodeNamesUsed[s];++e)s=t+"_"+e;return this.nodeNamesUsed[s]=!0,s}loadGeometries(e){const t=this,s=this.extensions,i=this.primitiveCache;function n(e){return s[C.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(s){return ue(s,e,t)}))}const l=[];for(let s=0,r=e.length;s0&&ae(h,n),h.name=t.createUniqueName(n.name||"mesh_"+e),oe(h,n),c.extensions&&re(i,h,c),t.assignFinalMaterial(h),a.push(h)}for(let s=0,i=a.length;s1?new Group:1===t.length?t[0]:new Object3D,r!==t[0])for(let e=0,s=t.length;e{const t=new Map;for(const[e,s]of n.associations)(e instanceof Material||e instanceof Texture)&&t.set(e,s);return e.traverse((e=>{const s=n.associations.get(e);null!=s&&t.set(e,s)})),t})(l),l}))}}function me(e,t,s,i){const n=s.nodes[e];return i.getDependency("node",e).then((function(e){if(void 0===n.skin)return e;let t;return i.getDependency("skin",n.skin).then((function(e){t=e;const s=[];for(let e=0,n=t.joints.length;e{const s=n[e];return s&&(l={profileId:e,profilePath:`${t}/${s.path}`,deprecated:!!s.deprecated}),!!l})),!l){if(!s)throw new Error("No matching profile name found");const e=n[s];if(!e)throw new Error(`No matching profile name found and default profile "${s}" missing.`);l={profileId:s,profilePath:`${t}/${e.path}`,deprecated:!!e.deprecated}}const r=await be(l.profilePath);let o;if(i){let t;if(t="any"===e.handedness?r.layouts[Object.keys(r.layouts)[0]]:r.layouts[e.handedness],!t)throw new Error(`No matching handedness, ${e.handedness}, in profile ${l.profileId}`);t.assetPath&&(o=l.profilePath.replace("profile.json",t.assetPath))}return{profile:r,assetPath:o}}const ye={xAxis:0,yAxis:0,button:0,state:fe.ComponentState.DEFAULT};class ve{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===fe.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(ye)}updateFromComponent({xAxis:e,yAxis:t,button:s,state:i}){const{normalizedXAxis:n,normalizedYAxis:l}=function(e=0,t=0){let s=e,i=t;if(Math.sqrt(e*e+t*t)>1){const n=Math.atan2(t,e);s=Math.cos(n),i=Math.sin(n)}return{normalizedXAxis:.5*s+.5,normalizedYAxis:.5*i+.5}}(e,t);switch(this.componentProperty){case fe.ComponentProperty.X_AXIS:this.value=this.states.includes(i)?n:.5;break;case fe.ComponentProperty.Y_AXIS:this.value=this.states.includes(i)?l:.5;break;case fe.ComponentProperty.BUTTON:this.value=this.states.includes(i)?s:0;break;case fe.ComponentProperty.STATE:this.valueNodeProperty===fe.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(i):this.value=this.states.includes(i)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}}class we{constructor(e,t){if(!(e&&t&&t.visualResponses&&t.gamepadIndices&&0!==Object.keys(t.gamepadIndices).length))throw new Error("Invalid arguments supplied");this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach((e=>{const s=new ve(t.visualResponses[e]);this.visualResponses[e]=s})),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:fe.ComponentState.DEFAULT,button:void 0!==this.gamepadIndices.button?0:void 0,xAxis:void 0!==this.gamepadIndices.xAxis?0:void 0,yAxis:void 0!==this.gamepadIndices.yAxis?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(e){if(this.values.state=fe.ComponentState.DEFAULT,void 0!==this.gamepadIndices.button&&e.buttons.length>this.gamepadIndices.button){const t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||1===this.values.button?this.values.state=fe.ComponentState.PRESSED:(t.touched||this.values.button>fe.ButtonTouchThreshold)&&(this.values.state=fe.ComponentState.TOUCHED)}void 0!==this.gamepadIndices.xAxis&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===fe.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>fe.AxisTouchThreshold&&(this.values.state=fe.ComponentState.TOUCHED)),void 0!==this.gamepadIndices.yAxis&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===fe.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>fe.AxisTouchThreshold&&(this.values.state=fe.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach((e=>{e.updateFromComponent(this.values)}))}}class _e{constructor(e,t,s){if(!e)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No profile supplied");this.xrInputSource=e,this.assetUrl=s,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach((e=>{const t=this.layoutDescription.components[e];this.components[e]=new we(e,t)})),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const e=[];return Object.values(this.components).forEach((t=>{e.push(t.data)})),e}updateFromGamepad(){Object.values(this.components).forEach((e=>{e.updateFromGamepad(this.xrInputSource.gamepad)}))}}class Se extends THREE.Object3D{constructor(){super(),this.motionController=null,this.envMap=null}setEnvironmentMap(e){return this.envMap==e||(this.envMap=e,this.traverse((e=>{e.isMesh&&(e.material.envMap=this.envMap,e.material.needsUpdate=!0)}))),this}updateMatrixWorld(e){super.updateMatrixWorld(e),this.motionController&&(this.motionController.updateFromGamepad(),Object.values(this.motionController.components).forEach((e=>{Object.values(e.visualResponses).forEach((e=>{const{valueNode:t,minNode:s,maxNode:i,value:n,valueNodeProperty:l}=e;t&&(l===fe.VisualResponseProperty.VISIBILITY?t.visible=n:l===fe.VisualResponseProperty.TRANSFORM&&(t.quaternion.slerpQuaternions(s.quaternion,i.quaternion,n),t.position.lerpVectors(s.position,i.position,n)))}))})))}}function Ae(e,t){!function(e,t){Object.values(e.components).forEach((e=>{const{type:s,touchPointNodeName:i,visualResponses:n}=e;if(s===fe.ComponentType.TOUCHPAD)if(e.touchPointNode=t.getObjectByName(i),e.touchPointNode){const t=new SphereGeometry(.001),s=new MeshBasicMaterial({color:255}),i=new Mesh(t,s);e.touchPointNode.add(i)}else console.warn(`Could not find touch dot, ${e.touchPointNodeName}, in touchpad component ${e.id}`);Object.values(n).forEach((e=>{const{valueNodeName:s,minNodeName:i,maxNodeName:n,valueNodeProperty:l}=e;if(l===fe.VisualResponseProperty.TRANSFORM){if(e.minNode=t.getObjectByName(i),e.maxNode=t.getObjectByName(n),!e.minNode)return void console.warn(`Could not find ${i} in the model`);if(!e.maxNode)return void console.warn(`Could not find ${n} in the model`)}e.valueNode=t.getObjectByName(s),e.valueNode||console.warn(`Could not find ${s} in the model`)}))}))}(e.motionController,t),e.envMap&&t.traverse((t=>{t.isMesh&&(t.material.envMap=e.envMap,t.material.needsUpdate=!0)})),e.add(t)}class xe{constructor(e=null){this.gltfLoader=e,this.path="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",this._assetCache={},this.gltfLoader||(this.gltfLoader=new f)}createControllerModel(e){const t=new Se;let s=null;return e.addEventListener("connected",(e=>{const i=e.data;"tracked-pointer"===i.targetRayMode&&i.gamepad&&Ce(i,this.path,"generic-trigger").then((({profile:e,assetPath:n})=>{t.motionController=new _e(i,e,n);const l=this._assetCache[t.motionController.assetUrl];if(l)s=l.scene.clone(),Ae(t,s);else{if(!this.gltfLoader)throw new Error("GLTFLoader not set.");this.gltfLoader.setPath(""),this.gltfLoader.load(t.motionController.assetUrl,(e=>{this._assetCache[t.motionController.assetUrl]=e,s=e.scene.clone(),Ae(t,s)}),null,(()=>{throw new Error(`Asset ${t.motionController.assetUrl} missing or malformed.`)}))}})).catch((e=>{console.warn(e)}))})),e.addEventListener("disconnected",(()=>{t.motionController=null,t.remove(s),s=null})),t}}class ke extends THREE.EventDispatcher{constructor(e){if(super(),void 0===e)return void console.error("ControllerGestures must be passed a renderer");const t=new THREE.Clock;this.controller1=e.xr.getController(0),this.controller1.userData.gestures={index:0},this.controller1.userData.selectPressed=!1,this.controller1.addEventListener("selectstart",i),this.controller1.addEventListener("selectend",n),this.controller2=e.xr.getController(1),this.controller2.userData.gestures={index:1},this.controller2.userData.selectPressed=!1,this.controller2.addEventListener("selectstart",i),this.controller2.addEventListener("selectend",n),this.doubleClickLimit=.2,this.pressMinimum=.4,this.right=new THREE.Vector3(1,0,0),this.up=new THREE.Vector3(0,1,0),this.type="unknown",this.prevTap="none",this.clock=t;const s=this;function i(){const e=this.userData.gestures;e.startPosition=void 0,e.startTime=t.getElapsedTime(),-1==s.type.indexOf("tap")&&(e.taps=0),s.type="unknown",this.userData.selectPressed=!0}function n(){const e=this.userData.gestures;e.endTime=t.getElapsedTime();e.endTime-e.startTime.05&&(e.startPosition=this.controller1.position.clone())),this.controller2.userData.selectPressed&&void 0===t.startPosition&&(i=s-t.startTime,i>.05&&(t.startPosition=this.controller2.position.clone())),!this.controller1.userData.selectPressed&&"tap"===this.type&&(i=this.clock.getElapsedTime()-e.endTime,i>this.doubleClickLimit)){switch(e.taps){case 1:self.prevTap="tap";break;case 2:this.dispatchEvent({type:"doubletap",position:this.controller1.position,matrixWorld:this.controller1.matrixWorld}),self.prevTap="doubletap"}this.type="unknown",e.taps=0}if("unknown"===this.type&&this.touch)"doubletap"==self.prevTap?(this.type="pinch",this.startDistance=this.controller1.position.distanceTo(this.controller2.position),this.dispatchEvent({type:"pinch",delta:new THREE.Vector3(0,0,0),scale:1,initialise:!0})):(this.type="pan",this.startPosition=this.controller1.position.clone(),this.dispatchEvent({type:"pan",delta:new THREE.Vector3(0,0,0),initialise:!0}));else if(("pinch"===this.type||"pan"===this.type)&&"doubletap"==self.prevTap&&this.controller2.position){const e=this.controller1.position.distanceTo(this.controller2.position)/this.startDistance,t=this.controller1.position.clone().sub(this.startPosition);this.dispatchEvent({type:"pinch",delta:t,scale:e})}}}class Oe{constructor(e,t){this.config=void 0===t?{panelSize:{width:1,height:1},width:512,height:512,opacity:.7,body:{fontFamily:"Arial",fontSize:30,padding:20,backgroundColor:"#000",fontColor:"#fff",borderRadius:6}}:t,void 0===this.config.width&&(this.config.width=512),void 0===this.config.height&&(this.config.height=512),void 0===this.config.body&&(this.config.body={fontFamily:"Arial",size:30,padding:20,backgroundColor:"#000",fontColor:"#fff",borderRadius:6});const s=this.config.body;void 0===s.borderRadius&&(s.borderRadius=6),void 0===s.fontFamily&&(s.fontFamily="Arial"),void 0===s.padding&&(s.padding=20),void 0===s.fontSize&&(s.fontSize=30),void 0===s.backgroundColor&&(s.backgroundColor="#000"),void 0===s.fontColor&&(s.fontColor="#fff"),Object.entries(this.config).forEach((([e,t])=>{if(!("object"!=typeof t||"panelSize"===e||t instanceof THREE.WebGLRenderer||t instanceof THREE.Scene)){const e=void 0!==t.position?t.position:{x:0,y:0};void 0!==e.left&&void 0===e.x&&(e.x=e.left),void 0!==e.top&&void 0===e.y&&(e.y=e.top);const s=void 0!==t.width?t.width:this.config.width,i=void 0!==t.height?t.height:this.config.height;void 0!==e.right&&void 0===e.x&&(e.x=this.config.width-e.right-s),void 0!==e.bottom&&void 0===e.y&&(e.y=this.config.height-e.bottom-i),void 0===e.x&&(e.x=0),void 0===e.y&&(e.y=0),t.position=e,void 0===t.type&&(t.type="text")}}));const i=this.createOffscreenCanvas(this.config.width,this.config.height);this.context=i.getContext("2d"),this.context.save();const n=void 0!==this.config.opacity?this.config.opacity:.7,l=new THREE.MeshBasicMaterial({transparent:!0,opacity:n});this.panelSize=void 0!==this.config.panelSize?this.config.panelSize:{width:1,height:1};const r=new THREE.PlaneGeometry(this.panelSize.width,this.panelSize.height);this.mesh=new THREE.Mesh(r,l),this.texture=new THREE.CanvasTexture(i),this.mesh.material.map=this.texture,this.scene=this.config.scene;if(Object.values(this.config).filter((e=>"input-text"===e.type)).length>0){this.keyboard=new Re(this.panelSize.width,this.config.renderer);this.keyboard.mesh.position.set(0,-.3,.2),this.mesh.add(this.keyboard.mesh)}if(void 0===e)this.content={body:""},this.config.body.type="text";else{this.content=e;Object.values(t).filter((e=>"button"===e.type||"scroll"===e.overflow||"input-text"===e.type)).length>0&&(void 0===t||void 0===t.renderer?console.warn("CanvasUI: button, scroll or input-text in the config but no renderer"):(this.renderer=t.renderer,this.initControllers()))}this.selectedElements=[void 0,void 0],this.selectPressed=[!1,!1],this.scrollData=[void 0,void 0],this.intersects=[void 0,void 0],this.needsUpdate=!0,this.update()}getIntersectY(e){const t=this.config.height||512,s=this.intersects[e];return void 0===s||void 0===s.uv?0:(1-s.uv.y)*t}initControllers(){this.vec3=new THREE.Vector3,this.mat4=new THREE.Matrix4,this.raycaster=new THREE.Raycaster;const e=this;function t(t){const s=t.target===e.controller?0:1,i=e.selectedElements[s];if(void 0!==i)if("button"==i.type)e.select(s);else if("input-text"==i.type&&e.keyboard)if(e.keyboard.visible)e.keyboard.linkedUI=void 0,e.keyboard.linkedText=void 0,e.keyboard.linkedElement=void 0,e.keyboard.visible=!1;else{let t;e.keyboard.linkedUI=e,Object.entries(e.config).forEach((([e,s])=>{s==i&&(t=e)}));const s=(.5-(i.position.y+i.height+e.config.body.padding)/e.config.height)*e.panelSize.height,n=Math.max(e.panelSize.width,e.panelSize.height)/2;e.keyboard.position.set(0,-n/1.5-s,.1),e.keyboard.linkedText=e.content[t],e.keyboard.linkedName=t,e.keyboard.linkedElement=i,e.keyboard.visible=!0}}function s(t){const s=t.target===e.controller?0:1;if(e.selectPressed[s]=!0,void 0!==e.selectedElements[s]&&"scroll"==e.selectedElements[s].overflow){const t=e.selectedElements[s];e.scrollData[s]={scrollY:t.scrollY,rayY:e.getIntersectY(s)}}}function i(t){const s=t.target===e.controller?0:1;e.selectPressed[s]=!1,void 0!==e.selectedElements[s]&&"scroll"==e.selectedElements[s].overflow&&(e.scrollData[s]=void 0)}if(this.controller=this.renderer.xr.getController(0),this.controller.addEventListener("select",t),this.controller.addEventListener("selectstart",s),this.controller.addEventListener("selectend",i),this.controller1=this.renderer.xr.getController(1),this.controller1.addEventListener("select",t),this.controller1.addEventListener("selectstart",s),this.controller1.addEventListener("selectend",i),this.scene){const e=.015,t=new THREE.IcosahedronBufferGeometry(e),s=new THREE.MeshBasicMaterial({color:170}),i=new THREE.Mesh(t,s);i.visible=!1,this.scene.add(i);const n=new THREE.Mesh(t,s);n.visible=!1,this.scene.add(n),this.intersectMesh=[i,n]}}setClip(e){const t=this.context;if(t.restore(),t.save(),void 0!==e.clipPath){const s=new Path2D(e.clipPath);t.clip(s)}else{const s=void 0!==e.position?e.position:{x:0,y:0},i=e.borderRadius||0,n=e.width||this.config.width,l=e.height||this.config.height;if(t.beginPath(),0!==i){const e=Math.PI/2;t.moveTo(s.x+i,s.y),t.arc(s.x+i,s.y+i,i,e,2*e,!0),t.lineTo(s.x,s.y+l-i),t.arc(s.x+i,s.y+l-i,i,0,e,!0),t.lineTo(s.x+n-i,s.y+l),t.arc(s.x+n-i,s.y+l-i,i,3*e,4*e,!0),t.lineTo(s.x+n,s.y+i),t.arc(s.x+n-i,s.y+i,i,2*e,3*e,!0),t.closePath(),t.clip()}else t.rect(s.x,s.y,n,l),t.clip()}}setPosition(e,t,s){void 0!==this.mesh&&this.mesh.position.set(e,t,s)}setRotation(e,t,s){void 0!==this.mesh&&this.mesh.rotation.set(e,t,s)}updateElement(e,t){let s=this.content[e];void 0!==s?("object"==typeof s?s.content=t:s=t,this.content[e]=s,this.needsUpdate=!0):console.warn(`CanvasGUI.updateElement: No ${e} found`)}get panel(){return this.mesh}getElementAtLocation(e,t){const s=this,i=Object.entries(this.config).filter((([i,n])=>{if(!("object"!=typeof n||"panelSize"===i||"body"===i||n instanceof THREE.WebGLRenderer||n instanceof THREE.Scene)){const i=n.position,l=void 0!==n.width?n.width:s.config.width,r=void 0!==n.height?n.height:s.config.height;return e>=i.x&&e=i.y&&t0?(this.hover(t,s[0].uv),this.intersects[t]=s[0],this.scroll(t)):(this.hover(t),this.intersects[t]=void 0,this.scroll(t))}update(){if(void 0===this.mesh)return;if(this.controller&&this.handleController(this.controller,0),this.controller1&&this.handleController(this.controller1,1),this.keyboard&&this.keyboard.visible&&this.keyboard.update(),!this.needsUpdate)return;let e=this.context;e.clearRect(0,0,this.config.width,this.config.height);const t=this.config.body.backgroundColor?this.config.body.backgroundColor:"#000";!this.config.body.fontFamily||this.config.body.fontFamily;const s=this.config.body.fontColor?this.config.body.fontColor:"#fff";!this.config.body.fontSize||this.config.body.fontSize,this.setClip(this.config.body),e.fillStyle=t,e.fillRect(0,0,this.config.width,this.config.height);const i=this;Object.entries(this.content).forEach((([t,n])=>{const l=void 0!==i.config[t]?i.config[t]:i.config.body;if("none"!==(void 0!==l.display?l.display:"block")){const r=void 0!==l.position?l.position:{x:0,y:0},o=void 0!==l.width?l.width:i.config.width,a=void 0!==l.height?l.height:i.config.height;"button"!=l.type||n.toLowerCase().startsWith("")||(void 0===l.borderRadius&&(l.borderRadius=6),void 0===l.textAlign&&(l.textAlign="center")),i.setClip(l);const d=n.toLowerCase().startsWith(""),c=void 0!==i.selectedElements[0]&&this.selectedElements[0]===l||void 0!==i.selectedElements[1]&&this.selectedElements[1]===l;if(void 0!==l.backgroundColor&&(c&&"button"==l.type&&void 0!==l.hover?e.fillStyle=l.hover:e.fillStyle=l.backgroundColor,e.fillRect(r.x,r.y,o,a)),"text"==l.type||"button"==l.type||"input-text"==l.type){let h=!1;if(c?(d||"button"!=l.type?e.fillStyle=void 0!==l.hover?l.hover:void 0!==l.fontColor?l.fontColor:s:e.fillStyle=void 0!==l.fontColor?l.fontColor:s,h=void 0===l.hover):e.fillStyle=void 0!==l.fontColor?l.fontColor:s,d){const t=n.toUpperCase().substring(6,n.length-7);e.save(),e.translate(r.x,r.y);const s=new Path2D(t);e.fill(s),e.restore()}else i.wrapText(t,n);h&&(e.beginPath(),e.strokeStyle="#fff",e.lineWidth=2,e.rect(r.x,r.y,o,a),e.stroke())}else if("img"==l.type)if(void 0===l.img)this.loadImage(n).then((e=>{console.log(`w: ${e.width} | h: ${e.height}`),l.img=e,i.needsUpdate=!0,i.update()})).catch((e=>console.error(e)));else{const t=o/(l.img.width/l.img.height);e.drawImage(l.img,r.x,r.y,o,t)}}})),this.needsUpdate=!1,this.texture.needsUpdate=!0}loadImage(e){return new Promise(((t,s)=>{const i=new THREE.Image;i.addEventListener("load",(()=>t(i))),i.addEventListener("error",(e=>s(e))),i.src=e}))}createOffscreenCanvas(e,t){const s=document.createElement("canvas");return s.width=e,s.height=t,s}fillRoundedRect(e,t,s,i,n){const l=this.context;l.beginPath(),l.moveTo(e+n,t),l.lineTo(e+s-n,t),l.quadraticCurveTo(e+s,t,e+s,t+n),l.lineTo(e+s,t+i-n),l.quadraticCurveTo(e+s,t+i,e+s-n,t+i),l.lineTo(e+n,t+i),l.quadraticCurveTo(e,t+i,e,t+i-n),l.lineTo(e,t+n),l.quadraticCurveTo(e,t,e+n,t),l.closePath(),l.fill()}lookAt(e){void 0!==this.mesh&&(e instanceof Vector3?this.mesh.lookAt(e):console.error("CanvasUI lookAt called parameter not a THREE.Vector3"))}get visible(){return void 0!==this.mesh&&this.mesh.visible}set visible(e){this.mesh&&(this.mesh.visible=e)}get position(){if(void 0!==this.mesh)return this.mesh.position}set position(e){void 0!==this.mesh&&(e instanceof Vector3?this.mesh.position.copy(e):console.error("CanvasUI trying to set the mesh position using a parameter that is not a THREE.Vector3"))}get quaternion(){if(void 0!==this.mesh)return this.mesh.quaternion}set quaternion(e){void 0!==this.mesh&&(e instanceof QUaternion?this.mesh.quaternion.copy(e):console.error("CanvasUI trying to set the mesh quaternion using a parameter that is not a THREE.Quaternion"))}wrapText(e,t){const s=t.split(" ");let i="";const n=[],l=void 0!==this.config[e]?this.config[e]:this.config.body,r=void 0!==l.width?l.width:this.config.width,o=void 0!==l.height?l.height:this.config.height,a=void 0!==l.position?l.position:{x:0,y:0},d=void 0!==l.padding?l.padding:void 0!==this.config.body.padding?this.config.body.padding:10,c=void 0!==l.paddingTop?l.paddingTop:d,h=void 0!==l.paddingLeft?l.paddingLeft:d,p=void 0!==l.paddingBottom?l.paddingBottom:d,m=void 0!==l.paddingRight?l.paddingRight:d,u={x:a.x+h,y:a.y+c,width:r-h-m,height:o-c-p},g=void 0!==l.textAlign?l.textAlign:void 0!==this.config.body.textAlign?this.config.body.textAlign:"left",f=void 0!==l.fontSize?l.fontSize:void 0!==this.config.body.fontSize?this.config.body.fontSize:30,b=void 0!==l.fontFamily?l.fontFamily:void 0!==this.config.body.fontFamily?this.config.body.fontFamily:"Arial",C=f+(void 0!==l.leading?l.leading:void 0!==this.config.body.leading?this.config.body.leading:8),y=this.context;y.textAlign=g,y.font=`${f}px '${b}'`,s.forEach((function(e){let t=s.length>1?`${i}${e} `:e,l=y.measureText(t);if(l.width>u.width&&e.length>1)if(0==i.length&&l.width>u.width){for(;l.width>u.width;){let s=0;do{s++,t=e.substr(0,s),l=y.measureText(t)}while(l.widthu.height&&"scroll"===l.overflow){void 0===l.scrollY&&(l.scrollY=0);const e=void 0!==l.fontColor?l.fontColor:this.config.body.fontColor;y.fillStyle="#aaa",this.fillRoundedRect(a.x+r-12,a.y,12,o,6),y.fillStyle="#666";const t=u.height/v,s=t*o,i=-l.scrollY*t;this.fillRoundedRect(a.x+r-12,a.y+i,12,s,6),y.fillStyle=e,w=l.scrollY,l.minScrollY=u.height-v}let _,S=w+u.y+f/2;switch(g){case"center":_=u.x+u.width/2;break;case"right":_=u.x+u.width;break;default:_=u.x}n.forEach((e=>{S+C>0&&y.fillText(e,_,S),S+=C}))}}class Re{constructor(e,t,s="EN"){const i=this.getConfig(s);i.panelSize={width:e,height:.5*e},i.height=256,i.body={backgroundColor:"#555"},i.renderer=t;const n=this.getContent(s);this.keyboard=new Oe(n,i),this.keyboard.mesh.visible=!1,this.shift=!1}get mesh(){return this.keyboard.mesh}getConfig(e){const t={};let s=10;const i=39.2,n=49,l="#333",r="#000";let o=s,a=s;for(let e=0;e<10;e++){const d={type:"button",position:{x:a,y:o},width:i,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e)};t[`btn${e}`]=d,a+=49.2}o+=59,a=s;for(let e=0;e<10;e++){const d={type:"button",position:{x:a,y:o},width:i,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+10)};t[`btn${e+10}`]=d,a+=49.2}o+=59,a=s;for(let e=0;e<9;e++){const d=0==e||8==e?1.5*i+5:i,c={type:"button",position:{x:a,y:o},width:d,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+20)};t[`btn${e+20}`]=c,a+=d+s}o+=59,a=s;for(let e=0;e<5;e++){const d=0==e||4==e?88.4:2==e?186.8:i,c={type:"button",position:{x:a,y:o},width:d,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+30)};0==e&&(c.fontSize=20),t[`btn${e+30}`]=c,a+=d+s}return t}getContent(e,t=0){let s,i={};switch(this.language=e,this.keyboardIndex=t,t){case 0:s=["q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","@","⇧","z","x","c","v","b","n","m","⇦","","?123",","," ",".","↲"];for(let e=0;e","_","`","~",":",";","⇦","","abc",","," ",".","↲"];for(let e=0;e=0;e--){let s=t.scene.children[e];t.scene.remove(s)}else t.scene=new THREE.Scene;if(void 0!==t.scene_ghost)for(let e=t.scene_ghost.children.length-1;e>=0;e--){let s=t.scene_ghost.children[e];t.scene_ghost.remove(s)}else t.scene_ghost=new THREE.Scene;if(""!=s.htmlCls.setHtmlCls.getCookie("shininess")){let e=parseFloat(s.htmlCls.setHtmlCls.getCookie("shininess"));t.shininess!=e&&s.htmlCls.clickMenuCls.setLogCmd("set shininess "+e,!0),t.shininess=e}if(!s.bNode&&""!=s.htmlCls.setHtmlCls.getCookie("light1")){let e=parseFloat(s.htmlCls.setHtmlCls.getCookie("light1")),i=parseFloat(s.htmlCls.setHtmlCls.getCookie("light2")),n=parseFloat(s.htmlCls.setHtmlCls.getCookie("light3"));t.light1==e&&t.light2==i&&t.light3==n||s.htmlCls.clickMenuCls.setLogCmd("set light | light1 "+e+" | light2 "+i+" | light3 "+n,!0),t.light1=e,t.light2=i,t.light3=n}t.directionalLight=new THREE.DirectionalLight(16777215,t.light1),t.directionalLight2=new THREE.DirectionalLight(16777215,t.light2),t.directionalLight3=new THREE.DirectionalLight(16777215,t.light3),t.cam_z>0?(t.directionalLight.position.set(-1,1,1),t.directionalLight2.position.set(1,1,1),t.directionalLight3.position.set(1,1,-1),t.lightPos=new THREE.Vector3(-1,1,1),t.lightPos2=new THREE.Vector3(1,1,1),t.lightPos3=new THREE.Vector3(1,1,-1)):(t.directionalLight.position.set(-1,1,-1),t.directionalLight2.position.set(1,1,-1),t.directionalLight3.position.set(1,1,1),t.lightPos=new THREE.Vector3(-1,1,-1),t.lightPos2=new THREE.Vector3(1,1,-1),t.lightPos3=new THREE.Vector3(1,1,1));let i=new THREE.AmbientLight(8947848);if(t.scene.add(t.directionalLight),t.scene.add(i),void 0!==t.mdl)for(let e=t.mdl.children.length-1;e>=0;e--){let s=t.mdl.children[e];s.geometry&&s.geometry.dispose(),s.material&&s.material.dispose(),t.mdl.remove(s)}if(void 0!==t.mdlImpostor){for(let e=t.mdlImpostor.children.length-1;e>=0;e--){let s=t.mdlImpostor.children[e];s.geometry&&s.geometry.dispose(),s.material&&s.material.dispose(),t.mdlImpostor.remove(s)}t.mdlImpostor.children.length=0}s.bNode||t.renderer.renderLists.dispose(),t.mdl=new THREE.Object3D,t.mdlImpostor=new THREE.Object3D,t.scene.add(t.mdl),t.scene.add(t.mdlImpostor),t.mdl_ghost=new THREE.Object3D,t.scene_ghost.add(t.mdl_ghost),t.objects=[],t.objects_ghost=[],t.raycaster=new THREE.Raycaster,t.projector=new THREE.Projector,t.mouse=new THREE.Vector2;let n=s.parasCls.backgroundColors[t.opts.background.toLowerCase()];s.bNode||("transparent"===t.opts.background.toLowerCase()?t.renderer.setClearColor(n,0):t.renderer.setClearColor(n,1)),t.perspectiveCamera=new THREE.PerspectiveCamera(20,t.container.whratio,.1,1e4),t.perspectiveCamera.position.set(0,0,t.cam_z),t.perspectiveCamera.lookAt(new THREE.Vector3(0,0,0)),t.orthographicCamera=new THREE.OrthographicCamera,t.orthographicCamera.position.set(0,0,t.cam_z),t.orthographicCamera.lookAt(new THREE.Vector3(0,0,0)),t.cams={perspective:t.perspectiveCamera,orthographic:t.orthographicCamera}}setVrAr(){let e=this.icn3d;e.icn3dui;let t=this;e.bSetVrAr=!0,e.bVr?(e.canvasUI=this.createUI(),e.raycasterVR=new THREE.Raycaster,e.workingMatrix=new THREE.Matrix4,e.workingVector=new THREE.Vector3,e.origin=new THREE.Vector3,e.dolly=new THREE.Object3D,e.dolly.position.z=5,e.dolly.add(e.cam),e.scene.add(e.dolly),e.dollyId=e.dolly.id,e.dummyCam=new THREE.Object3D,e.cam.add(e.dummyCam),e.clock=new THREE.Clock,e.controllers=this.getControllers(),e.controllers.forEach((s=>{s.addEventListener("connected",(function(e){try{const s={},i="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",n="generic-trigger";Ce(e.data,i,n).then((({profile:i,assetPath:n})=>{s.name=i.profileId,s.targetRayMode=e.data.targetRayMode,Object.entries(i.layouts).forEach((([e,t])=>{const i={};Object.values(t.components).forEach((e=>{i[e.rootNodeName]=e.gamepadIndices})),s[e]=i})),t.updateControllers(s)}))}catch(e){}})),s.addEventListener("disconnected",(function(){this.remove(this.children[0]),e.controllers.forEach((e=>{}))}))}))):e.bAr&&(e.gestures=new ke(e.renderer),e.scene.add(e.gestures.controller1),e.scene.add(e.gestures.controller2),e.gestures.addEventListener("doubletap",(e=>{t.positionCenter()})),e.gestures.addEventListener("pinch",(s=>{if(void 0!==s.initialise)t.startPosition=e.mdl.position.clone(),t.startScale=e.mdl.scale.clone();else{let i=1;const n=t.startScale.clone().multiplyScalar(s.scale*i);e.mdl.scale.copy(n)}})))}positionCenter(){let e=this.icn3d;e.icn3dui;const t=e.gestures.controller1;e.mdl.position.set(-.06,0,-.6).applyMatrix4(t.matrixWorld),e.mdl.scale.copy(new THREE.Vector3(.005,.005,.005))}setVrArButtons(){let e=this.icn3d,t=e.icn3dui;e.bSetVrArButtons=!0,t.bNode||($("#"+t.pre+"VRButton").remove(),$("#"+t.pre+"viewer").get(0).appendChild(e.VRButtonCls.createButton(e.renderer)),$("#"+t.pre+"ARButton").remove(),$("#"+t.pre+"viewer").get(0).appendChild(e.ARButtonCls.createButton(e.renderer)))}updateControllers(e){this.icn3d.icn3dui,this.addEventForController(e,"right"),this.addEventForController(e,"left")}addEventForController(e,t){let s=this.icn3d;s.icn3dui;const i="right"==t?s.renderer.xr.getController(0):s.renderer.xr.getController(1),n="right"==t?e.right:e.left;if(void 0!==n){let e=!1,t=!1;Object.keys(n).forEach((i=>{-1!=i.indexOf("trigger")&&(e=!0),-1!=i.indexOf("squeeze")&&(t=!0),-1==i.indexOf("thumbstick")&&-1==i.indexOf("touchpad")||(s.xAxisIndex=n[i].xAxis,s.yAxisIndex=n[i].yAxis)})),e&&(i.addEventListener("selectstart",(function(){this.userData.selectPressed=!0})),i.addEventListener("selectend",(function(){this.userData.selectPressed=!1,this.userData.selected=void 0}))),t&&(i.addEventListener("squeezestart",(function(){this.userData.squeezePressed=!0,s.cam.add(s.canvasUI.mesh)})),i.addEventListener("squeezeend",(function(){this.userData.squeezePressed=!1,s.cam.remove(s.canvasUI.mesh)})))}}createUI(){let e=this.icn3d;e.icn3dui;let t=94,s=50,i=44,n=12,l="#1c94c4",r="#ccc",o="#fbcb09";const a={panelSize:{width:2,height:1.2},height:300,select:{type:"button",position:{top:6,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},residue:{type:"button",position:{top:6,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.pk=2,e.cam.remove(e.canvasUI.mesh)}},secondarySelect:{type:"button",position:{top:6,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.pk=3,e.cam.remove(e.canvasUI.mesh)}},chainSelect:{type:"button",position:{top:6,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.pk=5,e.cam.remove(e.canvasUI.mesh)}},style:{type:"button",position:{top:62,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},ribbon:{type:"button",position:{top:62,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","ribbon"),e.setOptionCls.setStyle("nucleotides","nucleotide cartoon"),e.cam.remove(e.canvasUI.mesh)}},schematic:{type:"button",position:{top:62,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","schematic"),e.setOptionCls.setStyle("nucleotides","schematic"),e.cam.remove(e.canvasUI.mesh)}},stick:{type:"button",position:{top:62,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","stick"),e.setOptionCls.setStyle("nucleotides","stick"),e.cam.remove(e.canvasUI.mesh)}},sphere:{type:"button",position:{top:62,left:406},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","sphere"),e.setOptionCls.setStyle("nucleotides","sphere"),e.cam.remove(e.canvasUI.mesh)}},color:{type:"button",position:{top:118,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},rainbow:{type:"button",position:{top:118,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","rainbow for chains"),e.cam.remove(e.canvasUI.mesh)}},atomColor:{type:"button",position:{top:118,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","atom"),e.cam.remove(e.canvasUI.mesh)}},secondaryColor:{type:"button",position:{top:118,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","secondary structure green"),e.cam.remove(e.canvasUI.mesh)}},AlphaFold:{type:"button",position:{top:118,left:406},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","confidence"),e.cam.remove(e.canvasUI.mesh)}},unicolor:{type:"button",position:{top:174,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},red:{type:"button",position:{top:168,left:100},width:i,height:s,fontColor:"red",hover:o,onSelect:function(){e.setOptionCls.setOption("color","red"),e.cam.remove(e.canvasUI.mesh)}},green:{type:"button",position:{top:168,left:150},width:i,height:s,fontColor:"green",hover:o,onSelect:function(){e.setOptionCls.setOption("color","green"),e.cam.remove(e.canvasUI.mesh)}},blue:{type:"button",position:{top:168,left:200},width:i,height:s,fontColor:"blue",hover:o,onSelect:function(){e.setOptionCls.setOption("color","blue"),e.cam.remove(e.canvasUI.mesh)}},magenta:{type:"button",position:{top:168,left:250},width:i,height:s,fontColor:"magenta",hover:o,onSelect:function(){e.setOptionCls.setOption("color","magenta"),e.cam.remove(e.canvasUI.mesh)}},orange:{type:"button",position:{top:168,left:300},width:i,height:s,fontColor:"orange",hover:o,onSelect:function(){e.setOptionCls.setOption("color","FFA500"),e.cam.remove(e.canvasUI.mesh)}},cyan:{type:"button",position:{top:168,left:350},width:i,height:s,fontColor:"cyan",hover:o,onSelect:function(){e.setOptionCls.setOption("color","cyan"),e.cam.remove(e.canvasUI.mesh)}},gray:{type:"button",position:{top:168,left:400},width:i,height:s,fontColor:"gray",hover:o,onSelect:function(){e.setOptionCls.setOption("color","888888"),e.cam.remove(e.canvasUI.mesh)}},white:{type:"button",position:{top:168,left:450},width:i,height:s,fontColor:"white",hover:o,onSelect:function(){e.setOptionCls.setOption("color","white"),e.cam.remove(e.canvasUI.mesh)}},analysis:{type:"button",position:{top:230,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},interaction:{type:"button",position:{top:230,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){try{e.viewInterPairsCls.viewInteractionPairs(["selected"],["non-selected"],!1,"3d",1,1,1,1,1,1),e.cam.remove(e.canvasUI.mesh)}catch(e){}}},removeLabel:{type:"button",position:{top:230,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){for(let t in e.labels)e.labels[t]=[];e.drawCls.draw(),e.cam.remove(e.canvasUI.mesh)}},reset:{type:"button",position:{top:230,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.selectionCls.resetAll(),e.cam.remove(e.canvasUI.mesh)}},renderer:e.renderer},d=new Oe({select:"Select",residue:"Residue",secondarySelect:"SSE",chainSelect:"Chain",style:"Style",ribbon:"Ribbon",schematic:"Schem.",stick:"Stick",sphere:"Sphere",color:"Color",rainbow:"Rainbow",atomColor:"Atom",secondaryColor:"SSE",AlphaFold:"AlphaFold",unicolor:"UniColor",red:"M 50 15 L 15 15 L 15 50 L 50 50 Z",green:"M 50 15 L 15 15 L 15 50 L 50 50 Z",blue:"M 50 15 L 15 15 L 15 50 L 50 50 Z",magenta:"M 50 15 L 15 15 L 15 50 L 50 50 Z",orange:"M 50 15 L 15 15 L 15 50 L 50 50 Z",cyan:"M 50 15 L 15 15 L 15 50 L 50 50 Z",gray:"M 50 15 L 15 15 L 15 50 L 50 50 Z",white:"M 50 15 L 15 15 L 15 50 L 50 50 Z",analysis:"Analysis",interaction:"Interact",removeLabel:"No Label",reset:"Reset"},a);return d.mesh.position.set(0,0,-3),d}createUILog(){let e=this.icn3d;e.icn3dui;const t={panelSize:{width:2,height:2},height:512,info:{type:"text",overflow:"scroll",position:{top:6,left:6},width:506,height:506,backgroundColor:"#aaa",fontColor:"#000"},renderer:e.renderer},s=new Oe({info:"Debug info"},t);return s.mesh.position.set(0,-1,-2),s}getControllers(){let e=this.icn3d;e.icn3dui;const t=new xe,s=(new THREE.BufferGeometry).setFromPoints([new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,-1)]),i=new THREE.Line(s);i.name="line",i.scale.z=50;const n=[];for(let s=0;s<=1;s++){const l=e.renderer.xr.getController(s);e.dolly.add(l),l.add(i.clone()),l.userData.selectPressed=!1,e.cam.add(l),n.push(l);const r=e.renderer.xr.getControllerGrip(s);r.add(t.createControllerModel(r)),e.scene.add(r)}return n}}class Ie{constructor(e){this.icn3d=e}setCamera(){let e=this.icn3d,t=e.icn3dui;if(e.bControlGl&&!t.bNode){window.cam=e.cams[e.opts.camera.toLowerCase()];let s=e.maxD;if(window.cam===e.perspectiveCamera){let i=void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>e.maxatomcnt;i?window.camMaxDFactor=1:void 0!==window.camMaxDFactorFog?window.camMaxDFactor=window.camMaxDFactorFog:window.camMaxDFactor=3,window.cam_z>0?window.cam.position.z=s*window.camMaxDFactor:window.cam.position.z=-s*window.camMaxDFactor,"yes"===e.opts.slab?i?window.cam.near=.1:void 0!==window.camMaxDFactorFog?window.cam.near=s*window.camMaxDFactorFog-10:window.cam.near=s*window.camMaxDFactor:window.cam.near=.1,window.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.TrackballControls(window.cam,void 0,e):t.bNode?e.controls=new THREE.TrackballControls(e.cam,document,e):e.controls=new THREE.TrackballControls(e.cam,document.getElementById(e.id),e)}else window.cam===e.orthographicCamera&&(void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>10*e.maxatomcnt?window.cam.right=e.maxD/2*1.5:window.cam.right=e.maxD/2*2.5,window.cam.left=-window.cam.right,window.cam.top=window.cam.right/e.container.whratio,window.cam.bottom=-window.cam.right/e.container.whratio,"yes"===e.opts.slab?window.cam.near=2*e.maxD:window.cam.near=0,window.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.OrthographicTrackballControls(window.cam,void 0,e):t.bNode?e.controls=new THREE.OrthographicTrackballControls(e.cam,document,e):e.controls=new THREE.OrthographicTrackballControls(e.cam,document.getElementById(e.id),e));window.cam.updateProjectionMatrix()}e.cam=e.cams[e.opts.camera.toLowerCase()];let s=e.maxD;if(e.cam===e.perspectiveCamera){let i=void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>e.maxatomcnt;i?e.camMaxDFactor=1:void 0!==e.camMaxDFactorFog?e.camMaxDFactor=e.camMaxDFactorFog:e.camMaxDFactor=3,e.cam_z>0?e.cam.position.z=s*e.camMaxDFactor:e.cam.position.z=-s*e.camMaxDFactor,"yes"===e.opts.slab?i?e.cam.near=.1:void 0!==e.camMaxDFactorFog?e.cam.near=s*e.camMaxDFactorFog-10:e.cam.near=s*e.camMaxDFactor:e.cam.near=.1,e.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.TrackballControls(e.cam,void 0,e):t.bNode?e.controls=new THREE.TrackballControls(e.cam,document,e):e.controls=new THREE.TrackballControls(e.cam,document.getElementById(e.id),e)}else e.cam===e.orthographicCamera&&(void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>10*e.maxatomcnt?e.cam.right=e.maxD/2*1.5:e.cam.right=e.maxD/2*2.5,e.cam.left=-e.cam.right,e.cam.top=e.cam.right/e.container.whratio,e.cam.bottom=-e.cam.right/e.container.whratio,"yes"===e.opts.slab?e.cam.near=2*e.maxD:e.cam.near=0,e.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.OrthographicTrackballControls(e.cam,void 0,e):t.bNode?e.controls=new THREE.OrthographicTrackballControls(e.cam,document,e):e.controls=new THREE.OrthographicTrackballControls(e.cam,document.getElementById(e.id),e));e.cam.updateProjectionMatrix()}}class Te{constructor(e){this.icn3d=e}setFog(e){let t=this.icn3d,s=t.icn3dui.parasCls.backgroundColors[t.opts.background.toLowerCase()];if(e){let e=t.applyCenterCls.centerAtoms(t.hAtoms);t.maxD=e.maxD,t.maxD<25&&(t.maxD=25)}let i=void 0!==t.biomtMatrices&&t.biomtMatrices.length*t.cnt>t.maxatomcnt;if("yes"===t.opts.fog)if("perspective"===t.opts.camera)if(i)t.scene.fog=void 0,t.bSetFog=!1;else{let e=t._zoomFactor>1?1*t._zoomFactor:t._zoomFactor;t.scene.fog=new THREE.Fog(s,2.5*t.maxD*e,4*t.maxD*e),t.bSetFog=!0,t.camMaxDFactorFog=3}else"orthographic"===t.opts.camera&&(t.scene.fog=void 0,t.bSetFog=!1);else t.scene.fog=void 0,t.bSetFog=!1}}class Me{constructor(e){this.icn3d=e}createBox(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(o.bNode)return;void 0===t&&(t=.8),void 0===s&&(s=!1),void 0===i&&(i=.8),l?void 0===n&&(n=r.hColor):void 0===n&&(n=e.color);let a=s?t:(o.parasCls.vdwRadii[e.elem.toUpperCase()]||t)*(i||1);this.createBox_base(e.coord,a,n,l)}createBox_base(e,t,s,i,n,l,r){let o,a=this.icn3d;a.icn3dui.bNode||(void 0===r&&(r=l?.5:1),new THREE.BoxGeometry(1,1,1),o=new THREE.Mesh(a.boxGeometry,new THREE.MeshPhongMaterial({transparent:!0,opacity:r,specular:a.frac,shininess:a.shininess,emissive:a.emissive,color:s})),o.scale.x=o.scale.y=o.scale.z=t,o.position.copy(e),a.mdl.add(o),i?a.prevHighlightObjects.push(o):n?a.prevOtherMesh.push(o):a.objects.push(o))}createBoxRepresentation_P_CA(e,t,s){let i=this.icn3d;if(i.icn3dui.bNode)return;let n=this;i.reprSubCls.createRepresentationSub(e,(function(e){"CA"!==e.name&&"O3'"!==e.name&&"O3*"!==e.name||n.createBox(e,void 0,void 0,t,void 0,s)}))}}class Pe{constructor(e){this.icn3d=e}createBrick(e,t,s,i){let n=this.icn3d;if(n.icn3dui.bNode)return;let l=new THREE.CylinderGeometry(1,1,1,4,1),r=new THREE.Mesh(l,new THREE.MeshPhongMaterial({specular:n.frac,shininess:n.shininess,emissive:n.emissive,color:i}));r.position.copy(e).add(t).multiplyScalar(.5),r.matrixAutoUpdate=!1,r.lookAt(t.clone().sub(e)),r.updateMatrix(),r.matrix.multiply((new THREE.Matrix4).makeScale(s,s,e.distanceTo(t))).multiply((new THREE.Matrix4).makeRotationX(.5*Math.PI)),n.mdl.add(r)}}class De{constructor(e){this.icn3d=e}createCurveSubArrow(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u){if(this.icn3d.icn3dui.bNode)return;let g=[],f=[];g.push(e),f.push(o),this.prepareStrand(g,f,t,s,i,void 0,n,l,r,a,d,!1,c,h,p,m,u),g=[],f=[]}createStripArrow(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g){if(this.icn3d.icn3dui.bNode)return;let f=[],b=[];f.push(e),f.push(t),b.push(o),b.push(a),this.prepareStrand(f,b,void 0,s,i,n,l,void 0,r,d,c,!0,h,p,m,u,g),f=[],b=[]}prepareStrand(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g,f){let b=this.icn3d,C=b.icn3dui;if(1===d.length)return;let y=i,v=!u,w=[];w.push(i[i.length-2]),w.push(i[i.length-1]),n=n||b.axisDIV;let _,S,A,x,k=2/(a-1),O={};for(let e=0,s=t.length;e1)if(void 0!==d){let i,n,l=[];for(let r=0,o=p.length;r0&&i.tubeCls.createTube(a,"CA",i.coilWidth,s),Object.keys(d).length>0&&i.strandCls.createStrand(d,void 0,void 0,!0,0,i.helixSheetWidth,!1,2*i.ribbonthickness,s)):(Object.keys(a).length>0&&i.tubeCls.createTube(a,"CA",i.coilWidth),Object.keys(d).length>0&&i.strandCls.createStrand(d,void 0,void 0,!0,0,i.helixSheetWidth,!1,2*i.ribbonthickness))}createCylinderCurve(e,t,s,i,n){let l=this.icn3d;if(l.icn3dui.bNode)return;let r,o,a,d,c,h,p=null;for(a in e)if(d=e[a],!d.het&&(c=d.structure+"_"+d.chain,h=d.structure+"_"+r,-1!=t.indexOf(d.name))){if(null!==p&&r===d.chain&&l.ParserUtilsCls.getResiNCBI(h,o)+1===l.ParserUtilsCls.getResiNCBI(c,d.resi)&&Math.abs(p.coord.x-d.coord.x)<8&&Math.abs(p.coord.y-d.coord.y)<8&&Math.abs(p.coord.z-d.coord.z)<8){let e=p.coord.clone().add(d.coord).multiplyScalar(.5);if(n)1===n&&(this.createCylinder(p.coord,e,s,p.color,n),this.createCylinder(e,d.coord,s,d.color,n),l.sphereCls.createSphere(d,s,!0,1,n));else if(i){let t=l.lineCls.createSingleLine(p.coord,e,p.color,!1);l.mdl.add(t),l.objects.push(t),t=l.lineCls.createSingleLine(e,d.coord,d.color,!1),l.mdl.add(t),l.objects.push(t)}else this.createCylinder(p.coord,e,s,p.color),this.createCylinder(e,d.coord,s,d.color),l.sphereCls.createSphere(d,s,!0,1,n)}p=d,r=d.chain,o=d.resi,l.sphereCls.createSphere(d,s,!0,1,n),2===n&&l.boxCls.createBox(d,void 0,void 0,void 0,void 0,n)}if(null!==p&&r===d.chain&&l.ParserUtilsCls.getResiNCBI(h,o)+1===l.ParserUtilsCls.getResiNCBI(c,d.resi)&&Math.abs(p.coord.x-d.coord.x)<8&&Math.abs(p.coord.y-d.coord.y)<8&&Math.abs(p.coord.z-d.coord.z)<8){let e=p.coord.add(d.coord).multiplyScalar(.5);if(n)1===n&&(this.createCylinder(p.coord,e,s,p.color,n),this.createCylinder(e,d.coord,s,d.color,n),l.sphereCls.createSphere(d,s,!0,1,n));else if(i){let t=l.lineCls.createSingleLine(p.coord,e,p.color,!1);l.mdl.add(t),l.objects.push(t),t=l.lineCls.createSingleLine(e,d.coord,d.color,!1),l.mdl.add(t),l.objects.push(t)}else this.createCylinder(p.coord,e,s,p.color),this.createCylinder(e,d.coord,s,d.color)}}}class Le{constructor(e){this.icn3d=e}createLineRepresentation(e,t){let s=this.icn3d;if(s.icn3dui.bNode)return;let i=new THREE.BufferGeometry,n=[],l=[],r=0,o=0;s.reprSubCls.createRepresentationSub(e,void 0,(function(e,t){if(e.color===t.color)n[r++]=e.coord.x,n[r++]=e.coord.y,n[r++]=e.coord.z,n[r++]=t.coord.x,n[r++]=t.coord.y,n[r++]=t.coord.z,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b;else{let s=e.coord.clone().add(t.coord).multiplyScalar(.5);n[r++]=e.coord.x,n[r++]=e.coord.y,n[r++]=e.coord.z,n[r++]=s.x,n[r++]=s.y,n[r++]=s.z,n[r++]=t.coord.x,n[r++]=t.coord.y,n[r++]=t.coord.z,n[r++]=s.x,n[r++]=s.y,n[r++]=s.z,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b}}));if(i.setAttribute("position",new THREE.BufferAttribute(new Float32Array(n),3)),i.setAttribute("color",new THREE.BufferAttribute(new Float32Array(l),3)),2!==t){let e;1===t||(e=new THREE.LineSegments(i,new THREE.LineBasicMaterial({linewidth:s.linewidth,vertexColors:!0})),s.mdl.add(e)),1===t?s.prevHighlightObjects.push(e):s.objects.push(e)}else 2===t&&s.boxCls.createBoxRepresentation_P_CA(e,.8,t)}createConnCalphSidechain(e,t){let s=this.icn3d;if(s.icn3dui.bNode)return;let i={};for(let s in e){let n=e[s];if(!n.het&&n.style2===t){i[n.structure+"_"+n.chain+"_"+n.resi]=1}}let n=[],l=[];for(let e in i){let t=s.firstAtomObjCls.getFirstAtomObjByName(s.residues[e],"CA");if(void 0!==t)for(let e=0,i=t.bonds.length;e=t.bonds.length&&e.bonds.length>1)s=e.serial,l=e.bonds[0],d=e.bonds[1];else{if(!(t.bonds.length>=e.bonds.length&&t.bonds.length>1))return void console.log("Double bond was not drawn due to the undefined cross plane");s=t.serial,l=t.bonds[0],d=t.bonds[1]}let i=r.atoms[s].coord.clone();i.sub(r.atoms[l].coord);let n=r.atoms[s].coord.clone();n.sub(r.atoms[d].coord),i.cross(n),0==parseInt(1e4*i.length())&&(i=new THREE.Vector3(.2,.3,.5)),c=t.coord.clone(),c.sub(e.coord),c.cross(i).normalize().multiplyScalar(.2*o),0==parseInt(1e4*c.length())&&(i=new THREE.Vector3(.5,.3,.2),c.cross(i).normalize().multiplyScalar(.2*o))}e.color===t.color?r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),t.coord.clone().add(c),a,e.color,n),r.cylinderCls.createCylinder(e.coord.clone().sub(c),t.coord.clone().sub(c),a,e.color,n)):r.bImpo?r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),t.coord.clone().add(c),a,e.color,n,t.color),r.cylinderCls.createCylinder(e.coord.clone().sub(c),t.coord.clone().sub(c),a,e.color,n,t.color)):r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),i.clone().add(c),a,e.color,n),r.cylinderCls.createCylinder(t.coord.clone().add(c),i.clone().add(c),a,t.color,n),r.cylinderCls.createCylinder(e.coord.clone().sub(c),i.clone().sub(c),a,e.color,n),r.cylinderCls.createCylinder(t.coord.clone().sub(c),i.clone().sub(c),a,t.color,n))}else if(r.aromaticbonds.hasOwnProperty(l)){let s,l,d;if(e.bonds.length>t.bonds.length&&e.bonds.length>1)s=e.serial,l=e.bonds[0],d=e.bonds[1];else{if(!(t.bonds.length>1))return;s=t.serial,l=t.bonds[0],d=t.bonds[1]}let c=r.atoms[s].coord.clone();c.sub(r.atoms[l].coord);let h=r.atoms[s].coord.clone();h.sub(r.atoms[d].coord),c.cross(h);let p=t.coord.clone();p.sub(e.coord),p.cross(c).normalize().multiplyScalar(.2*o);let m=0;for(let s=0,i=e.bondOrder.length;so+1?(s=k.clone(),i=d.atoms[G[G.length-1-o-1]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random()))):d.bCalphaOnly&&"CA"===b.name&&(G.length>o+1?(s=k.clone(),i=d.atoms[G[G.length-1-o-1]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random())),s.normalize(),s.multiplyScalar(f),null!==E&&s.dot(E)<0&&s.negate(),E=s;for(let e=0,s=2/(t-1);e6||c&&Math.abs(S.y-c.y)>6||c&&Math.abs(S.z-c.z)>6;if((u!==b.chain||b.ssbegin||b.ssend||B===j-1||p)&&m[0].length>0){let c="CA",u=[],g=[];if(isNaN(d.atoms[P].resi))u=[];else{let e=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)-1).toString(),t=d.firstAtomObjCls.getAtomCoordFromResi(e,c);u=void 0!==t?[t]:[]}if(!isNaN(d.atoms[P].resi)){let e=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)+1).toString(),t=d.firstAtomObjCls.getAtomCoordFromResi(e,c);void 0!==t&&g.push(t);let s=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)+2).toString(),i=d.firstAtomObjCls.getAtomCoordFromResi(s,c);void 0!==i&&g.push(i)}if(!p){1===a||2===a?_.push(d.hColor):_.push(R),f=b.ssend&&"sheet"===b.ss?0:"coil"===I&&b.ssbegin||T&&b.ssbegin||"coil"===b.ss?n:l;let s,i,o=4;"O"===b.name?(s=A.clone(),s.sub(S)):d.bCalphaOnly&&"CA"===b.name&&(G.length>o?(s=S.clone(),i=d.atoms[G[G.length-1-o]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random())),s.normalize(),s.multiplyScalar(f),null!==E&&s.dot(E)<0&&s.negate(),E=s;for(let e=0,s=2/(t-1);e0){let e="CA",n=[],l=[];if(isNaN(d.atoms[P].resi))n=[];else{let t=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)-1).toString();d.firstAtomObjCls.getAtomCoordFromResi(t,e)}for(let e=0;!i&&e0;--e){let t=a.structure+"_"+a.chain+"_"+e;if(!c.residues.hasOwnProperty(t))break;let s=c.firstAtomObjCls.getFirstCalphaAtomObj(c.residues[t]);if(s.ss===a.ss&&s.ssbegin){g=s.resi;break}}for(let e=g;e0&&(o!==c.chain||Math.abs(c.coord.x-h.coord.x)>6||Math.abs(c.coord.y-h.coord.y)>6||Math.abs(c.coord.z-h.coord.z)>6||r.ParserUtilsCls.getResiNCBI(c.structure+"_"+o,a)+13||Math.abs(c.coord.y-h.coord.y)>3||Math.abs(c.coord.z-h.coord.z)>3))){if(2!==i){if(!isNaN(d.resi)&&!isNaN(h.resi)){let e=d.structure+"_"+d.chain+"_"+(parseInt(d.resi)-1).toString(),i=r.firstAtomObjCls.getAtomCoordFromResi(e,t);g=void 0!==i?[i]:[];let l=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+1).toString(),o=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+2).toString(),a=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+3).toString();if(r.residues.hasOwnProperty(l)){let e=r.firstAtomObjCls.getAtomFromResi(l,t);void 0!==e&&e.ssbegin&&(l=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+2).toString(),o=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+3).toString(),p.push(e.coord),n?u.push(this.getCustomtubesize(l)):u.push(this.getRadius(s,e)),m.push(e.color))}if(1==p.length&&r.residues.hasOwnProperty(l)){let e=r.firstAtomObjCls.getAtomFromResi(l,t);if(e){p.push(e.coord),m.push(e.color);let t=this.getRadius(s,c);u.push(t),l=o,o=a}}let b=r.firstAtomObjCls.getAtomCoordFromResi(l,t);void 0!==b&&f.push(b);let C=r.firstAtomObjCls.getAtomCoordFromResi(o,t);void 0!==C&&f.push(C)}C.push({pnts:p,colors:m,radii:u,prevone:g,nexttwo:f})}p=[],m=[],u=[],g=[],f=[],d=c,b=0}if(0==p.length&&!isNaN(c.resi)){let e=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)-1).toString();r.residues.hasOwnProperty(e)&&(h=r.firstAtomObjCls.getAtomFromResi(e,t),void 0!==h&&h.ssend&&(p.push(h.coord),n?u.push(this.getCustomtubesize(e)):u.push(this.getRadius(s,h)),m.push(h.color)))}let e;p.push(c.coord),e=n?this.getCustomtubesize(c.structure+"_"+c.chain+"_"+c.resi):this.getRadius(s,c),u.push(e),m.push(c.color),1===b&&(m[m.length-2]=c.color),o=c.chain,a=c.resi;let l=1.2;2!==i||c.ssbegin||r.boxCls.createBox(c,void 0,void 0,l,void 0,i),++b,h=c}if(2!==i){if(g=[],void 0!==d&&!isNaN(d.resi)){let e=d.structure+"_"+d.chain+"_"+(parseInt(d.resi)-1).toString(),s=r.firstAtomObjCls.getAtomCoordFromResi(e,t);g=void 0!==s?[s]:[]}if(f=[],void 0!==c&&!isNaN(c.resi)){let e=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+1).toString(),i=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+2).toString(),n=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+3).toString();if(1==p.length&&r.residues.hasOwnProperty(e)){let l=r.firstAtomObjCls.getAtomFromResi(e,t);if(l){p.push(l.coord),m.push(l.color);let t=this.getRadius(s,c);u.push(t),e=i,i=n}}let l=r.firstAtomObjCls.getAtomCoordFromResi(e,t);void 0!==l&&f.push(l);let o=r.firstAtomObjCls.getAtomCoordFromResi(i,t);void 0!==o&&f.push(o)}C.push({pnts:p,colors:m,radii:u,prevone:g,nexttwo:f})}for(let e=0,t=C.length;e1?a.parasCls.thr(t[t.length-2]):a.parasCls.thr(t[e]),f[y++]=d.r,f[y++]=d.g,f[y++]=d.b}}let x,k=0;for(let e=0,t=_.length-1;er&&(l=r,e=1);for(let t=0;t0&&t.b<=100?.01*t.b:t.b>100?1:s.coilWidth),i}}class ze{constructor(e){this.icn3d=e}drawCartoonNucleicAcid(e,t,s,i){this.drawStrandNucleicAcid(e,2,t,!0,void 0,s,i)}drawStrandNucleicAcid(e,t,s,i,n,l,r){let o,a,d,c=this.icn3d;if(c.icn3dui.bNode)return;2===r&&(t=void 0,l=void 0),n=n||c.nucleicAcidWidth,s=s||c.axisDIV,t=t||c.nucleicAcidStrandDIV;let h=[];for(d=0;dy?y=C:C=y);let v=.8*b/y;if(g.width=C,g.height=y,f.clearRect(0,0,C,y),h)if(f.fillStyle="rgba("+n.r+","+n.g+","+n.b+","+n.a+")",f.strokeStyle="rgba("+l.r+","+l.g+","+l.b+","+l.a+")",f.lineWidth=r,p){let e=.4*C;this.circle(f,0,0,C,y,e)}else{let e=0;this.roundRect(f,0,0,C,y,e)}f.font="Bold "+a+"px "+o,f.textAlign="center",f.textBaseline="middle",f.fillStyle="rgba("+u.r+", "+u.g+", "+u.b+", 1.0)",f.strokeStyle="rgba("+u.r+", "+u.g+", "+u.b+", 1.0)",f.fillText(e,.5*C,.5*y);let w=new THREE.Texture(g);w.needsUpdate=!0;let _=new THREE.SpriteMaterial({map:w,depthTest:!1,depthWrite:!1});_.map.minFilter=THREE.LinearFilter;let S=new THREE.Sprite(_);return p?S.scale.set(.3*d,.3*d,1):S.scale.set(v*d,d,1),S}roundRect(e,t,s,i,n,l){e.beginPath(),e.moveTo(t+l,s),e.lineTo(t+i-l,s),e.quadraticCurveTo(t+i,s,t+i,s+l),e.lineTo(t+i,s+n-l),e.quadraticCurveTo(t+i,s+n,t+i-l,s+n),e.lineTo(t+l,s+n),e.quadraticCurveTo(t,s+n,t,s+n-l),e.lineTo(t,s+l),e.quadraticCurveTo(t,s,t+l,s),e.closePath(),e.fill(),e.stroke()}circle(e,t,s,i,n,l){e.beginPath(),e.arc(t+i/2,.9*(s+n/2),l,0,2*Math.PI,!0),e.closePath(),e.fill(),e.stroke()}}class Ve{constructor(e){this.icn3d=e,this.textSpriteCls=new Ge(e)}createLabelRepresentation(e){let t=this.icn3d;t.icn3dui;let s=t.oriMaxD/100;s<.4&&(s=.4);let i=3*s*t.labelScale;for(let s in e){let n=void 0!==e[s]?e[s]:[],l="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd;for(let e=0,r=n.length;e.99999)h.set(0,0,0,1);else if(e.y<-.99999)h.set(1,0,0,0);else{let t=new THREE.Vector3;t.set(e.z,0,-e.x).normalize();let s=Math.acos(e.y);h.setFromAxisAngle(t,s)}return c.applyQuaternion(h),c.scale.set(l,n,l),c.position.copy(t),c}setPc1Axes(){let e=this.icn3d,t=e.icn3dui;if(t.bNode)return;let s=t.hashUtilsCls.intHash(e.hAtoms,e.dAtoms),i=[],n=Object.keys(s).length<100;for(let t in s){let s=e.atoms[t],l=s.structure+"_"+s.chain+"_"+s.resi;(n||""!=l)&&i.push(s.coord.clone())}let l=t.rmsdSuprCls.getEigenForSelection(i,i.length),r=new THREE.Vector3(l.h1[0],l.h1[1],l.h1[2]);if(0==l.k&&e.bRender)return void alert("Can't determine the first principal component. Please select a subset and try it again.");let o=e.applyCenterCls.centerAtoms(s),a=o.maxD,d=o.center,c=d.clone().add(r.normalize().multiplyScalar(.4*a)),h=new THREE.Vector3(l.h2[0],l.h2[1],l.h2[2]),p=d.clone().add(h.normalize().multiplyScalar(.3*a)),m=new THREE.Vector3(l.h3[0],l.h3[1],l.h3[2]),u=d.clone().add(m.normalize().multiplyScalar(.3*a));this.buildAxes(void 0,d,c,p,u,!0);let g=[d,c,p,u];return e.axes.push(g),e.drawCls.draw(),g}}class Ye{constructor(e){this.icn3d=e}showGlycans(){let e=this.icn3d,t=e.icn3dui;if(t.bNode)return;let s={},i=e.dAtoms;for(let n in i){let i=e.atoms[n];i.het&&-1!=t.parasCls.glycanHash.hasOwnProperty(i.resn)&&(void 0===s[i.resn]&&(s[i.resn]={}),"Misc"!=i.chain&&(s[i.resn][i.structure+"_"+i.chain+"_"+i.resi]=1))}let n=Object.keys(s);for(let i=0,l=n.length;i>2))+i+((2&t)>>1))*c+n+(1&t)]&this.ISDONE)<=3&&(t.push(t[i]),i=t.length-1,t.push(t[n]),n=t.length-1,t.push(t[l]),l=t.length-1),s.push(i),s.push(n),s.push(l)}}},Xe.prototype.laplacianSmooth=function(e,t,s){let i,n,l,r,o,a=new Array(t.length);for(i=0,n=t.length;ithis.origextent[1][0])&&(!(tthis.origextent[1][1])&&!(sthis.origextent[1][2]))},Ke.prototype.getFacesAndVertices=function(){let e,t,s=this.verts;for(e=0,t=s.length;eh&&(h=this.pmaxy-this.pminy),this.pmaxz-this.pminz>h&&(h=this.pmaxz-this.pminz),this.scaleFactor=(c-1)/h,this.scaleFactor=this.defaultScaleFactor,(this.bCalcArea||this.defaultScaleFactor*h>this.threshbox)&&(c=Math.floor(this.threshbox),this.scaleFactor=(this.threshbox-1)/h),this.pLength=Math.ceil(this.scaleFactor*(this.pmaxx-this.pminx))+1,this.pWidth=Math.ceil(this.scaleFactor*(this.pmaxy-this.pminy))+1,this.pHeight=Math.ceil(this.scaleFactor*(this.pmaxz-this.pminz))+1,this.finalScaleFactor.x=(this.pLength-1)/(this.pmaxx-this.pminx),this.finalScaleFactor.y=(this.pWidth-1)/(this.pmaxy-this.pminy),this.finalScaleFactor.z=(this.pHeight-1)/(this.pmaxz-this.pminz),this.boundingatom(t),this.cutRadius=this.probeRadius*this.scaleFactor,this.vpBits=new Uint8Array(this.pLength*this.pWidth*this.pHeight),this.vpDistance=new Float64Array(this.pLength*this.pWidth*this.pHeight),this.vpAtomID=new Int32Array(this.pLength*this.pWidth*this.pHeight),this.vpColor=[],this.vpPot=[]},Ke.prototype.boundingatom=function(e){let t,s,i,n,l=[];for(let r in this.vdwRadii){if(!this.vdwRadii.hasOwnProperty(r))continue;let o=this.vdwRadii[r];l[r]=e?(o+this.probeRadius)*this.scaleFactor+.5:o*this.scaleFactor+.5,i=l[r]*l[r],this.widxz[r]=Math.floor(l[r])+1,this.depty[r]=new Int32Array(this.widxz[r]*this.widxz[r]),n=0;for(let e=0;ei?this.depty[r][n]=-1:(s=Math.sqrt(i-t),this.depty[r][n]=Math.floor(s)),n++}},Ke.prototype.fillvoxels=function(e,t){let s,i,n,l;for(s=0,l=this.vpBits.length;sc&&(a=c),C>h&&(C=h),v>p&&(v=p);let w,_=g[o*m+d*u+y],S=g[a*m+d*u+y],A=g[o*m+C*u+y],x=g[o*m+d*u+v],k=g[a*m+C*u+y],O=g[o*m+C*u+v],R=g[a*m+d*u+v],E=g[a*m+C*u+v],I=r.x-o,T=r.y-d,M=r.z-y,P=((_*(1-I)+S*I)*(1-T)+(A*(1-I)+k*I)*T)*(1-M)+((x*(1-I)+R*I)*(1-T)+(O*(1-I)+E*I)*T)*M,D=s*f+i*b+n;this.vpPot[D]=P,P>this.isovalue&&(P=this.isovalue),P<-this.isovalue&&(P=-this.isovalue),P>0?(P/=1*this.isovalue,w=new THREE.Color(1-P,1-P,1)):(P/=-1*this.isovalue,w=new THREE.Color(1,1-P,1-P)),this.vpColor[D]=w}}for(s=0,l=this.vpBits.length;s=this.pLength||g>=this.pWidth||f>=this.pHeight)continue;let h=u*S+g*this.pHeight+f;if(this.vpBits[h]&this.INOUT){let p=t[this.vpAtomID[h]];p.serial!=e.serial&&(l=s+a-Math.floor(.5+this.scaleFactor*(p.x+this.ptranx)),r=i+d-Math.floor(.5+this.scaleFactor*(p.y+this.ptrany)),o=n+c-Math.floor(.5+this.scaleFactor*(p.z+this.ptranz)),a*a+d*d+c*c=this.pLength||p>=this.pWidth||m>=this.pHeight)continue;let u=h*S+p*this.pHeight+m;if(this.vpBits[u]&this.ISDONE){let h=t[this.vpAtomID[u]];h.serial!=e.serial&&(l=s+a-Math.floor(.5+this.scaleFactor*(h.x+this.ptranx)),r=i+d-Math.floor(.5+this.scaleFactor*(h.y+this.ptrany)),o=n+c-Math.floor(.5+this.scaleFactor*(h.z+this.ptranz)),a*a+d*d+c*c-1&&r-1&&a-1&&o=h)||(this.vpBits[n]|=this.ISBOUND))},Ke.prototype.fastoneshell=function(e,t){let s,i,n,l,r,o,a,d,c,h,p,m,u=[];if(0===e.length)return u;let g={ix:-1,iy:-1,iz:-1},f=this.pWidth*this.pHeight;for(a=0,c=e.length;a-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,h-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,h-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,hm&&(m=this.pmaxy-this.pminy),this.pmaxz-this.pminz>m&&(m=this.pmaxz-this.pminz),this.scaleFactor=1,this.pLength=Math.floor(.5+this.scaleFactor*(this.pmaxx-this.pminx))+1,this.pWidth=Math.floor(.5+this.scaleFactor*(this.pmaxy-this.pminy))+1,this.pHeight=Math.floor(.5+this.scaleFactor*(this.pmaxz-this.pminz))+1,this.cutRadius=this.probeRadius*this.scaleFactor,this.vpBits=new Uint8Array(this.pLength*this.pWidth*this.pHeight),this.vpAtomID=new Uint8Array(this.pLength*this.pWidth*this.pHeight)},Qe.prototype.transformMemPro=function(e,t,s,i){let n=e.clone();n.sub(s);let l=n.x*t[0]+n.y*t[1]+n.z*t[2]+i.x,r=n.x*t[3]+n.y*t[4]+n.z*t[5]+i.y,o=n.x*t[6]+n.y*t[7]+n.z*t[8]+i.z;return n.x=l,n.y=r,n.z=o,n},Qe.prototype.fillvoxels=function(e,t){let s,i,n,l,r,o;for(s=0,l=this.vpBits.length;sthis.pLength&&(o=this.pLength),p>this.pWidth&&(p=this.pWidth),b>this.pHeight&&(b=this.pHeight);let C,y=l[r*a+h*d+f],v=l[o*a+h*d+f],w=l[r*a+p*d+f],_=l[r*a+h*d+b],S=l[o*a+p*d+f],A=l[r*a+p*d+b],x=l[o*a+h*d+b],k=l[o*a+p*d+b],O=n.x-r,R=n.y-h,E=n.z-f,I=((y*(1-O)+v*O)*(1-R)+(w*(1-O)+S*O)*R)*(1-E)+((_*(1-O)+x*O)*(1-R)+(A*(1-O)+k*O)*R)*E;I>this.isovalue&&(I=this.isovalue),I<-this.isovalue&&(I=-this.isovalue),I>0?(I/=1*this.isovalue,C=new THREE.Color(1-I,1-I,1)):(I/=-1*this.isovalue,C=new THREE.Color(1,1-I,1-I)),this.icn3d.atoms[t[s]].color=C,this.icn3d.atomPrevColors[t[s]]=C}}else{for(let p in t){let f,b=e[t[p]];if("DUM"!==b.resn){if(void 0!==this.rmsd_supr&&void 0!==this.rmsd_supr.rot){f=this.transformMemPro(b.coord,g,u,m).applyMatrix4(c)}else f=b.coord.clone().applyMatrix4(c);for(s=Math.floor(f.x)-this.maxdist,l=Math.ceil(f.x)+this.maxdist;s<=l;++s)if(!(s<0||s>this.header.xExtent*this.scaleFactor-1))for(i=Math.floor(f.y)-this.maxdist,r=Math.ceil(f.y)+this.maxdist;i<=r;++i)if(!(i<0||i>this.header.yExtent*this.scaleFactor-1))for(n=Math.floor(f.z)-this.maxdist,o=Math.ceil(f.z)+this.maxdist;n<=o;++n){if(n<0||n>this.header.zExtent*this.scaleFactor-1)continue;let e=s*a+i*d+n;h.push(e)}}}for(s=0,l=h.length;s=this.isovalue?1:0:"fofc"==this.type?(this.vpBits[e]=this.dataArray[e]>=this.isovalue||this.dataArray[e]<=-this.isovalue?1:0,this.vpAtomID[e]=this.dataArray[e]>=0?1:0):"em"==this.type&&(this.vpBits[e]=this.dataArray[e]>=this.isovalue?1:0)}}}else for(s=0;s=this.isovalue||this.dataArray[e]<=-this.isovalue?1:0,this.vpAtomID[t]=this.dataArray[e]>=0?1:0)}for(s=0,l=this.vpBits.length;s-1&&r-1&&a-1&&o1?"Structure":"",a=Object.keys(i).length>1?"Chain":"";n+=""+o+a+"ResidueNumberSASA (Å2)Percent OutIn/Out";for(let e in l.resid2area){let d=e.lastIndexOf("_"),c=e.substr(d+1),h=r.utilsCls.getIdArray(e.substr(0,d));o=Object.keys(s).length>1?""+h[0]+"":"",a=Object.keys(i).length>1?""+h[1]+"":"";let p="",m="";l.resid2area[e]=(l.resid2area[e]/t).toFixed(2),r.parasCls.residueArea.hasOwnProperty(c)&&(m=parseInt(l.resid2area[e]/r.parasCls.residueArea[c]*100),m>100&&(m=100),m>=50&&(p="out"),m<20&&(p="in")),n+=''+o+a+""+c+''+h[2]+''+l.resid2area[e]+''+m+"%"+p+""}return n+="",void(l.areahtml=n)}let p,m,u,g=c.vertices,f=c.faces,b=r.parasCls.thr("#00FFFF"),C=r.parasCls.thr("#00FF00"),y=r.parasCls.thr("#ff0000"),v=r.parasCls.thr("#00FFFF"),w=r.parasCls.thr("#0000FF"),_=r.parasCls.thr("#FF0000");11!=t&&12!=t&&13!=t&&14!=t||void 0===l.rmsd_supr||void 0===l.rmsd_supr.rot||(p=l.rmsd_supr.rot,m=l.rmsd_supr.trans1,u=l.rmsd_supr.trans2);let S=(11==t||12==t||13==t||14==t&&"delphi"!=l.loadPhiFrom)&&void 0!==l.rmsd_supr&&void 0!==l.rmsd_supr.rot;n=new THREE.BufferGeometry;let A,x=[],k=[],O=[],R=0;for(let e=0,s=g.length;e0?-parseInt(C.z):parseInt(C.z),y.onBeforeRender=function(e,t,s,i,n,o){let a,d=new THREE.Vector3(0,0,0),c=i.getAttribute("position").array;for(let e=0,t=c.length;e0?-parseInt(a.z):parseInt(a.z)},l.mdl.add(y),11==t||12==t?l.prevMaps.push(y):13==t?l.prevEmmaps.push(y):14==t?l.prevPhimaps.push(y):l.prevSurfaces.push(y)}}else{let e=new THREE.Mesh(n,new THREE.MeshPhongMaterial({specular:l.frac,shininess:20,emissive:l.emissive,vertexColors:THREE.VertexColors,wireframe:s,opacity:i,transparent:!0,depthWrite:10==parseInt(10*i),side:THREE.DoubleSide}));e.renderOrder=-2,l.mdl.add(e),11==t||12==t?l.prevMaps.push(e):13==t?l.prevEmmaps.push(e):14==t?l.prevPhimaps.push(e):l.prevSurfaces.push(e)}c=null,g=null,f=null,n=null}transformMemPro(e,t,s,i,n){this.icn3d.icn3dui;let l=e.clone();l.sub(s),n&&console.log("sub coord: "+JSON.stringify(l));let r=l.x*t[0]+l.y*t[1]+l.z*t[2]+i.x,o=l.x*t[3]+l.y*t[4]+l.z*t[5]+i.y,a=l.x*t[6]+l.y*t[7]+l.z*t[8]+i.z;return l.x=r,l.y=o,l.z=a,n&&console.log("out coord: "+JSON.stringify(l)),l}SetupSurface(e){let t=this.icn3d;t.icn3dui;let s=e.threshbox,i=new Ke(t,s);i.initparm(e.extent,1!==e.type,e.bCalcArea,e.atomsToShow,e.header,e.data,e.matrix,e.isovalue,e.loadPhiFrom),i.fillvoxels(e.allatoms,e.extendedAtoms),i.buildboundary(),2===e.type&&(i.fastdistancemap(),i.boundingatom(!1),i.fillvoxelswaals(e.allatoms,e.extendedAtoms));let n=i.marchingcube();i.vpBits=null,i.vpDistance=null,i.vpAtomID=null;let l=i.getFacesAndVertices(e.atomsToShow);return l.area=n.area,l.serial2area=n.serial2area,l.scaleFactor=n.scaleFactor,i.faces=null,i.verts=null,l}SetupMap(e){let t=this.icn3d;t.icn3dui;let s,i=new Qe(t);return i.initparm(e.header,e.data,e.matrix,e.isovalue,e.center,e.maxdist,e.pmin,e.pmax,e.water,e.type,e.rmsd_supr,e.loadPhiFrom,e.icn3d),i.fillvoxels(e.allatoms,e.extendedAtoms),e.header.bSurface||i.buildboundary(),e.header.bSurface||i.marchingcube(),i.vpBits=null,i.vpAtomID=null,e.header.bSurface||(s=i.getFacesAndVertices(e.allatoms,e.atomsToShow)),i.faces=null,i.verts=null,s}}class Ze{constructor(e){this.icn3d=e}applyCenterOptions(e){let t,s=this.icn3d;switch(s.icn3dui,void 0===e&&(e=s.opts),e.rotationcenter.toLowerCase()){case"molecule center":void 0!==s.center&&this.setRotationCenter(s.center);break;case"pick center":void 0!==s.pAtom&&this.setRotationCenter(s.pAtom.coord);break;case"display center":t=this.centerAtoms(s.dAtoms).center,this.setRotationCenter(t);break;case"highlight center":t=this.centerAtoms(s.hAtoms).center,this.setRotationCenter(t)}}setRotationCenter(e){this.icn3d.icn3dui,this.setCenter(e)}setCenter(e){let t=this.icn3d;t.icn3dui,t.mdl.position.set(0,0,0),t.mdlImpostor.position.set(0,0,0),t.mdl_ghost.position.set(0,0,0),t.mdl.position.sub(e),t.mdlImpostor.position.sub(e),t.mdl_ghost.position.sub(e)}centerSelection(e,t){let s=this.icn3d,i=s.icn3dui;if(s.opts.rotationcenter="highlight center",void 0===e&&(e=i.hashUtilsCls.hash2Atoms(s.hAtoms,s.atoms)),t||(s._zoomFactor=1,s.mouseChange=new THREE.Vector2(0,0),s.quaternion=new THREE.Quaternion(0,0,0,1)),Object.keys(e).length>1){let t=this.centerAtoms(e);s.center=t.center,this.setCenter(s.center),s.cameraCls.setCamera()}}centerAtoms(e){let t=this.icn3d;t.icn3dui;let s=new THREE.Vector3(9999,9999,9999),i=new THREE.Vector3(-9999,-9999,-9999),n=new THREE.Vector3;for(let l in e){let e=t.atoms[l].coord;n.add(e),s.min(e),i.max(e)}let l=t.ParserUtilsCls.getGeoCenter(s,i);return{center:l,maxD:t.ParserUtilsCls.getStructureSize(e,s,i,l),pmin:s,pmax:i}}setWidthHeight(e,t){let s=this.icn3d;s.icn3dui,void 0===s.scaleFactor&&(s.scaleFactor=1),s.renderer.setSize(e*s.scaleFactor,t*s.scaleFactor),s.renderer.domElement.style.width=e*s.scaleFactor+"px",s.renderer.domElement.style.height=t*s.scaleFactor+"px",s.renderer.domElement.width=e*s.scaleFactor,s.renderer.domElement.height=t*s.scaleFactor,s.container.whratio=e/t}}class et{constructor(e){this.icn3d=e}applyClbondsOptions(e){let t=this.icn3d,s=t.icn3dui;if(void 0===e&&(e=t.opts),t.bCalcCrossLink||(t.clbondpnts={},t.clbondResid2serial={},this.applyClbondsOptions_base("chemical"),this.applyClbondsOptions_base("all"),t.bCalcCrossLink=!0),"yes"===e.clbonds.toLowerCase()&&"nothing"!==e.chemicals){let e="#006400",i=s.parasCls.thr(25600);if(t.lines.clbond=[],t.residuesHashClbonds={},t.structures){let n=Object.keys(t.structures);for(let l=0,r=n.length;l1&&"sphere"!==a[Object.keys(a)[0]].style&&"dot"!==a[Object.keys(a)[0]].style){if(void 0===i.bCid||!i.bCid)for(let e in a){let t=a[e],n=1;i.boxCls.createBox(t,void 0,void 0,n,void 0,s)}}else for(let e in o){let l=i.firstAtomObjCls.getFirstCalphaAtomObj(i.residues[e]),r=l,o=r.structure+"_"+r.chain+"_"+(parseInt(r.resi)-1).toString(),a=r.structure+"_"+r.chain+"_"+(parseInt(r.resi)+1).toString();if("cylinder and plate"===r.style&&"helix"===r.ss)for(let t in i.residues[e]){let e=i.atoms[t],n=1;i.boxCls.createBox(e,void 0,void 0,n,void 0,s)}else if("ribbon"===r.style&&"coil"===r.ss||"strand"===r.style&&"coil"===r.ss||"o3 trace"===r.style||"schematic"===r.style||"c alpha trace"===r.style||"b factor tube"===r.style||"cylinder and plate"===r.style&&"helix"!==r.ss){if(void 0!==l&&void 0!==l.style2&&"nothing"!==l.style2)continue;let e=!1;if(!isNaN(r.resi)&&!e&&i.residues.hasOwnProperty(a)){let s=Object.keys(i.residues[a])[0],l=n.hashUtilsCls.hash2Atoms(i.residues[a],i.atoms)[s];if(r.style===l.style&&!l.ssbegin||l.ssbegin){let s=i.residues[a];if(t=n.hashUtilsCls.unionHash(t,s),e=!0,l.ssbegin)for(let e in s)i.atoms[e].notshow=!0}}if(!isNaN(r.resi)&&!e&&i.residues.hasOwnProperty(o)){let s=Object.keys(i.residues[o])[0],l=n.hashUtilsCls.hash2Atoms(i.residues[o],i.atoms)[s];r.style===l.style&&(t=n.hashUtilsCls.unionHash(t,i.residues[o]),e=!0)}}else if("ribbon"===r.style&&"coil"!==r.ss&&r.ssend||"strand"===r.style&&"coil"!==r.ss&&r.ssend){if(void 0!==l&&void 0!==l.style2&&"nothing"!==l.style2)continue;let e=!1;if(!isNaN(r.resi)&&!e&&i.residues.hasOwnProperty(a)){let s=Object.keys(i.residues[a])[0];n.hashUtilsCls.hash2Atoms(i.residues[a],i.atoms)[s],t=n.hashUtilsCls.unionHash(t,i.residues[a]),e=!0}}}a={}}if(i.bInitial){if(""!=n.htmlCls.setHtmlCls.getCookie("membrane")){let e=parseInt(n.htmlCls.setHtmlCls.getCookie("membrane"));i.bMembrane!=e&&n.htmlCls.clickMenuCls.setLogCmd("set membrane "+e,!0),i.bMembrane=isNaN(e)?0:parseInt(e)}i.bMembrane?i.selectionCls.toggleMembrane(!0):i.selectionCls.toggleMembrane(!1)}i.setStyleCls.setStyle2Atoms(t);let d=.5*i.cylinderRadius;void 0!==i.labels&&delete i.labels.schematic;for(let e in i.style2atoms){let t=i.style2atoms[e],l=n.hashUtilsCls.intHash(t,i.nucleotides),r=n.utilsCls.isCalphaPhosOnly(n.hashUtilsCls.hash2Atoms(l,i.atoms));if("ribbon"===e)i.strandCls.createStrand(n.hashUtilsCls.hash2Atoms(t,i.atoms),2,void 0,!0,void 0,void 0,!1,i.ribbonthickness,s);else if("strand"===e)i.strandCls.createStrand(n.hashUtilsCls.hash2Atoms(t,i.atoms),null,null,null,null,null,!1,void 0,s);else if("cylinder and plate"===e)i.cylinderCls.createCylinderHelix(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderHelixRadius,s);else if("nucleotide cartoon"===e)r?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["P"],i.traceRadius,!1,s):(i.cartoonNuclCls.drawCartoonNucleicAcid(n.hashUtilsCls.hash2Atoms(t,i.atoms),null,i.ribbonthickness,s),2!==s&&i.cartoonNuclCls.drawNucleicAcidStick(n.hashUtilsCls.hash2Atoms(t,i.atoms),s));else if("o3 trace"===e)r?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["P"],i.traceRadius,!1,s):i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["O3'","O3*"],i.traceRadius,!1,s);else if("schematic"===e){let e=i.firstAtomObjCls.getFirstAtomObj(t);if(i.chemicals.hasOwnProperty(e.serial)){i.residueLabelsCls.addNonCarbonAtomLabels(n.hashUtilsCls.hash2Atoms(t,i.atoms));let e=!0;i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),d,d,void 0,s,e)}else i.residueLabelsCls.addResidueLabels(n.hashUtilsCls.hash2Atoms(t,i.atoms),!0),r?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["P"],i.traceRadius,!1,s):i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["O3'","O3*"],i.traceRadius,!1,s),i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["CA"],i.traceRadius,!1,s)}else"c alpha trace"===e?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["CA"],i.traceRadius,!1,s):"b factor tube"===e?i.tubeCls.createTube(n.hashUtilsCls.hash2Atoms(t,i.atoms),"CA",null,s,!1,!0):"custom tube"===e?i.tubeCls.createTube(n.hashUtilsCls.hash2Atoms(t,i.atoms),"CA",null,s,!0,!0):"lines"===e||"lines2"===e?(1===s?i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.hlLineRadius,i.hlLineRadius,void 0,s):i.lineCls.createLineRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),s),i.lineCls.createConnCalphSidechain(n.hashUtilsCls.hash2Atoms(t,i.atoms),e)):"stick"===e||"stick2"===e?(i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderRadius,i.cylinderRadius,void 0,s,void 0),i.lineCls.createConnCalphSidechain(n.hashUtilsCls.hash2Atoms(t,i.atoms),e)):"backbone"===e?(t=this.selectMainChainSubset(t),i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderRadius,i.cylinderRadius,void 0,s,void 0)):"ball and stick"===e||"ball and stick2"===e?(i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderRadius,.5*i.cylinderRadius,i.dotSphereScale,s,void 0),i.lineCls.createConnCalphSidechain(n.hashUtilsCls.hash2Atoms(t,i.atoms),e)):"sphere"===e||"sphere2"===e?i.sphereCls.createSphereRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.sphereRadius,void 0,void 0,s):"dot"===e&&i.sphereCls.createSphereRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.sphereRadius,!1,i.dotSphereScale,s)}if(i.cnt>i.maxmaxatomcnt&&i.init_base(),void 0!==i.labels&&Object.keys(i.labels).length>0){i.labelCls.hideLabels();for(let e in i.labels)"schematic"!=e&&this.changeLabelColor(i.labels[e]);i.labelCls.createLabelRepresentation(i.labels)}}changeLabelColor(e){let t=this.icn3d;if(t.icn3dui,e)for(let s=0,i=e.length;s0){this.updateStabilizer();let e="#FFFFFF",s=t.stabilizerpnts;t.lines.stabilizer=[];for(let i=0,n=Math.floor(s.length/2);i0)for(let e=0,s=t.distPnts.length;e0&&t.applySymdCls.applySymd(),void 0!==t.prevOtherMesh)for(let e=0,s=t.prevOtherMesh.length;e0&&(e=s.hashUtilsCls.hash2Atoms(t.chemicals,t.atoms));let i=4;if(void 0!==e){let n=t.contactCls.getAtomsWithinAtom(t.atoms,e,i),l=3.5;t.opts.hbonds="yes",Object.keys(n).length>0&&t.hBondCls.calculateChemicalHbonds(e,n,parseFloat(l)),t.bSetFog||t.transformCls.zoominSelection(s.hashUtilsCls.unionHash(e,n))}}else"hide"===e.chemicalbinding&&(t.hBondCls.hideHbonds(),t.bSetFog||t.transformCls.zoominSelection(t.atoms))}updateStabilizer(){let e=this.icn3d;if(e.icn3dui,e.stabilizerpnts=[],void 0!==e.pairArray)for(let t=0,s=e.pairArray.length;t=0;i--){let r=t.ssbondpnts[e][2*i],o=t.ssbondpnts[e][2*i+1],a={};a.color=n,a.dashed=!0;let d=[],c=[],h=[],p=[],m=!1,u=!1;for(let e in t.residues[r])"SG"===t.atoms[e].name&&(h.push(t.atoms[e].coord),d.push(t.atoms[e].serial),m=!0);if(!m)for(let e in t.residues[r])if("CA"===t.atoms[e].name){h.push(t.atoms[e].coord),d.push(t.atoms[e].serial),m=!0,u=!0;break}m=!1;for(let e in t.residues[o])"SG"===t.atoms[e].name&&(p.push(t.atoms[e].coord),c.push(t.atoms[e].serial),m=!0);if(!m)for(let e in t.residues[o])if("CA"===t.atoms[e].name){p.push(t.atoms[e].coord),c.push(t.atoms[e].serial),m=!0,u=!0;break}let g=u?7:3,f=!1;for(let e=0,t=h.length;e1&&(l=!0)}if(t)if(l){let t=Object.keys(r)[0];e=i.chains[t]}else{0==Object.keys(i.hAtoms).length&&(i.hAtoms=n.hashUtilsCls.cloneHash(i.dAtoms));let t,s=parseInt(Object.keys(i.hAtoms).length/u),l=0;for(let n in i.hAtoms)if(e[n]=1,t=n,++l,l>s)break;let r=i.atoms[t].structure+"_"+i.atoms[t].chain+"_"+i.atoms[t].resi;e=n.hashUtilsCls.unionHash(e,i.residues[r])}else{let t=Object.keys(i.structures)[0]+"_"+g;if(i.chains.hasOwnProperty(t)||(t=Object.keys(i.structures)[0]+"_"+g.toLowerCase()),!i.chains.hasOwnProperty(t)){t=Object.keys(i.chains)[0];for(let e in i.chains){let s=Object.keys(i.chains[e])[0];if(i.proteins.hasOwnProperty(s)){t=e;break}}}e=i.chains[t]}let a=s.clone().add(h).multiplyScalar(.5),c=new THREE.Vector3,p=0,f=h.clone().sub(s).normalize(),b=new THREE.Vector3(0,0,1),C=new THREE.Quaternion;C.setFromUnitVectors(f,b);let y=-9999;for(let t in e){let e=i.atoms[t].coord.clone();c.add(e),e.sub(a).applyQuaternion(C);let s=e.x*e.x+e.y*e.y;s>y&&(y=s),++p}let v=i.ParserUtilsCls.getMassCenter(c,p),w=new THREE.Line3(s,h),_=new THREE.Vector3;w.closestPointToPoint(v,!0,_);let S,A,x,k,O=Math.sqrt(y),R=v.clone().sub(_).normalize().multiplyScalar(O),E=a.clone().add(s.clone().sub(a).multiplyScalar(.83)).add(R),I=a.clone().add(h.clone().sub(a).multiplyScalar(.83)).add(R),T=2*Math.PI/o;for(let e=0;et&&(i.sphereCls.createSphereBase(r,colorPolygon,d,1,0),i.cylinderCls.createCylinder(e,r,d,colorPolygon,0),i.cylinderCls.createCylinder(s,r,d,colorPolygon,0),void 0!==n&&i.cylinderCls.createCylinder(c[n],r,d,colorPolygon,0),n=l)}}else if("O"==r)for(let e=0,t=c.length;e0&&(e.mdl.remove(e.prevSurfaces[e.prevSurfaces.length-1]),e.prevSurfaces.slice(e.prevSurfaces.length-1,1))}removeMaps(){let e=this.icn3d;e.icn3dui;for(let t=0,s=e.prevMaps.length;t0&&(e.mdl.remove(e.prevMaps[e.prevMaps.length-1]),e.prevMaps.slice(e.prevMaps.length-1,1))}removeLastEmmap(){let e=this.icn3d;e.icn3dui,e.prevEmmaps.length>0&&(e.mdl.remove(e.prevEmmaps[e.prevEmmaps.length-1]),e.prevEmmaps.slice(e.prevEmmaps.length-1,1))}removeLastPhimap(){let e=this.icn3d;e.icn3dui,e.prevPhimaps.length>0&&(e.mdl.remove(e.prevPhimaps[e.prevPhimaps.length-1]),e.prevPhimaps.slice(e.prevPhimaps.length-1,1))}}class rt{constructor(e){this.icn3d=e}addResidueLabels(e,t,s,i){let n=this.icn3d,l=n.icn3dui;if(l.bNode)return;let r=l.hashUtilsCls.intHash(n.hAtoms,e);t?void 0===n.labels.schematic&&(n.labels.schematic=[]):void 0===n.labels.residue&&(n.labels.residue=[]);let o="";for(let e in r){let s=n.atoms[e],r={},a=s.structure+"_"+s.chain+"_"+s.resi;if(!s.het&&("CA"===s.name||"O3'"===s.name||"O3*"===s.name)||n.water.hasOwnProperty(s.serial)||n.ions.hasOwnProperty(s.serial)||n.chemicals.hasOwnProperty(s.serial)&&a!==o){r.position=s.coord,r.bSchematic=0,t&&(r.bSchematic=1),r.text=l.utilsCls.residueName2Abbr(s.resn),i&&(r.text+=s.resi),r.size=18,r.factor=.3;let e=s.color.getHexString().toUpperCase();r.color=i?"black"!=n.opts.background?n.colorWhitebkgd:n.colorBlackbkgd:"CCCCCC"===e||"C8C8C8"===e?"#888888":"#"+e,r.background="#FFFFFF",t?n.labels.schematic.push(r):n.labels.residue.push(r)}o=a}n.hlObjectsCls.removeHlObjects()}addNonCarbonAtomLabels(e){let t=this.icn3d,s=t.icn3dui;if(s.bNode)return;let i=s.hashUtilsCls.intHash(t.hAtoms,e);void 0===t.labels.schematic&&(t.labels.schematic=[]);for(let e in i){let s=t.atoms[e];if(!t.residues.hasOwnProperty(s.structure+"_"+s.chain+"_"+s.resi))continue;if("C"===s.elem)continue;let i={};i.position=s.coord,i.bSchematic=1,i.text=s.elem,i.size=18,i.color="black"!=t.opts.background?t.colorWhitebkgd:s.color.getHexString(),i.background="#FFFFFF",t.labels.schematic.push(i)}t.hlObjectsCls.removeHlObjects()}addAtomLabels(e,t){let s=this.icn3d,i=s.icn3dui;if(i.bNode)return;let n=i.hashUtilsCls.intHash(s.hAtoms,e);n=i.hashUtilsCls.intHash(s.dAtoms,n),void 0===s.labels.residue&&(s.labels.residue=[]);for(let e in n){let i=s.atoms[e],n={};n.position=i.coord,n.bSchematic=0,n.text=t?i.elem:i.name.padEnd(2," "),n.size=18,t&&(n.bSchematic=!0);let l=i.color.getHexString().toUpperCase();n.color="black"!=s.opts.background?s.colorWhitebkgd:s.colorBlackbkgd,t&&(n.color="CCCCCC"===l||"C8C8C8"===l?"#888888":"#"+l),n.background="#FFFFFF",s.labels.residue.push(n)}s.hlObjectsCls.removeHlObjects()}}class ot{constructor(e){this.icn3d=e}onBeforeRender(e,t,s,i,n,l){let r=n.uniforms,o=[];if(r.objectId&&(r.objectId.value=SupportsReadPixelsFloat?this.id:this.id/255,o.push("objectId")),(r.modelViewMatrixInverse||r.modelViewMatrixInverseTranspose||r.modelViewProjectionMatrix||r.modelViewProjectionMatrixInverse)&&this.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,this.matrixWorld),r.modelViewMatrixInverse&&(r.modelViewMatrixInverse.value.copy(this.modelViewMatrix).invert(),o.push("modelViewMatrixInverse")),r.modelViewMatrixInverseTranspose&&(r.modelViewMatrixInverse?r.modelViewMatrixInverseTranspose.value.copy(r.modelViewMatrixInverse.value).transpose():r.modelViewMatrixInverseTranspose.value.copy(this.modelViewMatrix).invert().transpose(),o.push("modelViewMatrixInverseTranspose")),r.modelViewProjectionMatrix&&(s.updateProjectionMatrix(),r.modelViewProjectionMatrix.value.multiplyMatrices(s.projectionMatrix,this.modelViewMatrix),o.push("modelViewProjectionMatrix")),r.modelViewProjectionMatrixInverse){let e=new THREE.Matrix4;r.modelViewProjectionMatrix?(e.copy(r.modelViewProjectionMatrix.value),r.modelViewProjectionMatrixInverse.value.copy(e).invert()):(s.updateProjectionMatrix(),e.multiplyMatrices(s.projectionMatrix,this.modelViewMatrix),r.modelViewProjectionMatrixInverse.value.copy(e).invert()),o.push("modelViewProjectionMatrixInverse")}if(r.projectionMatrix&&(s.updateProjectionMatrix(),r.projectionMatrix.value.copy(s.projectionMatrix),o.push("projectionMatrix")),r.projectionMatrixInverse&&(s.updateProjectionMatrix(),r.projectionMatrixInverse.value.copy(s.projectionMatrix).invert(),o.push("projectionMatrixInverse")),o.length){let t=e.properties.get(n);if(t.program){let s=e.getContext(),i=t.program;s.useProgram(i.program);let n=i.getUniforms();o.forEach((function(e){n.setValue(s,e,r[e].value)}))}}}setParametersForShader(e){let t,s=this.icn3d,i=s.icn3dui.parasCls.backgroundColors[s.opts.background.toLowerCase()],n=2.5*s.maxD,l=4*s.maxD,r=void 0!==s.biomtMatrices&&s.biomtMatrices.length*s.cnt>s.maxatomcnt;"yes"===s.opts.slab?r?t=.1:void 0!==s.camMaxDFactorFog?(t=s.maxD*s.camMaxDFactorFog-10,n=2.5*s.maxD-t<0?0:2.5*s.maxD-t,l=4*s.maxD-t):t=s.maxD*s.camMaxDFactor:t=.1;let o=void 0!==e?e:1,a=s.shininess/100*.5;s.uniforms=THREE.UniformsUtils.merge([THREE.UniformsLib.common,{modelViewMatrix:{value:new THREE.Matrix4},modelViewMatrixInverse:{value:new THREE.Matrix4},modelViewMatrixInverseTranspose:{value:new THREE.Matrix4},modelViewProjectionMatrix:{value:new THREE.Matrix4},modelViewProjectionMatrixInverse:{value:new THREE.Matrix4},projectionMatrix:{value:new THREE.Matrix4},projectionMatrixInverse:{value:new THREE.Matrix4},diffuse:{type:"v3",value:[1,1,1]},emissive:{type:"v3",value:[.06,.06,.06]},roughness:{type:"f",value:.5},metalness:{type:"f",value:a},opacity:{type:"f",value:o},nearClip:{type:"f",value:t},ortho:{type:"f",value:0},shrink:{type:"f",value:.13},fogColor:{type:"v3",value:[i.r,i.g,i.b]},fogNear:{type:"f",value:n},fogFar:{type:"f",value:l},fogDensity:{type:"f",value:2}},THREE.UniformsLib.ambient,THREE.UniformsLib.lights]),s.defines={USE_COLOR:1,NEAR_CLIP:1,CAP:1},"yes"!==s.opts.fog||r||(s.defines.USE_FOG=1,"orthographic"===s.opts.camera&&(s.defines.FOG_EXP2=1)),s.bExtFragDepth&&(s.defines.USE_LOGDEPTHBUF_EXT=1)}drawImpostorShader(){this.icn3d.icn3dui.bNode||(this.setParametersForShader(),this.createImpostorShaderSphere("SphereImpostor"),this.createImpostorShaderCylinder("CylinderImpostor"))}getShader(e){this.icn3d.icn3dui;let t=$NGL_shaderTextHash[e];return t=t.replace(/#include\s+(\S+)/gim,(function(e,t){let s;return THREE.ShaderChunk.hasOwnProperty(t)&&(s=THREE.ShaderChunk[t]),s||""})),t}createImpostorShaderBase(e,t,s,i,n,l,r,o,a){let d=this.icn3d;d.icn3dui;let c=new THREE.ShaderMaterial({defines:d.defines,uniforms:d.uniforms,vertexShader:this.getShader(e+".vert"),fragmentShader:this.getShader(e+".frag"),depthTest:!0,depthWrite:!0,lights:!0});c.extensions.fragDepth=!0,"CylinderImpostor"==e?d.CylinderImpostorMaterial=c:"SphereImpostor"==e&&(d.SphereImpostorMaterial=c);let h,p,m=l*r,u=l*o,g=new(m>65535?Uint32Array:Uint16Array)(u);for(let e=0;e=0;t--){let s=a.children[t];s.onBeforeRender=e.impostorCls.onBeforeRender,s.frustumCulled=!1}l.add(a)}void 0!==e.mdl_ghost&&(a=e.mdl_ghost.clone(),this.applyMat(a,d),r.add(a));let c=e.center.clone();this.applyMat(c,d,!0),s.add(c),++t}e.mdl.add(n),e.mdlImpostor.add(l),e.mdl_ghost.add(r),void 0!==e.bSetInstancing&&e.bSetInstancing?(e.maxD=e.maxDAssembly,e.center=e.centerAssembly.clone(),e.applyCenterCls.setCenter(e.center),e.cameraCls.setCamera()):(e.maxD*=Math.sqrt(t),e.center=e.ParserUtilsCls.getMassCenter(s,t),e.maxDAssembly=e.maxD,e.centerAssembly=e.center.clone(),e.applyCenterCls.setCenter(e.center),e.cameraCls.setCamera()),e.bSetInstancing=!0}createInstancedGeometry(e){let t=this.icn3d,s=t.icn3dui,i=e.geometry,n=new THREE.InstancedBufferGeometry,l=[],r=[],o=[],a=[],d=[],c=[],h=[],p=[];if(t.bImpo&&"Cylinder"==e.type){t.instancedMaterial=this.getInstancedMaterial("CylinderInstancing");let e=s.hashUtilsCls.hashvalue2array(i.attributes.position1.array),r=s.hashUtilsCls.hashvalue2array(i.attributes.color.array),m=s.hashUtilsCls.hashvalue2array(i.attributes.position2.array),u=s.hashUtilsCls.hashvalue2array(i.attributes.color2.array),g=s.hashUtilsCls.hashvalue2array(i.index.array),f=s.hashUtilsCls.hashvalue2array(i.attributes.radius.array),b=s.hashUtilsCls.hashvalue2array(i.attributes.mapping.array);l=l.concat(e),o=o.concat(r),h=h.concat(m),p=p.concat(u),a=a.concat(g),d=d.concat(f),c=c.concat(b),n.setAttribute("position1",new THREE.BufferAttribute(new Float32Array(l),3)),n.setAttribute("color",new THREE.BufferAttribute(new Float32Array(o),3)),n.setAttribute("position2",new THREE.BufferAttribute(new Float32Array(h),3)),n.setAttribute("color2",new THREE.BufferAttribute(new Float32Array(p),3)),n.setAttribute("radius",new THREE.BufferAttribute(new Float32Array(d),1)),n.setAttribute("mapping",new THREE.BufferAttribute(new Float32Array(c),3)),n.setIndex(new THREE.BufferAttribute(new Uint32Array(a),1)),e=null,r=null,m=null,u=null,g=null,f=null,b=null}else if(t.bImpo&&"Sphere"==e.type){t.instancedMaterial=this.getInstancedMaterial("SphereInstancing");let e=s.hashUtilsCls.hashvalue2array(i.attributes.position.array),r=s.hashUtilsCls.hashvalue2array(i.attributes.color.array),h=s.hashUtilsCls.hashvalue2array(i.index.array),p=s.hashUtilsCls.hashvalue2array(i.attributes.radius.array),m=s.hashUtilsCls.hashvalue2array(i.attributes.mapping.array);l=l.concat(e),o=o.concat(r),a=a.concat(h),d=d.concat(p),c=c.concat(m),n.setAttribute("position",new THREE.BufferAttribute(new Float32Array(l),3)),n.setAttribute("color",new THREE.BufferAttribute(new Float32Array(o),3)),n.setAttribute("radius",new THREE.BufferAttribute(new Float32Array(d),1)),n.setAttribute("mapping",new THREE.BufferAttribute(new Float32Array(c),2)),n.setIndex(new THREE.BufferAttribute(new Uint32Array(a),1)),e=null,r=null,h=null,p=null,m=null}else{t.instancedMaterial=this.getInstancedMaterial("Instancing");let e=i.attributes.position?s.hashUtilsCls.hashvalue2array(i.attributes.position.array):[],d=i.attributes.normal?s.hashUtilsCls.hashvalue2array(i.attributes.normal.array):[],c=i.attributes.color?s.hashUtilsCls.hashvalue2array(i.attributes.color.array):[],h=i.index?s.hashUtilsCls.hashvalue2array(i.index.array):[];l=l.concat(e),r=r.concat(d),o=o.concat(c),a=a.concat(h);let p=[],m="CylinderGeometry"==i.type?1:0;for(let e=0,t=l.length/3;e0&&(e.dAtoms=t.hashUtilsCls.cloneHash(s)),e.bShowHighlight=!1}e.applyMapCls.removeSurfaces(),e.applyMapCls.applySurfaceOptions(),e.applyMapCls.removeMaps(),e.applyMapCls.applyMapOptions(),e.applyMapCls.removeEmmaps(),e.applyMapCls.applyEmmapOptions(),e.applyMapCls.removePhimaps(),e.axes=[],e.pc1&&e.axesCls.setPc1Axes(),e.drawCls.draw(),e.bShowHighlight=!0,e.opts.rotationcenter="molecule center"}alternateWrapper(){let e=this.icn3d;e.icn3dui,e.bAlternate=!0,this.alternateStructures(),e.bAlternate=!1}}class ct{constructor(e){this.icn3d=e}draw(e){let t=this.icn3d,s=t.icn3dui;if(!t.bRender||t.hAtoms&&0!=Object.keys(t.hAtoms)||(t.hAtoms=s.hashUtilsCls.cloneHash(t.atoms)),t.sceneCls.rebuildScene(),t.bImpo&&t.impostorCls.drawImpostorShader(),t.setColorCls.applyPrevColor(),void 0!==t.biomtMatrices&&t.biomtMatrices.length>1)if(t.bAssembly&&1==Object.keys(t.structures).length&&(void 0===s.cfg.mmdbid&&1==s.cfg.bu||void 0!==s.cfg.mmdbid&&1==s.cfg.bu&&Object.keys(t.atoms).length*t.biomtMatrices.length>t.maxatomcnt))t.instancingCls.drawSymmetryMates();else{let e=!0;t.applyCenterCls.centerSelection(void 0,e)}let i=void 0!==t.hAtoms?Object.keys(t.hAtoms).length:0;if(i>0&&i0){e.children[0].scale.z=t[0].distance,t[0].point.sub(r.mdl.position);let s=r.rayThreshold,i=r.rayCls.getAtomsFromPosition(t[0].point,s);for(;!i&&s<10;)s+=.5,i=r.rayCls.getAtomsFromPosition(t[0].point,s);i&&(r.pAtom=i,this.showPickingVr(r.pk,i))}}}}catch(e){}}showPickingVr(e,t){let s=this.icn3d;if(s.icn3dui,e||(e=2),1===e)s.hAtoms[t.serial]=1;else if(2===e){let e=t.structure+"_"+t.chain+"_"+t.resi;s.hAtoms=s.residues[e]}else if(3===e)s.hAtoms=s.pickingCls.selectStrandHelixFromAtom(t);else if(4===e)s.hAtoms=s.pickingCls.select3ddomainFromAtom(t);else if(5===e){let e=t.structure+"_"+t.chain;s.hAtoms=s.chains[e]}2===e?s.residueLabelsCls.addResidueLabels(s.hAtoms,void 0,void 0,!0):1===e&&s.residueLabelsCls.addAtomLabels(atoms),s.setOptionCls.setStyle("proteins",t.style)}render_base(){let e=this.icn3d,t=e.icn3dui,s=this;if(t.bNode)return;let i=e.bControlGl&&!t.bNode?window.cam:e.cam;if(e.directionalLight){let t=new THREE.Quaternion;t.setFromUnitVectors(new THREE.Vector3(0,0,e.cam_z).normalize(),i.position.clone().normalize()),e.directionalLight.position.copy(e.lightPos.clone().applyQuaternion(t).normalize()),e.directionalLight2.position.copy(e.lightPos2.clone().applyQuaternion(t).normalize()),e.directionalLight3.position.copy(e.lightPos3.clone().applyQuaternion(t).normalize())}if(e.bVr||e.renderer.setPixelRatio(window.devicePixelRatio),e.bVr){let t=.04;if(e.controllers){let i=this.updateGamepadState();for(let n=0,l=e.controllers.length;n{const i=e.gamepad.axes;let r=parseInt(1e3*i[t]),o=parseInt(-1e3*i[s]);n.push(r),l.push(o)})),{xArray:n,yArray:l}}return{xArray:[0,0],yArray:[0,0]}}}class ht{constructor(e){this.icn3d=e}getAtomsWithinAtom(e,t,s,i,n,l,r){let o=this.icn3d;o.icn3dui;let a=this.getNeighboringAtoms(e,t,s,r);i&&(o.resid2Residhash={});let d={};for(let e in t){let c,h,p=o.atoms[e],m=p.structure+"_"+p.chain+"_"+p.resi;for(let e in o.residues[m])if(o.atoms[e]&&("CA"===o.atoms[e].name&&"C"===o.atoms[e].elem||"O3'"===o.atoms[e].name||"O3*"===o.atoms[e].name)){c=o.atoms[e];break}void 0===c&&(c=p),i&&(h=p.resn+" $"+p.structure+"."+p.chain+":"+p.resi,void 0===o.resid2Residhash[h]&&(o.resid2Residhash[h]={}));let u=p.structure+"_"+p.chain+"_"+p.resi;for(let e in a){let m=a[e];if(!o.crossstrucinter&&p.structure!=m.structure)continue;if(!r&&m.serial in t)continue;if(o.bOpm&&"DUM"===m.resn)continue;let g=m.coord.distanceTo(p.coord);if(go?r:o,d=Math.sqrt(a),c=(d+s)*(d+s),h={};for(let r in e){let e=n.atoms[r];!i&&t.hasOwnProperty(e.serial)||(this.bOpm&&"DUM"===e.resn||e.coord.xl[1][0]+s||e.coord.yl[1][1]+s||e.coord.zl[1][2]+s||(e.coord.x-l[2][0])*(e.coord.x-l[2][0])+(e.coord.y-l[2][1])*(e.coord.y-l[2][1])+(e.coord.z-l[2][2])*(e.coord.z-l[2][2])e.coord.x?n:e.coord.x,l=l>e.coord.y?l:e.coord.y,r=r>e.coord.z?r:e.coord.z}return[[t,s,i],[n,l,r],[o/c,a/c,d/c]]}hideContact(){let e=this.icn3d;e.icn3dui,e.opts.contact="no",void 0===e.lines&&(e.lines={}),e.lines.contact=[],e.contactpnts=[];for(let t in e.atoms)e.atoms[t].style2="nothing";for(let t in e.sidec)e.hAtoms.hasOwnProperty(t)&&(e.atoms[t].style2=e.opts.sidec);for(let t in e.water)e.hAtoms.hasOwnProperty(t)&&(e.atoms[t].style=e.opts.water)}}class pt{constructor(e){this.icn3d=e}isHbondDonorAcceptor(e){let t=this.icn3d;if(t.icn3dui,"N"==e.name&&!e.het||"N"==e.elem&&"Arg"==e.resn||"N"==e.elem&&"Asn"==e.resn||"N"==e.elem&&"Gln"==e.resn||"N"==e.elem&&"Lys"==e.resn||"N"==e.elem&&"Trp"==e.resn)return"donor";if("O"==e.name&&!e.het||"S"==e.elem&&"Met"==e.resn||"O"==e.elem&&"Asn"==e.resn||"O"==e.elem&&"Asp"==e.resn||"O"==e.elem&&"Gln"==e.resn||"O"==e.elem&&"Glu"==e.resn)return"acceptor";if("S"==e.elem&&"Cys"==e.resn||"N"==e.elem&&"His"==e.resn||"O"==e.elem&&"Ser"==e.resn||"O"==e.elem&&"Thr"==e.resn||"O"==e.elem&&"Tyr"==e.resn)return"both";if("Pro"==e.resn)return"none";if("N"==e.elem){if("Asn"==e.resn||"Gln"==e.resn)return"both";let s=0,i=0;for(let i=0,n=e.bonds.length;i1?"ring":"donor":"none"}if("O"==e.elem&&1==e.bonds.length){if("Asn"==e.resn||"Gln"==e.resn)return"both";for(let s=0,i=e.bonds.length;s=2?"acceptor":"both"}if("O"==e.elem&&2==e.bonds.length){for(let s=0,i=e.bonds.length;s1);++t)"H"!=s.atoms[e.bonds[t]].elem&&(i=s.atoms[e.bonds[t]],l[r++].subVectors(s.atoms[e.bonds[t]].coord,e.coord));if(1===r)for(let t=0,n=i.bonds.length;t1);++t)"H"!=s.atoms[i.bonds[t]].elem&&s.atoms[i.bonds[t]].serial!=e.serial&&l[r++].subVectors(s.atoms[i.bonds[t]].coord,e.coord);if(2!==r)return;let o=l[0].cross(l[1]);return Math.abs(Math.PI/2-o.angleTo(n))}isValidHbond(e,t,s){let i=this.icn3d;i.icn3dui;let n,l,r=this.isHbondDonorAcceptor(e),o=this.isHbondDonorAcceptor(t),a=50*Math.PI/180,d=50*Math.PI/180,c=90*Math.PI/180,h=30*Math.PI/180;if("donor"==r&&("acceptor"==o||"both"==o||"ring"==o)||"acceptor"==o&&("donor"==r||"both"==r||"ring"==r))n=e,l=t;else if("acceptor"==r&&("donor"==o||"both"==o||"ring"==o)||"donor"==o&&("acceptor"==r||"both"==r||"ring"==r))l=e,n=t;else{if("both"!=r&&"ring"!=r||"both"!=o&&"ring"!=o)return!1;n=e,l=t,i.nucleotides.hasOwnProperty(e.serial)&&i.nucleotides.hasOwnProperty(t.serial)&&("ring"==r||"ring"==o)||(e.het||t.het)&&"ring"==r&&"ring"==o||(h=90*Math.PI/180)}let p=this.calcAngles(n,l),m=90*Math.PI/180;for(let e=0,t=p.length;ed)return!1;let u=this.calcPlaneAngle(n,l);if(void 0!==u&&u>h)return!1;let g=this.calcAngles(l,n),f=90*Math.PI/180;for(let e=0,t=g.length;ea)return!1;let b=this.calcPlaneAngle(l,n);return!(void 0!==b&&b>c)}calculateChemicalHbonds(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(0===Object.keys(e).length||0===Object.keys(t).length)return;r.resid2Residhash={};let a,d,c={},h=s*s;for(let t in e){let s=e[t],n=i?"LYS"===s.resn&&"N"===s.elem&&"N"!==s.name||"ARG"===s.resn&&("NH1"===s.name||"NH2"===s.name)||("GLU"===s.resn||"ASP"===s.resn)&&"O"===s.elem&&"O"!==s.name||s.het&&("N"===s.elem||"O"===s.elem||"S"===s.elem):"N"===s.elem||"O"===s.elem||"S"===s.elem&&(s.het||"Cys"===s.resn||"Met"===s.resn);n=r.bOpm?n&&"DUM"!==s.resn:n,n&&(a=s.structure+"_"+s.chain+"_"+s.resi,d=a+"_"+s.name,c[d]=s)}let p={},m={},u=.5,g=-27.888,f={};for(let e in t){let b=t[e],C=i?"LYS"===b.resn&&"N"===b.elem&&"N"!==b.name||"ARG"===b.resn&&("NH1"===b.name||"NH2"===b.name)||("GLU"===b.resn||"ASP"===b.resn)&&"O"===b.elem&&"O"!==b.name||b.het&&("N"===b.elem||"O"===b.elem||"S"===b.elem):"N"===b.elem||"O"===b.elem||"S"===b.elem&&(b.het||"Cys"===b.resn||"Met"===b.resn);if(C=r.bOpm?C&&"DUM"!==b.resn:C,C){a=b.structure+"_"+b.chain+"_"+b.resi,d=a+"_"+b.name;let e=b.resn+" $"+b.structure+"."+b.chain+":"+b.resi+"@"+b.name;void 0===r.resid2Residhash[e]&&(r.resid2Residhash[e]={});for(let t in c){if(i&&!(("LYS"!==b.resn&&"ARG"!==b.resn||"LYS"!==c[t].resn&&"ARG"!==c[t].resn)&&("GLU"!==b.resn&&"ASP"!==b.resn||"GLU"!==c[t].resn&&"ASP"!==c[t].resn)))continue;if(!r.crossstrucinter&&b.structure!=c[t].structure)continue;if(a==t.substr(0,t.lastIndexOf("_")))continue;let d=Math.abs(b.coord.x-c[t].coord.x);if(d>s)continue;let C=Math.abs(b.coord.y-c[t].coord.y);if(C>s)continue;let y=Math.abs(b.coord.z-c[t].coord.z);if(y>s)continue;let v=d*d+C*C+y*y;if(v>h)continue;if(!r.proteins.hasOwnProperty(b.serial)||!r.proteins.hasOwnProperty(c[t].serial)||"N"!==b.name&&"O"!==b.name||"O"!==c[t].name&&"N"!==c[t].name){if(!this.isValidHbond(b,c[t],s))continue}else{if(b.name===c[t].name)continue;if(b.structure==c[t].structure&&b.chain==c[t].chain&&Math.abs(b.resi-c[t].resi)<=1)continue;let e,i="N"===b.name?b:c[t],n="O"===b.name?b:c[t];if("Pro"===i.resn)continue;if(void 0===i.hcoord){if(!this.isValidHbond(b,c[t],s))continue}else{let s,l=i.hcoord,o=i.coord,a=n.structure+"_"+n.chain+"_"+n.resi;for(let e in r.residues[a])if("C"===r.atoms[e].name){s=r.atoms[e];break}if(!s)continue;let d=s.coord,h=n.coord,p=l.distanceTo(h),m=l.distanceTo(d),f=o.distanceTo(d),C=o.distanceTo(h);e=p2||f[c[t].serial]>2)continue;void 0===f[b.serial]?f[b.serial]=1:++f[b.serial],void 0===f[c[t].serial]?f[c[t].serial]=1:++f[c[t].serial],"graph"!==n&&(i?(r.saltbridgepnts.push({serial:b.serial,coord:b.coord}),r.saltbridgepnts.push({serial:c[t].serial,coord:c[t].coord})):(r.hbondpnts.push({serial:b.serial,coord:b.coord}),r.hbondpnts.push({serial:c[t].serial,coord:c[t].coord})));let w=c[t].structure+"_"+c[t].chain+"_"+c[t].resi;p=o.hashUtilsCls.unionHash(p,r.residues[a]),p=o.hashUtilsCls.unionHash(p,r.residues[w]),m[a]=1,m[w]=1;let _=c[t].resn+" $"+c[t].structure+"."+c[t].chain+":"+c[t].resi+"@"+c[t].name,S=a+"_"+b.resn+","+w+"_"+c[t].resn;void 0!==r.resids2interAll[S]&&void 0!==r.resids2interAll[S].ionic&&r.resids2interAll[S].ionic.hasOwnProperty(e+","+_)||(r.resid2Residhash[e][_]=v.toFixed(1),l||(void 0===r.resids2inter[S]&&(r.resids2inter[S]={}),void 0===r.resids2inter[S].hbond&&(r.resids2inter[S].hbond={}),r.resids2inter[S].hbond[e+","+_]=v.toFixed(1)),void 0===r.resids2interAll[S]&&(r.resids2interAll[S]={}),void 0===r.resids2interAll[S].hbond&&(r.resids2interAll[S].hbond={}),r.resids2interAll[S].hbond[e+","+_]=v.toFixed(1))}}}let b=Object.keys(m);if("graph"!==n)for(let e=0,t=b.length;en)return!1;let c=Math.abs(e.coord.y-t.coord.y);if(c>n)return!1;let h=Math.abs(e.coord.z-t.coord.z);if(h>n)return!1;let p=d*d+c*c+h*h;if(p>l)return!1;"graph"!==s&&("halogen"==i?(a.halogenpnts.push({serial:e.serial,coord:e.coord}),a.halogenpnts.push({serial:t.serial,coord:t.coord})):"pi-cation"==i?(a.picationpnts.push({serial:e.serial,coord:e.coord}),a.picationpnts.push({serial:t.serial,coord:t.coord})):"pi-stacking"==i&&(a.pistackingpnts.push({serial:e.serial,coord:e.coord}),a.pistackingpnts.push({serial:t.serial,coord:t.coord})));let m=t.resn+" $"+t.structure+"."+t.chain+":"+t.resi+"@"+t.name;a.resid2Residhash[r][m]=p.toFixed(1);let u=e.structure+"_"+e.chain+"_"+e.resi+"_"+e.resn+","+t.structure+"_"+t.chain+"_"+t.resi+"_"+t.resn;return o||(void 0===a.resids2inter[u]&&(a.resids2inter[u]={}),void 0===a.resids2inter[u][i]&&(a.resids2inter[u][i]={}),a.resids2inter[u][i][r+","+m]=p.toFixed(1)),void 0===a.resids2interAll[u]&&(a.resids2interAll[u]={}),void 0===a.resids2interAll[u][i]&&(a.resids2interAll[u][i]={}),a.resids2interAll[u][i][r+","+m]=p.toFixed(1),!0}getRingNormal(e){if(this.icn3d.icn3dui,e.length<3)return;let t=e[0].clone().sub(e[1]),s=e[1].clone().sub(e[2]);return t.cross(s).normalize()}getAromaticRings(e,t,s){let i=this.icn3d;i.icn3dui;let n=[],l=[],r=[],o=[];if("nucleotide"==s){let s=new THREE.Vector3,a=new THREE.Vector3;if("A"==e.trim().toUpperCase()||"DA"==e.trim().toUpperCase()||"G"==e.trim().toUpperCase()||"DG"==e.trim().toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"N1"==t.name||"C2"==t.name||"N3"==t.name||"C6"==t.name?(s.add(t.coord),r.push(t.coord)):"C4"==t.name||"C5"==t.name?(s.add(t.coord),a.add(t.coord),r.push(t.coord),o.push(t.coord)):"N7"!=t.name&&"C8"!=t.name&&"N9"!=t.name||(a.add(t.coord),o.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r))),5==o.length&&(a.multiplyScalar(.2),n.push(a),l.push(this.getRingNormal(o)))}else if("C"==e.trim().toUpperCase()||"DC"==e.trim().toUpperCase()||"T"==e.trim().toUpperCase()||"DT"==e.trim().toUpperCase()||"U"==e.trim().toUpperCase()||"DU"==e.trim().toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"N1"==t.name||"C2"==t.name||"N3"==t.name||"C6"==t.name?(s.add(t.coord),r.push(t.coord)):"C4"!=t.name&&"C5"!=t.name||(s.add(t.coord),r.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r)))}}else if("protein"==s){let s=new THREE.Vector3,a=new THREE.Vector3;if("PHE"==e.toUpperCase()||"TYR"==e.toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"CG"!=t.name&&"CD1"!=t.name&&"CE1"!=t.name&&"CZ"!=t.name&&"CE2"!=t.name&&"CD2"!=t.name||(s.add(t.coord),r.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r)))}else if("HIS"==e.toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"CG"!=t.name&&"ND1"!=t.name&&"CE1"!=t.name&&"NE2"!=t.name&&"CD2"!=t.name||(s.add(t.coord),r.push(t.coord))}5==r.length&&(s.multiplyScalar(.2),n.push(s),l.push(this.getRingNormal(r)))}else if("TRP"==e.toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"CZ2"==t.name||"CH2"==t.name||"CZ3"==t.name||"CE3"==t.name?(s.add(t.coord),r.push(t.coord)):"CD2"==t.name||"CE2"==t.name?(s.add(t.coord),a.add(t.coord),r.push(t.coord),o.push(t.coord)):"CG"!=t.name&&"CD1"!=t.name&&"NE1"!=t.name||(a.add(t.coord),o.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r))),5==o.length&&(a.multiplyScalar(.2),n.push(a),l.push(this.getRingNormal(o)))}}return{piPosArray:n,normalArray:l}}dfs_cycle(e,t,s){let i=this.icn3d;if(i.icn3dui,2==i.ring_color[e])return s;if(1==i.ring_color[e]){s++;let n=t;for(i.ring_mark[n]=s;n!=e;)n=i.ring_par[n],i.ring_mark[n]=s;return s}if(i.ring_par[e]=t,i.ring_color[e]=1,void 0!==i.atoms[e])for(let t=0,n=i.atoms[e].bonds.length;t=3&&o<=6&&a[0]&&a[1]&&a[2]&&a[3]){let i=a[0].clone().sub(a[1]).normalize(),r=a[1].clone().sub(a[2]).normalize(),d=a[2].clone().sub(a[3]).normalize(),c=i.cross(r).normalize(),h=c.dot(d);if(Math.abs(h)<.052){l.multiplyScalar(1/o);let i=t.atoms[n];s[e+"_pi"+n]={resn:i.resn,name:"pi"+n,coord:l,serial:i.serial,structure:i.structure,chain:i.chain,resi:i.resi,normal:c}}}}return s}hideHalogenPi(){let e=this.icn3d;e.icn3dui,e.opts.halogen="no",e.opts["pi-cation"]="no",e.opts["pi-stacking"]="no",void 0===e.lines&&(e.lines={}),e.lines.halogen=[],e.lines["pi-cation"]=[],e.lines["pi-stacking"]=[],e.halogenpnts=[],e.picationpnts=[],e.pistackingpnts=[];for(let t in e.atoms)e.atoms[t].style2="nothing";for(let t in e.sidec)e.hAtoms.hasOwnProperty(t)&&(e.atoms[t].style2=e.opts.sidec);for(let t in e.water)e.hAtoms.hasOwnProperty(t)&&(e.atoms[t].style=e.opts.water)}}class ut{constructor(e){this.icn3d=e}calculateIonicInteractions(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(0===Object.keys(e).length||0===Object.keys(t).length)return;r.resid2Residhash={};let a,d,c={},h={},p=s*s;for(let t in e){let s=e[t];if("ARG"===s.resn&&"NH2"===s.name||"GLU"===s.resn&&"OE2"===s.name||"ASP"===s.resn&&"OD2"===s.name)continue;let i=("LYS"===s.resn||"HIS"===s.resn)&&"N"===s.elem&&"N"!==s.name||"ARG"===s.resn&&("NH1"===s.name||"NH2"===s.name)||s.het&&-1!==o.parasCls.cationsTrimArray.indexOf(s.elem)||s.het&&"N"===s.elem&&1==s.bonds.length,n=this.isAnion(s);i=r.bOpm?i&&"DUM"!==s.resn:i,n=r.bOpm?n&&"DUM"!==s.resn:n,(i||n)&&(a=s.structure+"_"+s.chain+"_"+s.resi,d=a+"_"+s.name,i&&(c[d]=s),n&&(h[d]=s))}let m={},u={};for(let e in t){let i=t[e];if("ARG"===i.resn&&"NH2"===i.name||"GLU"===i.resn&&"OE2"===i.name||"ASP"===i.resn&&"OD2"===i.name)continue;let g=("LYS"===i.resn||"HIS"===i.resn)&&"N"===i.elem&&"N"!==i.name||"ARG"===i.resn&&("NH1"===i.name||"NH2"===i.name)||i.het&&-1!==o.parasCls.cationsTrimArray.indexOf(i.elem),f=this.isAnion(i);if(g=r.bOpm?g&&"DUM"!==i.resn:g,f=r.bOpm?f&&"DUM"!==i.resn:f,g||f){a=i.structure+"_"+i.chain+"_"+i.resi,d=a+"_"+i.name;let e=i.resn+" $"+i.structure+"."+i.chain+":"+i.resi+"@"+i.name;void 0===r.resid2Residhash[e]&&(r.resid2Residhash[e]={});let t={};g?t=h:f&&(t=c);let b,C=i.structure+"_"+i.chain+"_"+i.resi;g&&"ARG"===i.resn&&"NH1"===i.name?b=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[C],"NH2"):f&&"GLU"===i.resn&&"OE1"===i.name?b=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[C],"OE2"):f&&"ASP"===i.resn&&"OD1"===i.name&&(b=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[C],"OD2"));let y=void 0===b?i.coord:i.coord.clone().add(b.coord).multiplyScalar(.5);for(let d in t){if(a==d.substr(0,d.lastIndexOf("_")))continue;if(!r.crossstrucinter&&i.structure!=t[d].structure)continue;let c,h=t[d].structure+"_"+t[d].chain+"_"+t[d].resi;f&&"ARG"===t[d].resn&&"NH1"===t[d].name?c=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[h],"NH2"):g&&"GLU"===t[d].resn&&"OE1"===t[d].name?c=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[h],"OE2"):g&&"ASP"===t[d].resn&&"OD1"===t[d].name&&(c=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[h],"OD2"));let b=void 0===c?t[d].coord:t[d].coord.clone().add(c.coord).multiplyScalar(.5),C=Math.abs(y.x-b.x);if(C>s)continue;let v=Math.abs(y.y-b.y);if(v>s)continue;let w=Math.abs(y.z-b.z);if(w>s)continue;let _=C*C+v*v+w*w;if(_>p)continue;"graph"!==n&&(r.saltbridgepnts.push({serial:i.serial,coord:y}),r.saltbridgepnts.push({serial:t[d].serial,coord:b}));let S=t[d].structure+"_"+t[d].chain+"_"+t[d].resi;m=o.hashUtilsCls.unionHash(m,r.residues[a]),m=o.hashUtilsCls.unionHash(m,r.residues[S]),u[a]=1,u[S]=1;let A=t[d].resn+" $"+t[d].structure+"."+t[d].chain+":"+t[d].resi+"@"+t[d].name;r.resid2Residhash[e][A]=_.toFixed(1);let x=a+"_"+i.resn+","+S+"_"+t[d].resn;l||(void 0===r.resids2inter[x]&&(r.resids2inter[x]={}),void 0===r.resids2inter[x].ionic&&(r.resids2inter[x].ionic={}),r.resids2inter[x].ionic[e+","+A]=_.toFixed(1)),void 0===r.resids2interAll[x]&&(r.resids2interAll[x]={}),void 0===r.resids2interAll[x].ionic&&(r.resids2interAll[x].ionic={}),r.resids2interAll[x].ionic[e+","+A]=_.toFixed(1)}}}let g=Object.keys(u);if("graph"!==n)for(let e=0,t=g.length;e1?1/(n-1):1;for(let n in e){let e=t.atoms[n];e.color=e.het?s.parasCls.atomColors[e.elem]||s.parasCls.defaultAtomColor:s.parasCls.thr().setHSL(3/4*(1-i++*l),1,.45),t.atomPrevColors[n]=e.color}}colorRainbow(e){let t=this.icn3d,s=t.icn3dui,i=0,n=0;e=s.hashUtilsCls.intHash(e,t.hAtoms);for(let s in e){t.atoms[s].het||++n}let l=n>1?1/(n-1):1;for(let n in e){let e=t.atoms[n];e.color=e.het?s.parasCls.atomColors[e.elem]||s.parasCls.defaultAtomColor:s.parasCls.thr().setHSL(3/4*i++*l,1,.45),t.atomPrevColors[n]=e.color}}setColorAcrossSets(e,t){let s=this.icn3d,i=s.icn3dui,n=0,l=e.length,r=l>1?1/(l-1):1;for(let l=0,o=e.length;l0)this.setMmdbChainColor();else{let e=-1,s="",l=n.parasCls.stdChainColors.length;for(let r in t){let t=i.atoms[r];t.chain!=s&&(++e,e%=l),t.het?(t.color=n.parasCls.atomColors[t.elem],i.atomPrevColors[r]=t.color):(t.color=n.parasCls.stdChainColors[e],Object.keys(i.chainsColor).length>0&&this.updateChainsColor(t),i.atomPrevColors[r]=t.color),s=t.chain}}break;case"domain":s=0,l=0;let m=Object.keys(i.tddomains);l=m.length,r=l>1?1/(l-1):1;for(let e=0,t=m.length;e1?1/(l-1):1;for(let e=0;e Defined Sets", and try it again.');break;case"secondary structure green":i.sheetcolor="green";for(let e in t){let t=i.atoms[e];t.color=t.het?n.parasCls.atomColors[t.elem]||n.parasCls.defaultAtomColor:n.parasCls.ssColors[t.ss]||n.parasCls.thr(16711935),i.atomPrevColors[e]=t.color}break;case"secondary structure yellow":case"secondary structure":i.sheetcolor="yellow";for(let e in t){let t=i.atoms[e];t.color=t.het?n.parasCls.atomColors[t.elem]||n.parasCls.defaultAtomColor:n.parasCls.ssColors2[t.ss]||n.parasCls.thr(16711935),i.atomPrevColors[e]=t.color}break;case"secondary structure spectrum":s=0,l=0;let u,g,f=[],b=-9999;for(let e in t){if(!i.proteins.hasOwnProperty(e))continue;let t=i.atoms[e];-9999==b&&(u=parseInt(e)),-9999!=b&&(t.ss!=g.ss||Math.abs(t.resi-g.resi)>1||t.ssbegin&&g.ssend)&&("coil"==g.ss||f.push([u,b]),u=e),b=parseInt(e),g=t}"coil"==g.ss||f.push([u,b]),l=f.length,r=l>1?1/(l-1):1;for(let e=0,t=f.length;e100&&(e=100);let r=(i.middB-e)*i.spanBinv1,o=(e-i.middB)*i.spanBinv2;e=90?t.color=n.parasCls.thr().setRGB(0,.325,.839):e>=70&&e<90?t.color=n.parasCls.thr().setRGB(.396,.572,.953):e>=50&&e<70?t.color=n.parasCls.thr().setRGB(1,.859,.075):e<50&&(t.color=n.parasCls.thr().setRGB(1,.49,.271))}i.atomPrevColors[e]=t.color}break;case"b factor":i.middB=50,i.spanBinv1=.02,i.spanBinv2=.02;for(let e in t){let t=i.atoms[e];if(void 0===t.b||isNaN(t.b)||0==parseInt(1e3*t.b))t.color=n.parasCls.thr().setRGB(0,1,0);else{let e=t.b;e>100&&(e=100),e=t.structure.substr(0,4)!=i.defaultPdbId&&t.structure.length>5?100-e:e;let s=(i.middB-e)*i.spanBinv1,l=(e-i.middB)*i.spanBinv2;t.color=et.b&&(o=t.b),a5?100-t.b:t.b,s=i.bfactorArray.indexOf(e)/C;t.color=s<.5?n.parasCls.thr().setRGB(2*s,2*s,1):n.parasCls.thr().setRGB(1,2*(1-s),2*(1-s))}i.atomPrevColors[e]=t.color}break;case"area":if(void 0===i.resid2area){let e=n.hashUtilsCls.cloneHash(i.hAtoms);i.hAtoms=n.hashUtilsCls.cloneHash(i.atoms),i.bCalcArea=!0,i.opts.surface="solvent accessible surface",i.applyMapCls.applySurfaceOptions(),i.bCalcArea=!1,i.hAtoms=n.hashUtilsCls.cloneHash(e)}let y=void 0!==i.midpercent?i.midpercent:35;i.spanBinv1=.02,i.spanBinv2=.02;for(let e in t){let t=i.atoms[e],s=t.structure+"_"+t.chain+"_"+t.resi+"_"+t.resn,l=n.parasCls.residueArea.hasOwnProperty(t.resn)?i.resid2area[s]/n.parasCls.residueArea[t.resn]*100:y;l>100&&(l=100);let r=(y-l)*i.spanBinv1,o=(l-y)*i.spanBinv2;t.color=l

    ";if("atom"==e){let e=["proteins","nucleotides","chemicals","ions","water"];for(let i=0,n=e.length;i[e,s.parasCls.hydrophobicValues[e]]));r.sort(((e,t)=>parseFloat(e[1])-parseFloat(t[1])));var o=r.map((e=>[e[0],Object.keys(n[e[0]])[0]]));l+="
    ","normalized hydrophobic"==e?(l+="Dark green (W, F, Y, L, I, C, M): Hydrophobic
    ",l+="Light green (G, V, S, T, A, N, P, Q): Polar
    ",l+="Grey: Charged, not hydrophobic

    "):(l+="Green (W, F, Y, L, I, C, M): Hydrophobic
    ",l+="Yellow (G, V, S, T, A, N, P, Q): Polar
    ",l+="Red: Negatively Charged
    ",l+="Blue: Positively Charged

    ");let a=0;for(let e of o)s.parasCls.residueAbbrev[e[0]]&&(l+="
    ",l+="
    ",l+=s.parasCls.residueAbbrev[e[0]]+"
    ",a%4==3&&(l+="
    "),++a);l+="
    "}else"b factor"==e?(l+="
    B factor quantitates the uncertainty for each atom. A high B factor reflects that the position is less certain.

    ",l+=s.htmlCls.clickMenuCls.setLegendHtml()):"confidence"==e?l+=s.htmlCls.clickMenuCls.setLegendHtml(!0):(l="",i=!0);$("#"+s.pre+"dl_legend").html(l),s.htmlCls.dialogCls.openDlg("dl_legend","Color Legend"),i&&window.dialog&&window.dialog.dialog("close")}getColorLegendForElem(e,t){let s=this.icn3d,i=s.icn3dui,n="",l={};for(let e in t){let t=s.atoms[e],i=void 0===t||void 0===t.color||"FFFFFF"===t.color.getHexString().toUpperCase()?"DDDDDD":t.color.getHexString();void 0===l[t.elem]&&(l[t.elem]={}),l[t.elem][i]=1}if(Object.keys(l).length>0){n+=""+e+"
    ";let t=Object.keys(l).sort();for(let e=0,s=t.length;e";for(let e in l[s])n+="
    ";n+=i.parasCls.atomnames[s.toUpperCase()]+"

    "}n+="
    "}return n}getRes2color(e,t){let s=this.icn3d,i=s.icn3dui,n={},l=s.firstAtomObjCls.getResiduesFromAtoms(e);for(let e in l){let l=s.residues[e],r=s.firstAtomObjCls.getFirstAtomObj(l),o=t?r.resn:i.parasCls.residueAbbrev[r.resn],a=void 0===r||void 0===r.color||"FFFFFF"===r.color.getHexString().toUpperCase()?"DDDDDD":r.color.getHexString();null!=o&&(void 0===n[o]&&(n[o]={}),n[o][a]=1)}return n}getColorLegendForResidue(e){this.icn3d.icn3dui;let t="",s=this.getRes2color(e);if(Object.keys(s).length>0){t+="
    ";let e=Object.keys(s).sort(),i="",n=0;for(let l=0,r=e.length;l";for(let e in s[o])r+="
    ";r+=o+"
    ",n%4==3&&(r+="
    "),-1!=o.indexOf("(")?(t+=r,++n):i+=r}i&&(t+="
    "+i),t+="
    "}return t}getColorLegendForCharge(e){let t=this.icn3d;t.icn3dui;let s="",i=t.firstAtomObjCls.getResiduesFromAtoms(e),n={};for(let e in i){let s=t.residues[e],i=t.firstAtomObjCls.getFirstAtomObj(s);"ARG"==i.resn||"LYS"==i.resn?n.Positive=1:"HIS"==i.resn?n["Partial-Positive"]=1:"ASP"==i.resn||"GLU"==i.resn||t.nucleotides[i.serial]?n.Negative=1:n.Neutral=1}const l={Positive:"0000ff","Partial-Positive":"8080ff",Negative:"ff0000",Neutral:"888888"};let r=["Positive","Partial-Positive","Negative","Neutral"];s+="
    ";for(let e=0,t=r.length;e",s+="
    ",s+=t,s+="
    ")}return s+="
    (Charges are at pH 7)",s+="
    ",s}getColorLegendForIgstrand(e){this.icn3d.icn3dui;let t="";const s={"A^ Strand":"FF00FF","A Strand":"663399","A* Strand":"FFC0CB","A Strand":"9370db","B Strand":"ba55d3","C Strand":"0000FF","C' Strand":"6495ED","C'' Strand":"006400","D Strand":"00FF00","E Strand":"FFFF00","F Strand":"FFA500","G Strand":"FF0000","G* Strand":"8B0000",Loop:"CCCCCC"};t+="
    ";for(let e in s){t+="",t+="
    ",t+=e,t+="

    "}return t+="
    ",t}}class yt{constructor(e){this.icn3d=e}async showCddSiteAll(){let e=this.icn3d,t=e.icn3dui,s=this;e.chainid2pssmid={};let i=$.map(e.protein_chainid,(function(e){return e})),n=Object.keys(e.protein_chainid),l="https://www.ncbi.nlm.nih.gov/Structure/cdannots/cdannots.fcgi?fmt&frclive&live=lcl&queries="+i;if(1==Object.keys(e.structures).length&&(t.cfg.mmtfid||t.cfg.pdbid||t.cfg.opmid||t.cfg.mmdbid||t.cfg.gi||t.cfg.uniprotid||t.cfg.blast_rep_id||t.cfg.cid||t.cfg.mmcifid)||2==Object.keys(e.structures).length&&t.cfg.align){let e={};try{e.value=await t.getAjaxPromise(l,"jsonp"),s.parseCddData([e],n)}catch(e){return void s.getNoCdd(i)}}else{let i=[];for(let s=0,r=n.length;s',p=h,m=h,u=d.doms;n.bNode&&!i.resid2cdd[c]&&(i.resid2cdd[c]=[]);let g=l.setDomainFeature(u,c,!0,h,p,m);i.chainid2pssmid[c]={pssmid2name:g.pssmid2name,pssmid2fromArray:g.pssmid2fromArray,pssmid2toArray:g.pssmid2toArray};let f=g.acc2domain;h=g.html+"",p=g.html2+"",m=g.html3+"",$("#"+i.pre+"dt_cdd_"+c).html(h),$("#"+i.pre+"ov_cdd_"+c).html(p),$("#"+i.pre+"tt_cdd_"+c).html(m),h='
    ',p=h,m=h;let b=d.motifs;n.bNode&&!i.resid2site[c]&&(i.resid2site[c]=[]),g=l.setDomainFeature(b,c,!1,h,p,m,f),h=g.html,p=g.html2,m=g.html3;let C=a.data[e].sites,y=void 0!==C?C.length:0;for(let e=0;e17&&(s=s.substr(0,17)+"...");let l,r=C[e].title,o=[];for(let t=0,s=C[e].locs.length;t'+s+"
    ",u=''+t.toString()+" Res",g='';m+=d+u+"
    ",h+=d+u+g,p+=d+u+g;let f="site"+e.toString(),b=0,y=0,v=1;for(let t=0,s=i.giSeq[c].length;t1&&(l=s[0]+"..");let r=i.ParserUtilsCls.getResi(c,t);if(h+=''+s+"",n.bNode){let t={};t[c+"_"+r]="site: "+C[e].title,i.resid2site[c].push(t)}p+=i.showSeqCls.insertGapOverview(c,t);let o=n.cfg.blast_rep_id==c?Math.round(i.seqAnnWidth*t/(i.maxAnnoLength+i.nTotalGap)-b-y):Math.round(i.seqAnnWidth*t/i.maxAnnoLength-b-y);o>=0&&(p+='
     
    ',p+='
     
    ',b+=o,y+=v)}else h+="-";g=' '+t.toString()+" Residues",g+="
    ",g+="
    ",h+=g,p+=g}h+="",p+="",m+="",$("#"+i.pre+"dt_site_"+c).html(h),$("#"+i.pre+"ov_site_"+c).html(p),$("#"+i.pre+"tt_site_"+c).html(m)}}for(let e in i.protein_chainid)r.hasOwnProperty(e)||($("#"+i.pre+"dt_cdd_"+e).html(""),$("#"+i.pre+"ov_cdd_"+e).html(""),$("#"+i.pre+"tt_cdd_"+e).html(""),$("#"+i.pre+"dt_site_"+e).html(""),$("#"+i.pre+"ov_site_"+e).html(""),$("#"+i.pre+"tt_site_"+e).html(""));i.showAnnoCls.enableHlSeq(),i.bAjaxCddSite=!0}getNoCdd(e){let t=this.icn3d;t.icn3dui,console.log("No CDD data were found for the protein "+e+"...");for(let e in t.protein_chainid)$("#"+t.pre+"dt_cdd_"+e).html(""),$("#"+t.pre+"ov_cdd_"+e).html(""),$("#"+t.pre+"tt_cdd_"+e).html(""),$("#"+t.pre+"dt_site_"+e).html(""),$("#"+t.pre+"ov_site_"+e).html(""),$("#"+t.pre+"tt_site_"+e).html("");t.showAnnoCls.enableHlSeq(),t.bAjaxCddSite=!0}setDomainFeature(e,t,s,i,n,l,r){let o,a,d,c=this.icn3d,h=c.icn3dui;s&&(r={},o={},a={},d={});let p=void 0!==e?e.length:0,m=s?14:19,u=s?100:120;for(let g=0;gm&&(v=v.substr(0,m)+"...");let w=b+": "+C;s&&(o[p]=C);let _=e[g].locs;if(_)for(let e=0,r=_.length;e'+v+" ",E=''+S.toString()+" Res";l+=R+E+"
    ";let I='';i+=R+E+I,s&&(n+='
    '),n+='
    '+v+"
    ",n+=E+I;let T=b+g.toString();for(let e=0,n=c.giSeq[t].length;e1&&(l=n[0]+"..");let r=c.ParserUtilsCls.getResi(t,e);if(i+=''+n+"",h.bNode){let e={};e[t+"_"+r]=w,s?c.resid2cdd[t].push(e):c.resid2site[t].push(e)}}else i+="-";let M=c.firstAtomObjCls.getFirstCalphaAtomObj(c.chains[t]),P=void 0===M.color||"FFFFFF"===M.color.getHexString()?"DDDDDD":M.color.getHexString(),D=void 0!==M.color?P:"CCCCCC";if(h.cfg.blast_rep_id!=t)for(let s=0,i=r.length;s ',n+='
    '+C+"
    "}else{let s=[],i=[];for(let e=0,t=r.length;e ',n+='
    '+C+"
    "}}I=' '+S.toString()+" Residues",I+="
    ",I+="
    ",i+=I,n+=I,s&&(n+='')}}return{html:i,html2:n,html3:l,acc2domain:r,pssmid2name:o,pssmid2fromArray:a,pssmid2toArray:d}}showAnnoType(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui,a='
    ',d=a,c=a;if(0==n.length)return $("#"+r.pre+"dt_"+s+"_"+e).html(""),$("#"+r.pre+"ov_"+s+"_"+e).html(""),void $("#"+r.pre+"tt_"+s+"_"+e).html("");let h=i;i.length>17&&(i=i.substr(0,17)+"...");let p=[];for(let e=0,t=n.length;e'+i+"
    ",f=''+m.toString()+" Res";c+=g+f+"
    ";let b='';a+=g+f+b,d+=g+f+b;let C=s,y=0,v=0;for(let t=0,i=r.giSeq[e].length;t1&&(c=n[0]+"..");let h=i,p=e+"_"+i,m=n+i;if("ssbond"==s){m="Residue "+p+" has disulfide bond with";let t="";if(void 0!==l[p])for(let e=0,s=l[p].length;e'+c+"",d+=r.showSeqCls.insertGapOverview(e,t);let u=o.cfg.blast_rep_id==e?Math.round(r.seqAnnWidth*t/(r.maxAnnoLength+r.nTotalGap)-y-v):Math.round(r.seqAnnWidth*t/r.maxAnnoLength-y-v);u>=0&&(d+='
     
    ',d+='
     
    ',y+=u,v+=1)}else a+="-"}b=' '+m.toString()+" Residues",b+="",b+="
    ",a+=b,d+=b,a+="",d+="",c+="",$("#"+r.pre+"dt_"+s+"_"+e).html(a),$("#"+r.pre+"ov_"+s+"_"+e).html(d),$("#"+r.pre+"tt_"+s+"_"+e).html(c)}setToolTip(){let e=this.icn3d;e.icn3dui,$("[id^="+e.pre+"snp]").add("[id^="+e.pre+"clinvar]").add("[id^="+e.pre+"ssbond]").add("[id^="+e.pre+"crosslink]").tooltip({content:function(){return $(this).prop("title")},show:null,close:function(e,t){t.tooltip.hover((function(){$(this).stop(!0).fadeTo(400,1)}),(function(){$(this).fadeOut("400",(function(){$(this).remove()}))}))}})}}class vt{constructor(e){this.icn3d=e}showInteraction(e,t){this.icn3d.icn3dui,this.showInteraction_base(e,t)}showInteraction_base(e,t){let s=this.icn3d,i=s.icn3dui;i.bNode&&(s.resid2contact||(s.resid2contact={}),s.resid2contact[e]||(s.resid2contact[e]=[])),void 0===s.chainname2residues&&(s.chainname2residues={});let n=Object.keys(s.chains),l=e,r=Math.round(l.indexOf("_"));if(s.firstAtomObjCls.getFirstCalphaAtomObj(s.chains[l]),void 0===s.chainname2residues[l]){s.chainname2residues[l]={};let t=n.length;if(t>100&&void 0===i.cfg.mmdbid&&void 0===i.cfg.gi&&void 0===i.cfg.blast_rep_id&&void 0===i.cfg.align&&void 0===i.cfg.chainalign)return $("#"+s.pre+"dt_interaction_"+e).html(""),void $("#"+s.pre+"ov_interaction_"+e).html("");for(let e=0;e4)continue;let o,a=s.firstAtomObjCls.getFirstCalphaAtomObj(s.chains[t]);s.chemicals.hasOwnProperty(a.serial)?o="chemical":s.nucleotides.hasOwnProperty(a.serial)?o="nucleotide":s.ions.hasOwnProperty(a.serial)?o="ion":s.proteins.hasOwnProperty(a.serial)?o="protein":s.water.hasOwnProperty(a.serial)&&(o="water");let d=s.contactCls.getAtomsWithinAtom(i.hashUtilsCls.hash2Atoms(s.chains[l],s.atoms),i.hashUtilsCls.hash2Atoms(s.chains[t],s.atoms),4);if(0==Object.keys(d).length)continue;let c={};for(let e in d){let t=s.atoms[e];c[t.structure+"_"+t.chain+"_"+t.resi]=1}let h=t.substr(t.indexOf("_")+1)+"("+o+")";s.chainname2residues[l][h]=Object.keys(c)}}let o='
    ',a=o,d=o,c=0;for(let t in s.chainname2residues[e]){let n=s.chainname2residues[e][t];if(!n)continue;let l="Interact ."+t;l.length>17&&(l=l.substr(0,17)+"...");let r="Interact ."+t,h=[];for(let e=0,t=n.length;e'+l+"
    ",g=''+p.toString()+" Res";d+=u+g+"
    ";let f='';o+=u+g+f,a+=u+g+f;let b="inter"+c.toString(),C=0,y=0,v=1;for(let t=0,n=s.giSeq[e].length;t1&&(d=l[0]+"..");let c=n;if(o+=''+d+"",i.bNode){let t={};t[e+"_"+c]=r,s.resid2contact[e].push(t)}a+=s.showSeqCls.insertGapOverview(e,t);let h=i.cfg.blast_rep_id==e?Math.round(s.seqAnnWidth*t/(s.maxAnnoLength+s.nTotalGap)-C-y):Math.round(s.seqAnnWidth*t/s.maxAnnoLength-C-y);h>=0&&(a+='
     
    ',a+='
     
    ',C+=h,y+=v)}else o+="-"}f=' '+p.toString()+" Residues",f+="
    ",f+="
    ",o+=f,a+=f,++c}o+="",a+="",d+="",$("#"+s.pre+"dt_interaction_"+e).html(o),$("#"+s.pre+"ov_interaction_"+e).html(a),$("#"+s.pre+"tt_interaction_"+e).html(d),i.utilsCls.isMobile()?(s.hlSeqCls.selectSequenceMobile(),s.hlSeqCls.selectChainMobile()):s.hlSeqCls.selectSequenceNonMobile()}}class wt{constructor(e){this.icn3d=e}async showPTM(e,t,s,i,n){let l=this.icn3d,r=l.icn3dui,o=this,a=e.substr(0,e.indexOf("_")),d=e.substr(e.indexOf("_")+1);if("afmem"==s){let t={Transmembrane:[{begin:i,end:n}]};this.setAnnoPtmTransmem("transmem",t,e)}else if(a.length>5){let t,i="https://www.ebi.ac.uk/proteins/api/features/"+a;try{t=await r.getAjaxPromise(i,"json"),o.parsePTM(t,e,s)}catch{return void o.getNoPTM(e,s)}}else{let t,i=a.substr(0,4).toLowerCase(),n="https://www.ebi.ac.uk/pdbe/api/mappings/uniprot/"+i;try{t=await r.getAjaxPromise(n,"json");let a="";l.UPResi2ResiPosPerChain||(l.UPResi2ResiPosPerChain={}),l.UPResi2ResiPosPerChain[e]={};let c=t[i].UniProt,h=!1;for(let t in c){let s=c[t].mappings;for(let i=0,n=s.length;i',o+=r,a+=r;let d=s.substr(0,s.indexOf("_"));for(let c in t){let h=t[c],p=[],m=!1;for(let e=0,t=h.length;e5?p.push(e-1):i.UPResi2ResiPosPerChain&&i.UPResi2ResiPosPerChain[s][e]&&p.push(i.UPResi2ResiPosPerChain[s][e]),!m&&i.residues.hasOwnProperty(s+"_"+e)&&(m=!0)}if(0==p.length)continue;let u=p.length,g="ptm"==e?"PTM: "+c:"Transmembrane";g.length>17&&(g=g.substr(0,17)+"...");let f=c,b='
    '+g+"
    ",C=''+u.toString()+" Res",y='';a+=b+C+"
    ",r+=b+C+y,o+=b+C+y;let v=e+l.toString(),w=0,_=0,S=1;for(let e=0,t=i.giSeq[s].length;e1&&(l=t[0]+"..");let a=i.ParserUtilsCls.getResi(s,e);if(r+=''+t+"",n.bNode){let e={};e[s+"_"+a]=g,i.resid2ptm[s].push(e)}o+=i.showSeqCls.insertGapOverview(s,e);let d=n.cfg.blast_rep_id==s?Math.round(i.seqAnnWidth*e/(i.maxAnnoLength+i.nTotalGap)-w-_):Math.round(i.seqAnnWidth*e/i.maxAnnoLength-w-_);d>=0&&(o+='
     
    ',o+='
     
    ',w+=d,_+=S)}else r+="-";y=' '+u.toString()+" Residues",y+="
    ",y+="
    ",r+=y,o+=y,++l}r+="",o+="",a+="",$("#"+i.pre+"dt_"+e+"_"+s).html(r),$("#"+i.pre+"ov_"+e+"_"+s).html(o),$("#"+i.pre+"tt_"+e+"_"+s).html(a)}getNoPTM(e,t){let s=this.icn3d;s.icn3dui,console.log("No PTM data were found for the chain "+e+"...");let i="ptm"==t?"ptm":"transmem";$("#"+s.pre+"dt_"+i+"_"+e).html(""),$("#"+s.pre+"ov_"+i+"_"+e).html(""),$("#"+s.pre+"tt_"+i+"_"+e).html(""),s.showAnnoCls.enableHlSeq(),s.bAjaxPTM=!0}}class _t{constructor(e){this.icn3d=e}showCrosslink(e,t){let s=this.icn3d;s.icn3dui;let i=this;void 0===s.clbondpnts?setTimeout((function(){i.showCrosslink_base(e,t)}),1e3):this.showCrosslink_base(e,t)}showCrosslink_base(e,t){let s=this.icn3d;s.icn3dui.bNode&&(s.resid2crosslink||(s.resid2crosslink={}),s.resid2crosslink[e]||(s.resid2crosslink[e]=[]));let i=t,n={},l=i.substr(0,i.indexOf("_")),r=s.clbondpnts[l];if(void 0===r)return $("#"+s.pre+"dt_crosslink_"+e).html(""),$("#"+s.pre+"ov_crosslink_"+e).html(""),void $("#"+s.pre+"tt_crosslink_"+e).html("");for(let e=0,t=r.length;e',a=o,d=o,c=e.indexOf("_"),h=e.substr(c+1);if(s)n=e,i=t.domains[e]?t.domains[e].domains:[];else{let e,s=t.moleculeInfor;for(let t in s)if(s[t].chain===h){e=t,n=s[t].name;break}void 0!==e&&void 0!==t.domains[e]&&(i=t.domains[e].domains),void 0===i&&(i=[])}for(let t=0,s=i.length;t17?s.substr(0,17)+"...":s,h=i[t].intervals,p={},m={},u=[],g=[],f={},b=0;for(let e=0,t=h.length;e'+c+" ",y=''+b.toString()+" Res";d+=C+y+"
    ";let v='';o+=C+y+v,a+=C+y+v;let w="domain3d"+t.toString();for(let t=0,s=l.giSeq[e].length;t1&&(n=i[0]+"..");let r=s;o+=''+i+""}else o+="-"}let _=l.firstAtomObjCls.getFirstCalphaAtomObj(l.chains[e]),S=void 0===_.color||"FFFFFF"===_.color.getHexString()?"DDDDDD":_.color.getHexString(),A=void 0!==_.color?S:"CCCCCC";if(r.cfg.blast_rep_id!=e)for(let i=0,n=u.length;i ',a+='"}else{let i=[],n=[];for(let e=0,t=u.length;e ',a+='"}}v=' '+b.toString()+" Residues",v+="",v+="
    ",o+=v,a+=v}o+="",a+="",d+="",$("#"+l.pre+"dt_domain_"+e).html(o),$("#"+l.pre+"ov_domain_"+e).html(a),$("#"+l.pre+"tt_domain_"+e).html(d)}}class At{constructor(e){this.icn3d=e}async showSnp(e,t){this.icn3d.icn3dui,await this.showSnpClinvar(e,t,!0)}async showClinvar(e,t){this.icn3d.icn3dui,await this.showSnpClinvar(e,t,!1)}async showSnpClinvar(e,t,s){let i=this.icn3d.icn3dui,n=this,l=i.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainid="+t;try{let r=await i.getAjaxPromise(l,"jsonp"),o=r.snpgi,a=r.gi;if(s)await n.showSnpPart2(e,t,o);else{let s=o;[6137708,1942289,224510717,2624886,253723219,2554905,75765331,3660278,312207882,319443632,342350956,1827805,109157826,1065265,40889086,6730307,163931185,494469,163931091,60594093,55669745,18655489,17942684,6980537,166235465,6435586,4139398,4389047,364506122,78101667,262118402,20664221,2624640,158430173,494395,28948777,34810587,13399647,3660342,261278854,342350965,384482350,378792570,15988303,213424334,4558333,2098365,10835631,3318817,374074330,332639529,122919696,4389286,319443573,2781341,67464020,194709238,210061039,364506106,28949044,40889076,161172338,17943181,4557976,62738484,365813173,6137343,350610552,17942703,576308,223674070,15826518,1310997,93279697,4139395,255311799,157837067,361132363,357380836,146387678,383280379,1127268,299856826,13786789,1311054,46015217,3402130,381353319,30750059,218766885,340707375,27065817,355333104,2624634,62738384,241913553,304446010].includes(a)&&(s=a),await n.showClinvarPart2(e,t,s)}}catch(t){return void(s?n.processNoSnp(e):n.processNoClinvar(e))}}navClinVar(e){let t=this.icn3d;t.icn3dui;let s=this;t.currClin[e]=-1,$(document).on("click","#"+t.pre+e+"_prevclin",(function(t){let i=s.icn3d;t.stopImmediatePropagation();let n=void 0!==i.resi2disease_nonempty[e]?Object.keys(i.resi2disease_nonempty[e]).length:0;--i.currClin[e],i.currClin[e]<0&&(i.currClin[e]=n-1),s.showClinVarLabelOn3D(e)})),$(document).on("click","#"+t.pre+e+"_nextclin",(function(t){let i=s.icn3d;t.stopImmediatePropagation();let n=void 0!==i.resi2disease_nonempty[e]?Object.keys(i.resi2disease_nonempty[e]).length:0;++i.currClin[e],i.currClin[e]>n-1&&(i.currClin[e]=0),s.showClinVarLabelOn3D(e)}))}showClinVarLabelOn3D(e){let t,s,i=this.icn3d,n=i.icn3dui,l=Object.keys(i.resi2disease_nonempty[e]);t=e,s=t+"_"+(parseInt(l[i.currClin[e]])+i.baseResi[e]).toString();let r="",o=i.resi2disease_nonempty[e][l[i.currClin[e]]];for(let e=0,t=o.length;e0?o[0]:"N/A");let a=i.applyCenterCls.centerAtoms(n.hashUtilsCls.hash2Atoms(i.residues[s],i.atoms));r.length>30&&(r=r.substr(0,30)+"..."),i.selectionCls.removeSelection(),null==i.labels&&(i.labels={}),i.labels.clinvar=[];let d=i.LABELSIZE,c="black"!=i.opts.background?i.colorWhitebkgd:i.colorBlackbkgd;i.analysisCls.addLabel(r,a.center.x+1,a.center.y+1,a.center.z+1,d,c,void 0,"clinvar"),i.hAtoms={};for(let e in i.residues[s])i.hAtoms[e]=1;$("#clinvar_"+i.pre+s).addClass("icn3d-highlightSeq"),void 0===$("#"+i.pre+"modeswitch")[0]||$("#"+i.pre+"modeswitch")[0].checked||i.definedSetsCls.setMode("selection"),i.drawCls.draw()}getSnpLine(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g){let f=this.icn3d,b=f.icn3dui,C="",y=m?"clinvar":"snp",v=!1;for(let e in i){for(let t=0,s=i[e].length;t(from human)",i=" (based on human sequences and mapped to this structure by sequence similarity)"),C+=m?'":'"}else if(2==e&&m){let e=b.utilsCls.isMobile()?"none":"button";C+='
    ',C+='
    '}else C+='
    ';let w=y,_=0,S=0,A={},x={};for(let t=1,i=f.giSeq[h].length;t<=i;++t)if(void 0!==r[t]){++_;let i="";for(let n=0,r=s[t].length;n'+k+" Res":'',u)return C+"
    ";C+='';let O="",R=0,E=0;for(let t=1,a=f.giSeq[h].length;t<=a;++t)if(p){if(void 0!==r[t]){let e=f.giSeq[h][t-1],i=e;e.length>1&&(i=e[0]+"..");let n=f.ParserUtilsCls.getResi(h,t-1)+i+">";for(let e=0,i=s[t].length;e=0&&(C+='
     
    ',C+='
     
    ',R+=r,E+=1):r>0&&(C+='
     
    ',C+='
     
    ',R+=r,E+=1)}}else if(C+=f.showSeqCls.insertGap(h,t-1,"-"),void 0!==r[t])if(m||1!=e){let r=f.giSeq[h][t-1],a=r;r.length>1&&(a=r[0]+"..");let d,c=f.ParserUtilsCls.getResi(h,t-1),p="",u="
    ",y=s[t].length,v=0,_=0;if(2==e&&(v=0,_=y),m){d=1;let r=0;for(let e=v;e0?_+="; ":0!==e&&1!==e||(O='disease="'+v[t]+'"'),_+=v[t]+"("+w[t]+")",++S;""!=_&&(r"+s[t][e],u+=": "+_,C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(m,"snpin3d","3D with scap","SNP in 3D with scap",70,g)+"  ",u+=f.showAnnoCls.addSnpButton(m,"snpinter","Interactions","SNP Interactions in 3D",70,g)+"  ",u+=f.showAnnoCls.addSnpButton(m,"snppdb","PDB","Download SNP PDB",35,g)),u+="
    Links: ClinVar, dbSNP(rs"+i[t][e]+")",e
    "),++r)}r>d&&2==e&&(p+="..")}else{d=1;for(let e=v;e"+s[t][e],g)C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),0!=i[t][e]&&(u+="
    Link: dbSNP(rs"+i[t][e]+")"),e
    ");else{let s=l[t][e].split("; "),a=o[t][e].split("; "),d="",c=0;for(let t=0,i=s.length;t0?d+="; ":0!==e&&1!==e||(O='disease="'+s[t]+'"'),d+=s[t]+"("+a[t]+")",++c;""!=d?(u+=": "+d,C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),u+="
    Links: ClinVar, dbSNP(rs"+i[t][e]+")"):(C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),u+="
    Link: dbSNP(rs"+i[t][e]+")"),e
    ")}}y>d&&2==e&&(p+="..")}u+="
    ",m?"icn3d-clinvar"==A[t]||"icn3d-clinvar-path"==A[t]?C+=1==e?"":""==p||" "==p?"-":''+p+"":C+="-":C+=""==p||" "==p?"-":g?''+p+"":''+p+""}else C+="";else C+="-";return C+=1==e?' '+k+" Residues":'',C+="
    ",C+="
    ",C}processSnpClinvar(e,t,s,i,n){let l=this.icn3d,r=l.icn3dui,o='
    ',a=o,d=o,c='
    ',h=c,p=c,m=!i||n?e.data:e.split("\n"),u={},g={},f={};void 0===l.resi2disease_nonempty[t]&&(l.resi2disease_nonempty[t]={});let b={},C={},y={},v={},w={},_="";r.bNode&&(i?(l.resid2snp||(l.resid2snp={}),l.resid2snp[t]||(l.resid2snp[t]=[])):(l.resid2clinvar||(l.resid2clinvar={}),l.resid2clinvar[t]||(l.resid2clinvar[t]=[])));for(let e=0,s=m.length;e")+1),h=s[4],p=i?"":s[5],S=i?"":s[6],A=i?"":s[7],x=l.ParserUtilsCls.getResi(t,d-1);v[x]=1,""!=S&&(w[x]=1),g[d]=e+1,void 0===u[d]&&(u[d]=[]),u[d].push(c),void 0===C[d]&&(C[d]=[]),C[d].push(h),void 0===y[d]&&(y[d]=[]),y[d].push(p),void 0===f[d]&&(f[d]=[]),f[d].push(S),""!=S&&(void 0===l.resi2disease_nonempty[t][d]&&(l.resi2disease_nonempty[t][d]=[]),l.resi2disease_nonempty[t][d].push(S)),void 0===b[d]&&(b[d]=[]),b[d].push(A)}let S=Object.keys(v),A=Object.keys(w);if(i){let e=!1;o+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,void 0,i),o+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,void 0,i),d+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,!0,i),d+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,!0,i),a+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!0,e,void 0,i),o+="
    ",a+="
    ",d+="",$("#"+l.pre+"dt_snp_"+t).html(o),$("#"+l.pre+"ov_snp_"+t).html(a),$("#"+l.pre+"tt_snp_"+t).html(d)}else{let e=!0;c+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,void 0,i),c+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,void 0,i),p+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,!0,i),p+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,!0,i),h+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!0,e,void 0,i),c+="",h+="",p+="",$("#"+l.pre+"dt_clinvar_"+t).html(c),$("#"+l.pre+"ov_clinvar_"+t).html(h),$("#"+l.pre+"tt_clinvar_"+t).html(p),this.navClinVar(t,s)}l.showAnnoCls.enableHlSeq(),i?l.bAjaxSnp=!0:l.bAjaxClinvar=!0}async showClinvarPart2(e,t,s){let i=this.icn3d,n=i.icn3dui,l=this,r=n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainid_clinvar="+t;i.chainsGene[e]&&i.chainsGene[e].geneSymbol&&(r+="&gene="+i.chainsGene[e].geneSymbol);try{let s=await n.getAjaxPromise(r,"jsonp");if(s&&s.data&&s.data.length>0){let i=!1,n=s;l.processSnpClinvar(n,e,t,i)}else l.processNoClinvar(e)}catch(t){return void l.processNoClinvar(e)}}async showSnpPart2(e,t,s){let i=this.icn3d,n=i.icn3dui,l=this;if(void 0!==s){let s=n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainid_snp="+t;i.chainsGene[e]&&i.chainsGene[e].geneSymbol&&(s+="&gene="+i.chainsGene[e].geneSymbol);try{let i=await n.getAjaxPromise(s,"jsonp");if(i&&i.data&&i.data.length>0){let s=!0,n=!0;l.processSnpClinvar(i,e,t,s,n)}else l.processNoSnp(e)}catch(t){return void l.processNoSnp(e)}}else this.processNoSnp(e),console.log("No gi was found for the chain "+t+"...")}processNoClinvar(e){let t=this.icn3d;t.icn3dui,console.log("No ClinVar data were found for the protein "+e+"..."),$("#"+t.pre+"dt_clinvar_"+e).html(""),$("#"+t.pre+"ov_clinvar_"+e).html(""),t.showAnnoCls.enableHlSeq(),t.bAjaxClinvar=!0}processNoSnp(e){let t=this.icn3d;t.icn3dui,console.log("No SNP data were found for the protein "+e+"..."),$("#"+t.pre+"dt_snp_"+e).html(""),$("#"+t.pre+"ov_snp_"+e).html(""),t.showAnnoCls.enableHlSeq(),t.bAjaxSnp=!0}}class xt{constructor(e){this.icn3d=e}showSsbond(e,t){let s=this.icn3d;s.icn3dui;let i=this;void 0===s.ssbondpnts?setTimeout((function(){i.showSsbond_base(e,t)}),1e3):this.showSsbond_base(e,t)}showSsbond_base(e,t){let s=this.icn3d;s.icn3dui.bNode&&(s.resid2ssbond||(s.resid2ssbond={}),s.resid2ssbond[e]||(s.resid2ssbond[e]=[]));let i=t,n={},l=i.substr(0,i.indexOf("_")),r=s.ssbondpnts[l];if(void 0===r)return $("#"+s.pre+"dt_ssbond_"+e).html(""),$("#"+s.pre+"ov_ssbond_"+e).html(""),void $("#"+s.pre+"tt_ssbond_"+e).html("");for(let e=0,t=r.length;e-s.halfBilayerSize){i[t.structure+"_"+t.chain+"_"+t.resi]=1}}let n=Object.keys(i);s.annoCddSiteCls.showAnnoType(e,t,"transmem","Transmembrane",n)}}class Ot{constructor(e){this.icn3d=e,this.dcut=7,this.MAX_SSE=512,this.ctc_cnt=[];for(let e=0;e=this.curr_ratio+.01||f>this.split_ratio)return e;if(f>this.curr_ratio-.01&&Math.min(m,u)=0&&l[i]==t-e+i;i--);if(i<0)break;for(l[i]++,s=i+1;s-1;i++);for(l=Math.min(i-1,this.max_csz),this.curr_ne0=this.curr_ne1=0,this.curr_ratio=100,s=1;s<=l;s++)this.cut_size(s,i);if(this.top--,0==this.curr_ne0){for(n=this.stack[this.top],e=n;e-1;e++)this.parts[this.np++]=this.elements[e];this.parts[this.np++]=-1,this.n_doms++}else{if(this.save_ratios[this.saved++]=this.curr_ratio,this.curr_ne0>this.min_sse){for(n=this.stack[this.top],e=0;ethis.min_sse){for(n=this.stack[this.top],e=0;e0;)this.process_set()}output(e){let t,s;this.icn3d.icn3dui;let i=[];for(t=0;t<2*e;t++)i.push(0);for(t=s=0;st+n)break;let p=(t-a)*(t-a);p+=(s-c)*(s-c),p+=(i-h)*(i-h);let m=Math.sqrt(p);if(m>n)continue;let u={},g={};parseInt(e.rnum)this.MAX_SSE)return{subdomains:a,substruct:o};let g=h.length,f=r[g-1],b=this.c2b_AlphaContacts(g,i,n,l,t,r),C=[];for(let e=0;e0&&this.elt_size[s.sse-1]>=6&&0!=s.adj_strand2&&e++}for(let e=0;e0)for(let e=0;e0){let e=0;for(let t=0;t<=E;t++){let t=[];for(;e<2*u;){let s=this.parts[e++];if(0==s){I.push(t);break}t.push(s)}}}I.sort((function(e,t){return e[0]-t[0]}));for(let e=0,t=I.length;e=o.length)return{subdomains:a,substruct:o};let n=o[i],l=n.From,r=n.To;for(let e=l;e<=r;e++)s[e]=1;if(0==i&&l>1)for(let e=1;e0){let e=o[i-1].To,t=parseInt(.5*(l-e-1));if(t>0)for(let e=l-t;e<=l-1;e++)s[e]=1}if(i0)for(let e=r+1;e<=r+t;e++)s[e]=1}}let i,n=!1,l=[];for(let e=0;e0&&(d+=", "),d+='{"ss": [';let i=0;for(let s=0,r=n[e].length;s=r&&c<=o&&(i>0&&(d+=", "),d+="["+s+","+n+","+c+","+l[e].x1.toFixed(2)+","+l[e].y1.toFixed(2)+","+l[e].z1.toFixed(2)+","+l[e].x2.toFixed(2)+","+l[e].y2.toFixed(2)+","+l[e].z2.toFixed(2)+"]",++i))}}d+="]",d+=', "domain": [';let r=0;for(let i=0,l=n[e].length;i=l&&n<=a&&(r>0&&(d+=", "),d+="["+n+","+h+","+c.coord.x.toFixed(2)+","+c.coord.y.toFixed(2)+","+c.coord.z.toFixed(2)+"]",++r)}}d+="]}"}return d+="]}",d}}class Rt{constructor(e){this.icn3d=e}clickAddTrackButton(){let e=this.icn3d,t=e.icn3dui,s=this;t.myEventCls.onIds("#"+e.pre+"addtrack_button1","click",(async function(e){let i=s.icn3d;e.stopImmediatePropagation(),dialog.dialog("close");let n=$("#"+i.pre+"track_chainid").val(),l=$("#"+i.pre+"track_gi").val(),r=isNaN(l)?"Acc "+l:"gi "+l,o=t.htmlCls.baseUrl+"pwaln/pwaln.fcgi?from=track",a={targets:n,queries:l},d=await t.getAjaxPostPromise(o,a);s.alignSequenceToStructure(n,d,r)})),t.myEventCls.onIds("#"+e.pre+"addtrack_button2","click",(async function(e){let i=s.icn3d;e.stopImmediatePropagation(),dialog.dialog("close");let n=$("#"+i.pre+"track_chainid").val(),l=$("#"+i.pre+"track_fasta").val(),r=$("#"+i.pre+"fasta_title").val(),o=n.substr(0,n.indexOf("_")),a=n;if(5==o.length)a=a.substr(0,4);else if(o.length>5){a="";for(let e=0,t=i.chainsSeq[n].length;e"),a=o[1].indexOf("\n");o[1].substr(0,a);let d,c=o[1].substr(a+1).replace(/\n/g,""),h=[],p=[];for(let e=2,t=o.length;e0&&(u=f,i.targetGapHash[m+d]={from:m+d,to:u+C-1+d}),g=c[e],f=b,"-"!=c[e]?(++b,w=e,y||(v=e,y=!0)):++C;await i.annotationCls.resetAnnoAll();let _="",S=0;for(let e in i.targetGapHash)S>0&&(_+=" "),_+=e+"_"+i.targetGapHash[e].from+"_"+i.targetGapHash[e].to,++S;t.htmlCls.clickMenuCls.setLogCmd("msa | "+_,!0);let A={};for(let e=0,o=p.length;e0){void 0===i.queryresi2score&&(i.queryresi2score={}),void 0===i.queryresi2score[n]&&(i.queryresi2score[n]={});let e=p.length;for(let t in A){let s=parseInt(A[t]/e*100);i.queryresi2score[n][t]=s}let s=Object.keys(A),l=Math.min.apply(null,s),r=Math.max.apply(null,s),o="";for(let t=l;t<=r;++t)A.hasOwnProperty(t)?o+=Math.round(A[t]/e*9):o+="_";i.opts.color="align custom",i.setColorCls.setColorByOptions(i.opts,i.hAtoms),i.hlUpdateCls.updateHlAll(),i.drawCls.draw(),t.htmlCls.clickMenuCls.setLogCmd("color align custom | "+n+" | range "+l+"_"+r+" | "+o,!0)}})),t.myEventCls.onIds("#"+e.pre+"addtrack_button3","click",(function(e){let i=s.icn3d;e.stopImmediatePropagation(),dialog.dialog("close");let n=$("#"+i.pre+"track_chainid").val(),l=$("#"+i.pre+"track_bed")[0].files[0];if(l){window.File&&window.FileReader&&window.FileList&&window.Blob||alert("The File APIs are not fully supported in this browser.");let e=new FileReader;e.onload=function(e){let l,r=e.target.result.split("\n"),o=!1,a=!1;for(let e=0,d=r.length;e8||d.length<6)&&(a=!1),d.length<9&&(o=!1),d[0];let c,h,p=d[1],m=d[2],u=d[3];d.length,d.length>5&&(c=d[5]),d.length,d.length,d.length>8&&(h=d[8]),d.length,d.length,d.length;let g=u,f="51,51,51";o?f=h:a&&("+"==c&&l.length>0?f=l[0]:"-"==c&&l.length>1?f=l[1]:"."==c&&l.length>2&&(f=l[2]));let b="",C=[];for(let e=0,t=m;e1&&(s=t[0]);let l=i.ParserUtilsCls.getResi(n,e);if(a.hasOwnProperty(n+"_"+l)){let e=i.firstAtomObjCls.getFirstCalphaAtomObj(i.residues[n+"_"+l]),t=void 0===e.color||"FFFFFF"===e.color.getHexString().toUpperCase()?"DDDDDD":e.color.getHexString(),o=void 0!==e.color?t:"CCCCCC";r+=s,d.push("#"+o)}else r+="-",d.push("")}s.showNewTrack(n,l,r,d,void 0,"selection",void 0),t.htmlCls.clickMenuCls.setLogCmd("add track | chainid "+n+" | title "+l+" | text "+s.simplifyText(r)+" | type selection",!0)}))}showNewTrack(e,t,s,i,n,l,r,o,a,d){let c=this.icn3d,h=c.icn3dui,p=!1;"cannot be aligned"==s&&(p=!0);let m=s.replace(/-/g,"").length;if(!o)if(s.length>c.giSeq[e].length)s=s.substr(0,c.giSeq[e].length);else if(s.length20&&(u=u.substr(0,20));let g=h.htmlCls.RESIDUE_WIDTH*s.length+200;$("#"+c.pre+"dt_custom_"+e).append("
    "),$("#"+c.pre+"dt_custom_"+e+"_"+u).width(g),$("#"+c.pre+"ov_custom_"+e).append("
    "),$("#"+c.pre+"ov_custom_"+e+"_"+u).width(g),$("#"+c.pre+"tt_custom_"+e).append("
    "),$("#"+c.pre+"tt_custom_"+e+"_"+u).width(g);let f='
    ',b=f,C=f,y=parseInt(10*Math.random()),v='",w=''+m.toString()+" Pos";C+=v+w+"
    ";let _='';f+=v+w+_,b+=v+w+_;let S=e.indexOf("_"),A="cst"+e.substr(S+1),x=0,k=0,O=(void 0===l||"seq"===l||"custom"===l)&&-1==s.indexOf("cannot-be-aligned")&&-1==s.indexOf("cannot be aligned"),R="identity"===l&&-1==s.indexOf("cannot-be-aligned")&&-1==s.indexOf("cannot be aligned"),E={},I=0,T=1;v="";for(let t=0,a=s.length;t"+d+"",v+=c.showSeqCls.insertGapOverview(e,t);let g=h.cfg.blast_rep_id==e?Math.round(c.seqAnnWidth*t/(c.maxAnnoLength+c.nTotalGap)-x-k):Math.round(c.seqAnnWidth*t/c.maxAnnoLength-x-k);g<0&&(g=0),v+='
     
    ',s=void 0!==i&&""!=i[t]?i[t]:r?"rgb("+r+")":O?"#"+p:"#333",v+='
     
    ',x+=g,k+=1,++T}else f+=p?""+d+"":"-"}if(void 0!==a){v="";let s=[],i=[];for(let e=0,t=a.length;e 
    ',v+='"}}_=''+m.toString()+" Pos",_+="",_+="
    ",_+="",f+=_,b+=v+_,C+="",$("#"+c.pre+"dt_custom_"+e+"_"+u).html(f),$("#"+c.pre+"ov_custom_"+e+"_"+u).html(b),$("#"+c.pre+"tt_custom_"+e+"_"+u).html(C)}alignSequenceToStructure(e,t,s){let i,n,l,r=this.icn3d,o=r.icn3dui;void 0!==t.data&&(i=t.data[0].query,l=Object.keys(t.data[0].targets)[0],n=t.data[0].targets[l],n=n.hsps[0]);let a="",d=[],c={};if(void 0!==i&&void 0!==n){let h=n.scores.e_value.toPrecision(2);h>1e-200&&(h=parseFloat(h).toExponential()),n.scores.bit_score;let p=t.targets[l].seqdata,m=i.seqdata,u=n.segs;for(let e=0,t=u.length;e0&&(l=n+"H"+d+")","coil"==t&&(s.selectionCls.selectResidueList(r,l,l,o,a),o||(o=!0)),r={})),n=e+"_H"+d,r[p]=1,i.ssend&&(h=e+"_C(H"+d,"helix"==t&&(s.selectionCls.selectResidueList(r,n,n,o,a),o||(o=!0)),r={})):"E"==m?(i.ssbegin&&(++c,Object.keys(r).length>0&&(l=n+"S"+c+")","coil"==t&&(s.selectionCls.selectResidueList(r,l,l,o,a),o||(o=!0)),r={})),n=e+"_S"+c,r[p]=1,i.ssend&&(h=e+"_C(S"+c,"sheet"==t&&(s.selectionCls.selectResidueList(r,n,n,o,a),o||(o=!0)),r={})):(n=h+"-",r[p]=1)}}Object.keys(r).length>0&&(l=n+"Cterm)","coil"==t&&s.selectionCls.selectResidueList(r,l,l,o,a))}simplifyText(e){this.icn3d.icn3dui;let t,s,i="",n=!1,l=-1;for(t=0,s=(e=e.replace(/undefined/g," ")).length;t20)return!1;if(void 0!==o.giSeq&&void 0!==o.giSeq[e]){let r=this.getFullText(s);return s=r.text,this.showNewTrack(e,t,s,void 0,void 0,i,n,l),!1}setTimeout((function(){a.checkGiSeq(e,t,s,i,n,l,r+1)}),100)}getFullText(e){this.icn3d.icn3dui;let t="",s=[],i=[],n=e.split(","),l=-1;for(let e=0,r=n.length;ep?t+=c.substr(0,p):t+=c;for(let e=0;e0&&($("#"+e.pre+"anno_cdd")[0].checked?(this.setAnnoTabCdd(),t.htmlCls.clickMenuCls.setLogCmd("set annotation cdd",!0)):(this.hideAnnoTabCdd(),t.htmlCls.clickMenuCls.setLogCmd("hide annotation cdd",!0)))}showAnnoSelectedChains(){let e=this.icn3d,t=e.icn3dui,s={};for(let t in e.hAtoms){let i=e.atoms[t];s[i.structure+"_"+i.chain]=1}$("#"+e.pre+"dl_annotations > .icn3d-annotation").hide();for(let i in s){$("#"+e.pre+"anno_"+i).length&&$("#"+e.pre+"anno_"+i).show();let s=e.firstAtomObjCls.getFirstCalphaAtomObj(e.chains[i]);if(void 0!==s.resn){let i=t.utilsCls.residueName2Abbr(s.resn.substr(0,3));$("#"+e.pre+"anno_"+i).show()}}}showAnnoAllChains(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"dl_annotations > .icn3d-annotation").show()}setAnnoView(e){let t=this.icn3d;t.icn3dui.bNode||("detailed view"===e?(t.view="detailed view",$("#"+t.pre+"dl_anno_view_tabs").tabs("option","active",1)):(t.view="overview",$("#"+t.pre+"dl_anno_view_tabs").tabs("option","active",0)))}setAnnoDisplay(e,t){let s=this.icn3d;s.icn3dui;let i=["giseq","custom","site","ptm","snp","clinvar","cdd","domain","interaction","ssbond","crosslink","transmem"];for(let n in i){let l=i[n];$("[id^="+s.pre+t+"_"+l+"]").attr("style",e)}}showFixedTitle(){this.icn3d.icn3dui;this.setAnnoDisplay("display:block;","tt")}hideFixedTitle(){this.icn3d.icn3dui;this.setAnnoDisplay("display:none!important;","tt")}setAnnoViewAndDisplay(e){let t=this.icn3d;if(t.icn3dui,"detailed view"===e){this.setAnnoView("detailed view");let e="display:block;";this.setAnnoDisplay(e,"dt"),$("#"+t.pre+"seqguide_wrapper").attr("style",e),e="display:none;",this.setAnnoDisplay(e,"ov")}else{this.setAnnoView("overview"),this.hideFixedTitle();let e="display:none;";this.setAnnoDisplay(e,"dt"),$("#"+t.pre+"seqguide_wrapper").attr("style",e),e="display:block;",this.setAnnoDisplay(e,"ov")}}async updateClinvar(){let e=this.icn3d;if(e.icn3dui,void 0===e.bClinvarShown||!e.bClinvarShown)for(let t in e.protein_chainid){let s=e.protein_chainid[t];await e.annoSnpClinVarCls.showClinvar(t,s)}e.bClinvarShown=!0}async updateSnp(){let e=this.icn3d;if(e.icn3dui,void 0===e.bSnpShown||!e.bSnpShown)for(let t in e.protein_chainid){let s=e.protein_chainid[t];await e.annoSnpClinVarCls.showSnp(t,s)}e.bSnpShown=!0}updateDomain(){let e=this.icn3d;e.icn3dui,void 0!==e.bDomainShown&&e.bDomainShown||e.annoDomainCls.showDomainAll(),e.bDomainShown=!0}updateInteraction(){let e=this.icn3d;if(e.icn3dui,void 0===e.bInteractionShown||!e.bInteractionShown)for(let t in e.interactChainbase){let s=e.interactChainbase[t];e.annoContactCls.showInteraction(t,s)}e.bInteractionShown=!0}async updatePTM(){let e=this.icn3d;if(e.icn3dui,void 0===e.bPTMShown||!e.bPTMShown)for(let t in e.PTMChainbase){let s=e.PTMChainbase[t];await e.annoPTMCls.showPTM(t,s,"ptm")}e.bPTMShown=!0}updateSsbond(){let e=this.icn3d;if(e.icn3dui,void 0===e.bSSbondShown||!e.bSSbondShown)for(let t in e.ssbondChainbase){let s=e.ssbondChainbase[t];e.annoSsbondCls.showSsbond(t,s)}e.bSSbondShown=!0}updateCrosslink(){let e=this.icn3d;if(e.icn3dui,void 0===e.bCrosslinkShown||!e.bCrosslinkShown)for(let t in e.crosslinkChainbase){let s=e.crosslinkChainbase[t];e.annoCrossLinkCls.showCrosslink(t,s)}e.bCrosslinkShown=!0}async updateTransmem(){let e=this.icn3d,t=e.icn3dui;if(void 0===e.bTranememShown||!e.bTranememShown)for(let s in e.protein_chainid){let i=e.protein_chainid[s];if(void 0!==t.cfg.opmid)e.annoTransMemCls.showTransmem(s,i);else if(e.bAfMem&&e.afmem_start_end){let t=e.afmem_start_end[0],n=e.afmem_start_end[1];await e.annoPTMCls.showPTM(s,i,"afmem",t,n)}else await e.annoPTMCls.showPTM(s,i,"transmem")}e.bTranememShown=!0}}class It{constructor(e){this.icn3d=e}showAnnotations_part1(){let e=this.icn3d,t=e.icn3dui;if(t.htmlCls.dialogCls.openDlg("dl_selectannotations","Sequences and Annotations"),(void 0===e.bAssemblyNote||!e.bAssemblyNote)&&void 0!==e.asuCnt){let t="
    Assembly Tips: Only the asymmetric unit is shown in the sequence window.
    Click \"Assembly\" in the menu \"View\" to switch between asymmetric unit and biological assembly("+e.asuCnt+" asymmetric unit).
    ";$("#"+e.pre+"dl_annotations_tabs").append(t),e.bAssemblyNote=!0}e.bResetAnno&&(e.giSeq={},e.currClin={},e.resi2disease_nonempty={},e.baseResi={},e.matchedPos={},$("#"+t.pre+"dl_annotations").empty(),e.annotationCls.setAnnoView("overview"));let s={},i={},n={};if(void 0===e.bAnnoShown||!e.bAnnoShown||e.bResetAnno){e.protein_chainid={};let l,r=Object.keys(e.chains);void 0===e.giSeq&&(e.giSeq={}),void 0===e.currClin&&(e.currClin={}),void 0===e.resi2disease_nonempty&&(e.resi2disease_nonempty={}),void 0===e.baseResi&&(e.baseResi={}),void 0===e.matchedPos&&(e.matchedPos={}),l=t.bNode?500:t.cfg.notebook?t.htmlCls.WIDTH/2:$("#"+e.pre+"dl_selectannotations").dialog("option","width"),e.seqAnnWidth=l-120-60-50;for(let l=0,o=r.length;l1)e.protein_chainid[r[l]]=a;else if(e.nucleotides.hasOwnProperty(o.serial)&&e.chainsSeq[r[l]].length>1)s[r[l]]=a;else if(e.chainsSeq[r[l]].length>1)i[r[l]]=a;else{let t=e.chainsSeq[r[l]][0].name,s=r[l]+"_"+e.chainsSeq[r[l]][0].resi;void 0===n[t]&&(n[t]=[]),n[t].push(s)}if((void 0!==t.cfg.pdbid||void 0!==t.cfg.opmid||void 0!==t.cfg.mmcifid||void 0!==t.cfg.mmtfid)&&(e.proteins.hasOwnProperty(o.serial)||e.nucleotides.hasOwnProperty(o.serial)))for(let t=0,s=e.chainsSeq[r[l]].length;te.maxAnnoLength&&(e.protein_chainid.hasOwnProperty(t)||s.hasOwnProperty(t))&&(e.maxAnnoLength=e.chainsSeq[t].length)}return{nucleotide_chainid:s,chemical_chainid:i,chemical_set:n}}async showAnnotations(){let e=this.icn3d,t=e.icn3dui,s=this,i=this.showAnnotations_part1(),n=i.nucleotide_chainid,l=i.chemical_chainid,r=i.chemical_set;if(void 0===e.bAnnoShown||!e.bAnnoShown||e.bResetAnno)if(void 0===t.cfg.blast_rep_id){if(e.bFullUi){if(void 0!==t.cfg.mmtfid){let t=Object.keys(e.structures)[0];await e.mmcifParserCls.downloadMmcifSymmetry(t,"mmtfid")}await this.showAnnoSeqData(n,l,r)}}else if(void 0===t.cfg.blast_rep_id||e.bSmithwm||e.bLocalSmithwm){if(void 0!==t.cfg.blast_rep_id&&(e.bSmithwm||e.bLocalSmithwm)){let i,o,a=[t.cfg.blast_rep_id];if(-1!=t.cfg.query_id.indexOf(">")?o=t.cfg.query_id.substr(t.cfg.query_id.indexOf("\n")+1):!/\d/.test(t.cfg.query_id)||t.cfg.query_id.length>50?o=t.cfg.query_id:a.push(t.cfg.query_id),e.blastAcxn){let s=t.cfg.afid+"_A",n="";for(let t=0,i=e.chainsSeq[s].length;tProteins:

    ":"",a=e.chainsGene[s]&&e.chainsGene[s].geneId?"(Gene: "+e.chainsGene[s].geneSymbol+")":"",d=s.substr(0,s.indexOf("_")),c=d.length>5?''+s+"":s,h="
    "+o+"Annotations of "+c+": "+r+""+a+"   "+this.addButton(s,"icn3d-addtrack","Add Track","Add a custom track",60,i)+"   ";h+=this.addButton(s,"icn3d-customcolor","Custom Color/Tube","Use a custom file to define the colors or tubes in 3D structure",110,i)+"   ",h+=this.addButton(s,"icn3d-helixsets","Helix Sets",'Define sets for each helix in this chain and add them to the menu of "Defined Sets"',60,i)+" "+this.addButton(s,"icn3d-sheetsets","Sheet Sets",'Define sets for each sheet in this chain and add them to the menu of "Defined Sets"',60,i)+" "+this.addButton(s,"icn3d-coilsets","Coil Sets",'Define sets for each coil in this chain and add them to the menu of "Defined Sets"',60,i),$("#"+e.pre+"dl_annotations").append(h);let p=["giseq","cdd","clinvar","snp","site","ptm","ssbond","crosslink","transmem","domain","custom","interaction"];for(let t in p){let i=p[t];$("#"+e.pre+"anno_"+s).append(this.getAnDiv(s,i))}$("#"+e.pre+"anno_"+s).append("


    "),++n}if(t.bNode||e.annoCddSiteCls.setToolTip(),void 0!==e.chainid_seq)await this.processSeqData(e.chainid_seq);else try{let n=[],l=[];for(let e=0,t=i.length;e=6?l.push(i[e]):n.push(i[e]);if(n.length>0){let s=t.htmlCls.baseUrl+"/vastdyn/vastdyn.cgi?chainlist="+n;e.chainid_seq=await t.getAjaxPromise(s,"jsonp")}else e.chainid_seq={};for(let t=0,s=l.length;t40&&(r=r.substr(0,40)+"...");let o="";0==i&&("protein"==s?o="Proteins:

    ":"nucleotide"==s?o="Nucleotides:

    ":"chemical"==s&&(o="Chemicals/Ions/Water:

    ")),$("#"+n.pre+"dl_annotations").append("
    "+o+""+e+": "+r+"
    "),$("#"+n.pre+"anno_"+e).append(this.getAnDiv(e,"giseq")),$("#"+n.pre+"anno_"+e).append(this.getAnDiv(e,"interaction")),$("#"+n.pre+"anno_"+e).append("


    "),n.giSeq[e]=[];for(let t=0;tChemicals/Ions/Water:

    ":"",o=t[0].lastIndexOf("_"),a=t[0].substr(0,o),d=void 0!==l.cfg.mmdbid&&void 0!==n.chainid2sid?n.chainid2sid[a]:void 0;i=void 0!==d?""+e+" ":""+e+"",$("#"+n.pre+"dl_annotations").append("
    "+r+i+"
    "),$("#"+n.pre+"anno_"+e).append("
    "),$("#"+n.pre+"anno_"+e).append("


    ");let c='
    ';c+='",c+='Count: '+t.length+"",c+='';let h=c,p=c;for(let s=0,i=t.length;s3&&(l=i.substr(0,3)),s'+l+""}let m=l.htmlCls.GREY8,u=Math.round(n.seqAnnWidth*t.length/n.maxAnnoLength);u<1&&(u=1),p+='
     
    ',c="",c+="
    ",c+="
    ",h+=c,p+=c,$("#"+n.pre+"dt_giseq_"+e).html(h),$("#"+n.pre+"ov_giseq_"+e).html(p)}async processSeqData(e){let t=this.icn3d,s=t.icn3dui;for(let i in t.protein_chainid){let n=t.protein_chainid[i];if(e.hasOwnProperty(n)){let s=e[n];t.giSeq[i]=s;let l="";for(let e=0;e<10&&e14?"Query: "+o.substr(0,6)+"...":isNaN(s.cfg.query_id)?"Query: "+o:"Query: gi "+o;let a="cannot be aligned";t.queryStart="",t.queryEnd="",t.bRender&&alert("The sequence can NOT be aligned to the structure"),t.showSeqCls.showSeq(i,n,void 0,e,l,a,r)}else if(s.cfg.blast_rep_id==i&&(void 0!==t.seqStructAlignData||void 0!==t.seqStructAlignDataSmithwm)){let e,l,r,o,a,d=s.cfg.oriQuery_id?s.cfg.oriQuery_id:s.cfg.query_id;if(e=d.length>14?"Query: "+d.substr(0,6)+"...":isNaN(s.cfg.query_id)?"Query: "+d:"Query: gi "+d,void 0!==t.seqStructAlignData){let e,s,i=t.seqStructAlignData;if(void 0!==i.data){e=i.data[0].query;let t=Object.keys(i.data[0].targets);s=i.data[0].targets[t[0]],s=void 0!==s&&s.hsps.length>0?s.hsps[0]:void 0}if(void 0!==e&&void 0!==s){l=s.scores.e_value.toPrecision(2),l>1e-200&&(l=parseFloat(l).toExponential()),s.scores.bit_score;let t=Object.keys(i.targets);r=i.targets[t[0]].seqdata,o=e.seqdata,a=s.segs}}else{let e=t.seqStructAlignDataSmithwm;l=e.score,r=e.target.replace(/-/g,""),o=e.query.replace(/-/g,""),a=[];let s=-1,i=-1,n=!1,d={};for(let t=0,l=e.target.length;t0)if(i.orifrom-ni.from-l)for(let t=n+1;t
    "+i+"
    "}addButton(e,t,s,i,n,l){return this.icn3d.icn3dui,"
    "}addSnpButton(e,t,s,i,n,l){let r=this.icn3d;return r.icn3dui,"
    "}conservativeReplacement(e,t){let s=this.icn3d.icn3dui,i=-1!==s.parasCls.b62ResArray.indexOf(e)?s.parasCls.b62ResArray.indexOf(e):s.parasCls.b62ResArray.length-1,n=-1!==s.parasCls.b62ResArray.indexOf(t)?s.parasCls.b62ResArray.indexOf(t):s.parasCls.b62ResArray.length-1;return s.parasCls.b62Matrix[i][n]>0}getColorhexFromBlosum62(e,t){let s=this.icn3d.icn3dui;e=e.toUpperCase(),t=t.toUpperCase();let i=-1!==s.parasCls.b62ResArray.indexOf(e)?s.parasCls.b62ResArray.indexOf(e):s.parasCls.b62ResArray.length-1,n=-1!==s.parasCls.b62ResArray.indexOf(t)?s.parasCls.b62ResArray.indexOf(t):s.parasCls.b62ResArray.length-1,l=s.parasCls.b62Matrix[i][n];if(void 0===l)return"333333";let r="333333";if(l>0){let e=221-parseInt(l/11*221),t=e<10?"0"+e.toString(16):e.toString(16);r="DD"+t+t}else{let e=221-parseInt(-1*l/4*221),t=e<10?"0"+e.toString(16):e.toString(16);r=t+t+"DD"}return r}}class Tt{constructor(e){this.icn3d=e}showSeq(e,t,s,i,n,l,r){let o,a=this.icn3d,d=a.icn3dui,c=!1;if(void 0===d.cfg.mmdbid&&void 0===d.cfg.gi&&void 0===d.cfg.blast_rep_id&&void 0===d.cfg.align&&void 0===d.cfg.chainalign&&void 0===d.cfg.mmdbafid){c=!0,o=[];for(let t=0;t10){u='
    ';let t=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]);void 0===d.cfg.mmdbid&&void 0===d.cfg.gi&&void 0===d.cfg.blast_rep_id&&void 0===d.cfg.align&&void 0===d.cfg.chainalign&&void 0===d.cfg.mmdbafid||void 0===t.resi_ori||t.resi_ori==t.resi||-1!=e.indexOf("Misc")?u+='
    ':u+='
    NCBI Residue Numbers
    ',u+='',b+=u+"
    ",g+=u+'';let s=0,i=0,n="";for(let t=0,l=o.length;t",l%10==0&&(g+=l);let r=e+"_"+l,o=l%10!=0&&l%10!=1&&l%10!=9;if(a.residues.hasOwnProperty(r)){let e=a.firstAtomObjCls.getFirstCalphaAtomObj(a.residues[r]);"H"==a.secondaries[r]&&e.ssbegin?(++s,n='H'+s+"",o&&(g+=n,n="")):"E"==a.secondaries[r]&&e.ssbegin?(++i,"green"==a.sheetcolor?n='S'+i+"":"yellow"==a.sheetcolor&&(n='S'+i+""),o&&(g+=n,n="")):e.ssend&&(n=""),""!=n&&o&&(g+=n,n="")}g+=""}g+='',g+="",g+="
    ",g+="
    ",b+=""}u='
    ',u+='
    ',u+='',b+=u+"
    ",g+=u+'';for(let t=0,s=o.length;t':'',g+=" ";else if("E"==a.secondaries[s]){a.firstAtomObjCls.getFirstCalphaAtomObj(a.residues[s]).ssend?"green"==a.sheetcolor?g+='':"yellow"==a.sheetcolor&&(g+=''):"green"==a.sheetcolor?g+='':"yellow"==a.sheetcolor&&(g+=''),g+=" "}else"c"==a.secondaries[s]?g+=' ':"o"==a.secondaries[s]&&(g+=' ');else g+="-"}g+='',g+="",g+="
    ",g+="
    ",g+="",b+="",u=d.cfg.blast_rep_id===e?'
    ':'
    ';let C="Protein",y="Protein";void 0!==s&&("nucleotide"==s?(C="Nucl.",y="Nucleotide"):"chemical"==s&&(C="Chem.",y="Chemical")),u+='",u+=''+(a.baseResi[e]+1).toString()+"",b+=u+"
    ";let v='';g+=u+v,f+=u+v;let w,_=0;for(let t=0,s=o.length;t1&&(i=s[0]+".."),w=a.ParserUtilsCls.getResi(e,t),a.residues.hasOwnProperty(e+"_"+w)){let n="333333";if(d.cfg.blast_rep_id==e&&void 0!==a.fullpos2ConsTargetpos&&void 0!==a.fullpos2ConsTargetpos[t+_])n=a.fullpos2ConsTargetpos[t+_].color;else{let t=a.firstAtomObjCls.getFirstCalphaAtomObj(a.residues[e+"_"+w]),s=void 0===t.color||"FFFFFF"===t.color.getHexString()?"DDDDDD":t.color.getHexString();n=void 0!==t.color?s:"CCCCCC"}g+=''+i+""}else i=i.toLowerCase(),g+=''+i+""}d.cfg.blast_rep_id==e&&(a.opts.color=a.blastAcxn?"confidence":"conservation",a.setColorCls.setColorByOptions(a.opts,a.atoms));let S=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]),A=S.color?S.color.getHexString():"CCCCCC",x=Math.round(a.seqAnnWidth*o.length/a.maxAnnoLength);if(x<1&&(x=1),d.cfg.blast_rep_id!=e)f+='";else{let t=[],s=[];t.push(0);for(let e=0,i=o.length;e';for(let i=0,n=t.length;i'+e+"
    ";f+="
    "}if(u=''+w+"",u+="",u+="
    ",g+=u,f+=u,d.cfg.blast_rep_id==e){if(void 0!==r&&""!==r){u='",u+='',b+=u+"
    ";let t='';g+=u+t,f+=u+t;let s=0,i=0,l=1;a.queryStart;for(let t=0,n=r.length;t-";else if(" "==n)g+=" ";else{let r=a.fullpos2ConsTargetpos[t].pos;if(a.residues.hasOwnProperty(e+"_"+r)){let s=a.fullpos2ConsTargetpos[t].color;g+=''+n+""}else n=n.toLowerCase(),g+=''+n+"";f+=this.insertGapOverview(e,t);let o=Math.round(a.seqAnnWidth*t/(a.maxAnnoLength+a.nTotalGap)-s-i);o>=0&&(f+='
     
    ',f+='
     
    ',s+=o,i+=l)}}u='',u+="",u+="
    ",g+=u,f+=u}u='
    '+i+"
    ",u+=''+a.queryStart+"",b+=u+"
    ";let t='';g+=u+t,f+=u+t;let s=a.queryStart;for(let t=0,i=l.length;t-":(void 0===a.fullpos2ConsTargetpos||void 0===a.fullpos2ConsTargetpos[t]||a.residues.hasOwnProperty(e+"_"+a.fullpos2ConsTargetpos[t].pos)||(i=i.toLowerCase()),g+=''+i+"",++s)}let o=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]),d=void 0===o.color||"FFFFFF"===o.color.getHexString()?"DDDDDD":o.color.getHexString(),c=void 0!==o.color?d:"CCCCCC",h=[],p=[],m="-";for(let e=0,t=l.length;e ',f+='
    '+i+"
    "}u=''+a.queryEnd+"",u+="",u+="
    ",g+=u,f+=u}if(g+="",f+="",b+="",a.giSeq[e].length>10){let t=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]);if(void 0===d.cfg.mmdbid&&void 0===d.cfg.gi&&void 0===d.cfg.blast_rep_id&&void 0===d.cfg.align&&void 0===d.cfg.chainalign&&void 0===d.cfg.mmdbafid||void 0===t.resi_ori||t.resi_ori==t.resi||-1!=e.indexOf("Misc")){if(a.bShowRefnum&&a.chainid2index.hasOwnProperty(e)){let t=this.showRefNum(o,e);g+=t.html,b+=t.html3;let s=1;t=this.showRefNum(o,e,s),g+=t.html,b+=t.html3,s=2,t=this.showRefNum(o,e,s),g+=t.html,b+=t.html3}else if(a.bShowCustomRefnum&&a.chainsMapping.hasOwnProperty(e)){let t=!0,s=this.showRefNum(o,e,void 0,t);g+=s.html,b+=s.html3}}else{u='
    ',u+='
    ',u+='
    PDB Residue Numbers
    ',u+='',b+=u+"
    ",g+=u+'';for(let t=0,s=o.length;t",e%10==0&&(g+=e+" "),g+=""}else g+=""}g+='',g+="",g+="
    ",g+="
    ",g+="
    ",b+=""}}a.bShowRefnum&&(a.hAtoms=a.hAtomsRefnum,a.hlUpdateCls.updateHlAll()),$("#"+a.pre+"dt_giseq_"+e).html(g),$("#"+a.pre+"ov_giseq_"+e).html(f),$("#"+a.pre+"tt_giseq_"+e).html(b)}showRefNum(e,t,s,i){let n=this.icn3d;n.icn3dui;let l="",r="",o="";for(let e=0,s=n.chainid2index[t].length;eCustom Ref. No.':1==s?'
    Kabat Ref. No.
    ':2==s?'
    IMGT Ref. No.
    ':'
    IgStRAnD Ref. No.
    ',d+='',r+=d+"
    ",l+=d+'';let c=!1;for(let s=0,l=e.length;s0){c=!0;break}}if(1==s&&!c)return{html:"",html3:""};let h=!1;for(let s=0,l=e.length;s0){h=!0;break}}if(2==s&&!h)return{html:"",html3:""};let p,m,u,g,f,b,C,y,v,w=!1,_="",S="",A="",x=1,k={},O=1,R="",E=!1;for(let l=0,r=e.length;l1e3&&"9"!=u.substr(1,1)&&(x=1,E&&R&&(delete k[R],R="")),S&&" "!=_&&f>1e3&&"9"==u.substr(1,1)&&(1==x&&(k.hasOwnProperty(_+g)&&++O,g=u.replace(f.toString(),"")+"_"+O,k[_+g]={},k[_+g].start=b,k[_+g].chainid=t),u=(1e3*parseInt(A)+900+x).toString(),p=_+u,++x))):!S||" "==_||i||s||(1==x&&(k.hasOwnProperty(_+g)?(++O,g=u.replace(f.toString(),"")+"_"+O,k[_+g]={}):k[_+g]={},k[_+g].start=b,k[_+g].chainid=t,R=_+g,E=!0),u=(1e3*parseInt(A)+900+x).toString(),p=_+u,++x),b=u,y=f,C=g,S=_}k[S+C]&&(k[S+C].len=x-1,k[S+C].end=b),O=1,R="",E=!1;let I,T={},M=!0;for(let r=0,o=e.length;r1e3&&"9"!=u.substr(1,1)&&(x=1,E&&R&&(--O,R="")),S&&f>1e3&&"9"==u.substr(1,1)){w=!0,1==x&&(T.hasOwnProperty(I+g)&&(++O,g=u.replace(f.toString(),"")+"_"+O),T[I+g]=1);let e=this.getAdjustedRefnum(k,I,x,A,g,y);f=e.refnum,M=e.bShowRefnum,u=e.refnumStr,p=e.refnumLabel,v=e.refnumLabelNoPostfix,a=e.bHidelabel,_=p.replace(new RegExp(u,"g"),""),++x}y=f}if(i)if(u){l+=parseInt(u)%2==0?''+u+"":' '}else l+="";else if(1==s||2==s)if(u){let e=parseInt(u).toString(),t='style="color:'+this.getRefnumColor(_)+'"';l+=parseInt(e.substr(e.length-2,2))%2==0?"'+u+"":" '}else l+="";else M&&" "!=_?(l+=this.getRefnumHtml(e,u,m,p,_,w,a),w&&(n.residIgLoop[e]=1)):l+=""}else{let t=n.firstAtomObjCls.getFirstAtomObj(n.residues[e]);if(t&&!n.proteins.hasOwnProperty(t.serial)||!S||i||s||I&&"G"==I.substr(0,1))l+="";else{w=!0,1==x&&(T.hasOwnProperty(I+g)&&++O,g=u.replace(f.toString(),"")+"_"+O,T[I+g]=1,E=!0,R=I+g);let t=this.getAdjustedRefnum(k,I,x,A,g,y);f=t.refnum,M=t.bShowRefnum,u=t.refnumStr,p=t.refnumLabel,v=t.refnumLabelNoPostfix,y=f,a=t.bHidelabel,_=p.replace(new RegExp(u,"g"),""),++x,M&&" "!=_?(l+=this.getRefnumHtml(e,u,m,p,_,w,a),w&&(n.residIgLoop[e]=1)):l+=""}}n.resid2refnum[e]=p,n.refnum2residArray.hasOwnProperty(u)?n.refnum2residArray[u].push(e):n.refnum2residArray[u]=[e],n.chainsMapping.hasOwnProperty(t)||(n.chainsMapping[t]={}),n.chainsMapping[t][e]=v,S=I}return l+='',l+="",l+="
    ",l+="",l+="",r+="",{html:l,html3:r}}getAdjustedRefnum(e,t,s,i,n,l){let r,o,a,d;this.icn3d.icn3dui;let c=!1,h=!0;if(e[t+n]){let i=parseInt(e[t+n].start),p=parseInt(e[t+n].end),m=e[t+n].start.replace(i.toString(),""),u=e[t+n].end.replace(p.toString(),""),g=e[t+n].len;s<=(e[t+n].nextStrand?parseInt(g/2+.5):g)?(r=i+s,o=r+m,a=t+o):(r=p-(g+1-s),o=r+u,a=void 0!==e[t+n].nextStrand?e[t+n].nextStrand+o:" "+o),d=t+r,1!=s&&s!=p-1||(c=!0),1==s&&i!=l&&(h=!1,r=0,o="",a="",d="")}else r=0,o="",a="",d="",c=!0;return{refnum:r,refnumStr:o,refnumLabel:a,refnumLabelNoPostfix:d,bHidelabel:c,bShowRefnum:h}}getRefnumHtml(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui,d=parseInt(t).toString(),c=this.getRefnumColor(n),h=l?'style="color:'+c+'"':'style="color:'+c+'; text-decoration: underline overline;"',p=parseInt(d.substr(d.length-2,2));parseInt(d.substr(d.length-3,3));let m="";if(50!=p||l)if(p%2!=0||52==p||r)m+=" ';else{m+="'+(isNaN(t)?p+t.substr(t.length-1,1):p)+""}else o.hAtomsRefnum=a.hashUtilsCls.unionHash(o.hAtomsRefnum,o.residues[e]),m+="'+i.substr(0,1)+""+i.substr(1)+"";return m}getRefnumColor(e){let t=this.icn3d.icn3dui;return"A^"==e?"#FF00FF":"A"==e?"#663399":"A*"==e?"#FFC0CB":"A'"==e?"#9370db":"B"==e?"#ba55d3":"C"==e?"#0000FF":"C'"==e?"#6495ED":"C''"==e?"#006400":"D"==e?"#00FF00":"E"==e?"#FFFF00":"F"==e?"#FFA500":"G"==e?"#FF0000":"G*"==e?"#8B0000":t.htmlCls.GREYB}insertGap(e,t,s,i){let n=this.icn3d;n.icn3dui;let l="";if(void 0!==n.targetGapHash&&n.targetGapHash.hasOwnProperty(t))for(let e=0;e"+s+"";return l}insertGapOverview(e,t){let s=this.icn3d,i="";if(s.icn3dui.cfg.blast_rep_id==e&&void 0!==s.targetGapHash&&s.targetGapHash.hasOwnProperty(t)){i+='
     
    '}return i}setAlternativeSeq(e,t){let s=this.icn3d;s.icn3dui;let i=s.chainsSeq[e];s.giSeq[e]=[];for(let t=0,n=i.length;t1&&s.htmlCls.clickMenuCls.setLogCmd("select sets "+e,!0)}else{let o={};if(void 0!==$(e).attr("domain")||void 0!==$(e).attr("feat")||void 0!==$(e).attr("3ddomain")||void 0!==$(e).attr("custom")){t.hlUpdateCls.hlSummaryDomain3ddomain(e);let a,d,c,h=$(e).attr("from").split(","),p=$(e).attr("to").split(",");r.substr(0,r.indexOf("_"));for(let s=0,i=h.length;s1&&s.htmlCls.clickMenuCls.setLogCmd("select sets "+c,!0)}}else{t.bCtrl||t.bShift?(t.currSelectedSets.push(i),t.selectionCls.selectAChain(r,i,!0,!0)):(t.currSelectedSets=[i],t.selectionCls.selectAChain(r,i,t.bAlignSeq)),t.bAlignSeq?s.htmlCls.clickMenuCls.setLogCmd("select alignChain "+r,!0):s.htmlCls.clickMenuCls.setLogCmd("select chain "+r,!0);let e=t.currSelectedSets.join(" or ");t.currSelectedSets.length>1&&s.htmlCls.clickMenuCls.setLogCmd("select sets "+e,!0)}else t.hlObjectsCls.removeHlObjects(),t.hlUpdateCls.removeHl2D(),$("#"+t.pre+"atomsCustom").val("")}}selectResidues(e,t){let s=this.icn3d,i=s.icn3dui;if(!i.bNode&&(!1!==s.bSelectResidue||s.bShift||s.bCtrl||s.selectionCls.removeSelection(),void 0!==e&&""!==e)){e=e.substr(e.indexOf("_")+1),s.bSelectResidue=!0,$(t).toggleClass("icn3d-highlightSeq");let n=e.substr(e.indexOf("_")+1);if(s.residues.hasOwnProperty(n))if($(t).hasClass("icn3d-highlightSeq")){for(let e in s.residues[n])s.hAtoms[e]=1;if(s.selectedResidues[n]=1,s.bAnnotations&&void 0!==$(t).attr("disease")){let e=$(t).attr("disease"),l=s.applyCenterCls.centerAtoms(i.hashUtilsCls.hash2Atoms(s.residues[n],s.atoms)),r=15;e.length>r&&(e=e.substr(0,r)+"...");let o=s.LABELSIZE,a=i.htmlCls.GREYD;s.analysisCls.addLabel(e,l.center.x,l.center.y,l.center.z,o,a,void 0,"custom")}}else{for(let e in s.residues[n])delete s.hAtoms[e];delete s.selectedResidues[n],s.hlObjectsCls.removeHlObjects()}}}}class Pt{constructor(e){this.icn3d=e}update2DdgmContent(){let e=this.icn3d,t=e.icn3dui,s="";void 0!==t.cfg.mmdbid||void 0!==t.cfg.gi?(s+=e.diagram2dCls.draw2Ddgm(e.interactionData,e.inputid,void 0,!0),s+=e.diagram2dCls.set2DdgmNote(),$("#"+e.pre+"dl_2ddgm").html(s)):e.mmdbidArray&&(void 0!==t.cfg.align||void 0!==t.cfg.chainalign||e.bRealign)&&(s+=e.diagram2dCls.draw2Ddgm(e.interactionData1,e.mmdbidArray[0].toUpperCase(),0,!0),void 0!==e.mmdbid_q&&e.mmdbid_q===e.mmdbid_t?s+=e.diagram2dCls.draw2Ddgm(e.interactionData2,e.mmdbidArray[0].toUpperCase(),1,!0):s+=e.diagram2dCls.draw2Ddgm(e.interactionData2,e.mmdbidArray[1].toUpperCase(),1,!0),s+=e.diagram2dCls.set2DdgmNote(!0),$("#"+e.pre+"dl_2ddgm").html(s))}changeSeqColor(e){let t=this.icn3d,s=t.icn3dui;for(let i=0,n=e.length;i0&&($("#"+e.pre+"dl_2ddgm svg line").attr("stroke","#000000"),$("#"+e.pre+"dl_2ddgm line").attr("stroke-width",1))}removeHlMenus(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"atomsCustom").val(""),$("#"+e.pre+"atomsCustom")[0].blur()}updateHlAll(e,t,s,i){let n=this.icn3d,l=n.icn3dui;n.prevHighlightAtoms=l.hashUtilsCls.cloneHash(n.hAtoms),this.updateHlObjects(i),void 0!==e?this.updateHlSeqInChain(e,s):this.updateHlSeq(void 0,void 0,s),this.updateHl2D(),(void 0===t||t)&&this.updateHlMenus(e)}updateHlObjects(e){let t=this.icn3d;t.icn3dui,t.hlObjectsCls.removeHlObjects(),(t.hAtoms&&t.atoms&&Object.keys(t.hAtoms).length0&&(e=s.defNames2Residues[i]);let t={};if(void 0!==s.defNames2Atoms[i]&&s.defNames2Atoms[i].length>0){for(let e=0,n=s.defNames2Atoms[i].length;e0&&(r=t.firstAtomObjCls.getFirstCalphaAtomObj(l))}let o=void 0!==r&&void 0!==r.color?"#"+r.color.getHexString():"#FFFFFF",a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] rect[class='icn3d-hlnode']"),d=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] rect[class='icn3d-basenode']");void 0!==a&&(t.diagram2dCls.highlightNode("rect",a,d,l),$(a).attr("fill",o)),a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] circle[class='icn3d-hlnode']"),d=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] circle[class='icn3d-basenode']"),void 0!==a&&(t.diagram2dCls.highlightNode("circle",a,d,l),$(a).attr("fill",o)),a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] ellipse[class='icn3d-hlnode']"),void 0!==a&&t.diagram2dCls.highlightNode("ellipse",a,void 0,l),a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] polygon[class='icn3d-hlnode']"),d=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] polygon[class='icn3d-basenode']"),void 0!==a&&(t.diagram2dCls.highlightNode("polygon",a,d,l),$(a).attr("fill",o))}if(void 0!==t.lineArray2d)for(let e=0,i=t.lineArray2d.length;e1){let e={},l=[],o=[],a=[],c=[],h=[],m=[],u=[],g=[],f=[],b=[],C=[],y=[],v={};for(let t=0,s=p.length;t0&&(E=1,t=i.getGraphCls.getNodeTopBottom(c[e],d,void 0,E,g[e]),h[e]=t.nodeArray1,m[e]=t.nodeArray2,d=n.hashUtilsCls.unionHash(d,t.name2node),E=2,t=i.getGraphCls.getNodeTopBottom(c[e],d,void 0,E,y[e]),f[e]=t.nodeArray1,b[e]=t.nodeArray2,d=n.hashUtilsCls.unionHash(d,t.name2node)),x[e]=l[e].length,k[e]=o[e].length,O=Math.max(O,k[e]),R.push(p[e])}let I,T,M,P,D,H=1,F=3*H,L=7*H,N=10,U=10,q=30,$=20;t?(M=(n.utilsCls.sumArray(x)+2*R.length)*(F+L)+4*U+2*q+$*R.length,T=(O+2)*(F+L)+2*N+q):(I=110+$,M=I*R.length,T=(O+2)*(F+L)+2*N),Object.keys(i.chainsMapping).length>0&&(M*=3),t?(i.scatterplotWidth=2*T,D=i.scatterplotWidth,P=n.scatterplotid):(i.linegraphWidth=2*T,D=i.linegraphWidth,P=n.linegraphid),s=0==R.length?"No interactions found for each structure

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

    ",s+="";let j,B=0;E=0,j=this.drawGraphPerType(E,p,t,l,o,a,d,B,I,$,x,F,L,U),B=j.heightFinal,s+=j.html,Object.keys(i.chainsMapping).length>0&&(E=1,j=this.drawGraphPerType(E,p,t,h,m,u,d,B,I,$,x,F,L,U),B=j.heightFinal,s+=j.html,E=2,j=this.drawGraphPerType(E,p,t,f,b,C,d,B,I,$,x,F,L,U),B=j.heightFinal,s+=j.html),s+=""}else if(t){let e,t,l,c,h=p[0],m=o.length,u=a.length,g=1,f=3*g,b=7*g,C=30;t=(m+2)*(f+b)+2*10+C,e=(u+2)*(f+b)+2*10+C,i.scatterplotWidth=2*e,c=i.scatterplotWidth,l=n.scatterplotid,s=r.length>0?"":"No interactions found for these two sets

    ",s+="",s+=this.drawScatterplot_base(o,a,r,d,0),i.lineGraphStr+=i.getGraphCls.updateGraphJson(h,1,o,a,r),s+=""}else{let e=p[0],t=o.length,l=a.length,c=1,h=3*c,m=7*c,u=110,g=10,f=t>l?t*(h+m)+2*g:l*(h+m)+2*g;i.linegraphWidth=2*f,s=r.length>0?"":"No interactions found for these two sets

    ",s+="",s+=this.drawLineGraph_base(o,a,r,d,0),i.lineGraphStr+=i.getGraphCls.updateGraphJson(e,1,o,a,r),s+=""}return i.lineGraphStr+="}\n",i.scatterplotStr=i.lineGraphStr,t?$("#"+i.pre+"scatterplotDiv").html(s):$("#"+i.pre+"linegraphDiv").html(s),s}drawGraphPerType(e,t,s,i,n,l,r,o,a,d,c,h,p,m){let u=this.icn3d;u.icn3dui;let g,f,b="",C=2==t.length&&"2"==t[1].replace(t[0],"");0==e?(g="Interactions in ",f=""):1==e?(g="Common interactions in ",f="_common"):2==e&&(g="Different interactions in ",f="_diff");for(let y=0,v=t.length;y0&&(u.lineGraphStr+=", \n"):u.lineGraphStr+=", \n",u.lineGraphStr+=u.getGraphCls.updateGraphJson(t[y],y+f,i[y],n[y],l[y])}return{heightFinal:o,html:b}}getIdArrayFromNode(e){let t=this.icn3d.icn3dui,s=[];s.push(""),s.push("");let i=e.r.substr(4);return s=s.concat(t.utilsCls.getIdArray(i)),s}drawLineGraph_base(e,t,s,i,n,l,r){let o,a,d=this.icn3d,c=d.icn3dui,h="",p=e.length,m=t.length;p>m?(o=10,a=10*Math.abs(p-m)*.5+10):(a=10,o=10*Math.abs(p-m)*.5+10),l&&(h+=""+l+"");let u=30+n,g=80+n,f="",b={},C={};for(let t=0;t",h+="Interaction of residue "+n.id+" with residue "+l.id+"",h+="")}return h+=f,h}drawScatterplot_base(e,t,s,i,n,l,r,o,a){let d=this.icn3d;d.icn3dui;let c="",h=e.length,p=t.length,m=l?3:7,u=(h+1)*(3+m)+30+40;r&&(c+=""+r+"");let g=n+u-(50+(3+m)),f=40+(3+m),b="",C={},y={};for(let t=0;t"):(h+="",h+="Interaction of residue "+t.id+" with residue "+s.id+"",h+=l?"":"",h+=""))),h}copyStylesInline(e,t){this.icn3d.icn3dui;let s=["svg","g"];for(let i=0;i";return b+=""+e.id+"",o?(b+="",b+=""+g+""):(b+="",b+=""+g+""),b+="",b}getNodeTopBottom(e,t,s,i,n){let l=this.icn3d.icn3dui,r=this,o=[],a=[],d={};for(let s in e){let e=t[s];if(e){if(1==i||2==i){if(e=l.hashUtilsCls.cloneHash(e),1==i){let t=n[s]?n[s]:"-";e.id+="=>"+t}else{let t=n[s]?n[s]:"--";e.id+="==>"+t}d[e.id]=e}"a"==e.s?o.push(e):"b"==e.s?a.push(e):"ab"==e.s&&(o.push(e),a.push(e))}}return o.sort((function(e,t){return r.compNode(e,t)})),a.sort((function(e,t){return r.compNode(e,t,s)})),{nodeArray1:o,nodeArray2:a,name2node:d}}updateGraphJson(e,t,s,i,n){let l=this.icn3d.icn3dui,r="";return r+='"structure'+t+'": {"id": "'+e+'", "nodes1":[',r+=l.utilsCls.getJSONFromArray(s),r+='], \n"nodes2":[',r+=l.utilsCls.getJSONFromArray(i),r+='], \n"links":[',r+=l.utilsCls.getJSONFromArray(n),r+="]}",r}updateGraphColor(){let e=this.icn3d,t=e.icn3dui;if(void 0!==e.graphStr){let s=JSON.parse(e.graphStr),i={};for(let t in e.residues){let s=e.firstAtomObjCls.getFirstAtomObj(e.residues[t]);i[t]=s.color.getHexString().toUpperCase()}let n={};for(let e=0,l=s.nodes.length;e0&&c==e.chain&&(n.resid2ncbi[e.resi]==n.resid2ncbi[p]+1||n.resid2ncbi[e.resi]==n.resid2ncbi[p])&&(o.push('{"source": "'+h+'", "target": "'+u+'", "v": '+d+', "c": "'+f+'"}'),e.ssbegin&&(d=l.htmlCls.ssValue),e.ssend&&(d=l.htmlCls.coilValue)),c=e.chain,h=u,p=e.resi,++a}}return{node:r,link:o}}getHbondLinksForSet(e,t){let s=this.icn3d,i=s.icn3dui,n={},l=parseFloat($("#"+s.pre+"hbondthreshold").val()),r=e,o=r;if(Object.keys(o).length>0&&Object.keys(r).length>0){let e=!1;s.hBondCls.calculateChemicalHbonds(i.hashUtilsCls.intHash2Atoms(s.dAtoms,o,s.atoms),i.hashUtilsCls.intHash2Atoms(s.dAtoms,r,s.atoms),parseFloat(l),e,"graph",!0),n=i.hashUtilsCls.cloneHash(s.resid2Residhash)}return this.getGraphLinks(n,n,i.htmlCls.hbondInsideColor,t,i.htmlCls.hbondValuehbondInsideValue)}getIonicLinksForSet(e,t){let s=this.icn3d,i=s.icn3dui,n={},l=parseFloat($("#"+s.pre+"saltbridgethreshold").val()),r=e,o=r;if(Object.keys(o).length>0&&Object.keys(r).length>0){let e=!1;s.saltbridgeCls.calculateIonicInteractions(i.hashUtilsCls.intHash2Atoms(s.dAtoms,o,s.atoms),i.hashUtilsCls.intHash2Atoms(s.dAtoms,r,s.atoms),parseFloat(l),e,"graph",!0),n=i.hashUtilsCls.cloneHash(s.resid2Residhash)}return this.getGraphLinks(n,n,i.htmlCls.ionicInsideColor,t,i.htmlCls.ionicInsideValue)}getHalogenPiLinksForSet(e,t){let s,i=this.icn3d,n=i.icn3dui,l={},r=e,o=r,a="";return s=parseFloat($("#"+i.pre+"halogenthreshold").val()),Object.keys(o).length>0&&Object.keys(r).length>0&&(i.piHalogenCls.calculateHalogenPiInteractions(n.hashUtilsCls.intHash2Atoms(i.dAtoms,r,i.atoms),n.hashUtilsCls.intHash2Atoms(i.dAtoms,o,i.atoms),parseFloat(s),"graph","halogen",!0),l=n.hashUtilsCls.cloneHash(i.resid2Residhash)),a+=this.getGraphLinks(l,l,n.htmlCls.halogenInsideColor,t,n.htmlCls.halogenInsideValue),s=parseFloat($("#"+i.pre+"picationthreshold").val()),Object.keys(o).length>0&&Object.keys(r).length>0&&(i.piHalogenCls.calculateHalogenPiInteractions(n.hashUtilsCls.intHash2Atoms(i.dAtoms,r,i.atoms),n.hashUtilsCls.intHash2Atoms(i.dAtoms,o,i.atoms),parseFloat(s),"graph","pi-cation",!0),l=n.hashUtilsCls.cloneHash(i.resid2Residhash)),a+=this.getGraphLinks(l,l,n.htmlCls.picationInsideColor,t,n.htmlCls.picationInsideValue),s=parseFloat($("#"+i.pre+"pistackingthreshold").val()),Object.keys(o).length>0&&Object.keys(r).length>0&&(i.piHalogenCls.calculateHalogenPiInteractions(n.hashUtilsCls.intHash2Atoms(i.dAtoms,r,i.atoms),n.hashUtilsCls.intHash2Atoms(i.dAtoms,o,i.atoms),parseFloat(s),"graph","pi-stacking",!0),l=n.hashUtilsCls.cloneHash(i.resid2Residhash)),a+=this.getGraphLinks(l,l,n.htmlCls.pistackingInsideColor,t,n.htmlCls.pistackingInsideValue),a}getContactLinksForSet(e,t,s){let i=this.icn3d;i.icn3dui;let n=[],l="",r="",o={};for(let t in e){let e=i.atoms[t];e.ss==l&&e.chain==r||(Object.keys(o).length>0&&n.push(o),o={}),o[e.serial]=1,l=e.ss,r=e.chain}Object.keys(o).length>0&&n.push(o);let a=n.length,d="";for(let e=0;ed?s?-1:1:ah?1:c0&&Object.keys(a).length>0)){let t,s=c.hBondCls.calculateChemicalHbonds(h.hashUtilsCls.intHash2Atoms(c.dAtoms,d,c.atoms),h.hashUtilsCls.intHash2Atoms(c.dAtoms,a,c.atoms),parseFloat(e),n);n?(c.resid2ResidhashSaltbridge=h.hashUtilsCls.cloneHash(c.resid2Residhash),t="all atoms that have salt bridges with the selected atoms"):(c.resid2ResidhashHbond=h.hashUtilsCls.cloneHash(c.resid2Residhash),t="all atoms that are hydrogen-bonded with the selected atoms");let i={};for(let e in s){i[c.atoms[e].structure+"_"+c.atoms[e].chain+"_"+c.atoms[e].resi]=1}c.hAtoms={};for(let e in i)for(let t in c.residues[e])c.hAtoms[t]=1,c.atoms[t].style2="stick";let l=r+"_auto";c.selectionCls.addCustomSelection(Object.keys(i),l,t,o,!0),c.selectionCls.saveSelectionIfSelected(),c.drawCls.draw()}}showHydrogens(){let e=this.icn3d;if(void 0!==e.icn3dui.cfg.cid)for(let t in e.hAtoms){let s=e.atoms[t];if("H"!==s.elem.substr(0,1)){e.atoms[s.serial].bonds=e.atoms[s.serial].bonds2.concat(),e.atoms[s.serial].bondOrder=e.atoms[s.serial].bondOrder2.concat();for(let t=0,i=e.atoms[s.serial].bonds.length;t0){let i=e.atoms[t].bonds[0];e.atoms[i].bonds.push(s.serial),e.atoms[i].bondOrder&&e.atoms[i].bondOrder.push(1)}e.dAtoms[t]=1}}e.bShowHighlight=!1}hideHydrogens(){let e=this.icn3d;e.icn3dui;for(let t in e.hAtoms){let s=e.atoms[t];if("H"===s.elem.substr(0,1)){if(e.atoms[s.serial].bonds.length>0){let t=e.atoms[s.serial].bonds[0],i=e.atoms[t].bonds?e.atoms[t].bonds.indexOf(s.serial):-1;-1!==i&&(e.atoms[t].bonds.splice(i,1),e.atoms[t].bondOrder&&e.atoms[t].bondOrder.splice(i,1))}delete e.dAtoms[s.serial],delete e.hAtoms[s.serial]}}}hideHbondsContacts(){let e=this.icn3d,t=e.icn3dui,s="set hbonds off";t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.hBondCls.hideHbonds(),s="set salt bridge off",t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.saltbridgeCls.hideSaltbridge(),s="set contact off",t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.contactCls.hideContact(),s="set halogen pi off",t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.piHalogenCls.hideHalogenPi()}showIonicInteractions(e,t,s,i,n,l){let r,o,a,d,c=this.icn3d,h=c.icn3dui;if(!i&&(r="saltbridge",o="salt bridge "+e+" | sets "+t+" "+s+" | "+i,c.opts.saltbridge="yes",a=c.definedSetsCls.getAtomsFromNameArray(t),d=c.definedSetsCls.getAtomsFromNameArray(s),c.firstAtomObjCls.getFirstAtomObj(a),Object.keys(d).length>0&&Object.keys(a).length>0)){let t,s=c.saltbridgeCls.calculateIonicInteractions(h.hashUtilsCls.intHash2Atoms(c.dAtoms,d,c.atoms),h.hashUtilsCls.intHash2Atoms(c.dAtoms,a,c.atoms),parseFloat(e),n);c.resid2ResidhashSaltbridge=h.hashUtilsCls.cloneHash(c.resid2Residhash),t="all atoms that have ionic interactions with the selected atoms";let i={};for(let e in s){i[c.atoms[e].structure+"_"+c.atoms[e].chain+"_"+c.atoms[e].resi]=1}c.hAtoms={};for(let e in i)for(let t in c.residues[e])c.hAtoms[t]=1,c.atoms[t].style2="stick",c.ions.hasOwnProperty(t)&&(c.atoms[t].style2="sphere");let l="saltbridge_auto";c.selectionCls.addCustomSelection(Object.keys(i),l,t,o,!0),c.selectionCls.saveSelectionIfSelected(),c.drawCls.draw()}}showHalogenPi(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(i)return;let a,d,c=l+" "+e+" | sets "+t+" "+s+" | "+i;if(r.opts[l]="yes",a=r.definedSetsCls.getAtomsFromNameArray(t),d=r.definedSetsCls.getAtomsFromNameArray(s),r.firstAtomObjCls.getFirstAtomObj(a),Object.keys(d).length>0&&Object.keys(a).length>0){let t,s=r.piHalogenCls.calculateHalogenPiInteractions(o.hashUtilsCls.intHash2Atoms(r.dAtoms,a,r.atoms),o.hashUtilsCls.intHash2Atoms(r.dAtoms,d,r.atoms),parseFloat(e),n,l);"halogen"==l?(r.resid2ResidhashHalogen=o.hashUtilsCls.cloneHash(r.resid2Residhash),t="all atoms that have halogen bonds with the selected atoms"):"pi-cation"==l?(r.resid2ResidhashPication=o.hashUtilsCls.cloneHash(r.resid2Residhash),t="all atoms that have pi-cation interactions with the selected atoms"):"pi-stacking"==l&&(r.resid2ResidhashPistacking=o.hashUtilsCls.cloneHash(r.resid2Residhash),t="all atoms that have pi-stacking with the selected atoms");let i={};for(let e in s){i[r.atoms[e].structure+"_"+r.atoms[e].chain+"_"+r.atoms[e].resi]=1}r.hAtoms={};for(let e in i)for(let t in r.residues[e])r.hAtoms[t]=1,r.atoms[t].style2="stick",r.ions.hasOwnProperty(t)&&(r.atoms[t].style2="sphere");let h=l+"_auto";r.selectionCls.addCustomSelection(Object.keys(i),h,t,c,!0),r.selectionCls.saveSelectionIfSelected(),r.drawCls.draw()}}showClbonds(){let e=this.icn3d,t=e.icn3dui;e.opts.clbonds="yes";let s=e.applyClbondsCls.applyClbondsOptions();for(let i in s)e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.residues[i]);if(Object.keys(s).length>0){let t="clbonds",i="all atoms that have cross-linkages";e.selectionCls.addCustomSelection(Object.keys(s),t,i,"cross linkage",!0),e.selectionCls.saveSelectionIfSelected(),e.drawCls.draw()}}showSsbonds(){let e=this.icn3d,t=e.icn3dui;e.opts.ssbonds="yes";let s={},i=Object.keys(e.structures);for(let n=0,l=i.length;n0){let t="ssbonds",i="all atoms that have disulfide bonds";e.selectionCls.addCustomSelection(Object.keys(s),t,i,"disulfide bonds",!0),e.selectionCls.saveSelectionIfSelected(),e.drawCls.draw()}}pickCustomSphere(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(i)return;let a,d,c="select zone cutoff "+e+" | sets "+t+" "+s+" | "+i;n&&(c="interactions "+e+" | sets "+t+" "+s+" | "+i,r.opts.contact="yes"),a=r.definedSetsCls.getAtomsFromNameArray(t),d=r.definedSetsCls.getAtomsFromNameArray(s);let h,p,m=this.pickCustomSphere_base(e,a,d,i,n,l,c,!0),u=Object.keys(m.residues);r.hAtoms={};for(let e=0,t=u.length;e1?"structure":v>1?"chain":"residue";let _=[];if(n&&_.push("hbonds"),l&&_.push("salt bridge"),r&&_.push("interactions"),o&&_.push("halogen"),a&&_.push("pi-cation"),d&&_.push("pi-stacking"),s||(p.resids2inter={},p.resids2interAll={}),l){let n=parseFloat($("#"+p.pre+"saltbridgethreshold").val());n&&!isNaN(n)||(n=p.tsIonic),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showIonicInteractions(n,e,t,s,!0,i)),g=m.hashUtilsCls.unionHash(g,p.hAtoms)}if(n){let n=parseFloat($("#"+p.pre+"hbondthreshold").val());n&&!isNaN(n)||(n=p.tsHbond),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHbonds(n,e,t,s,void 0,i)),g=m.hashUtilsCls.unionHash(g,p.hAtoms)}let S,A,x,k,O="";if(n&&(O+=this.exportHbondPairs(i,u)),l&&(O+=this.exportSaltbridgePairs(i,u)),o){let n=parseFloat($("#"+p.pre+"halogenthreshold").val());n&&!isNaN(n)||(n=p.tsHalogen),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHalogenPi(n,e,t,s,i,"halogen")),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportHalogenPiPairs(i,u,"halogen")}if(a){let n=parseFloat($("#"+p.pre+"picationthreshold").val());n&&!isNaN(n)||(n=p.tsPication),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHalogenPi(n,e,t,s,i,"pi-cation")),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportHalogenPiPairs(i,u,"pi-cation")}if(d){let n=parseFloat($("#"+p.pre+"pistackingthreshold").val());n&&!isNaN(n)||(n=p.tsPistacking),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHalogenPi(n,e,t,s,i,"pi-stacking")),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportHalogenPiPairs(i,u,"pi-stacking")}if(r){let n=b?c:parseFloat($("#"+p.pre+"contactthreshold").val());if(n&&!isNaN(n)||(n=p.tsContact),1!=e.length||1!=t.length||e[0]!=t[0])s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.pickCustomSphere(n,e,t,s,!0,i)),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportSpherePairs(!0,i,u);else{if(!s){let l={},o={};if(b){let e=!0,t=p.showInterCls.pickCustomSphere_base(n,C,y,s,!0,void 0,void 0,!0,e);l=m.hashUtilsCls.unionHash(l,t.residues);for(let e in t.resid2Residhash)o[e]=m.hashUtilsCls.unionHash(o[e],t.resid2Residhash[e])}else{let r=[],a="",d="",c={};for(let e in C){let t=p.atoms[e];t.ss==a&&t.chain==d||(Object.keys(c).length>0&&r.push(c),c={}),c[t.serial]=1,a=t.ss,d=t.chain}Object.keys(c).length>0&&r.push(c);let h=r.length;A="interactions "+n+" | sets "+e+" "+t+" | true",p.opts.contact="yes";for(let e=0;e
    ",T=p.resid2specCls.atoms2residues(Object.keys(C)),M=p.resid2specCls.atoms2residues(Object.keys(y)),P="select "+p.resid2specCls.residueids2spec(T),D="select "+p.resid2specCls.residueids2spec(M);I+="Set 1: "+e+'
    ',I+="Set 2: "+t+'

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

    ',I+='
    Note: Each checkbox below selects the corresponding residue. You can click "Save Selection" in the "Select" menu to save the selection and click on "Highlight" button to clear the checkboxes.

    ';let U=I;if(("graph"==i||"linegraph"==i||"scatterplot"==i||b)&&(I=""),I+=O,"save1"==i||"save2"==i){I=U;let e="";"save1"==i?e="Set 1":"save2"==i&&(e="Set 2"),I+='

    Interactions Sorted on '+e+':
    ';let t=this.getAllInteractionTable(i);I+=t.html,h=t.bondCnt,$("#"+p.pre+"dl_interactionsorted").html(I),m.htmlCls.dialogCls.openDlg("dl_interactionsorted","Show sorted interactions")}else if("view"==i)$("#"+p.pre+"dl_allinteraction").html(I),m.htmlCls.dialogCls.openDlg("dl_allinteraction","Show interactions");else if("linegraph"==i){m.htmlCls.dialogCls.openDlg("dl_linegraph","Show interactions between two lines of residue nodes"),p.graphStr=p.getGraphCls.getGraphData(C,y,e,t,I,u),p.bLinegraph=!0;let s=p.lineGraphCls.drawLineGraph(p.graphStr);$("#"+p.pre+"linegraphDiv").html(s)}else if("scatterplot"==i){m.htmlCls.dialogCls.openDlg("dl_scatterplot","Show interactions as scatterplot"),p.graphStr=p.getGraphCls.getGraphData(C,y,e,t,I,u),p.bScatterplot=!0;let s=p.lineGraphCls.drawLineGraph(p.graphStr,!0);$("#"+p.pre+"scatterplotDiv").html(s)}else if(b){m.htmlCls.dialogCls.openDlg("dl_contactmap","Show contact map");let s=!0,i=p.getGraphCls.getGraphData(C,y,e,t,I,u,s);p.bContactMap=!0;let n=p.contactMapCls.drawContactMap(i);$("#"+p.pre+"contactmapDiv").html(n)}else if("graph"==i)if(p.graphStr=p.getGraphCls.getGraphData(C,y,e,t,I,u),p.bGraph=!0,Object.keys(y).length+Object.keys(C).length>Object.keys(p.dAtoms).length&&(p.graphStr=p.selectionCls.getGraphDataForDisplayed()),void 0===p.bD3){await m.getAjaxPromise("https://www.ncbi.nlm.nih.gov/Structure/icn3d/script/d3v4-force-all.min.js","script"),p.bD3=!0,$("#"+m.svgid).empty(),m.htmlCls.dialogCls.openDlg("dl_graph","Force-directed graph"),p.drawGraphCls.drawGraph(p.graphStr,p.pre+"dl_graph")}else $("#"+m.svgid).empty(),m.htmlCls.dialogCls.openDlg("dl_graph","Force-directed graph"),p.drawGraphCls.drawGraph(p.graphStr,p.pre+"dl_graph");return{interactionTypes:_.toString(),bondCnt:h}}clearInteractions(){let e=this.icn3d;e.icn3dui,e.lines.hbond=[],e.hbondpnts=[],e.lines.saltbridge=[],e.saltbridgepnts=[],e.lines.contact=[],e.contactpnts=[],e.lines.halogen=[],e.lines["pi-cation"]=[],e.lines["pi-stacking"]=[],e.halogenpnts=[],e.picationpnts=[],e.pistackingpnts=[]}resetInteractionPairs(){let e=this.icn3d;e.icn3dui,e.bHbondCalc=!1,e.showInterCls.hideHbondsContacts(),e.hlUpdateCls.clearHighlight(),e.resids2inter={},e.resids2interAll={}}async retrieveInteractionData(){let e=this.icn3d,t=e.icn3dui;if(!e.b2DShown)if(void 0!==t.cfg.align){let s=Object.keys(e.structures);if(2==t.cfg.atype){let t=!0;await e.alignParserCls.downloadAlignment(s[0]+","+s[1],t)}await e.ParserUtilsCls.set2DDiagramsForAlign(s[0].toUpperCase(),s[1].toUpperCase())}else void 0!==t.cfg.chainalign?(Object.keys(e.structures),await e.ParserUtilsCls.set2DDiagramsForChainalign(e.chainidArray)):e.ParserUtilsCls.download2Ddgm(e.inputid.toUpperCase())}getAllInteractionTable(e){let t=this.icn3d,s=t.icn3dui,i=[],n=Object.keys(t.resids2inter);("save1"==e||"save2"==e)&&n.sort((function(t,i){return s.utilsCls.compResid(t,i,e)}));let l,r,o="",a="",d="",c="",h="",p="",m="",u="",g="",f=0,b=0,C=0,y=0,v=0,w=0,_="";for(let s=0,S=n.length;s0&&l!=a&&(i.push({res1:a,res2:_,cntHbond:f,cntIonic:b,cntContact:C,cntHalegen:y,cntPication:v,cntPistacking:w}),o+=this.getInteractionPerResidue(d,c,h,p,m,u,g,f,b,C,y,v,w),c="",h="",p="",m="",u="",g="",f=0,b=0,C=0,y=0,v=0,w=0,_=""),x=t.resids2inter[S].hbond,k=this.getInteractionPairDetails(x,e,"hbond"),c+=k.html,f+=k.cnt,k.cnt>0&&(_+=r+":hbond_"+k.cnt+" "),x=t.resids2inter[S].ionic,k=this.getInteractionPairDetails(x,e,"ionic"),h+=k.html,b+=k.cnt,k.cnt>0&&(_+=r+":ionic_"+k.cnt+" "),x=t.resids2inter[S].contact,k=this.getContactPairDetails(x,e,"contact"),p+=k.html,C+=k.cnt,k.cnt>0&&(_+=r+":contact_"+k.cnt+" "),x=t.resids2inter[S].halogen,k=this.getInteractionPairDetails(x,e,"halogen"),m+=k.html,y+=k.cnt,k.cnt>0&&(_+=r+":halogen_"+k.cnt+" "),x=t.resids2inter[S]["pi-cation"],k=this.getInteractionPairDetails(x,e,"pi-cation"),u+=k.html,v+=k.cnt,k.cnt>0&&(_+=r+":pi-cation_"+k.cnt+" "),x=t.resids2inter[S]["pi-stacking"],k=this.getInteractionPairDetails(x,e,"pi-stacking"),g+=k.html,w+=k.cnt,k.cnt>0&&(_+=r+":pi-stacking_"+k.cnt+" "),a=l,d=O}i.push({res1:a,res2:_,cntHbond:f,cntIonic:b,cntContact:C,cntHalegen:y,cntPication:v,cntPistacking:w}),o+=this.getInteractionPerResidue(d,c,h,p,m,u,g,f,b,C,y,v,w);let S="";if(n.length>0){S+='
    ',S+="",S+="",S+="",S+="",S+="";let e='';S+=e,S+=e,S+='',S+=e,S+=e,S+=e,S+="",S+="",S+=o,S+="
    Residue# Hydrogen
    Bond
    # Salt Bridge
    /Ionic Interaction
    # Contact# Halogen
    Bond
    # π-Cation# π-StackingHydrogen Bond (backbone atoms: @CA, @N, @C, @O)Salt Bridge/Ionic InteractionContactHalogen Bondπ-Cationπ-Stacking
    Atom1Atom2Distance(Å)Highlight in 3D
    Atom1Atom2# ContactsMin Distance(Å)C-alpha Distance(Å)Highlight in 3D

    "}return{html:S,bondCnt:i}}getInteractionPerResidue(e,t,s,i,n,l,r,o,a,d,c,h,p){this.icn3d.icn3dui;let m="";m+=''+e[3]+e[2]+""+o+""+a+""+d+""+c+""+h+""+p+"";let u=[t,s,i,n,l,r];for(let e in u){m+=''+u[e]+"
    "}return m+="",m}getInteractionPairDetails(e,t,s){let i=this.icn3d;i.icn3dui;let n="",l=0,r='    ';if(void 0!==e)for(let a in e){let d=a.split(","),c="save1"==t?d[0]:d[1],h="save1"==t?d[1]:d[0],p=i.getGraphCls.convertLabel2Resid(c),m=i.firstAtomObjCls.getFirstAtomObj(i.residues[p]),u=m.color?m.color.getHexString():"",g=i.getGraphCls.convertLabel2Resid(h),f=i.firstAtomObjCls.getFirstAtomObj(i.residues[g]),b=f.color?f.color.getHexString():"",C=Math.sqrt(e[a]).toFixed(1);n+=' '+c+r+u+o+' '+h+r+b+o+''+C+"",n+='',n+="",++l}return{html:n,cnt:l}}getContactPairDetails(e,t){let s=this.icn3d;s.icn3dui;let i="",n=0,l='    ';if(void 0!==e)for(let o in e){let a=o.split(","),d="save1"==t?a[0]:a[1],c="save1"==t?a[1]:a[0],h=s.getGraphCls.convertLabel2Resid(d),p=s.firstAtomObjCls.getFirstAtomObj(s.residues[h]),m=p.color?p.color.getHexString():"",u=s.getGraphCls.convertLabel2Resid(c),g=s.firstAtomObjCls.getFirstAtomObj(s.residues[u]),f=g.color?g.color.getHexString():"",b=e[o].split("_"),C=b[0],y=b[1],v=b[2],w=b[3],_=b[4];i+=' '+d+"@"+v+l+m+r+' '+c+"@"+w+l+f+r+''+_+''+C+''+y+"",i+='',i+="",n+=parseInt(_)}return{html:i,cnt:n}}exportInteractions(){var e=this.icn3d;e.icn3dui;let t='

    Interacting residues:
    ';for(let s in e.chainname2residues)for(let i in e.chainname2residues[s]){let n=s.substr(0,s.indexOf("_"))+"_"+i.substr(0,i.indexOf(" "));t+=""}t+="
    Base Chain: ResiduesInteracting Chain
    "+s+": ",t+=e.resid2specCls.residueids2spec(e.chainname2residues[s][i]),t+=""+n+"

    ";let s=e.inputid?e.inputid:"custom";e.saveFileCls.saveFile(s+"_interactions.html","html",t)}exportSsbondPairs(){var e=this.icn3d;e.icn3dui;let t="",s=0;for(let i in e.structures){let n=e.ssbondpnts[i];if(void 0===n)break;for(let e=0,i=n.length;e"+n[e]+" Cys"+n[e+1]+" Cys",++s}}let i='

    '+s+" disulfide pairs:

    ";i+=t,i+="
    Residue ID 1Residue ID 2

    ";let n=e.inputid?e.inputid:"custom";e.saveFileCls.saveFile(n+"_disulfide_pairs.html","html",i)}exportClbondPairs(){var e=this.icn3d;e.icn3dui;let t="",s=0,i={};for(let n in e.structures){let l=e.clbondpnts[n];if(void 0===l)break;for(let n=0,r=l.length;n"+r+" "+i.resn+""+o+" "+n.resn+"",++s}i[r+"_"+o]=1,i[o+"_"+r]=1}}let n='

    '+s+" cross-linkage pairs:

    ";n+=t,n+="
    Residue ID 1Residue ID 2

    ";let l=e.inputid?e.inputid:"custom";e.saveFileCls.saveFile(l+"_crosslinkage_pairs.html","html",n)}exportHbondPairs(e,t){var s=this.icn3d,i=s.icn3dui;let n="",l=0,r='    ';for(let t in s.resid2ResidhashHbond){let i=s.getGraphCls.convertLabel2Resid(t),a=s.firstAtomObjCls.getFirstAtomObj(s.residues[i]),d=a.color?a.color.getHexString():"";for(let i in s.resid2ResidhashHbond[t]){let a=s.getGraphCls.convertLabel2Resid(i),c=s.firstAtomObjCls.getFirstAtomObj(s.residues[a]),h=c.color?c.color.getHexString():"",p=Math.sqrt(s.resid2ResidhashHbond[t][i]).toFixed(1);n+=' '+t+r+d+o+' '+i+r+h+o+''+p+"","view"==e&&(n+=''),n+="",++l}}let a='

    '+l+" hydrogen bond pairs (backbone atoms: @CA, @N, @C, @O):

    ";if(l>0&&(a+="
    ","view"==e&&(a+=''),a+="",a+=n,a+="
    Atom 1Atom 2Distance(Å)Highlight in 3D

    "),"graph"==e||"linegraph"==e||"scatterplot"==e){return s.getGraphCls.getGraphLinks(s.resid2ResidhashHbond,s.resid2ResidhashHbond,i.htmlCls.hbondColor,t,i.htmlCls.hbondValue)}return a}exportSaltbridgePairs(e,t){var s=this.icn3d,i=s.icn3dui;let n="",l=0,r='    ';for(let t in s.resid2ResidhashSaltbridge){let i=s.getGraphCls.convertLabel2Resid(t),a=s.firstAtomObjCls.getFirstAtomObj(s.residues[i]),d=a.color?a.color.getHexString():"";for(let i in s.resid2ResidhashSaltbridge[t]){let a=s.getGraphCls.convertLabel2Resid(i),c=s.firstAtomObjCls.getFirstAtomObj(s.residues[a]),h=c.color?c.color.getHexString():"",p=Math.sqrt(s.resid2ResidhashSaltbridge[t][i]).toFixed(1);n+=' '+t+r+d+o+' '+i+r+h+o+''+p+"","view"==e&&(n+=''),n+="",++l}}let a='

    '+l+" salt bridge/ionic interaction pairs:

    ";if(l>0&&(a+="
    ","view"==e&&(a+=''),a+="",a+=n,a+="
    Atom 1Atom 2Distance(Å)Highlight in 3D

    "),"graph"==e||"linegraph"==e||"scatterplot"==e){return s.getGraphCls.getGraphLinks(s.resid2ResidhashSaltbridge,s.resid2ResidhashSaltbridge,i.htmlCls.ionicColor,t,i.htmlCls.ionicValue)}return a}exportHalogenPiPairs(e,t,s){var i=this.icn3d,n=i.icn3dui;let l,r,o,a="",d=0,c='    ';"halogen"==s?(l=i.resid2ResidhashHalogen,r=n.htmlCls.halogenColor,o=n.htmlCls.halogenValue):"pi-cation"==s?(l=i.resid2ResidhashPication,r=n.htmlCls.picationColor,o=n.htmlCls.picationValue):"pi-stacking"==s&&(l=i.resid2ResidhashPistacking,r=n.htmlCls.pistackingColor,o=n.htmlCls.pistackingValue);for(let t in l){let n=i.getGraphCls.convertLabel2Resid(t),r=i.firstAtomObjCls.getFirstAtomObj(i.residues[n]),o=r.color?r.color.getHexString():"";for(let n in l[t]){let r=i.getGraphCls.convertLabel2Resid(n),p=i.firstAtomObjCls.getFirstAtomObj(i.residues[r]),m=p.color?p.color.getHexString():"",u=Math.sqrt(l[t][n]).toFixed(1);a+=' '+t+c+o+h+' '+n+c+m+h+''+u+"","view"==e&&(a+=''),a+="",++d}}let p='

    '+d+" "+s+" pairs:

    ";if(d>0&&(p+="
    ","view"==e&&(p+=''),p+="",p+=a,p+="
    Atom 1Atom 2Distance(Å)Highlight in 3D

    "),"graph"==e||"linegraph"==e||"scatterplot"==e){return i.getGraphCls.getGraphLinks(l,l,r,t,o)}return p}exportSpherePairs(e,t,s){var i=this.icn3d,n=i.icn3dui;let l="",r=0,o=e?i.resid2ResidhashInteractions:i.resid2ResidhashSphere,a='    ';for(let s in o){let n=i.getGraphCls.convertLabel2Resid(s),c=i.firstAtomObjCls.getFirstAtomObj(i.residues[n]),h=c.color?c.color.getHexString():"";for(let n in o[s]){let p=i.getGraphCls.convertLabel2Resid(n),m=i.firstAtomObjCls.getFirstAtomObj(i.residues[p]),u=m.color?m.color.getHexString():"",g=o[s][n].split("_"),f=g[0],b=g[1];c=g[2],m=g[3];let C=g[4];e?(l+=' '+s+"@"+c+a+h+d+' '+n+"@"+m+a+u+d+''+C+''+f+''+b+"","view"==t&&(l+=''),l+=""):l+=""+s+""+n+''+C+''+f+''+b+"",++r}}let c='

    '+r+" residue pairs in "+(e?"the contacts":"sphere")+":

    ";if(r>0&&(e?(c+='
    ',"view"==t&&(c+=''),c+=""):c+='
    Residue 1Residue 2Num ContactsMin Distance(Å)C-alpha Distance(Å)Highlight in 3D
    ',c+=l,c+="
    Residue 1Residue 2Num ContactsMin Distance(Å)C-alpha Distance(Å)

    "),"graph"==t||"linegraph"==t||"scatterplot"==t||"calpha"==t||"cbeta"==t||"heavyatoms"==t){return i.getGraphCls.getGraphLinks(o,o,n.htmlCls.contactColor,s,n.htmlCls.contactValue)}return c}}class Ut{constructor(e){this.icn3d=e}drawGraph(e,t){var s=this.icn3d,i=s.icn3dui;if(void 0===n)var n=d3;var l=JSON.parse(e),r=$("#"+t).width(),o=$("#"+t).height(),a=isNaN(r)?300:1*r,d=isNaN(o)?300:1*o,c=r,h=o,p=d3.select("#"+i.svgid).attr("width",r).attr("height",o).attr("viewBox","0,0,"+a+","+d);p.selectAll(".g-main").remove();var m=p.append("g").classed("g-main",!0),u=m.append("rect").attr("width",c).attr("height",h).style("fill","#FFF"),g=m.append("g"),f=n.zoom().on("zoom",(function(){g.attr("transform",n.event.transform)}));if(m.call(f),l.links){for(var b=[],C={},y=0,v=l.nodes.length;y0?n.structures[0]:n.defaultPdbId;p=10*(a.length+2)+20+30,h=10*(d.length+2)+20+30,t?(n.alignerrormapWidth=2*h,u=n.alignerrormapWidth,m=l.alignerrormapid):(n.contactmapWidth=2*h,u=n.contactmapWidth,m=l.contactmapid),i=o.length>0?"":"No interactions found for these two sets

    ",i+="";if(t){n.hex2id={};let e=29/s;n.hex2skip={};let t=1e3;for(let s=0;se&&(n.hex2skip[d]=c)}}if(i+=n.lineGraphCls.drawScatterplot_base(a,d,o,c,0,!0,void 0,void 0,t),g+=n.getGraphCls.updateGraphJson(f,1,a,d,o),i+="",g+="}\n",t){n.alignerrormapStr=g,$("#"+n.pre+"alignerrormapDiv").html(i);let e=$("#"+l.alignerrormapid+"_scale").val();$("#"+l.alignerrormapid).attr("width",(n.alignerrormapWidth*parseFloat(e)).toString()+"px")}else n.contactmapStr=g,$("#"+n.pre+"contactmapDiv").html(i);return i}}class $t{constructor(e){this.icn3d=e}async downloadAlignment(e,t){let s=this.icn3d,i=s.icn3dui,n=this;s.opts.proteins="c alpha trace";let l=e.split(","),r="ids="+e,o=i.htmlCls.baseUrl+"vastplus/vastplus.cgi?v=3&cmd=c&b=1&s=1&w3d&"+r;void 0!==i.cfg.inpara&&(o+=i.cfg.inpara),s.pdbid_chain2title={},void 0===s.chainids2resids&&(s.chainids2resids={});let a={},d="These two MMDB IDs "+l+' do not have 3D alignment data in the VAST+ database. You can try the VAST alignment by visiting the VAST+ page https://www.ncbi.nlm.nih.gov/Structure/vastplus/vastplus.cgi?uid=[PDB ID] (e.g., uid=1KQ2), and clicking "Original VAST"',c=await i.getAjaxPromise(o,"jsonp",!0,d);if(a=c.seqalign,void 0===a)return alert(d),!1;s.pdbid_molid2chain={},s.chainsColor={};for(let e=0,t=2;e5){let t=!1,s=!0;d=await r.pdbParserCls.loadPdbData(e,n,!1,t,"target",h,s)}else{let t=!0;d=await r.mmdbParserCls.parseMmdbData(e,"target",i[0],0,h,t)}for(let e=0,s=t.length;e5){let s=!0,i=!0;c=await r.pdbParserCls.loadPdbData(t[e],l,!1,s,"query",h,i)}else{let s=!0;c=await r.mmdbParserCls.parseMmdbData(t[e],"query",i[e+1],e,h,s)}d=o.hashUtilsCls.unionHash(d,c)}if(o.cfg.resnum)await r.realignParserCls.realignChainOnSeqAlign(s,i);else if(o.cfg.resdef)await r.realignParserCls.realignChainOnSeqAlign(s,i,void 0,!0);else{await r.pdbParserCls.applyCommandDssp(!0);for(let e in r.pdbChainIndexHash){let t=r.pdbChainIndexHash[e].split("_");l=t[0],t[1],n=t[2],t[3],a.transformStructure(l,e-1,"query")}let e=[],t=[],c=[],h=o.htmlCls.baseUrl+"vastdyn/vastdyn.cgi",p=o.htmlCls.baseUrl+"tmalign/tmalign.cgi";for(let s in r.afChainIndexHash){let i=r.afChainIndexHash[s].split("_");l=i[0];let a=i[1];n=i[2];let d,m=i[3];if("tmalign"!=o.cfg.aligntool){let e={domains1:r.domain3dCls.getDomainJsonForAlign(r.chains[l+"_"+a]),domains2:r.domain3dCls.getDomainJsonForAlign(r.chains[n+"_"+m])};d=o.getAjaxPostPromise(h,e)}else{let e={pdb_query:r.saveFileCls.getAtomPDB(r.chains[l+"_"+a]),pdb_target:r.saveFileCls.getAtomPDB(r.chains[n+"_"+m])};d=o.getAjaxPostPromise(p,e)}e.push(d),t.push(s-1),c.push(l)}let m=Promise.allSettled(e);try{let e=await m;await a.downloadChainalignmentPart2b(s,i,d,e,t,n,c)}catch(e){r.bRender&&alert("These structures can NOT be aligned to each other...")}}}async downloadChainalignmentPart2b(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui;for(let e=0,t=i.length;ed&&(d=n[t[0]],o=t[0]),n[t[1]]>d&&(d=n[t[1]],o=t[1])}let c={},h={},p={},m={};for(let e in l){let t,s,i=e.split("_"),n=l[e].split(","),r=n[2];o==i[0]?(t=i[0],s=i[1]):o==i[1]?(t=i[1],s=i[0]):(t=i[0],s=i[1]),p[t]=1,p.hasOwnProperty(s)||(p[s]=1,m[e]=l[e],a="target",this.transformStructure(t,r,a),a="query",this.transformStructure(s,r,a),c[n[0]]=1,c[n[1]]=1)}for(let e in m)if(void 0!==s.q_rotation){let t=m[e].split(","),n=[t[1],t[0],t[2]],l=s.setSeqAlignCls.setSeqAlignChain(void 0,void 0,n);h=i.hashUtilsCls.unionHash(h,l);let r=!1,o=i.htmlCls.alignSeqCls.getAlignSequencesAnnotations(Object.keys(s.alnChains),void 0,void 0,!1,void 0,r),a=$("#"+s.pre+"dl_sequence2").html();$("#"+s.pre+"dl_sequence2").html(a+o.sequencesHtml),$("#"+s.pre+"dl_sequence2").width(i.htmlCls.RESIDUE_WIDTH*o.maxSeqCnt+200)}s.dAtoms=i.hashUtilsCls.cloneHash(h),s.hAtoms=i.hashUtilsCls.cloneHash(h);let u="protein_aligned";s.selectionCls.saveSelection(u,u),s.opts.color="identity",s.setColorCls.setColorByOptions(s.opts,s.hAtoms),i.htmlCls.dialogCls.openDlg("dl_alignment","Select residues in aligned sequences"),s.drawCls.draw(),s.transformCls.zoominSelection(),s.hlUpdateCls.updateHlAll()}transformStructure(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=n.structures[e];for(let e=0,o=r.length;e2){let e=i.firstAtomObjCls.getResiduesFromAtoms(s),t="protein_aligned",n="protein aligned",l="select "+i.resid2specCls.residueids2spec(Object.keys(e));i.selectionCls.addCustomSelection(Object.keys(e),t,n,l,!0)}i.hlUpdateCls.updateHlAll(),void 0!==n.cfg.rotate&&i.resizeCanvasCls.rotStruc(n.cfg.rotate,!0),i.html2ddgm="",n.cfg.show2d&&i.bFullUi&&(n.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions"),i.bFullUi&&(i.bChainAlign?await i.ParserUtilsCls.set2DDiagramsForChainalign(t):i.ParserUtilsCls.download2Ddgm(i.inputid.toUpperCase())))}addPostfixForChainids(e){let t=this.icn3d;t.icn3dui;let s={};for(let i=0,n=e.length;i5?(c="https://alphafold.ebi.ac.uk/files/AF-"+i.mmdbid_t+"-F1-model_"+i.AFUniprotVersion+".pdb",d=n.getAjaxPromise(c,"text")):(c=n.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+n.cfg.bu+"&uid="+i.mmdbid_t,void 0!==n.cfg.inpara&&(c+=n.cfg.inpara),d=n.getAjaxPromise(c,"jsonp")),h.push(d),i.ParserUtilsCls.setYourNote(e.toUpperCase()+" in iCn3D"),i.pdbid_chain2title={},void 0===i.chainids2resids&&(i.chainids2resids={}),i.afChainIndexHash={},i.pdbChainIndexHash={};for(let e=1,t=r.length;e5?(t="https://alphafold.ebi.ac.uk/files/AF-"+i.mmdbid_q+"-F1-model_"+i.AFUniprotVersion+".pdb",s=n.getAjaxPromise(t,"text")):(t=n.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+n.cfg.bu+"&uid="+i.mmdbid_q,void 0!==n.cfg.inpara&&(t+=n.cfg.inpara),s=n.getAjaxPromise(t,"jsonp")),h.push(s)}for(let e=1,t=r.length;e0?o[e]+","+o[0]:void 0;if("tmalign"!=n.cfg.aligntool&&4==i.mmdbid_t.length&&4==i.mmdbid_q.length){let r;r=o.length>0?n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?domainpairs="+l:n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainpairs="+t;let a=n.getAjaxPromise(r,"jsonp");h.push(a),i.pdbChainIndexHash[e]=s+"_"+i.chain_q+"_"+i.mmdbid_t+"_"+i.chain_t}else i.afChainIndexHash[e]=i.mmdbid_q+"_"+i.chain_q+"_"+i.mmdbid_t+"_"+i.chain_t}}let p=Promise.allSettled(h);try{let e=await p;await l.parseChainAlignData(e,r,i.mmdbid_t,i.chain_t)}catch(e){let t="tmalign"==n.cfg.aligntool?"TM-align":"VAST";i.bRender&&alert("These chains can not be aligned by "+t+". You can specify the residue range and try it again...")}}async parseChainAlignData(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=e[0].value,o="HEADER "+s+"\n";isNaN(s)&&s.length>5&&(r=o+r),n.t_trans_add=[],n.q_trans_sub=[],"tmalign"==l.cfg.aligntool&&(n.q_trans_add=[]),n.q_rotation=[],n.qt_start_end=[],n.mmdbidArray=[],n.mmdbidArray.push(s);let a=[];for(let s=1,i=t.length;s5&&(i=o+i),void 0===i||-1!==JSON.stringify(i).indexOf("Oops there was a problem"))return void alert("The coordinate data can NOT be retrieved for the structure "+r+"...");n.mmdbidArray.push(r),a.push(i)}let d=0;for(let r=1,o=t.length;r";"tmalign"==o.cfg.aligntool&&(n+="TM-score: "+e[0].score.toPrecision(4)+"

    "),$("#"+r.pre+"dl_rmsd").html(n),o.cfg.bSidebyside||o.htmlCls.dialogCls.openDlg("dl_rmsd","RMSD of alignment"),a=!0}return a}async loadOpmDataForChainalign(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=this;if(l.cfg.resnum||l.cfg.resdef)n.bCommandLoad||n.init(),await this.downloadChainalignmentPart2(e,t,void 0,s);else{let o=l.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?mmdbids2opm="+i.join("','");try{let i=(await l.getAjaxPromise(o,"jsonp")).mmdbid;if(n.selectedPdbid=i,i){let o="https://opm-assets.storage.googleapis.com/pdb/"+i.toLowerCase()+".pdb";try{let a=await l.getAjaxPromise(o,"text");n.bOpm=!0;let d=!0,c=n.loadPDBCls.loadPDB(a,i,n.bOpm,d);$("#"+n.pre+"selectplane_z1").val(n.halfBilayerSize),$("#"+n.pre+"selectplane_z2").val(-n.halfBilayerSize),$("#"+n.pre+"extra_mem_z").val(n.halfBilayerSize),$("#"+n.pre+"intra_mem_z").val(-n.halfBilayerSize),n.bCommandLoad||n.init(),await r.downloadChainalignmentPart2(e,t,c,s)}catch(i){return n.bCommandLoad||n.init(),void await r.downloadChainalignmentPart2(e,t,void 0,s)}}else n.bCommandLoad||n.init(),await r.downloadChainalignmentPart2(e,t,void 0,s)}catch(i){return n.bCommandLoad||n.init(),void await r.downloadChainalignmentPart2(e,t,void 0,s)}}}async downloadMmdbAf(e,t,s){let i=this.icn3d,n=i.icn3dui,l=this;i.structArray=i.structures?Object.keys(i.structures):[],0==i.structArray.length?i.init():(i.resetConfig(),i.bResetAnno=!0,i.bResetSets=!0);let r=e.split(","),o=[];for(let e=0,t=r.length;e5?(t="https://alphafold.ebi.ac.uk/files/AF-"+l+"-F1-model_"+i.AFUniprotVersion+".pdb",s=n.getAjaxPromise(t,"text")):(t=n.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+n.cfg.bu+"&uid="+l,void 0!==n.cfg.inpara&&(t+=n.cfg.inpara),s=n.getAjaxPromise(t,"jsonp")),a.push(s)}i.ParserUtilsCls.setYourNote(i.structArray+" in iCn3D"),i.ParserUtilsCls.showLoading();let d=Promise.allSettled(a);try{let e=await d;await l.parseMMdbAfData(e,o,t,s),void 0===s&&i.ParserUtilsCls.hideLoading()}catch(e){alert("There are some problems in retrieving the coordinates...")}}async parseMMdbAfData(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=[];for(let s=0,i=t.length;s5&&(i=n+i),void 0===i||-1!==JSON.stringify(i).indexOf("Oops there was a problem"))return void alert("The coordinate data can NOT be retrieved for the structure "+t[s]+"...");r.push(i)}let o={},a={},d=!1;n.opts.color=n.structArray.length>1?"structure":t[0].length>5?"confidence":"chain";for(let e=0,i=t.length;e5){let s=!1;a=await n.pdbParserCls.loadPdbData(r[e],t[e],!1,c,i,d,s)}else{let t=!0;a=await n.mmdbParserCls.parseMmdbData(r[e],i,void 0,void 0,d,t)}o=l.hashUtilsCls.unionHash(o,a)}if(n.structArray.length>1&&(n.opts.color="structure"),n.setColorCls.setColorByOptions(n.opts,n.atoms),await n.ParserUtilsCls.renderStructure(),void 0!==l.cfg.rotate&&n.resizeCanvasCls.rotStruc(l.cfg.rotate,!0),s&&l.cfg.matchedchains){let e=!0,t=!0;await n.realignParserCls.realignChainOnSeqAlign(void 0,n.chainidArray,e,t),$("#"+n.pre+"dl_annotations").html(""),n.bAnnoShown=!1,$("#"+n.pre+"dl_selectannotations").dialog("isOpen")&&$("#"+n.pre+"dl_selectannotations").dialog("close")}else if(void 0!==i){let e=Object.keys(n.structures);await n.vastplusCls.vastplusAlign(e,i)}}}class Bt{constructor(e){this.icn3d=e}dsn6Parser(e,t,s){this.icn3d.icn3dui;let i="https://edmaps.rcsb.org/maps/"+e.toLowerCase()+"_"+t+".dsn6";this.dsn6ParserBase(i,t,s)}dsn6ParserBase(e,t,s){let i=this.icn3d;i.icn3dui;let n=this;if("2fofc"==t&&i.bAjax2fofc)i.mapData.sigma2=s,i.setOptionCls.setOption("map",t);else if("fofc"==t&&i.bAjaxfofc)i.mapData.sigma=s,i.setOptionCls.setOption("map",t);else{let l=new XMLHttpRequest;l.open("GET",e,!0),l.responseType="arraybuffer",l.onreadystatechange=function(){if(4==this.readyState)if(200==this.status){let e=l.response;n.loadDsn6Data(e,t,s),"2fofc"==t?i.bAjax2fofc=!0:"fofc"==t&&(i.bAjaxfofc=!0),i.setOptionCls.setOption("map",t)}else alert("RCSB server has no corresponding eletron density map for this structure.");else i.ParserUtilsCls.showLoading()},l.send()}}loadDsn6Data(e,t,s){let i=this.icn3d;i.icn3dui;let n,l,r={},o=e.buffer&&e.buffer instanceof ArrayBuffer?e.buffer:e,a=new Int16Array(o),d=new Uint8Array(o),c=String.fromCharCode.apply(null,d.subarray(0,512));if(0==c.indexOf(":-)"))r.xStart=parseInt(c.substr(10,5)),r.yStart=parseInt(c.substr(15,5)),r.zStart=parseInt(c.substr(20,5)),r.xExtent=parseInt(c.substr(32,5)),r.yExtent=parseInt(c.substr(38,5)),r.zExtent=parseInt(c.substr(42,5)),r.xRate=parseInt(c.substr(52,5)),r.yRate=parseInt(c.substr(58,5)),r.zRate=parseInt(c.substr(62,5)),r.xlen=1*parseFloat(c.substr(73,10)),r.ylen=1*parseFloat(c.substr(83,10)),r.zlen=1*parseFloat(c.substr(93,10)),r.alpha=parseFloat(c.substr(103,10)),r.beta=parseFloat(c.substr(113,10)),r.gamma=parseFloat(c.substr(123,10)),n=parseFloat(c.substr(138,12))/100,l=parseInt(c.substr(155,8)),r.sigma=100*parseFloat(c.substr(170,12));else{if(100!==a[18])for(let e=0,t=a.length;e>8&255}r.zStart=a[2],r.xStart=a[0],r.yStart=a[1],r.xExtent=a[3],r.yExtent=a[4],r.zExtent=a[5],r.xRate=a[6],r.yRate=a[7],r.zRate=a[8];let e=1/a[17],t=1*e;r.xlen=a[9]*t,r.ylen=a[10]*t,r.zlen=a[11]*t,r.alpha=a[12]*e,r.beta=a[13]*e,r.gamma=a[14]*e,n=a[15]/a[18],l=a[16]}let h=new Float32Array(r.xExtent*r.yExtent*r.zExtent),p=512,m=Math.ceil(r.xExtent/8),u=Math.ceil(r.yExtent/8),g=Math.ceil(r.zExtent/8);for(let e=0;es.maxatomcnt&&(s.bAssembly=!0)}if("mmtfid"===t&&void 0!==o.missingseq){let t=0,n="";for(let l=0,r=o.missingseq.length;lt)&&(s.chainMissingResidueArray[c].push(h),t=d,n=a)}s.loadPDBCls.adjustSeq(s.chainMissingResidueArray)}}async loadMmcifData(e,t){let s=this.icn3d;if(s.icn3dui,t||(t=e.mmcif),t||(t=s.defaultPdbId),void 0===e.atoms)return!1;s.init(),void 0!==e.emd&&(s.emd=e.emd),void 0!==e.organism&&(s.organism=e.organism),void 0!==s.emd?($("#"+s.pre+"mapWrapper1").hide(),$("#"+s.pre+"mapWrapper2").hide(),$("#"+s.pre+"mapWrapper3").hide()):($("#"+s.pre+"emmapWrapper1").hide(),$("#"+s.pre+"emmapWrapper2").hide(),$("#"+s.pre+"emmapWrapper3").hide()),await s.opmParserCls.loadOpmData(e,t,void 0,"mmcif")}}class Gt{constructor(e){this.icn3d=e}async downloadMmdb(e,t){let s,i=this.icn3d,n=i.icn3dui;try{if(s=await this.loadMmdbPrms(e,t),!s||s.error)return void this.getNoData(e,t)}catch(s){return void this.getNoData(e,t)}if(0!=Object.keys(s.atoms).length)if(n.utilsCls.isCalphaPhosOnly(s.atoms)||s.atomCount<=i.maxatomcnt)await this.parseMmdbData(s);else{let s;try{s=await this.loadMmdbPrms(e,t,!0)}catch(s){return void this.getNoData(e,t)}await this.parseMmdbData(s)}else{let e=s.pdbId;i.mmtfParserCls.downloadMmtf(e)}}async downloadGi(e){let t=this.icn3d;t.icn3dui,t.bCid=void 0;await this.downloadMmdb(e,!0)}async downloadBlast_rep_id(e){let t=this.icn3d,s=t.icn3dui,i=e.split(",");s.cfg.query_id=i[0],s.cfg.blast_rep_id=i[1];let n=s.cfg.blast_rep_id.split("_")[0];4==n.length?await this.downloadMmdb(n):(t.blastAcxn=s.cfg.blast_rep_id.split(".")[0],await this.downloadRefseq(t.blastAcxn,!0))}async downloadRefseq(e,t){let s=this.icn3d,i=s.icn3dui,n=i.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?refseq2uniprot="+e;i.cfg.refseqid=e;let l=await i.getAjaxPromise(n,"jsonp",!1,"The protein accession "+e+" can not be mapped to AlphaFold UniProt ID...");if(!l||!l.uniprot)return void alert("The accession "+e+" can not be mapped to AlphaFold UniProt ID. It will be treated as a UniProt ID instead.");i.cfg.afid=l.uniprot,t&&(i.cfg.blast_rep_id=i.cfg.afid+"_A");await s.pdbParserCls.downloadPdb(i.cfg.afid,!0)}getNoData(e,t){let s=this.icn3d.icn3dui;t?alert("This gi "+e+" has no corresponding 3D structure..."):alert("This mmdbid "+e+" with the parameters "+s.cfg.inpara+" may not have 3D structure data. Please visit the summary page for details: "+s.htmlCls.baseUrl+"pdb/"+e)}async parseMmdbData(e,t,s,i,n,l){let r,o=this.icn3d,a=o.icn3dui,d=void 0!==e.pdbId?e.pdbId:e.mmdbId;this.parseMmdbDataPart1(e,t),void 0===t?(void 0!==e.opm&&void 0!==e.opm.rot&&(o.bOpm=!0,o.opmParserCls.setOpmData(e)),r=o.loadAtomDataCls.loadAtomDataIn(e,d,"mmdbid",void 0,t)):(s&&(d=s.substr(0,s.indexOf("_"))),r=o.loadAtomDataCls.loadAtomDataIn(e,d,"mmdbid",void 0,t,s,i,n,l));let c=e.pdbId;void 0===t&&o.ParserUtilsCls.setYourNote(c.toUpperCase()+"(MMDB) in iCn3D");for(let t in e.domains){let s=e.domains[t].chain,i=c+"_"+s,n=e.domains[t].domains;for(let e=0,t=n.length;et.maxatomcnt){let i=!1;if(0==Object.keys(s).length)return void alert("This PDB structure is not found at RCSB...");await t.opmParserCls.loadOpmData(s,e,i,"mmtf")}else s=null,MMTF.fetch(e,(async function(s){0!=Object.keys(s).length?await t.opmParserCls.loadOpmData(s,e,!0,"mmtf"):alert("This PDB structure is not found at RCSB...")}),(function(e){}))}),(function(e){}))}async parseMmtfData(e,t,s){let i=this.icn3d,n=i.icn3dui;e.numAtoms,i.init();let l=new THREE.Vector3(9999,9999,9999),r=new THREE.Vector3(-9999,-9999,-9999),o=new THREE.Vector3,a=e.structureId;if(i.molTitle=e.title,void 0!==e.bioAssemblyList&&void 0!==e.bioAssemblyList[0]&&e.bioAssemblyList[0].transformList.length>1){i.biomtMatrices=[];for(let t=0,s=e.bioAssemblyList[0].transformList.length;t1&&($("#"+i.pre+"assemblyWrapper").show(),i.asuCnt=i.biomtMatrices.length);let d,c,h,p,m,u,g,f,b,C,y,v,w,_,S,A,x,k,O,R={},E=[],I="coil",T="",M=0,P=0,D={onModel:function(e){d=0===e.modelIndex?a:a+(e.modelIndex+1).toString()},onChain:function(e){c=e.chainName;let t=d+"_"+c;void 0===i.structures[d]&&(i.structures[d]=[]),i.structures[d].push(t)},onGroup:function(e){h=e.groupName,p=e.groupId;let t=d+"_"+c+"_"+p;m=0===e.secStruct||2===e.secStruct||4===e.secStruct?"helix":3===e.secStruct?"sheet":-1===e.secStruct?"other":"coil";let s=!1;if(c!==T){if(x=void 0,O=void 0,"coil"!==m&&"other"!==m?(u=!0,g=!1):(u=!1,g=!1),"coil"!==I&&"other"!==I){let e=d+"_"+T+"_"+M.toString();for(let t in i.residues[e])i.atoms[t].ssbegin=!1,i.atoms[t].ssend=!0}}else x=A,O=k,m!==I?"coil"===I||"other"===I?(u=!0,g=!1):"coil"===m||"other"===m?(s=!0,u=!1,g=!1):("sheet"===I&&"helix"===m||"helix"===I&&"sheet"===m)&&(s=!0,u=!0,g=!1):(u=!1,g=!1);if(s&&!isNaN(p)){let e=d+"_"+c+"_"+(p-1).toString();for(let t in i.residues[e])i.atoms[t].ssbegin=!1,i.atoms[t].ssend=!0}I=m,T=c,M=p,f=!1,b=!1,C=!1,"non-polymer"===e.chemCompType.toLowerCase()||"other"===e.chemCompType.toLowerCase()||-1!==e.chemCompType.toLowerCase().indexOf("saccharide")?f=!0:-1!==e.chemCompType.toLowerCase().indexOf("peptide")?b=!0:-1!==e.chemCompType.toLowerCase().indexOf("dna")||-1!==e.chemCompType.toLowerCase().indexOf("rna")?C=!0:b=!0;let l=d+"_"+c,r={};r.resi=p,r.name=n.utilsCls.residueName2Abbr(h),i.residueId2Name[t]=r.name,r.resi%10==0&&r.resi.toString();let o="-";"helix"===m?o="H":"sheet"===m?o="E":"coil"===m?o="c":"other"===m&&(o="o"),void 0===i.chainsSeq[l]&&(i.chainsSeq[l]=[]),i.bFullUi&&i.chainsSeq[l].push(r),i.secondaries[t]=o},onAtom:function(e){if(y=e.element,v=e.atomName,w=new THREE.Vector3(e.xCoord,e.yCoord,e.zCoord),_=e.bFactor,S=e.altLoc,"\0"===e.altLoc&&(S=""),""===S||"A"===S){++P,"SG"===v&&E.push(P),R[e.atomIndex]=P;let t={het:f,serial:P,name:v,alt:S,resn:h,structure:d,chain:c,resi:p,coord:w,b:_,elem:y,bonds:[],bondOrder:[],ss:m,ssbegin:u,ssend:g};if(t.het||"C"!==t.name||(A=P),t.het||"O"!==t.name||(k=P),!t.het&&"N"===t.name&&void 0!==x&&void 0!==O){let e=i.atoms[x].coord.distanceTo(i.atoms[O].coord),s=t.coord.x+(i.atoms[x].coord.x-i.atoms[O].coord.x)/e,n=t.coord.y+(i.atoms[x].coord.y-i.atoms[O].coord.y)/e,l=t.coord.z+(i.atoms[x].coord.z-i.atoms[O].coord.z)/e;t.hcoord=new THREE.Vector3(s,n,l)}i.atoms[P]=t,l.min(w),r.max(w),o.add(w);let a=d+"_"+c,I=a+"_"+p;void 0===i.chains[a]&&(i.chains[a]={}),i.chains[a][P]=1,void 0===i.residues[I]&&(i.residues[I]={}),i.residues[I][P]=1,b?(i.proteins[P]=1,"CA"===v&&(i.calphas[P]=1),"N"!==v&&"H"!==v&&"CA"!==v&&"HA"!==v&&"C"!==v&&"O"!==v&&(i.sidec[P]=1)):C?(i.nucleotides[P]=1,(!s||"O3'"!=v&&"O3*"!=v)&&(s||"P"!=v)||(i.nucleotidesO3[P]=1),-1===n.parasCls.nuclMainArray.indexOf(v)&&(i.ntbase[P]=1)):y.toLowerCase()===h.toLowerCase()?i.ions[P]=1:"HOH"===h||"WAT"===h||"SQL"===h||"H2O"===h||"W"===h||"DOD"===h||"D3O"===h?i.water[P]=1:i.chemicals[P]=1,i.dAtoms[P]=1,i.hAtoms[P]=1}},onBond:function(e){let t=R[e.atomIndex1],s=R[e.atomIndex2];if(R.hasOwnProperty(e.atomIndex1)&&R.hasOwnProperty(e.atomIndex2)&&(i.atoms[t].bonds.push(s),i.atoms[s].bonds.push(t),f)){let n=e.bondOrder;i.atoms[t].bondOrder.push(n),i.atoms[s].bondOrder.push(n),2===n?(i.doublebonds[t+"_"+s]=1,i.doublebonds[s+"_"+t]=1):3===n&&(i.triplebonds[t+"_"+s]=1,i.triplebonds[s+"_"+t]=1)}}};MMTF.traverse(e,D),i.loadPDBCls.setResidMapping();for(let e=0,t=E.length;ei.maxatomcnt||void 0!==i.biomtMatrices&&i.biomtMatrices.length*i.cnt>10*i.maxatomcnt)&&(i.opts.proteins="c alpha trace",i.opts.nucleotides="o3 trace"),i.pmin=l,i.pmax=r,i.center=i.ParserUtilsCls.getGeoCenter(i.pmin,i.pmax),i.maxD=i.ParserUtilsCls.getStructureSize(i.atoms,i.pmin,i.pmax,i.center),i.maxD<5&&(i.maxD=5),i.oriMaxD=i.maxD,i.oriCenter=i.center.clone(),i.ParserUtilsCls.transformToOpmOri(t),void 0===n.cfg.align&&1==Object.keys(i.structures).length&&$("#"+i.pre+"alternateWrapper").hide(),i.setStyleCls.setAtomStyleByOptions(i.opts),i.setColorCls.setColorByOptions(i.opts,i.atoms),await i.ParserUtilsCls.renderStructure(),i.saveFileCls.showTitle(),void 0!==n.cfg.rotate&&i.resizeCanvasCls.rotStruc(n.cfg.rotate,!0)}}class Wt{constructor(e){this.icn3d=e}async loadMol2Data(e){let t=this.icn3d,s=t.icn3dui,i=this.loadMol2AtomData(e);void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),i?(t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.atoms),await t.ParserUtilsCls.renderStructure(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0)):alert("The Mol2 file has the wrong format...")}loadMol2AtomData(e){let t=this.icn3d;t.icn3dui;let s=e.split(/\r?\n|\r/);if(s.length<4)return!1;t.init();let i,n,l="LIG",r={},o="1_A",a=0,d=0,c=1,h=!1,p=!1,m={},u={};for(let e=0,o=s.length;eMOLECULE"==o){t.molTitle=s[e+1].trim();let l=s[e+2].trim().replace(/\s+/g," ").split(" ");i=l[0],n=l[1],e+=4}else"@ATOM"==o?(c=1,h=!0,++e):"@BOND"==o?(p=!0,h=!1,++e):"@SUBSTRUCTURE"==o&&(p=!1,++e);if(o=s[e].trim(),""!==o&&"#"!==o.substr(0,1)){if(h&&a1&&($("#"+l.pre+"assemblyWrapper").show(),l.asuCnt=l.biomtMatrices.length),l.setStyleCls.setAtomStyleByOptions(l.opts),l.setColorCls.setColorByOptions(l.opts,l.atoms),await l.ParserUtilsCls.renderStructure(),void 0!==r.cfg.rotate&&l.resizeCanvasCls.rotStruc(r.cfg.rotate,!0)}else"pdb"===i?await l.pdbParserCls.loadPdbData(e,t):"align"===i&&(l.bOpm?await l.alignParserCls.downloadAlignmentPart2(t):void 0!==n?await this.loadOpmData(e,n,s,i):await l.alignParserCls.downloadAlignmentPart2(t))}}class Xt{constructor(e){this.icn3d=e}async downloadPdb(e,t){let s,i=this.icn3d,n=i.icn3dui;t?(s="https://alphafold.ebi.ac.uk/files/AF-"+e+"-F1-model_"+i.AFUniprotVersion+".pdb",n.cfg.refseqid?i.ParserUtilsCls.setYourNote(n.cfg.refseqid.toUpperCase()+"(NCBI Protein Acc.) in iCn3D"):i.ParserUtilsCls.setYourNote(e.toUpperCase()+"(AlphaFold) in iCn3D")):(s="https://files.rcsb.org/view/"+e+".pdb",i.ParserUtilsCls.setYourNote(e.toUpperCase()+"(PDB) in iCn3D"));let l=await n.getAjaxPromise(s,"text",!0,"The ID "+e+" can not be found in the server "+s+"...");if(t){l="HEADER "+e+"\n"+l,await i.opmParserCls.parseAtomData(l,e,void 0,"pdb",void 0)}else await i.opmParserCls.loadOpmData(l,e,void 0,"pdb")}async downloadUrl(e,t,s){let i=this.icn3d,n=i.icn3dui,l=e.lastIndexOf("/");if(-1!=l){let t=e.lastIndexOf(".");i.filename=e.substr(l+1,t-l-1)}else{let t=e.lastIndexOf(".");i.filename=e.substr(0,t)}let r=await n.getAjaxPromise(e,"text",!0);if(i.InputfileData=i.InputfileData?i.InputfileData+"\nENDMDL\n"+r:r,i.InputfileType=t,"pdb"===t)await this.loadPdbData(r);else if("mmcif"===t){let e=n.htmlCls.baseUrl+"mmcifparser/mmcifparser.cgi",t={mmciffile:r},s=await n.getAjaxPostPromise(e,t,!0);await i.mmcifParserCls.loadMmcifData(s,void 0)}else if("mol2"===t)await i.mol2ParserCls.loadMol2Data(r);else if("sdf"===t)await i.sdfParserCls.loadSdfData(r);else if("xyz"===t)await i.xyzParserCls.loadXyzData(r);else if("mmcif"===t)await i.mmcifParserCls.loadMmcifData(r);else if("icn3dpng"===t)await n.htmlCls.setHtmlCls.loadPng(r,s);else if("pae"===t){n.htmlCls.dialogCls.openDlg("dl_alignerrormap","Show Predicted Aligned Error (PAE) map");let e=!0;i.contactMapCls.processAfErrorMap(JSON.parse(r),e)}}async loadPdbData(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui;if(!i&&(void 0===n||"target"===n)){let e=!!o.bCommandLoad;o.bStatefile||o.init(e)}let d=o.loadPDBCls.loadPDB(e,t,s,void 0,void 0,i,n,l);void 0===a.cfg.opmid&&o.ParserUtilsCls.transformToOpmOri(t),void 0!==o.biomtMatrices&&o.biomtMatrices.length>1&&(a.bNode||$("#"+o.pre+"assemblyWrapper").show(),o.asuCnt=o.biomtMatrices.length),a.bNode||(void 0!==o.emd?($("#"+o.pre+"mapWrapper1").hide(),$("#"+o.pre+"mapWrapper2").hide(),$("#"+o.pre+"mapWrapper3").hide()):($("#"+o.pre+"emmapWrapper1").hide(),$("#"+o.pre+"emmapWrapper2").hide(),$("#"+o.pre+"emmapWrapper3").hide()));let c=!1;return o.bSecondaryStructure&&1==Object.keys(o.structures).length?c=!1:a.cfg.mmtfid||a.cfg.pdbid||a.cfg.opmid||a.cfg.mmdbid||a.cfg.gi||a.cfg.uniprotid||a.cfg.blast_rep_id||a.cfg.cid||a.cfg.mmcifid||a.cfg.align||a.cfg.chainalign||(c=!0),(!o.bSecondaryStructure||c)&&Object.keys(o.proteins).length>0&&!r?await this.applyCommandDssp(i):(await this.loadPdbDataRender(i),a.bNode||await o.ParserUtilsCls.checkMemProteinAndRotate()),d}async applyCommandDssp(e){let t=this.icn3d,s=t.icn3dui,i=s.utilsCls.isCalphaPhosOnly(s.hashUtilsCls.hash2Atoms(t.proteins,t.atoms));await t.dsspCls.applyDssp(i,e)}async loadPdbDataRender(e){let t=this.icn3d,s=t.icn3dui;void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),s.cfg.afid&&!t.bAfMem&&(t.opts.color="confidence"),t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.hAtoms),await t.ParserUtilsCls.renderStructure(),t.saveFileCls.showTitle(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0),e&&t.definedSetsCls.setModeAndDisplay("all")}}class Kt{constructor(e){this.icn3d=e}async downloadCid(e){let t=this.icn3d,s=t.icn3dui;t.ParserUtilsCls.setYourNote("PubChem CID "+e+" in iCn3D"),t.bCid=!0;let i="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/"+t.inputid+"/cids/JSONP?cids_type=parent",n="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/"+(await s.getAjaxPromise(i,"jsonp",!0,"Can not retrieve the parant CID...")).IdentifierList.CID[0]+"/record/SDF/?record_type=3d&response_type=display",l=await s.getAjaxPromise(n,"text",!0,"This CID may not have 3D structure..."),r=this.loadSdfAtomData(l,e);void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),r?(t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.atoms),await t.ParserUtilsCls.renderStructure(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0)):alert("The SDF of CID "+e+" has the wrong format...")}async loadSdfData(e){let t=this.icn3d,s=t.icn3dui,i=this.loadSdfAtomData(e);void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),i?(t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.atoms),await t.ParserUtilsCls.renderStructure(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0)):alert("The SDF file has the wrong format...")}loadSdfAtomData(e,t){let s=this.icn3d;s.icn3dui;let i=e.split(/\r?\n|\r/);if(i.length<4)return!1;s.init();let n=t||1,l="LIG",r=n,o=n+"_A",a=o+"_1",d=parseInt(i[3].substr(0,3));if(isNaN(d)||d<=0)return!1;let c=parseInt(i[3].substr(3,3)),h=4;if(i.lengthr||(Math.abs(t.coord.y-i.coord.y)>r||Math.abs(t.coord.z-i.coord.z)>r||l.utilsCls.hasCovalentBond(t,i)&&(n.atoms[o[e]].bonds.push(o[s]),n.atoms[o[s]].bonds.push(o[e])))}}}loadXyzAtomData(e){let t=this.icn3d;t.icn3dui;let s=e.split(/\r?\n|\r/);if(s.length<3)return!1;t.init();let i,n,l,r={},o=0,a=1;t.molTitle="";for(let e=0,d=s.length;e1&&(t.molTitle+="; "),t.molTitle+=s[e+1].trim(),e+=2),d=s[e].trim(),""===d)continue;let c=d.replace(/,/," ").replace(/\s+/g," ").split(" "),h=c[0],p=parseFloat(c[1]),m=parseFloat(c[2]),u=parseFloat(c[3]),g={het:!0,serial:a,name:h,resn:"LIG",structure:l,chain:"A",resi:1,coord:new THREE.Vector3(p,m,u),b:0,elem:h,bonds:[],ss:"coil",ssbegin:!1,ssend:!1,bondOrder:[]};t.atoms[a]=g,r[a]=1,++a}return this.setXyzAtomSeq(r,o,i,n),t.ParserUtilsCls.setMaxD(),t.saveFileCls.showTitle(),!0}}class Jt{constructor(e){this.icn3d=e}realign(){let e=this.icn3d,t=e.icn3dui;e.selectionCls.saveSelectionPrep();let s="alseq_"+Object.keys(e.defNames2Atoms).length;e.selectionCls.saveSelection(s,s),t.htmlCls.clickMenuCls.setLogCmd("realign",!0);let i={},n={};e.realignResid={};let l="";for(let s in e.hAtoms){let r=e.atoms[s],o=r.structure+"_"+r.chain;if(e.proteins.hasOwnProperty(s)&&"CA"==r.name||e.nucleotides.hasOwnProperty(s)&&("O3'"==r.name||"O3*"==r.name)){if(r.structure+"_"+r.resi==l)continue;i.hasOwnProperty(r.structure)||(i[r.structure]=[]),i[r.structure].push(r.coord.clone()),e.realignResid.hasOwnProperty(o)||(e.realignResid[o]=[]),e.realignResid[o].push({resid:o+"_"+r.resi,resn:t.utilsCls.residueName2Abbr(r.resn.substr(0,3)).substr(0,1)}),n[r.structure]=r.structure+"_"+r.chain,l=r.structure+"_"+r.resi}}let r=Object.keys(i),o=r[0],a=[];e.qt_start_end=[],a.push(n[o]);for(let t=1,s=r.length;t5){let e=r.cfg.chainalign.split(",");e.length>0&&(l.hAtoms=l.definedSetsCls.getAtomsFromNameArray(e)),r.cfg.aligntool="tmalign",await l.realignParserCls.realignOnStructAlign()}else l.hAtoms=l.chainalignParserCls.setMsa(e),l.transformCls.zoominSelection(),await l.chainalignParserCls.downloadChainalignmentPart3(void 0,e,l.hAtoms)}async parseChainRealignData(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui,d=s[0].substr(0,s[0].indexOf("_"));r||(d=d.toUpperCase());let c={};o.realignResid={},o.opts.color="grey",o.setColorCls.setColorByOptions(o.opts,o.dAtoms),o.qt_start_end=[];for(let t=0,h=e.length;t=6&&C.length>=6&&!a.cfg.command&&o.bRender&&alert("These sequences can not be aligned to each other")):o.bRender&&alert("Please do not align residues in the same structure")}if(r){o.hAtoms=o.chainalignParserCls.setMsa(s);let e="protein_aligned";if(o.selectionCls.saveSelection(e,e),o.bAfMem?(o.selectionCls.selectAll_base(),o.opts.chemicals="stick",o.opts.color="confidence",o.setColorCls.setColorByOptions(o.opts,o.atoms)):(o.transformCls.zoominSelection(),o.dAtoms=a.hashUtilsCls.cloneHash(o.hAtoms),o.opts.color="identity",o.setColorCls.setColorByOptions(o.opts,o.hAtoms)),o.drawCls.draw(),o.hlUpdateCls.updateHlAll(),o.bAfMem){let e=new THREE.Vector3(1,0,0),t=-.5*Math.PI;o.transformCls.setRotation(e,t)}}else o.hAtoms=o.chainalignParserCls.setMsa(s),o.transformCls.zoominSelection(),await o.chainalignParserCls.downloadChainalignmentPart3(t,s,o.hAtoms)}async realignOnSeqAlign(e){let t=this.icn3d;t.icn3dui;let s=t.firstAtomObjCls.getChainsFromAtoms(t.hAtoms),i=Object.keys(s),n=[],l="";for(let e=0,t=i.length;ef&&(f=s)}}}return{data:n,min:g,max:f}}(e.getCategory("_volume_data_3d").getColumn("values"),o,n.sampleCount,l);return{name:n.name,spacegroup:function(e,t,s){let i=Math.PI/180*s[0],n=Math.PI/180*s[1],l=Math.PI/180*s[2],r=t[0],o=t[1],a=t[2],d=Math.cos(n),c=(Math.cos(i)-Math.cos(n)*Math.cos(l))/Math.sin(l),h=Math.sqrt(1-d*d-c*c);return{number:e,size:t,angles:s,basis:{x:[r,0,0],y:[Math.cos(l)*o,Math.sin(l)*o,0],z:[d*a,c*a,h*a]}}}(n.spacegroupNumber,n.cellSize,n.cellAngles),box:{origin:r(n.origin),dimensions:r(n.dimensions),sampleCount:o},data:a.data,valuesInfo:{min:a.min,max:a.max,mean:n.mean,sigma:n.sigma}}}BinaryParse(e){this.icn3d.icn3dui;let t=new Uint8Array(e),s=this.MessagePackParse({buffer:t,offset:0,dataView:new DataView(t.buffer)}),i=function(){function e(e){this.additionalData={},this.header=e.header,this.categoryList=e.categories.map((function(e){return new n(e)})),this.categoryMap=new Map;for(let e=0,t=this.categoryList;e=0;s--)t=c(t,e.encoding[s]);return t}function p(e){if(!e.data.data)return _UndefinedColumn;let t,s=h(e.data);return e.mask&&(t=h(e.mask)),s.buffer&&s.byteLength&&s.BYTES_PER_ELEMENT?t?new f(s,t):new g(s):t?new C(s,t):new b(s)}function m(e,t,s){let i=0,n=1;for(45===e.charCodeAt(t)&&(n=-1,t++);t9||s<0)return n*i|0;i=10*i+s|0}return n*i}function u(e,t,s){let i=1,n=0,l=0,r=1;for(45===e.charCodeAt(t)&&(i=-1,++t);t=0&&o<10)){if(-2===o){for(++t;t=0&&o<10))return 53===o||21===o?parseScientific(i*(n+l/r),e,t+1,s):i*(n+l/r);l=10*l+o,r*=10,++t}return i*(n+l/r)}if(53===o||21===o)return parseScientific(i*n,e,t+1,s);break}n=10*n+o,++t}return i*n}let g=function(){function e(e){this.data=e,this.isDefined=!0}return e.prototype.getString=function(e){return""+this.data[e]},e.prototype.getInteger=function(e){return 0|this.data[e]},e.prototype.getFloat=function(e){return 1*this.data[e]},e.prototype.stringEquals=function(e,t){return this.data[e]===u(t,0,t.length)},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return 0},e}(),f=function(){function e(e,t){this.data=e,this.mask=t,this.isDefined=!0}return e.prototype.getString=function(e){return 0===this.mask[e]?""+this.data[e]:null},e.prototype.getInteger=function(e){return 0===this.mask[e]?this.data[e]:0},e.prototype.getFloat=function(e){return 0===this.mask[e]?this.data[e]:0},e.prototype.stringEquals=function(e,t){return 0===this.mask[e]?this.data[e]===u(t,0,t.length):null==t},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return this.mask[e]},e}(),b=function(){function e(e){this.data=e,this.isDefined=!0}return e.prototype.getString=function(e){return this.data[e]},e.prototype.getInteger=function(e){let t=this.data[e];return m(t,0,t.length)},e.prototype.getFloat=function(e){let t=this.data[e];return u(t,0,t.length)},e.prototype.stringEquals=function(e,t){return this.data[e]===t},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return 0},e}(),C=function(){function e(e,t){this.data=e,this.mask=t,this.isDefined=!0}return e.prototype.getString=function(e){return 0===this.mask[e]?this.data[e]:null},e.prototype.getInteger=function(e){if(0!==this.mask[e])return 0;let t=this.data[e];return m(t||"",0,(t||"").length)},e.prototype.getFloat=function(e){if(0!==this.mask[e])return 0;let t=this.data[e];return u(t||"",0,(t||"").length)},e.prototype.stringEquals=function(e,t){return this.data[e]===t},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return this.mask[e]},e}(),y=function(){function e(e){this.dataBlocks=e.dataBlocks.map((function(e){return new i(e)}))}return e.prototype.toJSON=function(){return this.dataBlocks.map((function(e){return e.toJSON()}))},e}();return new y(s)}MessagePackParse(e){this.icn3d.icn3dui;let t=this;function s(e,s){let i={};for(let n=0;n0&&(i[i.length]=l.slice(0,a).join(""));return i.join("")}(e.buffer,e.offset,t);return e.offset+=t,s}let r=function(){let e=[];for(let t=0;t<1024;t++)e[t]=String.fromCharCode(t);return e}();let o,a,d=e.buffer[e.offset];if(0==(128&d))return e.offset++,d;if(128==(240&d))return a=15&d,e.offset++,s(e,a);if(144==(240&d))return a=15&d,e.offset++,n(e,a);if(160==(224&d))return a=31&d,e.offset++,l(e,a);if(224==(224&d))return o=e.dataView.getInt8(e.offset),e.offset++,o;switch(d){case 192:return e.offset++,null;case 194:return e.offset++,!1;case 195:return e.offset++,!0;case 196:return a=e.dataView.getUint8(e.offset+1),e.offset+=2,i(e,a);case 197:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,i(e,a);case 198:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,i(e,a);case 202:return o=e.dataView.getFloat32(e.offset+1),e.offset+=5,o;case 203:return o=e.dataView.getFloat64(e.offset+1),e.offset+=9,o;case 204:return o=e.buffer[e.offset+1],e.offset+=2,o;case 205:return o=e.dataView.getUint16(e.offset+1),e.offset+=3,o;case 206:return o=e.dataView.getUint32(e.offset+1),e.offset+=5,o;case 208:return o=e.dataView.getInt8(e.offset+1),e.offset+=2,o;case 209:return o=e.dataView.getInt16(e.offset+1),e.offset+=3,o;case 210:return o=e.dataView.getInt32(e.offset+1),e.offset+=5,o;case 217:return a=e.dataView.getUint8(e.offset+1),e.offset+=2,l(e,a);case 218:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,l(e,a);case 219:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,l(e,a);case 220:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,n(e,a);case 221:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,n(e,a);case 222:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,s(e,a);case 223:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,s(e,a)}}}class es{constructor(e){this.icn3d=e}alignCoords(e,t,s,i,n,l,r,o){let a,d=this.icn3d,c=d.icn3dui,h=e.length=4&&(d.rmsd_suprTmp=c.rmsdSuprCls.getRmsdSuprCls(e,t,h),void 0!==d.rmsd_suprTmp.rot)){let e=d.rmsd_suprTmp.rot;null===e[0]&&alert("Please select more residues in each structure...");let t=d.rmsd_suprTmp.trans1,i=d.rmsd_suprTmp.trans2;if(a=d.rmsd_suprTmp.rmsd,a){c.htmlCls.clickMenuCls.setLogCmd("realignment RMSD: "+a.toPrecision(4),!1);let e="
    Realignment RMSD: "+a.toPrecision(4)+" Å

    ";d.bAfMem&&(e+=c.utilsCls.getMemDesc()),$("#"+d.pre+"dl_rmsd").html(e),c.cfg.bSidebyside||c.htmlCls.dialogCls.openDlg("dl_rmsd","Realignment RMSD")}let r={};for(let n=0,l=d.structures[s].length;n"+s.diagram2dCls.set2DdgmNote(!0),$("#"+s.pre+"dl_2ddgm").html(s.html2ddgm),s.b2DShown=!0}async set2DDiagramsForChainalign(e){let t=this.icn3d.icn3dui,s=this;t.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions");let i=[];for(let s=0,n=e.length;s"+s.diagram2dCls.set2DdgmNote(!0),s.b2DShown=!0,$("#"+s.pre+"dl_2ddgm").html(s.html2ddgm),i.cfg.show2d&&i.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions")}download2Ddgm(e,t){this.set2DDiagrams(e)}set2DDiagrams(e){let t=this.icn3d;t.icn3dui.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions"),void 0!==t.b2DShown&&t.b2DShown||(t.html2ddgm="",t.diagram2dCls.draw2Ddgm(t.interactionData,e),t.html2ddgm+="
    "+t.diagram2dCls.set2DdgmNote(),$("#"+t.pre+"dl_2ddgm").html(t.html2ddgm)),t.b2DShown=!0}showLoading(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"wait")&&$("#"+e.pre+"wait").show(),$("#"+e.pre+"canvas")&&$("#"+e.pre+"canvas").hide(),$("#"+e.pre+"cmdlog")&&$("#"+e.pre+"cmdlog").hide()}hideLoading(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"wait")&&$("#"+e.pre+"wait").hide(),$("#"+e.pre+"canvas")&&$("#"+e.pre+"canvas").show(),$("#"+e.pre+"cmdlog")&&$("#"+e.pre+"cmdlog").show()}setYourNote(e){let t=this.icn3d,s=t.icn3dui;t.yournote=e,$("#"+t.pre+"yournote").val(t.yournote),s.cfg.shownote&&(document.title=t.yournote)}transformToOpmOri(e){let t=this.icn3d;if(t.icn3dui,void 0!==t.rmsd_supr&&void 0!==t.rmsd_supr.rot){let s=t.rmsd_supr.rot,i=t.rmsd_supr.trans1,n=t.rmsd_supr.trans2;t.rmsd_supr.rmsd;let l=0;for(let e in t.atoms){let r=t.atoms[e];r.coord=t.surfaceCls.transformMemPro(r.coord,s,i,n);let o=r.coord.x*r.coord.x+r.coord.y*r.coord.y;Math.abs(r.coord.z)<=25&&o>l&&(l=o)}this.addMemAtoms(t.halfBilayerSize,e,Math.sqrt(l)),t.bStopRotate=!0,t.bOpm=!0,$("#"+t.pre+"togglememli").show(),$("#"+t.pre+"adjustmemli").show(),$("#"+t.pre+"selectplaneli").show()}else t.bOpm=!1}transformToOpmOriForAlign(e,t,s){let i=this.icn3d,n=i.icn3dui;if(void 0!==t){let l=i.loadPDBCls.getChainCalpha(i.chains,i.atoms,s,e),r=1==Object.keys(l.chainresiCalphaHash).length||1==Object.keys(t.chainresiCalphaHash).length,o=[],a=[];for(let e in l.chainresiCalphaHash)if(t.chainresiCalphaHash.hasOwnProperty(e)){let s=l.chainresiCalphaHash[e],i=t.chainresiCalphaHash[e];if((s.length==i.length||r)&&(o=o.concat(s),a=a.concat(i)),o.length>500)break}let d=o.length=4)if(i.rmsd_supr=n.rmsdSuprCls.getRmsdSuprCls(o,a,d),void 0!==i.rmsd_supr.rot&&i.rmsd_supr.rmsd<.1){let s=i.rmsd_supr.rot,l=i.rmsd_supr.trans1,r=i.rmsd_supr.trans2,o=i.rmsd_supr.rmsd;n.htmlCls.clickMenuCls.setLogCmd("RMSD of alignment to OPM: "+o.toPrecision(4),!1);let a=0;for(let e in i.atoms){let t=i.atoms[e];t.coord=i.surfaceCls.transformMemPro(t.coord,s,l,r);let n=t.coord.x*t.coord.x+t.coord.y*t.coord.y;Math.abs(t.coord.z)<=25&&n>a&&(a=n)}i.center=t.center,i.oriCenter=i.center.clone(),this.addMemAtoms(i.halfBilayerSize,e,Math.sqrt(a)),i.bStopRotate=!0,i.bOpm=!0,$("#"+i.pre+"togglememli").show(),$("#"+i.pre+"adjustmemli").show(),$("#"+i.pre+"selectplaneli").show()}else i.bOpm=!1;else i.bOpm=!1}}addOneDumAtom(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui,a={het:!0,serial:++l,name:t,alt:void 0,resn:"DUM",structure:e,chain:"MEM",resi:1,coord:new THREE.Vector3(s,i,n),b:void 0,elem:t,bonds:[],ss:"",ssbegin:!1,ssend:!1,color:o.parasCls.atomColors[t]};return r.atoms[l]=a,r.chains[e+"_MEM"][l]=1,r.residues[e+"_MEM_1"][l]=1,r.chemicals[l]=1,r.dAtoms[l]=1,r.hAtoms[l]=1,l}addMemAtoms(e,t,s){let i=this.icn3d;if(i.icn3dui,!t)return;t=t?t.toUpperCase():i.defaultPdbId,i.structures[t].push(t+"_MEM"),i.chains[t+"_MEM"]={},i.residues[t+"_MEM_1"]={},i.chainsSeq[t+"_MEM"]=[{name:"DUM",resi:1}];let n=Object.keys(i.atoms).length;for(let e=0;e<1e3;++e)if(!i.atoms.hasOwnProperty(n+e)){n=n+e-1;break}for(let i=0;i<81;++i)for(let l=0;l<81;++l){let r=2*i-80,o=2*l-80;if(Math.sqrt(r*r+o*o)=2?$("#"+e.pre+"mn2_alternateWrap").show():$("#"+e.pre+"mn2_alternateWrap").hide(),setTimeout((async function(){if(e.bInitial){if(void 0!==t.cfg.align||void 0!==t.cfg.chainalign){let s=e.pre+"selection";if($("#"+s).show(),$("#"+s+"_expand").hide(),$("#"+s+"_shrink").show(),void 0!==t.cfg.align&&2!=t.cfg.atype){let s=!1,i=t.htmlCls.alignSeqCls.getAlignSequencesAnnotations(Object.keys(e.alnChains),void 0,void 0,s);$("#"+e.pre+"dl_sequence2").html(i.sequencesHtml),$("#"+e.pre+"dl_sequence2").width(t.htmlCls.RESIDUE_WIDTH*i.maxSeqCnt+200)}}if(t.cfg.showanno){let s="view annotations";t.htmlCls.clickMenuCls.setLogCmd(s,!0),await e.showAnnoCls.showAnnotations()}t.cfg.closepopup&&e.resizeCanvasCls.closeDialogs()}else e.hlUpdateCls.updateHlAll();$("#"+e.pre+"atomsCustom").length>0&&$("#"+e.pre+"atomsCustom")[0].blur(),e.bInitial=!1}),0)}processCommand(){let e=this.icn3d,t=e.icn3dui;if(1==Object.keys(e.structures).length){let s=Object.keys(e.structures)[0];t.cfg.command=t.cfg.command.replace(new RegExp("!","g"),s+"_")}}getMassCenter(e,t){return this.icn3d.icn3dui,e.multiplyScalar(1/t)}getGeoCenter(e,t){return this.icn3d.icn3dui,e.clone().add(t).multiplyScalar(.5)}getStructureSize(e,t,s,i){let n=this.icn3d;n.icn3dui;let l=0;for(let r in e){let e=n.atoms[r].coord;if(Math.round(t.x)==Math.round(e.x)||Math.round(t.y)==Math.round(e.y)||Math.round(t.z)==Math.round(e.z)||Math.round(s.x)==Math.round(e.x)||Math.round(s.y)==Math.round(e.y)||Math.round(s.z)==Math.round(e.z)){let t=2*e.distanceTo(i);t>l&&(l=t)}}return l}async checkMemProteinAndRotate(){let e=this.icn3d,t=e.icn3dui;if(!e.bCheckMemProtein){e.bCheckMemProtein=!0;let s=t.cfg.afid?t.cfg.afid:t.cfg.mmdbafid;if(await e.ParserUtilsCls.checkMemProtein(s),t.cfg.url&&-1!=t.cfg.url.indexOf("membranome")){let t=new THREE.Vector3(1,0,0),s=-.5*Math.PI;e.transformCls.setRotation(t,s)}}}async checkMemProtein(e){let t=this.icn3d,s=t.icn3dui;try{let i=s.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?afid2mem="+e,n=await s.getAjaxPromise(i,"jsonp");if(n&&n.pdbid){let e='This is a single-spanning (bitopic) transmembrane protein according to the Membranome database. Do you want to align the protein with the model from Membranome? If you click "OK", you can press the letter "a" to alternate the structures.';if("off"==s.cfg.afmem);else if("on"==s.cfg.afmem||confirm(e))try{let e="https://storage.googleapis.com/membranome-assets/pdb_files/proteins/"+n.pdbid+".pdb",i=await s.getAjaxPromise(e,"text");t.bAfMem=!0,s.bNode||$("#"+s.pre+"togglememli").show();let l=n.pdbid.substr(0,n.pdbid.indexOf("_")),r=!0,o=!0;await t.pdbParserCls.loadPdbData(i,l,r,o),o&&(t.bSetChainsAdvancedMenu&&t.definedSetsCls.showSets(),t.bAnnoShown&&await t.showAnnoCls.showAnnotations());let a=n.segment.replace(/ /gi,"").split("(")[0];t.afmem_start_end=a.split("-"),t.hAtoms={},t.dAtoms={};for(let e in t.atoms)t.atoms[e].structure!=l&&(t.hAtoms[e]=1),t.dAtoms[e]=1;for(let e=parseInt(t.afmem_start_end[0]);e<=parseInt(t.afmem_start_end[1]);++e)t.hAtoms=s.hashUtilsCls.unionHash(t.hAtoms,t.residues[l+"_A_"+e]);await t.realignParserCls.realignOnSeqAlign(l)}catch(e){return void console.log("Error in retrieving matched PDB from Membranome...")}}}catch(e){return void console.log("Error in finding matched PDB in Membranome...")}}getResi(e,t){let s=this.icn3d;s.icn3dui;let i=s.ncbi2resid[e+"_"+(t+1).toString()];return i?i.substr(i.lastIndexOf("_")+1):""}getResiNCBI(e,t){let s=this.icn3d;s.icn3dui;let i=s.resid2ncbi[e+"_"+t];return i?parseInt(i.substr(i.lastIndexOf("_")+1)):0}}class ts{constructor(e){this.icn3d=e}loadAtomDataIn(e,t,s,i,n,l,r,o,a){let d=this.icn3d,c=d.icn3dui;d.pmin=new THREE.Vector3(9999,9999,9999),d.pmax=new THREE.Vector3(-9999,-9999,-9999),d.psum=new THREE.Vector3;let h=e.atoms,p=d.atoms?Object.keys(d.atoms).length:0,m={},u={};d.pmid=e.pubmedId,void 0===d.chainid2title&&(d.chainid2title={}),void 0===d.chainid2sid&&(d.chainid2sid={});let g={},f={};if("align"===s){d.pmid="",d.molTitle="",c.cfg.inpara&&-1!==c.cfg.inpara.indexOf("atype=1")?d.molTitle="Invariant Core Structure Alignment (VAST) of ":c.cfg.inpara&&-1!==c.cfg.inpara.indexOf("atype=2")?d.molTitle="Structure Alignment (TM-align) of ":d.molTitle="Structure Alignment (VAST) of ";let t=!1;for(let s=0,i=e.alignedStructures[0].length;s'+i.pdbId.toUpperCase()+"",void 0!==i.descr&&(d.pmid+=i.descr.pubmedid),0===s&&(d.molTitle+=" and ",void 0!==i.descr&&(d.pmid+="_")),t=!0}d.molTitle+=" from VAST+",t||(d.molTitle="")}else if(void 0!==e.descr&&(d.molTitle+=e.descr.name),"mmdbid"===s){let s=isNaN(t)?t:e.pdbId,i={};void 0===d.alignmolid2color&&(d.alignmolid2color=[]);let n=1;for(let t in e.moleculeInfor){if(0===Object.keys(e.moleculeInfor[t]).length)continue;let l=e.moleculeInfor[t].chain.trim(),r=s+"_"+l;i.hasOwnProperty(l)?(++i[l],r+=i[l]):i[l]=1,void 0!==d.mmdbid_q&&(d.mmdbid_q,d.mmdbid_t);let o=e.moleculeInfor[t].kind,a=e.moleculeInfor[t].color,c=e.moleculeInfor[t].sid;if(g[r]=o,f[r]=a,"protein"==o&&(d.organism=e.moleculeInfor[t].taxonomyName.toLowerCase()),void 0!==c&&(d.chainid2sid[r]=c),void 0===d.pdbid_chain2title&&(d.pdbid_chain2title={}),d.pdbid_chain2title[r]=e.moleculeInfor[t].name,l==r.substr(r.lastIndexOf("_"))){let e={};e[t]=n.toString(),d.alignmolid2color.push(e)}++n}}let b,C,y,v,w,_={},S="",A="",x="",k="",O="",R="",E=0,I=0,T="",M=!0,P=!1,D="",H=c.utilsCls.isCalphaPhosOnly(h),F=0,L={};for(let e in h){++p,_[e]=p;let i,n=h[e];n.serial=p,"mmdbid"===s||"mmcifid"===s?i=t:"align"===s&&(i=m[p]);let l=!1;if(void 0!==n.chain||"mmdbid"!==s&&"align"!==s)n.chain=""===n.chain?"Misc":n.chain;else if("mmdbid"===s)if(b=n.ids.m,void 0!==d.molid2chain[b]){let e=d.molid2chain[b].indexOf("_");n.chain=d.molid2chain[b].substr(e+1)}else{let e="Misc";("protein"===g[O]&&"nucleotide"===g[O]&&n.resi!=I||"protein"!==g[O]&&"nucleotide"!==g[O]&&(n.resn.substr(0,3)!=T.substr(0,3)||n.resi!=I||"solvent"===g[O]||"HOH"===n.resn))&&++F,n.resi_ori=n.resi,n.resi=F,l=!0,n.chain=e}else if("align"===s)if(b=n.ids.m,void 0!==d.pdbid_molid2chain[i+"_"+b])n.chain=d.pdbid_molid2chain[i+"_"+b];else{let e="Misc";("protein"===g[O]&&"nucleotide"===g[O]&&n.resi!=I||"protein"!==g[O]&&"nucleotide"!==g[O]&&(n.resn.substr(0,3)!=T.substr(0,3)||n.resi!=I||"solvent"===g[O]||"HOH"===n.resn))&&(++F,n.resi_ori=n.resi,n.resi=F,l=!0),n.chain=e}if(n.chain=n.chain.trim(),"mmdbid"!==s&&"align"!==s||(n.structure=i,"mmdbid"===s&&void 0!==d.mmdbid_q&&(d.mmdbid_q,d.mmdbid_t)),k=n.structure,O=k+"_"+n.chain,"mmdbid"===s||"align"===s){l||(n.resi_ori=n.resi,d.bUsePdbNum?n.resi=n.resi_ori:n.resi=n.ids.r);let e=n.resn.indexOf(" ");-1!==e&&0!=e&&(n.resn=n.resn.substr(0,e))}O!==A&&(E=0),n.resi!==E&&(O!==A?(y=void 0,w=void 0):(y=C,w=v)),n.coord="mmdbid"===s?new THREE.Vector3(n.coord[0],n.coord[1],n.coord[2]):new THREE.Vector3(n.coord.x,n.coord.y,n.coord.z);let r=c.utilsCls.residueName2Abbr(n.resn.substr(0,3));"mmdbid"!==s&&"align"!==s||!d.bFullUi||(void 0===d.mmdbMolidResid2mmdbChainResi&&(d.mmdbMolidResid2mmdbChainResi={}),d.mmdbMolidResid2mmdbChainResi[i+"_"+n.ids.m+"_"+n.ids.r]=i+"_"+n.chain+"_"+n.resi),d.pmin.min(n.coord),d.pmax.max(n.coord),d.psum.add(n.coord);let o=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"protein"===g[O]:"p"===n.mt,a=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"nucleotide"===g[O]:"n"===n.mt,u=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"solvent"===g[O]:"s"===n.mt,N=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"ligand"===g[O]||void 0!==g[O]&&-1!==g[O].indexOf("other")||void 0===g[O]:"l"===n.mt;if("Misc"!==n.chain&&"other"!==g[O]||"protein"===L[O]||"nucleotide"===L[O]||("CA"===n.name&&"C"===n.elem?L[O]="protein":"P"===n.name&&"P"===n.elem?L[O]="nucleotide":L[O]="chemical"),o||a?(o?(d.proteins[p]=1,"CA"===n.name&&(d.calphas[p]=1),"N"!==n.name&&"H"!==n.name&&"CA"!==n.name&&"HA"!==n.name&&"C"!==n.name&&"O"!==n.name&&(d.sidec[p]=1)):a&&(d.nucleotides[p]=1,("O3'"==n.name||"O3*"==n.name||H&&"P"==n.name)&&(d.nucleotidesO3[p]=1),-1===c.parasCls.nuclMainArray.indexOf(n.name)&&(d.ntbase[p]=1)),n.het=!1):u?(d.water[p]=1,n.het=!0):N&&("HOH"===n.resn||"O"===n.resn?d.water[p]=1:n.elem===n.resn?d.ions[p]=1:d.chemicals[p]=1,n.het=!0),"mmdbid"===s?n.het?n.color=c.parasCls.atomColors[n.elem]||c.parasCls.defaultAtomColor:n.color=void 0!==f[O]?c.parasCls.thr(f[O]):c.parasCls.chargeColors[n.resn]:void 0!==n.color&&(n.color=c.parasCls.thr(n.color))," "!==n.resn.charAt(0)&&" "===n.resn.charAt(1)&&(n.resn=n.resn.charAt(0)),n.het||"C"!==n.name||(C=p),n.het||"O"!==n.name||(v=p),!n.het&&"N"===n.name&&void 0!==y&&void 0!==w){let e=d.atoms[y].coord.distanceTo(d.atoms[w].coord),t=n.coord.x+(d.atoms[y].coord.x-d.atoms[w].coord.x)/e,s=n.coord.y+(d.atoms[y].coord.y-d.atoms[w].coord.y)/e,i=n.coord.z+(d.atoms[y].coord.z-d.atoms[w].coord.z)/e;n.hcoord=new THREE.Vector3(t,s,i)}"HOH"==n.resn&&(d.water[p]=1),d.atoms[p]=n,d.dAtoms[p]=1,d.hAtoms[p]=1;let U=n.structure+"_"+n.chain;void 0===d.chains[U]&&(d.chains[U]={}),d.chains[U][p]=1;let q=U+"_"+n.resi;void 0===d.residues[q]&&(d.residues[q]={}),d.residues[q][p]=1,R=O+"_"+n.resi,R!==x&&O!==A&&(M=!0,""!==S&&(void 0===d.structures[S]&&(d.structures[S]=[]),d.structures[S].push(A))),d.residueId2Name[q]=r;let $="-";if("helix"===n.ss?$="H":"sheet"===n.ss?$="E":n.het||a?$="o":(!n.het&&c.parasCls.residueColors.hasOwnProperty(n.resn.toUpperCase())||"coil"===n.ss)&&($="c"),d.secondaries[n.structure+"_"+n.chain+"_"+n.resi]=$,(n.resi!=E||b!=D)&&d.bFullUi&&(void 0===d.chainsSeq[U]&&(d.chainsSeq[U]=[],M=!1),!isNaN(n.resi)))if(M&&!P&&void 0!==d.chainsSeq[U][n.resi-1])d.chainsSeq[U][n.resi-1].name=r;else if(!M||!d.chainsSeq[U].hasOwnProperty(n.resi-1)){let e={};e.resi=n.resi,e.name=r,n.resi%10==0&&n.resi.toString(),d.chainsSeq[U].push(e),P=!0}E=n.resi,I=n.resi_ori,T=n.resn,S=k,A=O,x=R,D=b}for(let e in d.chemicals){let t=d.atoms[e];if("P"==t.elem&&t.bonds.length>=4)for(let e=t.bonds.length-1;e>=0;--e){"P"==d.atoms[t.bonds[e]].elem&&t.bonds.splice(e,1)}}for(let e in L)if(!(Object.keys(d.chains[e]).length<10)&&"chemical"!==L[e])for(let t in d.chains[e]){let s=d.atoms[t];delete d.chemicals[t],s.het=!1,"protein"===L[e]?(d.proteins[t]=1,"CA"===s.name&&(d.calphas[t]=1),"N"!==s.name&&"H"!==s.name&&"CA"!==s.name&&"HA"!==s.name&&"C"!==s.name&&"O"!==s.name&&(d.sidec[t]=1)):"nucleotide"===L[e]&&(d.nucleotides[t]=1,("O3'"==s.name||"O3*"==s.name||H&&"P"==s.name)&&(d.nucleotidesO3[t]=1),-1===c.parasCls.nuclMainArray.indexOf(s.name)&&(d.ntbase[t]=1))}if(void 0===d.structures[k]&&(d.structures[k]=[]),d.structures[k].push(O),d.bFullUi)if("mmdbid"===s||"mmcifid"===s)for(let i in e.sequences){let n=e.sequences[i],l=t+"_"+i;void 0!==d.mmdbid_q&&(d.mmdbid_q,d.mmdbid_t),d.ParserUtilsCls.getMissingResidues(n,s,l)}else if("align"===s)for(let e in d.chainid2seq){let t=d.chainid2seq[e];d.ParserUtilsCls.getMissingResidues(t,s,e)}if(d.loadPDBCls.setResidMapping(),"mmcifid"!==s)for(let e in h){let t=_[e],s=void 0===d.atoms[t].bonds?0:d.atoms[t].bonds.length;for(let e=0;ed.maxatomcnt||void 0!==d.biomtMatrices&&d.biomtMatrices.length*d.cnt>10*d.maxatomcnt)&&(d.opts.proteins="c alpha trace",d.opts.nucleotides="o3 trace"),d.center=d.ParserUtilsCls.getGeoCenter(d.pmin,d.pmax),d.maxD=d.ParserUtilsCls.getStructureSize(d.atoms,d.pmin,d.pmax,d.center),d.maxD<5&&(d.maxD=5),d.oriMaxD=d.maxD,("align"===s||o)&&(d.ssbondpnts={},d.loadPDBCls.setSsbond()),"mmdbid"===s&&1==Object.keys(d.structures).length){let t=e.disulfides;if(void 0!==t)for(let e=0,s=t.length;ep&&(p=e)),c[e]={resi:t,resn:i,aligned:n}}r=e[t][1];let u=r.moleculeId,g=s.pdbid_molid2chain[l+"_"+u],f=l+"_"+g;void 0===s.alnChainsAnTtl[d]&&(s.alnChainsAnTtl[d]=[]),void 0===s.alnChainsAnTtl[d][0]&&(s.alnChainsAnTtl[d][0]=[]),void 0===s.alnChainsAnTtl[d][1]&&(s.alnChainsAnTtl[d][1]=[]),void 0===s.alnChainsAnTtl[d][2]&&(s.alnChainsAnTtl[d][2]=[]),void 0===s.alnChainsAnTtl[d][3]&&(s.alnChainsAnTtl[d][3]=[]),void 0===s.alnChainsAnTtl[d][4]&&(s.alnChainsAnTtl[d][4]=[]),void 0===s.alnChainsAnTtl[d][5]&&(s.alnChainsAnTtl[d][5]=[]),void 0===s.alnChainsAnTtl[d][6]&&(s.alnChainsAnTtl[d][6]=[]),s.alnChainsAnTtl[d][0].push(f),s.alnChainsAnTtl[d][1].push(d),s.alnChainsAnTtl[d][2].push(""),s.alnChainsAnTtl[d][3].push(""),s.alnChainsAnTtl[d][4].push(f),s.alnChainsAnTtl[d][5].push(d),s.alnChainsAnTtl[d][6].push("");let b=1;s.chainsMapping[d]||(s.chainsMapping[d]={}),s.chainsMapping[f]||(s.chainsMapping[f]={});for(let e=h;e<=p;++e){let t,o,p,m=s.bUsePdbNum?s.ParserUtilsCls.getResi(f,r.sequence[e][0]-1):r.sequence[e][0],u="~"===r.sequence[e][2]?"-":r.sequence[e][2],C=r.sequence[e][3]?1:0,y=c[e].aligned+C;2===y?(c[e].resn===u?(t="#FF0000",p="icn3d-cons",s.consHash1[d+"_"+c[e].resi]=1,s.consHash2[f+"_"+m]=1):(t="#0000FF",p="icn3d-ncons",s.nconsHash1[d+"_"+c[e].resi]=1,s.nconsHash2[f+"_"+m]=1),s.chainsMapping[d][d+"_"+c[e].resi]=c[e].resn+c[e].resi,s.chainsMapping[f][f+"_"+m]=c[e].resn+c[e].resi,o="#"+s.showAnnoCls.getColorhexFromBlosum62(c[e].resn,u)):(t=i.htmlCls.GREY8,p="icn3d-nalign",s.nalignHash1[d+"_"+c[e].resi]=1,s.nalignHash2[f+"_"+m]=1),void 0===s.alnChainsSeq[d]&&(s.alnChainsSeq[d]=[]);let v={};v.mmdbid=n,v.chain=a,v.resi=c[e].resi,v.resn=""===v.resi||"icn3d-nalign"===p?c[e].resn.toLowerCase():c[e].resn,v.aligned=y,v.color=""===v.resi?i.htmlCls.GREYC:t,v.color2=""===v.resi?i.htmlCls.GREYC:o,v.class=p,s.alnChainsSeq[d].push(v),""!==c[e].resi&&(void 0===s.alnChains[d]&&(s.alnChains[d]={}),$.extend(s.alnChains[d],s.residues[d+"_"+c[e].resi])),void 0===s.alnChainsSeq[f]&&(s.alnChainsSeq[f]=[]),v={},v.mmdbid=l,v.chain=g,v.resi=m,v.resn=""===v.resi||"icn3d-nalign"===p?u.toLowerCase():u,v.aligned=y,v.color=""===v.resi?i.htmlCls.GREYC:t,v.color2=""===v.resi?i.htmlCls.GREYC:o,v.class=p,s.alnChainsSeq[f].push(v),""!==v.resi&&(void 0===s.alnChains[f]&&(s.alnChains[f]={}),$.extend(s.alnChains[f],s.residues[f+"_"+m])),void 0===s.alnChainsAnno[d]&&(s.alnChainsAnno[d]=[]),void 0===s.alnChainsAnno[d][0]&&(s.alnChainsAnno[d][0]=[]),void 0===s.alnChainsAnno[d][1]&&(s.alnChainsAnno[d][1]=[]),void 0===s.alnChainsAnno[d][2]&&(s.alnChainsAnno[d][2]=[]),void 0===s.alnChainsAnno[d][3]&&(s.alnChainsAnno[d][3]=[]),e===h&&(void 0===s.alnChainsAnno[d][4]&&(s.alnChainsAnno[d][4]=[]),void 0===s.alnChainsAnno[d][5]&&(s.alnChainsAnno[d][5]=[]),void 0===s.alnChainsAnno[d][6]&&(s.alnChainsAnno[d][6]=[]),s.alnChainsAnno[d][4].push(s.pdbid_chain2title[f]),s.alnChainsAnno[d][5].push(s.pdbid_chain2title[d]),s.alnChainsAnno[d][6].push(""));let w=d+"_"+c[e].resi,_=f+"_"+m,S=s.secondaries[w],A=s.secondaries[_];A?s.alnChainsAnno[d][0].push(A):s.alnChainsAnno[d][0].push("-"),S?s.alnChainsAnno[d][1].push(S):s.alnChainsAnno[d][1].push("-");let x=".";b%5==0&&(x="*"),b%10==0&&(x="|"),s.alnChainsAnno[d][2].push(x);let k="";b%10==0&&(k=b.toString()),s.alnChainsAnno[d][3].push(k),++b}}e={}}getPosFromResi(e,t){let s=this.icn3d;s.icn3dui;let i,n=s.resid2ncbi[e+"_"+t];if(n){i=n.substr(n.lastIndexOf("_")+1)-1}return i}getResnFromResi(e,t){let s=this.icn3d,i=s.icn3dui,n=this.getPosFromResi(e,t);if(!n)return"?";let l=e+"_"+t,r="";return r=void 0===s.residues[l]?s.chainsSeq[e][n]?s.chainsSeq[e][n].name:"?":i.utilsCls.residueName2Abbr(s.firstAtomObjCls.getFirstAtomObj(s.residues[l]).resn.substr(0,3)),r}setSeqAlignChain(e,t,s){let i,n,l,r,o,a,d,c,h,p,m,u=this.icn3d,g=u.icn3dui,f={},b=!!s;if(b){if(o=s[1],a=s[0],t=s[2],d=o.indexOf("_"),c=a.indexOf("_"),i=o.substr(0,d).toUpperCase(),n=a.substr(0,c).toUpperCase(),l=o.substr(d+1),r=a.substr(d+1),i==n&&l==r){let e=u.chainsSeq[n+"_"+r].length;u.qt_start_end[t]={q_start:1,q_end:e,t_start:1,t_end:e}}}else{let d=s[0].indexOf("_"),c=e.indexOf("_");if(i=u.mmdbid_t,n=e.substr(0,c).toUpperCase(),l=s[0].substr(d+1),r=e.substr(c+1),i==n&&l==r){let e=u.chainsSeq[u.mmdbid_q+"_"+u.chain_q].length;u.qt_start_end[t]={q_start:1,q_end:e,t_start:1,t_end:e}}o=i+"_"+l,a=n+"_"+r,void 0!==n&&u.mmdbid_t}u.conservedName1=o+"_cons",u.nonConservedName1=o+"_ncons",u.notAlignedName1=o+"_nalign",u.conservedName2=a+"_cons",u.nonConservedName2=a+"_ncons",u.notAlignedName2=a+"_nalign",u.consHash1={},u.nconsHash1={},u.nalignHash1={},u.consHash2={},u.nconsHash2={},u.nalignHash2={},u.alnChains={},u.alnChainsSeq[o]=[],u.alnChains[o]={},u.alnChainsSeq[a]=[],u.alnChains[a]={},u.alnChainsAnno[o]=[],u.alnChainsAnTtl[o]=[],void 0===u.alnChainsAnTtl[o]&&(u.alnChainsAnTtl[o]=[]);for(let e=0;e<7;++e)void 0===u.alnChainsAnTtl[o][e]&&(u.alnChainsAnTtl[o][e]=[]);u.alnChainsAnTtl[o][0].push(a),u.alnChainsAnTtl[o][1].push(o),u.alnChainsAnTtl[o][2].push(""),u.alnChainsAnTtl[o][3].push(""),u.alnChainsAnTtl[o][4].push(a),u.alnChainsAnTtl[o][5].push(o),u.alnChainsAnTtl[o][6].push("");let C=0,y=0;if(void 0===u.qt_start_end[t])return;let v=1;u.chainsMapping[o]||(u.chainsMapping[o]={}),u.chainsMapping[a]||(u.chainsMapping[a]={});let w={},_={};for(let e=0,s=u.qt_start_end[t].length;e0){let e=v;for(let t=C+1,i=s;tc&&(c=t)}}}"tmalign"==n.cfg.aligntool&&(s=!0);let p=Object.keys(a);p.sort((function(e,t){return parseInt(e)-parseInt(t)}));let m=-999,u=0,g=0,f=[],b=0;for(let e=0,t=p.length;e0&&i.resid2ncbi[t]!=i.resid2ncbi[m]+1&&i.resid2ncbi[t]!=i.resid2ncbi[m]){g=m;for(let e=0,t=f.length;ec)continue;let o={},p=r.indexOf("_");o.mmdbid=r.substr(0,p),o.chain=r.substr(p+1),o.resi=t,o.resn=a[t]?i.chainsSeq[r][e].name.toUpperCase():i.chainsSeq[r][e].name.toLowerCase(),o.aligned=!!a[t],o.color=a[t]?"#FF0000":n.htmlCls.GREYC,o.color2=a[t]?"#FF0000":n.htmlCls.GREYC,o.class=a[t]?"icn3d-align":"icn3d-nalign",i.alnChainsSeq[r].push(o),a[t]&&($.extend(i.alnChains[r],i.residues[r+"_"+o.resi]),l=n.hashUtilsCls.unionHash(l,i.residues[r+"_"+o.resi]))}let C=[0];for(let i=0,r=t.length;in)for(let e=0,t=u-m;e=n)for(let e=0,s=t-n;e0?void 0!==n?p.alnChainsAnno[t][0].push(n):p.alnChainsAnno[t][0].push("-"):console.log("Error: ic.alnChainsAnno[chainid1] is undefined")}}}class is{constructor(e){this.icn3d=e}getStructureId(e,t,s){let i=this.icn3d;i.icn3dui;let n=e;return(e==i.defaultPdbId||s)&&(n=1===t?e:e+t.toString()),n}loadPDB(e,t,s,i,n,l,r,o){let a,d,c=this.icn3d,h=c.icn3dui,p={},m=!1,u=e.split("\n"),g={},f={};c.atoms||(l=!1),n||l?(c.oriNStru=c.structures?Object.keys(c.structures).length:0,d=c.oriNStru+1,a=c.atoms?Object.keys(c.atoms).length:0):(c.init(),d=1,a=0);let b,C,y,v,w,_,S,A=[],x=[],k=[],O=[],R=[],E=[],I="",T="",M="",P={},D=t||c.defaultPdbId,H=D,F="",L=!1;for(let e in u){let r=u[e],o=r.substr(0,6);if("HEADER"!==o||L||t)if("TITLE "===o){let e=r.substr(10).replace(/ALPHAFOLD MONOMER V2.0 PREDICTION FOR /gi,"");c.molTitle+=e.trim()+" "}else if("HELIX "===o){c.bSecondaryStructure=!0;let e=""==r.substr(18,2).trim()?"A":r.substr(18,2).trim(),t=parseInt(r.substr(21,4)),s=parseInt(r.substr(33,4));for(let i=t;i<=s;++i){let n=H+"_"+e+"_"+i;O.push(n),i===t&&R.push(n),i===s&&E.push(n)}}else if("SHEET "===o){void 0!==s&&s||(c.bSecondaryStructure=!0);let e=""==r.substr(20,2).trim()?"A":r.substr(20,2).trim(),t=parseInt(r.substr(22,4)),i=parseInt(r.substr(33,4));for(let s=t;s<=i;++s){let n=H+"_"+e+"_"+s;A.push(n),s===t&&x.push(n),s===i&&k.push(n)}}else if("HBOND "===o)void 0!==s&&s||(c.bSecondaryStructure=!0);else if("SSBOND"===o){c.bSsbondProvided=!0;let e=D+"_"+(" "==r.substr(15,1)?"A":r.substr(15,1))+"_"+r.substr(17,4).trim(),t=D+"_"+(" "==r.substr(29,1)?"A":r.substr(29,1))+"_"+r.substr(31,4).trim();void 0===c.ssbondpnts[D]&&(c.ssbondpnts[D]=[]),c.ssbondpnts[D].push(e),c.ssbondpnts[D].push(t)}else if("REMARK"===o){let e=parseInt(r.substr(7,3));if(-1!==r.indexOf("1/2 of bilayer thickness:"))c.halfBilayerSize=parseFloat(r.substr(r.indexOf(":")+1).trim());else if(210==e)"EXPERIMENT TYPE"==r.substr(11,32).trim()&&"NMR"==r.substr(45).trim()&&(m=!0);else if(350==e&&"BIOMT"==r.substr(13,5)){let e=parseInt(r[18])-1,t=parseInt(r.substr(21,2))-1;null==c.biomtMatrices[t]&&(c.biomtMatrices[t]=(new THREE.Matrix4).identity()),c.biomtMatrices[t].elements[e]=parseFloat(r.substr(24,9)),c.biomtMatrices[t].elements[e+4]=parseFloat(r.substr(34,9)),c.biomtMatrices[t].elements[e+8]=parseFloat(r.substr(44,9)),c.biomtMatrices[t].elements[e+12]=parseFloat(r.substr(54,14))}else if(465==e&&" "==r.substr(18,1)&&" "==r.substr(20,1)&&"S"!=r.substr(21,1)){let e=r.substr(15,3),t=r.substr(18,2).trim(),s=r.substr(21,5).trim(),i=D+"_"+t;void 0===c.chainMissingResidueArray[i]&&(c.chainMissingResidueArray[i]=[]);let n={};n.resi=s,n.name=h.utilsCls.residueName2Abbr(e).toLowerCase(),""!=F&&t==F&&t!=F||(c.chainMissingResidueArray[i].push(n),F=t)}else 900==e&&void 0===c.emd&&"RELATED DB: EMDB"==r.substr(34).trim()&&(c.emd=r.substr(23,11).trim())}else if("SOURCE"===o&&void 0===c.organism&&"ORGANISM_COMMON"==r.substr(11,15).trim())c.organism=r.substr(28).toLowerCase().trim(),c.organism=c.organism.substr(0,c.organism.length-1);else if("ENDMDL"===o)++d,D=c.defaultPdbId,H=this.getStructureId(D,d,n),m||(A=[],x=[],k=[],O=[],R=[],E=[]),L=!1;else if("JRNL "===o)"PMID"===r.substr(12,4)&&(c.pmid=r.substr(19).trim());else if("ATOM "===o||"HETATM"===o){H=this.getStructureId(D,d,n);let e=r.substr(16,1);++a,P[parseInt(r.substr(6,5))]=a;let t=r.substr(76,2).trim();""===t&&(t=r.substr(12,2).trim());let l=r.substr(12,4).trim(),u=r.substr(17,3),F=r.substr(20,2).trim();""===F&&(F="A");let L=r.substr(22,5).trim(),N=L;if(s&&"DUM"===u&&(t=l,F="MEM",N=1,L=1),i&&"DUM"===u)break;b=H+"_"+F,y=b+"_"+L,C=b+"_"+N;let U=parseFloat(r.substr(30,8)),q=parseFloat(r.substr(38,8)),$=parseFloat(r.substr(46,8)),j=new THREE.Vector3(U,q,$),B={het:"H"===o[0],serial:a,name:l,alt:e,resn:u,structure:H,chain:F,resi:N,coord:j,b:parseFloat(r.substr(60,8)),elem:t,bonds:[],ss:"coil",ssbegin:!1,ssend:!1};if(B.het||"C"!==B.name||(v=a),B.het||"O"!==B.name||(_=a),!B.het&&"N"===B.name&&void 0!==w&&void 0!==S){let e=c.atoms[w].coord.distanceTo(c.atoms[S].coord),t=B.coord.x+(c.atoms[w].coord.x-c.atoms[S].coord.x)/e,s=B.coord.y+(c.atoms[w].coord.y-c.atoms[S].coord.y)/e,i=B.coord.z+(c.atoms[w].coord.z-c.atoms[S].coord.z)/e;B.hcoord=new THREE.Vector3(t,s,i)}c.atoms[a]=B,c.dAtoms[a]=1,c.hAtoms[a]=1,p[a]=1,this.isSecondary(C,A,m)?(c.atoms[a].ss="sheet",this.isSecondary(C,x,m)&&(c.atoms[a].ssbegin=!0),this.isSecondary(C,k,m)&&(c.atoms[a].ssend=!0)):this.isSecondary(C,O,m)&&(c.atoms[a].ss="helix",this.isSecondary(C,R,m)&&(c.atoms[a].ssbegin=!0),this.isSecondary(C,E,m)&&(c.atoms[a].ssend=!0));let z="-";if(z="helix"===c.atoms[a].ss?"H":"sheet"===c.atoms[a].ss?"E":!c.atoms[a].het&&h.parasCls.residueColors.hasOwnProperty(c.atoms[a].resn.toUpperCase())?"c":"o",c.secondaries[C]=z,y!==M){let e=h.utilsCls.residueName2Abbr(u);if(c.residueId2Name[C]=e,1!==a&&""!==T&&(c.residues[T]=f),C!==T&&(f={}),b!==I){w=void 0,S=void 0,1!==a&&""!==I&&(void 0===c.chains[I]&&(c.chains[I]={}),c.chains[I]=h.hashUtilsCls.unionHash(c.chains[I],g)),g={},void 0===c.structures[H.toString()]&&(c.structures[H.toString()]=[]),c.structures[H.toString()].includes(b)||c.structures[H.toString()].push(b),void 0===c.chainsSeq[b]&&(c.chainsSeq[b]=[]);let t={};t.resi=N,t.name=e,c.chainsSeq[b].push(t)}else{w=v,S=_;let t={};t.resi=N,t.name=e,c.chainsSeq[b].push(t)}}g[a]=1,f[a]=1,I=b,T=C,M=y}else if("CONECT"===o){let e=parseInt(r.substr(6,5));for(let t=0;t<4;++t){let s=parseInt(r.substr([11,16,21,26][t],5));isNaN(s)||void 0!==c.atoms[P[e]]&&c.atoms[P[e]].bonds.push(P[s])}}else"TER"===o.substr(0,3)&&++a;else D=r.substr(62).trim(),""==D&&(D=l?c.defaultPdbId:c.inputid&&-1==c.inputid.indexOf("/")?c.inputid.substr(0,10):c.defaultPdbId),H=this.getStructureId(D,d,n),c.molTitle="",L=!0}c.residues[C]=f,void 0===c.chains[b]&&(c.chains[b]={}),c.chains[b]=h.hashUtilsCls.unionHash2Atoms(c.chains[b],g,c.atoms),n||this.adjustSeq(c.chainMissingResidueArray);let N=Object.keys(c.structures);for(let e=0,t=N.length;e=l?n:l,o=new Array(s+i),a=0,d=0,c=0,h=!1;for(;ar&&i>r&&(h=!0),s<=r&&i>r?s>i||h?(o[c]=t[d],d++):(o[c]=e[a],a++):s>r&&i<=r?s<=i||h?(o[c]=e[a],a++):(o[c]=t[d],d++):s<=i?(o[c]=e[a],a++):(o[c]=t[d],d++),c++}if(a4||Math.abs(l.y-r.y)>4||Math.abs(l.z-r.z)>4||(l.x-r.x)*(l.x-r.x)+(l.y-r.y)*(l.y-r.y)+(l.z-r.z)*(l.z-r.z)<16&&(void 0===e.ssbondpnts[s]&&(e.ssbondpnts[s]=[]),e.ssbondpnts[s].push(o),e.ssbondpnts[s].push(a)))}}}getChainCalpha(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r={};for(let o in e){if(void 0!==i){if(o.split("_")[0]!==i)continue}let a=Object.keys(e[o]),d=[],c=0,h=0;for(let e=0,i=a.length;e3?i.resn.trim().substr(0,3):i.resn.trim();if(!l.parasCls.chargeColors.hasOwnProperty(e))continue;s?i.resi_ori:i.resi,d.push(i.coord.clone()),++c,h=i.resi}}if(c>0){r[t[a[0]].chain]=d}}return{chainresiCalphaHash:r,center:n.center.clone()}}isSecondary(e,t,s){if(this.icn3d.icn3dui,s){let s=e.substr(e.indexOf("_")+1),i=!1;for(let e=0,n=t.length;e0&&(d=!0);for(let n=0,l=t.length;na&&(a=l),s.push(l)}o.push(s)}if(!d)return void(n.bRender&&alert("These structures can not be aligned..."));a<1e-6&&(a=1);for(let e=0,s=t.length;ep[e]=4&&(n.rmsd_suprTmp=l.rmsdSuprCls.getRmsdSuprCls(c,a,p),void 0!==n.rmsd_suprTmp.rot))){let e=n.rmsd_suprTmp.rot;if(null===e[0])continue;let i=n.rmsd_suprTmp.trans1,r=n.rmsd_suprTmp.trans2,a=n.rmsd_suprTmp.rmsd;if(aRealignment RMSD: "+a.toPrecision(4)+" Å

    "),l.cfg.bSidebyside||l.htmlCls.dialogCls.openDlg("dl_rmsd","Realignment RMSD"),n.q_rotation=[],n.q_trans_sub=[],n.t_trans_add=[],n.q_rotation.push({x1:e[0],y1:e[1],z1:e[2],x2:e[3],y2:e[4],z2:e[5],x3:e[6],y3:e[7],z3:e[8]}),n.q_trans_sub.push(i),n.t_trans_add.push({x:-r.x,y:-r.y,z:-r.z}),l.cfg.aligntool="vast";//!= 'tmalign'; +var icn3d=function(e){"use strict";class t{constructor(e){this.icn3dui=e}cloneHash(e){this.icn3dui;let t={};void 0===e&&(e={});for(let s in e)t[s]=e[s];return t}intHash(e,t){this.icn3dui;let s={};if(void 0===e&&(e={}),void 0===t&&(t={}),Object.keys(e).length0||window.navigator.userAgent.match(/Trident.*rv\:11\./))}isMobile(){return this.icn3dui,/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)}isMac(){return this.icn3dui,/Mac/i.test(window.navigator.userAgent)}isAndroid(){return this.icn3dui,/android/i.test(window.navigator.userAgent.toLowerCase())}isChrome(){return this.icn3dui,navigator.userAgent.includes("Chrome")&&navigator.vendor.includes("Google Inc")}isSessionStorageSupported(){return this.icn3dui,window.sessionStorage}isLocalStorageSupported(){return this.icn3dui,window.localStorage}hexToRgb(e,t){this.icn3dui;let s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return s?{r:parseInt(s[1],16),g:parseInt(s[2],16),b:parseInt(s[3],16),a:t}:null}isCalphaPhosOnly(e){this.icn3dui;let t=!1,s=0,i=0;for(let t in e){if(!(s<100))break;{let s=e[t].name.trim();"CA"!==s&&"P"!==s&&"O3'"!==s&&"O3*"!==s&&++i}++s}return i<.5*s&&(t=!0),t}hasCovalentBond(e,t){let s=this.icn3dui,i=s.parasCls.covalentRadii[e.elem.toUpperCase()]+s.parasCls.covalentRadii[t.elem.toUpperCase()],n=e.coord.x-t.coord.x,l=e.coord.y-t.coord.y,r=e.coord.z-t.coord.z;return n*n+l*l+r*r<("N"==e.elem&&"H"==t.elem.substr(0,1)||"N"==t.elem&&"H"==e.elem.substr(0,1)?2.2:1.3)*i*i}residueName2Abbr(e){this.icn3dui;let t=e.indexOf(" ");switch(t>0&&(e=e.substr(0,t)),e){case" A":case" DA":case"DA":case"ALA":return"A";case" C":case" DC":case"DC":case"CYS":return"C";case" G":case" DG":case"DG":case"GLY":return"G";case" T":case" DT":case"DT":case"THR":return"T";case" U":case" DU":case"DU":case"SEC":return"U";case" I":case" DI":case"DI":case"ILE":return"I";case"ARG":return"R";case"ASN":return"N";case"ASP":return"D";case"GLU":return"E";case"GLN":return"Q";case"HIS":return"H";case"LEU":return"L";case"LYS":return"K";case"MET":return"M";case"PHE":return"F";case"PRO":return"P";case"SER":return"S";case"TRP":return"W";case"TYR":return"Y";case"VAL":return"V";case"HOH":case"WAT":return"O";default:return e.trim()}}residueAbbr2Name(e){if(this.icn3dui,(e=e.toUpperCase()).length>1)return e;switch(e){case"A":return"ALA";case"R":return"ARG";case"N":return"ASN";case"D":return"ASP";case"C":return"CYS";case"E":return"GLU";case"Q":return"GLN";case"G":return"GLY";case"H":return"HIS";case"I":return"ILE";case"L":return"LEU";case"K":return"LYS";case"M":return"MET";case"F":return"PHE";case"P":return"PRO";case"S":return"SER";case"T":return"THR";case"W":return"TRP";case"Y":return"TYR";case"V":return"VAL";case"O":return"HOH";default:return e.trim()}}getJSONFromArray(e){this.icn3dui;let t="";for(let s=0,i=e.length;sd?1:ah?1:cs&&(e.htmlCls.WIDTH=s),i&&e.htmlCls.HEIGHT>i&&(e.htmlCls.HEIGHT=i)}sumArray(e){let t=0;for(let s=0,i=e.length;sRed and blue membranes indicate extracellular and intracellular membranes, respectively.

    "}}class i{constructor(e){this.icn3dui=e,this.glycanHash={GLC:{c:"1E90FF",s:"sphere"},BGC:{c:"1E90FF",s:"sphere"},NAG:{c:"1E90FF",s:"cube"},NDG:{c:"1E90FF",s:"cube"},GCS:{c:"1E90FF",s:"cube"},PA1:{c:"1E90FF",s:"cube"},GCU:{c:"1E90FF",s:"cone"},BDP:{c:"1E90FF",s:"cone"},G6D:{c:"1E90FF",s:"cone"},DDA:{c:"1E90FF",s:"cylinder"},B6D:{c:"1E90FF",s:"cylinder"},XXM:{c:"1E90FF",s:"cylinder"},MAN:{c:"00FF00",s:"sphere"},BMA:{c:"00FF00",s:"sphere"},BM3:{c:"00FF00",s:"cube"},"95Z":{c:"00FF00",s:"cube"},MAV:{c:"00FF00",s:"cone"},BEM:{c:"00FF00",s:"cone"},RAM:{c:"00FF00",s:"cone"},RM4:{c:"00FF00",s:"cone"},TYV:{c:"00FF00",s:"cylinder"},ARA:{c:"00FF00",s:"cylinder"},ARB:{c:"00FF00",s:"cylinder"},KDN:{c:"00FF00",s:"cylinder"},KDM:{c:"00FF00",s:"cylinder"},"6PZ":{c:"00FF00",s:"cylinder"},GMH:{c:"00FF00",s:"cylinder"},BDF:{c:"00FF00",s:"cylinder"},GAL:{c:"FFFF00",s:"sphere"},GLA:{c:"FFFF00",s:"sphere"},NGA:{c:"FFFF00",s:"cube"},A2G:{c:"FFFF00",s:"cube"},X6X:{c:"FFFF00",s:"cube"},"1GN":{c:"FFFF00",s:"cube"},ADA:{c:"FFFF00",s:"cone"},GTR:{c:"FFFF00",s:"cone"},LDY:{c:"FFFF00",s:"cylinder"},KDO:{c:"FFFF00",s:"cylinder"},T6T:{c:"FFFF00",s:"cylinder"},GUP:{c:"A52A2A",s:"sphere"},GL0:{c:"A52A2A",s:"sphere"},LGU:{c:"A52A2A",s:"cone"},ABE:{c:"A52A2A",s:"cylinder"},XYS:{c:"A52A2A",s:"cylinder"},XYP:{c:"A52A2A",s:"cylinder"},SOE:{c:"A52A2A",s:"cylinder"},PZU:{c:"FF69B4",s:"cylinder"},RIP:{c:"FF69B4",s:"cylinder"},"0MK":{c:"FF69B4",s:"cylinder"},ALL:{c:"8A2BE2",s:"sphere"},AFD:{c:"8A2BE2",s:"sphere"},NAA:{c:"8A2BE2",s:"cube"},SIA:{c:"8A2BE2",s:"cylinder"},SIB:{c:"8A2BE2",s:"cylinder"},AMU:{c:"8A2BE2",s:"cylinder"},X0X:{c:"1E90FF",s:"cone"},X1X:{c:"1E90FF",s:"cone"},NGC:{c:"1E90FF",s:"cylinder"},NGE:{c:"1E90FF",s:"cylinder"},"4N2":{c:"A0522D",s:"sphere"},HSQ:{c:"A0522D",s:"cube"},IDR:{c:"A0522D",s:"cone"},MUR:{c:"A0522D",s:"cylinder"},FUC:{c:"FF0000",s:"cone"},FUL:{c:"FF0000",s:"cone"}},this.nucleotidesArray=[" G"," A"," T"," C"," U"," DG"," DA"," DT"," DC"," DU","G","A","T","C","U","DG","DA","DT","DC","DU"],this.ionsArray=[" K"," NA"," MG"," AL"," CA"," TI"," MN"," FE"," NI"," CU"," ZN"," AG"," BA"," F"," CL"," BR"," I","K","NA","MG","AL","CA","TI","MN","FE","NI","CU","ZN","AG","BA","F","CL","BR","I"],this.cationsTrimArray=["K","NA","MG","AL","CA","TI","MN","FE","NI","CU","ZN","AG","BA"],this.anionsTrimArray=["F","CL","BR","I"],this.ionCharges={K:1,NA:1,MG:2,AL:3,CA:2,TI:3,MN:2,FE:3,NI:2,CU:2,ZN:2,AG:1,BA:2},this.vdwRadii={H:1.08,HE:1.34,LI:1.75,BE:2.05,B:1.47,C:1.49,N:1.41,O:1.4,F:1.39,NE:1.68,NA:1.84,MG:2.05,AL:2.11,SI:2.07,P:1.92,S:1.82,CL:1.83,AR:1.93,K:2.05,CA:2.21,SC:2.16,TI:1.87,V:1.79,CR:1.89,MN:1.97,FE:1.94,CO:1.92,NI:1.84,CU:1.86,ZN:2.1,GA:2.08,GE:2.15,AS:2.06,SE:1.93,BR:1.98,KR:2.12,RB:2.16,SR:2.24,Y:2.19,ZR:1.86,NB:2.07,MO:2.09,TC:2.09,RU:2.07,RH:1.95,PD:2.02,AG:2.03,CD:2.3,IN:2.36,SN:2.33,SB:2.25,TE:2.23,I:2.23,XE:2.21,CS:2.22,BA:2.51,LA:2.4,CE:2.35,PR:2.39,ND:2.29,PM:2.36,SM:2.29,EU:2.33,GD:2.37,TB:2.21,DY:2.29,HO:2.16,ER:2.35,TM:2.27,YB:2.42,LU:2.21,HF:2.12,TA:2.17,W:2.1,RE:2.17,OS:2.16,IR:2.02,PT:2.09,AU:2.17,HG:2.09,TL:2.35,PB:2.32,BI:2.43,PO:2.29,AT:2.36,RN:2.43,FR:2.56,RA:2.43,AC:2.6,TH:2.37,PA:2.43,U:2.4,NP:2.21,PU:2.56,AM:2.56,CM:2.56,BK:2.56,CF:2.56,ES:2.56,FM:2.56},this.covalentRadii={H:.31,HE:.28,LI:1.28,BE:.96,B:.84,C:.76,N:.71,O:.66,F:.57,NE:.58,NA:1.66,MG:1.41,AL:1.21,SI:1.11,P:1.07,S:1.05,CL:1.02,AR:1.06,K:2.03,CA:1.76,SC:1.7,TI:1.6,V:1.53,CR:1.39,MN:1.39,FE:1.32,CO:1.26,NI:1.24,CU:1.32,ZN:1.22,GA:1.22,GE:1.2,AS:1.19,SE:1.2,BR:1.2,KR:1.16,RB:2.2,SR:1.95,Y:1.9,ZR:1.75,NB:1.64,MO:1.54,TC:1.47,RU:1.46,RH:1.42,PD:1.39,AG:1.45,CD:1.44,IN:1.42,SN:1.39,SB:1.39,TE:1.38,I:1.39,XE:1.4,CS:2.44,BA:2.15,LA:2.07,CE:2.04,PR:2.03,ND:2.01,PM:1.99,SM:1.98,EU:1.98,GD:1.96,TB:1.94,DY:1.92,HO:1.92,ER:1.89,TM:1.9,YB:1.87,LU:1.87,HF:1.75,TA:1.7,W:1.62,RE:1.51,OS:1.44,IR:1.41,PT:1.36,AU:1.36,HG:1.32,TL:1.45,PB:1.46,BI:1.48,PO:1.4,AT:1.5,RN:1.5,FR:2.6,RA:2.21,AC:2.15,TH:2.06,PA:2,U:1.96,NP:1.9,PU:1.87,AM:1.8,CM:1.69},this.atomColors={H:this.thr(16777215),He:this.thr(16761035),HE:this.thr(16761035),Li:this.thr(11674146),LI:this.thr(11674146),B:this.thr(65280),C:this.thr(11184810),N:this.thr(255),O:this.thr(15728640),F:this.thr(14329120),Na:this.thr(255),NA:this.thr(255),Mg:this.thr(2263842),MG:this.thr(2263842),Al:this.thr(8421520),AL:this.thr(8421520),Si:this.thr(14329120),SI:this.thr(14329120),P:this.thr(16753920),S:this.thr(16762930),Cl:this.thr(65280),CL:this.thr(65280),Ca:this.thr(8421520),CA:this.thr(8421520),Ti:this.thr(8421520),TI:this.thr(8421520),Cr:this.thr(8421520),CR:this.thr(8421520),Mn:this.thr(8421520),MN:this.thr(8421520),Fe:this.thr(16753920),FE:this.thr(16753920),Ni:this.thr(10824234),NI:this.thr(10824234),Cu:this.thr(10824234),CU:this.thr(10824234),Zn:this.thr(10824234),ZN:this.thr(10824234),Br:this.thr(10824234),BR:this.thr(10824234),Ag:this.thr(8421520),AG:this.thr(8421520),I:this.thr(10494192),Ba:this.thr(16753920),BA:this.thr(16753920),Au:this.thr(14329120),AU:this.thr(14329120)},this.atomnames={H:"Hydrogen",HE:"Helium",LI:"Lithium",B:"Boron",C:"Carbon",N:"Nitrogen",O:"Oxygen",F:"Fluorine",NA:"Sodium",MG:"Magnesium",AL:"Aluminum",SI:"Silicon",P:"Phosphorus",S:"Sulfur",CL:"Chlorine",CA:"Calcium",TI:"Titanium",CR:"Chromium",MN:"Manganese",FE:"Iron",NI:"Nickel",CU:"Copper",ZN:"Zinc",BR:"Bromine",AG:"Silver",I:"Iodine",BA:"Barium",AU:"Gold"},this.defaultAtomColor=this.thr(13421772),this.stdChainColors=[this.thr(16711935),this.thr(255),this.thr(10053171),this.thr(65433),this.thr(16750848),this.thr(16737894),this.thr(3329330),this.thr(2003199),this.thr(16416882),this.thr(16753920),this.thr(52945),this.thr(16738740),this.thr(65280),this.thr(255),this.thr(16711680),this.thr(16776960),this.thr(65535),this.thr(16711935),this.thr(3978097),this.thr(4620980),this.thr(13458524),this.thr(16770229),this.thr(11529966),this.thr(15631086),this.thr(25600),this.thr(139),this.thr(9109504),this.thr(13468991),this.thr(35723),this.thr(9699539)],this.backgroundColors={black:this.thr(0),grey:this.thr(13421772),white:this.thr(16777215),transparent:this.thr(16777215)},this.residueColors={ALA:this.thr(13158600),ARG:this.thr(1334015),ASN:this.thr(56540),ASP:this.thr(15075850),CYS:this.thr(15132160),GLN:this.thr(56540),GLU:this.thr(15075850),GLY:this.thr(15461355),HIS:this.thr(8553170),ILE:this.thr(1016335),LEU:this.thr(1016335),LYS:this.thr(1334015),MET:this.thr(15132160),PHE:this.thr(3289770),PRO:this.thr(14456450),SER:this.thr(16422400),THR:this.thr(16422400),TRP:this.thr(11819700),TYR:this.thr(3289770),VAL:this.thr(1016335),ASX:this.thr(16738740),GLX:this.thr(16738740),G:this.thr(32768),A:this.thr(6324479),T:this.thr(16744448),C:this.thr(16711680),U:this.thr(16744448),DG:this.thr(32768),DA:this.thr(6324479),DT:this.thr(16744448),DC:this.thr(16711680),DU:this.thr(16744448)},this.residueArea={ALA:247,ARG:366,ASN:290,ASP:285,CYS:271,GLN:336,GLU:325,GLY:217,HIS:340,ILE:324,LEU:328,LYS:373,MET:346,PHE:366,PRO:285,SER:265,THR:288,TRP:414,TYR:387,VAL:293,ASX:290,GLX:336,G:520,A:507,T:515,C:467,U:482,DG:520,DA:507,DT:515,DC:467,DU:482},this.defaultResidueColor=this.thr(12492910),this.chargeColors={" G":this.thr(16711680)," A":this.thr(16711680)," T":this.thr(16711680)," C":this.thr(16711680)," U":this.thr(16711680)," DG":this.thr(16711680)," DA":this.thr(16711680)," DT":this.thr(16711680)," DC":this.thr(16711680)," DU":this.thr(16711680),G:this.thr(16711680),A:this.thr(16711680),T:this.thr(16711680),C:this.thr(16711680),U:this.thr(16711680),DG:this.thr(16711680),DA:this.thr(16711680),DT:this.thr(16711680),DC:this.thr(16711680),DU:this.thr(16711680),ARG:this.thr(255),LYS:this.thr(255),ASP:this.thr(16711680),GLU:this.thr(16711680),HIS:this.thr(8421631),GLY:this.thr(8947848),PRO:this.thr(8947848),ALA:this.thr(8947848),VAL:this.thr(8947848),LEU:this.thr(8947848),ILE:this.thr(8947848),PHE:this.thr(8947848),SER:this.thr(8947848),THR:this.thr(8947848),ASN:this.thr(8947848),GLN:this.thr(8947848),TYR:this.thr(8947848),MET:this.thr(8947848),CYS:this.thr(8947848),TRP:this.thr(8947848)},this.hydrophobicColors={" G":this.thr(16711680)," A":this.thr(16711680)," T":this.thr(16711680)," C":this.thr(16711680)," U":this.thr(16711680)," DG":this.thr(16711680)," DA":this.thr(16711680)," DT":this.thr(16711680)," DC":this.thr(16711680)," DU":this.thr(16711680),G:this.thr(16711680),A:this.thr(16711680),T:this.thr(16711680),C:this.thr(16711680),U:this.thr(16711680),DG:this.thr(16711680),DA:this.thr(16711680),DT:this.thr(16711680),DC:this.thr(16711680),DU:this.thr(16711680),ARG:this.thr(255),LYS:this.thr(255),ASP:this.thr(16711680),GLU:this.thr(16711680),HIS:this.thr(8421631),TRP:this.thr().setHSL(1/3,1,.5),PHE:this.thr().setHSL(1/3,1,.6945945945945946),TYR:this.thr().setHSL(1/3,1,.745945945945946),LEU:this.thr().setHSL(1/3,1,.5+.645/1.85),ILE:this.thr().setHSL(1/3,1,.5+.77/1.85),CYS:this.thr().setHSL(1/3,1,.5+.805/1.85),MET:this.thr().setHSL(1/3,1,.5+.81/1.85),GLY:this.thr().setHSL(1/6,1,.5+.285/.58),VAL:this.thr().setHSL(1/6,1,.5+.255/.58),SER:this.thr().setHSL(1/6,1,.8879310344827587),THR:this.thr().setHSL(1/6,1,.8793103448275862),ALA:this.thr().setHSL(1/6,1,.853448275862069),ASN:this.thr().setHSL(1/6,1,.6379310344827587),PRO:this.thr().setHSL(1/6,1,.6120689655172413),GLN:this.thr().setHSL(1/6,1,.5)},this.normalizedHPColors={" G":this.thr(16777215)," A":this.thr(16777215)," T":this.thr(16777215)," C":this.thr(16777215)," U":this.thr(16777215)," DG":this.thr(16777215)," DA":this.thr(16777215)," DT":this.thr(16777215)," DC":this.thr(16777215)," DU":this.thr(16777215),G:this.thr(16777215),A:this.thr(16777215),T:this.thr(16777215),C:this.thr(16777215),U:this.thr(16777215),DG:this.thr(16777215),DA:this.thr(16777215),DT:this.thr(16777215),DC:this.thr(16777215),DU:this.thr(16777215),ARG:this.thr(16777215),LYS:this.thr(16777215),ASP:this.thr(16777215),GLU:this.thr(16777215),HIS:this.thr(16777215),TRP:this.thr().setHSL(1/3,1,.5),PHE:this.thr().setHSL(1/3,1,.644),TYR:this.thr().setHSL(1/3,1,.682),LEU:this.thr().setHSL(1/3,1,.758),ILE:this.thr().setHSL(1/3,1,.808),CYS:this.thr().setHSL(1/3,1,.5+.322),MET:this.thr().setHSL(1/3,1,.5+.324),GLY:this.thr().setHSL(1/3,1,.872),VAL:this.thr().setHSL(1/3,1,.884),SER:this.thr().setHSL(1/3,1,.896),THR:this.thr().setHSL(1/3,1,.898),ALA:this.thr().setHSL(1/3,1,.904),ASN:this.thr().setHSL(1/3,1,.954),PRO:this.thr().setHSL(1/3,1,.9600000000000001),GLN:this.thr().setHSL(1/3,1,.986)},this.hydrophobicValues={" G":3," A":3," T":3," C":3," U":3," DG":3," DA":3," DT":3," DC":3," DU":3,G:3,A:3,T:3,C:3,U:3,DG:3,DA:3,DT:3,DC:3,DU:3,ARG:1,LYS:1,ASP:3,GLU:3,HIS:2,TRP:-1.85,PHE:-1.13,TYR:-.94,LEU:-.56,ILE:-.31,CYS:-.24,MET:-.23,GLY:.01,VAL:.07,SER:.13,THR:.14,ALA:.17,ASN:.42,PRO:.45,GLN:.58},this.residueAbbrev={ALA:"A (Ala)",ARG:"R (Arg)",ASN:"N (Asn)",ASP:"D (Asp)",CYS:"C (Cys)",GLN:"Q (Gln)",GLU:"E (Glu)",GLY:"G (Gly)",HIS:"H (His)",ILE:"I (Ile)",LEU:"L (Leu)",LYS:"K (Lys)",MET:"M (Met)",PHE:"F (Phe)",PRO:"P (Pro)",SER:"S (Ser)",THR:"T (Thr)",TRP:"W (Trp)",TYR:"Y (Tyr)",VAL:"V (Val)",ASX:"X (Asx)",GLX:"X (Glx)",G:"Guanine",A:"Adenine",T:"Thymine",C:"Cytosine",U:"Uracil",DG:"deoxy-Guanine",DA:"deoxy-Adenine",DT:"deoxy-Thymine",DC:"deoxy-Cytosine",DU:"deoxy-Uracil"},this.ssColors={helix:this.thr(16711680),sheet:this.thr(32768),coil:this.thr(6324479)},this.ssColors2={helix:this.thr(16711680),sheet:this.thr(16762880),coil:this.thr(6324479)},this.resn2restype={ALA:1,ARG:4,ASN:7,ASP:10,CYS:13,GLN:16,GLU:19,GLY:22,HIS:25,ILE:28,LEU:31,LYS:34,MET:37,PHE:40,PRO:43,SER:46,THR:49,TRP:52,TYR:55,VAL:58},this.nuclMainArray=["C1'","C1*","C2'","C2*","C3'","C3*","C4'","C4*","C5'","C5*","O3'","O3*","O4'","O4*","O5'","O5*","P","OP1","O1P","OP2","O2P"],this.b62ResArray=["A","R","N","D","C","Q","E","G","H","I","L","K","M","F","P","S","T","W","Y","V","B","Z","X","*"],this.b62Matrix=[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0,-4],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1,-4],[-2,0,6,1,-3,0,0,0,1,-3,-3,0,-2,-3,-2,1,0,-4,-2,-3,3,0,-1,-4],[-2,-2,1,6,-3,0,2,-1,-1,-3,-4,-1,-3,-3,-1,0,-1,-4,-3,-3,4,1,-1,-4],[0,-3,-3,-3,9,-3,-4,-3,-3,-1,-1,-3,-1,-2,-3,-1,-1,-2,-2,-1,-3,-3,-2,-4],[-1,1,0,0,-3,5,2,-2,0,-3,-2,1,0,-3,-1,0,-1,-2,-1,-2,0,3,-1,-4],[-1,0,0,2,-4,2,5,-2,0,-3,-3,1,-2,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-2,0,-1,-3,-2,-2,6,-2,-4,-4,-2,-3,-3,-2,0,-2,-2,-3,-3,-1,-2,-1,-4],[-2,0,1,-1,-3,0,0,-2,8,-3,-3,-1,-2,-1,-2,-1,-2,-2,2,-3,0,0,-1,-4],[-1,-3,-3,-3,-1,-3,-3,-4,-3,4,2,-3,1,0,-3,-2,-1,-3,-1,3,-3,-3,-1,-4],[-1,-2,-3,-4,-1,-2,-3,-4,-3,2,4,-2,2,0,-3,-2,-1,-2,-1,1,-4,-3,-1,-4],[-1,2,0,-1,-3,1,1,-2,-1,-3,-2,5,-1,-3,-1,0,-1,-3,-2,-2,0,1,-1,-4],[-1,-1,-2,-3,-1,0,-2,-3,-2,1,2,-1,5,0,-2,-1,-1,-1,-1,1,-3,-1,-1,-4],[-2,-3,-3,-3,-2,-3,-3,-3,-1,0,0,-3,0,6,-4,-2,-2,1,3,-1,-3,-3,-1,-4],[-1,-2,-2,-1,-3,-1,-1,-2,-2,-3,-3,-1,-2,-4,7,-1,-1,-4,-3,-2,-2,-1,-2,-4],[1,-1,1,0,-1,0,0,0,-1,-2,-2,0,-1,-2,-1,4,1,-3,-2,-2,0,0,0,-4],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,1,5,-2,-2,0,-1,-1,0,-4],[-3,-3,-4,-4,-2,-2,-3,-2,-2,-3,-2,-3,-1,1,-4,-3,-2,11,2,-3,-4,-3,-2,-4],[-2,-2,-2,-3,-2,-1,-2,-3,2,-1,-1,-2,-1,3,-3,-2,-2,2,7,-1,-3,-2,-1,-4],[0,-3,-3,-3,-1,-2,-2,-3,-3,3,1,-2,1,-1,-2,-2,0,-3,-1,4,-3,-2,-1,-4],[-2,-1,3,4,-3,0,1,-1,0,-3,-4,0,-3,-3,-2,0,-1,-4,-3,-3,4,1,-1,-4],[-1,0,0,1,-3,3,4,-2,0,-3,-3,1,-1,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,0,0,-2,-1,-1,-1,-1,-1,-4],[-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,1]]}thr(e){return this.icn3dui,"#0"==e&&(e="#000"),new THREE.Color(e)}}class n{constructor(e){this.icn3dui=e}onId(e,t,s){if(this.icn3dui,!(Object.keys(window).length<2)&&("#"==e.substr(0,1)&&(e=e.substr(1)),document.getElementById(e))){t.split(" ").forEach((t=>{document.getElementById(e).addEventListener(t,s)}))}}onIds(e,t,s){let i=this.icn3dui;Array.isArray(e)?e.forEach((e=>{i.myEventCls.onId(e,t,s)})):i.myEventCls.onId(e,t,s)}}class l{constructor(e){this.icn3dui=e}getRmsdSuprCls(e,t,s){let i,n,l,r,o,a,d,c,h,p,m,u,g,f=this.icn3dui,b=new Array(9),C=new THREE.Vector3,y=new THREE.Vector3,v=[],w=[],_=new Array(3),S=new Array(3),A=new Array(3),x=new Array(3),k=new Array(3),O=new Array(3);if(i=0,s<=1)return{rot:void 0,trans1:void 0,trans2:void 0,rmsd:999};let R=s;for(n=0;n0?(b[0]=x[0]*_[0]+k[0]*S[0]+O[0]*A[0],b[1]=x[0]*_[1]+k[0]*S[1]+O[0]*A[1],b[2]=x[0]*_[2]+k[0]*S[2]+O[0]*A[2],b[3]=x[1]*_[0]+k[1]*S[0]+O[1]*A[0],b[4]=x[1]*_[1]+k[1]*S[1]+O[1]*A[1],b[5]=x[1]*_[2]+k[1]*S[2]+O[1]*A[2],b[6]=x[2]*_[0]+k[2]*S[0]+O[2]*A[0],b[7]=x[2]*_[1]+k[2]*S[1]+O[2]*A[1],b[8]=x[2]*_[2]+k[2]*S[2]+O[2]*A[2]):(b[0]=x[0]*_[0]+k[0]*S[0]-O[0]*A[0],b[1]=x[0]*_[1]+k[0]*S[1]-O[0]*A[1],b[2]=x[0]*_[2]+k[0]*S[2]-O[0]*A[2],b[3]=x[1]*_[0]+k[1]*S[0]-O[1]*A[0],b[4]=x[1]*_[1]+k[1]*S[1]-O[1]*A[1],b[5]=x[1]*_[2]+k[1]*S[2]-O[1]*A[2],b[6]=x[2]*_[0]+k[2]*S[0]-O[2]*A[0],b[7]=x[2]*_[1]+k[2]*S[1]-O[2]*A[1],b[8]=x[2]*_[2]+k[2]*S[2]-O[2]*A[2]),c=Math.sqrt(c),h=Math.sqrt(h),p=Math.sqrt(p),g=c+h+u*p,m=a+d-2*g,i=m>0?Math.sqrt(m):void 0,{rot:b,trans1:E,trans2:I,rmsd:i})}eigen_values(e){let t,s,i,n,l,r,o,a,d,c,h,p,m,u,g,f,b,C,y,v;if(this.icn3dui,t=e[0],s=e[1],i=e[2],n=e[3],l=e[4],r=e[5],o=e[6],a=e[7],d=e[8],c=-(t+l+d),h=t*l+(t+l)*d-r*a-s*n-i*o,p=-t*l*d+t*r*a+s*n*d-s*r*o-i*n*a+i*l*o,m=-c*c/3+h,u=c*c*c/13.5-c*h/3+p,g=.25*u*u+m*m*m/27,g<0){let e,t;e=Math.sqrt(.25*u*u-g),t=Math.acos(-.5*u/e),C=2*Math.cbrt(e)*Math.cos(t/3)}else f=Math.cbrt(-.5*u+Math.sqrt(g)),b=Math.cbrt(-.5*u-Math.sqrt(g)),C=f+b;return C-=c/3,c+=C,p/=-C,y=.5*(-c+Math.sqrt(c*c-4*p)),v=.5*(-c-Math.sqrt(c*c-4*p)),y_&&(_=Math.abs(d)),Math.abs(c)>_&&(_=Math.abs(c)),Math.abs(h)>_&&(_=Math.abs(h)),Math.abs(p)>_&&(_=Math.abs(p)),Math.abs(m)>_&&(_=Math.abs(m)),Math.abs(u)>_&&(_=Math.abs(u)),Math.abs(g)>_&&(_=Math.abs(g)),Math.abs(f)>_&&(_=Math.abs(f)),_<1e-10)return r=3,{k:r,v1:t,v2:s,v3:i};if(o=0,a/=_,d/=_,c/=_,h/=_,p/=_,m/=_,u/=_,g/=_,f/=_,Math.abs(a)_&&(w=a,a=h,h=w,w=d,d=p,p=w,w=c,c=m,m=w,_=Math.abs(d)),Math.abs(g)>_&&(w=a,a=u,u=w,w=d,d=g,g=w,w=c,c=f,f=w),y=m-p*c/d,v=f-g*c/d,Math.abs(y)_&&(w=a,a=h,h=w,w=d,d=p,p=w,w=c,c=m,m=w,_=Math.abs(a)),Math.abs(c)>_&&(w=a,a=u,u=w,w=d,d=g,g=w,w=c,c=f,f=w),b=p-h*d/a,C=m-h*c/a,y=g-u*d/a,v=f-u*c/a,Math.abs(b)0&&(1==o?(a=s[0],d=s[1],c=s[2],w=Math.sqrt(a*a+d*d+c*c),s[0]=a/w,s[1]=d/w,s[2]=c/w):2==o?(a=t[0],d=t[1],c=t[2],h=s[0],p=s[1],m=s[2],w=a*h+d*p+c*m,Math.abs(w)>=n&&(s[0]=a+w*h,s[1]=d+w*p,s[2]=c+w*m,h=s[0],p=s[1],m=s[2]),w=Math.sqrt(a*a+d*d+c*c),t[0]=a/w,t[1]=d/w,t[2]=c/w,w=Math.sqrt(h*h+p*p+m*m),s[0]=h/w,s[1]=p/w,s[2]=m/w):(a=t[0],d=t[1],c=t[2],w=Math.sqrt(a*a+d*d+c*c),t[0]=a/w,t[1]=d/w,t[2]=c/w)),{k:r,v1:t,v2:s,v3:i}}getEigenForSelection(e,t){let s,i=this.icn3dui,n=new THREE.Vector3,l=[];for(s=0;s0&&Math.abs(l[0].x-e[0].x)<=6&&Math.abs(l[0].y-e[0].y)<=6&&Math.abs(l[0].z-e[0].z)<=6?(p.push(l[0]),m=1):m=0,p.push(e[0]);for(let t=1,s=e.length-1;t0&&Math.abs(r[0].x-e[e.length-1].x)<=6&&Math.abs(r[0].y-e[e.length-1].y)<=6&&Math.abs(r[0].z-e[e.length-1].z)<=6&&(p.push(r[0]),++g),u>1&&Math.abs(r[0].x-r[1].x)<=6&&Math.abs(r[0].y-r[1].y)<=6&&Math.abs(r[0].z-r[1].z)<=6&&(p.push(r[1]),++g);let f=[],b=[],C=[];o&&(g=u>0?u-1:0);let y;for(let e=-1,n=p.length,l=1/s;e<=n-3;++e){y=e-m;let r=p[-1===e?0:e],o=p[e+1],u=p[e+2],v=p[e===n-3?n-1:e+3],w=0,_=a.subdivideCls.getKnot(1,w,r,o),S=a.subdivideCls.getKnot(1,_,o,u),A=a.subdivideCls.getKnot(1,S,u,v);_-w<1e-4&&(_=w+1),S-_<1e-4&&(S=_+1),A-S<1e-4&&(A=S+1),e>-1&&(void 0===i||i[y+1])&&e>=-1+m&&e<=n-3-g+1&&(d=d.concat(f),c=c.concat(b),h=h.concat(C)),f=[],b=[],C=[];let x=(S-_)*l;for(let l=0;l=-1+m&&e<=n-3-g&&i[y+1]&&l<=parseInt(s/2)&&(d.push(new THREE.Vector3(k,O,R)),c.push(i[y+1]),h.push(t[y+1])),e>=-1+m&&e<=n-3-g+1&&i[y+2]&&l>parseInt(s/2)&&(f.push(new THREE.Vector3(k,O,R)),b.push(i[y+2]),C.push(t[y+2]))):e>=-1+m&&e<=n-3-g&&(d.push(new THREE.Vector3(k,O,R)),c.push(y+1),h.push(t[y+1]))}}i&&!i[y+1]||(d=d.concat(f),c=c.concat(b),h=h.concat(C),d.push(p[p.length-1-g]),c.push(p.length-1-g),h.push(t[p.length-1-g])),f=[],b=[],C=[],p=[];let v=[];return v.push(d),v.push(c),v.push(h),v}getKnot(e,t,s,i){return this.icn3dui,s.distanceTo(i)+t}getValueFromKnot(e,t,s,i,n,l,r,o,a){this.icn3dui;let d,c,h=(r-l)/(s-t),p=(o-r)/(i-s),m=(a-o)/(n-i),u=(s+i)*(s+i)-4*(t*s+i*n-t*n);return 0==u?(d=9999,c=9999):(d=6*(3*p*s+2*h*n+m*s-2*h*s-2*p*n-p*i-m*s)/u,c=6*(3*p*i+2*m*t+h*s-2*p*t-2*m*i-h*i-p*s)/u),p*(e-s)+r+((2*d+c)/6/(s-i)*(e-s)*(e-i)*(e-i)+(2*c+d)/6/(i-s)*(e-s)*(e-s)*(e-i))}}class o{constructor(e){this.icn3dui=e}passFloat32(e,t){let s=this.icn3dui,i=e.length;t||(t=new Uint8Array(4*i));let n=s.convertTypeCls.getDataView(t);for(let t=0;t  Very high (pLDDT > 90)
      Confident (90 > pLDDT > 70)
      Low (70 > pLDDT > 50)
      Very low (pLDDT < 50)
    '}setLegendHtml(e){let t=this.icn3dui.icn3d,s="
    ";if(e)s+=this.setAlphaFoldLegend();else{s+="
    "+t.startValue+""+t.midValue+""+t.endValue+"
    "}return s}SetChainsAdvancedMenu(){let e=this.icn3dui,t=e.icn3d;if(void 0===t.bSetChainsAdvancedMenu||!t.bSetChainsAdvancedMenu){let s=e.hashUtilsCls.cloneHash(t.hAtoms);t.definedSetsCls.setPredefinedInMenu(),t.bSetChainsAdvancedMenu=!0,t.hAtoms=e.hashUtilsCls.cloneHash(s)}}setSetsMenus(e,t){let s=this.icn3dui,i=s.icn3d;this.SetChainsAdvancedMenu();let n=e,l=e+"2",r=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+s.pre+n).length&&$("#"+s.pre+n).html(" "+r),!t&&$("#"+s.pre+l).length&&$("#"+s.pre+l).html(" "+r),$("#"+s.pre+n).resizable(),t||$("#"+s.pre+l).resizable()}applyShownMenus(){let e=this.icn3dui;e.icn3d;let t=[];for(let s in e.htmlCls.allMenus)e.htmlCls.shownMenus.hasOwnProperty(s)?$("#"+e.pre+s).parent().show():($("#"+e.pre+s).parent().hide(),t.push(s));Object.keys(e.htmlCls.shownMenus).length==Object.keys(e.htmlCls.allMenus).length?$(".icn3d-menusep").show():$(".icn3d-menusep").hide(),localStorage&&localStorage.setItem("hiddenmenus",JSON.stringify(t))}getHiddenMenusFromCache(){let e=this.icn3dui;e.icn3d,e.htmlCls.shownMenus={};let t=localStorage?localStorage.getItem("hiddenmenus"):"";if(t&&"[]"!=t){let s=JSON.parse(t);for(let t in e.htmlCls.allMenus)-1==s.indexOf(t)&&(e.htmlCls.shownMenus[t]=1)}else e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.allMenus)}displayShownMenus(){let e=this.icn3dui;e.icn3d;let t="
    ";t+="",t+="";for(let s in e.htmlCls.allMenusSel){if("uniclr"==s.substr(0,6)||"mn5_opacity"==s.substr(0,11)||"mn6_labelscale"==s.substr(0,14)||"faq_"==s.substr(0,4)||"dev_"==s.substr(0,4))continue;"mn1_searchstru"==s?t+="
    FileSelectViewStyleColorAnalysisHelp
    ":("mn2_definedsets"==s||"mn2_show_selected"==s||"mn3_proteinwrap"==s||e.cfg.cid&&"mn3_ligwrap"==s||"mn4_clrwrap"==s||"mn6_selectannotations"==s||"abouticn3d"==s)&&(t+="");let i=e.htmlCls.shownMenus.hasOwnProperty(s)?"checked":"",n=e.htmlCls.allMenusSel[s];t+=""+e.htmlCls.allMenus[s]+"
    "}t+="
    ",$("#"+e.pre+"menulist").html(t)}clickMenu1(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds("#"+e.pre+"mn1_vastplus","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_vastplus","Please input PDB ID for VAST+")})),e.myEventCls.onIds("#"+e.pre+"mn1_vast","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_vast","Please input chain or PDB file for VAST")})),e.myEventCls.onIds("#"+e.pre+"mn1_foldseek","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_foldseek","Submit your selection to Foldseek")})),e.myEventCls.onIds("#"+e.pre+"mn1_mmtfid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmtfid","Please input MMTF ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_pdbid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pdbid","Please input PDB ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_afid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_afid","Please input AlphaFold UniProt ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_refseqid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_refseqid","Please input NCBI Protein Accession")})),e.myEventCls.onIds("#"+e.pre+"mn1_opmid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_opmid","Please input OPM PDB ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_align","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_align","Align two PDB structures")})),e.myEventCls.onIds("#"+e.pre+"mn1_alignaf","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_alignaf","Align two AlphaFold structures")})),e.myEventCls.onIds("#"+e.pre+"mn1_chainalign","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_chainalign","Align multiple chains by structure alignment")})),e.myEventCls.onIds("#"+e.pre+"mn1_chainalign2","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_chainalign2","Align multiple chains by sequence alignment")})),e.myEventCls.onIds("#"+e.pre+"mn1_chainalign3","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_chainalign3","Align multiple chains residue by residue")})),e.myEventCls.onIds("#"+e.pre+"mn1_mutation","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mutation","Show the mutations in 3D")})),e.myEventCls.onIds("#"+e.pre+"mn1_pdbfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pdbfile","Please input PDB File")})),e.myEventCls.onIds(["#"+e.pre+"mn1_pdbfile_app","#"+e.pre+"tool_pdbfile"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pdbfile_app","Please append PDB Files")})),e.myEventCls.onIds("#"+e.pre+"mn1_mol2file","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mol2file","Please input Mol2 File")})),e.myEventCls.onIds("#"+e.pre+"mn1_sdffile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_sdffile","Please input SDF File")})),e.myEventCls.onIds("#"+e.pre+"mn1_xyzfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_xyzfile","Please input XYZ File")})),e.myEventCls.onIds("#"+e.pre+"mn1_afmapfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_afmapfile","Please input AlphaFold PAE File")})),e.myEventCls.onIds("#"+e.pre+"mn1_urlfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_urlfile","Load data by URL")})),e.myEventCls.onIds("#"+e.pre+"mn1_fixedversion","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_fixedversion","Open Share Link URL in the archived version of iCn3D")})),e.myEventCls.onIds("#"+e.pre+"reload_fixedversion","click",(function(s){let i=e.icn3d,n=$("#"+e.pre+"sharelinkurl").val();t.setLogCmd("open "+n,!1),localStorage.setItem("fixedversion","1");let l=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(n,l)})),e.myEventCls.onIds("#"+e.pre+"mn1_mmciffile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmciffile","Please input mmCIF File")})),e.myEventCls.onIds("#"+e.pre+"mn1_mmcifid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmcifid","Please input mmCIF ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_mmdbid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmdbid","Please input MMDB or PDB ID")})),e.myEventCls.onIds(["#"+e.pre+"mn1_mmdbafid",,"#"+e.pre+"tool_mmdbafid"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmdbafid","Please input PDB/MMDB/AlphaFold UniProt IDs")})),e.myEventCls.onIds("#"+e.pre+"mn1_blast_rep_id","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_blast_rep_id","Align sequence to structure")})),e.myEventCls.onIds("#"+e.pre+"mn1_gi","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_gi","Please input protein gi")})),e.myEventCls.onIds("#"+e.pre+"mn1_cid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_cid","Please input PubChem CID")})),e.myEventCls.onIds("#"+e.pre+"mn1_pngimage","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pngimage","Please input the PNG image")})),e.myEventCls.onIds("#"+e.pre+"mn1_state","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_state","Please input the state file")})),e.myEventCls.onIds("#"+e.pre+"mn1_selection","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_selection","Please input the selection file")})),e.myEventCls.onIds("#"+e.pre+"mn1_dsn6","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_dsn6","Please input the DSN6 file to display electron density map")})),e.myEventCls.onIds(["#"+e.pre+"mn1_delphi","#"+e.pre+"mn1_delphi2","#"+e.pre+"tool_delphi"],"click",(function(t){e.icn3d.loadPhiFrom="delphi",$("#"+e.pre+"dl_delphi_tabs").tabs(),e.htmlCls.dialogCls.openDlg("dl_delphi","Please set parameters to display DelPhi potential map")})),e.myEventCls.onIds("#"+e.pre+"mn1_phi","click",(function(t){e.icn3d.loadPhiFrom="phi",$("#"+e.pre+"dl_phi_tabs").tabs(),$("#"+e.pre+"phitab1_tabs").tabs(),$("#"+e.pre+"phitab2_tabs").tabs(),e.htmlCls.dialogCls.openDlg("dl_phi","Please input local phi or cube file to display DelPhi potential map")})),e.myEventCls.onIds("#"+e.pre+"mn1_phiurl","click",(function(t){e.icn3d.loadPhiFrom="phiurl",$("#"+e.pre+"dl_phiurl_tabs").tabs(),$("#"+e.pre+"phiurltab1_tabs").tabs(),$("#"+e.pre+"phiurltab2_tabs").tabs(),e.htmlCls.dialogCls.openDlg("dl_phiurl","Please input URL phi or cube file to display DelPhi potential map")})),e.myEventCls.onIds("#"+e.pre+"mn1_dsn6url","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_dsn6url","Please input the DSN6 file to display electron density map")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportState","click",(function(s){let i=e.icn3d;t.setLogCmd("export state file",!1);let n=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(n+"_statefile.txt","command")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportPdbRes","click",(function(s){e.icn3d,e.htmlCls.setHtmlCls.exportPdb(),t.setLogCmd("export pdb",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportSecondary","click",(function(s){e.icn3d,e.htmlCls.setHtmlCls.exportSecondary(),t.setLogCmd("export secondary structure",!0)})),e.myEventCls.onIds(["#"+e.pre+"delphipdb","#"+e.pre+"phipdb"],"click",(function(s){let i=e.icn3d,n=i.saveFileCls.getSelectedResiduePDB();t.setLogCmd("export PDB of selected residues",!1);let l=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(l+"_icn3d_residues.pdb","text",[n])})),e.myEventCls.onIds(["#"+e.pre+"delphipqr","#"+e.pre+"phipqr","#"+e.pre+"phiurlpqr"],"click",(async function(s){e.icn3d,await e.htmlCls.setHtmlCls.exportPqr(),t.setLogCmd("export pqr",!0)})),e.myEventCls.onIds("#"+e.pre+"profixpdb","click",(async function(s){let i=e.icn3d;await i.scapCls.exportPdbProfix(!1),t.setLogCmd("export pdb missing atoms",!0)})),e.myEventCls.onIds("#"+e.pre+"profixpdbh","click",(async function(s){let i=e.icn3d;await i.scapCls.exportPdbProfix(!0),t.setLogCmd("export pdb hydrogen",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportStl","click",(function(s){let i=e.icn3d;t.setLogCmd("export stl file",!1),i.export3DCls.exportStlFile("")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportVrml","click",(function(s){let i=e.icn3d;t.setLogCmd("export vrml file",!1),i.export3DCls.exportVrmlFile("")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportStlStab","click",(function(s){let i=e.icn3d;t.setLogCmd("export stl stabilizer file",!1),i.threeDPrintCls.hideStabilizer(),i.threeDPrintCls.resetAfter3Dprint(),i.threeDPrintCls.addStabilizer(),i.export3DCls.exportStlFile("_stab")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportVrmlStab","click",(function(s){let i=e.icn3d;t.setLogCmd("export vrml stabilizer file",!1),i.threeDPrintCls.hideStabilizer(),i.threeDPrintCls.resetAfter3Dprint(),i.threeDPrintCls.addStabilizer(),i.export3DCls.exportVrmlFile("_stab")})),e.myEventCls.onIds("#"+e.pre+"mn6_exportInteraction","click",(async function(s){let i=e.icn3d;t.setLogCmd("export interactions",!1),void 0!==e.cfg.mmdbid&&await i.viewInterPairsCls.retrieveInteractionData(),i.viewInterPairsCls.exportInteractions()})),e.myEventCls.onIds(["#"+e.pre+"mn1_exportCanvas","#"+e.pre+"saveimage"],"click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas",!1);await i.shareLinkCls.shareLink(!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas1","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 1",!0),i.scaleFactor=1,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas2","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 2",!0),i.scaleFactor=2,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas4","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 4",!0),i.scaleFactor=4,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas8","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 8",!0),i.scaleFactor=8,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCounts","click",(function(s){let i=e.icn3d;t.setLogCmd("export counts",!1);let n='

    Total Count for atoms with coordinates:
    ';n+="",n+="
    Structure CountChain CountResidue CountAtom Count
    "+Object.keys(i.structures).length+""+Object.keys(i.chains).length+""+Object.keys(i.residues).length+""+Object.keys(i.atoms).length+"

    ",n+="Counts by Chain for atoms with coordinates:
    ";let l=Object.keys(i.chains);for(let e=0,t=l.length;e"}n+="
    StructureChainResidue CountAtom Count
    "+r+""+o+""+Object.keys(a).length+""+Object.keys(i.chains[t]).length+"

    ";let r=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(r+"_counts.html","html",n)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportSelections","click",(function(s){let i=e.icn3d;t.setLogCmd("export all selections",!1),t.SetChainsAdvancedMenu();let n=i.saveFileCls.exportCustomAtoms(),l=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(l+"_selections.txt","text",[n])})),e.myEventCls.onIds("#"+e.pre+"mn1_exportSelDetails","click",(function(s){let i=e.icn3d;t.setLogCmd("export all selections with details",!1),t.SetChainsAdvancedMenu();let n=i.saveFileCls.exportCustomAtoms(!0),l=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(l+"_sel_details.txt","text",[n])})),e.myEventCls.onIds(["#"+e.pre+"mn1_sharelink","#"+e.pre+"tool_sharelink"],"click",(async function(t){let s=e.icn3d;await s.shareLinkCls.shareLink()})),e.myEventCls.onIds("#"+e.pre+"mn1_replayon","click",(async function(s){let i=e.icn3d;await i.resizeCanvasCls.replayon(),t.setLogCmd("replay on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_replayoff","click",(async function(s){let i=e.icn3d;await i.resizeCanvasCls.replayoff(),t.setLogCmd("replay off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_menuall","click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.allMenus),t.applyShownMenus()})),e.myEventCls.onIds("#"+e.pre+"mn1_menusimple","click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.simpleMenus),t.applyShownMenus()})),e.myEventCls.onIds("#"+e.pre+"mn1_menupref","click",(function(s){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_menupref","Select Menus"),t.getHiddenMenusFromCache(),t.displayShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"apply_menupref","#"+e.pre+"apply_menupref2"],"click",(function(s){e.icn3d;var i=document.querySelectorAll('form[name="'+e.pre+'selmenu"] input:checked');for(var n of(e.htmlCls.shownMenus={},i))e.htmlCls.shownMenus[n.value]=1;t.applyShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"reset_menupref","#"+e.pre+"reset_menupref2"],"click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.simpleMenus),t.applyShownMenus(),t.displayShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"reset_menupref_all","#"+e.pre+"reset_menupref_all2"],"click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.allMenus),t.applyShownMenus(),t.displayShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"savepref","#"+e.pre+"savepref2"],"click",(function(t){let s=e.icn3d,i="[";var n=document.querySelectorAll('form[name="'+e.pre+'selmenu"] input:not(:checked)');let l=0;for(var r of n)l>0&&(i+=", "),i+='"'+r.value+'"',++l;i+="]",s.saveFileCls.saveFile("icn3d_menus_pref.txt","text",[i])})),e.myEventCls.onIds("#"+e.pre+"reload_menupreffile","click",(function(s){e.icn3d,e.cfg.notebook||dialog.dialog("close");let i=$("#"+e.pre+"menupreffile")[0].files[0];if(i){e.htmlCls.setHtmlCls.fileSupport();let s=new FileReader;s.onload=function(s){let i=s.target.result,n=JSON.parse(i);e.htmlCls.shownMenus={};for(let t in e.htmlCls.allMenus)-1==n.indexOf(t)&&(e.htmlCls.shownMenus[t]=1);t.applyShownMenus(),t.displayShownMenus()},s.readAsText(i)}else alert("Please select a file before clicking 'Load'")})),e.myEventCls.onIds("#"+e.pre+"mn1_menuloadpref","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_menuloadpref","Please input the menu preference file")})),e.myEventCls.onIds("#"+e.pre+"mn1_link_structure","click",(function(t){let s=e.icn3d,i=s.saveFileCls.getLinkToStructureSummary(!0),n=s.structures&&Object.keys(s.structures).length>0?"_blank":"_self";window.open(i,n)})),e.myEventCls.onIds("#"+e.pre+"mn1_link_bind","click",(function(s){let i=e.icn3d;url="https://www.ncbi.nlm.nih.gov/pccompound?LinkName=pccompound_structure&from_uid="+i.inputid,t.setLogCmd("link to 3D protein structures bound to CID "+i.inputid+": "+url,!1);let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(url,n)})),e.myEventCls.onIds("#"+e.pre+"mn1_link_vast","click",(function(s){let i=e.icn3d;if(void 0===i.inputid)url="https://www.ncbi.nlm.nih.gov/pccompound?term="+i.molTitle,t.setLogCmd("link to compounds "+i.molTitle+": "+url,!1);else{let s;if(void 0!==e.cfg.cid)s="https://www.ncbi.nlm.nih.gov/pccompound?LinkName=pccompound_pccompound_3d&from_uid="+i.inputid,t.setLogCmd("link to compounds with structure similar to CID "+i.inputid+": "+s,!1);else{let n=i.inputid.split("_");1===n.length?(s=e.htmlCls.baseUrl+"vastplus/vastplus.cgi?uid="+i.inputid,t.setLogCmd("link to structures similar to "+i.inputid+": "+s,!1)):2===n.length&&(s=e.htmlCls.baseUrl+"vastplus/vastplus.cgi?uid="+n[0],t.setLogCmd("link to structures similar to "+n[0]+": "+s,!1))}}let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(url,n)})),e.myEventCls.onIds("#"+e.pre+"mn1_link_pubmed","click",(function(s){let i=e.icn3d;if(void 0===i.inputid){let e;e="https://www.ncbi.nlm.nih.gov/pubmed/?term="+i.molTitle,t.setLogCmd("link to literature about "+i.molTitle+": "+e,!1);let s=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(e,s)}else if(i.pmid){let e,s=i.pmid.toString().split("_");1===s.length?(e="https://www.ncbi.nlm.nih.gov/pubmed/"+i.pmid,t.setLogCmd("link to PubMed ID "+i.pmid+": "+e,!1)):2===s.length&&(e="https://www.ncbi.nlm.nih.gov/pubmed/?term="+s[0]+" OR "+s[1],t.setLogCmd("link to PubMed IDs "+s[0]+", "+s[1]+": "+e,!1));let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(e,n)}else if(isNaN(i.inputid)){let e,s=i.inputid.toString().split("_");1===s.length?(e="https://www.ncbi.nlm.nih.gov/pubmed/?term="+i.inputid,t.setLogCmd("link to literature about PDB "+i.inputid+": "+e,!1)):2===s.length&&(e="https://www.ncbi.nlm.nih.gov/pubmed/?term="+s[0]+" OR "+s[1],t.setLogCmd("link to literature about PDB "+s[0]+" OR "+s[1]+": "+e,!1));let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(e,n)}else void 0!==e.cfg.cid?alert("No literature information is available for this compound in the SDF file."):alert("No literature information is available for this structure.")})),e.myEventCls.onIds("#"+e.pre+"mn1_link_protein","click",(function(s){let i=e.icn3d,n=Object.keys(i.structures),l=Object.keys(i.chains),r="";for(let e=0,t=l.length;e0&&(r=r.substr(0,r.length-4));let o="https://www.ncbi.nlm.nih.gov/protein/?term="+r;t.setLogCmd("link to Entrez protein about PDB "+n+": "+o,!1);let a=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(o,a)}))}clickMenu2(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds(["#"+e.pre+"mn6_selectannotations","#"+e.pre+"tool_selectannotations"],"click",(async function(s){let i=e.icn3d;await i.showAnnoCls.showAnnotations(),t.setLogCmd("view annotations",!0)})),e.myEventCls.onIds("#"+e.pre+"mn2_selectall","click",(function(s){let i=e.icn3d;t.setLogCmd("select all",!0),i.selectionCls.selectAll(),i.hlUpdateCls.removeHlAll(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"clearall","click",(function(s){let i=e.icn3d;t.setLogCmd("clear all",!0),i.bSelectResidue=!1,i.selectionCls.selectAll(),i.hlUpdateCls.removeHlAll(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn2_selectdisplayed","click",(function(s){let i=e.icn3d;t.setLogCmd("select displayed set",!0),i.hAtoms=e.hashUtilsCls.cloneHash(i.viewSelectionAtoms),i.hlUpdateCls.updateHlAll()})),e.myEventCls.onIds("#"+e.pre+"mn2_fullstru","click",(function(s){let i=e.icn3d;t.setLogCmd("show all",!0),i.selectionCls.showAll()})),e.myEventCls.onIds("#"+e.pre+"mn2_selectcomplement","click",(function(s){let i=e.icn3d;Object.keys(i.hAtoms).lengthnon-selected"+n),$("#"+e.pre+"atomsCustomSphere2").length&&$("#"+e.pre+"atomsCustomSphere2").html(" "+n),e.htmlCls.dialogCls.openDlg("dl_aroundsphere","Select a sphere around a set of residues"),i.bSphereCalc=!1,$("#"+e.pre+"atomsCustomSphere").resizable(),$("#"+e.pre+"atomsCustomSphere2").resizable()})),e.myEventCls.onIds(["#"+e.pre+"mn2_select_chain","#"+e.pre+"definedSets"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_select_chain","Select Structure/Chain/Custom Selection")}))}clickMenu3(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds(["#"+e.pre+"mn3_proteinsRibbon","#"+e.pre+"tool_proteinsRibbon"],"click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","ribbon"),t.setLogCmd("style proteins ribbon",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsStrand","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","strand"),t.setLogCmd("style proteins strand",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsCylinder","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","cylinder and plate"),t.setLogCmd("style proteins cylinder and plate",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsSchematic","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","schematic"),t.setLogCmd("style proteins schematic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsCalpha","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","c alpha trace"),t.setLogCmd("style proteins c alpha trace",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsBackbone","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","backbone"),t.setLogCmd("style proteins backbone",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsBfactor","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","b factor tube"),t.setLogCmd("style proteins b factor tube",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsLines","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","lines"),t.setLogCmd("style proteins lines",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsStick","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","stick"),t.setLogCmd("style proteins stick",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn3_proteinsBallstick","#"+e.pre+"tool_proteinsBallstick"],"click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","ball and stick"),t.setLogCmd("style proteins ball and stick",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn3_proteinsSphere","#"+e.pre+"tool_proteinsSphere"],"click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","sphere"),t.setLogCmd("style proteins sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsNo","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","nothing"),t.setLogCmd("style proteins nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecLines","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","lines2"),t.setLogCmd("style sidec lines2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecStick","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","stick2"),t.setLogCmd("style sidec stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","ball and stick2"),t.setLogCmd("style sidec ball and stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","sphere2"),t.setLogCmd("style sidec sphere2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecNo","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","nothing"),t.setLogCmd("style sidec nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseLines","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","lines2"),t.setLogCmd("style ntbase lines2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseStick","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","stick2"),t.setLogCmd("style ntbase stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","ball and stick2"),t.setLogCmd("style ntbase ball and stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","sphere2"),t.setLogCmd("style ntbase sphere2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseNo","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","nothing"),t.setLogCmd("style ntbase nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclCartoon","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","nucleotide cartoon"),t.setLogCmd("style nucleotides nucleotide cartoon",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclBackbone","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","backbone"),t.setLogCmd("style nucleotides backbone",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclSchematic","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","schematic"),t.setLogCmd("style nucleotides schematic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclPhos","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","o3 trace"),t.setLogCmd("style nucleotides o3 trace",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclLines","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","lines"),t.setLogCmd("style nucleotides lines",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclStick","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","stick"),t.setLogCmd("style nucleotides stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","ball and stick"),t.setLogCmd("style nucleotides ball and stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","sphere"),t.setLogCmd("style nucleotides sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclNo","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","nothing"),t.setLogCmd("style nucleotides nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligLines","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","lines"),t.setLogCmd("style chemicals lines",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligStick","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","stick"),t.setLogCmd("style chemicals stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","ball and stick"),t.setLogCmd("style chemicals ball and stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligSchematic","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","schematic"),t.setLogCmd("style chemicals schematic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","sphere"),t.setLogCmd("style chemicals sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligNo","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","nothing"),t.setLogCmd("style chemicals nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_glycansCartYes","click",(function(s){let i=e.icn3d;i.bGlycansCartoon=!0,i.drawCls.draw(),t.setLogCmd("glycans cartoon yes",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_glycansCartNo","click",(function(s){let i=e.icn3d;i.bGlycansCartoon=!1,i.drawCls.draw(),t.setLogCmd("glycans cartoon no",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_hydrogensYes","click",(function(s){let i=e.icn3d;i.showInterCls.showHydrogens(),i.drawCls.draw(),t.setLogCmd("hydrogens",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_hydrogensNo","click",(function(s){let i=e.icn3d;i.showInterCls.hideHydrogens(),i.drawCls.draw(),t.setLogCmd("set hydrogens off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ionsSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("ions","sphere"),t.setLogCmd("style ions sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ionsDot","click",(function(s){e.icn3d.setOptionCls.setStyle("ions","dot"),t.setLogCmd("style ions dot",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ionsNo","click",(function(s){e.icn3d.setOptionCls.setStyle("ions","nothing"),t.setLogCmd("style ions nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_waterSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("water","sphere"),t.setLogCmd("style water sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_waterDot","click",(function(s){e.icn3d.setOptionCls.setStyle("water","dot"),t.setLogCmd("style water dot",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_waterNo","click",(function(s){e.icn3d.setOptionCls.setStyle("water","nothing"),t.setLogCmd("style water nothing",!0)}))}clickMenu4(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrum","click",(function(s){e.icn3d.setOptionCls.setOption("color","spectrum"),t.setLogCmd("color spectrum",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrumChain","click",(function(s){e.icn3d.setOptionCls.setOption("color","spectrum for chains"),t.setLogCmd("color spectrum for chains",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrumAcrossSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorSpectrumAcross").length&&$("#"+e.pre+"atomsCustomColorSpectrumAcross").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorspectrumacrosssets","Please select sets to apply spectrum color for sets"),$("#"+e.pre+"atomsCustomColorSpectrumAcross").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrumSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorSpectrum").length&&$("#"+e.pre+"atomsCustomColorSpectrum").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorspectrumbysets","Please select sets to apply spectrum color for residues"),$("#"+e.pre+"atomsCustomColorSpectrum").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrRainbowAcrossSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorRainbowAcross").length&&$("#"+e.pre+"atomsCustomColorRainbowAcross").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorrainbowacrosssets","Please select sets to apply rainbow color for sets"),$("#"+e.pre+"atomsCustomColorRainbowAcross").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrRainbowSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorRainbow").length&&$("#"+e.pre+"atomsCustomColorRainbow").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorrainbowbysets","Please select sets to apply rainbow color for residues"),$("#"+e.pre+"atomsCustomColorRainbow").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrRainbow","click",(function(s){e.icn3d.setOptionCls.setOption("color","rainbow"),t.setLogCmd("color rainbow",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrRainbowChain","#"+e.pre+"tool_clrRainbowChain"],"click",(function(s){e.icn3d.setOptionCls.setOption("color","rainbow for chains"),t.setLogCmd("color rainbow for chains",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrChain","#"+e.pre+"tool_clrChain"],"click",(function(s){e.icn3d.setOptionCls.setOption("color","chain"),t.setLogCmd("color chain",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrStructure","click",(function(s){e.icn3d.setOptionCls.setOption("color","structure"),t.setLogCmd("color structure",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrdomain","click",(function(s){e.icn3d.setOptionCls.setOption("color","domain"),t.setLogCmd("color domain",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrsets","click",(function(s){e.icn3d.setOptionCls.setOption("color","defined sets"),t.setLogCmd("color defined sets",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrSSGreen","#"+e.pre+"tool_clrSSGreen"],"click",(function(s){let i=e.icn3d;i.sheetcolor="green",i.setOptionCls.setOption("color","secondary structure green"),t.setLogCmd("color secondary structure green",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSSYellow","click",(function(s){let i=e.icn3d;i.sheetcolor="yellow",i.setOptionCls.setOption("color","secondary structure yellow"),t.setLogCmd("color secondary structure yellow",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSSSpectrum","click",(function(s){e.icn3d.setOptionCls.setOption("color","secondary structure spectrum"),t.setLogCmd("color secondary structure spectrum",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrResidue","click",(function(s){e.icn3d.setOptionCls.setOption("color","residue"),t.setLogCmd("color residue",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrResidueCustom","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_rescolorfile","Please input the file on residue colors")})),e.myEventCls.onIds("#"+e.pre+"reload_rescolorfile","click",(function(s){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close");let n=$("#"+e.pre+"rescolorfile")[0].files[0];if(n){e.htmlCls.setHtmlCls.fileSupport();let s=new FileReader;s.onload=function(s){let n=s.target.result.replace(/#/g,"");i.customResidueColors=JSON.parse(n);for(let t in i.customResidueColors)i.customResidueColors[t.toUpperCase()]=e.parasCls.thr("#"+i.customResidueColors[t]);i.setOptionCls.setOption("color","residue custom"),t.setLogCmd("color residue custom | "+n,!0)},s.readAsText(n)}else alert("Please select a file before clicking 'Load'")})),e.myEventCls.onIds("#"+e.pre+"reload_customcolorfile","click",(function(s){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close"),i.startColor=$("#"+e.pre+"startColor").val(),i.midColor=$("#"+e.pre+"midColor").val(),i.endColor=$("#"+e.pre+"endColor").val();let n=t.setLegendHtml();$("#"+e.pre+"dl_legend").html(n),e.htmlCls.dialogCls.openDlg("dl_legend","Color range"),i.addTrackCls.setCustomFile("color",i.startColor,i.midColor,i.endColor)})),e.myEventCls.onIds("#"+e.pre+"mn6_customref","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_customref","Set custom reference numbers")})),e.myEventCls.onIds("#"+e.pre+"reload_customreffile","click",(function(s){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close");let n=$("#"+i.pre+"cstreffile")[0].files[0];if(n){e.utilsCls.checkFileAPI();let s=new FileReader;s.onload=async function(e){let s=e.target.result;await i.refnumCls.parseCustomRefFile(s),s=s.replace(/\r/g,"").replace(/\n/g,"\\n"),t.setLogCmd("custom refnum | "+s,!0)},s.readAsText(n)}else alert("Please select a file before clicking 'Apply'")})),e.myEventCls.onIds("#"+e.pre+"remove_legend","click",(function(s){e.icn3d,$("#"+e.pre+"legend").hide(),t.setLogCmd("remove legend",!0)})),e.myEventCls.onIds("#"+e.pre+"reload_customtubefile","click",(function(t){let s=e.icn3d;e.cfg.notebook||dialog.dialog("close"),s.addTrackCls.setCustomFile("tube")})),e.myEventCls.onIds("#"+e.pre+"mn4_clrCharge","click",(function(s){e.icn3d.setOptionCls.setOption("color","charge"),t.setLogCmd("color charge",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrHydrophobic","click",(function(s){e.icn3d.setOptionCls.setOption("color","hydrophobic"),t.setLogCmd("color hydrophobic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrNormalizedHP","click",(function(s){e.icn3d.setOptionCls.setOption("color","normalized hydrophobic"),t.setLogCmd("color normalized hydrophobic",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrAtom","#"+e.pre+"tool_clrAtom"],"click",(function(s){e.icn3d.setOptionCls.setOption("color","atom"),t.setLogCmd("color atom",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrBfactor","click",(function(s){e.icn3d.setOptionCls.setOption("color","b factor"),t.setLogCmd("color b factor",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrConfidence","click",(function(s){e.icn3d.setOptionCls.setOption("color","confidence"),t.setLogCmd("color confidence",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrIgstrand","click",(function(s){e.icn3d.setOptionCls.setOption("color","ig strand"),t.setLogCmd("color ig strand",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrArea","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_colorbyarea","Color based on residue's solvent accessibility")})),e.myEventCls.onIds("#"+e.pre+"applycolorbyarea","click",(function(s){let i=e.icn3d;i.midpercent=$("#"+e.pre+"midpercent").val(),i.setOptionCls.setOption("color","area"),t.setLogCmd("color area | "+i.midpercent,!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrBfactorNorm","click",(function(s){e.icn3d.setOptionCls.setOption("color","b factor percentile"),t.setLogCmd("color b factor percentile",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrIdentity","click",(function(s){e.icn3d.setOptionCls.setOption("color","identity"),t.setLogCmd("color identity",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrConserved","click",(function(s){e.icn3d.setOptionCls.setOption("color","conservation"),t.setLogCmd("color conservation",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrCustom","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_clr","Color picker")})),$(document).on("click",".icn3d-color-rad-text",(function(s){let i=e.icn3d;s.stopImmediatePropagation(),s.preventDefault();let n=$(this).attr("color");i.setOptionCls.setOption("color",n),t.setLogCmd("color "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSave","click",(function(s){e.icn3d.setOptionCls.saveColor(),t.setLogCmd("save color",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrApplySave","click",(function(s){e.icn3d.setOptionCls.applySavedColor(),t.setLogCmd("apply saved color",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_styleSave","click",(function(s){e.icn3d.setOptionCls.saveStyle(),t.setLogCmd("save style",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_styleApplySave","click",(function(s){e.icn3d.setOptionCls.applySavedStyle(),t.setLogCmd("apply saved style",!0)}))}clickMenu5(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds("#"+e.pre+"mn5_neighborsYes","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.applyMapCls.removeLastSurface(),i.applyMapCls.applySurfaceOptions(),i.bRender&&i.drawCls.render(),t.setLogCmd("set surface neighbors on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_neighborsNo","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.applyMapCls.removeLastSurface(),i.applyMapCls.applySurfaceOptions(),i.bRender&&i.drawCls.render(),t.setLogCmd("set surface neighbors off",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn5_surfaceVDW","#"+e.pre+"tool_surfaceVDW"],"click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.setOptionCls.setOption("surface","Van der Waals surface"),t.setLogCmd("set surface Van der Waals surface",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceSAS","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.setOptionCls.setOption("surface","solvent accessible surface"),t.setLogCmd("set surface solvent accessible surface",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceMolecular","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.setOptionCls.setOption("surface","molecular surface"),t.setLogCmd("set surface molecular surface",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceVDWContext","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.setOptionCls.setOption("surface","Van der Waals surface with context"),t.setLogCmd("set surface Van der Waals surface with context",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceSASContext","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.setOptionCls.setOption("surface","solvent accessible surface with context"),t.setLogCmd("set surface solvent accessible surface with context",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceMolecularContext","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.setOptionCls.setOption("surface","molecular surface with context"),t.setLogCmd("set surface molecular surface with context",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceNo","click",(function(s){e.icn3d.setOptionCls.setOption("surface","nothing"),t.setLogCmd("set surface nothing",!0)})),$(document).on("click","."+e.pre+"mn5_opacity",(function(s){let i=e.icn3d;i.transparentRenderOrder=!1;let n=$(this).attr("v");i.setOptionCls.setOption("opacity",n),t.setLogCmd("set surface opacity "+n,!0)})),$(document).on("click","."+e.pre+"mn5_opacityslow",(function(s){let i=e.icn3d;i.transparentRenderOrder=!0;let n=$(this).attr("v");i.setOptionCls.setOption("opacity",n),t.setLogCmd("set surface2 opacity "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_wireframeYes","click",(function(s){e.icn3d.setOptionCls.setOption("wireframe","yes"),t.setLogCmd("set surface wireframe on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_wireframeNo","click",(function(s){e.icn3d.setOptionCls.setOption("wireframe","no"),t.setLogCmd("set surface wireframe off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_elecmap2fofc","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_elecmap2fofc","2Fo-Fc Electron Density Map")})),e.myEventCls.onIds("#"+e.pre+"mn5_elecmapfofc","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_elecmapfofc","Fo-Fc Electron Density Map")})),e.myEventCls.onIds(["#"+e.pre+"mn5_elecmapNo","#"+e.pre+"elecmapNo2","#"+e.pre+"elecmapNo3","#"+e.pre+"elecmapNo4","#"+e.pre+"elecmapNo5"],"click",(function(s){e.icn3d.setOptionCls.setOption("map","nothing"),t.setLogCmd("setoption map nothing",!0)})),e.myEventCls.onIds(["#"+e.pre+"delphimapNo","#"+e.pre+"phimapNo","#"+e.pre+"phiurlmapNo","#"+e.pre+"mn1_phimapNo"],"click",(function(s){e.icn3d.setOptionCls.setOption("phimap","nothing"),t.setLogCmd("setoption phimap nothing",!0)})),e.myEventCls.onIds(["#"+e.pre+"delphimapNo2","#"+e.pre+"phimapNo2","#"+e.pre+"phiurlmapNo2"],"click",(function(s){e.icn3d.setOptionCls.setOption("phisurface","nothing"),t.setLogCmd("setoption phisurface nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"applymap2fofc","click",(function(s){let i=e.icn3d,n=parseFloat($("#"+e.pre+"sigma2fofc").val());i.dsn6ParserCls.dsn6Parser(i.inputid,"2fofc",n),t.setLogCmd("set map 2fofc sigma "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"applymapfofc","click",(function(s){let i=e.icn3d,n=parseFloat($("#"+e.pre+"sigmafofc").val());i.dsn6ParserCls.dsn6Parser(i.inputid,"fofc",n),t.setLogCmd("set map fofc sigma "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_mapwireframeYes","click",(function(s){e.icn3d.setOptionCls.setOption("mapwireframe","yes"),t.setLogCmd("set map wireframe on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_mapwireframeNo","click",(function(s){e.icn3d.setOptionCls.setOption("mapwireframe","no"),t.setLogCmd("set map wireframe off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_emmap","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_emmap","EM Density Map")})),e.myEventCls.onIds(["#"+e.pre+"mn5_emmapNo","#"+e.pre+"emmapNo2"],"click",(function(s){e.icn3d.setOptionCls.setOption("emmap","nothing"),t.setLogCmd("setoption emmap nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"applyemmap","click",(function(s){let i=e.icn3d,n=parseFloat($("#"+e.pre+"empercentage").val());i.densityCifParserCls.densityCifParser(i.inputid,"em",n,i.emd),t.setLogCmd("set emmap percentage "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_emmapwireframeYes","click",(function(s){e.icn3d.setOptionCls.setOption("emmapwireframe","yes"),t.setLogCmd("set emmap wireframe on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_emmapwireframeNo","click",(function(s){e.icn3d.setOptionCls.setOption("emmapwireframe","no"),t.setLogCmd("set emmap wireframe off",!0)}))}clickMenu6(){let e=this.icn3dui,t=e.icn3d;if(e.bNode)return;let s=this;e.myEventCls.onIds("#"+e.pre+"mn6_assemblyYes","click",(function(t){let i=e.icn3d;i.bAssembly=!0,s.setLogCmd("set assembly on",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_assemblyNo","click",(function(t){let i=e.icn3d;i.bAssembly=!1,s.setLogCmd("set assembly off",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_igrefYes","click",(async function(t){let i=e.icn3d;s.setLogCmd("ig refnum on",!0),await i.refnumCls.showIgRefNum()})),e.myEventCls.onIds("#"+e.pre+"mn6_igrefNo","click",(async function(t){let i=e.icn3d;s.setLogCmd("ig refnum off",!0),await i.refnumCls.hideIgRefNum()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelAtoms","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addAtomLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add atom labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelElements","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addAtomLabels(i.hAtoms,!0),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add element labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelResidues","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addResidueLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add residue labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelResnum","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addResidueLabels(i.hAtoms,void 0,void 0,!0),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add residue number labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelChains","click",(function(t){let i=e.icn3d;i.analysisCls.addChainLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add chain labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelTermini","click",(function(t){let i=e.icn3d;i.analysisCls.addTerminiLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add terminal labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelYes","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_addlabel","Add custom labels by selection"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelSelection","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_addlabelselection","Add custom labels by the selected")})),e.myEventCls.onIds("#"+e.pre+"mn6_labelColor","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_labelColor","Change color for all labels")})),e.myEventCls.onIds(["#"+e.pre+"mn2_saveselection","#"+e.pre+"tool_saveselection"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_saveselection","Save the selected")})),e.myEventCls.onIds(["#"+e.pre+"mn6_addlabelNo","#"+e.pre+"removeLabels"],"click",(function(t){let i=e.icn3d;i.labelcolor=void 0,i.pickpair=!1;s.setLogCmd("set labels off",!0);for(let e in i.labels)i.labels[e]=[];i.drawCls.draw()})),$(document).on("click","."+e.pre+"mn6_labelscale",(function(t){let i=e.icn3d,n=$(this).attr("v");i.labelScale=n,i.drawCls.draw(),s.setLogCmd("set label scale "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_distanceYes","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_distance","Measure the distance of atoms"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0,s.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_distTwoSets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_disttwosets","Measure the distance between two sets"),s.setSetsMenus("atomsCustomDist"),i.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_distManySets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_distmanysets","Measure the pairwise distance among many sets"),s.setSetsMenus("atomsCustomDistTable"),i.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_distanceNo","click",(function(t){let i=e.icn3d;i.pickpair=!1;s.setLogCmd("set lines off",!0),i.labels.distance=[],i.lines.distance=[],i.distPnts=[],i.pk=2,i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn5_cartoonshape","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_cartoonshape","Draw cartoon for a set");s.setSetsMenus("cartoonshape",!0),i.bCartoonshape=!0})),e.myEventCls.onIds("#"+e.pre+"mn5_linebtwsets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_linebtwsets","Draw a line between two sets"),s.setSetsMenus("linebtwsets"),i.bLinebtwsets=!0})),e.myEventCls.onIds(["#"+e.pre+"mn2_selectedcenter","#"+e.pre+"zoomin_selection","#"+e.pre+"tool_selectedcenter"],"click",(function(t){let i=e.icn3d;i.transformCls.zoominSelection(),i.drawCls.draw(),s.setLogCmd("zoom selection",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_center","click",(function(t){let i=e.icn3d;i.applyCenterCls.centerSelection(),i.drawCls.draw(),s.setLogCmd("center selection",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_resetOrientation","#"+e.pre+"resetOrientation","#"+e.pre+"tool_resetOrientation"],"click",(function(t){let i=e.icn3d;i.transformCls.resetOrientation(),i.drawCls.draw(),s.setLogCmd("reset orientation",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_chemicalbindingshow","#"+e.pre+"chemicalbindingshow"],"click",(function(t){e.icn3d.setOptionCls.setOption("chemicalbinding","show"),s.setLogCmd("set chemicalbinding show",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_chemicalbindinghide","#"+e.pre+"chemicalbindinghide"],"click",(function(t){e.icn3d.setOptionCls.setOption("chemicalbinding","hide"),s.setLogCmd("set chemicalbinding hide",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_sidebyside","click",(function(t){let i=e.icn3d;if(i.bInputfile)return void alert("Side-by-Side does NOT work when the input is from a local file.");let n=i.shareLinkCls.shareLinkUrl(void 0);n=n.replace("full.html","full2.html"),n+="&closepopup=1";let l=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(n,l),s.setLogCmd("side by side | "+n,!0)})),$(document).on("click","."+e.pre+"mn6_rotate",(function(t){let i=e.icn3d,n=$(this).attr("v").toLowerCase(),l=n.split(" ")[1];s.setLogCmd(n,!0),i.bStopRotate=!1,i.transformCls.rotateCount=0,i.transformCls.rotateCountMax=6e3,i.ROT_DIR=l,i.resizeCanvasCls.rotStruc(l)})),$(document).on("click","."+e.pre+"mn6_rotate90",(function(t){let i,n=e.icn3d,l=$(this).attr("v").toLowerCase(),r=l.split("-")[0];s.setLogCmd(l,!0),"x"==r?i=new THREE.Vector3(1,0,0):"y"==r?i=new THREE.Vector3(0,1,0):"z"==r&&(i=new THREE.Vector3(0,0,1));let o=.5*Math.PI;n.transformCls.setRotation(i,o)})),e.myEventCls.onIds("#"+e.pre+"mn6_cameraPers","click",(function(t){e.icn3d.setOptionCls.setOption("camera","perspective"),s.setLogCmd("set camera perspective",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_cameraOrth","click",(function(t){e.icn3d.setOptionCls.setOption("camera","orthographic"),s.setLogCmd("set camera orthographic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_bkgdBlack","click",(function(t){e.icn3d.setStyleCls.setBackground("black")})),e.myEventCls.onIds("#"+e.pre+"tool_bkgd","click",(function(t){let s=e.icn3d;"black"==s.opts.background?s.setStyleCls.setBackground("white"):s.setStyleCls.setBackground("black")})),e.myEventCls.onIds("#"+e.pre+"mn6_bkgdGrey","click",(function(t){e.icn3d.setStyleCls.setBackground("grey")})),e.myEventCls.onIds(["#"+e.pre+"mn6_bkgdWhite","#"+e.pre+"tool_bkgdWhite"],"click",(function(t){e.icn3d.setStyleCls.setBackground("white")})),e.myEventCls.onIds("#"+e.pre+"mn6_bkgdTransparent","click",(function(t){e.icn3d.setStyleCls.setBackground("transparent")})),e.myEventCls.onIds("#"+e.pre+"mn6_showfogYes","click",(function(t){let i=e.icn3d;i.opts.fog="yes",i.fogCls.setFog(!0),i.drawCls.draw(),s.setLogCmd("set fog on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showfogNo","click",(function(t){let i=e.icn3d;i.opts.fog="no",i.fogCls.setFog(!0),i.drawCls.draw(),s.setLogCmd("set fog off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showslabYes","click",(function(t){e.icn3d.setOptionCls.setOption("slab","yes"),s.setLogCmd("set slab on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showslabNo","click",(function(t){e.icn3d.setOptionCls.setOption("slab","no"),s.setLogCmd("set slab off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showaxisYes","click",(function(t){e.icn3d.setOptionCls.setOption("axis","yes"),s.setLogCmd("set axis on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showaxisSel","click",(function(t){let i=e.icn3d;i.pc1=!0,i.axesCls.setPc1Axes(),s.setLogCmd("set pc1 axis",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showaxisNo","click",(function(t){let i=e.icn3d;i.pc1=!1,i.axes=[],i.setOptionCls.setOption("axis","no"),s.setLogCmd("set axis off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_symmetry","click",(async function(t){let s=e.icn3d;s.bAxisOnly=!1,await s.symdCls.retrieveSymmetry(Object.keys(s.structures)[0])})),e.myEventCls.onIds("#"+e.pre+"mn6_symd","click",(async function(t){let i=e.icn3d;i.bAxisOnly=!1,await i.symdCls.retrieveSymd(),i.bSymd=!0,s.setLogCmd("symd symmetry",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_clear_sym","click",(function(t){let i=e.icn3d;i.symdArray=[],i.drawCls.draw(),s.setLogCmd("clear symd symmetry",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_axes_only","click",(function(t){let i=e.icn3d;i.bAxisOnly=!0,i.drawCls.draw(),s.setLogCmd("show axis",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_area","click",(function(t){e.icn3d.analysisCls.calculateArea(),s.setLogCmd("area",!0)})),e.myEventCls.onIds("#"+e.pre+"applysymmetry","click",(function(t){let i=e.icn3d;i.bAxisOnly=!1;let n=$("#"+e.pre+"selectSymmetry").val();i.symmetrytitle="none"===n?void 0:n,i.drawCls.draw(),s.setLogCmd("symmetry "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"clearsymmetry","click",(function(t){let i=e.icn3d;i.symmetrytitle=void 0,i.drawCls.draw(),s.setLogCmd("symmetry none",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_hbondsYes","#"+e.pre+"hbondsYes"],"click",(function(t){let i=e.icn3d;s.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomHbond").length&&$("#"+e.pre+"atomsCustomHbond").html(" "+n),$("#"+e.pre+"atomsCustomHbond2").length&&$("#"+e.pre+"atomsCustomHbond2").html(" "+n),e.htmlCls.dialogCls.openDlg("dl_hbonds","Hydrogen bonds/interactions between two sets of atoms"),i.bHbondCalc=!1,$("#"+e.pre+"atomsCustomHbond").resizable(),$("#"+e.pre+"atomsCustomHbond2").resizable()})),e.myEventCls.onIds(["#"+e.pre+"mn6_contactmap"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_contact","Set contact map")})),e.myEventCls.onIds("#"+e.pre+"mn6_hbondsNo","click",(function(t){let s=e.icn3d;s.showInterCls.hideHbondsContacts(),s.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerYes","click",(function(t){let i=e.icn3d;i.threeDPrintCls.addStabilizer(),i.threeDPrintCls.prepareFor3Dprint(),s.setLogCmd("stabilizer",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerNo","click",(function(t){let i=e.icn3d;s.setLogCmd("set stabilizer off",!0),i.threeDPrintCls.hideStabilizer(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerOne","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_stabilizer","Add One Stabilizer"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerRmOne","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_stabilizer_rm","Remove One Stabilizer"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0})),e.myEventCls.onIds("#"+e.pre+"mn1_thicknessSet","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_thickness","Set Thickness for 3D Printing")})),e.myEventCls.onIds("#"+e.pre+"mn3_setThickness","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_thickness2","Style Preferences")})),e.myEventCls.onIds("#"+e.pre+"mn6_ssbondsYes","click",(function(t){let i=e.icn3d;s.setLogCmd("disulfide bonds",!0),i.showInterCls.showSsbonds()})),e.myEventCls.onIds("#"+e.pre+"mn6_ssbondsExport","click",(function(t){e.icn3d.viewInterPairsCls.exportSsbondPairs(),s.setLogCmd("export disulfide bond pairs",!1)})),e.myEventCls.onIds("#"+e.pre+"mn6_ssbondsNo","click",(function(t){let i=e.icn3d;i.opts.ssbonds="no";s.setLogCmd("set disulfide bonds off",!0),i.lines.ssbond=[],i.setOptionCls.setStyle("sidec","nothing")})),e.myEventCls.onIds("#"+e.pre+"mn6_clbondsYes","click",(function(t){let i=e.icn3d;s.setLogCmd("cross linkage",!0),i.showInterCls.showClbonds()})),e.myEventCls.onIds("#"+e.pre+"mn6_clbondsExport","click",(function(t){e.icn3d.viewInterPairsCls.exportClbondPairs(),s.setLogCmd("export cross linkage pairs",!1)})),e.myEventCls.onIds("#"+e.pre+"mn6_clbondsNo","click",(function(t){let i=e.icn3d;i.opts.clbonds="no";s.setLogCmd("set cross linkage off",!0),i.lines.clbond=[],i.setOptionCls.setStyle("sidec","nothing")})),$("#"+e.pre+"newvs2").on("submit",(function(){let s=t.saveFileCls.getAtomPDB(t.hAtoms);return $("#"+e.pre+"pdbstr").val(s),!0})),$("#"+e.pre+"fssubmit").on("click",(function(){let e=t.saveFileCls.getAtomPDB(t.hAtoms),s=window.open("","_blank");s.document.body.innerHTML="\n\nLoading Foldseek\n\n\n\n
    Foldseek is loading...
    \n",$.ajax({url:"https://search.foldseek.com/api/ticket",type:"POST",data:{q:e,database:["afdb50","afdb-swissprot","gmgcl_id","pdb100","afdb-proteome","mgnify_esm30"],mode:"3diaa"},dataType:"text",success:function(e){s.location="https://search.foldseek.com/queue/"+JSON.parse(e).id},error:function(e,t,s){console.log("Error in submitting data to Foldseek...")}})}))}setLogCmd(e,t,s){var i=this.icn3dui,n=i.icn3d;if(""===e.trim())return!1;let l=e.indexOf("|||");-1!==l&&(e=e.substr(0,l));let r={};if(r.factor=n._zoomFactor,r.mouseChange=n.mouseChange,r.quaternion={},r.quaternion._x=parseFloat(n.quaternion._x).toPrecision(5),r.quaternion._y=parseFloat(n.quaternion._y).toPrecision(5),r.quaternion._z=parseFloat(n.quaternion._z).toPrecision(5),r.quaternion._w=parseFloat(n.quaternion._w).toPrecision(5),t&&n.bAddCommands)if(n.STATENUMBER "+n.logs.join("\n> ")+"\n> "),$("#"+i.pre+"logtext")[0]&&$("#"+i.pre+"logtext").scrollTop($("#"+i.pre+"logtext")[0].scrollHeight)}n.setStyleCls.adjustIcon()}}class d{constructor(e){this.icn3dui=e}getLink(e,t,s,i){return this.icn3dui.htmlCls.setHtmlCls.getLink(e,t,s,i)}getMenuText(e,t,s,i,n){return this.icn3dui.htmlCls.setHtmlCls.getMenuText(e,t,s,i,n)}getMenuUrl(e,t,s,i,n){return this.icn3dui.htmlCls.setHtmlCls.getMenuUrl(e,t,s,i,n)}getMenuSep(){return this.icn3dui.htmlCls.setHtmlCls.getMenuSep()}getLinkWrapper(e,t,s,i,n,l){let r=this.icn3dui;return r.icn3d,r.htmlCls.setHtmlCls.getLinkWrapper(e,t,s,i,n,l)}getLinkWrapper2(e,t,s,i,n){let l=this.icn3dui;return l.icn3d,l.htmlCls.setHtmlCls.getLinkWrapper2(e,t,s,i,n)}getRadio(e,t,s,i,n,l){return this.icn3dui.htmlCls.setHtmlCls.getRadio(e,t,s,i,n,l)}getRadClr(e,t,s,i,n,l,r){return this.icn3dui.htmlCls.setHtmlCls.getRadioColor(e,t,s,i,n,l,r)}setTopMenusHtml(e,t,s){let i=this.icn3dui;if(i.bNode)return"";let n="black"==i.htmlCls.opts.background?i.htmlCls.GREYD:"black",l="";l+="
    ",l+=i.htmlCls.divStr+"popup' class='icn3d-text icn3d-popup'>
    ",l+=this.setReplayHtml(),l+="\x3c!--https://forum.jquery.com/topic/looking-for-a-jquery-horizontal-menu-bar--\x3e",l+=i.htmlCls.divStr+"mnlist' style='position:absolute; z-index:999; float:left; display:table-row; margin-top: -2px;'>",l+="";let r='",l+=r+this.setMenu2()+"",l+=r+this.setMenu2b()+"",l+=r+this.setMenu3()+"",l+=r+this.setMenu4()+"",l+=r+this.setMenu5()+"",l+=r+this.setMenu6()+"",i.htmlCls.shownMenus=i.hashUtilsCls.cloneHash(i.htmlCls.simpleMenus),l+=r+"
    "+t,l+="
    "+s,l+=r+'
    '+i.htmlCls.space2+'Toolbar '+i.htmlCls.space2+'
    ",l+=r+'
    '+i.htmlCls.space2+' ?
    ',l+="
    ",l+="
    ';if(l+=r+this.setMenu1()+"
    ",l+="",l+=this.setTools(),l+=i.htmlCls.divStr+"title' class='icn3d-commandTitle' style='font-size:1.2em; font-weight:normal; position:absolute; z-index:1; float:left; display:table-row; margin: 85px 0px 0px 5px; color:"+n+"; width:"+i.htmlCls.WIDTH+"px'>",l+=i.htmlCls.divStr+"viewer' style='position:relative; width:100%; height:100%; background-color: "+i.htmlCls.GREYD+";'>",l+=i.htmlCls.divStr+"mnLogSection'>",l+="
    ",l+=" ",void 0===i.cfg.mmtfid){let e="top:180px; font-size: 1.8em;";l+=i.htmlCls.divStr+"wait' style='position:absolute; left:50px; "+e+" color: #444444;'>Loading data..."}l+="Your browser does not support WebGL.",(void 0===i.cfg.showcommand||i.cfg.showcommand)&&(l+=this.setLogWindow()),l+="",l+="",l+=i.htmlCls.setDialogCls.setDialogs(),l+=i.htmlCls.setDialogCls.setCustomDialogs(),$("#"+e).html(l),$("accordion").accordion({collapsible:!0,active:!1,heightStyle:"content"}),$("accordion div").removeClass("ui-accordion-content ui-corner-all ui-corner-bottom ui-widget-content"),$(".icn3d-mn-item").menu({position:{my:"left top",at:"right top"}}),$(".icn3d-mn-item").hover((function(){}),(function(){$("accordion").accordion("option","active","none")})),$("#"+i.pre+"accordion1").hover((function(){$("#"+i.pre+"accordion1 div").css("display","block")}),(function(){$("#"+i.pre+"accordion1 div").css("display","none")})),$("#"+i.pre+"accordion2").hover((function(){$("#"+i.pre+"accordion2 div").css("display","block")}),(function(){$("#"+i.pre+"accordion2 div").css("display","none")})),$("#"+i.pre+"accordion2b").hover((function(){$("#"+i.pre+"accordion2b div").css("display","block")}),(function(){$("#"+i.pre+"accordion2b div").css("display","none")})),$("#"+i.pre+"accordion3").hover((function(){$("#"+i.pre+"accordion3 div").css("display","block")}),(function(){$("#"+i.pre+"accordion3 div").css("display","none")})),$("#"+i.pre+"accordion4").hover((function(){$("#"+i.pre+"accordion4 div").css("display","block")}),(function(){$("#"+i.pre+"accordion4 div").css("display","none")})),$("#"+i.pre+"accordion5").hover((function(){$("#"+i.pre+"accordion5 div").css("display","block")}),(function(){$("#"+i.pre+"accordion5 div").css("display","none")})),$("#"+i.pre+"accordion6").hover((function(){$("#"+i.pre+"accordion6 div").css("display","block")}),(function(){$("#"+i.pre+"accordion6 div").css("display","none")}))}setTopMenusHtmlMobile(e,t,s){let i=this.icn3dui;if(i.bNode)return"";let n="black"==i.htmlCls.opts.background?i.htmlCls.GREYD:"black",l="";if(l+="
    ",l+=i.htmlCls.divStr+"popup' class='icn3d-text icn3d-popup'>
    ",l+=this.setReplayHtml(),!i.utilsCls.isMobile()){let e=i.htmlCls.WIDTH-40+5;l+=i.htmlCls.buttonStr+"fullscreen' style='position:absolute; z-index:1999; display:block; padding:0px; margin: 12px 0px 0px "+e+"px; width:30px; height:34px; border-radius:4px; border:none; background-color:#f6f6f6;' title='Full screen'>",l+="",l+="",l+="",l+="",l+=""}l+="\x3c!--https://forum.jquery.com/topic/looking-for-a-jquery-horizontal-menu-bar--\x3e",l+=i.htmlCls.divStr+"mnlist' style='position:absolute; z-index:999; float:left; display:block; margin: 5px 0px 0px 5px;'>",l+="
    ",l+="",i.cfg.notebook?l+="

    ":l+="

    ",l+="
    ";let r="
  • File",l+=this.setMenu1_base(),l+=r+">Select",l+=this.setMenu2_base(),l+=r+">View",l+=this.setMenu2b_base(),l+=r+" id='"+i.pre+"style'>Style",l+=this.setMenu3_base(),l+=r+" id='"+i.pre+"color'>Color",l+=this.setMenu4_base(),l+=r+">Analysis",l+=this.setMenu5_base(),l+=r+">Help",l+=this.setMenu6_base(),i.htmlCls.shownMenus=i.hashUtilsCls.cloneHash(i.htmlCls.simpleMenus),l+="
  • "+t,l+="
    "+s,l+="
  • Alternate",l+="",l+="
  • ",l+="
    ",l+="
    ",l+="",l+=i.htmlCls.divStr+"title' class='icn3d-commandTitle' style='font-size:1.2em; font-weight:normal; position:absolute; z-index:1; float:left; display:block; margin: 12px 0px 0px 40px; color:"+n+"; width:"+(i.htmlCls.WIDTH-40).toString()+"px'>",l+=i.htmlCls.divStr+"viewer' style='position:relative; width:100%; height:100%; background-color: "+i.htmlCls.GREYD+";'>",l+=i.htmlCls.divStr+"mnLogSection'>",l+="
    ",l+="",void 0===i.cfg.mmtfid){let e="top:180px; font-size: 1.8em;";l+=i.htmlCls.divStr+"wait' style='position:absolute; left:50px; "+e+" color: #444444;'>Loading data..."}l+="Your browser does not support WebGL.",(void 0===i.cfg.showcommand||i.cfg.showcommand)&&(l+=this.setLogWindow()),l+="",l+="",l+=i.htmlCls.setDialogCls.setDialogs(),l+=i.htmlCls.setDialogCls.setCustomDialogs(),$("#"+e).html(l),$("accordion").accordion({collapsible:!0,active:!1,heightStyle:"content"}),$("accordion div").removeClass("ui-accordion-content ui-corner-all ui-corner-bottom ui-widget-content"),$(".icn3d-mn-item").menu({position:{my:"left top",at:"right top"}}),$(".icn3d-mn-item").hover((function(){}),(function(){$("accordion").accordion("option","active","none")})),$("#"+i.pre+"accordion0").hover((function(){$("#"+i.pre+"accordion0 div").css("display","block")}),(function(){$("#"+i.pre+"accordion0 div").css("display","none")}))}setReplayHtml(e){let t=this.icn3dui;if(t.bNode)return"";let s="";return s+=t.htmlCls.divStr+"replay' style='display:none; position:absolute; z-index:9999; top:"+parseInt(t.htmlCls.HEIGHT-100).toString()+"px; left:20px;'>",s+="
    ",s+='',s+="",s+='',s+='',s+="",s+="
    ",s+=t.htmlCls.divStr+"replay_menu' style='background-color:#DDDDDD; padding:3px; font-weight:bold;'>",s+=t.htmlCls.divStr+"replay_cmd' style='background-color:#DDDDDD; padding:3px; max-width:250px'>",s+="",s}setTools(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+=e.htmlCls.divStr+"selection' style='display:none;'>
    ",t+="",t+=this.setTools_base(),t+="
    ",t+="
    ",t}setButton(e,t,s,i,n){let l=this.icn3dui;return l.bNode?"":(n=void 0!==n?"color:"+n:"","
    ")}setIcon(e,t,s,i,n,l,r){let o=this.icn3dui;if(o.bNode)return"";let a,d=r?"color:#f8b84e; ":"color:#1c94c4; ",c=" background-color:#EEE; ",h="text"==e?"":"cursor:pointer;";return a=l?'
    '+i+"
    ":'',"link"==e?''+a+"":a}setTools_base(){if(this.icn3dui.bNode)return"";let e="",t="regular",s="",i="";return e+=s+this.setIcon(t,"tool_mmdbafid","Input PDB/MMDB/AlphaFold IDs","id",void 0,!0)+"",e+=s+this.setIcon(t,"tool_pdbfile","Input PDB Files (appendable)","file-alt")+"",e+=s+this.setIcon(t,"tool_sharelink","Get Share Link","link")+"",e+=s+this.setIcon(t,"saveimage","Save iCn3D PNG Image","camera")+"",e+=i+this.setIcon(t,"tool_definedsets","Defined Sets","object-group")+"",e+=s+this.setIcon(t,"tool_aroundsphere","Select by Distance","dot-circle")+"",e+=s+this.setIcon(t,"tool_saveselection","Save Selection as a Set","save")+"",e+=s+this.setIcon(t,"toggleHighlight","Toggle Highlight","highlighter")+"",e+=i+this.setIcon(t,"show_selected","View Selection","eye")+"",e+=s+this.setIcon(t,"tool_selectedcenter","Zoom in Selection","search-plus")+"",e+=s+this.setIcon(t,"alternate","Alternate the Structures by keying the letter 'a'","a",void 0,!0,!0)+"",e+=s+this.setIcon(t,"tool_resetOrientation","Reset Orientation","undo-alt")+"",e+=i+this.setIcon(t,"tool_proteinsRibbon","Style Ribbon for proteins","dna")+"",e+=s+this.setIcon(t,"tool_proteinsSphere","Style Sphere for proteins","volleyball-ball")+"",e+=s+this.setIcon(t,"tool_surfaceVDW","Show Van der Waals Surface","cloud")+"",e+=s+this.setIcon(t,"tool_bkgd","Toggle Background Color","adjust")+"",e+=i+this.setIcon(t,"tool_clrRainbowChain","Color Rainbow for Chains","rainbow")+"",e+=s+this.setIcon(t,"tool_clrSSGreen","Color by Secondary Structures","ring")+"",e+=s+this.setIcon(t,"tool_clrChain","Color by Chains","layer-group")+"",e+=s+this.setIcon(t,"tool_clrAtom","Color by Atoms","atom")+"",e+=i+this.setIcon(t,"tool_selectannotations","Sequences & Annotations","grip-lines")+"",e+=s+this.setIcon(t,"hbondsYes","Interactions","users")+"",e+=s+this.setIcon(t,"tool_delphi","Delphi Potentials","cloud-meatball")+"",e+=s+this.setIcon(t,"removeLabels","Remove Labels","remove-format")+"",e+=i+this.setIcon("link","tool-gallery","Gallery","image","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#gallery")+"",e+=s+this.setIcon("link","tool-video","Videos","file-video","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#videos")+"",e+=s+this.setIcon("link","tool-github","iCn3D GitHub","code","https://github.com/ncbi/icn3d")+"",e+=s+this.setIcon("link","tool-hints","Transform Hints","info-circle","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#useicn3d")+"",e+="",e}setTheme(e){let t,s,i,n,l,r=this.icn3dui;if(r.bNode)return"";r.htmlCls.themecolor=e,"orange"==e?(t="#e78f08",s="#f6a828",i="ui-bg_gloss-wave_35_f6a828_500x100.png",n="ui-icons_ef8c08_256x240.png",l="#eb8f00"):"black"==e?(t="#333333",s="#333333",i="ui-bg_gloss-wave_25_333333_500x100.png",n="ui-icons_222222_256x240.png",l="#222222"):"blue"==e&&(t="#4297d7",s="#5c9ccc",i="ui-bg_gloss-wave_55_5c9ccc_500x100.png",n="ui-icons_228ef1_256x240.png",l="#444"),$(".ui-widget-header").css({border:"1px solid "+t,background:s+' url("https://www.ncbi.nlm.nih.gov/Structure/icn3d/lib/images/'+i+'") 50% 50% repeat-x',color:"#fff","font-weight":"bold"}),$(".ui-button .ui-icon").css({"background-image":"url(https://www.ncbi.nlm.nih.gov/Structure/icn3d/lib/images/"+n+")"}),$(".ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited").css({color:l,"text-decoration":"none"})}setLogWindow(e,t){let s=this.icn3dui;if(s.bNode)return"";let i,n="",l=s.htmlCls.setHtmlCls.getCookie("cmdwindow");return""!=l?(i=void 0!==t?t:parseInt(l),1==i?(s.htmlCls.LOG_HEIGHT=180,s.htmlCls.CMD_HEIGHT=.8*s.htmlCls.LOG_HEIGHT,e||(n+=s.htmlCls.divStr+"cmdlog' style='float:left; margin-top: 5px; width: 100%;'>"),n+=""):(s.htmlCls.LOG_HEIGHT=65,s.htmlCls.CMD_HEIGHT=.8*s.htmlCls.LOG_HEIGHT,e||(n+=s.htmlCls.divStr+"cmdlog' style='float:left; margin-top: 5px; width: 100%;'>"),n+="")):(i=0,s.htmlCls.LOG_HEIGHT=65,s.htmlCls.CMD_HEIGHT=.8*s.htmlCls.LOG_HEIGHT,e||(n+=s.htmlCls.divStr+"cmdlog' style='float:left; margin-top: 5px; width: 100%;'>"),n+=""),e||(n+=""),e&&(s.htmlCls.clickMenuCls.setLogCmd("set cmdwindow "+i,!0),$("#"+s.pre+"cmdlog").html(n)),n}setMenu1(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
    ",t+="",t+="

    File

    ",t+="
    ",t+=this.setMenu1_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu1_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getMenuUrl("mn1_searchstru","https://www.ncbi.nlm.nih.gov/structure","Search Structure "+e.htmlCls.wifiStr,1,1),t+=this.getMenuText("mn1_searchsimilar","Search Similar",void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_vastplus","NCBI VAST+ (PDB Complex)"+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_vast","NCBI VAST (PDB Chain)"+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_foldseek","Foldseek (PDB & AlphaFold)"+e.htmlCls.wifiStr,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn1_retrievebyid","Retrieve by ID",void 0,1,1),t+="
        ",t+=this.getLink("mn1_mmdbafid","PDB/MMDB/AlphaFold IDs"+e.htmlCls.wifiStr,1,2),t+=this.getLink("mn1_mmdbid","NCBI MMDB ID (annotation) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_mmtfid","RCSB MMTF ID (fast) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_pdbid","RCSB PDB ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getMenuText("mn1_afwrap","AlphaFold Structures",void 0,void 0,2),t+="
          ",t+=this.getLink("mn1_afid","UniProt ID "+e.htmlCls.wifiStr,void 0,3),t+=this.getLink("mn1_refseqid","NCBI Protein Accession "+e.htmlCls.wifiStr,void 0,3),t+="
        ",t+=this.getLink("mn1_opmid","OPM PDB ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_mmcifid","RCSB mmCIF ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_cid","PubChem CID "+e.htmlCls.wifiStr,1,2),t+="
      ",t+="",t+=this.getMenuText("mn1_openfile","Open File",void 0,1,1),t+="
        ",t+=this.getLink("mn1_pdbfile_app","PDB Files (appendable)",1,2),t+=this.getLink("mn1_mmciffile","mmCIF File",void 0,2),t+=this.getLink("mn1_mol2file","Mol2 File",void 0,2),t+=this.getLink("mn1_sdffile","SDF File",void 0,2),t+=this.getLink("mn1_xyzfile","XYZ File",void 0,2),t+=this.getLink("mn1_afmapfile","AlphaFold PAE File",void 0,2),t+=this.getLink("mn1_urlfile","URL(CORS) "+e.htmlCls.wifiStr,void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_pngimage","iCn3D PNG Image",1,2),t+=this.getLink("mn1_state","State/Script File",void 0,2),t+=this.getLink("mn1_fixedversion","Share Link in Archived Ver. "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_selection","Selection File",void 0,2),t+=this.getMenuSep(),t+=this.getMenuText("mn1_dsn6wrap","Electron Density(DSN6)",void 0,void 0,2),t+="
          ",t+=this.getLink("mn1_dsn6","Local File",void 0,3),t+=this.getLink("mn1_dsn6url","URL(CORS) "+e.htmlCls.wifiStr,void 0,3),t+="
        ",t+="
      ",t+="",t+=this.getMenuText("mn1_alignwrap","Align",void 0,1,1),t+="
        ",t+=this.getMenuText("mn1_chainalignwrap","Multiple Chains",void 0,1,2),t+="
          ",t+=this.getRadio("mn1_chainalignRad","mn1_chainalign","by Structure Alignment "+e.htmlCls.wifiStr,void 0,1,3),t+=this.getRadio("mn1_chainalignRad","mn1_chainalign2","by Sequence Alignment "+e.htmlCls.wifiStr,void 0,1,3),t+=this.getRadio("mn1_chainalignRad","mn1_chainalign3","Residue by Residue",void 0,void 0,3),t+="
        ",t+="",t+=this.getMenuText("mn1_aligntwostru","Protein Complexes",void 0,void 0,2),t+="
          ",t+=this.getLink("mn1_align","Two PDB Structures "+e.htmlCls.wifiStr,void 0,3),t+=this.getLink("mn1_alignaf","Two AlphaFold Structures "+e.htmlCls.wifiStr,void 0,3),t+="
        ",t+=this.getLink("mn1_blast_rep_id","Sequence to Structure",void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_realignWrap","Realign Selection",void 0,void 0,1),t+="
        ",t+=this.getMenuText("mn2_chainrealignwrap","Multiple Chains",void 0,void 0,2),t+="
          ",t+=this.getRadio("mn2_realign","mn2_realignonstruct","by Structure Alignment "+e.htmlCls.wifiStr,void 0,void 0,3),t+=this.getRadio("mn2_realign","mn2_realignonseqalign","by Sequence Alignment "+e.htmlCls.wifiStr,void 0,void 0,3),t+=this.getRadio("mn2_realign","mn2_realignresbyres","Residue by Residue",void 0,void 0,3),t+="
        ",t+=this.getLink("mn2_realigntwostru","Protein Complexes",void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn1_3dpprint","3D Printing",void 0,1,1),t+="
        ",void 0===e.cfg.cid?(t+=this.getLink("mn1_exportVrmlStab","WRL/VRML(Color, W/ Stab.)",1,2),t+=this.getLink("mn1_exportStlStab","STL(W/ Stabilizers)",1,2),t+=this.getMenuSep(),t+=this.getLink("mn1_exportVrml","WRL/VRML(Color)",void 0,2),t+=this.getLink("mn1_exportStl","STL",void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_stabilizerYes","Add All Stabilizers",void 0,2),t+=this.getLink("mn1_stabilizerNo","Remove All Stabilizers",void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_stabilizerOne","Add One Stabilizer",void 0,2),t+=this.getLink("mn1_stabilizerRmOne","Remove One Stabilizer",void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_thicknessSet","Set Thickness",void 0,2)):(t+=this.getLink("mn1_exportVrml","VRML(Color)",1,2),t+=this.getLink("mn1_exportStl","STL",1,2)),t+="
      ",t+="",t+=this.getMenuText("mn1_savefile","Save File",void 0,1,1),t+="
        ",t+=this.getMenuText("mn1_savepngimage","iCn3D PNG Image",void 0,1,2),t+="
          ",t+=this.getLink("mn1_exportCanvas","Original Size & HTML",1,3),t+=this.getLink("mn1_exportCanvas1","Original Size",void 0,3),t+=this.getLink("mn1_exportCanvas2","2X Large",void 0,3),t+=this.getLink("mn1_exportCanvas4","4X Large",void 0,3),t+=this.getLink("mn1_exportCanvas8","8X Large",void 0,3),t+="
        ",t+="",t+=this.getLink("mn1_exportState","State File",void 0,2),t+=this.getLink("mn1_exportSelections","Selection File",void 0,2),t+=this.getLink("mn1_exportSelDetails","Selection Details",void 0,2),t+=this.getLink("mn1_exportCounts","Residue Counts",void 0,2),t+=this.getLink("mn1_exportPdbRes","PDB",1,2),t+=this.getLink("profixpdb","PDB with Missing Atoms",void 0,2),t+=this.getLink("profixpdbh","PDB with Hydrogens",void 0,2),void 0===e.cfg.cid&&(t+=this.getLink("mn1_exportSecondary","Secondary Structure",void 0,2)),t+="

      • ",t+="
      ",t+="",t+=this.getLink("mn1_sharelink","Share Link "+e.htmlCls.wifiStr,1,1),t+=this.getLink("mn1_replayon","Replay Each Step",void 0,1),t+=this.getMenuSep(),t+=this.getMenuText("mn1_menuwrap","Customize Menus",void 0,1,1),t+="
        ",t+=this.getLink("mn1_menuall","All Menus",1,2),t+=this.getLink("mn1_menusimple","Simple Menus",1,2),t+=this.getMenuSep(),t+=this.getLink("mn1_menupref","Preferences",1,2),t+=this.getLink("mn1_menuloadpref","Load Preferences",1,2),t+="
      ",t+="",t+="

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

    Select

    ",t+="
    ",t+=this.setMenu2_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu2_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getLink("mn2_definedsets","Defined Sets",1,1),t+=this.getLink("mn2_selectall","All",void 0,1),t+=this.getLink("mn2_selectdisplayed","Displayed Set",void 0,1),t+=this.getLink("mn2_aroundsphere","by Distance",1,1),t+=this.getMenuText("mn2_selbyprop","by Property",void 0,void 0,1),t+="
        ",t+=this.getLink("mn2_propPos","Positive",void 0,2),t+=this.getLink("mn2_propNeg","Negative",void 0,2),t+=this.getLink("mn2_propHydro","Hydrophobic",void 0,2),t+=this.getLink("mn2_propPolar","Polar",void 0,2),t+=this.getLink("mn2_propBfactor","B-factor/pLDDT",void 0,2),t+=this.getLink("mn2_propSolAcc","Solvent Accessibility",void 0,2),t+="
      ",t+="",t+=this.getLink("mn2_selectcomplement","Inverse",void 0,1),t+=this.getLink("mn2_selectmainchains","Main Chains",void 0,1),t+=this.getLink("mn2_selectsidechains","Side Chains",void 0,1),t+=this.getLink("mn2_selectmainsidechains","Main & Side Chains",void 0,1),t+=this.getLink("mn2_command","Advanced",void 0,1),void 0===e.cfg.cid?(t+=this.getMenuText("mn2_selon3d","Select on 3D",void 0,1,1),t+="
        ",t+='
      • "Alt"+Click: start selection
      • ',t+='
      • "Ctrl"+Click: union selection
      • ',t+='
      • "Shift"+Click: range Selection
      • ',t+=this.getMenuSep(),t+=this.getRadio("mn2_pk","mn2_pkChain","Chain",void 0,1,2),void 0===e.cfg.mmdbid&&void 0===e.cfg.gi||(t+=this.getRadio("mn2_pk","mn2_pkDomain","3D Domain",void 0,void 0,2)),t+=this.getRadio("mn2_pk","mn2_pkStrand","Strand/Helix",void 0,void 0,2),t+=this.getRadio("mn2_pk","mn2_pkResidue","Residue",!0,1,2),t+=this.getRadio("mn2_pk","mn2_pkYes","Atom",void 0,1,2),t+=this.getRadio("mn2_pk","mn2_pkNo","None",void 0,void 0,2),t+="
      ",t+=""):e.utilsCls.isMobile()?t+="
    • Touch to pick
    • ":t+='
    • Picking with
      "Alt" + Click
    • ',t+=this.getMenuSep(),t+=this.getLink("mn2_saveselection","Save Selection",1,1),t+=this.getLink("clearall","Clear Selection",void 0,1),t+=this.getLink("mn2_saveresidue","Save Res. in Sel.",1,1),t+=this.getMenuSep(),t+=this.getMenuText("mn2_hlcolor","Highlight Color",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn2_hl_clr","mn2_hl_clrYellow","Yellow",!0,void 0,2),t+=this.getRadio("mn2_hl_clr","mn2_hl_clrGreen","Green",void 0,void 0,2),t+=this.getRadio("mn2_hl_clr","mn2_hl_clrRed","Red",void 0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_hlstyle","Highlight Style",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn2_hl_style","mn2_hl_styleOutline","Outline",!0,void 0,2),t+=this.getRadio("mn2_hl_style","mn2_hl_styleObject","3D Objects",void 0,void 0,2),t+="
      ",t+="",t+=this.getLink("toggleHighlight2","Toggle Highlight",1,1),t+="

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

    View

    ",t+="
    ",t+=this.setMenu2b_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu2b_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getLink("mn2_show_selected","View Selection",1,1),t+=this.getLink("mn2_hide_selected","Hide Selection",1,1),t+=this.getLink("mn2_selectedcenter","Zoom in Selection",1,1),t+=this.getLink("mn6_center","Center Selection",1,1),t+=this.getLink("mn2_fullstru","View Full Structure"),t+=this.getLinkWrapper("mn2_alternate",'Alternate(Key "a")',"mn2_alternateWrap",void 0,1),void 0!==e.cfg.opmid?t+=this.getLinkWrapper("togglemem","Toggle Membrane","togglememli",void 0,1):void 0===e.cfg.cid&&(t+=this.getLinkWrapper("togglemem","Toggle Membrane","togglememli",void 0,1,!0)),void 0!==e.cfg.opmid&&(t+=this.getLinkWrapper("adjustmem","Adjust Membrane","adjustmemli",void 0,1),t+=this.getLinkWrapper("selectplane","Select between
      Two X-Y Planes","selectplaneli",void 0,1)),t+=this.getMenuSep(),t+=this.getMenuText("mn2_vrarhints","VR & AR Hints",void 0,1,1),t+="
        ",t+=this.getMenuUrl("vrhint",e.htmlCls.baseUrl+"icn3d/icn3d.html#vr","VR: VR Headsets",1,2),t+=this.getMenuUrl("arhint",e.htmlCls.baseUrl+"icn3d/icn3d.html#ar","AR: Chrome in Android",1,2),t+="
      ",t+="",t+=this.getLink("mn6_sidebyside","Side by Side",1,1),t+=this.getMenuText("mn2_rotate","Rotate",void 0,1,1),t+="
        ",t+=this.getMenuText("mn2_rotate90","Rotate 90°",void 0,void 0,2),t+="
          ",t+=this.getRadio("mn6_rotate90","mn6_rotatex","X-axis(Shift + Key M)",void 0,void 0,2),t+=this.getRadio("mn6_rotate90","mn6_rotatey","Y-axis(Shift + Key J)",void 0,void 0,2),t+=this.getRadio("mn6_rotate90","mn6_rotatez","Z-axis",void 0,void 0,2),t+="
        ",t+="",t+=this.getMenuText("mn2_rotateauto","Auto Rotation",void 0,1,2),t+="
          ",t+=this.getRadio("mn6_rotate","mn6_rotateleft","Rotate Left",void 0,1,3),t+=this.getRadio("mn6_rotate","mn6_rotateright","Rotate Right",void 0,1,3),t+=this.getRadio("mn6_rotate","mn6_rotateup","Rotate Up",void 0,1,3),t+=this.getRadio("mn6_rotate","mn6_rotatedown","Rotate Down",void 0,1,3),t+="
        ",t+="",t+="
      ",t+="",t+=this.getMenuText("mn2_camera","Camera",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_camera","mn6_cameraPers","Perspective",!0,void 0,2),t+=this.getRadio("mn6_camera","mn6_cameraOrth","Orthographic",void 0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_fog","Fog for Selection",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_showfog","mn6_showfogYes","On",void 0,void 0,2),t+=this.getRadio("mn6_showfog","mn6_showfogNo","Off",!0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_slab","Slab for Selection",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_showslab","mn6_showslabYes","On",void 0,void 0,2),t+=this.getRadio("mn6_showslab","mn6_showslabNo","Off",!0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_axes","XYZ-axes",void 0,1),t+="
        ",t+=this.getRadio("mn6_showaxis","mn6_showaxisYes","Original",void 0,void 0,2),t+=this.getRadio("mn6_showaxis","mn6_showaxisSel","Prin. Axes on Sel.",void 0,void 0,2),t+=this.getRadio("mn6_showaxis","mn6_showaxisNo","Hide",!0,void 0,2),t+="
      ",t+="",t+=this.getMenuSep(),t+=this.getMenuText("mn2_resetwrap","Reset",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_reset","reset","All",void 0,1,2),t+=this.getRadio("mn6_reset","mn6_resetOrientation","Orientation",void 0,1,2),t+="
      ",t+="",t+=this.getLink("mn6_back","Undo",void 0,1),t+=this.getLink("mn6_forward","Redo",void 0,1),t+=this.getLink("mn6_fullscreen","Full Screen",void 0,1),t+="

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

    Style

    ",t+="
    ",t+=this.setMenu3_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu3_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";t+="
      ",void 0===e.cfg.cid&&(t+=this.getMenuText("mn3_proteinwrap","Proteins",void 0,1,1),t+="
        ",void 0!==e.cfg.align||void 0!==e.cfg.chainalign?t+=this.getRadio("mn3_proteins","mn3_proteinsRibbon","Ribbon",void 0,1,2):t+=this.getRadio("mn3_proteins","mn3_proteinsRibbon","Ribbon",!0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsStrand","Strand",void 0,void 0,2),t+=this.getRadio("mn3_proteins","mn3_proteinsCylinder","Cylinder and Plate",void 0,void 0,2),t+=this.getRadio("mn3_proteins","mn3_proteinsSchematic","Schematic",void 0,1,2),void 0!==e.cfg.align||void 0!==e.cfg.chainalign?t+=this.getRadio("mn3_proteins","mn3_proteinsCalpha","C Alpha Trace",!0,1,2):t+=this.getRadio("mn3_proteins","mn3_proteinsCalpha","C Alpha Trace",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsBackbone","Backbone",void 0,void 0,2),t+=this.getRadio("mn3_proteins","mn3_proteinsBfactor","B-factor Tube",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsLines","Lines",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsStick","Stick",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsBallstick","Ball and Stick",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_sidecwrap","Side Chains",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_sidec","mn3_sidecLines","Lines",void 0,1,2),t+=this.getRadio("mn3_sidec","mn3_sidecStick","Stick",void 0,1,2),t+=this.getRadio("mn3_sidec","mn3_sidecBallstick","Ball and Stick",void 0,1,2),t+=this.getRadio("mn3_sidec","mn3_sidecSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_sidec","mn3_sidecNo","Hide",!0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_nuclwrap","Nucleotides",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_nucl","mn3_nuclCartoon","Cartoon",!0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclPhos","O3' Trace",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclBackbone","Backbone",void 0,void 0,2),t+=this.getRadio("mn3_nucl","mn3_nuclSchematic","Schematic",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclLines","Lines",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclStick","Stick",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclBallstick","Ball and Stick",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_ntbasewrap","Nucl. Bases",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_ntbase","mn3_ntbaseLines","Lines",void 0,1,2),t+=this.getRadio("mn3_ntbase","mn3_ntbaseStick","Stick",void 0,1,2),t+=this.getRadio("mn3_ntbase","mn3_ntbaseBallstick","Ball and Stick",void 0,1,2),t+=this.getRadio("mn3_ntbase","mn3_ntbaseSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_ntbase","mn3_ntbaseNo","Hide",!0,1,2),t+="
      ",t+=""),t+=this.getMenuText("mn3_ligwrap","Chemicals",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_lig","mn3_ligLines","Lines",void 0,1,2),void 0===e.cfg.cid?(t+=this.getRadio("mn3_lig","mn3_ligStick","Stick",!0,1,2),t+=this.getRadio("mn3_lig","mn3_ligBallstick","Ball and Stick",void 0,1,2)):(t+=this.getRadio("mn3_lig","mn3_ligStick","Stick",void 0,1,2),t+=this.getRadio("mn3_lig","mn3_ligBallstick","BalHydrogensl and Stick",!0,1,2)),t+=this.getRadio("mn3_lig","mn3_ligSchematic","Schematic",void 0,1,2),t+=this.getRadio("mn3_lig","mn3_ligSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_lig","mn3_ligNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_hydrogenswrap","Hydrogens",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_hydrogens","mn3_hydrogensYes","Show",!0,1,2),t+=this.getRadio("mn3_hydrogens","mn3_hydrogensNo","Hide",void 0,1,2),t+="
      ",t+="",void 0===e.cfg.cid&&(t+=this.getMenuText("mn3_glycanwrap","Glycans",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn3_glycansCart","mn3_glycansCartYes","Show Cartoon",void 0,void 0,2),t+=this.getRadio("mn3_glycansCart","mn3_glycansCartNo","Hide Cartoon",!0,void 0,2),t+="
      ",t+=""),t+=this.getMenuText("mn3_ionswrap","Ions",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_ions","mn3_ionsSphere","Sphere",!0,1,2),t+=this.getRadio("mn3_ions","mn3_ionsDot","Dot",void 0,1,2),t+=this.getRadio("mn3_ions","mn3_ionsNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_waterwrap","Water",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_water","mn3_waterSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_water","mn3_waterDot","Dot",void 0,1,2),t+=this.getRadio("mn3_water","mn3_waterNo","Hide",!0,1,2),t+="
      ",t+="",t+=this.getLink("mn3_setThickness","Preferences",void 0,1),t+=this.getMenuSep(),t+=this.getLink("mn3_styleSave","Save Style",void 0,2),t+=this.getLink("mn3_styleApplySave","Apply Saved Style",void 0,2),t+=this.getMenuSep(),t+=this.getMenuText("mn5_surfacewrap","Surface Type",void 0,1,1),t+="
        ",t+=this.getRadio("mn5_surface","mn5_surfaceVDW","Van der Waals",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceVDWContext","VDW with Context",void 0,void 0,2),t+=this.getRadio("mn5_surface","mn5_surfaceMolecular","Molecular Surface",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceMolecularContext","MS with Context",void 0,void 0,2),t+=this.getRadio("mn5_surface","mn5_surfaceSAS","Solvent Accessible",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceSASContext","SA with Context",void 0,void 0,2),t+="
      ",t+="",t+=this.getLink("mn5_surfaceNo","Remove Surface",1,1),t+=this.getMenuText("mn5_surfaceop","Surface Opacity",void 0,1,1),t+="
        ",t+=this.getMenuText("mn5_surfaceopfast","Fast Transparency",void 0,1,2),t+="
          ",t+=this.getRadio("mn5_opacity","mn5_opacity10","1.0",!0,1,3);for(let e=9;e>0;--e)t+=this.getRadio("mn5_opacity","mn5_opacity0"+e,"0."+e,1,3);t+="
        ",t+="",t+=this.getMenuText("mn5_surfaceopslow","Slow Transparency",void 0,void 0,2),t+="
          ",t+=this.getRadio("mn5_opacityslow","mn5_opacityslow10","1.0",!0,void 0,3);for(let e=9;e>0;--e)t+=this.getRadio("mn5_opacityslow","mn5_opacityslow0"+e,"0."+e,void 0,void 0,3);return t+="
        ",t+="",t+="
      ",t+=this.getMenuText("mn5_wireframewrap","Surface Wireframe",void 0,1,1),t+="
        ",t+=this.getRadio("mn5_wireframe","mn5_wireframeYes","Yes",void 0,1,2),t+=this.getRadio("mn5_wireframe","mn5_wireframeNo","No",!0,1,2),t+="
      ",t+="",t+=this.getMenuSep(),t+=this.getLink("mn5_cartoonshape","Cartoon for a Set",void 0,1),t+=this.getLink("mn5_linebtwsets","Line btw. Two Sets",void 0,1),void 0===e.cfg.cid&&void 0===e.cfg.align&&void 0===e.cfg.chainalign&&void 0===e.cfg.mmdbaf&&(t+=this.getMenuSep(),t+=this.getLinkWrapper2("mn5_map","Electron Density","mapWrapper1",void 0,1),t+="
        ",t+=this.getLink("mn5_elecmap2fofc","2Fo-Fc Map",void 0,2),t+=this.getLink("mn5_elecmapfofc","Fo-Fc Map",void 0,2),t+=this.getLinkWrapper("mn5_elecmapNo","Remove Map","mapWrapper2",void 0,2),t+="
      ",t+="",t+=this.getLinkWrapper2("mn5_map3","Map Wireframe","mapWrapper3",void 0,1),t+="
        ",t+=this.getRadio("mn5_mapwireframe","mn5_mapwireframeYes","Yes",!0,void 0,2),t+=this.getRadio("mn5_mapwireframe","mn5_mapwireframeNo","No",void 0,void 0,2),t+="
      ",t+="",void 0===e.cfg.mmtfid&&(t+=this.getLinkWrapper("mn5_emmap","EM Density Map","emmapWrapper1",void 0,1),t+=this.getLinkWrapper("mn5_emmapNo","Remove EM Map","emmapWrapper2",void 0,1),t+=this.getLinkWrapper2("mn5_emmap3","EM Map Wireframe","emmapWrapper3",void 0,1),t+="
        ",t+=this.getRadio("mn5_emmapwireframe","mn5_emmapwireframeYes","Yes",!0,void 0,2),t+=this.getRadio("mn5_emmapwireframe","mn5_emmapwireframeNo","No",void 0,void 0,2),t+="
      ",t+="")),t+=this.getMenuSep(),t+=this.getMenuText("mn6_bkgdwrap","Background",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_bkgd","mn6_bkgdTransparent","Transparent",void 0,1,2),t+=this.getRadio("mn6_bkgd","mn6_bkgdBlack","Black",!0,1,2),t+=this.getRadio("mn6_bkgd","mn6_bkgdGrey","Gray",void 0,1,2),t+=this.getRadio("mn6_bkgd","mn6_bkgdWhite","White",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn6_themewrap","Dialog Color",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_theme","mn6_themeBlue","Blue",!0,void 0,2),t+=this.getRadio("mn6_theme","mn6_themeOrange","Orange",void 0,void 0,2),t+=this.getRadio("mn6_theme","mn6_themeBlack","Black",void 0,void 0,2),t+="
      ",t+="",t+="

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

    Color

    ",t+="
    ",t+=this.setMenu4_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu4_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getMenuText("mn4_clrwrap","Unicolor","icn3d-menupd",1,1),t+="
        ",t+=this.getMenuText("uniclrRedwrap","Red",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrRed1","Red","F00",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed2","Indian Red","CD5C5C",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed3","Light Coral","F08080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed4","Salmon","FA8072",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed5","Dark Salmon","E9967A",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed6","Light Salmon","FFA07A",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed7","Crimson","DC143C",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed8","Fire Brick","B22222",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed9","Dark Red","8B0000",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrPinkwrap","Pink",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrPink1","Pink","FFC0CB",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink2","Light Pink","FFB6C1",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink3","Hot Pink","FF69B4",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink4","Deep Pink","FF1493",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink5","Medium Violet Red","C71585",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink6","Pale Violet Red","DB7093",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrOrangewrap","Orange",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrOran1","Orange","FFA500",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran2","Dark Orange","FF8C00",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran3","Orange Red","FF4500",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran4","Tomato","FF6347",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran5","Coral","FF7F50",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran6","Light Salmon","FFA07A",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrYellowwrap","Yellow",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrYllw1","Yellow","FF0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw2","Gold","FFD700",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw3","Light Yellow","FFFFE0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw4","Lemon Chiffon","FFFACD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw5","Light Golden Rod","FAFAD2",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw6","Papaya Whip","FFEFD5",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw7","Moccasin","FFE4B5",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw8","Peach Puff","FFDAB9",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw9","Pale Golden Rod","EEE8AA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw10","Khaki","F0E68C",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw11","Dark Khaki","BDB76B",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrMagentawrap","Magenta",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrMgnt1","Magenta","F0F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt2","Orchid","DA70D6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt3","Violet","EE82EE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt4","Plum","DDA0DD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt5","Thistle","D8BFD8",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt6","Lavender","E6E6FA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt7","Medium Orchid","BA55D3",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt8","Medium Purple","9370DB",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt9","Rebecca Purple","663399",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt10","Blue Violet","8A2BE2",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt11","Dark Violet","9400D3",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt12","Dark Orchid","9932CC",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt13","Dark Magenta","8B008B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt14","Purple","800080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt15","Indigo","4B0082",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt16","Slat Blue","6A5ACD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt17","Dark Slate Blue","483D8B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt18","Medium Slat Blue","6A5ACD",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrGreenwrap","Green",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrGrn1","Green","0F0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn2","Dark Green","006400",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn3","Yellow Green","9ACD32",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn4","Olive Drab","6B8E23",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn5","Olive","808000",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn6","Dark Olive Green","556B2F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn7","Medium Aquamarine","66CDAA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn8","Dark Sea Green","8FBC8B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn9","Lignt Sea Green","20B2AA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn10","Dark Cyan","008B8B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn11","Teal","008080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn12","Forest Green","228B22",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn13","Sea Green","2E8B57",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn14","Medium Sea Green","3CB371",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn15","Spring Green","00FF7F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn16","Medium Spring","00FA9A",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn17","Light Green","90EE90",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn18","Pale Green","98FB98",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn19","Lime Green","32CD32",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn20","Lawn Green","7CFC00",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn21","Chartreuse","7FFF00",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn22","Green Yellow","ADFF2F",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrCyanwrap","Cyan",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrCyan1","Cyan","0FF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan2","Light Cyan","E0FFFF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan3","Pale Turquoise","AFEEEE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan4","Aquamarine","7FFFD4",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan5","Turquoise","40E0D0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan6","Medium Turquoise","48D1CC",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan7","Dark Turquoise","00CED1",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrBluewrap","Blue",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrBlue1","Blue","00F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue2","Medium Blue","0000CD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue3","Dark Blue","00008B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue4","Navy","000080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue5","Midnight Blue","191970",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue6","Royal Blue","4169E1",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue7","Medium Slate Blue","7B68EE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue8","Corn Flower Blue","6495ED",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue9","Dodger Blue","1E90FF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue10","Deep Sky Blue","00BFFF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue11","Light Sky Blue","87CEFA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue12","Sky Blue","87CEEB",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue13","Light Blue","ADD8E6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue14","Powder Blue","B0E0E6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue15","Light Steel Blue","B0C4DE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue16","Steel Blue","4682B4",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue17","Cadet Blue","5F9EA0",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrBrownwrap","Brown",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrBrown1","Brown","A52A2A",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown2","Maroon","800000",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown3","Sienna","A0522D",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown4","Saddle Brown","8B4513",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown5","Chocolate","D2691E",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown6","Peru","CD853F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown7","Dark Golden Rod","B8860B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown8","Golden Rod","DAA520",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown9","Sandy Brown","F4A460",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown10","Rosy Brown","BC8F8F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown11","Tan","D2B48C",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown12","Burlywood","DEB887",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown13","Wheat","F5DEB3",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown14","Navajo White","FFDEAD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown15","Bisque","FFE4C4",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown16","Blanched Almond","FFEBCD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown17","Corn Silk","FFF8DC",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrWhitewrap","White",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrWhite1","White","FFF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite2","Snow","FFFAFA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite3","Honey Dew","F0FFF0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite4","Mint Cream","F5FFFA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite5","Azure","F0FFFF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite6","Alice Blue","F0F8FF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite7","Ghost White","F8F8FF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite8","White Smoke","F5F5F5",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite9","Sea Shell","FFF5EE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite10","Beige","F5F5DC",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite11","Old Lace","FDF5E6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite12","Floral White","FFFAF0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite13","Ivory","FFFFF0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite14","Antique White","FAEBD7",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite15","Linen","FAF0E6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite16","Lavenderblush","FFF0F5",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite17","Misty Rose","FFE4E1",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrGraywrap","Gray",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrGray1","Gray","808080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray2","Dim Gray","696969",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray3","Light Slate Gray","778899",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray4","Slate Gray","708090",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray5","Dark Slate Gray","2F4F4F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray6","Black","000000",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray7","Dark Gray","A9A9A9",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray8","Silver","C0C0C0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray9","Light Gray","D3D3D3",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray10","Gainsboro","DCDCDC",void 0,1,3),t+="
        ",t+="
      ",t+=this.getRadio("mn4_clr","mn4_clrCustom","Color Picker",void 0,void 0,1),t+=this.getMenuSep(),void 0===e.cfg.cid?(t+=this.getMenuText("mn4_clrRainbowwrap","Rainbow (R-V)","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrRainbow","for Selection",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrRainbowChain","for Chains",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrRainbowSets","for Sets",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrRainbowAcrossSets","across Sets",void 0,void 0,2),t+="
      ",t+=this.getMenuText("mn4_clrSpectrumwrap","Spectrum (V-R)","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrSpectrum","for Selection",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSpectrumChain","for Chains",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSpectrumSets","for Sets",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrSpectrumAcrossSets","across Sets",void 0,void 0,2),t+="
      ",t+=this.getMenuText("mn4_clrSSwrap","Secondary","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrSSGreen","Sheet in Green",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSSYellow","Sheet in Yellow",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSSSpectrum","Spectrum",void 0,void 0,2),t+="
      ",t+=this.getRadio("mn4_clr","mn4_clrCharge","Charge",void 0,1,1),t+=this.getMenuText("mn4_hydrophobicwrap","Hydrophobicity","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrNormalizedHP","Normalized",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrHydrophobic","Wimley-White",void 0,void 0,2),t+="
      ",t+=this.getMenuText("mn4_clrBfactorwrap","B-factor","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrBfactor","Original",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrBfactorNorm","Percentile",void 0,1,2),t+="
      ",t+=this.getRadio("mn4_clr","mn4_clrArea",'Solvent
      Accessibility',void 0,void 0,1),t+=this.getRadio("mn4_clr","mn4_clrStructure","Structure",void 0,1,1),void 0!==e.cfg.align||void 0!==e.cfg.chainalign||void 0!==e.cfg.blast_rep_id?t+=this.getRadio("mn4_clr","mn4_clrChain","Chain",void 0,1,1):t+=this.getRadio("mn4_clr","mn4_clrChain","Chain",!0,1,1),t+=this.getRadio("mn4_clr","mn4_clrdomain","3D Domain",void 0,void 0,1),void 0===e.cfg.cid&&(t+=this.getMenuText("mn4_clrsetswrap","Defined Sets","icn3d-menupd",void 0,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrsets",'Rainbow for Selected Sets
        in "Analysis > Defined Sets"',void 0,void 0,2),t+="
      ",t+=""),t+=this.getMenuText("mn4_clrResiduewrap","Residue","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrResidue","Default",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrResidueCustom","Custom",void 0,void 0,2),t+="
      ",t+=this.getRadio("mn4_clr","mn4_clrAtom","Atom",void 0,1,1),void 0!==e.cfg.align||void 0!==e.cfg.chainalign?(t+=this.getRadio("mn4_clr","mn4_clrIdentity","Identity",!0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrConserved","Conservation",void 0,void 0,2)):void 0!==e.cfg.blast_rep_id?(t+=this.getRadio("mn4_clr","mn4_clrIdentity","Identity",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrConserved","Conservation",!0,void 0,2)):(t+=this.getRadio("mn4_clr","mn4_clrIdentity","Identity",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrConserved","Conservation",void 0,void 0,2)),t+=this.getRadio("mn4_clr","mn4_clrConfidence",'AlphaFold
      Confidence',void 0,1,1)):t+=this.getRadio("mn4_clr","mn4_clrAtom","Atom",!0,1,1),t+=this.getMenuSep(),t+=this.getLink("mn4_clrSave","Save Color",void 0,1),t+=this.getLink("mn4_clrApplySave","Apply Saved Color",void 0,1),t+="

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

     Analysis

    ",t+="
    ",t+=this.setMenu5_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu5_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";t+="
      ",void 0===e.cfg.cid&&(t+=this.getLink("mn6_selectannotations","Seq. & Annotations "+e.htmlCls.wifiStr,1,1),t+=this.getLink("mn2_alignment","Aligned Seq. "+e.htmlCls.wifiStr,void 0,1),void 0===e.cfg.mmdbid&&void 0===e.cfg.gi&&void 0===e.cfg.blast_rep_id&&void 0===e.cfg.align&&void 0===e.cfg.chainalign||(t+=this.getLink("mn2_2ddgm","2D Diagram "+e.htmlCls.wifiStr,1,1)),t+=this.getMenuText("2dctnwrap","2D Cartoon",void 0,void 0,1),t+="
        ",t+=this.getLink("2dctn_chain","Chain Level",void 0,2),t+=this.getLink("2dctn_domain","Domain Level",void 0,2),t+=this.getLink("2dctn_secondary","Helix/Sheet Level",void 0,2),t+="
      ",t+="",t+=this.getLink("definedsets2","Defined Sets",1,1),t+=this.getMenuSep(),t+=this.getLink("mn6_hbondsYes","Interactions",1,1),t+=this.getMenuText("mn1_window","Bring to Front",void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_window_table","Interaction Table",void 0,2),t+=this.getLink("mn1_window_linegraph","2D Interaction Network",void 0,2),t+=this.getLink("mn1_window_scatterplot","2D Interaction Map",void 0,2),t+=this.getLink("mn1_window_graph","2D Graph(Force-Directed)",void 0,2),t+="
      ",t+="",t+=this.getLink("mn6_contactmap","Contact Map",void 0,1),e.cfg.notebook||(t+=this.getLink("mn1_mutation","Mutation "+e.htmlCls.wifiStr,1,1))),e.cfg.notebook||e.cfg.hidelicense||(t+=this.getMenuText("mn1_delphiwrap","DelPhi Potential",void 0,1,1),t+="
        ",t+=this.getLink("mn1_delphi","DelPhi Potential "+e.htmlCls.licenseStr,1,2),t+=this.getMenuText("mn1_phiwrap","Load PQR/Phi",void 0,void 0,2),t+="
          ",t+=this.getLink("mn1_phi","Local PQR/Phi/Cube File",void 0,3),t+=this.getLink("mn1_phiurl","URL PQR/Phi/Cube File",void 0,3),t+="
        ",t+="",t+=this.getLink("delphipqr","Download PQR",void 0,2),t+="
      ",t+=""),t+=this.getMenuSep(),t+=this.getMenuText("mn6_distancewrap","Distance",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_distance","mn6_distanceYes","between Two Atoms",void 0,1,2),t+=this.getRadio("mn6_distance","mn6_distTwoSets","between Two Sets",void 0,void 0,2),t+=this.getRadio("mn6_distance","mn6_distManySets","Among Many Sets",void 0,void 0,2),t+=this.getRadio("mn6_distance","mn6_distanceNo","Hide",!0,1,2),t+="
      ",t+="",t+=this.getLink("mn6_area","Surface Area",1,1),t+=this.getMenuText("mn6_addlabelwrap","Label",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_addlabel","mn6_addlabelYes","by Picking Atoms",void 0,void 0,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelSelection","per Selection",void 0,void 0,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelAtoms","per Atom",void 0,void 0,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelElements","per Atom Element",void 0,1,2),void 0===e.cfg.cid&&(t+=this.getRadio("mn6_addlabel","mn6_addlabelResidues","per Residue",void 0,1,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelResnum","per Residue & Number",void 0,1,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelChains","per Chain",void 0,void 0,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelTermini","N- & C-Termini",void 0,1,2)),t+=this.getMenuSep(),t+=this.getRadio("mn6_addlabel","mn6_labelColor","Change Label Color",void 0,1,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelNo","Remove",!0,1,2),t+="
      ",t+="",t+=this.getMenuText("labelscalewrap","Label Scale",void 0,1,1),t+="
        ";for(let e=1;e<=4;++e){let s=2*e;t+=this.getRadio("mn6_labelscale","mn6_labelscale0"+s,"0."+s,void 0,1,2)}for(let e=1;e<=5;++e)t+=1==e?this.getRadio("mn6_labelscale","mn6_labelscale"+e+"0",e+".0",!0,1,2):this.getRadio("mn6_labelscale","mn6_labelscale"+e+"0",e+".0",void 0,1,2);if(t+="
      ",t+="",t+=this.getMenuSep(),void 0===e.cfg.cid){t+=this.getMenuText("mn6_chemicalbindingwrap","Chem. Binding",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_chemicalbinding","mn6_chemicalbindingshow","Show",void 0,void 0,2),t+=this.getRadio("mn6_chemicalbinding","mn6_chemicalbindinghide","Hide",!0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn6_ssbondswrap","Disulfide Bonds",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_ssbonds","mn6_ssbondsYes","Show",!0,1,2),t+=this.getRadio("mn6_ssbonds","mn6_ssbondsExport","Export Pairs",void 0,void 0,2),t+=this.getRadio("mn6_ssbonds","mn6_ssbondsNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn6_clbondswrap","Cross-Linkages",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_clbonds","mn6_clbondsYes","Show",!0,void 0,2),t+=this.getRadio("mn6_clbonds","mn6_clbondsExport","Export Pairs",void 0,void 0,2),t+=this.getRadio("mn6_clbonds","mn6_clbondsNo","Hide",void 0,void 0,2),t+="
      ",t+="";let s=void 0!==e.cfg.mmtfid||void 0!==e.cfg.pdbid||void 0!==e.cfg.opmid||void 0!==e.cfg.mmcifid||void 0!==e.cfg.mmdbid||void 0!==e.cfg.mmdbafid||void 0!==e.cfg.gi||void 0!==e.cfg.blast_rep_id;s&&(t+=this.getMenuText("assemblyWrapper","Assembly",void 0,1,1),t+="
        ",e.cfg.bu?(t+=this.getRadio("mn6_assembly","mn6_assemblyYes","Biological Assembly",!0,1,2),t+=this.getRadio("mn6_assembly","mn6_assemblyNo","Asymmetric Unit",void 0,1,2)):(t+=this.getRadio("mn6_assembly","mn6_assemblyYes","Biological Assembly",void 0,1,2),t+=this.getRadio("mn6_assembly","mn6_assemblyNo","Asymmetric Unit",!0,1,2)),t+="
      ",t+=""),t+=this.getMenuText("mn6_symmetrywrap","Symmetry",void 0,void 0,1),t+="
        ",s&&(t+=this.getLink("mn6_symmetry","from PDB(precalculated) "+e.htmlCls.wifiStr,void 0,2)),t+=this.getLink("mn6_symd","from SymD(Dynamic) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn6_clear_sym","Clear SymD Symmetry",void 0,2),t+=this.getLink("mn6_axes_only","Show Axes Only",void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn6_igrefwrap","Ref. Number",void 0,void 0,1),t+="
        ",t+=this.getLink("mn6_customref","Custom Ref. Number",void 0,2),t+="
      ",t+="",t+=this.getMenuSep()}return t+=this.getLink("mn6_yournote","Window Title",void 0,1),void 0!==e.cfg.cid?(t+=this.getMenuText("mn1_linkwrap","Links",void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_link_structure","Compound Summary "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_vast","Similar Compounds "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_bind","Structures Bound "+e.htmlCls.wifiStr,void 0,2),t+="
      ",t+=""):(t+=this.getMenuText("mn1_linkwrap","Links",void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_link_structure","Structure Summary "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_vast","Similar Structures "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_pubmed","Literature "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_protein","Protein "+e.htmlCls.wifiStr,void 0,2),t+="
      ",t+=""),t+="

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

    Help

    ",t+="
    ",t+=this.setMenu6_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu6_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getMenuUrl("abouticn3d",e.htmlCls.baseUrl+"icn3d/icn3d.html#about","About iCn3D "+e.REVISION+"",1,1),t+=this.getMenuUrl("gallery",e.htmlCls.baseUrl+"icn3d/icn3d.html#gallery","Live Gallery "+e.htmlCls.wifiStr,1,1),t+=this.getMenuUrl("video",e.htmlCls.baseUrl+"icn3d/icn3d.html#videos","iCn3D Videos",1,1),t+=this.getMenuText("mn6_faq","FAQ",void 0,1,1),t+="
        ",t+=this.getMenuUrl("faq_viewstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#viewstru","View structure",1,2),t+=this.getMenuUrl("faq_tfstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#tfstru","Transform Structure",1,2),t+=this.getMenuUrl("faq_selsubset",e.htmlCls.baseUrl+"icn3d/icn3d.html#selsubset","Select Subsets",1,2),t+=this.getMenuUrl("faq_stylecolor",e.htmlCls.baseUrl+"icn3d/icn3d.html#changestylecolor","Change Style/Color",1,2),t+=this.getMenuUrl("faq_savework",e.htmlCls.baseUrl+"icn3d/icn3d.html#saveview","Save Work",1,2),t+=this.getMenuUrl("faq_showanno",e.htmlCls.baseUrl+"icn3d/icn3d.html#showanno","Show Annotations",1,2),t+=this.getMenuUrl("faq_exportanno",e.htmlCls.baseUrl+"icn3d/icn3d.html#exportanno","Export Annotations",1,2),t+=this.getMenuUrl("faq_interanal",e.htmlCls.baseUrl+"icn3d/icn3d.html#interanalysis","Interaction Analysis",1,2),t+=this.getMenuUrl("faq_mutanal",e.htmlCls.baseUrl+"icn3d/icn3d.html#mutationanalysis","Mutation Analysis",1,2),t+=this.getMenuUrl("faq_elecpot",e.htmlCls.baseUrl+"icn3d/icn3d.html#elecpot","Electrostatic Pot.",1,2),t+=this.getMenuUrl("faq_simipdb",e.htmlCls.baseUrl+"icn3d/icn3d.html#simivast","Similar PDB",1,2),t+=this.getMenuUrl("faq_simialphapdb",e.htmlCls.baseUrl+"icn3d/icn3d.html#simifoldseek","Similar AlphaFold/PDB",1,2),t+=this.getMenuUrl("faq_alnstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#alignmul","Align Multiple Structures",1,2),t+=this.getMenuUrl("faq_batchanal",e.htmlCls.baseUrl+"icn3d/icn3d.html#batchanalysis","Batch Analysis",1,2),t+=this.getMenuUrl("faq_embedicn3d",e.htmlCls.baseUrl+"icn3d/icn3d.html#embedicn3d","Embed iCn3D",1,2),t+="
      ",t+="",t+=this.getMenuUrl("citing",e.htmlCls.baseUrl+"icn3d/icn3d.html#citing","Citing iCn3D",void 0,1),t+=this.getMenuText("mn6_source","Source Code",void 0,1,1),t+="
        ",t+=this.getMenuUrl("github","https://github.com/ncbi/icn3d","GitHub (browser) "+e.htmlCls.wifiStr,1,2),t+=this.getMenuUrl("npm","https://www.npmjs.com/package/icn3d","npm (Node.js) "+e.htmlCls.wifiStr,1,2),t+=this.getMenuUrl("notebook","https://pypi.org/project/icn3dpy","Jupyter Notebook "+e.htmlCls.wifiStr,1,2),t+="
      ",t+="",t+=this.getMenuText("mn6_develop","Develop",void 0,void 0,1),t+="
        ",t+=this.getMenuUrl("dev_embedicn3d2",e.htmlCls.baseUrl+"icn3d/icn3d.html#HowToUse","Embed iCn3D",void 0,2),t+=this.getMenuUrl("dev_urlpara",e.htmlCls.baseUrl+"icn3d/icn3d.html#parameters","URL Parameters",void 0,2),t+=this.getMenuUrl("dev_command",e.htmlCls.baseUrl+"icn3d/icn3d.html#commands","Commands",void 0,2),t+=this.getMenuUrl("dev_datastru",e.htmlCls.baseUrl+"icn3d/icn3d.html#datastructure","Data Structure",void 0,2),t+=this.getMenuUrl("dev_classstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#classstructure","Class Structure",void 0,2),t+=this.getMenuUrl("dev_addclass",e.htmlCls.baseUrl+"icn3d/icn3d.html#addclass","Add New Classes",void 0,2),t+=this.getMenuUrl("dev_modfunc",e.htmlCls.baseUrl+"icn3d/icn3d.html#modifyfunction","Modify Functions",void 0,2),t+=this.getMenuUrl("dev_restful",e.htmlCls.baseUrl+"icn3d/icn3d.html#restfulapi","RESTful APIs",void 0,2),t+=this.getMenuUrl("dev_contributor",e.htmlCls.baseUrl+"icn3d/icn3d.html#contributors","iCn3D Contributors",void 0,2),t+="
      ",t+="",t+=this.getMenuUrl("helpdoc",e.htmlCls.baseUrl+"icn3d/docs/icn3d_help.html","Help Doc "+e.htmlCls.wifiStr,1,1),t+=this.getMenuSep(),t+=this.getMenuText("mn6_tfhint","Transform Hints",void 0,1,1),t+="
        ",t+=this.getMenuText("mn6_rotate","Rotate",void 0,1,2),t+="
          ",t+="
        • Left Mouse (Click & Drag)
        • ",t+="
        • Key l: Left
        • ",t+="
        • Key j: Right
        • ",t+="
        • Key i: Up
        • ",t+="
        • Key m: Down
        • ",t+="
        • Shift + Key l: Left 90°
        • ",t+="
        • Shift + Key j: Right 90°
        • ",t+="
        • Shift + Key i: Up 90°
        • ",t+="
        • Shift + Key m: Down 90°
        • ",t+="
        ",t+="",t+=this.getMenuText("mn6_zoom","Zoom",void 0,1,2),t+="
          ",t+="
        • Middle Mouse
          (Pinch & Spread)
        • ",t+="
        • Key z: Zoom in
        • ",t+="
        • Key x: Zoom out
        • ",t+="
        ",t+="",t+=this.getMenuText("mn6_translate","Translate",void 0,1,2),t+="
          ",t+="
        • Right Mouse
          (Two Finger Click & Drag)
        • ",t+="
        ",t+="",t+="
      ",t+="",t+=this.getMenuUrl("selhints",e.htmlCls.baseUrl+"icn3d/icn3d.html#selsubset","Selection Hints",void 0,1),t+=this.getMenuUrl("helpdesk","https://support.nlm.nih.gov/support/create-case/","Write to Help Desk",1,1),t+="

    • ",t+="
    ",t}hideMenu(){let e=this.icn3dui;e.bNode||(void 0!==$("#"+e.pre+"mnlist")[0]&&($("#"+e.pre+"mnlist")[0].style.display="none"),void 0!==$("#"+e.pre+"mnLogSection")[0]&&($("#"+e.pre+"mnLogSection")[0].style.display="none"),void 0!==$("#"+e.pre+"cmdlog")[0]&&($("#"+e.pre+"cmdlog")[0].style.display="none"),$("#"+e.pre+"title")[0].style.margin="10px 0 0 10px")}showMenu(){let e=this.icn3dui;e.bNode||(void 0!==$("#"+e.pre+"mnlist")[0]&&($("#"+e.pre+"mnlist")[0].style.display="block"),void 0!==$("#"+e.pre+"mnLogSection")[0]&&($("#"+e.pre+"mnLogSection")[0].style.display="block"),void 0!==$("#"+e.pre+"cmdlog")[0]&&($("#"+e.pre+"cmdlog")[0].style.display="block"))}}class c{constructor(e){this.icn3dui=e}openDlg(e,t){let s=this.icn3dui;s.icn3d,s.bNode||(e=s.pre+e,s.cfg.notebook?this.openDlgNotebook(e,t):this.openDlgRegular(e,t),s.htmlCls.themecolor||(s.htmlCls.themecolor="blue"),s.htmlCls.setMenuCls.setTheme(s.htmlCls.themecolor))}addSaveButton(e){let t=this.icn3dui;t.icn3d,t.bNode||void 0!==this.dialogHashSave&&this.dialogHashSave.hasOwnProperty(e)||($("#"+e).parent().children(".ui-dialog-titlebar").append("
    "),void 0===this.dialogHashSave&&(this.dialogHashSave={}),this.dialogHashSave[e]=1)}addHideButton(e){let t=this.icn3dui;t.icn3d,t.bNode||void 0!==this.dialogHashHide&&this.dialogHashHide.hasOwnProperty(e)||($("#"+e).parent().children(".ui-dialog-titlebar").append("
    "),void 0===this.dialogHashHide&&(this.dialogHashHide={}),this.dialogHashHide[e]=1)}getDialogStatus(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t={},s={},i=$("#"+e.pre+"dl_selectannotations").hasClass("ui-dialog-content"),n=$("#"+e.pre+"dl_graph").hasClass("ui-dialog-content"),l=$("#"+e.pre+"dl_linegraph").hasClass("ui-dialog-content"),r=$("#"+e.pre+"dl_scatterplot").hasClass("ui-dialog-content"),o=$("#"+e.pre+"dl_contactmap").hasClass("ui-dialog-content"),a=$("#"+e.pre+"dl_alignerrormap").hasClass("ui-dialog-content"),d=$("#"+e.pre+"dl_interactionsorted").hasClass("ui-dialog-content"),c=$("#"+e.pre+"dl_alignment").hasClass("ui-dialog-content"),h=$("#"+e.pre+"dl_2ddgm").hasClass("ui-dialog-content"),p=$("#"+e.pre+"dl_2dctn").hasClass("ui-dialog-content"),m=$("#"+e.pre+"dl_definedsets").hasClass("ui-dialog-content");return t.bSelectannotationsInit2=!1,t.bGraph2=!1,t.bLineGraph2=!1,t.bScatterplot2=!1,t.bTable2=!1,t.bAlignmentInit2=!1,t.bTwoddgmInit2=!1,t.bTwodctnInit2=!1,t.bSetsInit2=!1,s.dl_selectannotations="bSelectannotationsInit2",s.dl_graph="bGraph2",s.dl_linegraph="bLineGraph2",s.dl_scatterplot="bScatterplot2",s.dl_contactmap="bContactmap2",s.dl_alignerrormap="bAlignerrormap2",s.dl_interactionsorted="bTable2",s.dl_alignment="bAlignmentInit2",s.dl_2ddgm="bTwoddgmInit2",s.dl_2dctn="bTwodctnInit2",s.dl_definedsets="bSetsInit2",i&&(t.bSelectannotationsInit2=$("#"+e.pre+"dl_selectannotations").dialog("isOpen")),n&&(t.bGraph2=$("#"+e.pre+"dl_graph").dialog("isOpen")),l&&(t.bLineGraph2=$("#"+e.pre+"dl_linegraph").dialog("isOpen")),r&&(t.bScatterplot2=$("#"+e.pre+"dl_scatterplot").dialog("isOpen")),o&&(t.bContactmap2=$("#"+e.pre+"dl_contactmap").dialog("isOpen")),a&&(t.bAlignerror2=$("#"+e.pre+"dl_alignerrormap").dialog("isOpen")),d&&(t.bTable2=$("#"+e.pre+"dl_interactionsorted").dialog("isOpen")),c&&(t.bAlignmentInit2=$("#"+e.pre+"dl_alignment").dialog("isOpen")),h&&(t.bTwoddgmInit2=$("#"+e.pre+"dl_2ddgm").dialog("isOpen")),p&&(t.bTwodctnInit2=$("#"+e.pre+"dl_2dctn").dialog("isOpen")),m&&(t.bSetsInit2=$("#"+e.pre+"dl_definedsets").dialog("isOpen")),{status:t,id2flag:s}}openDlgHalfWindow(e,t,s,i){let n=this.icn3dui,l=n.icn3d;if(n.bNode)return;let r=this,o=n.htmlCls.width2d+20;l.resizeCanvasCls.resizeCanvas(n.htmlCls.WIDTH-s,n.htmlCls.HEIGHT,i);let a,d=n.htmlCls.HEIGHT,c=s;a=!n.cfg.showmenu||n.utilsCls.isMobile()||n.cfg.mobilemenu?{my:"left top",at:"right top",of:"#"+n.pre+"viewer",collision:"none"}:{my:"left top",at:"right top+40",of:"#"+n.pre+"viewer",collision:"none"},n.cfg.resize=!1,window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:d,width:c,modal:!1,position:a,close:function(t){let s=r.getDialogStatus(),i=s.status,a=s.id2flag,d=!1;for(let t in a){let s=e===n.pre+t;for(let e in i)i.hasOwnProperty(e)||(s=s&&!i[e]);d=d||s}if(d)if(i.bTwoddgmInit2||i.bTwodctnInit2||i.bSetsInit2){let e=n.utilsCls.isMobile()?n.htmlCls.WIDTH:n.htmlCls.WIDTH-o;l.resizeCanvasCls.resizeCanvas(e,n.htmlCls.HEIGHT,!0),i.bTwoddgmInit2&&r.openDlg2Ddgm(n.pre+"dl_2ddgm",void 0,i.bSetsInit2),i.bTwodctnInit2&&r.openDlg2Ddgm(n.pre+"dl_2dctn",void 0,i.bSetsInit2),i.bSetsInit2&&r.openDlg2Ddgm(n.pre+"dl_definedsets")}else l.resizeCanvasCls.resizeCanvas(n.htmlCls.WIDTH,n.htmlCls.HEIGHT,!0)},resize:function(t){if(e==n.pre+"dl_selectannotations")l.annotationCls.hideFixedTitle();else if(e==n.pre+"dl_graph"){let t=$("#"+e).width(),s=$("#"+e).height();d3.select("#"+n.svgid).attr("width",t).attr("height",s)}else if(e==n.pre+"dl_linegraph"||e==n.pre+"dl_scatterplot"||e==n.pre+"dl_contactmap"||e==n.pre+"dl_alignerrormap"){let t=status.bTwoddgmInit2||status.bSetsInit2?(n.htmlCls.WIDTH-o)/2:n.htmlCls.WIDTH/2,s=$("#"+e).width()/t;if(e==n.pre+"dl_linegraph"){let e=l.linegraphWidth*s;$("#"+n.linegraphid).attr("width",e)}else if(e==n.pre+"dl_scatterplot"){let e=l.scatterplotWidth*s;$("#"+n.scatterplotid).attr("width",e)}else if(e==n.pre+"dl_contactmap"){let e=l.contactmapWidth*s;$("#"+n.contactmapid).attr("width",e)}else if(e==n.pre+"dl_alignerrormap"){let e=l.alignerrormapWidth*s;$("#"+n.alignerrormapid).attr("width",e)}}}}),this.addSaveButton(e),this.addHideButton(e)}openDlg2Ddgm(e,t,s){let i=this.icn3dui,n=i.icn3d;if(i.bNode)return;let l,r,o=this,a=i.htmlCls.width2d+20;e===i.pre+"dl_definedsets"?(l="right top",r="Select sets"):e!==i.pre+"dl_2ddgm"&&e!==i.pre+"dl_2dctn"||(l=s?"right top+240":"right top",r=e===i.pre+"dl_2ddgm"?"2D Diagram":"2D Cartoon");let d={my:"left top+"+i.htmlCls.MENU_HEIGHT,at:l,of:"#"+i.pre+"viewer",collision:"none"};window.dialog=$("#"+e).dialog({autoOpen:!0,title:r,height:"auto",width:a,modal:!1,position:d,close:function(e){let t=o.getDialogStatus().status;t.bSelectannotationsInit2||t.bGraph2||t.bLineGraph2||t.bScatterplot2||t.bTable2||t.bAlignmentInit2||n.resizeCanvasCls.resizeCanvas(i.htmlCls.WIDTH,i.htmlCls.HEIGHT,!0)},resize:function(t,s){e==i.pre+"dl_2dctn"&&(n.resizeRatioX=s.size.width/i.htmlCls.width2d,n.resizeRatioY=s.size.height/(i.htmlCls.width2d+70))},resizeStop:function(e,t){n.resizeRatioX=t.size.width/i.htmlCls.width2d,n.resizeRatioY=t.size.height/(i.htmlCls.width2d+70)}}),this.addSaveButton(e),this.addHideButton(e)}openDlgRegular(e,t){let s=this.icn3dui,i=s.icn3d;if(s.bNode)return;let n=400,l=150,r=s.htmlCls.width2d+20,o=this.getDialogStatus().status;if(e===s.pre+"dl_selectannotations"||e===s.pre+"dl_graph"||e===s.pre+"dl_linegraph"||e===s.pre+"dl_scatterplot"||e===s.pre+"dl_contactmap"||e===s.pre+"dl_alignerrormap"||e===s.pre+"dl_interactionsorted"||e===s.pre+"dl_alignment"){let a=.5*s.htmlCls.WIDTH-.5*r;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)this.openDlgHalfWindow(e,t,a,!0),(o.bTwoddgmInit2||o.bTwodctnInit2||o.bSetsInit2)&&(i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-a-r,s.htmlCls.HEIGHT,!0),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,o.bSetsInit2),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,o.bSetsInit2),o.bSetsInit2&&this.openDlg2Ddgm(s.pre+"dl_definedsets"));else{i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH,.5*s.htmlCls.HEIGHT,!0),l=.5*s.htmlCls.HEIGHT,n=s.htmlCls.WIDTH;let a={my:"left top",at:"left bottom+32",of:"#"+s.pre+"canvas",collision:"none"};window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:l,width:n,modal:!1,position:a,close:function(t){if(!((e!==s.pre+"dl_selectannotations"||o.bAlignmentInit2||o.bGraph2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_graph"||o.bSelectannotationsInit2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_alignment"||o.bSelectannotationsInit2||o.bGraph2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_interactionsorted"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_linegraph"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_scatterplot"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_contactmap"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bAlignerrormap2)&&(e!==s.pre+"dl_alignerrormap"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2)))if(o.bTwoddgmInit2||o.bTwodctnInit2||o.bSetsInit2){let e=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(e,s.htmlCls.HEIGHT,!0),o.bTwoddgmInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,o.bSetsInit2),o.bTwodctnInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,o.bSetsInit2),o.bSetsInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_definedsets")}else i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH,s.htmlCls.HEIGHT,!0)},resize:function(t){if(e==s.pre+"dl_selectannotations")i.annotationCls.hideFixedTitle();else if(e==s.pre+"dl_graph"){let t=$("#"+e).width(),i=$("#"+e).height();d3.select("#"+s.svgid).attr("width",t).attr("height",i)}else if(e==s.pre+"dl_linegraph"||e==s.pre+"dl_scatterplot"||e==s.pre+"dl_contactmap"||e==s.pre+"dl_alignerrormap"){let t=o.bTwoddgmInit2||o.bSetsInit2?(s.htmlCls.WIDTH-r)/2:s.htmlCls.WIDTH/2,n=$("#"+e).width()/t;if(e==s.pre+"dl_linegraph"){let e=i.linegraphWidth*n;$("#"+s.linegraphid).attr("width",e)}else if(e==s.pre+"dl_scatterplot"){let e=i.scatterplotWidth*n;$("#"+s.scatterplotid).attr("width",e)}else if(e==s.pre+"dl_contactmap"){let e=i.contactmapWidth*n;$("#"+s.contactmapid).attr("width",e)}else if(e==s.pre+"dl_alignerrormap"){let e=i.alignerrormapWidth*n;$("#"+s.alignerrormapid).attr("width",e)}}}}),this.addSaveButton(e),this.addHideButton(e)}}else if(e===s.pre+"dl_2ddgm"||e===s.pre+"dl_2dctn"){let t=0;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)(o.bSelectannotationsInit2||o.bGraph2||o.bLineGraph2||o.bScatterplot2||o.bTable2||o.bAlignmentInit2)&&(t=.5*s.htmlCls.WIDTH-.5*r),i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-t-r,s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,void 0,o.bSetsInit2);else{let t=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(t,.5*s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT,o.bSetsInit2)}}else{let a;if(l="auto",n="auto",e===s.pre+"dl_addtrack"?n="50%":e===s.pre+"dl_menupref"&&(n=600,l=500),e===s.pre+"dl_definedsets"){let t=0;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)(o.bSelectannotationsInit2||o.bGraph2||o.bLineGraph2||o.bScatterplot2||o.bTable2||o.bAlignmentInit2)&&(t=.5*s.htmlCls.WIDTH-.5*r),i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-t-r,s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,!0),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,!0);else{let t=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(t,.5*s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",.5*s.htmlCls.HEIGHT,!0),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",.5*s.htmlCls.HEIGHT,!0)}}else s.utilsCls.isMobile()?a={my:"left top",at:"left bottom-50",of:"#"+s.pre+"canvas",collision:"none"}:e===s.pre+"dl_allinteraction"||e===s.pre+"dl_buriedarea"?(a={my:"right top",at:"right top+50",of:"#"+i.divid,collision:"none"},n=700,l=500):a=e===s.pre+"dl_rmsd"||e===s.pre+"dl_legend"?{my:"left bottom",at:"left+20 bottom-20",of:"#"+s.pre+"canvas",collision:"none"}:e===s.pre+"dl_symd"?{my:"left top",at:"right-200 bottom-200",of:"#"+s.pre+"canvas",collision:"none"}:s.cfg.align?{my:"left top",at:"left top+90",of:"#"+s.pre+"canvas",collision:"none"}:{my:"left top",at:"left top+50",of:"#"+s.pre+"canvas",collision:"none"},window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:l,width:n,modal:!1,position:a}),this.addSaveButton(e),this.addHideButton(e)}$(".ui-dialog .ui-button span").removeClass("ui-icon-closethick").addClass("ui-icon-close")}openDlgNotebook(e,t){let s=this.icn3dui,i=s.icn3d;if(s.bNode)return;let n=400,l=150,r=s.htmlCls.width2d+20;e===s.pre+"dl_selectannotations"||e===s.pre+"dl_graph"||e===s.pre+"dl_linegraph"||e===s.pre+"dl_scatterplot"||e===s.pre+"dl_contactmap"||e===s.pre+"dl_alignerrormap"||e===s.pre+"dl_interactionsorted"||e===s.pre+"dl_alignment"?($("#"+e).show(),l=.5*s.htmlCls.HEIGHT,n=s.htmlCls.WIDTH,$("#"+e).width(n),$("#"+e).height(l),$("#"+e).resize((function(t){let n=s.htmlCls.WIDTH/2,l=$("#"+e).width()/n;if(e==s.pre+"dl_selectannotations")i.annotationCls.hideFixedTitle();else if(e==s.pre+"dl_graph"){let t=$("#"+e).width(),i=$("#"+e).height();d3.select("#"+s.svgid).attr("width",t).attr("height",i)}else if(e==s.pre+"dl_linegraph"){let e=i.linegraphWidth*l;$("#"+s.linegraphid).attr("width",e)}else if(e==s.pre+"dl_scatterplot"){let e=i.scatterplotWidth*l;$("#"+s.scatterplotid).attr("width",e)}else if(e==s.pre+"dl_contactmap"){let e=i.contactmapWidth*l;$("#"+s.contactmapid).attr("width",e)}else if(e==s.pre+"dl_alignerrormap"){let e=i.alignerrormapWidth*l;$("#"+s.alignerrormapid).attr("width",e)}}))):(i.bRender&&$("#"+e).show(),l="auto",n="auto",e===s.pre+"dl_addtrack"?n="50%":e===s.pre+"dl_2ddgm"||e===s.pre+"dl_2dctn"||e===s.pre+"dl_definedsets"?n=r:e!==s.pre+"dl_allinteraction"&&e!==s.pre+"dl_buriedarea"||(n=700,l=500),$("#"+e).width(n),$("#"+e).height(l))}}class h{constructor(e){this.icn3dui=e}setCustomDialogs(){let e=this.icn3dui;if(e.icn3d,e.bNode)return"";return""}getHtmlAlignResidueByResidue(e,t,s){let i=this.icn3dui;i.icn3d;let n="";return n+="All chains will be aligned to the first chain in the comma-separated chain IDs. Each chain ID has the form of PDBID_chain (e.g., 1HHO_A, case sensitive) or UniprotID (e.g., P69905 for AlphaFold structures).

    ",n+="Chain IDs: "+i.htmlCls.inputTextStr+"id='"+i.pre+e+"' value='P69905,P01942,1HHO_A' size=50>

    ",n+='Each alignment is defined as " | "-separated residue lists in one line. "10-50" means a range of residues from 10 to 50.

    ",n+=i.htmlCls.buttonStr+s+"'>Align Residue by Residue
    ",n}setDialogs(){let e=this.icn3dui,t=e.icn3d;if(e.bNode)return"";let s="";e.htmlCls.optionStr="":s.htmlCls.optionStr+"'"+l+"'>"+l+""}return i}setColorHints(){let e=this.icn3dui;e.icn3d;let t="";return t+=e.htmlCls.divNowrapStr+'Green: H-Bonds; ',t+='Cyan: Salt Bridge/Ionic; ',t+='Grey: contacts',t+=e.htmlCls.divNowrapStr+'Magenta: Halogen Bonds; ',t+='Red: π-Cation; ',t+='Blue: π-Stacking',t}setThicknessHtml(e){let t=this.icn3dui,s=t.icn3d,i="",n="3dprint"==e?"1":"0.1",l="3dprint"==e?"1.2":"0.3",r="3dprint"==e?"0.8":"0.4",o="3dprint"==e?"0.8":"0.4",a="3dprint"==e?"1":"0.4",d="3dprint"==e?"0.6":"0.3",c="3dprint"==e?"1":"0.2",h="3dprint"==e?"2":"1.3",p="3dprint"==e?"1.4":"0.8",m=40,u=.6,g=.4,f=.2,b=0,C=1,y=0;if("style"==e){if(""!=this.getCookie("shininess")&&(m=parseFloat(this.getCookie("shininess"))),""!=this.getCookie("light1")&&(u=parseFloat(this.getCookie("light1")),g=parseFloat(this.getCookie("light2")),f=parseFloat(this.getCookie("light3"))),""!=this.getCookie("lineRadius")){n=parseFloat(this.getCookie("lineRadius")),l=parseFloat(this.getCookie("coilWidth")),r=parseFloat(this.getCookie("cylinderRadius"));let e=this.getCookie("crosslinkRadius");o=isNaN(e)?s.crosslinkRadius:parseFloat(e),a=parseFloat(this.getCookie("traceRadius")),d=parseFloat(this.getCookie("dotSphereScale")),c=parseFloat(this.getCookie("ribbonthickness")),h=parseFloat(this.getCookie("helixSheetWidth")),p=parseFloat(this.getCookie("nucleicAcidWidth"))}""!=this.getCookie("glycan")&&(b=parseFloat(this.getCookie("glycan"))),""!=this.getCookie("membrane")&&(C=parseFloat(this.getCookie("membrane"))),""!=this.getCookie("cmdwindow")&&(y=parseFloat(this.getCookie("cmdwindow"))),i+="Note: The following parameters will be saved in cache. You just need to set them once.

    ",i+="1. Shininess: "+t.htmlCls.inputTextStr+"id='"+t.pre+"shininess' value='"+m+"' size=4>"+t.htmlCls.space3+"(for the shininess of the 3D objects, default 40)

    ",i+="2. Three directional lights:
    ",i+="Key Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light1' value='"+u+"' size=4>"+t.htmlCls.space3+"(for the light strength of the key light, default 0.6)
    ",i+="Fill Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light2' value='"+g+"' size=4>"+t.htmlCls.space3+"(for the light strength of the fill light, default 0.4)
    ",i+="Back Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light3' value='"+f+"' size=4>"+t.htmlCls.space3+"(for the light strength of the back light, default 0.2)

    ",i+="3. Thickness:
    "}return i+="Line Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"linerad_"+e+"' value='"+n+"' size=4>"+t.htmlCls.space3+"(for stabilizers, hydrogen bonds, distance lines, default 0.1)
    ",i+="Coil Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"coilrad_"+e+"' value='"+l+"' size=4>"+t.htmlCls.space3+"(for coils, default 0.3)
    ",i+="Stick Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"stickrad_"+e+"' value='"+r+"' size=4>"+t.htmlCls.space3+"(for sticks, default 0.4)
    ",i+="Cross-Linkage Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"crosslinkrad_"+e+"' value='"+o+"' size=4>"+t.htmlCls.space3+"(for cross-linkages, default 0.4)
    ",i+="Trace Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"tracerad_"+e+"' value='"+a+"' size=4>"+t.htmlCls.space3+"(for C alpha trace, O3' trace, default 0.4)
    ",i+="Ribbon Thickness: "+t.htmlCls.inputTextStr+"id='"+t.pre+"ribbonthick_"+e+"' value='"+c+"' size=4>"+t.htmlCls.space3+"(for helix and sheet ribbons, nucleotide ribbons, default 0.2)
    ",i+="Protein Ribbon Width: "+t.htmlCls.inputTextStr+"id='"+t.pre+"prtribbonwidth_"+e+"' value='"+h+"' size=4>"+t.htmlCls.space3+"(for helix and sheet ribbons, default 1.3)
    ",i+="Nucleotide Ribbon Width: "+t.htmlCls.inputTextStr+"id='"+t.pre+"nucleotideribbonwidth_"+e+"' value='"+p+"' size=4>"+t.htmlCls.space3+"(for nucleotide ribbons, default 0.8)
    ",i+="Ball Scale: "+t.htmlCls.inputTextStr+"id='"+t.pre+"ballscale_"+e+"' value='"+d+"' size=4>"+t.htmlCls.space3+"(for styles 'Ball and Stick' and 'Dot', default 0.3)
    ","style"==e&&(i+="
    4. Show Glycan Cartoon: "+t.htmlCls.inputTextStr+"id='"+t.pre+"glycan' value='"+b+"' size=4>"+t.htmlCls.space3+"(0: hide, 1: show, default 0)
    ",i+="
    5. Show Membrane: "+t.htmlCls.inputTextStr+"id='"+t.pre+"membrane' value='"+C+"' size=4>"+t.htmlCls.space3+"(0: hide, 1: show, default 1)
    ",i+="
    6. Enlarge Command Window: "+t.htmlCls.inputTextStr+"id='"+t.pre+"cmdwindow' value='"+y+"' size=4>"+t.htmlCls.space3+"(0: Regular, 1: Large, default 0)

    "),i+=t.htmlCls.spanNowrapStr+""+t.htmlCls.buttonStr+"apply_thickness_"+e+"'>Apply   ",i+=t.htmlCls.spanNowrapStr+""+t.htmlCls.buttonStr+"reset_thickness_"+e+"'>Reset",i}getCookie(e){let t=e+"=",s=decodeURIComponent(document.cookie).split(";");for(let e=0;e":(n+='
    ',n+="
    Selection: Name: "+s.htmlCls.inputTextStr+"id='"+s.pre+"seq_command_name"+e+"' value='seq_"+l+"' size='5'> "+s.htmlCls.space2+"

    ",n+=s.htmlCls.divStr+"seqguide"+e+"' style='display:none; white-space:normal;' class='icn3d-box'>"),n+=this.getSelectionHints();return n+="Residue labeling: standard residue with coordinates: UPPER case letter; nonstandard residue with coordinates: the first UPPER case letter plus a period except that water residue uses the letter 'O'; residue missing coordinates: lower case letter."+(s.utilsCls.isMac()&&!s.utilsCls.isMobile()?"

    Turn on scroll bar: System preferences -> General -> show scroll bars -> check Always":"")+"
    ",n}setAlignSequenceGuide(e,t){let s=this.icn3dui,i=s.icn3d,n="";let l=i&&i.defNames2Atoms?Object.keys(i.defNames2Atoms).length:1;n+='
    ',n+="
    Selection: Name: "+s.htmlCls.inputTextStr+"id='"+s.pre+"alignseq_command_name' value='alseq_"+l+"' size='10'> "+s.htmlCls.space2+"

    ",n+=s.htmlCls.divStr+"alignseqguide' style='display:none; white-space:normal;' class='icn3d-box'>",n+=this.getSelectionHints();return n+="Residue labeling: aligned residue with coordinates: UPPER case letter; non-aligned residue with coordinates: lower case letter which can be highlighted; residue missing coordinates: lower case letter which can NOT be highlighted."+(s.utilsCls.isMac()&&!s.utilsCls.isMobile()?"

    Turn on scroll bar: System preferences -> General -> show scroll bars -> check Always":"")+"
    ",n}getSelectionHints(){let e=this.icn3dui;e.icn3d;let t="";if(e.utilsCls.isMobile())t+='Select Aligned Sequences: touch to select, touch again to deselect, multiple selection is allowed without Ctrl key, click "Save Selection" to save the current selection.
    ';else{t+='Select on 1D sequences: drag to select, drag again to deselect, multiple selection is allowed without Ctrl key, click "Save Selection" to save the current selection.

    ',t+="Select on 2D interaction diagram: click on the nodes or lines. The nodes are chains and can be united with the Ctrl key. The lines are interactions and can NOT be united. Each click on the lines selects half of the lines, i.e., select the interacting residues in one of the two chains.

    ",t+="Select on 3D structures: "+(e.utilsCls.isMobile()?"use finger to pick":'hold "Alt" and use mouse to pick')+', click the second time to deselect, hold "Ctrl" to union selection, hold "Shift" to select a range, press the up/down arrow to switch among atom/residue/strand/chain/structure, click "Save Selection" to save the current selection.

    ',t+='Save the current selection(either on 3D structure, 2D interactions, or 1D sequence): open the menu "Select -> Save Selection", specify the name and description for the selection, and click "Save".

    '}return t}addGsizeSalt(e){let t=this.icn3dui;t.icn3d;let s="";s+="Grid Size: ",s+="Salt Concentration: M
    ",s}getFootHtml(e,t){let s=this.icn3dui;s.icn3d;let i="
    ";return"delphi"==e?s.cfg.cid?i+="Note: Partial charges(MMFF94) are from PubChem Compound SDF files.

    ":(i+="Note: Only the selected residues are used for DelPhi potential calculation by solving linear Poisson-Boltzmann equation.",i+='

    ',i+=s.htmlCls.divStr+t+"' style='display:none;'>",i+="
    The hydrogens and partial charges of proteins and nucleotides are added using DelPhiPKa with the Amber charge and size files. The hydrogens of ligands are added using Open Babel. The partial charges of ligands are calculated using Antechamber with the Gasteiger charge method. All partial charges are calculated at pH 7.

    ",i+='Lipids are treated as ligands. Please use "HETATM" instead of "ATOM " for each lipid atom in your PDB file. Each phosphate in lipids is assigned with a charge of -1. You can download PQR and modify it, or prepare your PQR file using other tools. Then load the PQR file at the menu "Analysis > Load PQR/Potential".

    ',i+="
    "):(i+="Note: Always load a PDB file before loading a PQR or DelPhi potential file.",i+='

    ',i+=s.htmlCls.divStr+t+"' style='display:none;'>",i+='The PDB file can be loaded in the URL with "pdbid=" or at "File > Open File". The PQR file can be prepared at the menu "Analysis > Download PQR" with your modification or using other tools. The DelPhi potential file can be calculated at DelPhi Web Server and be exported as a Cube file. ',"url"==e&&(i+="The PQR or potential file can be accessed in a URL if it is located in the same host as iCn3D."),i+="

    ",i+=""),i+="",i}getPotentialHtml(e,t){let s=this.icn3dui;s.icn3d;let i,n,l,r,o,a="";r="Equipotential Map",o="Surface with Potential","delphi"==e?n="delphi":"local"==e?(i="pqr",n="phi",l="cube"):"url"==e&&(i="pqrurl",n="phiurl",l="cubeurl"),a+=s.htmlCls.divStr+"dl_"+n+"' class='"+t+"'>",a+=s.htmlCls.divStr+"dl_"+n+"_tabs' style='border:0px;'>",a+="",a+=s.htmlCls.divStr+n+"tab1'>","delphi"==e&&(a+=this.addGsizeSalt(n)+"
    "),a+="Potential contour at: kT/e(25.6mV at 298K)

    ","delphi"==e?(a+=s.htmlCls.buttonStr+"reload_"+n+"file' style='margin-top: 6px;'>Equipotential Map",a+=s.htmlCls.buttonStr+n+"mapNo' style='margin-left:30px;'>Remove Map
    "):"local"==e?(a+=s.htmlCls.divStr+n+"tab1_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo'>Remove Map",a+=s.htmlCls.divStr+n+"tab1_"+i+"'>",a+=this.addGsizeSalt(i)+"
    ",a+="PQR File: "+s.htmlCls.inputFileStr+"id='"+s.pre+i+"file'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+n+"'>",a+="Phi File: "+s.htmlCls.inputFileStr+"id='"+s.pre+n+"file'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+l+"'>",a+="Cube File: "+s.htmlCls.inputFileStr+"id='"+s.pre+l+"file'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=""):"url"==e&&(a+=s.htmlCls.divStr+n+"tab1_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo'>Remove Map",a+=s.htmlCls.divStr+n+"tab1_"+i+"2'>",a+=this.addGsizeSalt(i)+"
    ",a+="PQR URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+i+"file'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+n+"2'>",a+="Phi URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+n+"file'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+l+"2'>",a+="Cube URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+l+"file'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=""),a+="
    "+this.getFootHtml(e,n+"tab1_foot"),a+="",a+=s.htmlCls.divStr+n+"tab2'>","delphi"==e&&(a+=this.addGsizeSalt(n)+"
    "),a+="Surface with max potential at: kT/e(25.6mV at 298K)

    ",a+="Surface: ",a+="Opacity: ",a+="Wireframe:
    ",a+="
    ","delphi"==e?(a+=s.htmlCls.buttonStr+"reload_"+n+"file2' style='margin-top: 6px;'>Surface with Potential",a+=s.htmlCls.buttonStr+n+"mapNo2' style='margin-left:30px;'>Remove Surface
    "):"local"==e?(a+=s.htmlCls.divStr+n+"tab2_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo2'>Remove Surface",a+=s.htmlCls.divStr+n+"tab2_"+i+"'>",a+=this.addGsizeSalt(i+"2")+"
    ",a+="PQR File: "+s.htmlCls.inputFileStr+"id='"+s.pre+i+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+n+"'>",a+="Phi File: "+s.htmlCls.inputFileStr+"id='"+s.pre+n+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+l+"'>",a+="Cube File: "+s.htmlCls.inputFileStr+"id='"+s.pre+l+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=""):"url"==e&&(a+=s.htmlCls.divStr+n+"tab2_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo2'>Remove Surface",a+=s.htmlCls.divStr+n+"tab2_"+i+"2'>",a+=this.addGsizeSalt(i+"2")+"
    ",a+="PQR URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+i+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+n+"2'>",a+="Phi URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+n+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+l+"2'>",a+="Cube URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+l+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=""),a+="
    "+this.getFootHtml(e,n+"tab2_foot"),a+="",a+="",a+="",a}async exportPqr(e){let t=this.icn3dui,s=t.icn3d,i={},n={},l=t.hashUtilsCls.intHash(s.dAtoms,s.hAtoms);for(let e in l)s.atoms[e],s.ions.hasOwnProperty(e)?i[e]=1:n[e]=1;let r=e?"pdb":"pqr";if(t.cfg.cid){let t="",l=!e;t+=s.saveFileCls.getAtomPDB(n,l)+s.saveFileCls.getAtomPDB(i,l);let o=s.inputid?s.inputid:"custom";s.saveFileCls.saveFile(o+"_icn3d."+r,"text",[t])}else{if(t.utilsCls.isCalphaPhosOnly(t.hashUtilsCls.hash2Atoms(n,s.atoms)))return void alert("The potential will not be shown because the side chains are missing in the structure...");let l="";l+=s.saveFileCls.getAtomPDB(n),l+=s.saveFileCls.getAtomPDB(i,!0,void 0,!0);let o="https://www.ncbi.nlm.nih.gov/Structure/delphi/delphi.fcgi",a={pdb2pqr:l,pdbid:t.cfg.cid?t.cfg.cid:Object.keys(s.structures).toString()},d=await t.getAjaxPostPromise(o,a,!0,void 0,void 0,!0,"text");if(e){let e=d.split("\n"),s="";for(let i=0,n=e.length;i PNG Image" in the Data menu...');else if(-1!=l){let t=e.substr(l+n.length);s.htmlCls.clickMenuCls.setLogCmd("load iCn3D PNG image "+$("#"+s.pre+"pngimage").val(),!1),window.open(t,"_self")}else if(-1!=o){let n="Start of data file======\n",l=e.indexOf(n);i.bInputfile=-1!=l;let a,d=t?t.replace(/;/g,"\n"):"";if(i.bInputfile){let t=e.indexOf("End of data file======\n"),s=e.substr(l+n.length,t-l-n.length);i.InputfileData=i.InputfileData?i.InputfileData+"\nENDMDL\n"+s:s;let c="Start of type file======\n",h=e.indexOf(c),p=e.indexOf("End of type file======\n"),m=e.substr(h+c.length,p-h-c.length-1);i.InputfileType=m;let u=e.indexOf("End of state file======\n");a=e.substr(o+r.length,u-o-r.length),a=decodeURIComponent(a+"\n"+d),"pdb"===m?(await i.pdbParserCls.loadPdbData(s),i.commands=[],i.optsHistory=[]):("mol2"===m?await i.mol2ParserCls.loadMol2Data(s):"sdf"===m?await i.sdfParserCls.loadSdfData(s):"xyz"===m?await i.xyzParserCls.loadXyzData(s):"mmcif"===m&&await i.mmcifParserCls.loadMmcifData(s),i.commands=[],i.optsHistory=[])}else{let t=e.indexOf("End of state file======\n");a=e.substr(o+r.length,t-o-r.length),a=decodeURIComponent(a+"\n"+d),i.commands=[],i.optsHistory=[]}await i.loadScriptCls.loadScript(a,!0),s.htmlCls.clickMenuCls.setLogCmd("load iCn3D PNG image "+$("#"+s.pre+"pngimage").val(),!1)}}fileSupport(){window.File&&window.FileReader&&window.FileList&&window.Blob||alert("The File APIs are not fully supported in this browser.")}getLinkColor(){let e="";return e+=", linkmap: {\n",e+='3: {"type": "peptidebond", "c":""},\n',e+='4: {"type": "ssbond", "c":"FFA500"},\n',e+='5: {"type": "ionic", "c":"0FF"},\n',e+='6: {"type": "ionicInside", "c":"FFF"},\n',e+='11: {"type": "contact", "c":"888"},\n',e+='12: {"type": "contactInside", "c":"FFF"},\n',e+='13: {"type": "hbond", "c":"0F0"},\n',e+='14: {"type": "hbondInside", "c":"FFF"},\n',e+='15: {"type": "clbond", "c":"006400"},\n',e+='17: {"type": "halogen", "c":"F0F"},\n',e+='18: {"type": "halogenInside", "c":"FFF"},\n',e+='19: {"type": "pication", "c":"F00"},\n',e+='20: {"type": "picationInside", "c":"FFF"},\n',e+='21: {"type": "pistacking", "c":"00F"},\n',e+='22: {"type": "pistackingInside", "c":"FFF"}\n',e+="}}\n",', linkmap: {\n3: {"type": "peptidebond", "c":""},\n4: {"type": "ssbond", "c":"FFA500"},\n5: {"type": "ionic", "c":"0FF"},\n6: {"type": "ionicInside", "c":"FFF"},\n11: {"type": "contact", "c":"888"},\n12: {"type": "contactInside", "c":"FFF"},\n13: {"type": "hbond", "c":"0F0"},\n14: {"type": "hbondInside", "c":"FFF"},\n15: {"type": "clbond", "c":"006400"},\n17: {"type": "halogen", "c":"F0F"},\n18: {"type": "halogenInside", "c":"FFF"},\n19: {"type": "pication", "c":"F00"},\n20: {"type": "picationInside", "c":"FFF"},\n21: {"type": "pistacking", "c":"00F"},\n22: {"type": "pistackingInside", "c":"FFF"}\n}}\n'}setCookieForThickness(){let e=this.icn3dui,t=e.icn3d;if(!e.bNode){let e=3650;this.setCookie("lineRadius",t.lineRadius,e),this.setCookie("coilWidth",t.coilWidth,e),this.setCookie("cylinderRadius",t.cylinderRadius,e),this.setCookie("crosslinkRadius",t.crosslinkRadius,e),this.setCookie("traceRadius",t.traceRadius,e),this.setCookie("dotSphereScale",t.dotSphereScale,e),this.setCookie("ribbonthickness",t.ribbonthickness,e),this.setCookie("helixSheetWidth",t.helixSheetWidth,e),this.setCookie("nucleicAcidWidth",t.nucleicAcidWidth,e)}}setLineThickness(e,t){let s=this.icn3dui,i=s.icn3d;if(i.bSetThickness=!0,"style"==e&&(t&&($("#"+s.pre+"shininess").val("40"),$("#"+s.pre+"light1").val("0.6"),$("#"+s.pre+"light2").val("0.4"),$("#"+s.pre+"light3").val("0.2"),$("#"+s.pre+"glycan").val("0"),$("#"+s.pre+"membrane").val("1"),$("#"+s.pre+"cmdwindow").val("0")),i.shininess=parseFloat($("#"+s.pre+"shininess").val()),i.light1=parseFloat($("#"+s.pre+"light1").val()),i.light2=parseFloat($("#"+s.pre+"light2").val()),i.light3=parseFloat($("#"+s.pre+"light3").val()),i.bGlycansCartoon=parseInt($("#"+s.pre+"glycan").val()),i.bMembrane=parseInt($("#"+s.pre+"membrane").val()),i.bCmdWindow=parseInt($("#"+s.pre+"cmdwindow").val())),t&&($("#"+s.pre+"linerad_"+e).val(.1),$("#"+s.pre+"coilrad_"+e).val(.3),$("#"+s.pre+"stickrad_"+e).val(.4),$("#"+s.pre+"crosslinkrad_"+e).val(.4),$("#"+s.pre+"tracerad_"+e).val(.4),$("#"+s.pre+"ballscale_"+e).val(.3),$("#"+s.pre+"ribbonthick_"+e).val(.2),$("#"+s.pre+"prtribbonwidth_"+e).val(1.3),$("#"+s.pre+"nucleotideribbonwidth_"+e).val(.8)),i.lineRadius=parseFloat($("#"+s.pre+"linerad_"+e).val()),i.coilWidth=parseFloat($("#"+s.pre+"coilrad_"+e).val()),i.cylinderRadius=parseFloat($("#"+s.pre+"stickrad_"+e).val()),i.crosslinkRadius=parseFloat($("#"+s.pre+"crosslinkrad_"+e).val()),i.traceRadius=parseFloat($("#"+s.pre+"tracerad_"+e).val()),i.dotSphereScale=parseFloat($("#"+s.pre+"ballscale_"+e).val()),i.ribbonthickness=parseFloat($("#"+s.pre+"ribbonthick_"+e).val()),i.helixSheetWidth=parseFloat($("#"+s.pre+"prtribbonwidth_"+e).val()),i.nucleicAcidWidth=parseFloat($("#"+s.pre+"nucleotideribbonwidth_"+e).val()),!s.bNode){let e=3650;this.setCookie("shininess",i.shininess,e),this.setCookie("light1",i.light1,e),this.setCookie("light2",i.light2,e),this.setCookie("light3",i.light3,e),this.setCookie("glycan",i.bGlycansCartoon,e),this.setCookie("membrane",i.bMembrane,e),this.setCookie("cmdwindow",i.bCmdWindow,e)}if(this.setCookieForThickness(),e=t){let e="reset thickness";s.htmlCls.clickMenuCls.setLogCmd(e,!0),i.bSetThickness=!1,i.threeDPrintCls.resetAfter3Dprint()}else s.htmlCls.clickMenuCls.setLogCmd("set thickness | linerad "+i.lineRadius+" | coilrad "+i.coilWidth+" | stickrad "+i.cylinderRadius+" | crosslinkrad "+i.crosslinkRadius+" | tracerad "+i.traceRadius+" | ribbonthick "+i.ribbonthickness+" | proteinwidth "+i.helixSheetWidth+" | nucleotidewidth "+i.nucleicAcidWidth+" | ballscale "+i.dotSphereScale,!0),s.htmlCls.clickMenuCls.setLogCmd("set glycan "+i.bGlycansCartoon,!0),s.htmlCls.clickMenuCls.setLogCmd("set membrane "+i.bMembrane,!0),s.htmlCls.clickMenuCls.setLogCmd("set cmdwindow "+i.bCmdWindow,!0);i.drawCls.draw()}setCookie(e,t,s){let i=new Date;i.setTime(i.getTime()+24*s*60*60*1e3);let n="expires="+i.toUTCString();document.cookie=e+"="+t+";"+n+";path=/"}updateSurfPara(e){let t=this.icn3dui,s=t.icn3d;s.phisurftype=$("#"+t.pre+e+"surftype").val(),s.phisurfop=$("#"+t.pre+e+"surfop").val(),s.phisurfwf=$("#"+t.pre+e+"surfwf").val()}exportPdb(){let e=this.icn3dui,t=e.icn3d,s="",i=e.hashUtilsCls.intHash(t.dAtoms,t.hAtoms);if(s+=t.saveFileCls.getAtomPDB(i),!e.bNode){let e=t.inputid?t.inputid:"custom";t.saveFileCls.saveFile(e+"_icn3d.pdb","text",[s])}return s}exportSecondary(){let e=this.icn3dui,t=e.icn3d,s="",i=e.hashUtilsCls.intHash(t.dAtoms,t.hAtoms);if(s+=t.saveFileCls.getSecondary(i),!e.bNode){let e=t.inputid?t.inputid:"custom";t.saveFileCls.saveFile(e+"_icn3d_ss.txt","text",[s])}return s}}class g{constructor(e){let t=e;this.icn3dui=e,this.cfg=this.icn3dui.cfg,this.opts={},this.opts.background="black",this.allMenus={},this.allMenusSel={},this.simpleMenus={},this.shownMenus={},this.WIDTH=400,this.HEIGHT=400,this.RESIDUE_WIDTH=10,t.utilsCls.isMobile()||this.cfg.mobilemenu?this.MENU_HEIGHT=0:this.MENU_HEIGHT=40,this.LOG_HEIGHT=65,this.MENU_WIDTH=750,this.LESSWIDTH=20,this.LESSWIDTH_RESIZE=20,this.LESSHEIGHT=20,this.width2d=200,this.CMD_HEIGHT=.8*this.LOG_HEIGHT,this.EXTRAHEIGHT=this.MENU_HEIGHT+this.CMD_HEIGHT,null!=this.cfg.showmenu&&0==this.cfg.showmenu&&(this.EXTRAHEIGHT-=this.MENU_HEIGHT),null!=this.cfg.showcommand&&0==this.cfg.showcommand&&(this.EXTRAHEIGHT-=this.CMD_HEIGHT),this.GREY8="#AAAAAA",this.GREYB="#CCCCCC",this.GREYC="#DDDDDD",this.GREYD="#EEEEEE",this.ORANGE="#FFA500",this.themecolor="blue",this.defaultValue=1,this.ssValue=3,this.coilValue=3,this.contactValue=11,this.contactInsideValue=12,this.hbondValue=13,this.hbondInsideValue=14,this.ssbondValue=4,this.ionicValue=5,this.ionicInsideValue=6,this.clbondValue=15,this.halogenValue=17,this.halogenInsideValue=18,this.picationValue=19,this.picationInsideValue=20,this.pistackingValue=21,this.pistackingInsideValue=22,this.contactColor="888",this.contactInsideColor="FFF",this.hbondColor="0F0",this.hbondInsideColor="FFF",this.ssbondColor="FFA500",this.ionicColor="0FF",this.ionicInsideColor="FFF",this.clbondColor="006400",this.halogenColor="F0F",this.halogenInsideColor="FFF",this.picationColor="F00",this.picationInsideColor="FFF",this.pistackingColor="00F",this.pistackingInsideColor="FFF",this.hideedges=1,this.force=4,this.simulation=void 0,this.baseUrl=window&&window.location&&"structure.ncbi.nlm.nih.gov"==window.location.hostname?"https://structure.ncbi.nlm.nih.gov/Structure/":"https://www.ncbi.nlm.nih.gov/Structure/",this.divStr="
    ",this.spanNowrapStr="",this.inputTextStr="=2.0 are supported.")));const a=new pe(o,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});a.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===r[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}a.setExtensions(l),a.setPlugins(r),a.parse(s,i)}parseAsync(e,t){const s=this;return new Promise((function(i,n){s.parse(e,t,i,n)}))}}function b(){let e={};return{get:function(t){return e[t]},add:function(t,s){e[t]=s},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const C={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class y{constructor(e){this.parser=e,this.name=C.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,i=t.length;s=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,n.source,l)}}class R{constructor(e){this.parser=e,this.name=C.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,i=s.json,n=i.textures[e];if(!n.extensions||!n.extensions[t])return null;const l=n.extensions[t],r=i.images[l.source];let o=s.textureLoader;if(r.uri){const e=s.options.manager.getHandler(r.uri);null!==e&&(o=e)}return this.detectSupport().then((function(n){if(n)return s.loadTextureImage(e,l.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class E{constructor(e){this.name=C.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const e=s.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),n=this.parser.options.meshoptDecoder;if(!n||!n.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([i,n.ready]).then((function(t){const s=e.byteOffset||0,i=e.byteLength||0,l=e.count,r=e.byteStride,o=new ArrayBuffer(l*r),a=new Uint8Array(t[0],s,i);return n.decodeGltfBuffer(new Uint8Array(o),l,r,a,e.mode,e.filter),o}))}return null}}const I="glTF",T=1313821514,M=5130562;class P{constructor(e){this.name=C.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:THREE.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==I)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-12,i=new DataView(e,12);let n=0;for(;n",t).replace("#include ",s).replace("#include ",i).replace("#include ",n).replace("#include ",l)},Object.defineProperties(this,{specular:{get:function(){return r.specular.value},set:function(e){r.specular.value=e}},specularMap:{get:function(){return r.specularMap.value},set:function(e){r.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return r.glossiness.value},set:function(e){r.glossiness.value=e}},glossinessMap:{get:function(){return r.glossinessMap.value},set:function(e){r.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class L{constructor(){this.name=C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity"]}getMaterialType(){return F}extendParams(e,t,s){const i=t.extensions[this.name];e.color=new Color(1,1,1),e.opacity=1;const n=[];if(Array.isArray(i.diffuseFactor)){const t=i.diffuseFactor;e.color.fromArray(t),e.opacity=t[3]}if(void 0!==i.diffuseTexture&&n.push(s.assignTexture(e,"map",i.diffuseTexture,sRGBEncoding)),e.emissive=new Color(0,0,0),e.glossiness=void 0!==i.glossinessFactor?i.glossinessFactor:1,e.specular=new Color(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),void 0!==i.specularGlossinessTexture){const t=i.specularGlossinessTexture;n.push(s.assignTexture(e,"glossinessMap",t)),n.push(s.assignTexture(e,"specularMap",t,sRGBEncoding))}return Promise.all(n)}createMaterial(e){const t=new F(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=TangentSpaceNormalMap,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t}}class N{constructor(){this.name=C.KHR_MESH_QUANTIZATION}}class U extends THREE.Interpolant{constructor(e,t,s,i){super(e,t,s,i)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,i=this.valueSize,n=e*i*3+i;for(let e=0;e!==i;e++)t[e]=s[n+e];return t}}U.prototype.beforeStart_=U.prototype.copySampleValue_,U.prototype.afterEnd_=U.prototype.copySampleValue_,U.prototype.interpolate_=function(e,t,s,i){const n=this.resultBuffer,l=this.sampleValues,r=this.valueSize,o=2*r,a=3*r,d=i-t,c=(s-t)/d,h=c*c,p=h*c,m=e*a,u=m-a,g=-2*p+3*h,f=p-h,b=1-g,C=f-h+c;for(let e=0;e!==r;e++){const t=l[u+e+r],s=l[u+e+o]*d,i=l[m+e+r],a=l[m+e]*d;n[e]=b*t+C*s+g*i+f*a}return n};const q=new THREE.Quaternion;class j extends U{interpolate_(e,t,s,i){const n=super.interpolate_(e,t,s,i);return q.fromArray(n).normalize().toArray(n),n}}const B=0,z=1,G=2,V=3,W=4,Y=5,X=6,K={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Q={9728:THREE.NearestFilter,9729:THREE.LinearFilter,9984:THREE.NearestMipmapNearestFilter,9985:THREE.LinearMipmapNearestFilter,9986:THREE.NearestMipmapLinearFilter,9987:THREE.LinearMipmapLinearFilter},J={33071:THREE.ClampToEdgeWrapping,33648:THREE.MirroredRepeatWrapping,10497:THREE.RepeatWrapping},Z={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ee={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},te={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},se={CUBICSPLINE:void 0,LINEAR:THREE.InterpolateLinear,STEP:THREE.InterpolateDiscrete},ie="OPAQUE",ne="MASK",le="BLEND";function re(e,t,s){for(const i in s.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=s.extensions[i])}function oe(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function ae(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let s=0,i=t.weights.length;s{const s=this.associations.get(e);null!=s&&this.associations.set(t,s);for(const[s,i]of e.children.entries())n(i,t.children[s])};return n(s,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s=2&&m.setY(t,c[e*l+1]),l>=3&&m.setZ(t,c[e*l+2]),l>=4&&m.setW(t,c[e*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m}))}loadTexture(e){const t=this.json,s=this.options,i=t.textures[e].source,n=t.images[i];let l=this.textureLoader;if(n.uri){const e=s.manager.getHandler(n.uri);null!==e&&(l=e)}return this.loadTextureImage(e,i,l)}loadTextureImage(e,t,s){const i=this,n=this.json,l=n.textures[e],r=n.images[t],o=(r.uri||r.bufferView)+":"+l.sampler;if(this.textureCache[o])return this.textureCache[o];const a=this.loadImageSource(t,s).then((function(t){t.flipY=!1,l.name&&(t.name=l.name);const s=(n.samplers||{})[l.sampler]||{};return t.magFilter=Q[s.magFilter]||LinearFilter,t.minFilter=Q[s.minFilter]||LinearMipmapLinearFilter,t.wrapS=J[s.wrapS]||RepeatWrapping,t.wrapT=J[s.wrapT]||RepeatWrapping,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=a,a}loadImageSource(e,t){const s=this,i=this.json,n=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const l=i.images[e],r=self.URL||self.webkitURL;let o=l.uri||"",a=!1;if(void 0!==l.bufferView)o=s.getDependency("bufferView",l.bufferView).then((function(e){a=!0;const t=new Blob([e],{type:l.mimeType});return o=r.createObjectURL(t),o}));else if(void 0===l.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(o).then((function(e){return new Promise((function(s,i){let l=s;!0===t.isImageBitmapLoader&&(l=function(e){const t=new Texture(e);t.needsUpdate=!0,s(t)}),t.load(THREE.LoaderUtils.resolveURL(e,n.path),l,void 0,i)}))})).then((function(e){var t;return!0===a&&r.revokeObjectURL(o),e.userData.mimeType=l.mimeType||((t=l.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),e}));return this.sourceCache[e]=d,d}assignTexture(e,t,s,i){const n=this;return this.getDependency("texture",s.index).then((function(l){if(void 0===s.texCoord||0==s.texCoord||"aoMap"===t&&1==s.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+s.texCoord+" for texture "+t+" not yet supported."),n.extensions[C.KHR_TEXTURE_TRANSFORM]){const e=void 0!==s.extensions?s.extensions[C.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=n.associations.get(l);l=n.extensions[C.KHR_TEXTURE_TRANSFORM].extendTexture(l,e),n.associations.set(l,t)}}return void 0!==i&&(l.encoding=i),e[t]=l,l}))}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const i=void 0===t.attributes.tangent,n=void 0!==t.attributes.color,l=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new PointsMaterial,Material.prototype.copy.call(t,s),t.color.copy(s.color),t.map=s.map,t.sizeAttenuation=!1,this.cache.add(e,t)),s=t}else if(e.isLine){const e="LineBasicMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new LineBasicMaterial,Material.prototype.copy.call(t,s),t.color.copy(s.color),this.cache.add(e,t)),s=t}if(i||n||l){let e="ClonedMaterial:"+s.uuid+":";s.isGLTFSpecularGlossinessMaterial&&(e+="specular-glossiness:"),i&&(e+="derivative-tangents:"),n&&(e+="vertex-colors:"),l&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=s.clone(),n&&(t.vertexColors=!0),l&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(s))),s=t}s.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),e.material=s}getMaterialType(){return MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,i=this.extensions,n=s.materials[e];let l;const r={},o=n.extensions||{},a=[];if(o[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=i[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];l=e.getMaterialType(),a.push(e.extendParams(r,n,t))}else if(o[C.KHR_MATERIALS_UNLIT]){const e=i[C.KHR_MATERIALS_UNLIT];l=e.getMaterialType(),a.push(e.extendParams(r,n,t))}else{const s=n.pbrMetallicRoughness||{};if(r.color=new Color(1,1,1),r.opacity=1,Array.isArray(s.baseColorFactor)){const e=s.baseColorFactor;r.color.fromArray(e),r.opacity=e[3]}void 0!==s.baseColorTexture&&a.push(t.assignTexture(r,"map",s.baseColorTexture,sRGBEncoding)),r.metalness=void 0!==s.metallicFactor?s.metallicFactor:1,r.roughness=void 0!==s.roughnessFactor?s.roughnessFactor:1,void 0!==s.metallicRoughnessTexture&&(a.push(t.assignTexture(r,"metalnessMap",s.metallicRoughnessTexture)),a.push(t.assignTexture(r,"roughnessMap",s.metallicRoughnessTexture))),l=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),a.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,r)}))))}!0===n.doubleSided&&(r.side=DoubleSide);const d=n.alphaMode||ie;if(d===le?(r.transparent=!0,r.depthWrite=!1):(r.transparent=!1,d===ne&&(r.alphaTest=void 0!==n.alphaCutoff?n.alphaCutoff:.5)),void 0!==n.normalTexture&&l!==MeshBasicMaterial&&(a.push(t.assignTexture(r,"normalMap",n.normalTexture)),r.normalScale=new Vector2(1,1),void 0!==n.normalTexture.scale)){const e=n.normalTexture.scale;r.normalScale.set(e,e)}return void 0!==n.occlusionTexture&&l!==MeshBasicMaterial&&(a.push(t.assignTexture(r,"aoMap",n.occlusionTexture)),void 0!==n.occlusionTexture.strength&&(r.aoMapIntensity=n.occlusionTexture.strength)),void 0!==n.emissiveFactor&&l!==MeshBasicMaterial&&(r.emissive=(new Color).fromArray(n.emissiveFactor)),void 0!==n.emissiveTexture&&l!==MeshBasicMaterial&&a.push(t.assignTexture(r,"emissiveMap",n.emissiveTexture,sRGBEncoding)),Promise.all(a).then((function(){let s;return s=l===F?i[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(r):new l(r),n.name&&(s.name=n.name),oe(s,n),t.associations.set(s,{materials:e}),n.extensions&&re(i,s,n),s}))}createUniqueName(e){const t=PropertyBinding.sanitizeNodeName(e||"");let s=t;for(let e=1;this.nodeNamesUsed[s];++e)s=t+"_"+e;return this.nodeNamesUsed[s]=!0,s}loadGeometries(e){const t=this,s=this.extensions,i=this.primitiveCache;function n(e){return s[C.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(s){return ue(s,e,t)}))}const l=[];for(let s=0,r=e.length;s0&&ae(h,n),h.name=t.createUniqueName(n.name||"mesh_"+e),oe(h,n),c.extensions&&re(i,h,c),t.assignFinalMaterial(h),a.push(h)}for(let s=0,i=a.length;s1?new Group:1===t.length?t[0]:new Object3D,r!==t[0])for(let e=0,s=t.length;e{const t=new Map;for(const[e,s]of n.associations)(e instanceof Material||e instanceof Texture)&&t.set(e,s);return e.traverse((e=>{const s=n.associations.get(e);null!=s&&t.set(e,s)})),t})(l),l}))}}function me(e,t,s,i){const n=s.nodes[e];return i.getDependency("node",e).then((function(e){if(void 0===n.skin)return e;let t;return i.getDependency("skin",n.skin).then((function(e){t=e;const s=[];for(let e=0,n=t.joints.length;e{const s=n[e];return s&&(l={profileId:e,profilePath:`${t}/${s.path}`,deprecated:!!s.deprecated}),!!l})),!l){if(!s)throw new Error("No matching profile name found");const e=n[s];if(!e)throw new Error(`No matching profile name found and default profile "${s}" missing.`);l={profileId:s,profilePath:`${t}/${e.path}`,deprecated:!!e.deprecated}}const r=await be(l.profilePath);let o;if(i){let t;if(t="any"===e.handedness?r.layouts[Object.keys(r.layouts)[0]]:r.layouts[e.handedness],!t)throw new Error(`No matching handedness, ${e.handedness}, in profile ${l.profileId}`);t.assetPath&&(o=l.profilePath.replace("profile.json",t.assetPath))}return{profile:r,assetPath:o}}const ye={xAxis:0,yAxis:0,button:0,state:fe.ComponentState.DEFAULT};class ve{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===fe.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(ye)}updateFromComponent({xAxis:e,yAxis:t,button:s,state:i}){const{normalizedXAxis:n,normalizedYAxis:l}=function(e=0,t=0){let s=e,i=t;if(Math.sqrt(e*e+t*t)>1){const n=Math.atan2(t,e);s=Math.cos(n),i=Math.sin(n)}return{normalizedXAxis:.5*s+.5,normalizedYAxis:.5*i+.5}}(e,t);switch(this.componentProperty){case fe.ComponentProperty.X_AXIS:this.value=this.states.includes(i)?n:.5;break;case fe.ComponentProperty.Y_AXIS:this.value=this.states.includes(i)?l:.5;break;case fe.ComponentProperty.BUTTON:this.value=this.states.includes(i)?s:0;break;case fe.ComponentProperty.STATE:this.valueNodeProperty===fe.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(i):this.value=this.states.includes(i)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}}class we{constructor(e,t){if(!(e&&t&&t.visualResponses&&t.gamepadIndices&&0!==Object.keys(t.gamepadIndices).length))throw new Error("Invalid arguments supplied");this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach((e=>{const s=new ve(t.visualResponses[e]);this.visualResponses[e]=s})),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:fe.ComponentState.DEFAULT,button:void 0!==this.gamepadIndices.button?0:void 0,xAxis:void 0!==this.gamepadIndices.xAxis?0:void 0,yAxis:void 0!==this.gamepadIndices.yAxis?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(e){if(this.values.state=fe.ComponentState.DEFAULT,void 0!==this.gamepadIndices.button&&e.buttons.length>this.gamepadIndices.button){const t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||1===this.values.button?this.values.state=fe.ComponentState.PRESSED:(t.touched||this.values.button>fe.ButtonTouchThreshold)&&(this.values.state=fe.ComponentState.TOUCHED)}void 0!==this.gamepadIndices.xAxis&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===fe.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>fe.AxisTouchThreshold&&(this.values.state=fe.ComponentState.TOUCHED)),void 0!==this.gamepadIndices.yAxis&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===fe.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>fe.AxisTouchThreshold&&(this.values.state=fe.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach((e=>{e.updateFromComponent(this.values)}))}}class _e{constructor(e,t,s){if(!e)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No profile supplied");this.xrInputSource=e,this.assetUrl=s,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach((e=>{const t=this.layoutDescription.components[e];this.components[e]=new we(e,t)})),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const e=[];return Object.values(this.components).forEach((t=>{e.push(t.data)})),e}updateFromGamepad(){Object.values(this.components).forEach((e=>{e.updateFromGamepad(this.xrInputSource.gamepad)}))}}class Se extends THREE.Object3D{constructor(){super(),this.motionController=null,this.envMap=null}setEnvironmentMap(e){return this.envMap==e||(this.envMap=e,this.traverse((e=>{e.isMesh&&(e.material.envMap=this.envMap,e.material.needsUpdate=!0)}))),this}updateMatrixWorld(e){super.updateMatrixWorld(e),this.motionController&&(this.motionController.updateFromGamepad(),Object.values(this.motionController.components).forEach((e=>{Object.values(e.visualResponses).forEach((e=>{const{valueNode:t,minNode:s,maxNode:i,value:n,valueNodeProperty:l}=e;t&&(l===fe.VisualResponseProperty.VISIBILITY?t.visible=n:l===fe.VisualResponseProperty.TRANSFORM&&(t.quaternion.slerpQuaternions(s.quaternion,i.quaternion,n),t.position.lerpVectors(s.position,i.position,n)))}))})))}}function Ae(e,t){!function(e,t){Object.values(e.components).forEach((e=>{const{type:s,touchPointNodeName:i,visualResponses:n}=e;if(s===fe.ComponentType.TOUCHPAD)if(e.touchPointNode=t.getObjectByName(i),e.touchPointNode){const t=new SphereGeometry(.001),s=new MeshBasicMaterial({color:255}),i=new Mesh(t,s);e.touchPointNode.add(i)}else console.warn(`Could not find touch dot, ${e.touchPointNodeName}, in touchpad component ${e.id}`);Object.values(n).forEach((e=>{const{valueNodeName:s,minNodeName:i,maxNodeName:n,valueNodeProperty:l}=e;if(l===fe.VisualResponseProperty.TRANSFORM){if(e.minNode=t.getObjectByName(i),e.maxNode=t.getObjectByName(n),!e.minNode)return void console.warn(`Could not find ${i} in the model`);if(!e.maxNode)return void console.warn(`Could not find ${n} in the model`)}e.valueNode=t.getObjectByName(s),e.valueNode||console.warn(`Could not find ${s} in the model`)}))}))}(e.motionController,t),e.envMap&&t.traverse((t=>{t.isMesh&&(t.material.envMap=e.envMap,t.material.needsUpdate=!0)})),e.add(t)}class xe{constructor(e=null){this.gltfLoader=e,this.path="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",this._assetCache={},this.gltfLoader||(this.gltfLoader=new f)}createControllerModel(e){const t=new Se;let s=null;return e.addEventListener("connected",(e=>{const i=e.data;"tracked-pointer"===i.targetRayMode&&i.gamepad&&Ce(i,this.path,"generic-trigger").then((({profile:e,assetPath:n})=>{t.motionController=new _e(i,e,n);const l=this._assetCache[t.motionController.assetUrl];if(l)s=l.scene.clone(),Ae(t,s);else{if(!this.gltfLoader)throw new Error("GLTFLoader not set.");this.gltfLoader.setPath(""),this.gltfLoader.load(t.motionController.assetUrl,(e=>{this._assetCache[t.motionController.assetUrl]=e,s=e.scene.clone(),Ae(t,s)}),null,(()=>{throw new Error(`Asset ${t.motionController.assetUrl} missing or malformed.`)}))}})).catch((e=>{console.warn(e)}))})),e.addEventListener("disconnected",(()=>{t.motionController=null,t.remove(s),s=null})),t}}class ke extends THREE.EventDispatcher{constructor(e){if(super(),void 0===e)return void console.error("ControllerGestures must be passed a renderer");const t=new THREE.Clock;this.controller1=e.xr.getController(0),this.controller1.userData.gestures={index:0},this.controller1.userData.selectPressed=!1,this.controller1.addEventListener("selectstart",i),this.controller1.addEventListener("selectend",n),this.controller2=e.xr.getController(1),this.controller2.userData.gestures={index:1},this.controller2.userData.selectPressed=!1,this.controller2.addEventListener("selectstart",i),this.controller2.addEventListener("selectend",n),this.doubleClickLimit=.2,this.pressMinimum=.4,this.right=new THREE.Vector3(1,0,0),this.up=new THREE.Vector3(0,1,0),this.type="unknown",this.prevTap="none",this.clock=t;const s=this;function i(){const e=this.userData.gestures;e.startPosition=void 0,e.startTime=t.getElapsedTime(),-1==s.type.indexOf("tap")&&(e.taps=0),s.type="unknown",this.userData.selectPressed=!0}function n(){const e=this.userData.gestures;e.endTime=t.getElapsedTime();e.endTime-e.startTime.05&&(e.startPosition=this.controller1.position.clone())),this.controller2.userData.selectPressed&&void 0===t.startPosition&&(i=s-t.startTime,i>.05&&(t.startPosition=this.controller2.position.clone())),!this.controller1.userData.selectPressed&&"tap"===this.type&&(i=this.clock.getElapsedTime()-e.endTime,i>this.doubleClickLimit)){switch(e.taps){case 1:self.prevTap="tap";break;case 2:this.dispatchEvent({type:"doubletap",position:this.controller1.position,matrixWorld:this.controller1.matrixWorld}),self.prevTap="doubletap"}this.type="unknown",e.taps=0}if("unknown"===this.type&&this.touch)"doubletap"==self.prevTap?(this.type="pinch",this.startDistance=this.controller1.position.distanceTo(this.controller2.position),this.dispatchEvent({type:"pinch",delta:new THREE.Vector3(0,0,0),scale:1,initialise:!0})):(this.type="pan",this.startPosition=this.controller1.position.clone(),this.dispatchEvent({type:"pan",delta:new THREE.Vector3(0,0,0),initialise:!0}));else if(("pinch"===this.type||"pan"===this.type)&&"doubletap"==self.prevTap&&this.controller2.position){const e=this.controller1.position.distanceTo(this.controller2.position)/this.startDistance,t=this.controller1.position.clone().sub(this.startPosition);this.dispatchEvent({type:"pinch",delta:t,scale:e})}}}class Oe{constructor(e,t){this.config=void 0===t?{panelSize:{width:1,height:1},width:512,height:512,opacity:.7,body:{fontFamily:"Arial",fontSize:30,padding:20,backgroundColor:"#000",fontColor:"#fff",borderRadius:6}}:t,void 0===this.config.width&&(this.config.width=512),void 0===this.config.height&&(this.config.height=512),void 0===this.config.body&&(this.config.body={fontFamily:"Arial",size:30,padding:20,backgroundColor:"#000",fontColor:"#fff",borderRadius:6});const s=this.config.body;void 0===s.borderRadius&&(s.borderRadius=6),void 0===s.fontFamily&&(s.fontFamily="Arial"),void 0===s.padding&&(s.padding=20),void 0===s.fontSize&&(s.fontSize=30),void 0===s.backgroundColor&&(s.backgroundColor="#000"),void 0===s.fontColor&&(s.fontColor="#fff"),Object.entries(this.config).forEach((([e,t])=>{if(!("object"!=typeof t||"panelSize"===e||t instanceof THREE.WebGLRenderer||t instanceof THREE.Scene)){const e=void 0!==t.position?t.position:{x:0,y:0};void 0!==e.left&&void 0===e.x&&(e.x=e.left),void 0!==e.top&&void 0===e.y&&(e.y=e.top);const s=void 0!==t.width?t.width:this.config.width,i=void 0!==t.height?t.height:this.config.height;void 0!==e.right&&void 0===e.x&&(e.x=this.config.width-e.right-s),void 0!==e.bottom&&void 0===e.y&&(e.y=this.config.height-e.bottom-i),void 0===e.x&&(e.x=0),void 0===e.y&&(e.y=0),t.position=e,void 0===t.type&&(t.type="text")}}));const i=this.createOffscreenCanvas(this.config.width,this.config.height);this.context=i.getContext("2d"),this.context.save();const n=void 0!==this.config.opacity?this.config.opacity:.7,l=new THREE.MeshBasicMaterial({transparent:!0,opacity:n});this.panelSize=void 0!==this.config.panelSize?this.config.panelSize:{width:1,height:1};const r=new THREE.PlaneGeometry(this.panelSize.width,this.panelSize.height);this.mesh=new THREE.Mesh(r,l),this.texture=new THREE.CanvasTexture(i),this.mesh.material.map=this.texture,this.scene=this.config.scene;if(Object.values(this.config).filter((e=>"input-text"===e.type)).length>0){this.keyboard=new Re(this.panelSize.width,this.config.renderer);this.keyboard.mesh.position.set(0,-.3,.2),this.mesh.add(this.keyboard.mesh)}if(void 0===e)this.content={body:""},this.config.body.type="text";else{this.content=e;Object.values(t).filter((e=>"button"===e.type||"scroll"===e.overflow||"input-text"===e.type)).length>0&&(void 0===t||void 0===t.renderer?console.warn("CanvasUI: button, scroll or input-text in the config but no renderer"):(this.renderer=t.renderer,this.initControllers()))}this.selectedElements=[void 0,void 0],this.selectPressed=[!1,!1],this.scrollData=[void 0,void 0],this.intersects=[void 0,void 0],this.needsUpdate=!0,this.update()}getIntersectY(e){const t=this.config.height||512,s=this.intersects[e];return void 0===s||void 0===s.uv?0:(1-s.uv.y)*t}initControllers(){this.vec3=new THREE.Vector3,this.mat4=new THREE.Matrix4,this.raycaster=new THREE.Raycaster;const e=this;function t(t){const s=t.target===e.controller?0:1,i=e.selectedElements[s];if(void 0!==i)if("button"==i.type)e.select(s);else if("input-text"==i.type&&e.keyboard)if(e.keyboard.visible)e.keyboard.linkedUI=void 0,e.keyboard.linkedText=void 0,e.keyboard.linkedElement=void 0,e.keyboard.visible=!1;else{let t;e.keyboard.linkedUI=e,Object.entries(e.config).forEach((([e,s])=>{s==i&&(t=e)}));const s=(.5-(i.position.y+i.height+e.config.body.padding)/e.config.height)*e.panelSize.height,n=Math.max(e.panelSize.width,e.panelSize.height)/2;e.keyboard.position.set(0,-n/1.5-s,.1),e.keyboard.linkedText=e.content[t],e.keyboard.linkedName=t,e.keyboard.linkedElement=i,e.keyboard.visible=!0}}function s(t){const s=t.target===e.controller?0:1;if(e.selectPressed[s]=!0,void 0!==e.selectedElements[s]&&"scroll"==e.selectedElements[s].overflow){const t=e.selectedElements[s];e.scrollData[s]={scrollY:t.scrollY,rayY:e.getIntersectY(s)}}}function i(t){const s=t.target===e.controller?0:1;e.selectPressed[s]=!1,void 0!==e.selectedElements[s]&&"scroll"==e.selectedElements[s].overflow&&(e.scrollData[s]=void 0)}if(this.controller=this.renderer.xr.getController(0),this.controller.addEventListener("select",t),this.controller.addEventListener("selectstart",s),this.controller.addEventListener("selectend",i),this.controller1=this.renderer.xr.getController(1),this.controller1.addEventListener("select",t),this.controller1.addEventListener("selectstart",s),this.controller1.addEventListener("selectend",i),this.scene){const e=.015,t=new THREE.IcosahedronBufferGeometry(e),s=new THREE.MeshBasicMaterial({color:170}),i=new THREE.Mesh(t,s);i.visible=!1,this.scene.add(i);const n=new THREE.Mesh(t,s);n.visible=!1,this.scene.add(n),this.intersectMesh=[i,n]}}setClip(e){const t=this.context;if(t.restore(),t.save(),void 0!==e.clipPath){const s=new Path2D(e.clipPath);t.clip(s)}else{const s=void 0!==e.position?e.position:{x:0,y:0},i=e.borderRadius||0,n=e.width||this.config.width,l=e.height||this.config.height;if(t.beginPath(),0!==i){const e=Math.PI/2;t.moveTo(s.x+i,s.y),t.arc(s.x+i,s.y+i,i,e,2*e,!0),t.lineTo(s.x,s.y+l-i),t.arc(s.x+i,s.y+l-i,i,0,e,!0),t.lineTo(s.x+n-i,s.y+l),t.arc(s.x+n-i,s.y+l-i,i,3*e,4*e,!0),t.lineTo(s.x+n,s.y+i),t.arc(s.x+n-i,s.y+i,i,2*e,3*e,!0),t.closePath(),t.clip()}else t.rect(s.x,s.y,n,l),t.clip()}}setPosition(e,t,s){void 0!==this.mesh&&this.mesh.position.set(e,t,s)}setRotation(e,t,s){void 0!==this.mesh&&this.mesh.rotation.set(e,t,s)}updateElement(e,t){let s=this.content[e];void 0!==s?("object"==typeof s?s.content=t:s=t,this.content[e]=s,this.needsUpdate=!0):console.warn(`CanvasGUI.updateElement: No ${e} found`)}get panel(){return this.mesh}getElementAtLocation(e,t){const s=this,i=Object.entries(this.config).filter((([i,n])=>{if(!("object"!=typeof n||"panelSize"===i||"body"===i||n instanceof THREE.WebGLRenderer||n instanceof THREE.Scene)){const i=n.position,l=void 0!==n.width?n.width:s.config.width,r=void 0!==n.height?n.height:s.config.height;return e>=i.x&&e=i.y&&t0?(this.hover(t,s[0].uv),this.intersects[t]=s[0],this.scroll(t)):(this.hover(t),this.intersects[t]=void 0,this.scroll(t))}update(){if(void 0===this.mesh)return;if(this.controller&&this.handleController(this.controller,0),this.controller1&&this.handleController(this.controller1,1),this.keyboard&&this.keyboard.visible&&this.keyboard.update(),!this.needsUpdate)return;let e=this.context;e.clearRect(0,0,this.config.width,this.config.height);const t=this.config.body.backgroundColor?this.config.body.backgroundColor:"#000";!this.config.body.fontFamily||this.config.body.fontFamily;const s=this.config.body.fontColor?this.config.body.fontColor:"#fff";!this.config.body.fontSize||this.config.body.fontSize,this.setClip(this.config.body),e.fillStyle=t,e.fillRect(0,0,this.config.width,this.config.height);const i=this;Object.entries(this.content).forEach((([t,n])=>{const l=void 0!==i.config[t]?i.config[t]:i.config.body;if("none"!==(void 0!==l.display?l.display:"block")){const r=void 0!==l.position?l.position:{x:0,y:0},o=void 0!==l.width?l.width:i.config.width,a=void 0!==l.height?l.height:i.config.height;"button"!=l.type||n.toLowerCase().startsWith("")||(void 0===l.borderRadius&&(l.borderRadius=6),void 0===l.textAlign&&(l.textAlign="center")),i.setClip(l);const d=n.toLowerCase().startsWith(""),c=void 0!==i.selectedElements[0]&&this.selectedElements[0]===l||void 0!==i.selectedElements[1]&&this.selectedElements[1]===l;if(void 0!==l.backgroundColor&&(c&&"button"==l.type&&void 0!==l.hover?e.fillStyle=l.hover:e.fillStyle=l.backgroundColor,e.fillRect(r.x,r.y,o,a)),"text"==l.type||"button"==l.type||"input-text"==l.type){let h=!1;if(c?(d||"button"!=l.type?e.fillStyle=void 0!==l.hover?l.hover:void 0!==l.fontColor?l.fontColor:s:e.fillStyle=void 0!==l.fontColor?l.fontColor:s,h=void 0===l.hover):e.fillStyle=void 0!==l.fontColor?l.fontColor:s,d){const t=n.toUpperCase().substring(6,n.length-7);e.save(),e.translate(r.x,r.y);const s=new Path2D(t);e.fill(s),e.restore()}else i.wrapText(t,n);h&&(e.beginPath(),e.strokeStyle="#fff",e.lineWidth=2,e.rect(r.x,r.y,o,a),e.stroke())}else if("img"==l.type)if(void 0===l.img)this.loadImage(n).then((e=>{console.log(`w: ${e.width} | h: ${e.height}`),l.img=e,i.needsUpdate=!0,i.update()})).catch((e=>console.error(e)));else{const t=o/(l.img.width/l.img.height);e.drawImage(l.img,r.x,r.y,o,t)}}})),this.needsUpdate=!1,this.texture.needsUpdate=!0}loadImage(e){return new Promise(((t,s)=>{const i=new THREE.Image;i.addEventListener("load",(()=>t(i))),i.addEventListener("error",(e=>s(e))),i.src=e}))}createOffscreenCanvas(e,t){const s=document.createElement("canvas");return s.width=e,s.height=t,s}fillRoundedRect(e,t,s,i,n){const l=this.context;l.beginPath(),l.moveTo(e+n,t),l.lineTo(e+s-n,t),l.quadraticCurveTo(e+s,t,e+s,t+n),l.lineTo(e+s,t+i-n),l.quadraticCurveTo(e+s,t+i,e+s-n,t+i),l.lineTo(e+n,t+i),l.quadraticCurveTo(e,t+i,e,t+i-n),l.lineTo(e,t+n),l.quadraticCurveTo(e,t,e+n,t),l.closePath(),l.fill()}lookAt(e){void 0!==this.mesh&&(e instanceof Vector3?this.mesh.lookAt(e):console.error("CanvasUI lookAt called parameter not a THREE.Vector3"))}get visible(){return void 0!==this.mesh&&this.mesh.visible}set visible(e){this.mesh&&(this.mesh.visible=e)}get position(){if(void 0!==this.mesh)return this.mesh.position}set position(e){void 0!==this.mesh&&(e instanceof Vector3?this.mesh.position.copy(e):console.error("CanvasUI trying to set the mesh position using a parameter that is not a THREE.Vector3"))}get quaternion(){if(void 0!==this.mesh)return this.mesh.quaternion}set quaternion(e){void 0!==this.mesh&&(e instanceof QUaternion?this.mesh.quaternion.copy(e):console.error("CanvasUI trying to set the mesh quaternion using a parameter that is not a THREE.Quaternion"))}wrapText(e,t){const s=t.split(" ");let i="";const n=[],l=void 0!==this.config[e]?this.config[e]:this.config.body,r=void 0!==l.width?l.width:this.config.width,o=void 0!==l.height?l.height:this.config.height,a=void 0!==l.position?l.position:{x:0,y:0},d=void 0!==l.padding?l.padding:void 0!==this.config.body.padding?this.config.body.padding:10,c=void 0!==l.paddingTop?l.paddingTop:d,h=void 0!==l.paddingLeft?l.paddingLeft:d,p=void 0!==l.paddingBottom?l.paddingBottom:d,m=void 0!==l.paddingRight?l.paddingRight:d,u={x:a.x+h,y:a.y+c,width:r-h-m,height:o-c-p},g=void 0!==l.textAlign?l.textAlign:void 0!==this.config.body.textAlign?this.config.body.textAlign:"left",f=void 0!==l.fontSize?l.fontSize:void 0!==this.config.body.fontSize?this.config.body.fontSize:30,b=void 0!==l.fontFamily?l.fontFamily:void 0!==this.config.body.fontFamily?this.config.body.fontFamily:"Arial",C=f+(void 0!==l.leading?l.leading:void 0!==this.config.body.leading?this.config.body.leading:8),y=this.context;y.textAlign=g,y.font=`${f}px '${b}'`,s.forEach((function(e){let t=s.length>1?`${i}${e} `:e,l=y.measureText(t);if(l.width>u.width&&e.length>1)if(0==i.length&&l.width>u.width){for(;l.width>u.width;){let s=0;do{s++,t=e.substr(0,s),l=y.measureText(t)}while(l.widthu.height&&"scroll"===l.overflow){void 0===l.scrollY&&(l.scrollY=0);const e=void 0!==l.fontColor?l.fontColor:this.config.body.fontColor;y.fillStyle="#aaa",this.fillRoundedRect(a.x+r-12,a.y,12,o,6),y.fillStyle="#666";const t=u.height/v,s=t*o,i=-l.scrollY*t;this.fillRoundedRect(a.x+r-12,a.y+i,12,s,6),y.fillStyle=e,w=l.scrollY,l.minScrollY=u.height-v}let _,S=w+u.y+f/2;switch(g){case"center":_=u.x+u.width/2;break;case"right":_=u.x+u.width;break;default:_=u.x}n.forEach((e=>{S+C>0&&y.fillText(e,_,S),S+=C}))}}class Re{constructor(e,t,s="EN"){const i=this.getConfig(s);i.panelSize={width:e,height:.5*e},i.height=256,i.body={backgroundColor:"#555"},i.renderer=t;const n=this.getContent(s);this.keyboard=new Oe(n,i),this.keyboard.mesh.visible=!1,this.shift=!1}get mesh(){return this.keyboard.mesh}getConfig(e){const t={};let s=10;const i=39.2,n=49,l="#333",r="#000";let o=s,a=s;for(let e=0;e<10;e++){const d={type:"button",position:{x:a,y:o},width:i,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e)};t[`btn${e}`]=d,a+=49.2}o+=59,a=s;for(let e=0;e<10;e++){const d={type:"button",position:{x:a,y:o},width:i,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+10)};t[`btn${e+10}`]=d,a+=49.2}o+=59,a=s;for(let e=0;e<9;e++){const d=0==e||8==e?1.5*i+5:i,c={type:"button",position:{x:a,y:o},width:d,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+20)};t[`btn${e+20}`]=c,a+=d+s}o+=59,a=s;for(let e=0;e<5;e++){const d=0==e||4==e?88.4:2==e?186.8:i,c={type:"button",position:{x:a,y:o},width:d,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+30)};0==e&&(c.fontSize=20),t[`btn${e+30}`]=c,a+=d+s}return t}getContent(e,t=0){let s,i={};switch(this.language=e,this.keyboardIndex=t,t){case 0:s=["q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","@","⇧","z","x","c","v","b","n","m","⇦","","?123",","," ",".","↲"];for(let e=0;e","_","`","~",":",";","⇦","","abc",","," ",".","↲"];for(let e=0;e=0;e--){let s=t.scene.children[e];t.scene.remove(s)}else t.scene=new THREE.Scene;if(void 0!==t.scene_ghost)for(let e=t.scene_ghost.children.length-1;e>=0;e--){let s=t.scene_ghost.children[e];t.scene_ghost.remove(s)}else t.scene_ghost=new THREE.Scene;if(""!=s.htmlCls.setHtmlCls.getCookie("shininess")){let e=parseFloat(s.htmlCls.setHtmlCls.getCookie("shininess"));t.shininess!=e&&s.htmlCls.clickMenuCls.setLogCmd("set shininess "+e,!0),t.shininess=e}if(!s.bNode&&""!=s.htmlCls.setHtmlCls.getCookie("light1")){let e=parseFloat(s.htmlCls.setHtmlCls.getCookie("light1")),i=parseFloat(s.htmlCls.setHtmlCls.getCookie("light2")),n=parseFloat(s.htmlCls.setHtmlCls.getCookie("light3"));t.light1==e&&t.light2==i&&t.light3==n||s.htmlCls.clickMenuCls.setLogCmd("set light | light1 "+e+" | light2 "+i+" | light3 "+n,!0),t.light1=e,t.light2=i,t.light3=n}t.directionalLight=new THREE.DirectionalLight(16777215,t.light1),t.directionalLight2=new THREE.DirectionalLight(16777215,t.light2),t.directionalLight3=new THREE.DirectionalLight(16777215,t.light3),t.cam_z>0?(t.directionalLight.position.set(-1,1,1),t.directionalLight2.position.set(1,1,1),t.directionalLight3.position.set(1,1,-1),t.lightPos=new THREE.Vector3(-1,1,1),t.lightPos2=new THREE.Vector3(1,1,1),t.lightPos3=new THREE.Vector3(1,1,-1)):(t.directionalLight.position.set(-1,1,-1),t.directionalLight2.position.set(1,1,-1),t.directionalLight3.position.set(1,1,1),t.lightPos=new THREE.Vector3(-1,1,-1),t.lightPos2=new THREE.Vector3(1,1,-1),t.lightPos3=new THREE.Vector3(1,1,1));let i=new THREE.AmbientLight(8947848);if(t.scene.add(t.directionalLight),t.scene.add(i),void 0!==t.mdl)for(let e=t.mdl.children.length-1;e>=0;e--){let s=t.mdl.children[e];s.geometry&&s.geometry.dispose(),s.material&&s.material.dispose(),t.mdl.remove(s)}if(void 0!==t.mdlImpostor){for(let e=t.mdlImpostor.children.length-1;e>=0;e--){let s=t.mdlImpostor.children[e];s.geometry&&s.geometry.dispose(),s.material&&s.material.dispose(),t.mdlImpostor.remove(s)}t.mdlImpostor.children.length=0}s.bNode||t.renderer.renderLists.dispose(),t.mdl=new THREE.Object3D,t.mdlImpostor=new THREE.Object3D,t.scene.add(t.mdl),t.scene.add(t.mdlImpostor),t.mdl_ghost=new THREE.Object3D,t.scene_ghost.add(t.mdl_ghost),t.objects=[],t.objects_ghost=[],t.raycaster=new THREE.Raycaster,t.projector=new THREE.Projector,t.mouse=new THREE.Vector2;let n=s.parasCls.backgroundColors[t.opts.background.toLowerCase()];s.bNode||("transparent"===t.opts.background.toLowerCase()?t.renderer.setClearColor(n,0):t.renderer.setClearColor(n,1)),t.perspectiveCamera=new THREE.PerspectiveCamera(20,t.container.whratio,.1,1e4),t.perspectiveCamera.position.set(0,0,t.cam_z),t.perspectiveCamera.lookAt(new THREE.Vector3(0,0,0)),t.orthographicCamera=new THREE.OrthographicCamera,t.orthographicCamera.position.set(0,0,t.cam_z),t.orthographicCamera.lookAt(new THREE.Vector3(0,0,0)),t.cams={perspective:t.perspectiveCamera,orthographic:t.orthographicCamera}}setVrAr(){let e=this.icn3d;e.icn3dui;let t=this;e.bSetVrAr=!0,e.bVr?(e.canvasUI=this.createUI(),e.raycasterVR=new THREE.Raycaster,e.workingMatrix=new THREE.Matrix4,e.workingVector=new THREE.Vector3,e.origin=new THREE.Vector3,e.dolly=new THREE.Object3D,e.dolly.position.z=5,e.dolly.add(e.cam),e.scene.add(e.dolly),e.dollyId=e.dolly.id,e.dummyCam=new THREE.Object3D,e.cam.add(e.dummyCam),e.clock=new THREE.Clock,e.controllers=this.getControllers(),e.controllers.forEach((s=>{s.addEventListener("connected",(function(e){try{const s={},i="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",n="generic-trigger";Ce(e.data,i,n).then((({profile:i,assetPath:n})=>{s.name=i.profileId,s.targetRayMode=e.data.targetRayMode,Object.entries(i.layouts).forEach((([e,t])=>{const i={};Object.values(t.components).forEach((e=>{i[e.rootNodeName]=e.gamepadIndices})),s[e]=i})),t.updateControllers(s)}))}catch(e){}})),s.addEventListener("disconnected",(function(){this.remove(this.children[0]),e.controllers.forEach((e=>{}))}))}))):e.bAr&&(e.gestures=new ke(e.renderer),e.scene.add(e.gestures.controller1),e.scene.add(e.gestures.controller2),e.gestures.addEventListener("doubletap",(e=>{t.positionCenter()})),e.gestures.addEventListener("pinch",(s=>{if(void 0!==s.initialise)t.startPosition=e.mdl.position.clone(),t.startScale=e.mdl.scale.clone();else{let i=1;const n=t.startScale.clone().multiplyScalar(s.scale*i);e.mdl.scale.copy(n)}})))}positionCenter(){let e=this.icn3d;e.icn3dui;const t=e.gestures.controller1;e.mdl.position.set(-.06,0,-.6).applyMatrix4(t.matrixWorld),e.mdl.scale.copy(new THREE.Vector3(.005,.005,.005))}setVrArButtons(){let e=this.icn3d,t=e.icn3dui;e.bSetVrArButtons=!0,t.bNode||($("#"+t.pre+"VRButton").remove(),$("#"+t.pre+"viewer").get(0).appendChild(e.VRButtonCls.createButton(e.renderer)),$("#"+t.pre+"ARButton").remove(),$("#"+t.pre+"viewer").get(0).appendChild(e.ARButtonCls.createButton(e.renderer)))}updateControllers(e){this.icn3d.icn3dui,this.addEventForController(e,"right"),this.addEventForController(e,"left")}addEventForController(e,t){let s=this.icn3d;s.icn3dui;const i="right"==t?s.renderer.xr.getController(0):s.renderer.xr.getController(1),n="right"==t?e.right:e.left;if(void 0!==n){let e=!1,t=!1;Object.keys(n).forEach((i=>{-1!=i.indexOf("trigger")&&(e=!0),-1!=i.indexOf("squeeze")&&(t=!0),-1==i.indexOf("thumbstick")&&-1==i.indexOf("touchpad")||(s.xAxisIndex=n[i].xAxis,s.yAxisIndex=n[i].yAxis)})),e&&(i.addEventListener("selectstart",(function(){this.userData.selectPressed=!0})),i.addEventListener("selectend",(function(){this.userData.selectPressed=!1,this.userData.selected=void 0}))),t&&(i.addEventListener("squeezestart",(function(){this.userData.squeezePressed=!0,s.cam.add(s.canvasUI.mesh)})),i.addEventListener("squeezeend",(function(){this.userData.squeezePressed=!1,s.cam.remove(s.canvasUI.mesh)})))}}createUI(){let e=this.icn3d;e.icn3dui;let t=94,s=50,i=44,n=12,l="#1c94c4",r="#ccc",o="#fbcb09";const a={panelSize:{width:2,height:1.2},height:300,select:{type:"button",position:{top:6,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},residue:{type:"button",position:{top:6,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.pk=2,e.cam.remove(e.canvasUI.mesh)}},secondarySelect:{type:"button",position:{top:6,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.pk=3,e.cam.remove(e.canvasUI.mesh)}},chainSelect:{type:"button",position:{top:6,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.pk=5,e.cam.remove(e.canvasUI.mesh)}},style:{type:"button",position:{top:62,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},ribbon:{type:"button",position:{top:62,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","ribbon"),e.setOptionCls.setStyle("nucleotides","nucleotide cartoon"),e.cam.remove(e.canvasUI.mesh)}},schematic:{type:"button",position:{top:62,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","schematic"),e.setOptionCls.setStyle("nucleotides","schematic"),e.cam.remove(e.canvasUI.mesh)}},stick:{type:"button",position:{top:62,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","stick"),e.setOptionCls.setStyle("nucleotides","stick"),e.cam.remove(e.canvasUI.mesh)}},sphere:{type:"button",position:{top:62,left:406},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","sphere"),e.setOptionCls.setStyle("nucleotides","sphere"),e.cam.remove(e.canvasUI.mesh)}},color:{type:"button",position:{top:118,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},rainbow:{type:"button",position:{top:118,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","rainbow for chains"),e.cam.remove(e.canvasUI.mesh)}},atomColor:{type:"button",position:{top:118,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","atom"),e.cam.remove(e.canvasUI.mesh)}},secondaryColor:{type:"button",position:{top:118,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","secondary structure green"),e.cam.remove(e.canvasUI.mesh)}},AlphaFold:{type:"button",position:{top:118,left:406},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","confidence"),e.cam.remove(e.canvasUI.mesh)}},unicolor:{type:"button",position:{top:174,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},red:{type:"button",position:{top:168,left:100},width:i,height:s,fontColor:"red",hover:o,onSelect:function(){e.setOptionCls.setOption("color","red"),e.cam.remove(e.canvasUI.mesh)}},green:{type:"button",position:{top:168,left:150},width:i,height:s,fontColor:"green",hover:o,onSelect:function(){e.setOptionCls.setOption("color","green"),e.cam.remove(e.canvasUI.mesh)}},blue:{type:"button",position:{top:168,left:200},width:i,height:s,fontColor:"blue",hover:o,onSelect:function(){e.setOptionCls.setOption("color","blue"),e.cam.remove(e.canvasUI.mesh)}},magenta:{type:"button",position:{top:168,left:250},width:i,height:s,fontColor:"magenta",hover:o,onSelect:function(){e.setOptionCls.setOption("color","magenta"),e.cam.remove(e.canvasUI.mesh)}},orange:{type:"button",position:{top:168,left:300},width:i,height:s,fontColor:"orange",hover:o,onSelect:function(){e.setOptionCls.setOption("color","FFA500"),e.cam.remove(e.canvasUI.mesh)}},cyan:{type:"button",position:{top:168,left:350},width:i,height:s,fontColor:"cyan",hover:o,onSelect:function(){e.setOptionCls.setOption("color","cyan"),e.cam.remove(e.canvasUI.mesh)}},gray:{type:"button",position:{top:168,left:400},width:i,height:s,fontColor:"gray",hover:o,onSelect:function(){e.setOptionCls.setOption("color","888888"),e.cam.remove(e.canvasUI.mesh)}},white:{type:"button",position:{top:168,left:450},width:i,height:s,fontColor:"white",hover:o,onSelect:function(){e.setOptionCls.setOption("color","white"),e.cam.remove(e.canvasUI.mesh)}},analysis:{type:"button",position:{top:230,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},interaction:{type:"button",position:{top:230,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){try{e.viewInterPairsCls.viewInteractionPairs(["selected"],["non-selected"],!1,"3d",1,1,1,1,1,1),e.cam.remove(e.canvasUI.mesh)}catch(e){}}},removeLabel:{type:"button",position:{top:230,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){for(let t in e.labels)e.labels[t]=[];e.drawCls.draw(),e.cam.remove(e.canvasUI.mesh)}},reset:{type:"button",position:{top:230,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.selectionCls.resetAll(),e.cam.remove(e.canvasUI.mesh)}},renderer:e.renderer},d=new Oe({select:"Select",residue:"Residue",secondarySelect:"SSE",chainSelect:"Chain",style:"Style",ribbon:"Ribbon",schematic:"Schem.",stick:"Stick",sphere:"Sphere",color:"Color",rainbow:"Rainbow",atomColor:"Atom",secondaryColor:"SSE",AlphaFold:"AlphaFold",unicolor:"UniColor",red:"M 50 15 L 15 15 L 15 50 L 50 50 Z",green:"M 50 15 L 15 15 L 15 50 L 50 50 Z",blue:"M 50 15 L 15 15 L 15 50 L 50 50 Z",magenta:"M 50 15 L 15 15 L 15 50 L 50 50 Z",orange:"M 50 15 L 15 15 L 15 50 L 50 50 Z",cyan:"M 50 15 L 15 15 L 15 50 L 50 50 Z",gray:"M 50 15 L 15 15 L 15 50 L 50 50 Z",white:"M 50 15 L 15 15 L 15 50 L 50 50 Z",analysis:"Analysis",interaction:"Interact",removeLabel:"No Label",reset:"Reset"},a);return d.mesh.position.set(0,0,-3),d}createUILog(){let e=this.icn3d;e.icn3dui;const t={panelSize:{width:2,height:2},height:512,info:{type:"text",overflow:"scroll",position:{top:6,left:6},width:506,height:506,backgroundColor:"#aaa",fontColor:"#000"},renderer:e.renderer},s=new Oe({info:"Debug info"},t);return s.mesh.position.set(0,-1,-2),s}getControllers(){let e=this.icn3d;e.icn3dui;const t=new xe,s=(new THREE.BufferGeometry).setFromPoints([new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,-1)]),i=new THREE.Line(s);i.name="line",i.scale.z=50;const n=[];for(let s=0;s<=1;s++){const l=e.renderer.xr.getController(s);e.dolly.add(l),l.add(i.clone()),l.userData.selectPressed=!1,e.cam.add(l),n.push(l);const r=e.renderer.xr.getControllerGrip(s);r.add(t.createControllerModel(r)),e.scene.add(r)}return n}}class Ie{constructor(e){this.icn3d=e}setCamera(){let e=this.icn3d,t=e.icn3dui;if(e.bControlGl&&!t.bNode){window.cam=e.cams[e.opts.camera.toLowerCase()];let s=e.maxD;if(window.cam===e.perspectiveCamera){let i=void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>e.maxatomcnt;i?window.camMaxDFactor=1:void 0!==window.camMaxDFactorFog?window.camMaxDFactor=window.camMaxDFactorFog:window.camMaxDFactor=3,window.cam_z>0?window.cam.position.z=s*window.camMaxDFactor:window.cam.position.z=-s*window.camMaxDFactor,"yes"===e.opts.slab?i?window.cam.near=.1:void 0!==window.camMaxDFactorFog?window.cam.near=s*window.camMaxDFactorFog-10:window.cam.near=s*window.camMaxDFactor:window.cam.near=.1,window.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.TrackballControls(window.cam,void 0,e):t.bNode?e.controls=new THREE.TrackballControls(e.cam,document,e):e.controls=new THREE.TrackballControls(e.cam,document.getElementById(e.id),e)}else window.cam===e.orthographicCamera&&(void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>10*e.maxatomcnt?window.cam.right=e.maxD/2*1.5:window.cam.right=e.maxD/2*2.5,window.cam.left=-window.cam.right,window.cam.top=window.cam.right/e.container.whratio,window.cam.bottom=-window.cam.right/e.container.whratio,"yes"===e.opts.slab?window.cam.near=2*e.maxD:window.cam.near=0,window.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.OrthographicTrackballControls(window.cam,void 0,e):t.bNode?e.controls=new THREE.OrthographicTrackballControls(e.cam,document,e):e.controls=new THREE.OrthographicTrackballControls(e.cam,document.getElementById(e.id),e));window.cam.updateProjectionMatrix()}e.cam=e.cams[e.opts.camera.toLowerCase()];let s=e.maxD;if(e.cam===e.perspectiveCamera){let i=void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>e.maxatomcnt;i?e.camMaxDFactor=1:void 0!==e.camMaxDFactorFog?e.camMaxDFactor=e.camMaxDFactorFog:e.camMaxDFactor=3,e.cam_z>0?e.cam.position.z=s*e.camMaxDFactor:e.cam.position.z=-s*e.camMaxDFactor,"yes"===e.opts.slab?i?e.cam.near=.1:void 0!==e.camMaxDFactorFog?e.cam.near=s*e.camMaxDFactorFog-10:e.cam.near=s*e.camMaxDFactor:e.cam.near=.1,e.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.TrackballControls(e.cam,void 0,e):t.bNode?e.controls=new THREE.TrackballControls(e.cam,document,e):e.controls=new THREE.TrackballControls(e.cam,document.getElementById(e.id),e)}else e.cam===e.orthographicCamera&&(void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>10*e.maxatomcnt?e.cam.right=e.maxD/2*1.5:e.cam.right=e.maxD/2*2.5,e.cam.left=-e.cam.right,e.cam.top=e.cam.right/e.container.whratio,e.cam.bottom=-e.cam.right/e.container.whratio,"yes"===e.opts.slab?e.cam.near=2*e.maxD:e.cam.near=0,e.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.OrthographicTrackballControls(e.cam,void 0,e):t.bNode?e.controls=new THREE.OrthographicTrackballControls(e.cam,document,e):e.controls=new THREE.OrthographicTrackballControls(e.cam,document.getElementById(e.id),e));e.cam.updateProjectionMatrix()}}class Te{constructor(e){this.icn3d=e}setFog(e){let t=this.icn3d,s=t.icn3dui.parasCls.backgroundColors[t.opts.background.toLowerCase()];if(e){let e=t.applyCenterCls.centerAtoms(t.hAtoms);t.maxD=e.maxD,t.maxD<25&&(t.maxD=25)}let i=void 0!==t.biomtMatrices&&t.biomtMatrices.length*t.cnt>t.maxatomcnt;if("yes"===t.opts.fog)if("perspective"===t.opts.camera)if(i)t.scene.fog=void 0,t.bSetFog=!1;else{let e=t._zoomFactor>1?1*t._zoomFactor:t._zoomFactor;t.scene.fog=new THREE.Fog(s,2.5*t.maxD*e,4*t.maxD*e),t.bSetFog=!0,t.camMaxDFactorFog=3}else"orthographic"===t.opts.camera&&(t.scene.fog=void 0,t.bSetFog=!1);else t.scene.fog=void 0,t.bSetFog=!1}}class Me{constructor(e){this.icn3d=e}createBox(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(o.bNode)return;void 0===t&&(t=.8),void 0===s&&(s=!1),void 0===i&&(i=.8),l?void 0===n&&(n=r.hColor):void 0===n&&(n=e.color);let a=s?t:(o.parasCls.vdwRadii[e.elem.toUpperCase()]||t)*(i||1);this.createBox_base(e.coord,a,n,l)}createBox_base(e,t,s,i,n,l,r){let o,a=this.icn3d;a.icn3dui.bNode||(void 0===r&&(r=l?.5:1),new THREE.BoxGeometry(1,1,1),o=new THREE.Mesh(a.boxGeometry,new THREE.MeshPhongMaterial({transparent:!0,opacity:r,specular:a.frac,shininess:a.shininess,emissive:a.emissive,color:s})),o.scale.x=o.scale.y=o.scale.z=t,o.position.copy(e),a.mdl.add(o),i?a.prevHighlightObjects.push(o):n?a.prevOtherMesh.push(o):a.objects.push(o))}createBoxRepresentation_P_CA(e,t,s){let i=this.icn3d;if(i.icn3dui.bNode)return;let n=this;i.reprSubCls.createRepresentationSub(e,(function(e){"CA"!==e.name&&"O3'"!==e.name&&"O3*"!==e.name||n.createBox(e,void 0,void 0,t,void 0,s)}))}}class Pe{constructor(e){this.icn3d=e}createBrick(e,t,s,i){let n=this.icn3d;if(n.icn3dui.bNode)return;let l=new THREE.CylinderGeometry(1,1,1,4,1),r=new THREE.Mesh(l,new THREE.MeshPhongMaterial({specular:n.frac,shininess:n.shininess,emissive:n.emissive,color:i}));r.position.copy(e).add(t).multiplyScalar(.5),r.matrixAutoUpdate=!1,r.lookAt(t.clone().sub(e)),r.updateMatrix(),r.matrix.multiply((new THREE.Matrix4).makeScale(s,s,e.distanceTo(t))).multiply((new THREE.Matrix4).makeRotationX(.5*Math.PI)),n.mdl.add(r)}}class De{constructor(e){this.icn3d=e}createCurveSubArrow(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u){if(this.icn3d.icn3dui.bNode)return;let g=[],f=[];g.push(e),f.push(o),this.prepareStrand(g,f,t,s,i,void 0,n,l,r,a,d,!1,c,h,p,m,u),g=[],f=[]}createStripArrow(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g){if(this.icn3d.icn3dui.bNode)return;let f=[],b=[];f.push(e),f.push(t),b.push(o),b.push(a),this.prepareStrand(f,b,void 0,s,i,n,l,void 0,r,d,c,!0,h,p,m,u,g),f=[],b=[]}prepareStrand(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g,f){let b=this.icn3d,C=b.icn3dui;if(1===d.length)return;let y=i,v=!u,w=[];w.push(i[i.length-2]),w.push(i[i.length-1]),n=n||b.axisDIV;let _,S,A,x,k=2/(a-1),O={};for(let e=0,s=t.length;e1)if(void 0!==d){let i,n,l=[];for(let r=0,o=p.length;r0&&i.tubeCls.createTube(a,"CA",i.coilWidth,s),Object.keys(d).length>0&&i.strandCls.createStrand(d,void 0,void 0,!0,0,i.helixSheetWidth,!1,2*i.ribbonthickness,s)):(Object.keys(a).length>0&&i.tubeCls.createTube(a,"CA",i.coilWidth),Object.keys(d).length>0&&i.strandCls.createStrand(d,void 0,void 0,!0,0,i.helixSheetWidth,!1,2*i.ribbonthickness))}createCylinderCurve(e,t,s,i,n){let l=this.icn3d;if(l.icn3dui.bNode)return;let r,o,a,d,c,h,p=null;for(a in e)if(d=e[a],!d.het&&(c=d.structure+"_"+d.chain,h=d.structure+"_"+r,-1!=t.indexOf(d.name))){if(null!==p&&r===d.chain&&l.ParserUtilsCls.getResiNCBI(h,o)+1===l.ParserUtilsCls.getResiNCBI(c,d.resi)&&Math.abs(p.coord.x-d.coord.x)<8&&Math.abs(p.coord.y-d.coord.y)<8&&Math.abs(p.coord.z-d.coord.z)<8){let e=p.coord.clone().add(d.coord).multiplyScalar(.5);if(n)1===n&&(this.createCylinder(p.coord,e,s,p.color,n),this.createCylinder(e,d.coord,s,d.color,n),l.sphereCls.createSphere(d,s,!0,1,n));else if(i){let t=l.lineCls.createSingleLine(p.coord,e,p.color,!1);l.mdl.add(t),l.objects.push(t),t=l.lineCls.createSingleLine(e,d.coord,d.color,!1),l.mdl.add(t),l.objects.push(t)}else this.createCylinder(p.coord,e,s,p.color),this.createCylinder(e,d.coord,s,d.color),l.sphereCls.createSphere(d,s,!0,1,n)}p=d,r=d.chain,o=d.resi,l.sphereCls.createSphere(d,s,!0,1,n),2===n&&l.boxCls.createBox(d,void 0,void 0,void 0,void 0,n)}if(null!==p&&r===d.chain&&l.ParserUtilsCls.getResiNCBI(h,o)+1===l.ParserUtilsCls.getResiNCBI(c,d.resi)&&Math.abs(p.coord.x-d.coord.x)<8&&Math.abs(p.coord.y-d.coord.y)<8&&Math.abs(p.coord.z-d.coord.z)<8){let e=p.coord.add(d.coord).multiplyScalar(.5);if(n)1===n&&(this.createCylinder(p.coord,e,s,p.color,n),this.createCylinder(e,d.coord,s,d.color,n),l.sphereCls.createSphere(d,s,!0,1,n));else if(i){let t=l.lineCls.createSingleLine(p.coord,e,p.color,!1);l.mdl.add(t),l.objects.push(t),t=l.lineCls.createSingleLine(e,d.coord,d.color,!1),l.mdl.add(t),l.objects.push(t)}else this.createCylinder(p.coord,e,s,p.color),this.createCylinder(e,d.coord,s,d.color)}}}class Le{constructor(e){this.icn3d=e}createLineRepresentation(e,t){let s=this.icn3d;if(s.icn3dui.bNode)return;let i=new THREE.BufferGeometry,n=[],l=[],r=0,o=0;s.reprSubCls.createRepresentationSub(e,void 0,(function(e,t){if(e.color===t.color)n[r++]=e.coord.x,n[r++]=e.coord.y,n[r++]=e.coord.z,n[r++]=t.coord.x,n[r++]=t.coord.y,n[r++]=t.coord.z,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b;else{let s=e.coord.clone().add(t.coord).multiplyScalar(.5);n[r++]=e.coord.x,n[r++]=e.coord.y,n[r++]=e.coord.z,n[r++]=s.x,n[r++]=s.y,n[r++]=s.z,n[r++]=t.coord.x,n[r++]=t.coord.y,n[r++]=t.coord.z,n[r++]=s.x,n[r++]=s.y,n[r++]=s.z,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b}}));if(i.setAttribute("position",new THREE.BufferAttribute(new Float32Array(n),3)),i.setAttribute("color",new THREE.BufferAttribute(new Float32Array(l),3)),2!==t){let e;1===t||(e=new THREE.LineSegments(i,new THREE.LineBasicMaterial({linewidth:s.linewidth,vertexColors:!0})),s.mdl.add(e)),1===t?s.prevHighlightObjects.push(e):s.objects.push(e)}else 2===t&&s.boxCls.createBoxRepresentation_P_CA(e,.8,t)}createConnCalphSidechain(e,t){let s=this.icn3d;if(s.icn3dui.bNode)return;let i={};for(let s in e){let n=e[s];if(!n.het&&n.style2===t){i[n.structure+"_"+n.chain+"_"+n.resi]=1}}let n=[],l=[];for(let e in i){let t=s.firstAtomObjCls.getFirstAtomObjByName(s.residues[e],"CA");if(void 0!==t)for(let e=0,i=t.bonds.length;e=t.bonds.length&&e.bonds.length>1)s=e.serial,l=e.bonds[0],d=e.bonds[1];else{if(!(t.bonds.length>=e.bonds.length&&t.bonds.length>1))return void console.log("Double bond was not drawn due to the undefined cross plane");s=t.serial,l=t.bonds[0],d=t.bonds[1]}let i=r.atoms[s].coord.clone();i.sub(r.atoms[l].coord);let n=r.atoms[s].coord.clone();n.sub(r.atoms[d].coord),i.cross(n),0==parseInt(1e4*i.length())&&(i=new THREE.Vector3(.2,.3,.5)),c=t.coord.clone(),c.sub(e.coord),c.cross(i).normalize().multiplyScalar(.2*o),0==parseInt(1e4*c.length())&&(i=new THREE.Vector3(.5,.3,.2),c.cross(i).normalize().multiplyScalar(.2*o))}e.color===t.color?r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),t.coord.clone().add(c),a,e.color,n),r.cylinderCls.createCylinder(e.coord.clone().sub(c),t.coord.clone().sub(c),a,e.color,n)):r.bImpo?r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),t.coord.clone().add(c),a,e.color,n,t.color),r.cylinderCls.createCylinder(e.coord.clone().sub(c),t.coord.clone().sub(c),a,e.color,n,t.color)):r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),i.clone().add(c),a,e.color,n),r.cylinderCls.createCylinder(t.coord.clone().add(c),i.clone().add(c),a,t.color,n),r.cylinderCls.createCylinder(e.coord.clone().sub(c),i.clone().sub(c),a,e.color,n),r.cylinderCls.createCylinder(t.coord.clone().sub(c),i.clone().sub(c),a,t.color,n))}else if(r.aromaticbonds.hasOwnProperty(l)){let s,l,d;if(e.bonds.length>t.bonds.length&&e.bonds.length>1)s=e.serial,l=e.bonds[0],d=e.bonds[1];else{if(!(t.bonds.length>1))return;s=t.serial,l=t.bonds[0],d=t.bonds[1]}let c=r.atoms[s].coord.clone();c.sub(r.atoms[l].coord);let h=r.atoms[s].coord.clone();h.sub(r.atoms[d].coord),c.cross(h);let p=t.coord.clone();p.sub(e.coord),p.cross(c).normalize().multiplyScalar(.2*o);let m=0;for(let s=0,i=e.bondOrder.length;so+1?(s=k.clone(),i=d.atoms[G[G.length-1-o-1]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random()))):d.bCalphaOnly&&"CA"===b.name&&(G.length>o+1?(s=k.clone(),i=d.atoms[G[G.length-1-o-1]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random())),s.normalize(),s.multiplyScalar(f),null!==E&&s.dot(E)<0&&s.negate(),E=s;for(let e=0,s=2/(t-1);e6||c&&Math.abs(S.y-c.y)>6||c&&Math.abs(S.z-c.z)>6;if((u!==b.chain||b.ssbegin||b.ssend||B===j-1||p)&&m[0].length>0){let c="CA",u=[],g=[];if(isNaN(d.atoms[P].resi))u=[];else{let e=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)-1).toString(),t=d.firstAtomObjCls.getAtomCoordFromResi(e,c);u=void 0!==t?[t]:[]}if(!isNaN(d.atoms[P].resi)){let e=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)+1).toString(),t=d.firstAtomObjCls.getAtomCoordFromResi(e,c);void 0!==t&&g.push(t);let s=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)+2).toString(),i=d.firstAtomObjCls.getAtomCoordFromResi(s,c);void 0!==i&&g.push(i)}if(!p){1===a||2===a?_.push(d.hColor):_.push(R),f=b.ssend&&"sheet"===b.ss?0:"coil"===I&&b.ssbegin||T&&b.ssbegin||"coil"===b.ss?n:l;let s,i,o=4;"O"===b.name?(s=A.clone(),s.sub(S)):d.bCalphaOnly&&"CA"===b.name&&(G.length>o?(s=S.clone(),i=d.atoms[G[G.length-1-o]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random())),s.normalize(),s.multiplyScalar(f),null!==E&&s.dot(E)<0&&s.negate(),E=s;for(let e=0,s=2/(t-1);e0){let e="CA",n=[],l=[];if(isNaN(d.atoms[P].resi))n=[];else{let t=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)-1).toString();d.firstAtomObjCls.getAtomCoordFromResi(t,e)}for(let e=0;!i&&e0;--e){let t=a.structure+"_"+a.chain+"_"+e;if(!c.residues.hasOwnProperty(t))break;let s=c.firstAtomObjCls.getFirstCalphaAtomObj(c.residues[t]);if(s.ss===a.ss&&s.ssbegin){g=s.resi;break}}for(let e=g;e0&&(o!==c.chain||Math.abs(c.coord.x-h.coord.x)>6||Math.abs(c.coord.y-h.coord.y)>6||Math.abs(c.coord.z-h.coord.z)>6||r.ParserUtilsCls.getResiNCBI(c.structure+"_"+o,a)+13||Math.abs(c.coord.y-h.coord.y)>3||Math.abs(c.coord.z-h.coord.z)>3))){if(2!==i){if(!isNaN(d.resi)&&!isNaN(h.resi)){let e=d.structure+"_"+d.chain+"_"+(parseInt(d.resi)-1).toString(),i=r.firstAtomObjCls.getAtomCoordFromResi(e,t);g=void 0!==i?[i]:[];let l=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+1).toString(),o=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+2).toString(),a=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+3).toString();if(r.residues.hasOwnProperty(l)){let e=r.firstAtomObjCls.getAtomFromResi(l,t);void 0!==e&&e.ssbegin&&(l=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+2).toString(),o=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+3).toString(),p.push(e.coord),n?u.push(this.getCustomtubesize(l)):u.push(this.getRadius(s,e)),m.push(e.color))}if(1==p.length&&r.residues.hasOwnProperty(l)){let e=r.firstAtomObjCls.getAtomFromResi(l,t);if(e){p.push(e.coord),m.push(e.color);let t=this.getRadius(s,c);u.push(t),l=o,o=a}}let b=r.firstAtomObjCls.getAtomCoordFromResi(l,t);void 0!==b&&f.push(b);let C=r.firstAtomObjCls.getAtomCoordFromResi(o,t);void 0!==C&&f.push(C)}C.push({pnts:p,colors:m,radii:u,prevone:g,nexttwo:f})}p=[],m=[],u=[],g=[],f=[],d=c,b=0}if(0==p.length&&!isNaN(c.resi)){let e=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)-1).toString();r.residues.hasOwnProperty(e)&&(h=r.firstAtomObjCls.getAtomFromResi(e,t),void 0!==h&&h.ssend&&(p.push(h.coord),n?u.push(this.getCustomtubesize(e)):u.push(this.getRadius(s,h)),m.push(h.color)))}let e;p.push(c.coord),e=n?this.getCustomtubesize(c.structure+"_"+c.chain+"_"+c.resi):this.getRadius(s,c),u.push(e),m.push(c.color),1===b&&(m[m.length-2]=c.color),o=c.chain,a=c.resi;let l=1.2;2!==i||c.ssbegin||r.boxCls.createBox(c,void 0,void 0,l,void 0,i),++b,h=c}if(2!==i){if(g=[],void 0!==d&&!isNaN(d.resi)){let e=d.structure+"_"+d.chain+"_"+(parseInt(d.resi)-1).toString(),s=r.firstAtomObjCls.getAtomCoordFromResi(e,t);g=void 0!==s?[s]:[]}if(f=[],void 0!==c&&!isNaN(c.resi)){let e=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+1).toString(),i=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+2).toString(),n=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+3).toString();if(1==p.length&&r.residues.hasOwnProperty(e)){let l=r.firstAtomObjCls.getAtomFromResi(e,t);if(l){p.push(l.coord),m.push(l.color);let t=this.getRadius(s,c);u.push(t),e=i,i=n}}let l=r.firstAtomObjCls.getAtomCoordFromResi(e,t);void 0!==l&&f.push(l);let o=r.firstAtomObjCls.getAtomCoordFromResi(i,t);void 0!==o&&f.push(o)}C.push({pnts:p,colors:m,radii:u,prevone:g,nexttwo:f})}for(let e=0,t=C.length;e1?a.parasCls.thr(t[t.length-2]):a.parasCls.thr(t[e]),f[y++]=d.r,f[y++]=d.g,f[y++]=d.b}}let x,k=0;for(let e=0,t=_.length-1;er&&(l=r,e=1);for(let t=0;t0&&t.b<=100?.01*t.b:t.b>100?1:s.coilWidth),i}}class ze{constructor(e){this.icn3d=e}drawCartoonNucleicAcid(e,t,s,i){this.drawStrandNucleicAcid(e,2,t,!0,void 0,s,i)}drawStrandNucleicAcid(e,t,s,i,n,l,r){let o,a,d,c=this.icn3d;if(c.icn3dui.bNode)return;2===r&&(t=void 0,l=void 0),n=n||c.nucleicAcidWidth,s=s||c.axisDIV,t=t||c.nucleicAcidStrandDIV;let h=[];for(d=0;dy?y=C:C=y);let v=.8*b/y;if(g.width=C,g.height=y,f.clearRect(0,0,C,y),h)if(f.fillStyle="rgba("+n.r+","+n.g+","+n.b+","+n.a+")",f.strokeStyle="rgba("+l.r+","+l.g+","+l.b+","+l.a+")",f.lineWidth=r,p){let e=.4*C;this.circle(f,0,0,C,y,e)}else{let e=0;this.roundRect(f,0,0,C,y,e)}f.font="Bold "+a+"px "+o,f.textAlign="center",f.textBaseline="middle",f.fillStyle="rgba("+u.r+", "+u.g+", "+u.b+", 1.0)",f.strokeStyle="rgba("+u.r+", "+u.g+", "+u.b+", 1.0)",f.fillText(e,.5*C,.5*y);let w=new THREE.Texture(g);w.needsUpdate=!0;let _=new THREE.SpriteMaterial({map:w,depthTest:!1,depthWrite:!1});_.map.minFilter=THREE.LinearFilter;let S=new THREE.Sprite(_);return p?S.scale.set(.3*d,.3*d,1):S.scale.set(v*d,d,1),S}roundRect(e,t,s,i,n,l){e.beginPath(),e.moveTo(t+l,s),e.lineTo(t+i-l,s),e.quadraticCurveTo(t+i,s,t+i,s+l),e.lineTo(t+i,s+n-l),e.quadraticCurveTo(t+i,s+n,t+i-l,s+n),e.lineTo(t+l,s+n),e.quadraticCurveTo(t,s+n,t,s+n-l),e.lineTo(t,s+l),e.quadraticCurveTo(t,s,t+l,s),e.closePath(),e.fill(),e.stroke()}circle(e,t,s,i,n,l){e.beginPath(),e.arc(t+i/2,.9*(s+n/2),l,0,2*Math.PI,!0),e.closePath(),e.fill(),e.stroke()}}class Ve{constructor(e){this.icn3d=e,this.textSpriteCls=new Ge(e)}createLabelRepresentation(e){let t=this.icn3d;t.icn3dui;let s=t.oriMaxD/100;s<.4&&(s=.4);let i=3*s*t.labelScale;for(let s in e){let n=void 0!==e[s]?e[s]:[],l="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd;for(let e=0,r=n.length;e.99999)h.set(0,0,0,1);else if(e.y<-.99999)h.set(1,0,0,0);else{let t=new THREE.Vector3;t.set(e.z,0,-e.x).normalize();let s=Math.acos(e.y);h.setFromAxisAngle(t,s)}return c.applyQuaternion(h),c.scale.set(l,n,l),c.position.copy(t),c}setPc1Axes(){let e=this.icn3d,t=e.icn3dui;if(t.bNode)return;let s=t.hashUtilsCls.intHash(e.hAtoms,e.dAtoms),i=[],n=Object.keys(s).length<100;for(let t in s){let s=e.atoms[t],l=s.structure+"_"+s.chain+"_"+s.resi;(n||""!=l)&&i.push(s.coord.clone())}let l=t.rmsdSuprCls.getEigenForSelection(i,i.length),r=new THREE.Vector3(l.h1[0],l.h1[1],l.h1[2]);if(0==l.k&&e.bRender)return void alert("Can't determine the first principal component. Please select a subset and try it again.");let o=e.applyCenterCls.centerAtoms(s),a=o.maxD,d=o.center,c=d.clone().add(r.normalize().multiplyScalar(.4*a)),h=new THREE.Vector3(l.h2[0],l.h2[1],l.h2[2]),p=d.clone().add(h.normalize().multiplyScalar(.3*a)),m=new THREE.Vector3(l.h3[0],l.h3[1],l.h3[2]),u=d.clone().add(m.normalize().multiplyScalar(.3*a));this.buildAxes(void 0,d,c,p,u,!0);let g=[d,c,p,u];return e.axes.push(g),e.drawCls.draw(),g}}class Ye{constructor(e){this.icn3d=e}showGlycans(){let e=this.icn3d,t=e.icn3dui;if(t.bNode)return;let s={},i=e.dAtoms;for(let n in i){let i=e.atoms[n];i.het&&-1!=t.parasCls.glycanHash.hasOwnProperty(i.resn)&&(void 0===s[i.resn]&&(s[i.resn]={}),"Misc"!=i.chain&&(s[i.resn][i.structure+"_"+i.chain+"_"+i.resi]=1))}let n=Object.keys(s);for(let i=0,l=n.length;i>2))+i+((2&t)>>1))*c+n+(1&t)]&this.ISDONE)<=3&&(t.push(t[i]),i=t.length-1,t.push(t[n]),n=t.length-1,t.push(t[l]),l=t.length-1),s.push(i),s.push(n),s.push(l)}}},Xe.prototype.laplacianSmooth=function(e,t,s){let i,n,l,r,o,a=new Array(t.length);for(i=0,n=t.length;ithis.origextent[1][0])&&(!(tthis.origextent[1][1])&&!(sthis.origextent[1][2]))},Ke.prototype.getFacesAndVertices=function(){let e,t,s=this.verts;for(e=0,t=s.length;eh&&(h=this.pmaxy-this.pminy),this.pmaxz-this.pminz>h&&(h=this.pmaxz-this.pminz),this.scaleFactor=(c-1)/h,this.scaleFactor=this.defaultScaleFactor,(this.bCalcArea||this.defaultScaleFactor*h>this.threshbox)&&(c=Math.floor(this.threshbox),this.scaleFactor=(this.threshbox-1)/h),this.pLength=Math.ceil(this.scaleFactor*(this.pmaxx-this.pminx))+1,this.pWidth=Math.ceil(this.scaleFactor*(this.pmaxy-this.pminy))+1,this.pHeight=Math.ceil(this.scaleFactor*(this.pmaxz-this.pminz))+1,this.finalScaleFactor.x=(this.pLength-1)/(this.pmaxx-this.pminx),this.finalScaleFactor.y=(this.pWidth-1)/(this.pmaxy-this.pminy),this.finalScaleFactor.z=(this.pHeight-1)/(this.pmaxz-this.pminz),this.boundingatom(t),this.cutRadius=this.probeRadius*this.scaleFactor,this.vpBits=new Uint8Array(this.pLength*this.pWidth*this.pHeight),this.vpDistance=new Float64Array(this.pLength*this.pWidth*this.pHeight),this.vpAtomID=new Int32Array(this.pLength*this.pWidth*this.pHeight),this.vpColor=[],this.vpPot=[]},Ke.prototype.boundingatom=function(e){let t,s,i,n,l=[];for(let r in this.vdwRadii){if(!this.vdwRadii.hasOwnProperty(r))continue;let o=this.vdwRadii[r];l[r]=e?(o+this.probeRadius)*this.scaleFactor+.5:o*this.scaleFactor+.5,i=l[r]*l[r],this.widxz[r]=Math.floor(l[r])+1,this.depty[r]=new Int32Array(this.widxz[r]*this.widxz[r]),n=0;for(let e=0;ei?this.depty[r][n]=-1:(s=Math.sqrt(i-t),this.depty[r][n]=Math.floor(s)),n++}},Ke.prototype.fillvoxels=function(e,t){let s,i,n,l;for(s=0,l=this.vpBits.length;sc&&(a=c),C>h&&(C=h),v>p&&(v=p);let w,_=g[o*m+d*u+y],S=g[a*m+d*u+y],A=g[o*m+C*u+y],x=g[o*m+d*u+v],k=g[a*m+C*u+y],O=g[o*m+C*u+v],R=g[a*m+d*u+v],E=g[a*m+C*u+v],I=r.x-o,T=r.y-d,M=r.z-y,P=((_*(1-I)+S*I)*(1-T)+(A*(1-I)+k*I)*T)*(1-M)+((x*(1-I)+R*I)*(1-T)+(O*(1-I)+E*I)*T)*M,D=s*f+i*b+n;this.vpPot[D]=P,P>this.isovalue&&(P=this.isovalue),P<-this.isovalue&&(P=-this.isovalue),P>0?(P/=1*this.isovalue,w=new THREE.Color(1-P,1-P,1)):(P/=-1*this.isovalue,w=new THREE.Color(1,1-P,1-P)),this.vpColor[D]=w}}for(s=0,l=this.vpBits.length;s=this.pLength||g>=this.pWidth||f>=this.pHeight)continue;let h=u*S+g*this.pHeight+f;if(this.vpBits[h]&this.INOUT){let p=t[this.vpAtomID[h]];p.serial!=e.serial&&(l=s+a-Math.floor(.5+this.scaleFactor*(p.x+this.ptranx)),r=i+d-Math.floor(.5+this.scaleFactor*(p.y+this.ptrany)),o=n+c-Math.floor(.5+this.scaleFactor*(p.z+this.ptranz)),a*a+d*d+c*c=this.pLength||p>=this.pWidth||m>=this.pHeight)continue;let u=h*S+p*this.pHeight+m;if(this.vpBits[u]&this.ISDONE){let h=t[this.vpAtomID[u]];h.serial!=e.serial&&(l=s+a-Math.floor(.5+this.scaleFactor*(h.x+this.ptranx)),r=i+d-Math.floor(.5+this.scaleFactor*(h.y+this.ptrany)),o=n+c-Math.floor(.5+this.scaleFactor*(h.z+this.ptranz)),a*a+d*d+c*c-1&&r-1&&a-1&&o=h)||(this.vpBits[n]|=this.ISBOUND))},Ke.prototype.fastoneshell=function(e,t){let s,i,n,l,r,o,a,d,c,h,p,m,u=[];if(0===e.length)return u;let g={ix:-1,iy:-1,iz:-1},f=this.pWidth*this.pHeight;for(a=0,c=e.length;a-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,h-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,h-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,hm&&(m=this.pmaxy-this.pminy),this.pmaxz-this.pminz>m&&(m=this.pmaxz-this.pminz),this.scaleFactor=1,this.pLength=Math.floor(.5+this.scaleFactor*(this.pmaxx-this.pminx))+1,this.pWidth=Math.floor(.5+this.scaleFactor*(this.pmaxy-this.pminy))+1,this.pHeight=Math.floor(.5+this.scaleFactor*(this.pmaxz-this.pminz))+1,this.cutRadius=this.probeRadius*this.scaleFactor,this.vpBits=new Uint8Array(this.pLength*this.pWidth*this.pHeight),this.vpAtomID=new Uint8Array(this.pLength*this.pWidth*this.pHeight)},Qe.prototype.transformMemPro=function(e,t,s,i){let n=e.clone();n.sub(s);let l=n.x*t[0]+n.y*t[1]+n.z*t[2]+i.x,r=n.x*t[3]+n.y*t[4]+n.z*t[5]+i.y,o=n.x*t[6]+n.y*t[7]+n.z*t[8]+i.z;return n.x=l,n.y=r,n.z=o,n},Qe.prototype.fillvoxels=function(e,t){let s,i,n,l,r,o;for(s=0,l=this.vpBits.length;sthis.pLength&&(o=this.pLength),p>this.pWidth&&(p=this.pWidth),b>this.pHeight&&(b=this.pHeight);let C,y=l[r*a+h*d+f],v=l[o*a+h*d+f],w=l[r*a+p*d+f],_=l[r*a+h*d+b],S=l[o*a+p*d+f],A=l[r*a+p*d+b],x=l[o*a+h*d+b],k=l[o*a+p*d+b],O=n.x-r,R=n.y-h,E=n.z-f,I=((y*(1-O)+v*O)*(1-R)+(w*(1-O)+S*O)*R)*(1-E)+((_*(1-O)+x*O)*(1-R)+(A*(1-O)+k*O)*R)*E;I>this.isovalue&&(I=this.isovalue),I<-this.isovalue&&(I=-this.isovalue),I>0?(I/=1*this.isovalue,C=new THREE.Color(1-I,1-I,1)):(I/=-1*this.isovalue,C=new THREE.Color(1,1-I,1-I)),this.icn3d.atoms[t[s]].color=C,this.icn3d.atomPrevColors[t[s]]=C}}else{for(let p in t){let f,b=e[t[p]];if("DUM"!==b.resn){if(void 0!==this.rmsd_supr&&void 0!==this.rmsd_supr.rot){f=this.transformMemPro(b.coord,g,u,m).applyMatrix4(c)}else f=b.coord.clone().applyMatrix4(c);for(s=Math.floor(f.x)-this.maxdist,l=Math.ceil(f.x)+this.maxdist;s<=l;++s)if(!(s<0||s>this.header.xExtent*this.scaleFactor-1))for(i=Math.floor(f.y)-this.maxdist,r=Math.ceil(f.y)+this.maxdist;i<=r;++i)if(!(i<0||i>this.header.yExtent*this.scaleFactor-1))for(n=Math.floor(f.z)-this.maxdist,o=Math.ceil(f.z)+this.maxdist;n<=o;++n){if(n<0||n>this.header.zExtent*this.scaleFactor-1)continue;let e=s*a+i*d+n;h.push(e)}}}for(s=0,l=h.length;s=this.isovalue?1:0:"fofc"==this.type?(this.vpBits[e]=this.dataArray[e]>=this.isovalue||this.dataArray[e]<=-this.isovalue?1:0,this.vpAtomID[e]=this.dataArray[e]>=0?1:0):"em"==this.type&&(this.vpBits[e]=this.dataArray[e]>=this.isovalue?1:0)}}}else for(s=0;s=this.isovalue||this.dataArray[e]<=-this.isovalue?1:0,this.vpAtomID[t]=this.dataArray[e]>=0?1:0)}for(s=0,l=this.vpBits.length;s-1&&r-1&&a-1&&o1?"Structure":"",a=Object.keys(i).length>1?"Chain":"";n+=""+o+a+"ResidueNumberSASA (Å2)Percent OutIn/Out";for(let e in l.resid2area){let d=e.lastIndexOf("_"),c=e.substr(d+1),h=r.utilsCls.getIdArray(e.substr(0,d));o=Object.keys(s).length>1?""+h[0]+"":"",a=Object.keys(i).length>1?""+h[1]+"":"";let p="",m="";l.resid2area[e]=(l.resid2area[e]/t).toFixed(2),r.parasCls.residueArea.hasOwnProperty(c)&&(m=parseInt(l.resid2area[e]/r.parasCls.residueArea[c]*100),m>100&&(m=100),m>=50&&(p="out"),m<20&&(p="in")),n+=''+o+a+""+c+''+h[2]+''+l.resid2area[e]+''+m+"%"+p+""}return n+="",void(l.areahtml=n)}let p,m,u,g=c.vertices,f=c.faces,b=r.parasCls.thr("#00FFFF"),C=r.parasCls.thr("#00FF00"),y=r.parasCls.thr("#ff0000"),v=r.parasCls.thr("#00FFFF"),w=r.parasCls.thr("#0000FF"),_=r.parasCls.thr("#FF0000");11!=t&&12!=t&&13!=t&&14!=t||void 0===l.rmsd_supr||void 0===l.rmsd_supr.rot||(p=l.rmsd_supr.rot,m=l.rmsd_supr.trans1,u=l.rmsd_supr.trans2);let S=(11==t||12==t||13==t||14==t&&"delphi"!=l.loadPhiFrom)&&void 0!==l.rmsd_supr&&void 0!==l.rmsd_supr.rot;n=new THREE.BufferGeometry;let A,x=[],k=[],O=[],R=0;for(let e=0,s=g.length;e0?-parseInt(C.z):parseInt(C.z),y.onBeforeRender=function(e,t,s,i,n,o){let a,d=new THREE.Vector3(0,0,0),c=i.getAttribute("position").array;for(let e=0,t=c.length;e0?-parseInt(a.z):parseInt(a.z)},l.mdl.add(y),11==t||12==t?l.prevMaps.push(y):13==t?l.prevEmmaps.push(y):14==t?l.prevPhimaps.push(y):l.prevSurfaces.push(y)}}else{let e=new THREE.Mesh(n,new THREE.MeshPhongMaterial({specular:l.frac,shininess:20,emissive:l.emissive,vertexColors:THREE.VertexColors,wireframe:s,opacity:i,transparent:!0,depthWrite:10==parseInt(10*i),side:THREE.DoubleSide}));e.renderOrder=-2,l.mdl.add(e),11==t||12==t?l.prevMaps.push(e):13==t?l.prevEmmaps.push(e):14==t?l.prevPhimaps.push(e):l.prevSurfaces.push(e)}c=null,g=null,f=null,n=null}transformMemPro(e,t,s,i,n){this.icn3d.icn3dui;let l=e.clone();l.sub(s),n&&console.log("sub coord: "+JSON.stringify(l));let r=l.x*t[0]+l.y*t[1]+l.z*t[2]+i.x,o=l.x*t[3]+l.y*t[4]+l.z*t[5]+i.y,a=l.x*t[6]+l.y*t[7]+l.z*t[8]+i.z;return l.x=r,l.y=o,l.z=a,n&&console.log("out coord: "+JSON.stringify(l)),l}SetupSurface(e){let t=this.icn3d;t.icn3dui;let s=e.threshbox,i=new Ke(t,s);i.initparm(e.extent,1!==e.type,e.bCalcArea,e.atomsToShow,e.header,e.data,e.matrix,e.isovalue,e.loadPhiFrom),i.fillvoxels(e.allatoms,e.extendedAtoms),i.buildboundary(),2===e.type&&(i.fastdistancemap(),i.boundingatom(!1),i.fillvoxelswaals(e.allatoms,e.extendedAtoms));let n=i.marchingcube();i.vpBits=null,i.vpDistance=null,i.vpAtomID=null;let l=i.getFacesAndVertices(e.atomsToShow);return l.area=n.area,l.serial2area=n.serial2area,l.scaleFactor=n.scaleFactor,i.faces=null,i.verts=null,l}SetupMap(e){let t=this.icn3d;t.icn3dui;let s,i=new Qe(t);return i.initparm(e.header,e.data,e.matrix,e.isovalue,e.center,e.maxdist,e.pmin,e.pmax,e.water,e.type,e.rmsd_supr,e.loadPhiFrom,e.icn3d),i.fillvoxels(e.allatoms,e.extendedAtoms),e.header.bSurface||i.buildboundary(),e.header.bSurface||i.marchingcube(),i.vpBits=null,i.vpAtomID=null,e.header.bSurface||(s=i.getFacesAndVertices(e.allatoms,e.atomsToShow)),i.faces=null,i.verts=null,s}}class Ze{constructor(e){this.icn3d=e}applyCenterOptions(e){let t,s=this.icn3d;switch(s.icn3dui,void 0===e&&(e=s.opts),e.rotationcenter.toLowerCase()){case"molecule center":void 0!==s.center&&this.setRotationCenter(s.center);break;case"pick center":void 0!==s.pAtom&&this.setRotationCenter(s.pAtom.coord);break;case"display center":t=this.centerAtoms(s.dAtoms).center,this.setRotationCenter(t);break;case"highlight center":t=this.centerAtoms(s.hAtoms).center,this.setRotationCenter(t)}}setRotationCenter(e){this.icn3d.icn3dui,this.setCenter(e)}setCenter(e){let t=this.icn3d;t.icn3dui,t.mdl.position.set(0,0,0),t.mdlImpostor.position.set(0,0,0),t.mdl_ghost.position.set(0,0,0),t.mdl.position.sub(e),t.mdlImpostor.position.sub(e),t.mdl_ghost.position.sub(e)}centerSelection(e,t){let s=this.icn3d,i=s.icn3dui;if(s.opts.rotationcenter="highlight center",void 0===e&&(e=i.hashUtilsCls.hash2Atoms(s.hAtoms,s.atoms)),t||(s._zoomFactor=1,s.mouseChange=new THREE.Vector2(0,0),s.quaternion=new THREE.Quaternion(0,0,0,1)),Object.keys(e).length>1){let t=this.centerAtoms(e);s.center=t.center,this.setCenter(s.center),s.cameraCls.setCamera()}}centerAtoms(e){let t=this.icn3d;t.icn3dui;let s=new THREE.Vector3(9999,9999,9999),i=new THREE.Vector3(-9999,-9999,-9999),n=new THREE.Vector3;for(let l in e){let e=t.atoms[l].coord;n.add(e),s.min(e),i.max(e)}let l=t.ParserUtilsCls.getGeoCenter(s,i);return{center:l,maxD:t.ParserUtilsCls.getStructureSize(e,s,i,l),pmin:s,pmax:i}}setWidthHeight(e,t){let s=this.icn3d;s.icn3dui,void 0===s.scaleFactor&&(s.scaleFactor=1),s.renderer.setSize(e*s.scaleFactor,t*s.scaleFactor),s.renderer.domElement.style.width=e*s.scaleFactor+"px",s.renderer.domElement.style.height=t*s.scaleFactor+"px",s.renderer.domElement.width=e*s.scaleFactor,s.renderer.domElement.height=t*s.scaleFactor,s.container.whratio=e/t}}class et{constructor(e){this.icn3d=e}applyClbondsOptions(e){let t=this.icn3d,s=t.icn3dui;if(void 0===e&&(e=t.opts),t.bCalcCrossLink||(t.clbondpnts={},t.clbondResid2serial={},this.applyClbondsOptions_base("chemical"),this.applyClbondsOptions_base("all"),t.bCalcCrossLink=!0),"yes"===e.clbonds.toLowerCase()&&"nothing"!==e.chemicals){let e="#006400",i=s.parasCls.thr(25600);if(t.lines.clbond=[],t.residuesHashClbonds={},t.structures){let n=Object.keys(t.structures);for(let l=0,r=n.length;l1&&"sphere"!==a[Object.keys(a)[0]].style&&"dot"!==a[Object.keys(a)[0]].style){if(void 0===i.bCid||!i.bCid)for(let e in a){let t=a[e],n=1;i.boxCls.createBox(t,void 0,void 0,n,void 0,s)}}else for(let e in o){let l=i.firstAtomObjCls.getFirstCalphaAtomObj(i.residues[e]),r=l,o=r.structure+"_"+r.chain+"_"+(parseInt(r.resi)-1).toString(),a=r.structure+"_"+r.chain+"_"+(parseInt(r.resi)+1).toString();if("cylinder and plate"===r.style&&"helix"===r.ss)for(let t in i.residues[e]){let e=i.atoms[t],n=1;i.boxCls.createBox(e,void 0,void 0,n,void 0,s)}else if("ribbon"===r.style&&"coil"===r.ss||"strand"===r.style&&"coil"===r.ss||"o3 trace"===r.style||"schematic"===r.style||"c alpha trace"===r.style||"b factor tube"===r.style||"cylinder and plate"===r.style&&"helix"!==r.ss){if(void 0!==l&&void 0!==l.style2&&"nothing"!==l.style2)continue;let e=!1;if(!isNaN(r.resi)&&!e&&i.residues.hasOwnProperty(a)){let s=Object.keys(i.residues[a])[0],l=n.hashUtilsCls.hash2Atoms(i.residues[a],i.atoms)[s];if(r.style===l.style&&!l.ssbegin||l.ssbegin){let s=i.residues[a];if(t=n.hashUtilsCls.unionHash(t,s),e=!0,l.ssbegin)for(let e in s)i.atoms[e].notshow=!0}}if(!isNaN(r.resi)&&!e&&i.residues.hasOwnProperty(o)){let s=Object.keys(i.residues[o])[0],l=n.hashUtilsCls.hash2Atoms(i.residues[o],i.atoms)[s];r.style===l.style&&(t=n.hashUtilsCls.unionHash(t,i.residues[o]),e=!0)}}else if("ribbon"===r.style&&"coil"!==r.ss&&r.ssend||"strand"===r.style&&"coil"!==r.ss&&r.ssend){if(void 0!==l&&void 0!==l.style2&&"nothing"!==l.style2)continue;let e=!1;if(!isNaN(r.resi)&&!e&&i.residues.hasOwnProperty(a)){let s=Object.keys(i.residues[a])[0];n.hashUtilsCls.hash2Atoms(i.residues[a],i.atoms)[s],t=n.hashUtilsCls.unionHash(t,i.residues[a]),e=!0}}}a={}}if(i.bInitial){if(""!=n.htmlCls.setHtmlCls.getCookie("membrane")){let e=parseInt(n.htmlCls.setHtmlCls.getCookie("membrane"));i.bMembrane!=e&&n.htmlCls.clickMenuCls.setLogCmd("set membrane "+e,!0),i.bMembrane=isNaN(e)?0:parseInt(e)}i.bMembrane?i.selectionCls.toggleMembrane(!0):i.selectionCls.toggleMembrane(!1)}i.setStyleCls.setStyle2Atoms(t);let d=.5*i.cylinderRadius;void 0!==i.labels&&delete i.labels.schematic;for(let e in i.style2atoms){let t=i.style2atoms[e],l=n.hashUtilsCls.intHash(t,i.nucleotides),r=n.utilsCls.isCalphaPhosOnly(n.hashUtilsCls.hash2Atoms(l,i.atoms));if("ribbon"===e)i.strandCls.createStrand(n.hashUtilsCls.hash2Atoms(t,i.atoms),2,void 0,!0,void 0,void 0,!1,i.ribbonthickness,s);else if("strand"===e)i.strandCls.createStrand(n.hashUtilsCls.hash2Atoms(t,i.atoms),null,null,null,null,null,!1,void 0,s);else if("cylinder and plate"===e)i.cylinderCls.createCylinderHelix(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderHelixRadius,s);else if("nucleotide cartoon"===e)r?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["P"],i.traceRadius,!1,s):(i.cartoonNuclCls.drawCartoonNucleicAcid(n.hashUtilsCls.hash2Atoms(t,i.atoms),null,i.ribbonthickness,s),2!==s&&i.cartoonNuclCls.drawNucleicAcidStick(n.hashUtilsCls.hash2Atoms(t,i.atoms),s));else if("o3 trace"===e)r?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["P"],i.traceRadius,!1,s):i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["O3'","O3*"],i.traceRadius,!1,s);else if("schematic"===e){let e=i.firstAtomObjCls.getFirstAtomObj(t);if(i.chemicals.hasOwnProperty(e.serial)){i.residueLabelsCls.addNonCarbonAtomLabels(n.hashUtilsCls.hash2Atoms(t,i.atoms));let e=!0;i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),d,d,void 0,s,e)}else i.residueLabelsCls.addResidueLabels(n.hashUtilsCls.hash2Atoms(t,i.atoms),!0),r?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["P"],i.traceRadius,!1,s):i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["O3'","O3*"],i.traceRadius,!1,s),i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["CA"],i.traceRadius,!1,s)}else"c alpha trace"===e?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["CA"],i.traceRadius,!1,s):"b factor tube"===e?i.tubeCls.createTube(n.hashUtilsCls.hash2Atoms(t,i.atoms),"CA",null,s,!1,!0):"custom tube"===e?i.tubeCls.createTube(n.hashUtilsCls.hash2Atoms(t,i.atoms),"CA",null,s,!0,!0):"lines"===e||"lines2"===e?(1===s?i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.hlLineRadius,i.hlLineRadius,void 0,s):i.lineCls.createLineRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),s),i.lineCls.createConnCalphSidechain(n.hashUtilsCls.hash2Atoms(t,i.atoms),e)):"stick"===e||"stick2"===e?(i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderRadius,i.cylinderRadius,void 0,s,void 0),i.lineCls.createConnCalphSidechain(n.hashUtilsCls.hash2Atoms(t,i.atoms),e)):"backbone"===e?(t=this.selectMainChainSubset(t),i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderRadius,i.cylinderRadius,void 0,s,void 0)):"ball and stick"===e||"ball and stick2"===e?(i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderRadius,.5*i.cylinderRadius,i.dotSphereScale,s,void 0),i.lineCls.createConnCalphSidechain(n.hashUtilsCls.hash2Atoms(t,i.atoms),e)):"sphere"===e||"sphere2"===e?i.sphereCls.createSphereRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.sphereRadius,void 0,void 0,s):"dot"===e&&i.sphereCls.createSphereRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.sphereRadius,!1,i.dotSphereScale,s)}if(i.cnt>i.maxmaxatomcnt&&i.init_base(),void 0!==i.labels&&Object.keys(i.labels).length>0){i.labelCls.hideLabels();for(let e in i.labels)"schematic"!=e&&this.changeLabelColor(i.labels[e]);i.labelCls.createLabelRepresentation(i.labels)}}changeLabelColor(e){let t=this.icn3d;if(t.icn3dui,e)for(let s=0,i=e.length;s0){this.updateStabilizer();let e="#FFFFFF",s=t.stabilizerpnts;t.lines.stabilizer=[];for(let i=0,n=Math.floor(s.length/2);i0)for(let e=0,s=t.distPnts.length;e0&&t.applySymdCls.applySymd(),void 0!==t.prevOtherMesh)for(let e=0,s=t.prevOtherMesh.length;e0&&(e=s.hashUtilsCls.hash2Atoms(t.chemicals,t.atoms));let i=4;if(void 0!==e){let n=t.contactCls.getAtomsWithinAtom(t.atoms,e,i),l=3.5;t.opts.hbonds="yes",Object.keys(n).length>0&&t.hBondCls.calculateChemicalHbonds(e,n,parseFloat(l)),t.bSetFog||t.transformCls.zoominSelection(s.hashUtilsCls.unionHash(e,n))}}else"hide"===e.chemicalbinding&&(t.hBondCls.hideHbonds(),t.bSetFog||t.transformCls.zoominSelection(t.atoms))}updateStabilizer(){let e=this.icn3d;if(e.icn3dui,e.stabilizerpnts=[],void 0!==e.pairArray)for(let t=0,s=e.pairArray.length;t=0;i--){let r=t.ssbondpnts[e][2*i],o=t.ssbondpnts[e][2*i+1],a={};a.color=n,a.dashed=!0;let d=[],c=[],h=[],p=[],m=!1,u=!1;for(let e in t.residues[r])"SG"===t.atoms[e].name&&(h.push(t.atoms[e].coord),d.push(t.atoms[e].serial),m=!0);if(!m)for(let e in t.residues[r])if("CA"===t.atoms[e].name){h.push(t.atoms[e].coord),d.push(t.atoms[e].serial),m=!0,u=!0;break}m=!1;for(let e in t.residues[o])"SG"===t.atoms[e].name&&(p.push(t.atoms[e].coord),c.push(t.atoms[e].serial),m=!0);if(!m)for(let e in t.residues[o])if("CA"===t.atoms[e].name){p.push(t.atoms[e].coord),c.push(t.atoms[e].serial),m=!0,u=!0;break}let g=u?7:3,f=!1;for(let e=0,t=h.length;e1&&(l=!0)}if(t)if(l){let t=Object.keys(r)[0];e=i.chains[t]}else{0==Object.keys(i.hAtoms).length&&(i.hAtoms=n.hashUtilsCls.cloneHash(i.dAtoms));let t,s=parseInt(Object.keys(i.hAtoms).length/u),l=0;for(let n in i.hAtoms)if(e[n]=1,t=n,++l,l>s)break;let r=i.atoms[t].structure+"_"+i.atoms[t].chain+"_"+i.atoms[t].resi;e=n.hashUtilsCls.unionHash(e,i.residues[r])}else{let t=Object.keys(i.structures)[0]+"_"+g;if(i.chains.hasOwnProperty(t)||(t=Object.keys(i.structures)[0]+"_"+g.toLowerCase()),!i.chains.hasOwnProperty(t)){t=Object.keys(i.chains)[0];for(let e in i.chains){let s=Object.keys(i.chains[e])[0];if(i.proteins.hasOwnProperty(s)){t=e;break}}}e=i.chains[t]}let a=s.clone().add(h).multiplyScalar(.5),c=new THREE.Vector3,p=0,f=h.clone().sub(s).normalize(),b=new THREE.Vector3(0,0,1),C=new THREE.Quaternion;C.setFromUnitVectors(f,b);let y=-9999;for(let t in e){let e=i.atoms[t].coord.clone();c.add(e),e.sub(a).applyQuaternion(C);let s=e.x*e.x+e.y*e.y;s>y&&(y=s),++p}let v=i.ParserUtilsCls.getMassCenter(c,p),w=new THREE.Line3(s,h),_=new THREE.Vector3;w.closestPointToPoint(v,!0,_);let S,A,x,k,O=Math.sqrt(y),R=v.clone().sub(_).normalize().multiplyScalar(O),E=a.clone().add(s.clone().sub(a).multiplyScalar(.83)).add(R),I=a.clone().add(h.clone().sub(a).multiplyScalar(.83)).add(R),T=2*Math.PI/o;for(let e=0;et&&(i.sphereCls.createSphereBase(r,colorPolygon,d,1,0),i.cylinderCls.createCylinder(e,r,d,colorPolygon,0),i.cylinderCls.createCylinder(s,r,d,colorPolygon,0),void 0!==n&&i.cylinderCls.createCylinder(c[n],r,d,colorPolygon,0),n=l)}}else if("O"==r)for(let e=0,t=c.length;e0&&(e.mdl.remove(e.prevSurfaces[e.prevSurfaces.length-1]),e.prevSurfaces.slice(e.prevSurfaces.length-1,1))}removeMaps(){let e=this.icn3d;e.icn3dui;for(let t=0,s=e.prevMaps.length;t0&&(e.mdl.remove(e.prevMaps[e.prevMaps.length-1]),e.prevMaps.slice(e.prevMaps.length-1,1))}removeLastEmmap(){let e=this.icn3d;e.icn3dui,e.prevEmmaps.length>0&&(e.mdl.remove(e.prevEmmaps[e.prevEmmaps.length-1]),e.prevEmmaps.slice(e.prevEmmaps.length-1,1))}removeLastPhimap(){let e=this.icn3d;e.icn3dui,e.prevPhimaps.length>0&&(e.mdl.remove(e.prevPhimaps[e.prevPhimaps.length-1]),e.prevPhimaps.slice(e.prevPhimaps.length-1,1))}}class rt{constructor(e){this.icn3d=e}addResidueLabels(e,t,s,i){let n=this.icn3d,l=n.icn3dui;if(l.bNode)return;let r=l.hashUtilsCls.intHash(n.hAtoms,e);t?void 0===n.labels.schematic&&(n.labels.schematic=[]):void 0===n.labels.residue&&(n.labels.residue=[]);let o="";for(let e in r){let s=n.atoms[e],r={},a=s.structure+"_"+s.chain+"_"+s.resi;if(!s.het&&("CA"===s.name||"O3'"===s.name||"O3*"===s.name)||n.water.hasOwnProperty(s.serial)||n.ions.hasOwnProperty(s.serial)||n.chemicals.hasOwnProperty(s.serial)&&a!==o){r.position=s.coord,r.bSchematic=0,t&&(r.bSchematic=1),r.text=l.utilsCls.residueName2Abbr(s.resn),i&&(r.text+=s.resi),r.size=18,r.factor=.3;let e=s.color.getHexString().toUpperCase();r.color=i?"black"!=n.opts.background?n.colorWhitebkgd:n.colorBlackbkgd:"CCCCCC"===e||"C8C8C8"===e?"#888888":"#"+e,r.background="#FFFFFF",t?n.labels.schematic.push(r):n.labels.residue.push(r)}o=a}n.hlObjectsCls.removeHlObjects()}addNonCarbonAtomLabels(e){let t=this.icn3d,s=t.icn3dui;if(s.bNode)return;let i=s.hashUtilsCls.intHash(t.hAtoms,e);void 0===t.labels.schematic&&(t.labels.schematic=[]);for(let e in i){let s=t.atoms[e];if(!t.residues.hasOwnProperty(s.structure+"_"+s.chain+"_"+s.resi))continue;if("C"===s.elem)continue;let i={};i.position=s.coord,i.bSchematic=1,i.text=s.elem,i.size=18,i.color="black"!=t.opts.background?t.colorWhitebkgd:s.color.getHexString(),i.background="#FFFFFF",t.labels.schematic.push(i)}t.hlObjectsCls.removeHlObjects()}addAtomLabels(e,t){let s=this.icn3d,i=s.icn3dui;if(i.bNode)return;let n=i.hashUtilsCls.intHash(s.hAtoms,e);n=i.hashUtilsCls.intHash(s.dAtoms,n),void 0===s.labels.residue&&(s.labels.residue=[]);for(let e in n){let i=s.atoms[e],n={};n.position=i.coord,n.bSchematic=0,n.text=t?i.elem:i.name.padEnd(2," "),n.size=18,t&&(n.bSchematic=!0);let l=i.color.getHexString().toUpperCase();n.color="black"!=s.opts.background?s.colorWhitebkgd:s.colorBlackbkgd,t&&(n.color="CCCCCC"===l||"C8C8C8"===l?"#888888":"#"+l),n.background="#FFFFFF",s.labels.residue.push(n)}s.hlObjectsCls.removeHlObjects()}}class ot{constructor(e){this.icn3d=e}onBeforeRender(e,t,s,i,n,l){let r=n.uniforms,o=[];if(r.objectId&&(r.objectId.value=SupportsReadPixelsFloat?this.id:this.id/255,o.push("objectId")),(r.modelViewMatrixInverse||r.modelViewMatrixInverseTranspose||r.modelViewProjectionMatrix||r.modelViewProjectionMatrixInverse)&&this.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,this.matrixWorld),r.modelViewMatrixInverse&&(r.modelViewMatrixInverse.value.copy(this.modelViewMatrix).invert(),o.push("modelViewMatrixInverse")),r.modelViewMatrixInverseTranspose&&(r.modelViewMatrixInverse?r.modelViewMatrixInverseTranspose.value.copy(r.modelViewMatrixInverse.value).transpose():r.modelViewMatrixInverseTranspose.value.copy(this.modelViewMatrix).invert().transpose(),o.push("modelViewMatrixInverseTranspose")),r.modelViewProjectionMatrix&&(s.updateProjectionMatrix(),r.modelViewProjectionMatrix.value.multiplyMatrices(s.projectionMatrix,this.modelViewMatrix),o.push("modelViewProjectionMatrix")),r.modelViewProjectionMatrixInverse){let e=new THREE.Matrix4;r.modelViewProjectionMatrix?(e.copy(r.modelViewProjectionMatrix.value),r.modelViewProjectionMatrixInverse.value.copy(e).invert()):(s.updateProjectionMatrix(),e.multiplyMatrices(s.projectionMatrix,this.modelViewMatrix),r.modelViewProjectionMatrixInverse.value.copy(e).invert()),o.push("modelViewProjectionMatrixInverse")}if(r.projectionMatrix&&(s.updateProjectionMatrix(),r.projectionMatrix.value.copy(s.projectionMatrix),o.push("projectionMatrix")),r.projectionMatrixInverse&&(s.updateProjectionMatrix(),r.projectionMatrixInverse.value.copy(s.projectionMatrix).invert(),o.push("projectionMatrixInverse")),o.length){let t=e.properties.get(n);if(t.program){let s=e.getContext(),i=t.program;s.useProgram(i.program);let n=i.getUniforms();o.forEach((function(e){n.setValue(s,e,r[e].value)}))}}}setParametersForShader(e){let t,s=this.icn3d,i=s.icn3dui.parasCls.backgroundColors[s.opts.background.toLowerCase()],n=2.5*s.maxD,l=4*s.maxD,r=void 0!==s.biomtMatrices&&s.biomtMatrices.length*s.cnt>s.maxatomcnt;"yes"===s.opts.slab?r?t=.1:void 0!==s.camMaxDFactorFog?(t=s.maxD*s.camMaxDFactorFog-10,n=2.5*s.maxD-t<0?0:2.5*s.maxD-t,l=4*s.maxD-t):t=s.maxD*s.camMaxDFactor:t=.1;let o=void 0!==e?e:1,a=s.shininess/100*.5;s.uniforms=THREE.UniformsUtils.merge([THREE.UniformsLib.common,{modelViewMatrix:{value:new THREE.Matrix4},modelViewMatrixInverse:{value:new THREE.Matrix4},modelViewMatrixInverseTranspose:{value:new THREE.Matrix4},modelViewProjectionMatrix:{value:new THREE.Matrix4},modelViewProjectionMatrixInverse:{value:new THREE.Matrix4},projectionMatrix:{value:new THREE.Matrix4},projectionMatrixInverse:{value:new THREE.Matrix4},diffuse:{type:"v3",value:[1,1,1]},emissive:{type:"v3",value:[.06,.06,.06]},roughness:{type:"f",value:.5},metalness:{type:"f",value:a},opacity:{type:"f",value:o},nearClip:{type:"f",value:t},ortho:{type:"f",value:0},shrink:{type:"f",value:.13},fogColor:{type:"v3",value:[i.r,i.g,i.b]},fogNear:{type:"f",value:n},fogFar:{type:"f",value:l},fogDensity:{type:"f",value:2}},THREE.UniformsLib.ambient,THREE.UniformsLib.lights]),s.defines={USE_COLOR:1,NEAR_CLIP:1,CAP:1},"yes"!==s.opts.fog||r||(s.defines.USE_FOG=1,"orthographic"===s.opts.camera&&(s.defines.FOG_EXP2=1)),s.bExtFragDepth&&(s.defines.USE_LOGDEPTHBUF_EXT=1)}drawImpostorShader(){this.icn3d.icn3dui.bNode||(this.setParametersForShader(),this.createImpostorShaderSphere("SphereImpostor"),this.createImpostorShaderCylinder("CylinderImpostor"))}getShader(e){this.icn3d.icn3dui;let t=$NGL_shaderTextHash[e];return t=t.replace(/#include\s+(\S+)/gim,(function(e,t){let s;return THREE.ShaderChunk.hasOwnProperty(t)&&(s=THREE.ShaderChunk[t]),s||""})),t}createImpostorShaderBase(e,t,s,i,n,l,r,o,a){let d=this.icn3d;d.icn3dui;let c=new THREE.ShaderMaterial({defines:d.defines,uniforms:d.uniforms,vertexShader:this.getShader(e+".vert"),fragmentShader:this.getShader(e+".frag"),depthTest:!0,depthWrite:!0,lights:!0});c.extensions.fragDepth=!0,"CylinderImpostor"==e?d.CylinderImpostorMaterial=c:"SphereImpostor"==e&&(d.SphereImpostorMaterial=c);let h,p,m=l*r,u=l*o,g=new(m>65535?Uint32Array:Uint16Array)(u);for(let e=0;e=0;t--){let s=a.children[t];s.onBeforeRender=e.impostorCls.onBeforeRender,s.frustumCulled=!1}l.add(a)}void 0!==e.mdl_ghost&&(a=e.mdl_ghost.clone(),this.applyMat(a,d),r.add(a));let c=e.center.clone();this.applyMat(c,d,!0),s.add(c),++t}e.mdl.add(n),e.mdlImpostor.add(l),e.mdl_ghost.add(r),void 0!==e.bSetInstancing&&e.bSetInstancing?(e.maxD=e.maxDAssembly,e.center=e.centerAssembly.clone(),e.applyCenterCls.setCenter(e.center),e.cameraCls.setCamera()):(e.maxD*=Math.sqrt(t),e.center=e.ParserUtilsCls.getMassCenter(s,t),e.maxDAssembly=e.maxD,e.centerAssembly=e.center.clone(),e.applyCenterCls.setCenter(e.center),e.cameraCls.setCamera()),e.bSetInstancing=!0}createInstancedGeometry(e){let t=this.icn3d,s=t.icn3dui,i=e.geometry,n=new THREE.InstancedBufferGeometry,l=[],r=[],o=[],a=[],d=[],c=[],h=[],p=[];if(t.bImpo&&"Cylinder"==e.type){t.instancedMaterial=this.getInstancedMaterial("CylinderInstancing");let e=s.hashUtilsCls.hashvalue2array(i.attributes.position1.array),r=s.hashUtilsCls.hashvalue2array(i.attributes.color.array),m=s.hashUtilsCls.hashvalue2array(i.attributes.position2.array),u=s.hashUtilsCls.hashvalue2array(i.attributes.color2.array),g=s.hashUtilsCls.hashvalue2array(i.index.array),f=s.hashUtilsCls.hashvalue2array(i.attributes.radius.array),b=s.hashUtilsCls.hashvalue2array(i.attributes.mapping.array);l=l.concat(e),o=o.concat(r),h=h.concat(m),p=p.concat(u),a=a.concat(g),d=d.concat(f),c=c.concat(b),n.setAttribute("position1",new THREE.BufferAttribute(new Float32Array(l),3)),n.setAttribute("color",new THREE.BufferAttribute(new Float32Array(o),3)),n.setAttribute("position2",new THREE.BufferAttribute(new Float32Array(h),3)),n.setAttribute("color2",new THREE.BufferAttribute(new Float32Array(p),3)),n.setAttribute("radius",new THREE.BufferAttribute(new Float32Array(d),1)),n.setAttribute("mapping",new THREE.BufferAttribute(new Float32Array(c),3)),n.setIndex(new THREE.BufferAttribute(new Uint32Array(a),1)),e=null,r=null,m=null,u=null,g=null,f=null,b=null}else if(t.bImpo&&"Sphere"==e.type){t.instancedMaterial=this.getInstancedMaterial("SphereInstancing");let e=s.hashUtilsCls.hashvalue2array(i.attributes.position.array),r=s.hashUtilsCls.hashvalue2array(i.attributes.color.array),h=s.hashUtilsCls.hashvalue2array(i.index.array),p=s.hashUtilsCls.hashvalue2array(i.attributes.radius.array),m=s.hashUtilsCls.hashvalue2array(i.attributes.mapping.array);l=l.concat(e),o=o.concat(r),a=a.concat(h),d=d.concat(p),c=c.concat(m),n.setAttribute("position",new THREE.BufferAttribute(new Float32Array(l),3)),n.setAttribute("color",new THREE.BufferAttribute(new Float32Array(o),3)),n.setAttribute("radius",new THREE.BufferAttribute(new Float32Array(d),1)),n.setAttribute("mapping",new THREE.BufferAttribute(new Float32Array(c),2)),n.setIndex(new THREE.BufferAttribute(new Uint32Array(a),1)),e=null,r=null,h=null,p=null,m=null}else{t.instancedMaterial=this.getInstancedMaterial("Instancing");let e=i.attributes.position?s.hashUtilsCls.hashvalue2array(i.attributes.position.array):[],d=i.attributes.normal?s.hashUtilsCls.hashvalue2array(i.attributes.normal.array):[],c=i.attributes.color?s.hashUtilsCls.hashvalue2array(i.attributes.color.array):[],h=i.index?s.hashUtilsCls.hashvalue2array(i.index.array):[];l=l.concat(e),r=r.concat(d),o=o.concat(c),a=a.concat(h);let p=[],m="CylinderGeometry"==i.type?1:0;for(let e=0,t=l.length/3;e0&&(e.dAtoms=t.hashUtilsCls.cloneHash(s)),e.bShowHighlight=!1}e.applyMapCls.removeSurfaces(),e.applyMapCls.applySurfaceOptions(),e.applyMapCls.removeMaps(),e.applyMapCls.applyMapOptions(),e.applyMapCls.removeEmmaps(),e.applyMapCls.applyEmmapOptions(),e.applyMapCls.removePhimaps(),e.axes=[],e.pc1&&e.axesCls.setPc1Axes(),e.drawCls.draw(),e.bShowHighlight=!0,e.opts.rotationcenter="molecule center"}alternateWrapper(){let e=this.icn3d;e.icn3dui,e.bAlternate=!0,this.alternateStructures(),e.bAlternate=!1}}class ct{constructor(e){this.icn3d=e}draw(e){let t=this.icn3d,s=t.icn3dui;if(!t.bRender||t.hAtoms&&0!=Object.keys(t.hAtoms)||(t.hAtoms=s.hashUtilsCls.cloneHash(t.atoms)),t.sceneCls.rebuildScene(),t.bImpo&&t.impostorCls.drawImpostorShader(),t.setColorCls.applyPrevColor(),void 0!==t.biomtMatrices&&t.biomtMatrices.length>1)if(t.bAssembly&&1==Object.keys(t.structures).length&&(void 0===s.cfg.mmdbid&&1==s.cfg.bu||void 0!==s.cfg.mmdbid&&1==s.cfg.bu&&Object.keys(t.atoms).length*t.biomtMatrices.length>t.maxatomcnt))t.instancingCls.drawSymmetryMates();else{let e=!0;t.applyCenterCls.centerSelection(void 0,e)}let i=void 0!==t.hAtoms?Object.keys(t.hAtoms).length:0;if(i>0&&i0){e.children[0].scale.z=t[0].distance,t[0].point.sub(r.mdl.position);let s=r.rayThreshold,i=r.rayCls.getAtomsFromPosition(t[0].point,s);for(;!i&&s<10;)s+=.5,i=r.rayCls.getAtomsFromPosition(t[0].point,s);i&&(r.pAtom=i,this.showPickingVr(r.pk,i))}}}}catch(e){}}showPickingVr(e,t){let s=this.icn3d;if(s.icn3dui,e||(e=2),1===e)s.hAtoms[t.serial]=1;else if(2===e){let e=t.structure+"_"+t.chain+"_"+t.resi;s.hAtoms=s.residues[e]}else if(3===e)s.hAtoms=s.pickingCls.selectStrandHelixFromAtom(t);else if(4===e)s.hAtoms=s.pickingCls.select3ddomainFromAtom(t);else if(5===e){let e=t.structure+"_"+t.chain;s.hAtoms=s.chains[e]}2===e?s.residueLabelsCls.addResidueLabels(s.hAtoms,void 0,void 0,!0):1===e&&s.residueLabelsCls.addAtomLabels(atoms),s.setOptionCls.setStyle("proteins",t.style)}render_base(){let e=this.icn3d,t=e.icn3dui,s=this;if(t.bNode)return;let i=e.bControlGl&&!t.bNode?window.cam:e.cam;if(e.directionalLight){let t=new THREE.Quaternion;t.setFromUnitVectors(new THREE.Vector3(0,0,e.cam_z).normalize(),i.position.clone().normalize()),e.directionalLight.position.copy(e.lightPos.clone().applyQuaternion(t).normalize()),e.directionalLight2.position.copy(e.lightPos2.clone().applyQuaternion(t).normalize()),e.directionalLight3.position.copy(e.lightPos3.clone().applyQuaternion(t).normalize())}if(e.bVr||e.renderer.setPixelRatio(window.devicePixelRatio),e.bVr){let t=.04;if(e.controllers){let i=this.updateGamepadState();for(let n=0,l=e.controllers.length;n{const i=e.gamepad.axes;let r=parseInt(1e3*i[t]),o=parseInt(-1e3*i[s]);n.push(r),l.push(o)})),{xArray:n,yArray:l}}return{xArray:[0,0],yArray:[0,0]}}}class ht{constructor(e){this.icn3d=e}getAtomsWithinAtom(e,t,s,i,n,l,r){let o=this.icn3d;o.icn3dui;let a=this.getNeighboringAtoms(e,t,s,r);i&&(o.resid2Residhash={});let d={};for(let e in t){let c,h,p=o.atoms[e],m=p.structure+"_"+p.chain+"_"+p.resi;for(let e in o.residues[m])if(o.atoms[e]&&("CA"===o.atoms[e].name&&"C"===o.atoms[e].elem||"O3'"===o.atoms[e].name||"O3*"===o.atoms[e].name)){c=o.atoms[e];break}void 0===c&&(c=p),i&&(h=p.resn+" $"+p.structure+"."+p.chain+":"+p.resi,void 0===o.resid2Residhash[h]&&(o.resid2Residhash[h]={}));let u=p.structure+"_"+p.chain+"_"+p.resi;for(let e in a){let m=a[e];if(!o.crossstrucinter&&p.structure!=m.structure)continue;if(!r&&m.serial in t)continue;if(o.bOpm&&"DUM"===m.resn)continue;let g=m.coord.distanceTo(p.coord);if(go?r:o,d=Math.sqrt(a),c=(d+s)*(d+s),h={};for(let r in e){let e=n.atoms[r];!i&&t.hasOwnProperty(e.serial)||(this.bOpm&&"DUM"===e.resn||e.coord.xl[1][0]+s||e.coord.yl[1][1]+s||e.coord.zl[1][2]+s||(e.coord.x-l[2][0])*(e.coord.x-l[2][0])+(e.coord.y-l[2][1])*(e.coord.y-l[2][1])+(e.coord.z-l[2][2])*(e.coord.z-l[2][2])e.coord.x?n:e.coord.x,l=l>e.coord.y?l:e.coord.y,r=r>e.coord.z?r:e.coord.z}return[[t,s,i],[n,l,r],[o/c,a/c,d/c]]}hideContact(){let e=this.icn3d;e.icn3dui,e.opts.contact="no",void 0===e.lines&&(e.lines={}),e.lines.contact=[],e.contactpnts=[];for(let t in e.atoms)e.atoms[t].style2="nothing";for(let t in e.sidec)e.hAtoms.hasOwnProperty(t)&&(e.atoms[t].style2=e.opts.sidec);for(let t in e.water)e.hAtoms.hasOwnProperty(t)&&(e.atoms[t].style=e.opts.water)}}class pt{constructor(e){this.icn3d=e}isHbondDonorAcceptor(e){let t=this.icn3d;if(t.icn3dui,"N"==e.name&&!e.het||"N"==e.elem&&"Arg"==e.resn||"N"==e.elem&&"Asn"==e.resn||"N"==e.elem&&"Gln"==e.resn||"N"==e.elem&&"Lys"==e.resn||"N"==e.elem&&"Trp"==e.resn)return"donor";if("O"==e.name&&!e.het||"S"==e.elem&&"Met"==e.resn||"O"==e.elem&&"Asn"==e.resn||"O"==e.elem&&"Asp"==e.resn||"O"==e.elem&&"Gln"==e.resn||"O"==e.elem&&"Glu"==e.resn)return"acceptor";if("S"==e.elem&&"Cys"==e.resn||"N"==e.elem&&"His"==e.resn||"O"==e.elem&&"Ser"==e.resn||"O"==e.elem&&"Thr"==e.resn||"O"==e.elem&&"Tyr"==e.resn)return"both";if("Pro"==e.resn)return"none";if("N"==e.elem){if("Asn"==e.resn||"Gln"==e.resn)return"both";let s=0,i=0;for(let i=0,n=e.bonds.length;i1?"ring":"donor":"none"}if("O"==e.elem&&1==e.bonds.length){if("Asn"==e.resn||"Gln"==e.resn)return"both";for(let s=0,i=e.bonds.length;s=2?"acceptor":"both"}if("O"==e.elem&&2==e.bonds.length){for(let s=0,i=e.bonds.length;s1);++t)"H"!=s.atoms[e.bonds[t]].elem&&(i=s.atoms[e.bonds[t]],l[r++].subVectors(s.atoms[e.bonds[t]].coord,e.coord));if(1===r)for(let t=0,n=i.bonds.length;t1);++t)"H"!=s.atoms[i.bonds[t]].elem&&s.atoms[i.bonds[t]].serial!=e.serial&&l[r++].subVectors(s.atoms[i.bonds[t]].coord,e.coord);if(2!==r)return;let o=l[0].cross(l[1]);return Math.abs(Math.PI/2-o.angleTo(n))}isValidHbond(e,t,s){let i=this.icn3d;i.icn3dui;let n,l,r=this.isHbondDonorAcceptor(e),o=this.isHbondDonorAcceptor(t),a=50*Math.PI/180,d=50*Math.PI/180,c=90*Math.PI/180,h=30*Math.PI/180;if("donor"==r&&("acceptor"==o||"both"==o||"ring"==o)||"acceptor"==o&&("donor"==r||"both"==r||"ring"==r))n=e,l=t;else if("acceptor"==r&&("donor"==o||"both"==o||"ring"==o)||"donor"==o&&("acceptor"==r||"both"==r||"ring"==r))l=e,n=t;else{if("both"!=r&&"ring"!=r||"both"!=o&&"ring"!=o)return!1;n=e,l=t,i.nucleotides.hasOwnProperty(e.serial)&&i.nucleotides.hasOwnProperty(t.serial)&&("ring"==r||"ring"==o)||(e.het||t.het)&&"ring"==r&&"ring"==o||(h=90*Math.PI/180)}let p=this.calcAngles(n,l),m=90*Math.PI/180;for(let e=0,t=p.length;ed)return!1;let u=this.calcPlaneAngle(n,l);if(void 0!==u&&u>h)return!1;let g=this.calcAngles(l,n),f=90*Math.PI/180;for(let e=0,t=g.length;ea)return!1;let b=this.calcPlaneAngle(l,n);return!(void 0!==b&&b>c)}calculateChemicalHbonds(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(0===Object.keys(e).length||0===Object.keys(t).length)return;r.resid2Residhash={};let a,d,c={},h=s*s;for(let t in e){let s=e[t],n=i?"LYS"===s.resn&&"N"===s.elem&&"N"!==s.name||"ARG"===s.resn&&("NH1"===s.name||"NH2"===s.name)||("GLU"===s.resn||"ASP"===s.resn)&&"O"===s.elem&&"O"!==s.name||s.het&&("N"===s.elem||"O"===s.elem||"S"===s.elem):"N"===s.elem||"O"===s.elem||"S"===s.elem&&(s.het||"Cys"===s.resn||"Met"===s.resn);n=r.bOpm?n&&"DUM"!==s.resn:n,n&&(a=s.structure+"_"+s.chain+"_"+s.resi,d=a+"_"+s.name,c[d]=s)}let p={},m={},u=.5,g=-27.888,f={};for(let e in t){let b=t[e],C=i?"LYS"===b.resn&&"N"===b.elem&&"N"!==b.name||"ARG"===b.resn&&("NH1"===b.name||"NH2"===b.name)||("GLU"===b.resn||"ASP"===b.resn)&&"O"===b.elem&&"O"!==b.name||b.het&&("N"===b.elem||"O"===b.elem||"S"===b.elem):"N"===b.elem||"O"===b.elem||"S"===b.elem&&(b.het||"Cys"===b.resn||"Met"===b.resn);if(C=r.bOpm?C&&"DUM"!==b.resn:C,C){a=b.structure+"_"+b.chain+"_"+b.resi,d=a+"_"+b.name;let e=b.resn+" $"+b.structure+"."+b.chain+":"+b.resi+"@"+b.name;void 0===r.resid2Residhash[e]&&(r.resid2Residhash[e]={});for(let t in c){if(i&&!(("LYS"!==b.resn&&"ARG"!==b.resn||"LYS"!==c[t].resn&&"ARG"!==c[t].resn)&&("GLU"!==b.resn&&"ASP"!==b.resn||"GLU"!==c[t].resn&&"ASP"!==c[t].resn)))continue;if(!r.crossstrucinter&&b.structure!=c[t].structure)continue;if(a==t.substr(0,t.lastIndexOf("_")))continue;let d=Math.abs(b.coord.x-c[t].coord.x);if(d>s)continue;let C=Math.abs(b.coord.y-c[t].coord.y);if(C>s)continue;let y=Math.abs(b.coord.z-c[t].coord.z);if(y>s)continue;let v=d*d+C*C+y*y;if(v>h)continue;if(!r.proteins.hasOwnProperty(b.serial)||!r.proteins.hasOwnProperty(c[t].serial)||"N"!==b.name&&"O"!==b.name||"O"!==c[t].name&&"N"!==c[t].name){if(!this.isValidHbond(b,c[t],s))continue}else{if(b.name===c[t].name)continue;if(b.structure==c[t].structure&&b.chain==c[t].chain&&Math.abs(b.resi-c[t].resi)<=1)continue;let e,i="N"===b.name?b:c[t],n="O"===b.name?b:c[t];if("Pro"===i.resn)continue;if(void 0===i.hcoord){if(!this.isValidHbond(b,c[t],s))continue}else{let s,l=i.hcoord,o=i.coord,a=n.structure+"_"+n.chain+"_"+n.resi;for(let e in r.residues[a])if("C"===r.atoms[e].name){s=r.atoms[e];break}if(!s)continue;let d=s.coord,h=n.coord,p=l.distanceTo(h),m=l.distanceTo(d),f=o.distanceTo(d),C=o.distanceTo(h);e=p2||f[c[t].serial]>2)continue;void 0===f[b.serial]?f[b.serial]=1:++f[b.serial],void 0===f[c[t].serial]?f[c[t].serial]=1:++f[c[t].serial],"graph"!==n&&(i?(r.saltbridgepnts.push({serial:b.serial,coord:b.coord}),r.saltbridgepnts.push({serial:c[t].serial,coord:c[t].coord})):(r.hbondpnts.push({serial:b.serial,coord:b.coord}),r.hbondpnts.push({serial:c[t].serial,coord:c[t].coord})));let w=c[t].structure+"_"+c[t].chain+"_"+c[t].resi;p=o.hashUtilsCls.unionHash(p,r.residues[a]),p=o.hashUtilsCls.unionHash(p,r.residues[w]),m[a]=1,m[w]=1;let _=c[t].resn+" $"+c[t].structure+"."+c[t].chain+":"+c[t].resi+"@"+c[t].name,S=a+"_"+b.resn+","+w+"_"+c[t].resn;void 0!==r.resids2interAll[S]&&void 0!==r.resids2interAll[S].ionic&&r.resids2interAll[S].ionic.hasOwnProperty(e+","+_)||(r.resid2Residhash[e][_]=v.toFixed(1),l||(void 0===r.resids2inter[S]&&(r.resids2inter[S]={}),void 0===r.resids2inter[S].hbond&&(r.resids2inter[S].hbond={}),r.resids2inter[S].hbond[e+","+_]=v.toFixed(1)),void 0===r.resids2interAll[S]&&(r.resids2interAll[S]={}),void 0===r.resids2interAll[S].hbond&&(r.resids2interAll[S].hbond={}),r.resids2interAll[S].hbond[e+","+_]=v.toFixed(1))}}}let b=Object.keys(m);if("graph"!==n)for(let e=0,t=b.length;en)return!1;let c=Math.abs(e.coord.y-t.coord.y);if(c>n)return!1;let h=Math.abs(e.coord.z-t.coord.z);if(h>n)return!1;let p=d*d+c*c+h*h;if(p>l)return!1;"graph"!==s&&("halogen"==i?(a.halogenpnts.push({serial:e.serial,coord:e.coord}),a.halogenpnts.push({serial:t.serial,coord:t.coord})):"pi-cation"==i?(a.picationpnts.push({serial:e.serial,coord:e.coord}),a.picationpnts.push({serial:t.serial,coord:t.coord})):"pi-stacking"==i&&(a.pistackingpnts.push({serial:e.serial,coord:e.coord}),a.pistackingpnts.push({serial:t.serial,coord:t.coord})));let m=t.resn+" $"+t.structure+"."+t.chain+":"+t.resi+"@"+t.name;a.resid2Residhash[r][m]=p.toFixed(1);let u=e.structure+"_"+e.chain+"_"+e.resi+"_"+e.resn+","+t.structure+"_"+t.chain+"_"+t.resi+"_"+t.resn;return o||(void 0===a.resids2inter[u]&&(a.resids2inter[u]={}),void 0===a.resids2inter[u][i]&&(a.resids2inter[u][i]={}),a.resids2inter[u][i][r+","+m]=p.toFixed(1)),void 0===a.resids2interAll[u]&&(a.resids2interAll[u]={}),void 0===a.resids2interAll[u][i]&&(a.resids2interAll[u][i]={}),a.resids2interAll[u][i][r+","+m]=p.toFixed(1),!0}getRingNormal(e){if(this.icn3d.icn3dui,e.length<3)return;let t=e[0].clone().sub(e[1]),s=e[1].clone().sub(e[2]);return t.cross(s).normalize()}getAromaticRings(e,t,s){let i=this.icn3d;i.icn3dui;let n=[],l=[],r=[],o=[];if("nucleotide"==s){let s=new THREE.Vector3,a=new THREE.Vector3;if("A"==e.trim().toUpperCase()||"DA"==e.trim().toUpperCase()||"G"==e.trim().toUpperCase()||"DG"==e.trim().toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"N1"==t.name||"C2"==t.name||"N3"==t.name||"C6"==t.name?(s.add(t.coord),r.push(t.coord)):"C4"==t.name||"C5"==t.name?(s.add(t.coord),a.add(t.coord),r.push(t.coord),o.push(t.coord)):"N7"!=t.name&&"C8"!=t.name&&"N9"!=t.name||(a.add(t.coord),o.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r))),5==o.length&&(a.multiplyScalar(.2),n.push(a),l.push(this.getRingNormal(o)))}else if("C"==e.trim().toUpperCase()||"DC"==e.trim().toUpperCase()||"T"==e.trim().toUpperCase()||"DT"==e.trim().toUpperCase()||"U"==e.trim().toUpperCase()||"DU"==e.trim().toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"N1"==t.name||"C2"==t.name||"N3"==t.name||"C6"==t.name?(s.add(t.coord),r.push(t.coord)):"C4"!=t.name&&"C5"!=t.name||(s.add(t.coord),r.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r)))}}else if("protein"==s){let s=new THREE.Vector3,a=new THREE.Vector3;if("PHE"==e.toUpperCase()||"TYR"==e.toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"CG"!=t.name&&"CD1"!=t.name&&"CE1"!=t.name&&"CZ"!=t.name&&"CE2"!=t.name&&"CD2"!=t.name||(s.add(t.coord),r.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r)))}else if("HIS"==e.toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"CG"!=t.name&&"ND1"!=t.name&&"CE1"!=t.name&&"NE2"!=t.name&&"CD2"!=t.name||(s.add(t.coord),r.push(t.coord))}5==r.length&&(s.multiplyScalar(.2),n.push(s),l.push(this.getRingNormal(r)))}else if("TRP"==e.toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"CZ2"==t.name||"CH2"==t.name||"CZ3"==t.name||"CE3"==t.name?(s.add(t.coord),r.push(t.coord)):"CD2"==t.name||"CE2"==t.name?(s.add(t.coord),a.add(t.coord),r.push(t.coord),o.push(t.coord)):"CG"!=t.name&&"CD1"!=t.name&&"NE1"!=t.name||(a.add(t.coord),o.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r))),5==o.length&&(a.multiplyScalar(.2),n.push(a),l.push(this.getRingNormal(o)))}}return{piPosArray:n,normalArray:l}}dfs_cycle(e,t,s){let i=this.icn3d;if(i.icn3dui,2==i.ring_color[e])return s;if(1==i.ring_color[e]){s++;let n=t;for(i.ring_mark[n]=s;n!=e;)n=i.ring_par[n],i.ring_mark[n]=s;return s}if(i.ring_par[e]=t,i.ring_color[e]=1,void 0!==i.atoms[e])for(let t=0,n=i.atoms[e].bonds.length;t=3&&o<=6&&a[0]&&a[1]&&a[2]&&a[3]){let i=a[0].clone().sub(a[1]).normalize(),r=a[1].clone().sub(a[2]).normalize(),d=a[2].clone().sub(a[3]).normalize(),c=i.cross(r).normalize(),h=c.dot(d);if(Math.abs(h)<.052){l.multiplyScalar(1/o);let i=t.atoms[n];s[e+"_pi"+n]={resn:i.resn,name:"pi"+n,coord:l,serial:i.serial,structure:i.structure,chain:i.chain,resi:i.resi,normal:c}}}}return s}hideHalogenPi(){let e=this.icn3d;e.icn3dui,e.opts.halogen="no",e.opts["pi-cation"]="no",e.opts["pi-stacking"]="no",void 0===e.lines&&(e.lines={}),e.lines.halogen=[],e.lines["pi-cation"]=[],e.lines["pi-stacking"]=[],e.halogenpnts=[],e.picationpnts=[],e.pistackingpnts=[];for(let t in e.atoms)e.atoms[t].style2="nothing";for(let t in e.sidec)e.hAtoms.hasOwnProperty(t)&&(e.atoms[t].style2=e.opts.sidec);for(let t in e.water)e.hAtoms.hasOwnProperty(t)&&(e.atoms[t].style=e.opts.water)}}class ut{constructor(e){this.icn3d=e}calculateIonicInteractions(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(0===Object.keys(e).length||0===Object.keys(t).length)return;r.resid2Residhash={};let a,d,c={},h={},p=s*s;for(let t in e){let s=e[t];if("ARG"===s.resn&&"NH2"===s.name||"GLU"===s.resn&&"OE2"===s.name||"ASP"===s.resn&&"OD2"===s.name)continue;let i=("LYS"===s.resn||"HIS"===s.resn)&&"N"===s.elem&&"N"!==s.name||"ARG"===s.resn&&("NH1"===s.name||"NH2"===s.name)||s.het&&-1!==o.parasCls.cationsTrimArray.indexOf(s.elem)||s.het&&"N"===s.elem&&1==s.bonds.length,n=this.isAnion(s);i=r.bOpm?i&&"DUM"!==s.resn:i,n=r.bOpm?n&&"DUM"!==s.resn:n,(i||n)&&(a=s.structure+"_"+s.chain+"_"+s.resi,d=a+"_"+s.name,i&&(c[d]=s),n&&(h[d]=s))}let m={},u={};for(let e in t){let i=t[e];if("ARG"===i.resn&&"NH2"===i.name||"GLU"===i.resn&&"OE2"===i.name||"ASP"===i.resn&&"OD2"===i.name)continue;let g=("LYS"===i.resn||"HIS"===i.resn)&&"N"===i.elem&&"N"!==i.name||"ARG"===i.resn&&("NH1"===i.name||"NH2"===i.name)||i.het&&-1!==o.parasCls.cationsTrimArray.indexOf(i.elem),f=this.isAnion(i);if(g=r.bOpm?g&&"DUM"!==i.resn:g,f=r.bOpm?f&&"DUM"!==i.resn:f,g||f){a=i.structure+"_"+i.chain+"_"+i.resi,d=a+"_"+i.name;let e=i.resn+" $"+i.structure+"."+i.chain+":"+i.resi+"@"+i.name;void 0===r.resid2Residhash[e]&&(r.resid2Residhash[e]={});let t={};g?t=h:f&&(t=c);let b,C=i.structure+"_"+i.chain+"_"+i.resi;g&&"ARG"===i.resn&&"NH1"===i.name?b=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[C],"NH2"):f&&"GLU"===i.resn&&"OE1"===i.name?b=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[C],"OE2"):f&&"ASP"===i.resn&&"OD1"===i.name&&(b=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[C],"OD2"));let y=void 0===b?i.coord:i.coord.clone().add(b.coord).multiplyScalar(.5);for(let d in t){if(a==d.substr(0,d.lastIndexOf("_")))continue;if(!r.crossstrucinter&&i.structure!=t[d].structure)continue;let c,h=t[d].structure+"_"+t[d].chain+"_"+t[d].resi;f&&"ARG"===t[d].resn&&"NH1"===t[d].name?c=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[h],"NH2"):g&&"GLU"===t[d].resn&&"OE1"===t[d].name?c=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[h],"OE2"):g&&"ASP"===t[d].resn&&"OD1"===t[d].name&&(c=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[h],"OD2"));let b=void 0===c?t[d].coord:t[d].coord.clone().add(c.coord).multiplyScalar(.5),C=Math.abs(y.x-b.x);if(C>s)continue;let v=Math.abs(y.y-b.y);if(v>s)continue;let w=Math.abs(y.z-b.z);if(w>s)continue;let _=C*C+v*v+w*w;if(_>p)continue;"graph"!==n&&(r.saltbridgepnts.push({serial:i.serial,coord:y}),r.saltbridgepnts.push({serial:t[d].serial,coord:b}));let S=t[d].structure+"_"+t[d].chain+"_"+t[d].resi;m=o.hashUtilsCls.unionHash(m,r.residues[a]),m=o.hashUtilsCls.unionHash(m,r.residues[S]),u[a]=1,u[S]=1;let A=t[d].resn+" $"+t[d].structure+"."+t[d].chain+":"+t[d].resi+"@"+t[d].name;r.resid2Residhash[e][A]=_.toFixed(1);let x=a+"_"+i.resn+","+S+"_"+t[d].resn;l||(void 0===r.resids2inter[x]&&(r.resids2inter[x]={}),void 0===r.resids2inter[x].ionic&&(r.resids2inter[x].ionic={}),r.resids2inter[x].ionic[e+","+A]=_.toFixed(1)),void 0===r.resids2interAll[x]&&(r.resids2interAll[x]={}),void 0===r.resids2interAll[x].ionic&&(r.resids2interAll[x].ionic={}),r.resids2interAll[x].ionic[e+","+A]=_.toFixed(1)}}}let g=Object.keys(u);if("graph"!==n)for(let e=0,t=g.length;e1?1/(n-1):1;for(let n in e){let e=t.atoms[n];e.color=e.het?s.parasCls.atomColors[e.elem]||s.parasCls.defaultAtomColor:s.parasCls.thr().setHSL(3/4*(1-i++*l),1,.45),t.atomPrevColors[n]=e.color}}colorRainbow(e){let t=this.icn3d,s=t.icn3dui,i=0,n=0;e=s.hashUtilsCls.intHash(e,t.hAtoms);for(let s in e){t.atoms[s].het||++n}let l=n>1?1/(n-1):1;for(let n in e){let e=t.atoms[n];e.color=e.het?s.parasCls.atomColors[e.elem]||s.parasCls.defaultAtomColor:s.parasCls.thr().setHSL(3/4*i++*l,1,.45),t.atomPrevColors[n]=e.color}}setColorAcrossSets(e,t){let s=this.icn3d,i=s.icn3dui,n=0,l=e.length,r=l>1?1/(l-1):1;for(let l=0,o=e.length;l0)this.setMmdbChainColor();else{let e=-1,s="",l=n.parasCls.stdChainColors.length;for(let r in t){let t=i.atoms[r];t.chain!=s&&(++e,e%=l),t.het?(t.color=n.parasCls.atomColors[t.elem],i.atomPrevColors[r]=t.color):(t.color=n.parasCls.stdChainColors[e],Object.keys(i.chainsColor).length>0&&this.updateChainsColor(t),i.atomPrevColors[r]=t.color),s=t.chain}}break;case"domain":s=0,l=0;let m=Object.keys(i.tddomains);l=m.length,r=l>1?1/(l-1):1;for(let e=0,t=m.length;e1?1/(l-1):1;for(let e=0;e Defined Sets", and try it again.');break;case"secondary structure green":i.sheetcolor="green";for(let e in t){let t=i.atoms[e];t.color=t.het?n.parasCls.atomColors[t.elem]||n.parasCls.defaultAtomColor:n.parasCls.ssColors[t.ss]||n.parasCls.thr(16711935),i.atomPrevColors[e]=t.color}break;case"secondary structure yellow":case"secondary structure":i.sheetcolor="yellow";for(let e in t){let t=i.atoms[e];t.color=t.het?n.parasCls.atomColors[t.elem]||n.parasCls.defaultAtomColor:n.parasCls.ssColors2[t.ss]||n.parasCls.thr(16711935),i.atomPrevColors[e]=t.color}break;case"secondary structure spectrum":s=0,l=0;let u,g,f=[],b=-9999;for(let e in t){if(!i.proteins.hasOwnProperty(e))continue;let t=i.atoms[e];-9999==b&&(u=parseInt(e)),-9999!=b&&(t.ss!=g.ss||Math.abs(t.resi-g.resi)>1||t.ssbegin&&g.ssend)&&("coil"==g.ss||f.push([u,b]),u=e),b=parseInt(e),g=t}"coil"==g.ss||f.push([u,b]),l=f.length,r=l>1?1/(l-1):1;for(let e=0,t=f.length;e100&&(e=100);let r=(i.middB-e)*i.spanBinv1,o=(e-i.middB)*i.spanBinv2;e=90?t.color=n.parasCls.thr().setRGB(0,.325,.839):e>=70&&e<90?t.color=n.parasCls.thr().setRGB(.396,.572,.953):e>=50&&e<70?t.color=n.parasCls.thr().setRGB(1,.859,.075):e<50&&(t.color=n.parasCls.thr().setRGB(1,.49,.271))}i.atomPrevColors[e]=t.color}break;case"b factor":i.middB=50,i.spanBinv1=.02,i.spanBinv2=.02;for(let e in t){let t=i.atoms[e];if(void 0===t.b||isNaN(t.b)||0==parseInt(1e3*t.b))t.color=n.parasCls.thr().setRGB(0,1,0);else{let e=t.b;e>100&&(e=100),e=t.structure.substr(0,4)!=i.defaultPdbId&&t.structure.length>5?100-e:e;let s=(i.middB-e)*i.spanBinv1,l=(e-i.middB)*i.spanBinv2;t.color=et.b&&(o=t.b),a5?100-t.b:t.b,s=i.bfactorArray.indexOf(e)/C;t.color=s<.5?n.parasCls.thr().setRGB(2*s,2*s,1):n.parasCls.thr().setRGB(1,2*(1-s),2*(1-s))}i.atomPrevColors[e]=t.color}break;case"area":if(void 0===i.resid2area){let e=n.hashUtilsCls.cloneHash(i.hAtoms);i.hAtoms=n.hashUtilsCls.cloneHash(i.atoms),i.bCalcArea=!0,i.opts.surface="solvent accessible surface",i.applyMapCls.applySurfaceOptions(),i.bCalcArea=!1,i.hAtoms=n.hashUtilsCls.cloneHash(e)}let y=void 0!==i.midpercent?i.midpercent:35;i.spanBinv1=.02,i.spanBinv2=.02;for(let e in t){let t=i.atoms[e],s=t.structure+"_"+t.chain+"_"+t.resi+"_"+t.resn,l=n.parasCls.residueArea.hasOwnProperty(t.resn)?i.resid2area[s]/n.parasCls.residueArea[t.resn]*100:y;l>100&&(l=100);let r=(y-l)*i.spanBinv1,o=(l-y)*i.spanBinv2;t.color=l

    ";if("atom"==e){let e=["proteins","nucleotides","chemicals","ions","water"];for(let i=0,n=e.length;i[e,s.parasCls.hydrophobicValues[e]]));r.sort(((e,t)=>parseFloat(e[1])-parseFloat(t[1])));var o=r.map((e=>[e[0],Object.keys(n[e[0]])[0]]));l+="
    ","normalized hydrophobic"==e?(l+="Dark green (W, F, Y, L, I, C, M): Hydrophobic
    ",l+="Light green (G, V, S, T, A, N, P, Q): Polar
    ",l+="Grey: Charged, not hydrophobic

    "):(l+="Green (W, F, Y, L, I, C, M): Hydrophobic
    ",l+="Yellow (G, V, S, T, A, N, P, Q): Polar
    ",l+="Red: Negatively Charged
    ",l+="Blue: Positively Charged

    ");let a=0;for(let e of o)s.parasCls.residueAbbrev[e[0]]&&(l+="
    ",l+="
    ",l+=s.parasCls.residueAbbrev[e[0]]+"
    ",a%4==3&&(l+="
    "),++a);l+="
    "}else"b factor"==e?(l+="
    B factor quantitates the uncertainty for each atom. A high B factor reflects that the position is less certain.

    ",l+=s.htmlCls.clickMenuCls.setLegendHtml()):"confidence"==e?l+=s.htmlCls.clickMenuCls.setLegendHtml(!0):(l="",i=!0);$("#"+s.pre+"dl_legend").html(l),s.htmlCls.dialogCls.openDlg("dl_legend","Color Legend"),i&&window.dialog&&window.dialog.dialog("close")}getColorLegendForElem(e,t){let s=this.icn3d,i=s.icn3dui,n="",l={};for(let e in t){let t=s.atoms[e],i=void 0===t||void 0===t.color||"FFFFFF"===t.color.getHexString().toUpperCase()?"DDDDDD":t.color.getHexString();void 0===l[t.elem]&&(l[t.elem]={}),l[t.elem][i]=1}if(Object.keys(l).length>0){n+=""+e+"
    ";let t=Object.keys(l).sort();for(let e=0,s=t.length;e";for(let e in l[s])n+="
    ";n+=i.parasCls.atomnames[s.toUpperCase()]+"

    "}n+="
    "}return n}getRes2color(e,t){let s=this.icn3d,i=s.icn3dui,n={},l=s.firstAtomObjCls.getResiduesFromAtoms(e);for(let e in l){let l=s.residues[e],r=s.firstAtomObjCls.getFirstAtomObj(l),o=t?r.resn:i.parasCls.residueAbbrev[r.resn],a=void 0===r||void 0===r.color||"FFFFFF"===r.color.getHexString().toUpperCase()?"DDDDDD":r.color.getHexString();null!=o&&(void 0===n[o]&&(n[o]={}),n[o][a]=1)}return n}getColorLegendForResidue(e){this.icn3d.icn3dui;let t="",s=this.getRes2color(e);if(Object.keys(s).length>0){t+="
    ";let e=Object.keys(s).sort(),i="",n=0;for(let l=0,r=e.length;l";for(let e in s[o])r+="
    ";r+=o+"
    ",n%4==3&&(r+="
    "),-1!=o.indexOf("(")?(t+=r,++n):i+=r}i&&(t+="
    "+i),t+="
    "}return t}getColorLegendForCharge(e){let t=this.icn3d;t.icn3dui;let s="",i=t.firstAtomObjCls.getResiduesFromAtoms(e),n={};for(let e in i){let s=t.residues[e],i=t.firstAtomObjCls.getFirstAtomObj(s);"ARG"==i.resn||"LYS"==i.resn?n.Positive=1:"HIS"==i.resn?n["Partial-Positive"]=1:"ASP"==i.resn||"GLU"==i.resn||t.nucleotides[i.serial]?n.Negative=1:n.Neutral=1}const l={Positive:"0000ff","Partial-Positive":"8080ff",Negative:"ff0000",Neutral:"888888"};let r=["Positive","Partial-Positive","Negative","Neutral"];s+="
    ";for(let e=0,t=r.length;e",s+="
    ",s+=t,s+="
    ")}return s+="
    (Charges are at pH 7)",s+="
    ",s}getColorLegendForIgstrand(e){this.icn3d.icn3dui;let t="";const s={"A^ Strand":"FF00FF","A Strand":"663399","A* Strand":"FFC0CB","A Strand":"9370db","B Strand":"ba55d3","C Strand":"0000FF","C' Strand":"6495ED","C'' Strand":"006400","D Strand":"00FF00","E Strand":"FFFF00","F Strand":"FFA500","G Strand":"FF0000","G* Strand":"8B0000",Loop:"CCCCCC"};t+="
    ";for(let e in s){t+="",t+="
    ",t+=e,t+="

    "}return t+="
    ",t}}class yt{constructor(e){this.icn3d=e}async showCddSiteAll(){let e=this.icn3d,t=e.icn3dui,s=this;e.chainid2pssmid={};let i=$.map(e.protein_chainid,(function(e){return e})),n=Object.keys(e.protein_chainid),l="https://www.ncbi.nlm.nih.gov/Structure/cdannots/cdannots.fcgi?fmt&frclive&live=lcl&queries="+i;if(1==Object.keys(e.structures).length&&(t.cfg.mmtfid||t.cfg.pdbid||t.cfg.opmid||t.cfg.mmdbid||t.cfg.gi||t.cfg.uniprotid||t.cfg.blast_rep_id||t.cfg.cid||t.cfg.mmcifid)||2==Object.keys(e.structures).length&&t.cfg.align){let e={};try{e.value=await t.getAjaxPromise(l,"jsonp"),s.parseCddData([e],n)}catch(e){return void s.getNoCdd(i)}}else{let i=[];for(let s=0,r=n.length;s',p=h,m=h,u=d.doms;n.bNode&&!i.resid2cdd[c]&&(i.resid2cdd[c]=[]);let g=l.setDomainFeature(u,c,!0,h,p,m);i.chainid2pssmid[c]={pssmid2name:g.pssmid2name,pssmid2fromArray:g.pssmid2fromArray,pssmid2toArray:g.pssmid2toArray};let f=g.acc2domain;h=g.html+"",p=g.html2+"",m=g.html3+"",$("#"+i.pre+"dt_cdd_"+c).html(h),$("#"+i.pre+"ov_cdd_"+c).html(p),$("#"+i.pre+"tt_cdd_"+c).html(m),h='
    ',p=h,m=h;let b=d.motifs;n.bNode&&!i.resid2site[c]&&(i.resid2site[c]=[]),g=l.setDomainFeature(b,c,!1,h,p,m,f),h=g.html,p=g.html2,m=g.html3;let C=a.data[e].sites,y=void 0!==C?C.length:0;for(let e=0;e17&&(s=s.substr(0,17)+"...");let l,r=C[e].title,o=[];for(let t=0,s=C[e].locs.length;t'+s+"
    ",u=''+t.toString()+" Res",g='';m+=d+u+"
    ",h+=d+u+g,p+=d+u+g;let f="site"+e.toString(),b=0,y=0,v=1;for(let t=0,s=i.giSeq[c].length;t1&&(l=s[0]+"..");let r=i.ParserUtilsCls.getResi(c,t);if(h+=''+s+"",n.bNode){let t={};t[c+"_"+r]="site: "+C[e].title,i.resid2site[c].push(t)}p+=i.showSeqCls.insertGapOverview(c,t);let o=n.cfg.blast_rep_id==c?Math.round(i.seqAnnWidth*t/(i.maxAnnoLength+i.nTotalGap)-b-y):Math.round(i.seqAnnWidth*t/i.maxAnnoLength-b-y);o>=0&&(p+='
     
    ',p+='
     
    ',b+=o,y+=v)}else h+="-";g=' '+t.toString()+" Residues",g+="
    ",g+="
    ",h+=g,p+=g}h+="",p+="",m+="",$("#"+i.pre+"dt_site_"+c).html(h),$("#"+i.pre+"ov_site_"+c).html(p),$("#"+i.pre+"tt_site_"+c).html(m)}}for(let e in i.protein_chainid)r.hasOwnProperty(e)||($("#"+i.pre+"dt_cdd_"+e).html(""),$("#"+i.pre+"ov_cdd_"+e).html(""),$("#"+i.pre+"tt_cdd_"+e).html(""),$("#"+i.pre+"dt_site_"+e).html(""),$("#"+i.pre+"ov_site_"+e).html(""),$("#"+i.pre+"tt_site_"+e).html(""));i.showAnnoCls.enableHlSeq(),i.bAjaxCddSite=!0}getNoCdd(e){let t=this.icn3d;t.icn3dui,console.log("No CDD data were found for the protein "+e+"...");for(let e in t.protein_chainid)$("#"+t.pre+"dt_cdd_"+e).html(""),$("#"+t.pre+"ov_cdd_"+e).html(""),$("#"+t.pre+"tt_cdd_"+e).html(""),$("#"+t.pre+"dt_site_"+e).html(""),$("#"+t.pre+"ov_site_"+e).html(""),$("#"+t.pre+"tt_site_"+e).html("");t.showAnnoCls.enableHlSeq(),t.bAjaxCddSite=!0}setDomainFeature(e,t,s,i,n,l,r){let o,a,d,c=this.icn3d,h=c.icn3dui;s&&(r={},o={},a={},d={});let p=void 0!==e?e.length:0,m=s?14:19,u=s?100:120;for(let g=0;gm&&(v=v.substr(0,m)+"...");let w=b+": "+C;s&&(o[p]=C);let _=e[g].locs;if(_)for(let e=0,r=_.length;e'+v+" ",E=''+S.toString()+" Res";l+=R+E+"
    ";let I='';i+=R+E+I,s&&(n+='
    '),n+='
    '+v+"
    ",n+=E+I;let T=b+g.toString();for(let e=0,n=c.giSeq[t].length;e1&&(l=n[0]+"..");let r=c.ParserUtilsCls.getResi(t,e);if(i+=''+n+"",h.bNode){let e={};e[t+"_"+r]=w,s?c.resid2cdd[t].push(e):c.resid2site[t].push(e)}}else i+="-";let M=c.firstAtomObjCls.getFirstCalphaAtomObj(c.chains[t]),P=void 0===M.color||"FFFFFF"===M.color.getHexString()?"DDDDDD":M.color.getHexString(),D=void 0!==M.color?P:"CCCCCC";if(h.cfg.blast_rep_id!=t)for(let s=0,i=r.length;s ',n+='
    '+C+"
    "}else{let s=[],i=[];for(let e=0,t=r.length;e ',n+='
    '+C+"
    "}}I=' '+S.toString()+" Residues",I+="
    ",I+="
    ",i+=I,n+=I,s&&(n+='')}}return{html:i,html2:n,html3:l,acc2domain:r,pssmid2name:o,pssmid2fromArray:a,pssmid2toArray:d}}showAnnoType(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui,a='
    ',d=a,c=a;if(0==n.length)return $("#"+r.pre+"dt_"+s+"_"+e).html(""),$("#"+r.pre+"ov_"+s+"_"+e).html(""),void $("#"+r.pre+"tt_"+s+"_"+e).html("");let h=i;i.length>17&&(i=i.substr(0,17)+"...");let p=[];for(let e=0,t=n.length;e'+i+"
    ",f=''+m.toString()+" Res";c+=g+f+"
    ";let b='';a+=g+f+b,d+=g+f+b;let C=s,y=0,v=0;for(let t=0,i=r.giSeq[e].length;t1&&(c=n[0]+"..");let h=i,p=e+"_"+i,m=n+i;if("ssbond"==s){m="Residue "+p+" has disulfide bond with";let t="";if(void 0!==l[p])for(let e=0,s=l[p].length;e'+c+"",d+=r.showSeqCls.insertGapOverview(e,t);let u=o.cfg.blast_rep_id==e?Math.round(r.seqAnnWidth*t/(r.maxAnnoLength+r.nTotalGap)-y-v):Math.round(r.seqAnnWidth*t/r.maxAnnoLength-y-v);u>=0&&(d+='
     
    ',d+='
     
    ',y+=u,v+=1)}else a+="-"}b=' '+m.toString()+" Residues",b+="",b+="
    ",a+=b,d+=b,a+="",d+="",c+="",$("#"+r.pre+"dt_"+s+"_"+e).html(a),$("#"+r.pre+"ov_"+s+"_"+e).html(d),$("#"+r.pre+"tt_"+s+"_"+e).html(c)}setToolTip(){let e=this.icn3d;e.icn3dui,$("[id^="+e.pre+"snp]").add("[id^="+e.pre+"clinvar]").add("[id^="+e.pre+"ssbond]").add("[id^="+e.pre+"crosslink]").tooltip({content:function(){return $(this).prop("title")},show:null,close:function(e,t){t.tooltip.hover((function(){$(this).stop(!0).fadeTo(400,1)}),(function(){$(this).fadeOut("400",(function(){$(this).remove()}))}))}})}}class vt{constructor(e){this.icn3d=e}showInteraction(e,t){this.icn3d.icn3dui,this.showInteraction_base(e,t)}showInteraction_base(e,t){let s=this.icn3d,i=s.icn3dui;i.bNode&&(s.resid2contact||(s.resid2contact={}),s.resid2contact[e]||(s.resid2contact[e]=[])),void 0===s.chainname2residues&&(s.chainname2residues={});let n=Object.keys(s.chains),l=e,r=Math.round(l.indexOf("_"));if(s.firstAtomObjCls.getFirstCalphaAtomObj(s.chains[l]),void 0===s.chainname2residues[l]){s.chainname2residues[l]={};let t=n.length;if(t>100&&void 0===i.cfg.mmdbid&&void 0===i.cfg.gi&&void 0===i.cfg.blast_rep_id&&void 0===i.cfg.align&&void 0===i.cfg.chainalign)return $("#"+s.pre+"dt_interaction_"+e).html(""),void $("#"+s.pre+"ov_interaction_"+e).html("");for(let e=0;e4)continue;let o,a=s.firstAtomObjCls.getFirstCalphaAtomObj(s.chains[t]);s.chemicals.hasOwnProperty(a.serial)?o="chemical":s.nucleotides.hasOwnProperty(a.serial)?o="nucleotide":s.ions.hasOwnProperty(a.serial)?o="ion":s.proteins.hasOwnProperty(a.serial)?o="protein":s.water.hasOwnProperty(a.serial)&&(o="water");let d=s.contactCls.getAtomsWithinAtom(i.hashUtilsCls.hash2Atoms(s.chains[l],s.atoms),i.hashUtilsCls.hash2Atoms(s.chains[t],s.atoms),4);if(0==Object.keys(d).length)continue;let c={};for(let e in d){let t=s.atoms[e];c[t.structure+"_"+t.chain+"_"+t.resi]=1}let h=t.substr(t.indexOf("_")+1)+"("+o+")";s.chainname2residues[l][h]=Object.keys(c)}}let o='
    ',a=o,d=o,c=0;for(let t in s.chainname2residues[e]){let n=s.chainname2residues[e][t];if(!n)continue;let l="Interact ."+t;l.length>17&&(l=l.substr(0,17)+"...");let r="Interact ."+t,h=[];for(let e=0,t=n.length;e'+l+"
    ",g=''+p.toString()+" Res";d+=u+g+"
    ";let f='';o+=u+g+f,a+=u+g+f;let b="inter"+c.toString(),C=0,y=0,v=1;for(let t=0,n=s.giSeq[e].length;t1&&(d=l[0]+"..");let c=n;if(o+=''+d+"",i.bNode){let t={};t[e+"_"+c]=r,s.resid2contact[e].push(t)}a+=s.showSeqCls.insertGapOverview(e,t);let h=i.cfg.blast_rep_id==e?Math.round(s.seqAnnWidth*t/(s.maxAnnoLength+s.nTotalGap)-C-y):Math.round(s.seqAnnWidth*t/s.maxAnnoLength-C-y);h>=0&&(a+='
     
    ',a+='
     
    ',C+=h,y+=v)}else o+="-"}f=' '+p.toString()+" Residues",f+="
    ",f+="
    ",o+=f,a+=f,++c}o+="",a+="",d+="",$("#"+s.pre+"dt_interaction_"+e).html(o),$("#"+s.pre+"ov_interaction_"+e).html(a),$("#"+s.pre+"tt_interaction_"+e).html(d),i.utilsCls.isMobile()?(s.hlSeqCls.selectSequenceMobile(),s.hlSeqCls.selectChainMobile()):s.hlSeqCls.selectSequenceNonMobile()}}class wt{constructor(e){this.icn3d=e}async showPTM(e,t,s,i,n){let l=this.icn3d,r=l.icn3dui,o=this,a=e.substr(0,e.indexOf("_")),d=e.substr(e.indexOf("_")+1);if("afmem"==s){let t={Transmembrane:[{begin:i,end:n}]};this.setAnnoPtmTransmem("transmem",t,e)}else if(a.length>5){let t,i="https://www.ebi.ac.uk/proteins/api/features/"+a;try{t=await r.getAjaxPromise(i,"json"),o.parsePTM(t,e,s)}catch{return void o.getNoPTM(e,s)}}else{let t,i=a.substr(0,4).toLowerCase(),n="https://www.ebi.ac.uk/pdbe/api/mappings/uniprot/"+i;try{t=await r.getAjaxPromise(n,"json");let a="";l.UPResi2ResiPosPerChain||(l.UPResi2ResiPosPerChain={}),l.UPResi2ResiPosPerChain[e]={};let c=t[i].UniProt,h=!1;for(let t in c){let s=c[t].mappings;for(let i=0,n=s.length;i',o+=r,a+=r;let d=s.substr(0,s.indexOf("_"));for(let c in t){let h=t[c],p=[],m=!1;for(let e=0,t=h.length;e5?p.push(e-1):i.UPResi2ResiPosPerChain&&i.UPResi2ResiPosPerChain[s][e]&&p.push(i.UPResi2ResiPosPerChain[s][e]),!m&&i.residues.hasOwnProperty(s+"_"+e)&&(m=!0)}if(0==p.length)continue;let u=p.length,g="ptm"==e?"PTM: "+c:"Transmembrane";g.length>17&&(g=g.substr(0,17)+"...");let f=c,b='
    '+g+"
    ",C=''+u.toString()+" Res",y='';a+=b+C+"
    ",r+=b+C+y,o+=b+C+y;let v=e+l.toString(),w=0,_=0,S=1;for(let e=0,t=i.giSeq[s].length;e1&&(l=t[0]+"..");let a=i.ParserUtilsCls.getResi(s,e);if(r+=''+t+"",n.bNode){let e={};e[s+"_"+a]=g,i.resid2ptm[s].push(e)}o+=i.showSeqCls.insertGapOverview(s,e);let d=n.cfg.blast_rep_id==s?Math.round(i.seqAnnWidth*e/(i.maxAnnoLength+i.nTotalGap)-w-_):Math.round(i.seqAnnWidth*e/i.maxAnnoLength-w-_);d>=0&&(o+='
     
    ',o+='
     
    ',w+=d,_+=S)}else r+="-";y=' '+u.toString()+" Residues",y+="
    ",y+="
    ",r+=y,o+=y,++l}r+="",o+="",a+="",$("#"+i.pre+"dt_"+e+"_"+s).html(r),$("#"+i.pre+"ov_"+e+"_"+s).html(o),$("#"+i.pre+"tt_"+e+"_"+s).html(a)}getNoPTM(e,t){let s=this.icn3d;s.icn3dui,console.log("No PTM data were found for the chain "+e+"...");let i="ptm"==t?"ptm":"transmem";$("#"+s.pre+"dt_"+i+"_"+e).html(""),$("#"+s.pre+"ov_"+i+"_"+e).html(""),$("#"+s.pre+"tt_"+i+"_"+e).html(""),s.showAnnoCls.enableHlSeq(),s.bAjaxPTM=!0}}class _t{constructor(e){this.icn3d=e}showCrosslink(e,t){let s=this.icn3d;s.icn3dui;let i=this;void 0===s.clbondpnts?setTimeout((function(){i.showCrosslink_base(e,t)}),1e3):this.showCrosslink_base(e,t)}showCrosslink_base(e,t){let s=this.icn3d;s.icn3dui.bNode&&(s.resid2crosslink||(s.resid2crosslink={}),s.resid2crosslink[e]||(s.resid2crosslink[e]=[]));let i=t,n={},l=i.substr(0,i.indexOf("_")),r=s.clbondpnts[l];if(void 0===r)return $("#"+s.pre+"dt_crosslink_"+e).html(""),$("#"+s.pre+"ov_crosslink_"+e).html(""),void $("#"+s.pre+"tt_crosslink_"+e).html("");for(let e=0,t=r.length;e',a=o,d=o,c=e.indexOf("_"),h=e.substr(c+1);if(s)n=e,i=t.domains[e]?t.domains[e].domains:[];else{let e,s=t.moleculeInfor;for(let t in s)if(s[t].chain===h){e=t,n=s[t].name;break}void 0!==e&&void 0!==t.domains[e]&&(i=t.domains[e].domains),void 0===i&&(i=[])}for(let t=0,s=i.length;t17?s.substr(0,17)+"...":s,h=i[t].intervals,p={},m={},u=[],g=[],f={},b=0;for(let e=0,t=h.length;e'+c+" ",y=''+b.toString()+" Res";d+=C+y+"
    ";let v='';o+=C+y+v,a+=C+y+v;let w="domain3d"+t.toString();for(let t=0,s=l.giSeq[e].length;t1&&(n=i[0]+"..");let r=s;o+=''+i+""}else o+="-"}let _=l.firstAtomObjCls.getFirstCalphaAtomObj(l.chains[e]),S=void 0===_.color||"FFFFFF"===_.color.getHexString()?"DDDDDD":_.color.getHexString(),A=void 0!==_.color?S:"CCCCCC";if(r.cfg.blast_rep_id!=e)for(let i=0,n=u.length;i ',a+='"}else{let i=[],n=[];for(let e=0,t=u.length;e ',a+='"}}v=' '+b.toString()+" Residues",v+="",v+="
    ",o+=v,a+=v}o+="",a+="",d+="",$("#"+l.pre+"dt_domain_"+e).html(o),$("#"+l.pre+"ov_domain_"+e).html(a),$("#"+l.pre+"tt_domain_"+e).html(d)}}class At{constructor(e){this.icn3d=e}async showSnp(e,t){this.icn3d.icn3dui,await this.showSnpClinvar(e,t,!0)}async showClinvar(e,t){this.icn3d.icn3dui,await this.showSnpClinvar(e,t,!1)}async showSnpClinvar(e,t,s){let i=this.icn3d.icn3dui,n=this,l=i.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainid="+t;try{let r=await i.getAjaxPromise(l,"jsonp"),o=r.snpgi,a=r.gi;if(s)await n.showSnpPart2(e,t,o);else{let s=o;[6137708,1942289,224510717,2624886,253723219,2554905,75765331,3660278,312207882,319443632,342350956,1827805,109157826,1065265,40889086,6730307,163931185,494469,163931091,60594093,55669745,18655489,17942684,6980537,166235465,6435586,4139398,4389047,364506122,78101667,262118402,20664221,2624640,158430173,494395,28948777,34810587,13399647,3660342,261278854,342350965,384482350,378792570,15988303,213424334,4558333,2098365,10835631,3318817,374074330,332639529,122919696,4389286,319443573,2781341,67464020,194709238,210061039,364506106,28949044,40889076,161172338,17943181,4557976,62738484,365813173,6137343,350610552,17942703,576308,223674070,15826518,1310997,93279697,4139395,255311799,157837067,361132363,357380836,146387678,383280379,1127268,299856826,13786789,1311054,46015217,3402130,381353319,30750059,218766885,340707375,27065817,355333104,2624634,62738384,241913553,304446010].includes(a)&&(s=a),await n.showClinvarPart2(e,t,s)}}catch(t){return void(s?n.processNoSnp(e):n.processNoClinvar(e))}}navClinVar(e){let t=this.icn3d;t.icn3dui;let s=this;t.currClin[e]=-1,$(document).on("click","#"+t.pre+e+"_prevclin",(function(t){let i=s.icn3d;t.stopImmediatePropagation();let n=void 0!==i.resi2disease_nonempty[e]?Object.keys(i.resi2disease_nonempty[e]).length:0;--i.currClin[e],i.currClin[e]<0&&(i.currClin[e]=n-1),s.showClinVarLabelOn3D(e)})),$(document).on("click","#"+t.pre+e+"_nextclin",(function(t){let i=s.icn3d;t.stopImmediatePropagation();let n=void 0!==i.resi2disease_nonempty[e]?Object.keys(i.resi2disease_nonempty[e]).length:0;++i.currClin[e],i.currClin[e]>n-1&&(i.currClin[e]=0),s.showClinVarLabelOn3D(e)}))}showClinVarLabelOn3D(e){let t,s,i=this.icn3d,n=i.icn3dui,l=Object.keys(i.resi2disease_nonempty[e]);t=e,s=t+"_"+(parseInt(l[i.currClin[e]])+i.baseResi[e]).toString();let r="",o=i.resi2disease_nonempty[e][l[i.currClin[e]]];for(let e=0,t=o.length;e0?o[0]:"N/A");let a=i.applyCenterCls.centerAtoms(n.hashUtilsCls.hash2Atoms(i.residues[s],i.atoms));r.length>30&&(r=r.substr(0,30)+"..."),i.selectionCls.removeSelection(),null==i.labels&&(i.labels={}),i.labels.clinvar=[];let d=i.LABELSIZE,c="black"!=i.opts.background?i.colorWhitebkgd:i.colorBlackbkgd;i.analysisCls.addLabel(r,a.center.x+1,a.center.y+1,a.center.z+1,d,c,void 0,"clinvar"),i.hAtoms={};for(let e in i.residues[s])i.hAtoms[e]=1;$("#clinvar_"+i.pre+s).addClass("icn3d-highlightSeq"),void 0===$("#"+i.pre+"modeswitch")[0]||$("#"+i.pre+"modeswitch")[0].checked||i.definedSetsCls.setMode("selection"),i.drawCls.draw()}getSnpLine(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g){let f=this.icn3d,b=f.icn3dui,C="",y=m?"clinvar":"snp",v=!1;for(let e in i){for(let t=0,s=i[e].length;t(from human)",i=" (based on human sequences and mapped to this structure by sequence similarity)"),C+=m?'":'"}else if(2==e&&m){let e=b.utilsCls.isMobile()?"none":"button";C+='
    ',C+='
    '}else C+='
    ';let w=y,_=0,S=0,A={},x={};for(let t=1,i=f.giSeq[h].length;t<=i;++t)if(void 0!==r[t]){++_;let i="";for(let n=0,r=s[t].length;n'+k+" Res":'',u)return C+"
    ";C+='';let O="",R=0,E=0;for(let t=1,a=f.giSeq[h].length;t<=a;++t)if(p){if(void 0!==r[t]){let e=f.giSeq[h][t-1],i=e;e.length>1&&(i=e[0]+"..");let n=f.ParserUtilsCls.getResi(h,t-1)+i+">";for(let e=0,i=s[t].length;e=0&&(C+='
     
    ',C+='
     
    ',R+=r,E+=1):r>0&&(C+='
     
    ',C+='
     
    ',R+=r,E+=1)}}else if(C+=f.showSeqCls.insertGap(h,t-1,"-"),void 0!==r[t])if(m||1!=e){let r=f.giSeq[h][t-1],a=r;r.length>1&&(a=r[0]+"..");let d,c=f.ParserUtilsCls.getResi(h,t-1),p="",u="
    ",y=s[t].length,v=0,_=0;if(2==e&&(v=0,_=y),m){d=1;let r=0;for(let e=v;e0?_+="; ":0!==e&&1!==e||(O='disease="'+v[t]+'"'),_+=v[t]+"("+w[t]+")",++S;""!=_&&(r"+s[t][e],u+=": "+_,C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(m,"snpin3d","3D with scap","SNP in 3D with scap",70,g)+"  ",u+=f.showAnnoCls.addSnpButton(m,"snpinter","Interactions","SNP Interactions in 3D",70,g)+"  ",u+=f.showAnnoCls.addSnpButton(m,"snppdb","PDB","Download SNP PDB",35,g)),u+="
    Links: ClinVar, dbSNP(rs"+i[t][e]+")",e
    "),++r)}r>d&&2==e&&(p+="..")}else{d=1;for(let e=v;e"+s[t][e],g)C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),0!=i[t][e]&&(u+="
    Link: dbSNP(rs"+i[t][e]+")"),e
    ");else{let s=l[t][e].split("; "),a=o[t][e].split("; "),d="",c=0;for(let t=0,i=s.length;t0?d+="; ":0!==e&&1!==e||(O='disease="'+s[t]+'"'),d+=s[t]+"("+a[t]+")",++c;""!=d?(u+=": "+d,C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),u+="
    Links: ClinVar, dbSNP(rs"+i[t][e]+")"):(C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),u+="
    Link: dbSNP(rs"+i[t][e]+")"),e
    ")}}y>d&&2==e&&(p+="..")}u+="
    ",m?"icn3d-clinvar"==A[t]||"icn3d-clinvar-path"==A[t]?C+=1==e?"":""==p||" "==p?"-":''+p+"":C+="-":C+=""==p||" "==p?"-":g?''+p+"":''+p+""}else C+="";else C+="-";return C+=1==e?' '+k+" Residues":'',C+="
    ",C+="
    ",C}processSnpClinvar(e,t,s,i,n){let l=this.icn3d,r=l.icn3dui,o='
    ',a=o,d=o,c='
    ',h=c,p=c,m=!i||n?e.data:e.split("\n"),u={},g={},f={};void 0===l.resi2disease_nonempty[t]&&(l.resi2disease_nonempty[t]={});let b={},C={},y={},v={},w={},_="";r.bNode&&(i?(l.resid2snp||(l.resid2snp={}),l.resid2snp[t]||(l.resid2snp[t]=[])):(l.resid2clinvar||(l.resid2clinvar={}),l.resid2clinvar[t]||(l.resid2clinvar[t]=[])));for(let e=0,s=m.length;e")+1),h=s[4],p=i?"":s[5],S=i?"":s[6],A=i?"":s[7],x=l.ParserUtilsCls.getResi(t,d-1);v[x]=1,""!=S&&(w[x]=1),g[d]=e+1,void 0===u[d]&&(u[d]=[]),u[d].push(c),void 0===C[d]&&(C[d]=[]),C[d].push(h),void 0===y[d]&&(y[d]=[]),y[d].push(p),void 0===f[d]&&(f[d]=[]),f[d].push(S),""!=S&&(void 0===l.resi2disease_nonempty[t][d]&&(l.resi2disease_nonempty[t][d]=[]),l.resi2disease_nonempty[t][d].push(S)),void 0===b[d]&&(b[d]=[]),b[d].push(A)}let S=Object.keys(v),A=Object.keys(w);if(i){let e=!1;o+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,void 0,i),o+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,void 0,i),d+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,!0,i),d+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,!0,i),a+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!0,e,void 0,i),o+="
    ",a+="
    ",d+="",$("#"+l.pre+"dt_snp_"+t).html(o),$("#"+l.pre+"ov_snp_"+t).html(a),$("#"+l.pre+"tt_snp_"+t).html(d)}else{let e=!0;c+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,void 0,i),c+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,void 0,i),p+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,!0,i),p+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,!0,i),h+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!0,e,void 0,i),c+="",h+="",p+="",$("#"+l.pre+"dt_clinvar_"+t).html(c),$("#"+l.pre+"ov_clinvar_"+t).html(h),$("#"+l.pre+"tt_clinvar_"+t).html(p),this.navClinVar(t,s)}l.showAnnoCls.enableHlSeq(),i?l.bAjaxSnp=!0:l.bAjaxClinvar=!0}async showClinvarPart2(e,t,s){let i=this.icn3d,n=i.icn3dui,l=this,r=n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainid_clinvar="+t;i.chainsGene[e]&&i.chainsGene[e].geneSymbol&&(r+="&gene="+i.chainsGene[e].geneSymbol);try{let s=await n.getAjaxPromise(r,"jsonp");if(s&&s.data&&s.data.length>0){let i=!1,n=s;l.processSnpClinvar(n,e,t,i)}else l.processNoClinvar(e)}catch(t){return void l.processNoClinvar(e)}}async showSnpPart2(e,t,s){let i=this.icn3d,n=i.icn3dui,l=this;if(void 0!==s){let s=n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainid_snp="+t;i.chainsGene[e]&&i.chainsGene[e].geneSymbol&&(s+="&gene="+i.chainsGene[e].geneSymbol);try{let i=await n.getAjaxPromise(s,"jsonp");if(i&&i.data&&i.data.length>0){let s=!0,n=!0;l.processSnpClinvar(i,e,t,s,n)}else l.processNoSnp(e)}catch(t){return void l.processNoSnp(e)}}else this.processNoSnp(e),console.log("No gi was found for the chain "+t+"...")}processNoClinvar(e){let t=this.icn3d;t.icn3dui,console.log("No ClinVar data were found for the protein "+e+"..."),$("#"+t.pre+"dt_clinvar_"+e).html(""),$("#"+t.pre+"ov_clinvar_"+e).html(""),t.showAnnoCls.enableHlSeq(),t.bAjaxClinvar=!0}processNoSnp(e){let t=this.icn3d;t.icn3dui,console.log("No SNP data were found for the protein "+e+"..."),$("#"+t.pre+"dt_snp_"+e).html(""),$("#"+t.pre+"ov_snp_"+e).html(""),t.showAnnoCls.enableHlSeq(),t.bAjaxSnp=!0}}class xt{constructor(e){this.icn3d=e}showSsbond(e,t){let s=this.icn3d;s.icn3dui;let i=this;void 0===s.ssbondpnts?setTimeout((function(){i.showSsbond_base(e,t)}),1e3):this.showSsbond_base(e,t)}showSsbond_base(e,t){let s=this.icn3d;s.icn3dui.bNode&&(s.resid2ssbond||(s.resid2ssbond={}),s.resid2ssbond[e]||(s.resid2ssbond[e]=[]));let i=t,n={},l=i.substr(0,i.indexOf("_")),r=s.ssbondpnts[l];if(void 0===r)return $("#"+s.pre+"dt_ssbond_"+e).html(""),$("#"+s.pre+"ov_ssbond_"+e).html(""),void $("#"+s.pre+"tt_ssbond_"+e).html("");for(let e=0,t=r.length;e-s.halfBilayerSize){i[t.structure+"_"+t.chain+"_"+t.resi]=1}}let n=Object.keys(i);s.annoCddSiteCls.showAnnoType(e,t,"transmem","Transmembrane",n)}}class Ot{constructor(e){this.icn3d=e,this.dcut=7,this.MAX_SSE=512,this.ctc_cnt=[];for(let e=0;e=this.curr_ratio+.01||f>this.split_ratio)return e;if(f>this.curr_ratio-.01&&Math.min(m,u)=0&&l[i]==t-e+i;i--);if(i<0)break;for(l[i]++,s=i+1;s-1;i++);for(l=Math.min(i-1,this.max_csz),this.curr_ne0=this.curr_ne1=0,this.curr_ratio=100,s=1;s<=l;s++)this.cut_size(s,i);if(this.top--,0==this.curr_ne0){for(n=this.stack[this.top],e=n;e-1;e++)this.parts[this.np++]=this.elements[e];this.parts[this.np++]=-1,this.n_doms++}else{if(this.save_ratios[this.saved++]=this.curr_ratio,this.curr_ne0>this.min_sse){for(n=this.stack[this.top],e=0;ethis.min_sse){for(n=this.stack[this.top],e=0;e0;)this.process_set()}output(e){let t,s;this.icn3d.icn3dui;let i=[];for(t=0;t<2*e;t++)i.push(0);for(t=s=0;st+n)break;let p=(t-a)*(t-a);p+=(s-c)*(s-c),p+=(i-h)*(i-h);let m=Math.sqrt(p);if(m>n)continue;let u={},g={};parseInt(e.rnum)this.MAX_SSE)return{subdomains:a,substruct:o};let g=h.length,f=r[g-1],b=this.c2b_AlphaContacts(g,i,n,l,t,r),C=[];for(let e=0;e0&&this.elt_size[s.sse-1]>=6&&0!=s.adj_strand2&&e++}for(let e=0;e0)for(let e=0;e0){let e=0;for(let t=0;t<=E;t++){let t=[];for(;e<2*u;){let s=this.parts[e++];if(0==s){I.push(t);break}t.push(s)}}}I.sort((function(e,t){return e[0]-t[0]}));for(let e=0,t=I.length;e=o.length)return{subdomains:a,substruct:o};let n=o[i],l=n.From,r=n.To;for(let e=l;e<=r;e++)s[e]=1;if(0==i&&l>1)for(let e=1;e0){let e=o[i-1].To,t=parseInt(.5*(l-e-1));if(t>0)for(let e=l-t;e<=l-1;e++)s[e]=1}if(i0)for(let e=r+1;e<=r+t;e++)s[e]=1}}let i,n=!1,l=[];for(let e=0;e0&&(d+=", "),d+='{"ss": [';let i=0;for(let s=0,r=n[e].length;s=r&&c<=o&&(i>0&&(d+=", "),d+="["+s+","+n+","+c+","+l[e].x1.toFixed(2)+","+l[e].y1.toFixed(2)+","+l[e].z1.toFixed(2)+","+l[e].x2.toFixed(2)+","+l[e].y2.toFixed(2)+","+l[e].z2.toFixed(2)+"]",++i))}}d+="]",d+=', "domain": [';let r=0;for(let i=0,l=n[e].length;i=l&&n<=a&&(r>0&&(d+=", "),d+="["+n+","+h+","+c.coord.x.toFixed(2)+","+c.coord.y.toFixed(2)+","+c.coord.z.toFixed(2)+"]",++r)}}d+="]}"}return d+="]}",d}}class Rt{constructor(e){this.icn3d=e}clickAddTrackButton(){let e=this.icn3d,t=e.icn3dui,s=this;t.myEventCls.onIds("#"+e.pre+"addtrack_button1","click",(async function(e){let i=s.icn3d;e.stopImmediatePropagation(),dialog.dialog("close");let n=$("#"+i.pre+"track_chainid").val(),l=$("#"+i.pre+"track_gi").val(),r=isNaN(l)?"Acc "+l:"gi "+l,o=t.htmlCls.baseUrl+"pwaln/pwaln.fcgi?from=track",a={targets:n,queries:l},d=await t.getAjaxPostPromise(o,a);s.alignSequenceToStructure(n,d,r)})),t.myEventCls.onIds("#"+e.pre+"addtrack_button2","click",(async function(e){let i=s.icn3d;e.stopImmediatePropagation(),dialog.dialog("close");let n=$("#"+i.pre+"track_chainid").val(),l=$("#"+i.pre+"track_fasta").val(),r=$("#"+i.pre+"fasta_title").val(),o=n.substr(0,n.indexOf("_")),a=n;if(5==o.length)a=a.substr(0,4);else if(o.length>5){a="";for(let e=0,t=i.chainsSeq[n].length;e"),a=o[1].indexOf("\n");o[1].substr(0,a);let d,c=o[1].substr(a+1).replace(/\n/g,""),h=[],p=[];for(let e=2,t=o.length;e0&&(u=f,i.targetGapHash[m+d]={from:m+d,to:u+C-1+d}),g=c[e],f=b,"-"!=c[e]?(++b,w=e,y||(v=e,y=!0)):++C;await i.annotationCls.resetAnnoAll();let _="",S=0;for(let e in i.targetGapHash)S>0&&(_+=" "),_+=e+"_"+i.targetGapHash[e].from+"_"+i.targetGapHash[e].to,++S;t.htmlCls.clickMenuCls.setLogCmd("msa | "+_,!0);let A={};for(let e=0,o=p.length;e0){void 0===i.queryresi2score&&(i.queryresi2score={}),void 0===i.queryresi2score[n]&&(i.queryresi2score[n]={});let e=p.length;for(let t in A){let s=parseInt(A[t]/e*100);i.queryresi2score[n][t]=s}let s=Object.keys(A),l=Math.min.apply(null,s),r=Math.max.apply(null,s),o="";for(let t=l;t<=r;++t)A.hasOwnProperty(t)?o+=Math.round(A[t]/e*9):o+="_";i.opts.color="align custom",i.setColorCls.setColorByOptions(i.opts,i.hAtoms),i.hlUpdateCls.updateHlAll(),i.drawCls.draw(),t.htmlCls.clickMenuCls.setLogCmd("color align custom | "+n+" | range "+l+"_"+r+" | "+o,!0)}})),t.myEventCls.onIds("#"+e.pre+"addtrack_button3","click",(function(e){let i=s.icn3d;e.stopImmediatePropagation(),dialog.dialog("close");let n=$("#"+i.pre+"track_chainid").val(),l=$("#"+i.pre+"track_bed")[0].files[0];if(l){window.File&&window.FileReader&&window.FileList&&window.Blob||alert("The File APIs are not fully supported in this browser.");let e=new FileReader;e.onload=function(e){let l,r=e.target.result.split("\n"),o=!1,a=!1;for(let e=0,d=r.length;e8||d.length<6)&&(a=!1),d.length<9&&(o=!1),d[0];let c,h,p=d[1],m=d[2],u=d[3];d.length,d.length>5&&(c=d[5]),d.length,d.length,d.length>8&&(h=d[8]),d.length,d.length,d.length;let g=u,f="51,51,51";o?f=h:a&&("+"==c&&l.length>0?f=l[0]:"-"==c&&l.length>1?f=l[1]:"."==c&&l.length>2&&(f=l[2]));let b="",C=[];for(let e=0,t=m;e1&&(s=t[0]);let l=i.ParserUtilsCls.getResi(n,e);if(a.hasOwnProperty(n+"_"+l)){let e=i.firstAtomObjCls.getFirstCalphaAtomObj(i.residues[n+"_"+l]),t=void 0===e.color||"FFFFFF"===e.color.getHexString().toUpperCase()?"DDDDDD":e.color.getHexString(),o=void 0!==e.color?t:"CCCCCC";r+=s,d.push("#"+o)}else r+="-",d.push("")}s.showNewTrack(n,l,r,d,void 0,"selection",void 0),t.htmlCls.clickMenuCls.setLogCmd("add track | chainid "+n+" | title "+l+" | text "+s.simplifyText(r)+" | type selection",!0)}))}showNewTrack(e,t,s,i,n,l,r,o,a,d){let c=this.icn3d,h=c.icn3dui,p=!1;"cannot be aligned"==s&&(p=!0);let m=s.replace(/-/g,"").length;if(!o)if(s.length>c.giSeq[e].length)s=s.substr(0,c.giSeq[e].length);else if(s.length20&&(u=u.substr(0,20));let g=h.htmlCls.RESIDUE_WIDTH*s.length+200;$("#"+c.pre+"dt_custom_"+e).append("
    "),$("#"+c.pre+"dt_custom_"+e+"_"+u).width(g),$("#"+c.pre+"ov_custom_"+e).append("
    "),$("#"+c.pre+"ov_custom_"+e+"_"+u).width(g),$("#"+c.pre+"tt_custom_"+e).append("
    "),$("#"+c.pre+"tt_custom_"+e+"_"+u).width(g);let f='
    ',b=f,C=f,y=parseInt(10*Math.random()),v='",w=''+m.toString()+" Pos";C+=v+w+"
    ";let _='';f+=v+w+_,b+=v+w+_;let S=e.indexOf("_"),A="cst"+e.substr(S+1),x=0,k=0,O=(void 0===l||"seq"===l||"custom"===l)&&-1==s.indexOf("cannot-be-aligned")&&-1==s.indexOf("cannot be aligned"),R="identity"===l&&-1==s.indexOf("cannot-be-aligned")&&-1==s.indexOf("cannot be aligned"),E={},I=0,T=1;v="";for(let t=0,a=s.length;t"+d+"",v+=c.showSeqCls.insertGapOverview(e,t);let g=h.cfg.blast_rep_id==e?Math.round(c.seqAnnWidth*t/(c.maxAnnoLength+c.nTotalGap)-x-k):Math.round(c.seqAnnWidth*t/c.maxAnnoLength-x-k);g<0&&(g=0),v+='
     
    ',s=void 0!==i&&""!=i[t]?i[t]:r?"rgb("+r+")":O?"#"+p:"#333",v+='
     
    ',x+=g,k+=1,++T}else f+=p?""+d+"":"-"}if(void 0!==a){v="";let s=[],i=[];for(let e=0,t=a.length;e 
    ',v+='"}}_=''+m.toString()+" Pos",_+="",_+="
    ",_+="",f+=_,b+=v+_,C+="",$("#"+c.pre+"dt_custom_"+e+"_"+u).html(f),$("#"+c.pre+"ov_custom_"+e+"_"+u).html(b),$("#"+c.pre+"tt_custom_"+e+"_"+u).html(C)}alignSequenceToStructure(e,t,s){let i,n,l,r=this.icn3d,o=r.icn3dui;void 0!==t.data&&(i=t.data[0].query,l=Object.keys(t.data[0].targets)[0],n=t.data[0].targets[l],n=n.hsps[0]);let a="",d=[],c={};if(void 0!==i&&void 0!==n){let h=n.scores.e_value.toPrecision(2);h>1e-200&&(h=parseFloat(h).toExponential()),n.scores.bit_score;let p=t.targets[l].seqdata,m=i.seqdata,u=n.segs;for(let e=0,t=u.length;e0&&(l=n+"H"+d+")","coil"==t&&(s.selectionCls.selectResidueList(r,l,l,o,a),o||(o=!0)),r={})),n=e+"_H"+d,r[p]=1,i.ssend&&(h=e+"_C(H"+d,"helix"==t&&(s.selectionCls.selectResidueList(r,n,n,o,a),o||(o=!0)),r={})):"E"==m?(i.ssbegin&&(++c,Object.keys(r).length>0&&(l=n+"S"+c+")","coil"==t&&(s.selectionCls.selectResidueList(r,l,l,o,a),o||(o=!0)),r={})),n=e+"_S"+c,r[p]=1,i.ssend&&(h=e+"_C(S"+c,"sheet"==t&&(s.selectionCls.selectResidueList(r,n,n,o,a),o||(o=!0)),r={})):(n=h+"-",r[p]=1)}}Object.keys(r).length>0&&(l=n+"Cterm)","coil"==t&&s.selectionCls.selectResidueList(r,l,l,o,a))}simplifyText(e){this.icn3d.icn3dui;let t,s,i="",n=!1,l=-1;for(t=0,s=(e=e.replace(/undefined/g," ")).length;t20)return!1;if(void 0!==o.giSeq&&void 0!==o.giSeq[e]){let r=this.getFullText(s);return s=r.text,this.showNewTrack(e,t,s,void 0,void 0,i,n,l),!1}setTimeout((function(){a.checkGiSeq(e,t,s,i,n,l,r+1)}),100)}getFullText(e){this.icn3d.icn3dui;let t="",s=[],i=[],n=e.split(","),l=-1;for(let e=0,r=n.length;ep?t+=c.substr(0,p):t+=c;for(let e=0;e0&&($("#"+e.pre+"anno_cdd")[0].checked?(this.setAnnoTabCdd(),t.htmlCls.clickMenuCls.setLogCmd("set annotation cdd",!0)):(this.hideAnnoTabCdd(),t.htmlCls.clickMenuCls.setLogCmd("hide annotation cdd",!0)))}showAnnoSelectedChains(){let e=this.icn3d,t=e.icn3dui,s={};for(let t in e.hAtoms){let i=e.atoms[t];s[i.structure+"_"+i.chain]=1}$("#"+e.pre+"dl_annotations > .icn3d-annotation").hide();for(let i in s){$("#"+e.pre+"anno_"+i).length&&$("#"+e.pre+"anno_"+i).show();let s=e.firstAtomObjCls.getFirstCalphaAtomObj(e.chains[i]);if(void 0!==s.resn){let i=t.utilsCls.residueName2Abbr(s.resn.substr(0,3));$("#"+e.pre+"anno_"+i).show()}}}showAnnoAllChains(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"dl_annotations > .icn3d-annotation").show()}setAnnoView(e){let t=this.icn3d;t.icn3dui.bNode||("detailed view"===e?(t.view="detailed view",$("#"+t.pre+"dl_anno_view_tabs").tabs("option","active",1)):(t.view="overview",$("#"+t.pre+"dl_anno_view_tabs").tabs("option","active",0)))}setAnnoDisplay(e,t){let s=this.icn3d;s.icn3dui;let i=["giseq","custom","site","ptm","snp","clinvar","cdd","domain","interaction","ssbond","crosslink","transmem"];for(let n in i){let l=i[n];$("[id^="+s.pre+t+"_"+l+"]").attr("style",e)}}showFixedTitle(){this.icn3d.icn3dui;this.setAnnoDisplay("display:block;","tt")}hideFixedTitle(){this.icn3d.icn3dui;this.setAnnoDisplay("display:none!important;","tt")}setAnnoViewAndDisplay(e){let t=this.icn3d;if(t.icn3dui,"detailed view"===e){this.setAnnoView("detailed view");let e="display:block;";this.setAnnoDisplay(e,"dt"),$("#"+t.pre+"seqguide_wrapper").attr("style",e),e="display:none;",this.setAnnoDisplay(e,"ov")}else{this.setAnnoView("overview"),this.hideFixedTitle();let e="display:none;";this.setAnnoDisplay(e,"dt"),$("#"+t.pre+"seqguide_wrapper").attr("style",e),e="display:block;",this.setAnnoDisplay(e,"ov")}}async updateClinvar(){let e=this.icn3d;if(e.icn3dui,void 0===e.bClinvarShown||!e.bClinvarShown)for(let t in e.protein_chainid){let s=e.protein_chainid[t];await e.annoSnpClinVarCls.showClinvar(t,s)}e.bClinvarShown=!0}async updateSnp(){let e=this.icn3d;if(e.icn3dui,void 0===e.bSnpShown||!e.bSnpShown)for(let t in e.protein_chainid){let s=e.protein_chainid[t];await e.annoSnpClinVarCls.showSnp(t,s)}e.bSnpShown=!0}updateDomain(){let e=this.icn3d;e.icn3dui,void 0!==e.bDomainShown&&e.bDomainShown||e.annoDomainCls.showDomainAll(),e.bDomainShown=!0}updateInteraction(){let e=this.icn3d;if(e.icn3dui,void 0===e.bInteractionShown||!e.bInteractionShown)for(let t in e.interactChainbase){let s=e.interactChainbase[t];e.annoContactCls.showInteraction(t,s)}e.bInteractionShown=!0}async updatePTM(){let e=this.icn3d;if(e.icn3dui,void 0===e.bPTMShown||!e.bPTMShown)for(let t in e.PTMChainbase){let s=e.PTMChainbase[t];await e.annoPTMCls.showPTM(t,s,"ptm")}e.bPTMShown=!0}updateSsbond(){let e=this.icn3d;if(e.icn3dui,void 0===e.bSSbondShown||!e.bSSbondShown)for(let t in e.ssbondChainbase){let s=e.ssbondChainbase[t];e.annoSsbondCls.showSsbond(t,s)}e.bSSbondShown=!0}updateCrosslink(){let e=this.icn3d;if(e.icn3dui,void 0===e.bCrosslinkShown||!e.bCrosslinkShown)for(let t in e.crosslinkChainbase){let s=e.crosslinkChainbase[t];e.annoCrossLinkCls.showCrosslink(t,s)}e.bCrosslinkShown=!0}async updateTransmem(){let e=this.icn3d,t=e.icn3dui;if(void 0===e.bTranememShown||!e.bTranememShown)for(let s in e.protein_chainid){let i=e.protein_chainid[s];if(void 0!==t.cfg.opmid)e.annoTransMemCls.showTransmem(s,i);else if(e.bAfMem&&e.afmem_start_end){let t=e.afmem_start_end[0],n=e.afmem_start_end[1];await e.annoPTMCls.showPTM(s,i,"afmem",t,n)}else await e.annoPTMCls.showPTM(s,i,"transmem")}e.bTranememShown=!0}}class It{constructor(e){this.icn3d=e}showAnnotations_part1(){let e=this.icn3d,t=e.icn3dui;if(t.htmlCls.dialogCls.openDlg("dl_selectannotations","Sequences and Annotations"),(void 0===e.bAssemblyNote||!e.bAssemblyNote)&&void 0!==e.asuCnt){let t="
    Assembly Tips: Only the asymmetric unit is shown in the sequence window.
    Click \"Assembly\" in the menu \"View\" to switch between asymmetric unit and biological assembly("+e.asuCnt+" asymmetric unit).
    ";$("#"+e.pre+"dl_annotations_tabs").append(t),e.bAssemblyNote=!0}e.bResetAnno&&(e.giSeq={},e.currClin={},e.resi2disease_nonempty={},e.baseResi={},e.matchedPos={},$("#"+t.pre+"dl_annotations").empty(),e.annotationCls.setAnnoView("overview"));let s={},i={},n={};if(void 0===e.bAnnoShown||!e.bAnnoShown||e.bResetAnno){e.protein_chainid={};let l,r=Object.keys(e.chains);void 0===e.giSeq&&(e.giSeq={}),void 0===e.currClin&&(e.currClin={}),void 0===e.resi2disease_nonempty&&(e.resi2disease_nonempty={}),void 0===e.baseResi&&(e.baseResi={}),void 0===e.matchedPos&&(e.matchedPos={}),l=t.bNode?500:t.cfg.notebook?t.htmlCls.WIDTH/2:$("#"+e.pre+"dl_selectannotations").dialog("option","width"),e.seqAnnWidth=l-120-60-50;for(let l=0,o=r.length;l1)e.protein_chainid[r[l]]=a;else if(e.nucleotides.hasOwnProperty(o.serial)&&e.chainsSeq[r[l]].length>1)s[r[l]]=a;else if(e.chainsSeq[r[l]].length>1)i[r[l]]=a;else{let t=e.chainsSeq[r[l]][0].name,s=r[l]+"_"+e.chainsSeq[r[l]][0].resi;void 0===n[t]&&(n[t]=[]),n[t].push(s)}if((void 0!==t.cfg.pdbid||void 0!==t.cfg.opmid||void 0!==t.cfg.mmcifid||void 0!==t.cfg.mmtfid)&&(e.proteins.hasOwnProperty(o.serial)||e.nucleotides.hasOwnProperty(o.serial)))for(let t=0,s=e.chainsSeq[r[l]].length;te.maxAnnoLength&&(e.protein_chainid.hasOwnProperty(t)||s.hasOwnProperty(t))&&(e.maxAnnoLength=e.chainsSeq[t].length)}return{nucleotide_chainid:s,chemical_chainid:i,chemical_set:n}}async showAnnotations(){let e=this.icn3d,t=e.icn3dui,s=this,i=this.showAnnotations_part1(),n=i.nucleotide_chainid,l=i.chemical_chainid,r=i.chemical_set;if(void 0===e.bAnnoShown||!e.bAnnoShown||e.bResetAnno)if(void 0===t.cfg.blast_rep_id){if(e.bFullUi){if(void 0!==t.cfg.mmtfid){let t=Object.keys(e.structures)[0];await e.mmcifParserCls.downloadMmcifSymmetry(t,"mmtfid")}await this.showAnnoSeqData(n,l,r)}}else if(void 0===t.cfg.blast_rep_id||e.bSmithwm||e.bLocalSmithwm){if(void 0!==t.cfg.blast_rep_id&&(e.bSmithwm||e.bLocalSmithwm)){let i,o,a=[t.cfg.blast_rep_id];if(-1!=t.cfg.query_id.indexOf(">")?o=t.cfg.query_id.substr(t.cfg.query_id.indexOf("\n")+1):!/\d/.test(t.cfg.query_id)||t.cfg.query_id.length>50?o=t.cfg.query_id:a.push(t.cfg.query_id),e.blastAcxn){let s=t.cfg.afid+"_A",n="";for(let t=0,i=e.chainsSeq[s].length;tProteins:

    ":"",a=e.chainsGene[s]&&e.chainsGene[s].geneId?"(Gene: "+e.chainsGene[s].geneSymbol+")":"",d=s.substr(0,s.indexOf("_")),c=d.length>5?''+s+"":s,h="
    "+o+"Annotations of "+c+": "+r+""+a+"   "+this.addButton(s,"icn3d-addtrack","Add Track","Add a custom track",60,i)+"   ";h+=this.addButton(s,"icn3d-customcolor","Custom Color/Tube","Use a custom file to define the colors or tubes in 3D structure",110,i)+"   ",h+=this.addButton(s,"icn3d-helixsets","Helix Sets",'Define sets for each helix in this chain and add them to the menu of "Defined Sets"',60,i)+" "+this.addButton(s,"icn3d-sheetsets","Sheet Sets",'Define sets for each sheet in this chain and add them to the menu of "Defined Sets"',60,i)+" "+this.addButton(s,"icn3d-coilsets","Coil Sets",'Define sets for each coil in this chain and add them to the menu of "Defined Sets"',60,i),$("#"+e.pre+"dl_annotations").append(h);let p=["giseq","cdd","clinvar","snp","site","ptm","ssbond","crosslink","transmem","domain","custom","interaction"];for(let t in p){let i=p[t];$("#"+e.pre+"anno_"+s).append(this.getAnDiv(s,i))}$("#"+e.pre+"anno_"+s).append("


    "),++n}if(t.bNode||e.annoCddSiteCls.setToolTip(),void 0!==e.chainid_seq)await this.processSeqData(e.chainid_seq);else try{let n=[],l=[];for(let e=0,t=i.length;e=6?l.push(i[e]):n.push(i[e]);if(n.length>0){let s=t.htmlCls.baseUrl+"/vastdyn/vastdyn.cgi?chainlist="+n;e.chainid_seq=await t.getAjaxPromise(s,"jsonp")}else e.chainid_seq={};for(let t=0,s=l.length;t40&&(r=r.substr(0,40)+"...");let o="";0==i&&("protein"==s?o="Proteins:

    ":"nucleotide"==s?o="Nucleotides:

    ":"chemical"==s&&(o="Chemicals/Ions/Water:

    ")),$("#"+n.pre+"dl_annotations").append("
    "+o+""+e+": "+r+"
    "),$("#"+n.pre+"anno_"+e).append(this.getAnDiv(e,"giseq")),$("#"+n.pre+"anno_"+e).append(this.getAnDiv(e,"interaction")),$("#"+n.pre+"anno_"+e).append("


    "),n.giSeq[e]=[];for(let t=0;tChemicals/Ions/Water:

    ":"",o=t[0].lastIndexOf("_"),a=t[0].substr(0,o),d=void 0!==l.cfg.mmdbid&&void 0!==n.chainid2sid?n.chainid2sid[a]:void 0;i=void 0!==d?""+e+" ":""+e+"",$("#"+n.pre+"dl_annotations").append("
    "+r+i+"
    "),$("#"+n.pre+"anno_"+e).append("
    "),$("#"+n.pre+"anno_"+e).append("


    ");let c='
    ';c+='",c+='Count: '+t.length+"",c+='';let h=c,p=c;for(let s=0,i=t.length;s3&&(l=i.substr(0,3)),s'+l+""}let m=l.htmlCls.GREY8,u=Math.round(n.seqAnnWidth*t.length/n.maxAnnoLength);u<1&&(u=1),p+='
     
    ',c="",c+="
    ",c+="
    ",h+=c,p+=c,$("#"+n.pre+"dt_giseq_"+e).html(h),$("#"+n.pre+"ov_giseq_"+e).html(p)}async processSeqData(e){let t=this.icn3d,s=t.icn3dui;for(let i in t.protein_chainid){let n=t.protein_chainid[i];if(e.hasOwnProperty(n)){let s=e[n];t.giSeq[i]=s;let l="";for(let e=0;e<10&&e14?"Query: "+o.substr(0,6)+"...":isNaN(s.cfg.query_id)?"Query: "+o:"Query: gi "+o;let a="cannot be aligned";t.queryStart="",t.queryEnd="",t.bRender&&alert("The sequence can NOT be aligned to the structure"),t.showSeqCls.showSeq(i,n,void 0,e,l,a,r)}else if(s.cfg.blast_rep_id==i&&(void 0!==t.seqStructAlignData||void 0!==t.seqStructAlignDataSmithwm)){let e,l,r,o,a,d=s.cfg.oriQuery_id?s.cfg.oriQuery_id:s.cfg.query_id;if(e=d.length>14?"Query: "+d.substr(0,6)+"...":isNaN(s.cfg.query_id)?"Query: "+d:"Query: gi "+d,void 0!==t.seqStructAlignData){let e,s,i=t.seqStructAlignData;if(void 0!==i.data){e=i.data[0].query;let t=Object.keys(i.data[0].targets);s=i.data[0].targets[t[0]],s=void 0!==s&&s.hsps.length>0?s.hsps[0]:void 0}if(void 0!==e&&void 0!==s){l=s.scores.e_value.toPrecision(2),l>1e-200&&(l=parseFloat(l).toExponential()),s.scores.bit_score;let t=Object.keys(i.targets);r=i.targets[t[0]].seqdata,o=e.seqdata,a=s.segs}}else{let e=t.seqStructAlignDataSmithwm;l=e.score,r=e.target.replace(/-/g,""),o=e.query.replace(/-/g,""),a=[];let s=-1,i=-1,n=!1,d={};for(let t=0,l=e.target.length;t0)if(i.orifrom-ni.from-l)for(let t=n+1;t
    "+i+"
    "}addButton(e,t,s,i,n,l){return this.icn3d.icn3dui,"
    "}addSnpButton(e,t,s,i,n,l){let r=this.icn3d;return r.icn3dui,"
    "}conservativeReplacement(e,t){let s=this.icn3d.icn3dui,i=-1!==s.parasCls.b62ResArray.indexOf(e)?s.parasCls.b62ResArray.indexOf(e):s.parasCls.b62ResArray.length-1,n=-1!==s.parasCls.b62ResArray.indexOf(t)?s.parasCls.b62ResArray.indexOf(t):s.parasCls.b62ResArray.length-1;return s.parasCls.b62Matrix[i][n]>0}getColorhexFromBlosum62(e,t){let s=this.icn3d.icn3dui;e=e.toUpperCase(),t=t.toUpperCase();let i=-1!==s.parasCls.b62ResArray.indexOf(e)?s.parasCls.b62ResArray.indexOf(e):s.parasCls.b62ResArray.length-1,n=-1!==s.parasCls.b62ResArray.indexOf(t)?s.parasCls.b62ResArray.indexOf(t):s.parasCls.b62ResArray.length-1,l=s.parasCls.b62Matrix[i][n];if(void 0===l)return"333333";let r="333333";if(l>0){let e=221-parseInt(l/11*221),t=e<10?"0"+e.toString(16):e.toString(16);r="DD"+t+t}else{let e=221-parseInt(-1*l/4*221),t=e<10?"0"+e.toString(16):e.toString(16);r=t+t+"DD"}return r}}class Tt{constructor(e){this.icn3d=e}showSeq(e,t,s,i,n,l,r){let o,a=this.icn3d,d=a.icn3dui,c=!1;if(void 0===d.cfg.mmdbid&&void 0===d.cfg.gi&&void 0===d.cfg.blast_rep_id&&void 0===d.cfg.align&&void 0===d.cfg.chainalign&&void 0===d.cfg.mmdbafid){c=!0,o=[];for(let t=0;t10){u='
    ';let t=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]);void 0===d.cfg.mmdbid&&void 0===d.cfg.gi&&void 0===d.cfg.blast_rep_id&&void 0===d.cfg.align&&void 0===d.cfg.chainalign&&void 0===d.cfg.mmdbafid||void 0===t.resi_ori||t.resi_ori==t.resi||-1!=e.indexOf("Misc")?u+='
    ':u+='
    NCBI Residue Numbers
    ',u+='',b+=u+"
    ",g+=u+'';let s=0,i=0,n="";for(let t=0,l=o.length;t",l%10==0&&(g+=l);let r=e+"_"+l,o=l%10!=0&&l%10!=1&&l%10!=9;if(a.residues.hasOwnProperty(r)){let e=a.firstAtomObjCls.getFirstCalphaAtomObj(a.residues[r]);"H"==a.secondaries[r]&&e.ssbegin?(++s,n='H'+s+"",o&&(g+=n,n="")):"E"==a.secondaries[r]&&e.ssbegin?(++i,"green"==a.sheetcolor?n='S'+i+"":"yellow"==a.sheetcolor&&(n='S'+i+""),o&&(g+=n,n="")):e.ssend&&(n=""),""!=n&&o&&(g+=n,n="")}g+=""}g+='',g+="",g+="
    ",g+="
    ",b+=""}u='
    ',u+='
    ',u+='',b+=u+"
    ",g+=u+'';for(let t=0,s=o.length;t':'',g+=" ";else if("E"==a.secondaries[s]){a.firstAtomObjCls.getFirstCalphaAtomObj(a.residues[s]).ssend?"green"==a.sheetcolor?g+='':"yellow"==a.sheetcolor&&(g+=''):"green"==a.sheetcolor?g+='':"yellow"==a.sheetcolor&&(g+=''),g+=" "}else"c"==a.secondaries[s]?g+=' ':"o"==a.secondaries[s]&&(g+=' ');else g+="-"}g+='',g+="",g+="
    ",g+="
    ",g+="",b+="",u=d.cfg.blast_rep_id===e?'
    ':'
    ';let C="Protein",y="Protein";void 0!==s&&("nucleotide"==s?(C="Nucl.",y="Nucleotide"):"chemical"==s&&(C="Chem.",y="Chemical")),u+='",u+=''+(a.baseResi[e]+1).toString()+"",b+=u+"
    ";let v='';g+=u+v,f+=u+v;let w,_=0;for(let t=0,s=o.length;t1&&(i=s[0]+".."),w=a.ParserUtilsCls.getResi(e,t),a.residues.hasOwnProperty(e+"_"+w)){let n="333333";if(d.cfg.blast_rep_id==e&&void 0!==a.fullpos2ConsTargetpos&&void 0!==a.fullpos2ConsTargetpos[t+_])n=a.fullpos2ConsTargetpos[t+_].color;else{let t=a.firstAtomObjCls.getFirstCalphaAtomObj(a.residues[e+"_"+w]),s=void 0===t.color||"FFFFFF"===t.color.getHexString()?"DDDDDD":t.color.getHexString();n=void 0!==t.color?s:"CCCCCC"}g+=''+i+""}else i=i.toLowerCase(),g+=''+i+""}d.cfg.blast_rep_id==e&&(a.opts.color=a.blastAcxn?"confidence":"conservation",a.setColorCls.setColorByOptions(a.opts,a.atoms));let S=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]),A=S.color?S.color.getHexString():"CCCCCC",x=Math.round(a.seqAnnWidth*o.length/a.maxAnnoLength);if(x<1&&(x=1),d.cfg.blast_rep_id!=e)f+='";else{let t=[],s=[];t.push(0);for(let e=0,i=o.length;e';for(let i=0,n=t.length;i'+e+"
    ";f+="
    "}if(u=''+w+"",u+="",u+="
    ",g+=u,f+=u,d.cfg.blast_rep_id==e){if(void 0!==r&&""!==r){u='",u+='',b+=u+"
    ";let t='';g+=u+t,f+=u+t;let s=0,i=0,l=1;a.queryStart;for(let t=0,n=r.length;t-";else if(" "==n)g+=" ";else{let r=a.fullpos2ConsTargetpos[t].pos;if(a.residues.hasOwnProperty(e+"_"+r)){let s=a.fullpos2ConsTargetpos[t].color;g+=''+n+""}else n=n.toLowerCase(),g+=''+n+"";f+=this.insertGapOverview(e,t);let o=Math.round(a.seqAnnWidth*t/(a.maxAnnoLength+a.nTotalGap)-s-i);o>=0&&(f+='
     
    ',f+='
     
    ',s+=o,i+=l)}}u='',u+="",u+="
    ",g+=u,f+=u}u='
    '+i+"
    ",u+=''+a.queryStart+"",b+=u+"
    ";let t='';g+=u+t,f+=u+t;let s=a.queryStart;for(let t=0,i=l.length;t-":(void 0===a.fullpos2ConsTargetpos||void 0===a.fullpos2ConsTargetpos[t]||a.residues.hasOwnProperty(e+"_"+a.fullpos2ConsTargetpos[t].pos)||(i=i.toLowerCase()),g+=''+i+"",++s)}let o=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]),d=void 0===o.color||"FFFFFF"===o.color.getHexString()?"DDDDDD":o.color.getHexString(),c=void 0!==o.color?d:"CCCCCC",h=[],p=[],m="-";for(let e=0,t=l.length;e ',f+='
    '+i+"
    "}u=''+a.queryEnd+"",u+="",u+="
    ",g+=u,f+=u}if(g+="",f+="",b+="",a.giSeq[e].length>10){let t=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]);if(void 0===d.cfg.mmdbid&&void 0===d.cfg.gi&&void 0===d.cfg.blast_rep_id&&void 0===d.cfg.align&&void 0===d.cfg.chainalign&&void 0===d.cfg.mmdbafid||void 0===t.resi_ori||t.resi_ori==t.resi||-1!=e.indexOf("Misc")){if(a.bShowRefnum&&a.chainid2index.hasOwnProperty(e)){let t=this.showRefNum(o,e);g+=t.html,b+=t.html3;let s=1;t=this.showRefNum(o,e,s),g+=t.html,b+=t.html3,s=2,t=this.showRefNum(o,e,s),g+=t.html,b+=t.html3}else if(a.bShowCustomRefnum&&a.chainsMapping.hasOwnProperty(e)){let t=!0,s=this.showRefNum(o,e,void 0,t);g+=s.html,b+=s.html3}}else{u='
    ',u+='
    ',u+='
    PDB Residue Numbers
    ',u+='',b+=u+"
    ",g+=u+'';for(let t=0,s=o.length;t",e%10==0&&(g+=e+" "),g+=""}else g+=""}g+='',g+="",g+="
    ",g+="
    ",g+="
    ",b+=""}}a.bShowRefnum&&(a.hAtoms=a.hAtomsRefnum,a.hlUpdateCls.updateHlAll()),$("#"+a.pre+"dt_giseq_"+e).html(g),$("#"+a.pre+"ov_giseq_"+e).html(f),$("#"+a.pre+"tt_giseq_"+e).html(b)}showRefNum(e,t,s,i){let n=this.icn3d;n.icn3dui;let l="",r="",o="";for(let e=0,s=n.chainid2index[t].length;eCustom Ref. No.':1==s?'
    Kabat Ref. No.
    ':2==s?'
    IMGT Ref. No.
    ':'
    IgStRAnD Ref. No.
    ',d+='',r+=d+"
    ",l+=d+'';let c=!1;for(let s=0,l=e.length;s0){c=!0;break}}if(1==s&&!c)return{html:"",html3:""};let h=!1;for(let s=0,l=e.length;s0){h=!0;break}}if(2==s&&!h)return{html:"",html3:""};let p,m,u,g,f,b,C,y,v,w=!1,_="",S="",A="",x=1,k={},O=1,R="",E=!1;for(let l=0,r=e.length;l1e3&&"9"!=u.substr(1,1)&&(x=1,E&&R&&(delete k[R],R="")),S&&" "!=_&&f>1e3&&"9"==u.substr(1,1)&&(1==x&&(k.hasOwnProperty(_+g)&&++O,g=u.replace(f.toString(),"")+"_"+O,k[_+g]={},k[_+g].start=b,k[_+g].chainid=t),u=(1e3*parseInt(A)+900+x).toString(),p=_+u,++x))):!S||" "==_||i||s||(1==x&&(k.hasOwnProperty(_+g)?(++O,g=u.replace(f.toString(),"")+"_"+O,k[_+g]={}):k[_+g]={},k[_+g].start=b,k[_+g].chainid=t,R=_+g,E=!0),u=(1e3*parseInt(A)+900+x).toString(),p=_+u,++x),b=u,y=f,C=g,S=_}k[S+C]&&(k[S+C].len=x-1,k[S+C].end=b),O=1,R="",E=!1;let I,T={},M=!0;for(let r=0,o=e.length;r1e3&&"9"!=u.substr(1,1)&&(x=1,E&&R&&(--O,R="")),S&&f>1e3&&"9"==u.substr(1,1)){w=!0,1==x&&(T.hasOwnProperty(I+g)&&(++O,g=u.replace(f.toString(),"")+"_"+O),T[I+g]=1);let e=this.getAdjustedRefnum(k,I,x,A,g,y);f=e.refnum,M=e.bShowRefnum,u=e.refnumStr,p=e.refnumLabel,v=e.refnumLabelNoPostfix,a=e.bHidelabel,_=p.replace(new RegExp(u,"g"),""),++x}y=f}if(i)if(u){l+=parseInt(u)%2==0?''+u+"":' '}else l+="";else if(1==s||2==s)if(u){let e=parseInt(u).toString(),t='style="color:'+this.getRefnumColor(_)+'"';l+=parseInt(e.substr(e.length-2,2))%2==0?"'+u+"":" '}else l+="";else M&&" "!=_?(l+=this.getRefnumHtml(e,u,m,p,_,w,a),w&&(n.residIgLoop[e]=1)):l+=""}else{let t=n.firstAtomObjCls.getFirstAtomObj(n.residues[e]);if(t&&!n.proteins.hasOwnProperty(t.serial)||!S||i||s||I&&"G"==I.substr(0,1))l+="";else{w=!0,1==x&&(T.hasOwnProperty(I+g)&&++O,g=u.replace(f.toString(),"")+"_"+O,T[I+g]=1,E=!0,R=I+g);let t=this.getAdjustedRefnum(k,I,x,A,g,y);f=t.refnum,M=t.bShowRefnum,u=t.refnumStr,p=t.refnumLabel,v=t.refnumLabelNoPostfix,y=f,a=t.bHidelabel,_=p.replace(new RegExp(u,"g"),""),++x,M&&" "!=_?(l+=this.getRefnumHtml(e,u,m,p,_,w,a),w&&(n.residIgLoop[e]=1)):l+=""}}n.resid2refnum[e]=p,n.refnum2residArray.hasOwnProperty(u)?n.refnum2residArray[u].push(e):n.refnum2residArray[u]=[e],n.chainsMapping.hasOwnProperty(t)||(n.chainsMapping[t]={}),n.chainsMapping[t][e]=v,S=I}return l+='',l+="",l+="
    ",l+="",l+="",r+="",{html:l,html3:r}}getAdjustedRefnum(e,t,s,i,n,l){let r,o,a,d;this.icn3d.icn3dui;let c=!1,h=!0;if(e[t+n]){let i=parseInt(e[t+n].start),p=parseInt(e[t+n].end),m=e[t+n].start.replace(i.toString(),""),u=e[t+n].end.replace(p.toString(),""),g=e[t+n].len;s<=(e[t+n].nextStrand?parseInt(g/2+.5):g)?(r=i+s,o=r+m,a=t+o):(r=p-(g+1-s),o=r+u,a=void 0!==e[t+n].nextStrand?e[t+n].nextStrand+o:" "+o),d=t+r,1!=s&&s!=p-1||(c=!0),1==s&&i!=l&&(h=!1,r=0,o="",a="",d="")}else r=0,o="",a="",d="",c=!0;return{refnum:r,refnumStr:o,refnumLabel:a,refnumLabelNoPostfix:d,bHidelabel:c,bShowRefnum:h}}getRefnumHtml(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui,d=parseInt(t).toString(),c=this.getRefnumColor(n),h=l?'style="color:'+c+'"':'style="color:'+c+'; text-decoration: underline overline;"',p=parseInt(d.substr(d.length-2,2));parseInt(d.substr(d.length-3,3));let m="";if(50!=p||l)if(p%2!=0||52==p||r)m+=" ';else{m+="'+(isNaN(t)?p+t.substr(t.length-1,1):p)+""}else o.hAtomsRefnum=a.hashUtilsCls.unionHash(o.hAtomsRefnum,o.residues[e]),m+="'+i.substr(0,1)+""+i.substr(1)+"";return m}getRefnumColor(e){let t=this.icn3d.icn3dui;return"A^"==e?"#FF00FF":"A"==e?"#663399":"A*"==e?"#FFC0CB":"A'"==e?"#9370db":"B"==e?"#ba55d3":"C"==e?"#0000FF":"C'"==e?"#6495ED":"C''"==e?"#006400":"D"==e?"#00FF00":"E"==e?"#FFFF00":"F"==e?"#FFA500":"G"==e?"#FF0000":"G*"==e?"#8B0000":t.htmlCls.GREYB}insertGap(e,t,s,i){let n=this.icn3d;n.icn3dui;let l="";if(void 0!==n.targetGapHash&&n.targetGapHash.hasOwnProperty(t))for(let e=0;e"+s+"";return l}insertGapOverview(e,t){let s=this.icn3d,i="";if(s.icn3dui.cfg.blast_rep_id==e&&void 0!==s.targetGapHash&&s.targetGapHash.hasOwnProperty(t)){i+='
     
    '}return i}setAlternativeSeq(e,t){let s=this.icn3d;s.icn3dui;let i=s.chainsSeq[e];s.giSeq[e]=[];for(let t=0,n=i.length;t1&&s.htmlCls.clickMenuCls.setLogCmd("select sets "+e,!0)}else{let o={};if(void 0!==$(e).attr("domain")||void 0!==$(e).attr("feat")||void 0!==$(e).attr("3ddomain")||void 0!==$(e).attr("custom")){t.hlUpdateCls.hlSummaryDomain3ddomain(e);let a,d,c,h=$(e).attr("from").split(","),p=$(e).attr("to").split(",");r.substr(0,r.indexOf("_"));for(let s=0,i=h.length;s1&&s.htmlCls.clickMenuCls.setLogCmd("select sets "+c,!0)}}else{t.bCtrl||t.bShift?(t.currSelectedSets.push(i),t.selectionCls.selectAChain(r,i,!0,!0)):(t.currSelectedSets=[i],t.selectionCls.selectAChain(r,i,t.bAlignSeq)),t.bAlignSeq?s.htmlCls.clickMenuCls.setLogCmd("select alignChain "+r,!0):s.htmlCls.clickMenuCls.setLogCmd("select chain "+r,!0);let e=t.currSelectedSets.join(" or ");t.currSelectedSets.length>1&&s.htmlCls.clickMenuCls.setLogCmd("select sets "+e,!0)}else t.hlObjectsCls.removeHlObjects(),t.hlUpdateCls.removeHl2D(),$("#"+t.pre+"atomsCustom").val("")}}selectResidues(e,t){let s=this.icn3d,i=s.icn3dui;if(!i.bNode&&(!1!==s.bSelectResidue||s.bShift||s.bCtrl||s.selectionCls.removeSelection(),void 0!==e&&""!==e)){e=e.substr(e.indexOf("_")+1),s.bSelectResidue=!0,$(t).toggleClass("icn3d-highlightSeq");let n=e.substr(e.indexOf("_")+1);if(s.residues.hasOwnProperty(n))if($(t).hasClass("icn3d-highlightSeq")){for(let e in s.residues[n])s.hAtoms[e]=1;if(s.selectedResidues[n]=1,s.bAnnotations&&void 0!==$(t).attr("disease")){let e=$(t).attr("disease"),l=s.applyCenterCls.centerAtoms(i.hashUtilsCls.hash2Atoms(s.residues[n],s.atoms)),r=15;e.length>r&&(e=e.substr(0,r)+"...");let o=s.LABELSIZE,a=i.htmlCls.GREYD;s.analysisCls.addLabel(e,l.center.x,l.center.y,l.center.z,o,a,void 0,"custom")}}else{for(let e in s.residues[n])delete s.hAtoms[e];delete s.selectedResidues[n],s.hlObjectsCls.removeHlObjects()}}}}class Pt{constructor(e){this.icn3d=e}update2DdgmContent(){let e=this.icn3d,t=e.icn3dui,s="";void 0!==t.cfg.mmdbid||void 0!==t.cfg.gi?(s+=e.diagram2dCls.draw2Ddgm(e.interactionData,e.inputid,void 0,!0),s+=e.diagram2dCls.set2DdgmNote(),$("#"+e.pre+"dl_2ddgm").html(s)):e.mmdbidArray&&(void 0!==t.cfg.align||void 0!==t.cfg.chainalign||e.bRealign)&&(s+=e.diagram2dCls.draw2Ddgm(e.interactionData1,e.mmdbidArray[0].toUpperCase(),0,!0),void 0!==e.mmdbid_q&&e.mmdbid_q===e.mmdbid_t?s+=e.diagram2dCls.draw2Ddgm(e.interactionData2,e.mmdbidArray[0].toUpperCase(),1,!0):s+=e.diagram2dCls.draw2Ddgm(e.interactionData2,e.mmdbidArray[1].toUpperCase(),1,!0),s+=e.diagram2dCls.set2DdgmNote(!0),$("#"+e.pre+"dl_2ddgm").html(s))}changeSeqColor(e){let t=this.icn3d,s=t.icn3dui;for(let i=0,n=e.length;i0&&($("#"+e.pre+"dl_2ddgm svg line").attr("stroke","#000000"),$("#"+e.pre+"dl_2ddgm line").attr("stroke-width",1))}removeHlMenus(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"atomsCustom").val(""),$("#"+e.pre+"atomsCustom")[0].blur()}updateHlAll(e,t,s,i){let n=this.icn3d,l=n.icn3dui;n.prevHighlightAtoms=l.hashUtilsCls.cloneHash(n.hAtoms),this.updateHlObjects(i),void 0!==e?this.updateHlSeqInChain(e,s):this.updateHlSeq(void 0,void 0,s),this.updateHl2D(),(void 0===t||t)&&this.updateHlMenus(e)}updateHlObjects(e){let t=this.icn3d;t.icn3dui,t.hlObjectsCls.removeHlObjects(),(t.hAtoms&&t.atoms&&Object.keys(t.hAtoms).length0&&(e=s.defNames2Residues[i]);let t={};if(void 0!==s.defNames2Atoms[i]&&s.defNames2Atoms[i].length>0){for(let e=0,n=s.defNames2Atoms[i].length;e0&&(r=t.firstAtomObjCls.getFirstCalphaAtomObj(l))}let o=void 0!==r&&void 0!==r.color?"#"+r.color.getHexString():"#FFFFFF",a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] rect[class='icn3d-hlnode']"),d=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] rect[class='icn3d-basenode']");void 0!==a&&(t.diagram2dCls.highlightNode("rect",a,d,l),$(a).attr("fill",o)),a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] circle[class='icn3d-hlnode']"),d=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] circle[class='icn3d-basenode']"),void 0!==a&&(t.diagram2dCls.highlightNode("circle",a,d,l),$(a).attr("fill",o)),a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] ellipse[class='icn3d-hlnode']"),void 0!==a&&t.diagram2dCls.highlightNode("ellipse",a,void 0,l),a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] polygon[class='icn3d-hlnode']"),d=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] polygon[class='icn3d-basenode']"),void 0!==a&&(t.diagram2dCls.highlightNode("polygon",a,d,l),$(a).attr("fill",o))}if(void 0!==t.lineArray2d)for(let e=0,i=t.lineArray2d.length;e1){let e={},l=[],o=[],a=[],c=[],h=[],m=[],u=[],g=[],f=[],b=[],C=[],y=[],v={};for(let t=0,s=p.length;t0&&(E=1,t=i.getGraphCls.getNodeTopBottom(c[e],d,void 0,E,g[e]),h[e]=t.nodeArray1,m[e]=t.nodeArray2,d=n.hashUtilsCls.unionHash(d,t.name2node),E=2,t=i.getGraphCls.getNodeTopBottom(c[e],d,void 0,E,y[e]),f[e]=t.nodeArray1,b[e]=t.nodeArray2,d=n.hashUtilsCls.unionHash(d,t.name2node)),x[e]=l[e].length,k[e]=o[e].length,O=Math.max(O,k[e]),R.push(p[e])}let I,T,M,P,D,H=1,F=3*H,L=7*H,N=10,U=10,q=30,$=20;t?(M=(n.utilsCls.sumArray(x)+2*R.length)*(F+L)+4*U+2*q+$*R.length,T=(O+2)*(F+L)+2*N+q):(I=110+$,M=I*R.length,T=(O+2)*(F+L)+2*N),Object.keys(i.chainsMapping).length>0&&(M*=3),t?(i.scatterplotWidth=2*T,D=i.scatterplotWidth,P=n.scatterplotid):(i.linegraphWidth=2*T,D=i.linegraphWidth,P=n.linegraphid),s=0==R.length?"No interactions found for each structure

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

    ",s+="";let j,B=0;E=0,j=this.drawGraphPerType(E,p,t,l,o,a,d,B,I,$,x,F,L,U),B=j.heightFinal,s+=j.html,Object.keys(i.chainsMapping).length>0&&(E=1,j=this.drawGraphPerType(E,p,t,h,m,u,d,B,I,$,x,F,L,U),B=j.heightFinal,s+=j.html,E=2,j=this.drawGraphPerType(E,p,t,f,b,C,d,B,I,$,x,F,L,U),B=j.heightFinal,s+=j.html),s+=""}else if(t){let e,t,l,c,h=p[0],m=o.length,u=a.length,g=1,f=3*g,b=7*g,C=30;t=(m+2)*(f+b)+2*10+C,e=(u+2)*(f+b)+2*10+C,i.scatterplotWidth=2*e,c=i.scatterplotWidth,l=n.scatterplotid,s=r.length>0?"":"No interactions found for these two sets

    ",s+="",s+=this.drawScatterplot_base(o,a,r,d,0),i.lineGraphStr+=i.getGraphCls.updateGraphJson(h,1,o,a,r),s+=""}else{let e=p[0],t=o.length,l=a.length,c=1,h=3*c,m=7*c,u=110,g=10,f=t>l?t*(h+m)+2*g:l*(h+m)+2*g;i.linegraphWidth=2*f,s=r.length>0?"":"No interactions found for these two sets

    ",s+="",s+=this.drawLineGraph_base(o,a,r,d,0),i.lineGraphStr+=i.getGraphCls.updateGraphJson(e,1,o,a,r),s+=""}return i.lineGraphStr+="}\n",i.scatterplotStr=i.lineGraphStr,t?$("#"+i.pre+"scatterplotDiv").html(s):$("#"+i.pre+"linegraphDiv").html(s),s}drawGraphPerType(e,t,s,i,n,l,r,o,a,d,c,h,p,m){let u=this.icn3d;u.icn3dui;let g,f,b="",C=2==t.length&&"2"==t[1].replace(t[0],"");0==e?(g="Interactions in ",f=""):1==e?(g="Common interactions in ",f="_common"):2==e&&(g="Different interactions in ",f="_diff");for(let y=0,v=t.length;y0&&(u.lineGraphStr+=", \n"):u.lineGraphStr+=", \n",u.lineGraphStr+=u.getGraphCls.updateGraphJson(t[y],y+f,i[y],n[y],l[y])}return{heightFinal:o,html:b}}getIdArrayFromNode(e){let t=this.icn3d.icn3dui,s=[];s.push(""),s.push("");let i=e.r.substr(4);return s=s.concat(t.utilsCls.getIdArray(i)),s}drawLineGraph_base(e,t,s,i,n,l,r){let o,a,d=this.icn3d,c=d.icn3dui,h="",p=e.length,m=t.length;p>m?(o=10,a=10*Math.abs(p-m)*.5+10):(a=10,o=10*Math.abs(p-m)*.5+10),l&&(h+=""+l+"");let u=30+n,g=80+n,f="",b={},C={};for(let t=0;t",h+="Interaction of residue "+n.id+" with residue "+l.id+"",h+="")}return h+=f,h}drawScatterplot_base(e,t,s,i,n,l,r,o,a){let d=this.icn3d;d.icn3dui;let c="",h=e.length,p=t.length,m=l?3:7,u=(h+1)*(3+m)+30+40;r&&(c+=""+r+"");let g=n+u-(50+(3+m)),f=40+(3+m),b="",C={},y={};for(let t=0;t"):(h+="",h+="Interaction of residue "+t.id+" with residue "+s.id+"",h+=l?"":"",h+=""))),h}copyStylesInline(e,t){this.icn3d.icn3dui;let s=["svg","g"];for(let i=0;i";return b+=""+e.id+"",o?(b+="",b+=""+g+""):(b+="",b+=""+g+""),b+="",b}getNodeTopBottom(e,t,s,i,n){let l=this.icn3d.icn3dui,r=this,o=[],a=[],d={};for(let s in e){let e=t[s];if(e){if(1==i||2==i){if(e=l.hashUtilsCls.cloneHash(e),1==i){let t=n[s]?n[s]:"-";e.id+="=>"+t}else{let t=n[s]?n[s]:"--";e.id+="==>"+t}d[e.id]=e}"a"==e.s?o.push(e):"b"==e.s?a.push(e):"ab"==e.s&&(o.push(e),a.push(e))}}return o.sort((function(e,t){return r.compNode(e,t)})),a.sort((function(e,t){return r.compNode(e,t,s)})),{nodeArray1:o,nodeArray2:a,name2node:d}}updateGraphJson(e,t,s,i,n){let l=this.icn3d.icn3dui,r="";return r+='"structure'+t+'": {"id": "'+e+'", "nodes1":[',r+=l.utilsCls.getJSONFromArray(s),r+='], \n"nodes2":[',r+=l.utilsCls.getJSONFromArray(i),r+='], \n"links":[',r+=l.utilsCls.getJSONFromArray(n),r+="]}",r}updateGraphColor(){let e=this.icn3d,t=e.icn3dui;if(void 0!==e.graphStr){let s=JSON.parse(e.graphStr),i={};for(let t in e.residues){let s=e.firstAtomObjCls.getFirstAtomObj(e.residues[t]);i[t]=s.color.getHexString().toUpperCase()}let n={};for(let e=0,l=s.nodes.length;e0&&c==e.chain&&(n.resid2ncbi[e.resi]==n.resid2ncbi[p]+1||n.resid2ncbi[e.resi]==n.resid2ncbi[p])&&(o.push('{"source": "'+h+'", "target": "'+u+'", "v": '+d+', "c": "'+f+'"}'),e.ssbegin&&(d=l.htmlCls.ssValue),e.ssend&&(d=l.htmlCls.coilValue)),c=e.chain,h=u,p=e.resi,++a}}return{node:r,link:o}}getHbondLinksForSet(e,t){let s=this.icn3d,i=s.icn3dui,n={},l=parseFloat($("#"+s.pre+"hbondthreshold").val()),r=e,o=r;if(Object.keys(o).length>0&&Object.keys(r).length>0){let e=!1;s.hBondCls.calculateChemicalHbonds(i.hashUtilsCls.intHash2Atoms(s.dAtoms,o,s.atoms),i.hashUtilsCls.intHash2Atoms(s.dAtoms,r,s.atoms),parseFloat(l),e,"graph",!0),n=i.hashUtilsCls.cloneHash(s.resid2Residhash)}return this.getGraphLinks(n,n,i.htmlCls.hbondInsideColor,t,i.htmlCls.hbondValuehbondInsideValue)}getIonicLinksForSet(e,t){let s=this.icn3d,i=s.icn3dui,n={},l=parseFloat($("#"+s.pre+"saltbridgethreshold").val()),r=e,o=r;if(Object.keys(o).length>0&&Object.keys(r).length>0){let e=!1;s.saltbridgeCls.calculateIonicInteractions(i.hashUtilsCls.intHash2Atoms(s.dAtoms,o,s.atoms),i.hashUtilsCls.intHash2Atoms(s.dAtoms,r,s.atoms),parseFloat(l),e,"graph",!0),n=i.hashUtilsCls.cloneHash(s.resid2Residhash)}return this.getGraphLinks(n,n,i.htmlCls.ionicInsideColor,t,i.htmlCls.ionicInsideValue)}getHalogenPiLinksForSet(e,t){let s,i=this.icn3d,n=i.icn3dui,l={},r=e,o=r,a="";return s=parseFloat($("#"+i.pre+"halogenthreshold").val()),Object.keys(o).length>0&&Object.keys(r).length>0&&(i.piHalogenCls.calculateHalogenPiInteractions(n.hashUtilsCls.intHash2Atoms(i.dAtoms,r,i.atoms),n.hashUtilsCls.intHash2Atoms(i.dAtoms,o,i.atoms),parseFloat(s),"graph","halogen",!0),l=n.hashUtilsCls.cloneHash(i.resid2Residhash)),a+=this.getGraphLinks(l,l,n.htmlCls.halogenInsideColor,t,n.htmlCls.halogenInsideValue),s=parseFloat($("#"+i.pre+"picationthreshold").val()),Object.keys(o).length>0&&Object.keys(r).length>0&&(i.piHalogenCls.calculateHalogenPiInteractions(n.hashUtilsCls.intHash2Atoms(i.dAtoms,r,i.atoms),n.hashUtilsCls.intHash2Atoms(i.dAtoms,o,i.atoms),parseFloat(s),"graph","pi-cation",!0),l=n.hashUtilsCls.cloneHash(i.resid2Residhash)),a+=this.getGraphLinks(l,l,n.htmlCls.picationInsideColor,t,n.htmlCls.picationInsideValue),s=parseFloat($("#"+i.pre+"pistackingthreshold").val()),Object.keys(o).length>0&&Object.keys(r).length>0&&(i.piHalogenCls.calculateHalogenPiInteractions(n.hashUtilsCls.intHash2Atoms(i.dAtoms,r,i.atoms),n.hashUtilsCls.intHash2Atoms(i.dAtoms,o,i.atoms),parseFloat(s),"graph","pi-stacking",!0),l=n.hashUtilsCls.cloneHash(i.resid2Residhash)),a+=this.getGraphLinks(l,l,n.htmlCls.pistackingInsideColor,t,n.htmlCls.pistackingInsideValue),a}getContactLinksForSet(e,t,s){let i=this.icn3d;i.icn3dui;let n=[],l="",r="",o={};for(let t in e){let e=i.atoms[t];e.ss==l&&e.chain==r||(Object.keys(o).length>0&&n.push(o),o={}),o[e.serial]=1,l=e.ss,r=e.chain}Object.keys(o).length>0&&n.push(o);let a=n.length,d="";for(let e=0;ed?s?-1:1:ah?1:c0&&Object.keys(a).length>0)){let t,s=c.hBondCls.calculateChemicalHbonds(h.hashUtilsCls.intHash2Atoms(c.dAtoms,d,c.atoms),h.hashUtilsCls.intHash2Atoms(c.dAtoms,a,c.atoms),parseFloat(e),n);n?(c.resid2ResidhashSaltbridge=h.hashUtilsCls.cloneHash(c.resid2Residhash),t="all atoms that have salt bridges with the selected atoms"):(c.resid2ResidhashHbond=h.hashUtilsCls.cloneHash(c.resid2Residhash),t="all atoms that are hydrogen-bonded with the selected atoms");let i={};for(let e in s){i[c.atoms[e].structure+"_"+c.atoms[e].chain+"_"+c.atoms[e].resi]=1}c.hAtoms={};for(let e in i)for(let t in c.residues[e])c.hAtoms[t]=1,c.atoms[t].style2="stick";let l=r+"_auto";c.selectionCls.addCustomSelection(Object.keys(i),l,t,o,!0),c.selectionCls.saveSelectionIfSelected(),c.drawCls.draw()}}showHydrogens(){let e=this.icn3d;if(void 0!==e.icn3dui.cfg.cid)for(let t in e.hAtoms){let s=e.atoms[t];if("H"!==s.elem.substr(0,1)){e.atoms[s.serial].bonds=e.atoms[s.serial].bonds2.concat(),e.atoms[s.serial].bondOrder=e.atoms[s.serial].bondOrder2.concat();for(let t=0,i=e.atoms[s.serial].bonds.length;t0){let i=e.atoms[t].bonds[0];e.atoms[i].bonds.push(s.serial),e.atoms[i].bondOrder&&e.atoms[i].bondOrder.push(1)}e.dAtoms[t]=1}}e.bShowHighlight=!1}hideHydrogens(){let e=this.icn3d;e.icn3dui;for(let t in e.hAtoms){let s=e.atoms[t];if("H"===s.elem.substr(0,1)){if(e.atoms[s.serial].bonds.length>0){let t=e.atoms[s.serial].bonds[0],i=e.atoms[t].bonds?e.atoms[t].bonds.indexOf(s.serial):-1;-1!==i&&(e.atoms[t].bonds.splice(i,1),e.atoms[t].bondOrder&&e.atoms[t].bondOrder.splice(i,1))}delete e.dAtoms[s.serial],delete e.hAtoms[s.serial]}}}hideHbondsContacts(){let e=this.icn3d,t=e.icn3dui,s="set hbonds off";t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.hBondCls.hideHbonds(),s="set salt bridge off",t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.saltbridgeCls.hideSaltbridge(),s="set contact off",t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.contactCls.hideContact(),s="set halogen pi off",t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.piHalogenCls.hideHalogenPi()}showIonicInteractions(e,t,s,i,n,l){let r,o,a,d,c=this.icn3d,h=c.icn3dui;if(!i&&(r="saltbridge",o="salt bridge "+e+" | sets "+t+" "+s+" | "+i,c.opts.saltbridge="yes",a=c.definedSetsCls.getAtomsFromNameArray(t),d=c.definedSetsCls.getAtomsFromNameArray(s),c.firstAtomObjCls.getFirstAtomObj(a),Object.keys(d).length>0&&Object.keys(a).length>0)){let t,s=c.saltbridgeCls.calculateIonicInteractions(h.hashUtilsCls.intHash2Atoms(c.dAtoms,d,c.atoms),h.hashUtilsCls.intHash2Atoms(c.dAtoms,a,c.atoms),parseFloat(e),n);c.resid2ResidhashSaltbridge=h.hashUtilsCls.cloneHash(c.resid2Residhash),t="all atoms that have ionic interactions with the selected atoms";let i={};for(let e in s){i[c.atoms[e].structure+"_"+c.atoms[e].chain+"_"+c.atoms[e].resi]=1}c.hAtoms={};for(let e in i)for(let t in c.residues[e])c.hAtoms[t]=1,c.atoms[t].style2="stick",c.ions.hasOwnProperty(t)&&(c.atoms[t].style2="sphere");let l="saltbridge_auto";c.selectionCls.addCustomSelection(Object.keys(i),l,t,o,!0),c.selectionCls.saveSelectionIfSelected(),c.drawCls.draw()}}showHalogenPi(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(i)return;let a,d,c=l+" "+e+" | sets "+t+" "+s+" | "+i;if(r.opts[l]="yes",a=r.definedSetsCls.getAtomsFromNameArray(t),d=r.definedSetsCls.getAtomsFromNameArray(s),r.firstAtomObjCls.getFirstAtomObj(a),Object.keys(d).length>0&&Object.keys(a).length>0){let t,s=r.piHalogenCls.calculateHalogenPiInteractions(o.hashUtilsCls.intHash2Atoms(r.dAtoms,a,r.atoms),o.hashUtilsCls.intHash2Atoms(r.dAtoms,d,r.atoms),parseFloat(e),n,l);"halogen"==l?(r.resid2ResidhashHalogen=o.hashUtilsCls.cloneHash(r.resid2Residhash),t="all atoms that have halogen bonds with the selected atoms"):"pi-cation"==l?(r.resid2ResidhashPication=o.hashUtilsCls.cloneHash(r.resid2Residhash),t="all atoms that have pi-cation interactions with the selected atoms"):"pi-stacking"==l&&(r.resid2ResidhashPistacking=o.hashUtilsCls.cloneHash(r.resid2Residhash),t="all atoms that have pi-stacking with the selected atoms");let i={};for(let e in s){i[r.atoms[e].structure+"_"+r.atoms[e].chain+"_"+r.atoms[e].resi]=1}r.hAtoms={};for(let e in i)for(let t in r.residues[e])r.hAtoms[t]=1,r.atoms[t].style2="stick",r.ions.hasOwnProperty(t)&&(r.atoms[t].style2="sphere");let h=l+"_auto";r.selectionCls.addCustomSelection(Object.keys(i),h,t,c,!0),r.selectionCls.saveSelectionIfSelected(),r.drawCls.draw()}}showClbonds(){let e=this.icn3d,t=e.icn3dui;e.opts.clbonds="yes";let s=e.applyClbondsCls.applyClbondsOptions();for(let i in s)e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.residues[i]);if(Object.keys(s).length>0){let t="clbonds",i="all atoms that have cross-linkages";e.selectionCls.addCustomSelection(Object.keys(s),t,i,"cross linkage",!0),e.selectionCls.saveSelectionIfSelected(),e.drawCls.draw()}}showSsbonds(){let e=this.icn3d,t=e.icn3dui;e.opts.ssbonds="yes";let s={},i=Object.keys(e.structures);for(let n=0,l=i.length;n0){let t="ssbonds",i="all atoms that have disulfide bonds";e.selectionCls.addCustomSelection(Object.keys(s),t,i,"disulfide bonds",!0),e.selectionCls.saveSelectionIfSelected(),e.drawCls.draw()}}pickCustomSphere(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(i)return;let a,d,c="select zone cutoff "+e+" | sets "+t+" "+s+" | "+i;n&&(c="interactions "+e+" | sets "+t+" "+s+" | "+i,r.opts.contact="yes"),a=r.definedSetsCls.getAtomsFromNameArray(t),d=r.definedSetsCls.getAtomsFromNameArray(s);let h,p,m=this.pickCustomSphere_base(e,a,d,i,n,l,c,!0),u=Object.keys(m.residues);r.hAtoms={};for(let e=0,t=u.length;e1?"structure":v>1?"chain":"residue";let _=[];if(n&&_.push("hbonds"),l&&_.push("salt bridge"),r&&_.push("interactions"),o&&_.push("halogen"),a&&_.push("pi-cation"),d&&_.push("pi-stacking"),s||(p.resids2inter={},p.resids2interAll={}),l){let n=parseFloat($("#"+p.pre+"saltbridgethreshold").val());n&&!isNaN(n)||(n=p.tsIonic),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showIonicInteractions(n,e,t,s,!0,i)),g=m.hashUtilsCls.unionHash(g,p.hAtoms)}if(n){let n=parseFloat($("#"+p.pre+"hbondthreshold").val());n&&!isNaN(n)||(n=p.tsHbond),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHbonds(n,e,t,s,void 0,i)),g=m.hashUtilsCls.unionHash(g,p.hAtoms)}let S,A,x,k,O="";if(n&&(O+=this.exportHbondPairs(i,u)),l&&(O+=this.exportSaltbridgePairs(i,u)),o){let n=parseFloat($("#"+p.pre+"halogenthreshold").val());n&&!isNaN(n)||(n=p.tsHalogen),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHalogenPi(n,e,t,s,i,"halogen")),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportHalogenPiPairs(i,u,"halogen")}if(a){let n=parseFloat($("#"+p.pre+"picationthreshold").val());n&&!isNaN(n)||(n=p.tsPication),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHalogenPi(n,e,t,s,i,"pi-cation")),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportHalogenPiPairs(i,u,"pi-cation")}if(d){let n=parseFloat($("#"+p.pre+"pistackingthreshold").val());n&&!isNaN(n)||(n=p.tsPistacking),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHalogenPi(n,e,t,s,i,"pi-stacking")),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportHalogenPiPairs(i,u,"pi-stacking")}if(r){let n=b?c:parseFloat($("#"+p.pre+"contactthreshold").val());if(n&&!isNaN(n)||(n=p.tsContact),1!=e.length||1!=t.length||e[0]!=t[0])s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.pickCustomSphere(n,e,t,s,!0,i)),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportSpherePairs(!0,i,u);else{if(!s){let l={},o={};if(b){let e=!0,t=p.showInterCls.pickCustomSphere_base(n,C,y,s,!0,void 0,void 0,!0,e);l=m.hashUtilsCls.unionHash(l,t.residues);for(let e in t.resid2Residhash)o[e]=m.hashUtilsCls.unionHash(o[e],t.resid2Residhash[e])}else{let r=[],a="",d="",c={};for(let e in C){let t=p.atoms[e];t.ss==a&&t.chain==d||(Object.keys(c).length>0&&r.push(c),c={}),c[t.serial]=1,a=t.ss,d=t.chain}Object.keys(c).length>0&&r.push(c);let h=r.length;A="interactions "+n+" | sets "+e+" "+t+" | true",p.opts.contact="yes";for(let e=0;e
    ",T=p.resid2specCls.atoms2residues(Object.keys(C)),M=p.resid2specCls.atoms2residues(Object.keys(y)),P="select "+p.resid2specCls.residueids2spec(T),D="select "+p.resid2specCls.residueids2spec(M);I+="Set 1: "+e+'
    ',I+="Set 2: "+t+'

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

    ',I+='
    Note: Each checkbox below selects the corresponding residue. You can click "Save Selection" in the "Select" menu to save the selection and click on "Highlight" button to clear the checkboxes.

    ';let U=I;if(("graph"==i||"linegraph"==i||"scatterplot"==i||b)&&(I=""),I+=O,"save1"==i||"save2"==i){I=U;let e="";"save1"==i?e="Set 1":"save2"==i&&(e="Set 2"),I+='

    Interactions Sorted on '+e+':
    ';let t=this.getAllInteractionTable(i);I+=t.html,h=t.bondCnt,$("#"+p.pre+"dl_interactionsorted").html(I),m.htmlCls.dialogCls.openDlg("dl_interactionsorted","Show sorted interactions")}else if("view"==i)$("#"+p.pre+"dl_allinteraction").html(I),m.htmlCls.dialogCls.openDlg("dl_allinteraction","Show interactions");else if("linegraph"==i){m.htmlCls.dialogCls.openDlg("dl_linegraph","Show interactions between two lines of residue nodes"),p.graphStr=p.getGraphCls.getGraphData(C,y,e,t,I,u),p.bLinegraph=!0;let s=p.lineGraphCls.drawLineGraph(p.graphStr);$("#"+p.pre+"linegraphDiv").html(s)}else if("scatterplot"==i){m.htmlCls.dialogCls.openDlg("dl_scatterplot","Show interactions as scatterplot"),p.graphStr=p.getGraphCls.getGraphData(C,y,e,t,I,u),p.bScatterplot=!0;let s=p.lineGraphCls.drawLineGraph(p.graphStr,!0);$("#"+p.pre+"scatterplotDiv").html(s)}else if(b){m.htmlCls.dialogCls.openDlg("dl_contactmap","Show contact map");let s=!0,i=p.getGraphCls.getGraphData(C,y,e,t,I,u,s);p.bContactMap=!0;let n=p.contactMapCls.drawContactMap(i);$("#"+p.pre+"contactmapDiv").html(n)}else if("graph"==i)if(p.graphStr=p.getGraphCls.getGraphData(C,y,e,t,I,u),p.bGraph=!0,Object.keys(y).length+Object.keys(C).length>Object.keys(p.dAtoms).length&&(p.graphStr=p.selectionCls.getGraphDataForDisplayed()),void 0===p.bD3){await m.getAjaxPromise("https://www.ncbi.nlm.nih.gov/Structure/icn3d/script/d3v4-force-all.min.js","script"),p.bD3=!0,$("#"+m.svgid).empty(),m.htmlCls.dialogCls.openDlg("dl_graph","Force-directed graph"),p.drawGraphCls.drawGraph(p.graphStr,p.pre+"dl_graph")}else $("#"+m.svgid).empty(),m.htmlCls.dialogCls.openDlg("dl_graph","Force-directed graph"),p.drawGraphCls.drawGraph(p.graphStr,p.pre+"dl_graph");return{interactionTypes:_.toString(),bondCnt:h}}clearInteractions(){let e=this.icn3d;e.icn3dui,e.lines.hbond=[],e.hbondpnts=[],e.lines.saltbridge=[],e.saltbridgepnts=[],e.lines.contact=[],e.contactpnts=[],e.lines.halogen=[],e.lines["pi-cation"]=[],e.lines["pi-stacking"]=[],e.halogenpnts=[],e.picationpnts=[],e.pistackingpnts=[]}resetInteractionPairs(){let e=this.icn3d;e.icn3dui,e.bHbondCalc=!1,e.showInterCls.hideHbondsContacts(),e.hlUpdateCls.clearHighlight(),e.resids2inter={},e.resids2interAll={}}async retrieveInteractionData(){let e=this.icn3d,t=e.icn3dui;if(!e.b2DShown)if(void 0!==t.cfg.align){let s=Object.keys(e.structures);if(2==t.cfg.atype){let t=!0;await e.alignParserCls.downloadAlignment(s[0]+","+s[1],t)}await e.ParserUtilsCls.set2DDiagramsForAlign(s[0].toUpperCase(),s[1].toUpperCase())}else void 0!==t.cfg.chainalign?(Object.keys(e.structures),await e.ParserUtilsCls.set2DDiagramsForChainalign(e.chainidArray)):e.ParserUtilsCls.download2Ddgm(e.inputid.toUpperCase())}getAllInteractionTable(e){let t=this.icn3d,s=t.icn3dui,i=[],n=Object.keys(t.resids2inter);("save1"==e||"save2"==e)&&n.sort((function(t,i){return s.utilsCls.compResid(t,i,e)}));let l,r,o="",a="",d="",c="",h="",p="",m="",u="",g="",f=0,b=0,C=0,y=0,v=0,w=0,_="";for(let s=0,S=n.length;s0&&l!=a&&(i.push({res1:a,res2:_,cntHbond:f,cntIonic:b,cntContact:C,cntHalegen:y,cntPication:v,cntPistacking:w}),o+=this.getInteractionPerResidue(d,c,h,p,m,u,g,f,b,C,y,v,w),c="",h="",p="",m="",u="",g="",f=0,b=0,C=0,y=0,v=0,w=0,_=""),x=t.resids2inter[S].hbond,k=this.getInteractionPairDetails(x,e,"hbond"),c+=k.html,f+=k.cnt,k.cnt>0&&(_+=r+":hbond_"+k.cnt+" "),x=t.resids2inter[S].ionic,k=this.getInteractionPairDetails(x,e,"ionic"),h+=k.html,b+=k.cnt,k.cnt>0&&(_+=r+":ionic_"+k.cnt+" "),x=t.resids2inter[S].contact,k=this.getContactPairDetails(x,e,"contact"),p+=k.html,C+=k.cnt,k.cnt>0&&(_+=r+":contact_"+k.cnt+" "),x=t.resids2inter[S].halogen,k=this.getInteractionPairDetails(x,e,"halogen"),m+=k.html,y+=k.cnt,k.cnt>0&&(_+=r+":halogen_"+k.cnt+" "),x=t.resids2inter[S]["pi-cation"],k=this.getInteractionPairDetails(x,e,"pi-cation"),u+=k.html,v+=k.cnt,k.cnt>0&&(_+=r+":pi-cation_"+k.cnt+" "),x=t.resids2inter[S]["pi-stacking"],k=this.getInteractionPairDetails(x,e,"pi-stacking"),g+=k.html,w+=k.cnt,k.cnt>0&&(_+=r+":pi-stacking_"+k.cnt+" "),a=l,d=O}i.push({res1:a,res2:_,cntHbond:f,cntIonic:b,cntContact:C,cntHalegen:y,cntPication:v,cntPistacking:w}),o+=this.getInteractionPerResidue(d,c,h,p,m,u,g,f,b,C,y,v,w);let S="";if(n.length>0){S+='
    ',S+="",S+="",S+="",S+="",S+="";let e='';S+=e,S+=e,S+='',S+=e,S+=e,S+=e,S+="",S+="",S+=o,S+="
    Residue# Hydrogen
    Bond
    # Salt Bridge
    /Ionic Interaction
    # Contact# Halogen
    Bond
    # π-Cation# π-StackingHydrogen Bond (backbone atoms: @CA, @N, @C, @O)Salt Bridge/Ionic InteractionContactHalogen Bondπ-Cationπ-Stacking
    Atom1Atom2Distance(Å)Highlight in 3D
    Atom1Atom2# ContactsMin Distance(Å)C-alpha Distance(Å)Highlight in 3D

    "}return{html:S,bondCnt:i}}getInteractionPerResidue(e,t,s,i,n,l,r,o,a,d,c,h,p){this.icn3d.icn3dui;let m="";m+=''+e[3]+e[2]+""+o+""+a+""+d+""+c+""+h+""+p+"";let u=[t,s,i,n,l,r];for(let e in u){m+=''+u[e]+"
    "}return m+="",m}getInteractionPairDetails(e,t,s){let i=this.icn3d;i.icn3dui;let n="",l=0,r='    ';if(void 0!==e)for(let a in e){let d=a.split(","),c="save1"==t?d[0]:d[1],h="save1"==t?d[1]:d[0],p=i.getGraphCls.convertLabel2Resid(c),m=i.firstAtomObjCls.getFirstAtomObj(i.residues[p]),u=m.color?m.color.getHexString():"",g=i.getGraphCls.convertLabel2Resid(h),f=i.firstAtomObjCls.getFirstAtomObj(i.residues[g]),b=f.color?f.color.getHexString():"",C=Math.sqrt(e[a]).toFixed(1);n+=' '+c+r+u+o+' '+h+r+b+o+''+C+"",n+='',n+="",++l}return{html:n,cnt:l}}getContactPairDetails(e,t){let s=this.icn3d;s.icn3dui;let i="",n=0,l='    ';if(void 0!==e)for(let o in e){let a=o.split(","),d="save1"==t?a[0]:a[1],c="save1"==t?a[1]:a[0],h=s.getGraphCls.convertLabel2Resid(d),p=s.firstAtomObjCls.getFirstAtomObj(s.residues[h]),m=p.color?p.color.getHexString():"",u=s.getGraphCls.convertLabel2Resid(c),g=s.firstAtomObjCls.getFirstAtomObj(s.residues[u]),f=g.color?g.color.getHexString():"",b=e[o].split("_"),C=b[0],y=b[1],v=b[2],w=b[3],_=b[4];i+=' '+d+"@"+v+l+m+r+' '+c+"@"+w+l+f+r+''+_+''+C+''+y+"",i+='',i+="",n+=parseInt(_)}return{html:i,cnt:n}}exportInteractions(){var e=this.icn3d;e.icn3dui;let t='

    Interacting residues:
    ';for(let s in e.chainname2residues)for(let i in e.chainname2residues[s]){let n=s.substr(0,s.indexOf("_"))+"_"+i.substr(0,i.indexOf(" "));t+=""}t+="
    Base Chain: ResiduesInteracting Chain
    "+s+": ",t+=e.resid2specCls.residueids2spec(e.chainname2residues[s][i]),t+=""+n+"

    ";let s=e.inputid?e.inputid:"custom";e.saveFileCls.saveFile(s+"_interactions.html","html",t)}exportSsbondPairs(){var e=this.icn3d;e.icn3dui;let t="",s=0;for(let i in e.structures){let n=e.ssbondpnts[i];if(void 0===n)break;for(let e=0,i=n.length;e"+n[e]+" Cys"+n[e+1]+" Cys",++s}}let i='

    '+s+" disulfide pairs:

    ";i+=t,i+="
    Residue ID 1Residue ID 2

    ";let n=e.inputid?e.inputid:"custom";e.saveFileCls.saveFile(n+"_disulfide_pairs.html","html",i)}exportClbondPairs(){var e=this.icn3d;e.icn3dui;let t="",s=0,i={};for(let n in e.structures){let l=e.clbondpnts[n];if(void 0===l)break;for(let n=0,r=l.length;n"+r+" "+i.resn+""+o+" "+n.resn+"",++s}i[r+"_"+o]=1,i[o+"_"+r]=1}}let n='

    '+s+" cross-linkage pairs:

    ";n+=t,n+="
    Residue ID 1Residue ID 2

    ";let l=e.inputid?e.inputid:"custom";e.saveFileCls.saveFile(l+"_crosslinkage_pairs.html","html",n)}exportHbondPairs(e,t){var s=this.icn3d,i=s.icn3dui;let n="",l=0,r='    ';for(let t in s.resid2ResidhashHbond){let i=s.getGraphCls.convertLabel2Resid(t),a=s.firstAtomObjCls.getFirstAtomObj(s.residues[i]),d=a.color?a.color.getHexString():"";for(let i in s.resid2ResidhashHbond[t]){let a=s.getGraphCls.convertLabel2Resid(i),c=s.firstAtomObjCls.getFirstAtomObj(s.residues[a]),h=c.color?c.color.getHexString():"",p=Math.sqrt(s.resid2ResidhashHbond[t][i]).toFixed(1);n+=' '+t+r+d+o+' '+i+r+h+o+''+p+"","view"==e&&(n+=''),n+="",++l}}let a='

    '+l+" hydrogen bond pairs (backbone atoms: @CA, @N, @C, @O):

    ";if(l>0&&(a+="
    ","view"==e&&(a+=''),a+="",a+=n,a+="
    Atom 1Atom 2Distance(Å)Highlight in 3D

    "),"graph"==e||"linegraph"==e||"scatterplot"==e){return s.getGraphCls.getGraphLinks(s.resid2ResidhashHbond,s.resid2ResidhashHbond,i.htmlCls.hbondColor,t,i.htmlCls.hbondValue)}return a}exportSaltbridgePairs(e,t){var s=this.icn3d,i=s.icn3dui;let n="",l=0,r='    ';for(let t in s.resid2ResidhashSaltbridge){let i=s.getGraphCls.convertLabel2Resid(t),a=s.firstAtomObjCls.getFirstAtomObj(s.residues[i]),d=a.color?a.color.getHexString():"";for(let i in s.resid2ResidhashSaltbridge[t]){let a=s.getGraphCls.convertLabel2Resid(i),c=s.firstAtomObjCls.getFirstAtomObj(s.residues[a]),h=c.color?c.color.getHexString():"",p=Math.sqrt(s.resid2ResidhashSaltbridge[t][i]).toFixed(1);n+=' '+t+r+d+o+' '+i+r+h+o+''+p+"","view"==e&&(n+=''),n+="",++l}}let a='

    '+l+" salt bridge/ionic interaction pairs:

    ";if(l>0&&(a+="
    ","view"==e&&(a+=''),a+="",a+=n,a+="
    Atom 1Atom 2Distance(Å)Highlight in 3D

    "),"graph"==e||"linegraph"==e||"scatterplot"==e){return s.getGraphCls.getGraphLinks(s.resid2ResidhashSaltbridge,s.resid2ResidhashSaltbridge,i.htmlCls.ionicColor,t,i.htmlCls.ionicValue)}return a}exportHalogenPiPairs(e,t,s){var i=this.icn3d,n=i.icn3dui;let l,r,o,a="",d=0,c='    ';"halogen"==s?(l=i.resid2ResidhashHalogen,r=n.htmlCls.halogenColor,o=n.htmlCls.halogenValue):"pi-cation"==s?(l=i.resid2ResidhashPication,r=n.htmlCls.picationColor,o=n.htmlCls.picationValue):"pi-stacking"==s&&(l=i.resid2ResidhashPistacking,r=n.htmlCls.pistackingColor,o=n.htmlCls.pistackingValue);for(let t in l){let n=i.getGraphCls.convertLabel2Resid(t),r=i.firstAtomObjCls.getFirstAtomObj(i.residues[n]),o=r.color?r.color.getHexString():"";for(let n in l[t]){let r=i.getGraphCls.convertLabel2Resid(n),p=i.firstAtomObjCls.getFirstAtomObj(i.residues[r]),m=p.color?p.color.getHexString():"",u=Math.sqrt(l[t][n]).toFixed(1);a+=' '+t+c+o+h+' '+n+c+m+h+''+u+"","view"==e&&(a+=''),a+="",++d}}let p='

    '+d+" "+s+" pairs:

    ";if(d>0&&(p+="
    ","view"==e&&(p+=''),p+="",p+=a,p+="
    Atom 1Atom 2Distance(Å)Highlight in 3D

    "),"graph"==e||"linegraph"==e||"scatterplot"==e){return i.getGraphCls.getGraphLinks(l,l,r,t,o)}return p}exportSpherePairs(e,t,s){var i=this.icn3d,n=i.icn3dui;let l="",r=0,o=e?i.resid2ResidhashInteractions:i.resid2ResidhashSphere,a='    ';for(let s in o){let n=i.getGraphCls.convertLabel2Resid(s),c=i.firstAtomObjCls.getFirstAtomObj(i.residues[n]),h=c.color?c.color.getHexString():"";for(let n in o[s]){let p=i.getGraphCls.convertLabel2Resid(n),m=i.firstAtomObjCls.getFirstAtomObj(i.residues[p]),u=m.color?m.color.getHexString():"",g=o[s][n].split("_"),f=g[0],b=g[1];c=g[2],m=g[3];let C=g[4];e?(l+=' '+s+"@"+c+a+h+d+' '+n+"@"+m+a+u+d+''+C+''+f+''+b+"","view"==t&&(l+=''),l+=""):l+=""+s+""+n+''+C+''+f+''+b+"",++r}}let c='

    '+r+" residue pairs in "+(e?"the contacts":"sphere")+":

    ";if(r>0&&(e?(c+='
    ',"view"==t&&(c+=''),c+=""):c+='
    Residue 1Residue 2Num ContactsMin Distance(Å)C-alpha Distance(Å)Highlight in 3D
    ',c+=l,c+="
    Residue 1Residue 2Num ContactsMin Distance(Å)C-alpha Distance(Å)

    "),"graph"==t||"linegraph"==t||"scatterplot"==t||"calpha"==t||"cbeta"==t||"heavyatoms"==t){return i.getGraphCls.getGraphLinks(o,o,n.htmlCls.contactColor,s,n.htmlCls.contactValue)}return c}}class Ut{constructor(e){this.icn3d=e}drawGraph(e,t){var s=this.icn3d,i=s.icn3dui;if(void 0===n)var n=d3;var l=JSON.parse(e),r=$("#"+t).width(),o=$("#"+t).height(),a=isNaN(r)?300:1*r,d=isNaN(o)?300:1*o,c=r,h=o,p=d3.select("#"+i.svgid).attr("width",r).attr("height",o).attr("viewBox","0,0,"+a+","+d);p.selectAll(".g-main").remove();var m=p.append("g").classed("g-main",!0),u=m.append("rect").attr("width",c).attr("height",h).style("fill","#FFF"),g=m.append("g"),f=n.zoom().on("zoom",(function(){g.attr("transform",n.event.transform)}));if(m.call(f),l.links){for(var b=[],C={},y=0,v=l.nodes.length;y0?n.structures[0]:n.defaultPdbId;p=10*(a.length+2)+20+30,h=10*(d.length+2)+20+30,t?(n.alignerrormapWidth=2*h,u=n.alignerrormapWidth,m=l.alignerrormapid):(n.contactmapWidth=2*h,u=n.contactmapWidth,m=l.contactmapid),i=o.length>0?"":"No interactions found for these two sets

    ",i+="";if(t){n.hex2id={};let e=29/s;n.hex2skip={};let t=1e3;for(let s=0;se&&(n.hex2skip[d]=c)}}if(i+=n.lineGraphCls.drawScatterplot_base(a,d,o,c,0,!0,void 0,void 0,t),g+=n.getGraphCls.updateGraphJson(f,1,a,d,o),i+="",g+="}\n",t){n.alignerrormapStr=g,$("#"+n.pre+"alignerrormapDiv").html(i);let e=$("#"+l.alignerrormapid+"_scale").val();$("#"+l.alignerrormapid).attr("width",(n.alignerrormapWidth*parseFloat(e)).toString()+"px")}else n.contactmapStr=g,$("#"+n.pre+"contactmapDiv").html(i);return i}}class $t{constructor(e){this.icn3d=e}async downloadAlignment(e,t){let s=this.icn3d,i=s.icn3dui,n=this;s.opts.proteins="c alpha trace";let l=e.split(","),r="ids="+e,o=i.htmlCls.baseUrl+"vastplus/vastplus.cgi?v=3&cmd=c&b=1&s=1&w3d&"+r;void 0!==i.cfg.inpara&&(o+=i.cfg.inpara),s.pdbid_chain2title={},void 0===s.chainids2resids&&(s.chainids2resids={});let a={},d="These two MMDB IDs "+l+' do not have 3D alignment data in the VAST+ database. You can try the VAST alignment by visiting the VAST+ page https://www.ncbi.nlm.nih.gov/Structure/vastplus/vastplus.cgi?uid=[PDB ID] (e.g., uid=1KQ2), and clicking "Original VAST"',c=await i.getAjaxPromise(o,"jsonp",!0,d);if(a=c.seqalign,void 0===a)return alert(d),!1;s.pdbid_molid2chain={},s.chainsColor={};for(let e=0,t=2;e5){let t=!1,s=!0;d=await r.pdbParserCls.loadPdbData(e,n,!1,t,"target",h,s)}else{let t=!0;d=await r.mmdbParserCls.parseMmdbData(e,"target",i[0],0,h,t)}for(let e=0,s=t.length;e5){let s=!0,i=!0;c=await r.pdbParserCls.loadPdbData(t[e],l,!1,s,"query",h,i)}else{let s=!0;c=await r.mmdbParserCls.parseMmdbData(t[e],"query",i[e+1],e,h,s)}d=o.hashUtilsCls.unionHash(d,c)}if(o.cfg.resnum)await r.realignParserCls.realignChainOnSeqAlign(s,i);else if(o.cfg.resdef)await r.realignParserCls.realignChainOnSeqAlign(s,i,void 0,!0);else{await r.pdbParserCls.applyCommandDssp(!0);for(let e in r.pdbChainIndexHash){let t=r.pdbChainIndexHash[e].split("_");l=t[0],t[1],n=t[2],t[3],a.transformStructure(l,e-1,"query")}let e=[],t=[],c=[],h=o.htmlCls.baseUrl+"vastdyn/vastdyn.cgi",p=o.htmlCls.baseUrl+"tmalign/tmalign.cgi";for(let s in r.afChainIndexHash){let i=r.afChainIndexHash[s].split("_");l=i[0];let a=i[1];n=i[2];let d,m=i[3];if("tmalign"!=o.cfg.aligntool){let e={domains1:r.domain3dCls.getDomainJsonForAlign(r.chains[l+"_"+a]),domains2:r.domain3dCls.getDomainJsonForAlign(r.chains[n+"_"+m])};d=o.getAjaxPostPromise(h,e)}else{let e={pdb_query:r.saveFileCls.getAtomPDB(r.chains[l+"_"+a]),pdb_target:r.saveFileCls.getAtomPDB(r.chains[n+"_"+m])};d=o.getAjaxPostPromise(p,e)}e.push(d),t.push(s-1),c.push(l)}let m=Promise.allSettled(e);try{let e=await m;await a.downloadChainalignmentPart2b(s,i,d,e,t,n,c)}catch(e){r.bRender&&alert("These structures can NOT be aligned to each other...")}}}async downloadChainalignmentPart2b(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui;for(let e=0,t=i.length;ed&&(d=n[t[0]],o=t[0]),n[t[1]]>d&&(d=n[t[1]],o=t[1])}let c={},h={},p={},m={};for(let e in l){let t,s,i=e.split("_"),n=l[e].split(","),r=n[2];o==i[0]?(t=i[0],s=i[1]):o==i[1]?(t=i[1],s=i[0]):(t=i[0],s=i[1]),p[t]=1,p.hasOwnProperty(s)||(p[s]=1,m[e]=l[e],a="target",this.transformStructure(t,r,a),a="query",this.transformStructure(s,r,a),c[n[0]]=1,c[n[1]]=1)}for(let e in m)if(void 0!==s.q_rotation){let t=m[e].split(","),n=[t[1],t[0],t[2]],l=s.setSeqAlignCls.setSeqAlignChain(void 0,void 0,n);h=i.hashUtilsCls.unionHash(h,l);let r=!1,o=i.htmlCls.alignSeqCls.getAlignSequencesAnnotations(Object.keys(s.alnChains),void 0,void 0,!1,void 0,r),a=$("#"+s.pre+"dl_sequence2").html();$("#"+s.pre+"dl_sequence2").html(a+o.sequencesHtml),$("#"+s.pre+"dl_sequence2").width(i.htmlCls.RESIDUE_WIDTH*o.maxSeqCnt+200)}s.dAtoms=i.hashUtilsCls.cloneHash(h),s.hAtoms=i.hashUtilsCls.cloneHash(h);let u="protein_aligned";s.selectionCls.saveSelection(u,u),s.opts.color="identity",s.setColorCls.setColorByOptions(s.opts,s.hAtoms),i.htmlCls.dialogCls.openDlg("dl_alignment","Select residues in aligned sequences"),s.drawCls.draw(),s.transformCls.zoominSelection(),s.hlUpdateCls.updateHlAll()}transformStructure(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=n.structures[e];for(let e=0,o=r.length;e2){let e=i.firstAtomObjCls.getResiduesFromAtoms(s),t="protein_aligned",n="protein aligned",l="select "+i.resid2specCls.residueids2spec(Object.keys(e));i.selectionCls.addCustomSelection(Object.keys(e),t,n,l,!0)}i.hlUpdateCls.updateHlAll(),void 0!==n.cfg.rotate&&i.resizeCanvasCls.rotStruc(n.cfg.rotate,!0),i.html2ddgm="",n.cfg.show2d&&i.bFullUi&&(n.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions"),i.bFullUi&&(i.bChainAlign?await i.ParserUtilsCls.set2DDiagramsForChainalign(t):i.ParserUtilsCls.download2Ddgm(i.inputid.toUpperCase())))}addPostfixForChainids(e){let t=this.icn3d;t.icn3dui;let s={};for(let i=0,n=e.length;i5?(c="https://alphafold.ebi.ac.uk/files/AF-"+i.mmdbid_t+"-F1-model_"+i.AFUniprotVersion+".pdb",d=n.getAjaxPromise(c,"text")):(c=n.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+n.cfg.bu+"&uid="+i.mmdbid_t,void 0!==n.cfg.inpara&&(c+=n.cfg.inpara),d=n.getAjaxPromise(c,"jsonp")),h.push(d),i.ParserUtilsCls.setYourNote(e.toUpperCase()+" in iCn3D"),i.pdbid_chain2title={},void 0===i.chainids2resids&&(i.chainids2resids={}),i.afChainIndexHash={},i.pdbChainIndexHash={};for(let e=1,t=r.length;e5?(t="https://alphafold.ebi.ac.uk/files/AF-"+i.mmdbid_q+"-F1-model_"+i.AFUniprotVersion+".pdb",s=n.getAjaxPromise(t,"text")):(t=n.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+n.cfg.bu+"&uid="+i.mmdbid_q,void 0!==n.cfg.inpara&&(t+=n.cfg.inpara),s=n.getAjaxPromise(t,"jsonp")),h.push(s)}for(let e=1,t=r.length;e0?o[e]+","+o[0]:void 0;if("tmalign"!=n.cfg.aligntool&&4==i.mmdbid_t.length&&4==i.mmdbid_q.length){let r;r=o.length>0?n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?domainpairs="+l:n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainpairs="+t;let a=n.getAjaxPromise(r,"jsonp");h.push(a),i.pdbChainIndexHash[e]=s+"_"+i.chain_q+"_"+i.mmdbid_t+"_"+i.chain_t}else i.afChainIndexHash[e]=i.mmdbid_q+"_"+i.chain_q+"_"+i.mmdbid_t+"_"+i.chain_t}}let p=Promise.allSettled(h);try{let e=await p;await l.parseChainAlignData(e,r,i.mmdbid_t,i.chain_t)}catch(e){let t="tmalign"==n.cfg.aligntool?"TM-align":"VAST";i.bRender&&alert("These chains can not be aligned by "+t+". You can specify the residue range and try it again...")}}async parseChainAlignData(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=e[0].value,o="HEADER "+s+"\n";isNaN(s)&&s.length>5&&(r=o+r),n.t_trans_add=[],n.q_trans_sub=[],"tmalign"==l.cfg.aligntool&&(n.q_trans_add=[]),n.q_rotation=[],n.qt_start_end=[],n.mmdbidArray=[],n.mmdbidArray.push(s);let a=[];for(let s=1,i=t.length;s5&&(i=o+i),void 0===i||-1!==JSON.stringify(i).indexOf("Oops there was a problem"))return void alert("The coordinate data can NOT be retrieved for the structure "+r+"...");n.mmdbidArray.push(r),a.push(i)}let d=0;for(let r=1,o=t.length;r";"tmalign"==o.cfg.aligntool&&(n+="TM-score: "+e[0].score.toPrecision(4)+"

    "),$("#"+r.pre+"dl_rmsd").html(n),o.cfg.bSidebyside||o.htmlCls.dialogCls.openDlg("dl_rmsd","RMSD of alignment"),a=!0}return a}async loadOpmDataForChainalign(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=this;if(l.cfg.resnum||l.cfg.resdef)n.bCommandLoad||n.init(),await this.downloadChainalignmentPart2(e,t,void 0,s);else{let o=l.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?mmdbids2opm="+i.join("','");try{let i=(await l.getAjaxPromise(o,"jsonp")).mmdbid;if(n.selectedPdbid=i,i){let o="https://opm-assets.storage.googleapis.com/pdb/"+i.toLowerCase()+".pdb";try{let a=await l.getAjaxPromise(o,"text");n.bOpm=!0;let d=!0,c=n.loadPDBCls.loadPDB(a,i,n.bOpm,d);$("#"+n.pre+"selectplane_z1").val(n.halfBilayerSize),$("#"+n.pre+"selectplane_z2").val(-n.halfBilayerSize),$("#"+n.pre+"extra_mem_z").val(n.halfBilayerSize),$("#"+n.pre+"intra_mem_z").val(-n.halfBilayerSize),n.bCommandLoad||n.init(),await r.downloadChainalignmentPart2(e,t,c,s)}catch(i){return n.bCommandLoad||n.init(),void await r.downloadChainalignmentPart2(e,t,void 0,s)}}else n.bCommandLoad||n.init(),await r.downloadChainalignmentPart2(e,t,void 0,s)}catch(i){return n.bCommandLoad||n.init(),void await r.downloadChainalignmentPart2(e,t,void 0,s)}}}async downloadMmdbAf(e,t,s){let i=this.icn3d,n=i.icn3dui,l=this;i.structArray=i.structures?Object.keys(i.structures):[],0==i.structArray.length?i.init():(i.resetConfig(),i.bResetAnno=!0,i.bResetSets=!0);let r=e.split(","),o=[];for(let e=0,t=r.length;e5?(t="https://alphafold.ebi.ac.uk/files/AF-"+l+"-F1-model_"+i.AFUniprotVersion+".pdb",s=n.getAjaxPromise(t,"text")):(t=n.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+n.cfg.bu+"&uid="+l,void 0!==n.cfg.inpara&&(t+=n.cfg.inpara),s=n.getAjaxPromise(t,"jsonp")),a.push(s)}i.ParserUtilsCls.setYourNote(i.structArray+" in iCn3D"),i.ParserUtilsCls.showLoading();let d=Promise.allSettled(a);try{let e=await d;await l.parseMMdbAfData(e,o,t,s),void 0===s&&i.ParserUtilsCls.hideLoading()}catch(e){alert("There are some problems in retrieving the coordinates...")}}async parseMMdbAfData(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=[];for(let s=0,i=t.length;s5&&(i=n+i),void 0===i||-1!==JSON.stringify(i).indexOf("Oops there was a problem"))return void alert("The coordinate data can NOT be retrieved for the structure "+t[s]+"...");r.push(i)}let o={},a={},d=!1;n.opts.color=n.structArray.length>1?"structure":t[0].length>5?"confidence":"chain";for(let e=0,i=t.length;e5){let s=!1;a=await n.pdbParserCls.loadPdbData(r[e],t[e],!1,c,i,d,s)}else{let t=!0;a=await n.mmdbParserCls.parseMmdbData(r[e],i,void 0,void 0,d,t)}o=l.hashUtilsCls.unionHash(o,a)}if(n.structArray.length>1&&(n.opts.color="structure"),n.setColorCls.setColorByOptions(n.opts,n.atoms),await n.ParserUtilsCls.renderStructure(),void 0!==l.cfg.rotate&&n.resizeCanvasCls.rotStruc(l.cfg.rotate,!0),s&&l.cfg.matchedchains){let e=!0,t=!0;await n.realignParserCls.realignChainOnSeqAlign(void 0,n.chainidArray,e,t),$("#"+n.pre+"dl_annotations").html(""),n.bAnnoShown=!1,$("#"+n.pre+"dl_selectannotations").dialog("isOpen")&&$("#"+n.pre+"dl_selectannotations").dialog("close")}else if(void 0!==i){let e=Object.keys(n.structures);await n.vastplusCls.vastplusAlign(e,i)}}}class Bt{constructor(e){this.icn3d=e}dsn6Parser(e,t,s){this.icn3d.icn3dui;let i="https://edmaps.rcsb.org/maps/"+e.toLowerCase()+"_"+t+".dsn6";this.dsn6ParserBase(i,t,s)}dsn6ParserBase(e,t,s){let i=this.icn3d;i.icn3dui;let n=this;if("2fofc"==t&&i.bAjax2fofc)i.mapData.sigma2=s,i.setOptionCls.setOption("map",t);else if("fofc"==t&&i.bAjaxfofc)i.mapData.sigma=s,i.setOptionCls.setOption("map",t);else{let l=new XMLHttpRequest;l.open("GET",e,!0),l.responseType="arraybuffer",l.onreadystatechange=function(){if(4==this.readyState)if(200==this.status){let e=l.response;n.loadDsn6Data(e,t,s),"2fofc"==t?i.bAjax2fofc=!0:"fofc"==t&&(i.bAjaxfofc=!0),i.setOptionCls.setOption("map",t)}else alert("RCSB server has no corresponding eletron density map for this structure.");else i.ParserUtilsCls.showLoading()},l.send()}}loadDsn6Data(e,t,s){let i=this.icn3d;i.icn3dui;let n,l,r={},o=e.buffer&&e.buffer instanceof ArrayBuffer?e.buffer:e,a=new Int16Array(o),d=new Uint8Array(o),c=String.fromCharCode.apply(null,d.subarray(0,512));if(0==c.indexOf(":-)"))r.xStart=parseInt(c.substr(10,5)),r.yStart=parseInt(c.substr(15,5)),r.zStart=parseInt(c.substr(20,5)),r.xExtent=parseInt(c.substr(32,5)),r.yExtent=parseInt(c.substr(38,5)),r.zExtent=parseInt(c.substr(42,5)),r.xRate=parseInt(c.substr(52,5)),r.yRate=parseInt(c.substr(58,5)),r.zRate=parseInt(c.substr(62,5)),r.xlen=1*parseFloat(c.substr(73,10)),r.ylen=1*parseFloat(c.substr(83,10)),r.zlen=1*parseFloat(c.substr(93,10)),r.alpha=parseFloat(c.substr(103,10)),r.beta=parseFloat(c.substr(113,10)),r.gamma=parseFloat(c.substr(123,10)),n=parseFloat(c.substr(138,12))/100,l=parseInt(c.substr(155,8)),r.sigma=100*parseFloat(c.substr(170,12));else{if(100!==a[18])for(let e=0,t=a.length;e>8&255}r.zStart=a[2],r.xStart=a[0],r.yStart=a[1],r.xExtent=a[3],r.yExtent=a[4],r.zExtent=a[5],r.xRate=a[6],r.yRate=a[7],r.zRate=a[8];let e=1/a[17],t=1*e;r.xlen=a[9]*t,r.ylen=a[10]*t,r.zlen=a[11]*t,r.alpha=a[12]*e,r.beta=a[13]*e,r.gamma=a[14]*e,n=a[15]/a[18],l=a[16]}let h=new Float32Array(r.xExtent*r.yExtent*r.zExtent),p=512,m=Math.ceil(r.xExtent/8),u=Math.ceil(r.yExtent/8),g=Math.ceil(r.zExtent/8);for(let e=0;es.maxatomcnt&&(s.bAssembly=!0)}if("mmtfid"===t&&void 0!==o.missingseq){let t=0,n="";for(let l=0,r=o.missingseq.length;lt)&&(s.chainMissingResidueArray[c].push(h),t=d,n=a)}s.loadPDBCls.adjustSeq(s.chainMissingResidueArray)}}async loadMmcifData(e,t){let s=this.icn3d;if(s.icn3dui,t||(t=e.mmcif),t||(t=s.defaultPdbId),void 0===e.atoms)return!1;s.init(),void 0!==e.emd&&(s.emd=e.emd),void 0!==e.organism&&(s.organism=e.organism),void 0!==s.emd?($("#"+s.pre+"mapWrapper1").hide(),$("#"+s.pre+"mapWrapper2").hide(),$("#"+s.pre+"mapWrapper3").hide()):($("#"+s.pre+"emmapWrapper1").hide(),$("#"+s.pre+"emmapWrapper2").hide(),$("#"+s.pre+"emmapWrapper3").hide()),await s.opmParserCls.loadOpmData(e,t,void 0,"mmcif")}}class Gt{constructor(e){this.icn3d=e}async downloadMmdb(e,t){let s,i=this.icn3d,n=i.icn3dui;try{if(s=await this.loadMmdbPrms(e,t),!s||s.error)return void this.getNoData(e,t)}catch(s){return void this.getNoData(e,t)}if(0!=Object.keys(s.atoms).length)if(n.utilsCls.isCalphaPhosOnly(s.atoms)||s.atomCount<=i.maxatomcnt)await this.parseMmdbData(s);else{let s;try{s=await this.loadMmdbPrms(e,t,!0)}catch(s){return void this.getNoData(e,t)}await this.parseMmdbData(s)}else{let e=s.pdbId;i.mmtfParserCls.downloadMmtf(e)}}async downloadGi(e){let t=this.icn3d;t.icn3dui,t.bCid=void 0;await this.downloadMmdb(e,!0)}async downloadBlast_rep_id(e){let t=this.icn3d,s=t.icn3dui,i=e.split(",");s.cfg.query_id=i[0],s.cfg.blast_rep_id=i[1];let n=s.cfg.blast_rep_id.split("_")[0];4==n.length?await this.downloadMmdb(n):(t.blastAcxn=s.cfg.blast_rep_id.split(".")[0],await this.downloadRefseq(t.blastAcxn,!0))}async downloadRefseq(e,t){let s=this.icn3d,i=s.icn3dui,n=i.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?refseq2uniprot="+e;i.cfg.refseqid=e;let l=await i.getAjaxPromise(n,"jsonp",!1,"The protein accession "+e+" can not be mapped to AlphaFold UniProt ID...");if(!l||!l.uniprot)return void alert("The accession "+e+" can not be mapped to AlphaFold UniProt ID. It will be treated as a UniProt ID instead.");i.cfg.afid=l.uniprot,t&&(i.cfg.blast_rep_id=i.cfg.afid+"_A");await s.pdbParserCls.downloadPdb(i.cfg.afid,!0)}getNoData(e,t){let s=this.icn3d.icn3dui;t?alert("This gi "+e+" has no corresponding 3D structure..."):alert("This mmdbid "+e+" with the parameters "+s.cfg.inpara+" may not have 3D structure data. Please visit the summary page for details: "+s.htmlCls.baseUrl+"pdb/"+e)}async parseMmdbData(e,t,s,i,n,l){let r,o=this.icn3d,a=o.icn3dui,d=void 0!==e.pdbId?e.pdbId:e.mmdbId;this.parseMmdbDataPart1(e,t),void 0===t?(void 0!==e.opm&&void 0!==e.opm.rot&&(o.bOpm=!0,o.opmParserCls.setOpmData(e)),r=o.loadAtomDataCls.loadAtomDataIn(e,d,"mmdbid",void 0,t)):(s&&(d=s.substr(0,s.indexOf("_"))),r=o.loadAtomDataCls.loadAtomDataIn(e,d,"mmdbid",void 0,t,s,i,n,l));let c=e.pdbId;void 0===t&&o.ParserUtilsCls.setYourNote(c.toUpperCase()+"(MMDB) in iCn3D");for(let t in e.domains){let s=e.domains[t].chain,i=c+"_"+s,n=e.domains[t].domains;for(let e=0,t=n.length;et.maxatomcnt){let i=!1;if(0==Object.keys(s).length)return void alert("This PDB structure is not found at RCSB...");await t.opmParserCls.loadOpmData(s,e,i,"mmtf")}else s=null,MMTF.fetch(e,(async function(s){0!=Object.keys(s).length?await t.opmParserCls.loadOpmData(s,e,!0,"mmtf"):alert("This PDB structure is not found at RCSB...")}),(function(e){}))}),(function(e){}))}async parseMmtfData(e,t,s){let i=this.icn3d,n=i.icn3dui;e.numAtoms,i.init();let l=new THREE.Vector3(9999,9999,9999),r=new THREE.Vector3(-9999,-9999,-9999),o=new THREE.Vector3,a=e.structureId;if(i.molTitle=e.title,void 0!==e.bioAssemblyList&&void 0!==e.bioAssemblyList[0]&&e.bioAssemblyList[0].transformList.length>1){i.biomtMatrices=[];for(let t=0,s=e.bioAssemblyList[0].transformList.length;t1&&($("#"+i.pre+"assemblyWrapper").show(),i.asuCnt=i.biomtMatrices.length);let d,c,h,p,m,u,g,f,b,C,y,v,w,_,S,A,x,k,O,R={},E=[],I="coil",T="",M=0,P=0,D={onModel:function(e){d=0===e.modelIndex?a:a+(e.modelIndex+1).toString()},onChain:function(e){c=e.chainName;let t=d+"_"+c;void 0===i.structures[d]&&(i.structures[d]=[]),i.structures[d].push(t)},onGroup:function(e){h=e.groupName,p=e.groupId;let t=d+"_"+c+"_"+p;m=0===e.secStruct||2===e.secStruct||4===e.secStruct?"helix":3===e.secStruct?"sheet":-1===e.secStruct?"other":"coil";let s=!1;if(c!==T){if(x=void 0,O=void 0,"coil"!==m&&"other"!==m?(u=!0,g=!1):(u=!1,g=!1),"coil"!==I&&"other"!==I){let e=d+"_"+T+"_"+M.toString();for(let t in i.residues[e])i.atoms[t].ssbegin=!1,i.atoms[t].ssend=!0}}else x=A,O=k,m!==I?"coil"===I||"other"===I?(u=!0,g=!1):"coil"===m||"other"===m?(s=!0,u=!1,g=!1):("sheet"===I&&"helix"===m||"helix"===I&&"sheet"===m)&&(s=!0,u=!0,g=!1):(u=!1,g=!1);if(s&&!isNaN(p)){let e=d+"_"+c+"_"+(p-1).toString();for(let t in i.residues[e])i.atoms[t].ssbegin=!1,i.atoms[t].ssend=!0}I=m,T=c,M=p,f=!1,b=!1,C=!1,"non-polymer"===e.chemCompType.toLowerCase()||"other"===e.chemCompType.toLowerCase()||-1!==e.chemCompType.toLowerCase().indexOf("saccharide")?f=!0:-1!==e.chemCompType.toLowerCase().indexOf("peptide")?b=!0:-1!==e.chemCompType.toLowerCase().indexOf("dna")||-1!==e.chemCompType.toLowerCase().indexOf("rna")?C=!0:b=!0;let l=d+"_"+c,r={};r.resi=p,r.name=n.utilsCls.residueName2Abbr(h),i.residueId2Name[t]=r.name,r.resi%10==0&&r.resi.toString();let o="-";"helix"===m?o="H":"sheet"===m?o="E":"coil"===m?o="c":"other"===m&&(o="o"),void 0===i.chainsSeq[l]&&(i.chainsSeq[l]=[]),i.bFullUi&&i.chainsSeq[l].push(r),i.secondaries[t]=o},onAtom:function(e){if(y=e.element,v=e.atomName,w=new THREE.Vector3(e.xCoord,e.yCoord,e.zCoord),_=e.bFactor,S=e.altLoc,"\0"===e.altLoc&&(S=""),""===S||"A"===S){++P,"SG"===v&&E.push(P),R[e.atomIndex]=P;let t={het:f,serial:P,name:v,alt:S,resn:h,structure:d,chain:c,resi:p,coord:w,b:_,elem:y,bonds:[],bondOrder:[],ss:m,ssbegin:u,ssend:g};if(t.het||"C"!==t.name||(A=P),t.het||"O"!==t.name||(k=P),!t.het&&"N"===t.name&&void 0!==x&&void 0!==O){let e=i.atoms[x].coord.distanceTo(i.atoms[O].coord),s=t.coord.x+(i.atoms[x].coord.x-i.atoms[O].coord.x)/e,n=t.coord.y+(i.atoms[x].coord.y-i.atoms[O].coord.y)/e,l=t.coord.z+(i.atoms[x].coord.z-i.atoms[O].coord.z)/e;t.hcoord=new THREE.Vector3(s,n,l)}i.atoms[P]=t,l.min(w),r.max(w),o.add(w);let a=d+"_"+c,I=a+"_"+p;void 0===i.chains[a]&&(i.chains[a]={}),i.chains[a][P]=1,void 0===i.residues[I]&&(i.residues[I]={}),i.residues[I][P]=1,b?(i.proteins[P]=1,"CA"===v&&(i.calphas[P]=1),"N"!==v&&"H"!==v&&"CA"!==v&&"HA"!==v&&"C"!==v&&"O"!==v&&(i.sidec[P]=1)):C?(i.nucleotides[P]=1,(!s||"O3'"!=v&&"O3*"!=v)&&(s||"P"!=v)||(i.nucleotidesO3[P]=1),-1===n.parasCls.nuclMainArray.indexOf(v)&&(i.ntbase[P]=1)):y.toLowerCase()===h.toLowerCase()?i.ions[P]=1:"HOH"===h||"WAT"===h||"SQL"===h||"H2O"===h||"W"===h||"DOD"===h||"D3O"===h?i.water[P]=1:i.chemicals[P]=1,i.dAtoms[P]=1,i.hAtoms[P]=1}},onBond:function(e){let t=R[e.atomIndex1],s=R[e.atomIndex2];if(R.hasOwnProperty(e.atomIndex1)&&R.hasOwnProperty(e.atomIndex2)&&(i.atoms[t].bonds.push(s),i.atoms[s].bonds.push(t),f)){let n=e.bondOrder;i.atoms[t].bondOrder.push(n),i.atoms[s].bondOrder.push(n),2===n?(i.doublebonds[t+"_"+s]=1,i.doublebonds[s+"_"+t]=1):3===n&&(i.triplebonds[t+"_"+s]=1,i.triplebonds[s+"_"+t]=1)}}};MMTF.traverse(e,D),i.loadPDBCls.setResidMapping();for(let e=0,t=E.length;ei.maxatomcnt||void 0!==i.biomtMatrices&&i.biomtMatrices.length*i.cnt>10*i.maxatomcnt)&&(i.opts.proteins="c alpha trace",i.opts.nucleotides="o3 trace"),i.pmin=l,i.pmax=r,i.center=i.ParserUtilsCls.getGeoCenter(i.pmin,i.pmax),i.maxD=i.ParserUtilsCls.getStructureSize(i.atoms,i.pmin,i.pmax,i.center),i.maxD<5&&(i.maxD=5),i.oriMaxD=i.maxD,i.oriCenter=i.center.clone(),i.ParserUtilsCls.transformToOpmOri(t),void 0===n.cfg.align&&1==Object.keys(i.structures).length&&$("#"+i.pre+"alternateWrapper").hide(),i.setStyleCls.setAtomStyleByOptions(i.opts),i.setColorCls.setColorByOptions(i.opts,i.atoms),await i.ParserUtilsCls.renderStructure(),i.saveFileCls.showTitle(),void 0!==n.cfg.rotate&&i.resizeCanvasCls.rotStruc(n.cfg.rotate,!0)}}class Wt{constructor(e){this.icn3d=e}async loadMol2Data(e){let t=this.icn3d,s=t.icn3dui,i=this.loadMol2AtomData(e);void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),i?(t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.atoms),await t.ParserUtilsCls.renderStructure(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0)):alert("The Mol2 file has the wrong format...")}loadMol2AtomData(e){let t=this.icn3d;t.icn3dui;let s=e.split(/\r?\n|\r/);if(s.length<4)return!1;t.init();let i,n,l="LIG",r={},o="1_A",a=0,d=0,c=1,h=!1,p=!1,m={},u={};for(let e=0,o=s.length;eMOLECULE"==o){t.molTitle=s[e+1].trim();let l=s[e+2].trim().replace(/\s+/g," ").split(" ");i=l[0],n=l[1],e+=4}else"@ATOM"==o?(c=1,h=!0,++e):"@BOND"==o?(p=!0,h=!1,++e):"@SUBSTRUCTURE"==o&&(p=!1,++e);if(o=s[e].trim(),""!==o&&"#"!==o.substr(0,1)){if(h&&a1&&($("#"+l.pre+"assemblyWrapper").show(),l.asuCnt=l.biomtMatrices.length),l.setStyleCls.setAtomStyleByOptions(l.opts),l.setColorCls.setColorByOptions(l.opts,l.atoms),await l.ParserUtilsCls.renderStructure(),void 0!==r.cfg.rotate&&l.resizeCanvasCls.rotStruc(r.cfg.rotate,!0)}else"pdb"===i?await l.pdbParserCls.loadPdbData(e,t):"align"===i&&(l.bOpm?await l.alignParserCls.downloadAlignmentPart2(t):void 0!==n?await this.loadOpmData(e,n,s,i):await l.alignParserCls.downloadAlignmentPart2(t))}}class Xt{constructor(e){this.icn3d=e}async downloadPdb(e,t){let s,i=this.icn3d,n=i.icn3dui;t?(s="https://alphafold.ebi.ac.uk/files/AF-"+e+"-F1-model_"+i.AFUniprotVersion+".pdb",n.cfg.refseqid?i.ParserUtilsCls.setYourNote(n.cfg.refseqid.toUpperCase()+"(NCBI Protein Acc.) in iCn3D"):i.ParserUtilsCls.setYourNote(e.toUpperCase()+"(AlphaFold) in iCn3D")):(s="https://files.rcsb.org/view/"+e+".pdb",i.ParserUtilsCls.setYourNote(e.toUpperCase()+"(PDB) in iCn3D"));let l=await n.getAjaxPromise(s,"text",!0,"The ID "+e+" can not be found in the server "+s+"...");if(t){l="HEADER "+e+"\n"+l,await i.opmParserCls.parseAtomData(l,e,void 0,"pdb",void 0)}else await i.opmParserCls.loadOpmData(l,e,void 0,"pdb")}async downloadUrl(e,t,s){let i=this.icn3d,n=i.icn3dui,l=e.lastIndexOf("/");if(-1!=l){let t=e.lastIndexOf(".");i.filename=e.substr(l+1,t-l-1)}else{let t=e.lastIndexOf(".");i.filename=e.substr(0,t)}let r=await n.getAjaxPromise(e,"text",!0);if(i.InputfileData=i.InputfileData?i.InputfileData+"\nENDMDL\n"+r:r,i.InputfileType=t,"pdb"===t)await this.loadPdbData(r);else if("mmcif"===t){let e=n.htmlCls.baseUrl+"mmcifparser/mmcifparser.cgi",t={mmciffile:r},s=await n.getAjaxPostPromise(e,t,!0);await i.mmcifParserCls.loadMmcifData(s,void 0)}else if("mol2"===t)await i.mol2ParserCls.loadMol2Data(r);else if("sdf"===t)await i.sdfParserCls.loadSdfData(r);else if("xyz"===t)await i.xyzParserCls.loadXyzData(r);else if("mmcif"===t)await i.mmcifParserCls.loadMmcifData(r);else if("icn3dpng"===t)await n.htmlCls.setHtmlCls.loadPng(r,s);else if("pae"===t){n.htmlCls.dialogCls.openDlg("dl_alignerrormap","Show Predicted Aligned Error (PAE) map");let e=!0;i.contactMapCls.processAfErrorMap(JSON.parse(r),e)}}async loadPdbData(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui;if(!i&&(void 0===n||"target"===n)){let e=!!o.bCommandLoad;o.bStatefile||o.init(e)}let d=o.loadPDBCls.loadPDB(e,t,s,void 0,void 0,i,n,l);void 0===a.cfg.opmid&&o.ParserUtilsCls.transformToOpmOri(t),void 0!==o.biomtMatrices&&o.biomtMatrices.length>1&&(a.bNode||$("#"+o.pre+"assemblyWrapper").show(),o.asuCnt=o.biomtMatrices.length),a.bNode||(void 0!==o.emd?($("#"+o.pre+"mapWrapper1").hide(),$("#"+o.pre+"mapWrapper2").hide(),$("#"+o.pre+"mapWrapper3").hide()):($("#"+o.pre+"emmapWrapper1").hide(),$("#"+o.pre+"emmapWrapper2").hide(),$("#"+o.pre+"emmapWrapper3").hide()));let c=!1;return o.bSecondaryStructure&&1==Object.keys(o.structures).length?c=!1:a.cfg.mmtfid||a.cfg.pdbid||a.cfg.opmid||a.cfg.mmdbid||a.cfg.gi||a.cfg.uniprotid||a.cfg.blast_rep_id||a.cfg.cid||a.cfg.mmcifid||a.cfg.align||a.cfg.chainalign||(c=!0),(!o.bSecondaryStructure||c)&&Object.keys(o.proteins).length>0&&!r?await this.applyCommandDssp(i):(await this.loadPdbDataRender(i),a.bNode||await o.ParserUtilsCls.checkMemProteinAndRotate()),d}async applyCommandDssp(e){let t=this.icn3d,s=t.icn3dui,i=s.utilsCls.isCalphaPhosOnly(s.hashUtilsCls.hash2Atoms(t.proteins,t.atoms));await t.dsspCls.applyDssp(i,e)}async loadPdbDataRender(e){let t=this.icn3d,s=t.icn3dui;void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),s.cfg.afid&&!t.bAfMem&&(t.opts.color="confidence"),t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.hAtoms),await t.ParserUtilsCls.renderStructure(),t.saveFileCls.showTitle(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0),e&&t.definedSetsCls.setModeAndDisplay("all")}}class Kt{constructor(e){this.icn3d=e}async downloadCid(e){let t=this.icn3d,s=t.icn3dui;t.ParserUtilsCls.setYourNote("PubChem CID "+e+" in iCn3D"),t.bCid=!0;let i="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/"+t.inputid+"/cids/JSONP?cids_type=parent",n="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/"+(await s.getAjaxPromise(i,"jsonp",!0,"Can not retrieve the parant CID...")).IdentifierList.CID[0]+"/record/SDF/?record_type=3d&response_type=display",l=await s.getAjaxPromise(n,"text",!0,"This CID may not have 3D structure..."),r=this.loadSdfAtomData(l,e);void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),r?(t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.atoms),await t.ParserUtilsCls.renderStructure(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0)):alert("The SDF of CID "+e+" has the wrong format...")}async loadSdfData(e){let t=this.icn3d,s=t.icn3dui,i=this.loadSdfAtomData(e);void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),i?(t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.atoms),await t.ParserUtilsCls.renderStructure(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0)):alert("The SDF file has the wrong format...")}loadSdfAtomData(e,t){let s=this.icn3d;s.icn3dui;let i=e.split(/\r?\n|\r/);if(i.length<4)return!1;s.init();let n=t||1,l="LIG",r=n,o=n+"_A",a=o+"_1",d=parseInt(i[3].substr(0,3));if(isNaN(d)||d<=0)return!1;let c=parseInt(i[3].substr(3,3)),h=4;if(i.lengthr||(Math.abs(t.coord.y-i.coord.y)>r||Math.abs(t.coord.z-i.coord.z)>r||l.utilsCls.hasCovalentBond(t,i)&&(n.atoms[o[e]].bonds.push(o[s]),n.atoms[o[s]].bonds.push(o[e])))}}}loadXyzAtomData(e){let t=this.icn3d;t.icn3dui;let s=e.split(/\r?\n|\r/);if(s.length<3)return!1;t.init();let i,n,l,r={},o=0,a=1;t.molTitle="";for(let e=0,d=s.length;e1&&(t.molTitle+="; "),t.molTitle+=s[e+1].trim(),e+=2),d=s[e].trim(),""===d)continue;let c=d.replace(/,/," ").replace(/\s+/g," ").split(" "),h=c[0],p=parseFloat(c[1]),m=parseFloat(c[2]),u=parseFloat(c[3]),g={het:!0,serial:a,name:h,resn:"LIG",structure:l,chain:"A",resi:1,coord:new THREE.Vector3(p,m,u),b:0,elem:h,bonds:[],ss:"coil",ssbegin:!1,ssend:!1,bondOrder:[]};t.atoms[a]=g,r[a]=1,++a}return this.setXyzAtomSeq(r,o,i,n),t.ParserUtilsCls.setMaxD(),t.saveFileCls.showTitle(),!0}}class Jt{constructor(e){this.icn3d=e}realign(){let e=this.icn3d,t=e.icn3dui;e.selectionCls.saveSelectionPrep();let s="alseq_"+Object.keys(e.defNames2Atoms).length;e.selectionCls.saveSelection(s,s),t.htmlCls.clickMenuCls.setLogCmd("realign",!0);let i={},n={};e.realignResid={};let l="";for(let s in e.hAtoms){let r=e.atoms[s],o=r.structure+"_"+r.chain;if(e.proteins.hasOwnProperty(s)&&"CA"==r.name||e.nucleotides.hasOwnProperty(s)&&("O3'"==r.name||"O3*"==r.name)){if(r.structure+"_"+r.resi==l)continue;i.hasOwnProperty(r.structure)||(i[r.structure]=[]),i[r.structure].push(r.coord.clone()),e.realignResid.hasOwnProperty(o)||(e.realignResid[o]=[]),e.realignResid[o].push({resid:o+"_"+r.resi,resn:t.utilsCls.residueName2Abbr(r.resn.substr(0,3)).substr(0,1)}),n[r.structure]=r.structure+"_"+r.chain,l=r.structure+"_"+r.resi}}let r=Object.keys(i),o=r[0],a=[];e.qt_start_end=[],a.push(n[o]);for(let t=1,s=r.length;t5){let e=r.cfg.chainalign.split(",");e.length>0&&(l.hAtoms=l.definedSetsCls.getAtomsFromNameArray(e)),r.cfg.aligntool="tmalign",await l.realignParserCls.realignOnStructAlign()}else l.hAtoms=l.chainalignParserCls.setMsa(e),l.transformCls.zoominSelection(),await l.chainalignParserCls.downloadChainalignmentPart3(void 0,e,l.hAtoms)}async parseChainRealignData(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui,d=s[0].substr(0,s[0].indexOf("_"));r||(d=d.toUpperCase());let c={};o.realignResid={},o.opts.color="grey",o.setColorCls.setColorByOptions(o.opts,o.dAtoms),o.qt_start_end=[];for(let t=0,h=e.length;t=6&&C.length>=6&&!a.cfg.command&&o.bRender&&alert("These sequences can not be aligned to each other")):o.bRender&&alert("Please do not align residues in the same structure")}if(r){o.hAtoms=o.chainalignParserCls.setMsa(s);let e="protein_aligned";if(o.selectionCls.saveSelection(e,e),o.bAfMem?(o.selectionCls.selectAll_base(),o.opts.chemicals="stick",o.opts.color="confidence",o.setColorCls.setColorByOptions(o.opts,o.atoms)):(o.transformCls.zoominSelection(),o.dAtoms=a.hashUtilsCls.cloneHash(o.hAtoms),o.opts.color="identity",o.setColorCls.setColorByOptions(o.opts,o.hAtoms)),o.drawCls.draw(),o.hlUpdateCls.updateHlAll(),o.bAfMem){let e=new THREE.Vector3(1,0,0),t=-.5*Math.PI;o.transformCls.setRotation(e,t)}}else o.hAtoms=o.chainalignParserCls.setMsa(s),o.transformCls.zoominSelection(),await o.chainalignParserCls.downloadChainalignmentPart3(t,s,o.hAtoms)}async realignOnSeqAlign(e){let t=this.icn3d;t.icn3dui;let s=t.firstAtomObjCls.getChainsFromAtoms(t.hAtoms),i=Object.keys(s),n=[],l="";for(let e=0,t=i.length;ef&&(f=s)}}}return{data:n,min:g,max:f}}(e.getCategory("_volume_data_3d").getColumn("values"),o,n.sampleCount,l);return{name:n.name,spacegroup:function(e,t,s){let i=Math.PI/180*s[0],n=Math.PI/180*s[1],l=Math.PI/180*s[2],r=t[0],o=t[1],a=t[2],d=Math.cos(n),c=(Math.cos(i)-Math.cos(n)*Math.cos(l))/Math.sin(l),h=Math.sqrt(1-d*d-c*c);return{number:e,size:t,angles:s,basis:{x:[r,0,0],y:[Math.cos(l)*o,Math.sin(l)*o,0],z:[d*a,c*a,h*a]}}}(n.spacegroupNumber,n.cellSize,n.cellAngles),box:{origin:r(n.origin),dimensions:r(n.dimensions),sampleCount:o},data:a.data,valuesInfo:{min:a.min,max:a.max,mean:n.mean,sigma:n.sigma}}}BinaryParse(e){this.icn3d.icn3dui;let t=new Uint8Array(e),s=this.MessagePackParse({buffer:t,offset:0,dataView:new DataView(t.buffer)}),i=function(){function e(e){this.additionalData={},this.header=e.header,this.categoryList=e.categories.map((function(e){return new n(e)})),this.categoryMap=new Map;for(let e=0,t=this.categoryList;e=0;s--)t=c(t,e.encoding[s]);return t}function p(e){if(!e.data.data)return _UndefinedColumn;let t,s=h(e.data);return e.mask&&(t=h(e.mask)),s.buffer&&s.byteLength&&s.BYTES_PER_ELEMENT?t?new f(s,t):new g(s):t?new C(s,t):new b(s)}function m(e,t,s){let i=0,n=1;for(45===e.charCodeAt(t)&&(n=-1,t++);t9||s<0)return n*i|0;i=10*i+s|0}return n*i}function u(e,t,s){let i=1,n=0,l=0,r=1;for(45===e.charCodeAt(t)&&(i=-1,++t);t=0&&o<10)){if(-2===o){for(++t;t=0&&o<10))return 53===o||21===o?parseScientific(i*(n+l/r),e,t+1,s):i*(n+l/r);l=10*l+o,r*=10,++t}return i*(n+l/r)}if(53===o||21===o)return parseScientific(i*n,e,t+1,s);break}n=10*n+o,++t}return i*n}let g=function(){function e(e){this.data=e,this.isDefined=!0}return e.prototype.getString=function(e){return""+this.data[e]},e.prototype.getInteger=function(e){return 0|this.data[e]},e.prototype.getFloat=function(e){return 1*this.data[e]},e.prototype.stringEquals=function(e,t){return this.data[e]===u(t,0,t.length)},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return 0},e}(),f=function(){function e(e,t){this.data=e,this.mask=t,this.isDefined=!0}return e.prototype.getString=function(e){return 0===this.mask[e]?""+this.data[e]:null},e.prototype.getInteger=function(e){return 0===this.mask[e]?this.data[e]:0},e.prototype.getFloat=function(e){return 0===this.mask[e]?this.data[e]:0},e.prototype.stringEquals=function(e,t){return 0===this.mask[e]?this.data[e]===u(t,0,t.length):null==t},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return this.mask[e]},e}(),b=function(){function e(e){this.data=e,this.isDefined=!0}return e.prototype.getString=function(e){return this.data[e]},e.prototype.getInteger=function(e){let t=this.data[e];return m(t,0,t.length)},e.prototype.getFloat=function(e){let t=this.data[e];return u(t,0,t.length)},e.prototype.stringEquals=function(e,t){return this.data[e]===t},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return 0},e}(),C=function(){function e(e,t){this.data=e,this.mask=t,this.isDefined=!0}return e.prototype.getString=function(e){return 0===this.mask[e]?this.data[e]:null},e.prototype.getInteger=function(e){if(0!==this.mask[e])return 0;let t=this.data[e];return m(t||"",0,(t||"").length)},e.prototype.getFloat=function(e){if(0!==this.mask[e])return 0;let t=this.data[e];return u(t||"",0,(t||"").length)},e.prototype.stringEquals=function(e,t){return this.data[e]===t},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return this.mask[e]},e}(),y=function(){function e(e){this.dataBlocks=e.dataBlocks.map((function(e){return new i(e)}))}return e.prototype.toJSON=function(){return this.dataBlocks.map((function(e){return e.toJSON()}))},e}();return new y(s)}MessagePackParse(e){this.icn3d.icn3dui;let t=this;function s(e,s){let i={};for(let n=0;n0&&(i[i.length]=l.slice(0,a).join(""));return i.join("")}(e.buffer,e.offset,t);return e.offset+=t,s}let r=function(){let e=[];for(let t=0;t<1024;t++)e[t]=String.fromCharCode(t);return e}();let o,a,d=e.buffer[e.offset];if(0==(128&d))return e.offset++,d;if(128==(240&d))return a=15&d,e.offset++,s(e,a);if(144==(240&d))return a=15&d,e.offset++,n(e,a);if(160==(224&d))return a=31&d,e.offset++,l(e,a);if(224==(224&d))return o=e.dataView.getInt8(e.offset),e.offset++,o;switch(d){case 192:return e.offset++,null;case 194:return e.offset++,!1;case 195:return e.offset++,!0;case 196:return a=e.dataView.getUint8(e.offset+1),e.offset+=2,i(e,a);case 197:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,i(e,a);case 198:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,i(e,a);case 202:return o=e.dataView.getFloat32(e.offset+1),e.offset+=5,o;case 203:return o=e.dataView.getFloat64(e.offset+1),e.offset+=9,o;case 204:return o=e.buffer[e.offset+1],e.offset+=2,o;case 205:return o=e.dataView.getUint16(e.offset+1),e.offset+=3,o;case 206:return o=e.dataView.getUint32(e.offset+1),e.offset+=5,o;case 208:return o=e.dataView.getInt8(e.offset+1),e.offset+=2,o;case 209:return o=e.dataView.getInt16(e.offset+1),e.offset+=3,o;case 210:return o=e.dataView.getInt32(e.offset+1),e.offset+=5,o;case 217:return a=e.dataView.getUint8(e.offset+1),e.offset+=2,l(e,a);case 218:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,l(e,a);case 219:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,l(e,a);case 220:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,n(e,a);case 221:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,n(e,a);case 222:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,s(e,a);case 223:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,s(e,a)}}}class es{constructor(e){this.icn3d=e}alignCoords(e,t,s,i,n,l,r,o){let a,d=this.icn3d,c=d.icn3dui,h=e.length=4&&(d.rmsd_suprTmp=c.rmsdSuprCls.getRmsdSuprCls(e,t,h),void 0!==d.rmsd_suprTmp.rot)){let e=d.rmsd_suprTmp.rot;null===e[0]&&alert("Please select more residues in each structure...");let t=d.rmsd_suprTmp.trans1,i=d.rmsd_suprTmp.trans2;if(a=d.rmsd_suprTmp.rmsd,a){c.htmlCls.clickMenuCls.setLogCmd("realignment RMSD: "+a.toPrecision(4),!1);let e="
    Realignment RMSD: "+a.toPrecision(4)+" Å

    ";d.bAfMem&&(e+=c.utilsCls.getMemDesc()),$("#"+d.pre+"dl_rmsd").html(e),c.cfg.bSidebyside||c.htmlCls.dialogCls.openDlg("dl_rmsd","Realignment RMSD")}let r={};for(let n=0,l=d.structures[s].length;n"+s.diagram2dCls.set2DdgmNote(!0),$("#"+s.pre+"dl_2ddgm").html(s.html2ddgm),s.b2DShown=!0}async set2DDiagramsForChainalign(e){let t=this.icn3d.icn3dui,s=this;t.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions");let i=[];for(let s=0,n=e.length;s"+s.diagram2dCls.set2DdgmNote(!0),s.b2DShown=!0,$("#"+s.pre+"dl_2ddgm").html(s.html2ddgm),i.cfg.show2d&&i.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions")}download2Ddgm(e,t){this.set2DDiagrams(e)}set2DDiagrams(e){let t=this.icn3d;t.icn3dui.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions"),void 0!==t.b2DShown&&t.b2DShown||(t.html2ddgm="",t.diagram2dCls.draw2Ddgm(t.interactionData,e),t.html2ddgm+="
    "+t.diagram2dCls.set2DdgmNote(),$("#"+t.pre+"dl_2ddgm").html(t.html2ddgm)),t.b2DShown=!0}showLoading(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"wait")&&$("#"+e.pre+"wait").show(),$("#"+e.pre+"canvas")&&$("#"+e.pre+"canvas").hide(),$("#"+e.pre+"cmdlog")&&$("#"+e.pre+"cmdlog").hide()}hideLoading(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"wait")&&$("#"+e.pre+"wait").hide(),$("#"+e.pre+"canvas")&&$("#"+e.pre+"canvas").show(),$("#"+e.pre+"cmdlog")&&$("#"+e.pre+"cmdlog").show()}setYourNote(e){let t=this.icn3d,s=t.icn3dui;t.yournote=e,$("#"+t.pre+"yournote").val(t.yournote),s.cfg.shownote&&(document.title=t.yournote)}transformToOpmOri(e){let t=this.icn3d;if(t.icn3dui,void 0!==t.rmsd_supr&&void 0!==t.rmsd_supr.rot){let s=t.rmsd_supr.rot,i=t.rmsd_supr.trans1,n=t.rmsd_supr.trans2;t.rmsd_supr.rmsd;let l=0;for(let e in t.atoms){let r=t.atoms[e];r.coord=t.surfaceCls.transformMemPro(r.coord,s,i,n);let o=r.coord.x*r.coord.x+r.coord.y*r.coord.y;Math.abs(r.coord.z)<=25&&o>l&&(l=o)}this.addMemAtoms(t.halfBilayerSize,e,Math.sqrt(l)),t.bStopRotate=!0,t.bOpm=!0,$("#"+t.pre+"togglememli").show(),$("#"+t.pre+"adjustmemli").show(),$("#"+t.pre+"selectplaneli").show()}else t.bOpm=!1}transformToOpmOriForAlign(e,t,s){let i=this.icn3d,n=i.icn3dui;if(void 0!==t){let l=i.loadPDBCls.getChainCalpha(i.chains,i.atoms,s,e),r=1==Object.keys(l.chainresiCalphaHash).length||1==Object.keys(t.chainresiCalphaHash).length,o=[],a=[];for(let e in l.chainresiCalphaHash)if(t.chainresiCalphaHash.hasOwnProperty(e)){let s=l.chainresiCalphaHash[e],i=t.chainresiCalphaHash[e];if((s.length==i.length||r)&&(o=o.concat(s),a=a.concat(i)),o.length>500)break}let d=o.length=4)if(i.rmsd_supr=n.rmsdSuprCls.getRmsdSuprCls(o,a,d),void 0!==i.rmsd_supr.rot&&i.rmsd_supr.rmsd<.1){let s=i.rmsd_supr.rot,l=i.rmsd_supr.trans1,r=i.rmsd_supr.trans2,o=i.rmsd_supr.rmsd;n.htmlCls.clickMenuCls.setLogCmd("RMSD of alignment to OPM: "+o.toPrecision(4),!1);let a=0;for(let e in i.atoms){let t=i.atoms[e];t.coord=i.surfaceCls.transformMemPro(t.coord,s,l,r);let n=t.coord.x*t.coord.x+t.coord.y*t.coord.y;Math.abs(t.coord.z)<=25&&n>a&&(a=n)}i.center=t.center,i.oriCenter=i.center.clone(),this.addMemAtoms(i.halfBilayerSize,e,Math.sqrt(a)),i.bStopRotate=!0,i.bOpm=!0,$("#"+i.pre+"togglememli").show(),$("#"+i.pre+"adjustmemli").show(),$("#"+i.pre+"selectplaneli").show()}else i.bOpm=!1;else i.bOpm=!1}}addOneDumAtom(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui,a={het:!0,serial:++l,name:t,alt:void 0,resn:"DUM",structure:e,chain:"MEM",resi:1,coord:new THREE.Vector3(s,i,n),b:void 0,elem:t,bonds:[],ss:"",ssbegin:!1,ssend:!1,color:o.parasCls.atomColors[t]};return r.atoms[l]=a,r.chains[e+"_MEM"][l]=1,r.residues[e+"_MEM_1"][l]=1,r.chemicals[l]=1,r.dAtoms[l]=1,r.hAtoms[l]=1,l}addMemAtoms(e,t,s){let i=this.icn3d;if(i.icn3dui,!t)return;t=t?t.toUpperCase():i.defaultPdbId,i.structures[t].push(t+"_MEM"),i.chains[t+"_MEM"]={},i.residues[t+"_MEM_1"]={},i.chainsSeq[t+"_MEM"]=[{name:"DUM",resi:1}];let n=Object.keys(i.atoms).length;for(let e=0;e<1e3;++e)if(!i.atoms.hasOwnProperty(n+e)){n=n+e-1;break}for(let i=0;i<81;++i)for(let l=0;l<81;++l){let r=2*i-80,o=2*l-80;if(Math.sqrt(r*r+o*o)=2?$("#"+e.pre+"mn2_alternateWrap").show():$("#"+e.pre+"mn2_alternateWrap").hide(),setTimeout((async function(){if(e.bInitial){if(void 0!==t.cfg.align||void 0!==t.cfg.chainalign){let s=e.pre+"selection";if($("#"+s).show(),$("#"+s+"_expand").hide(),$("#"+s+"_shrink").show(),void 0!==t.cfg.align&&2!=t.cfg.atype){let s=!1,i=t.htmlCls.alignSeqCls.getAlignSequencesAnnotations(Object.keys(e.alnChains),void 0,void 0,s);$("#"+e.pre+"dl_sequence2").html(i.sequencesHtml),$("#"+e.pre+"dl_sequence2").width(t.htmlCls.RESIDUE_WIDTH*i.maxSeqCnt+200)}}if(t.cfg.showanno){let s="view annotations";t.htmlCls.clickMenuCls.setLogCmd(s,!0),await e.showAnnoCls.showAnnotations()}t.cfg.closepopup&&e.resizeCanvasCls.closeDialogs()}else e.hlUpdateCls.updateHlAll();$("#"+e.pre+"atomsCustom").length>0&&$("#"+e.pre+"atomsCustom")[0].blur(),e.bInitial=!1}),0)}processCommand(){let e=this.icn3d,t=e.icn3dui;if(1==Object.keys(e.structures).length){let s=Object.keys(e.structures)[0];t.cfg.command=t.cfg.command.replace(new RegExp("!","g"),s+"_")}}getMassCenter(e,t){return this.icn3d.icn3dui,e.multiplyScalar(1/t)}getGeoCenter(e,t){return this.icn3d.icn3dui,e.clone().add(t).multiplyScalar(.5)}getStructureSize(e,t,s,i){let n=this.icn3d;n.icn3dui;let l=0;for(let r in e){let e=n.atoms[r].coord;if(Math.round(t.x)==Math.round(e.x)||Math.round(t.y)==Math.round(e.y)||Math.round(t.z)==Math.round(e.z)||Math.round(s.x)==Math.round(e.x)||Math.round(s.y)==Math.round(e.y)||Math.round(s.z)==Math.round(e.z)){let t=2*e.distanceTo(i);t>l&&(l=t)}}return l}async checkMemProteinAndRotate(){let e=this.icn3d,t=e.icn3dui;if(!e.bCheckMemProtein){e.bCheckMemProtein=!0;let s=t.cfg.afid?t.cfg.afid:t.cfg.mmdbafid;if(await e.ParserUtilsCls.checkMemProtein(s),t.cfg.url&&-1!=t.cfg.url.indexOf("membranome")){let t=new THREE.Vector3(1,0,0),s=-.5*Math.PI;e.transformCls.setRotation(t,s)}}}async checkMemProtein(e){let t=this.icn3d,s=t.icn3dui;try{let i=s.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?afid2mem="+e,n=await s.getAjaxPromise(i,"jsonp");if(n&&n.pdbid){let e='This is a single-spanning (bitopic) transmembrane protein according to the Membranome database. Do you want to align the protein with the model from Membranome? If you click "OK", you can press the letter "a" to alternate the structures.';if("off"==s.cfg.afmem);else if("on"==s.cfg.afmem||confirm(e))try{let e="https://storage.googleapis.com/membranome-assets/pdb_files/proteins/"+n.pdbid+".pdb",i=await s.getAjaxPromise(e,"text");t.bAfMem=!0,s.bNode||$("#"+s.pre+"togglememli").show();let l=n.pdbid.substr(0,n.pdbid.indexOf("_")),r=!0,o=!0;await t.pdbParserCls.loadPdbData(i,l,r,o),o&&(t.bSetChainsAdvancedMenu&&t.definedSetsCls.showSets(),t.bAnnoShown&&await t.showAnnoCls.showAnnotations());let a=n.segment.replace(/ /gi,"").split("(")[0];t.afmem_start_end=a.split("-"),t.hAtoms={},t.dAtoms={};for(let e in t.atoms)t.atoms[e].structure!=l&&(t.hAtoms[e]=1),t.dAtoms[e]=1;for(let e=parseInt(t.afmem_start_end[0]);e<=parseInt(t.afmem_start_end[1]);++e)t.hAtoms=s.hashUtilsCls.unionHash(t.hAtoms,t.residues[l+"_A_"+e]);await t.realignParserCls.realignOnSeqAlign(l)}catch(e){return void console.log("Error in retrieving matched PDB from Membranome...")}}}catch(e){return void console.log("Error in finding matched PDB in Membranome...")}}getResi(e,t){let s=this.icn3d;s.icn3dui;let i=s.ncbi2resid[e+"_"+(t+1).toString()];return i?i.substr(i.lastIndexOf("_")+1):""}getResiNCBI(e,t){let s=this.icn3d;s.icn3dui;let i=s.resid2ncbi[e+"_"+t];return i?parseInt(i.substr(i.lastIndexOf("_")+1)):0}}class ts{constructor(e){this.icn3d=e}loadAtomDataIn(e,t,s,i,n,l,r,o,a){let d=this.icn3d,c=d.icn3dui;d.pmin=new THREE.Vector3(9999,9999,9999),d.pmax=new THREE.Vector3(-9999,-9999,-9999),d.psum=new THREE.Vector3;let h=e.atoms,p=d.atoms?Object.keys(d.atoms).length:0,m={},u={};d.pmid=e.pubmedId,void 0===d.chainid2title&&(d.chainid2title={}),void 0===d.chainid2sid&&(d.chainid2sid={});let g={},f={};if("align"===s){d.pmid="",d.molTitle="",c.cfg.inpara&&-1!==c.cfg.inpara.indexOf("atype=1")?d.molTitle="Invariant Core Structure Alignment (VAST) of ":c.cfg.inpara&&-1!==c.cfg.inpara.indexOf("atype=2")?d.molTitle="Structure Alignment (TM-align) of ":d.molTitle="Structure Alignment (VAST) of ";let t=!1;for(let s=0,i=e.alignedStructures[0].length;s'+i.pdbId.toUpperCase()+"",void 0!==i.descr&&(d.pmid+=i.descr.pubmedid),0===s&&(d.molTitle+=" and ",void 0!==i.descr&&(d.pmid+="_")),t=!0}d.molTitle+=" from VAST+",t||(d.molTitle="")}else if(void 0!==e.descr&&(d.molTitle+=e.descr.name),"mmdbid"===s){let s=isNaN(t)?t:e.pdbId,i={};void 0===d.alignmolid2color&&(d.alignmolid2color=[]);let n=1;for(let t in e.moleculeInfor){if(0===Object.keys(e.moleculeInfor[t]).length)continue;let l=e.moleculeInfor[t].chain.trim(),r=s+"_"+l;i.hasOwnProperty(l)?(++i[l],r+=i[l]):i[l]=1,void 0!==d.mmdbid_q&&(d.mmdbid_q,d.mmdbid_t);let o=e.moleculeInfor[t].kind,a=e.moleculeInfor[t].color,c=e.moleculeInfor[t].sid;if(g[r]=o,f[r]=a,"protein"==o&&(d.organism=e.moleculeInfor[t].taxonomyName.toLowerCase()),void 0!==c&&(d.chainid2sid[r]=c),void 0===d.pdbid_chain2title&&(d.pdbid_chain2title={}),d.pdbid_chain2title[r]=e.moleculeInfor[t].name,l==r.substr(r.lastIndexOf("_"))){let e={};e[t]=n.toString(),d.alignmolid2color.push(e)}++n}}let b,C,y,v,w,_={},S="",A="",x="",k="",O="",R="",E=0,I=0,T="",M=!0,P=!1,D="",H=c.utilsCls.isCalphaPhosOnly(h),F=0,L={};for(let e in h){++p,_[e]=p;let i,n=h[e];n.serial=p,"mmdbid"===s||"mmcifid"===s?i=t:"align"===s&&(i=m[p]);let l=!1;if(void 0!==n.chain||"mmdbid"!==s&&"align"!==s)n.chain=""===n.chain?"Misc":n.chain;else if("mmdbid"===s)if(b=n.ids.m,void 0!==d.molid2chain[b]){let e=d.molid2chain[b].indexOf("_");n.chain=d.molid2chain[b].substr(e+1)}else{let e="Misc";("protein"===g[O]&&"nucleotide"===g[O]&&n.resi!=I||"protein"!==g[O]&&"nucleotide"!==g[O]&&(n.resn.substr(0,3)!=T.substr(0,3)||n.resi!=I||"solvent"===g[O]||"HOH"===n.resn))&&++F,n.resi_ori=n.resi,n.resi=F,l=!0,n.chain=e}else if("align"===s)if(b=n.ids.m,void 0!==d.pdbid_molid2chain[i+"_"+b])n.chain=d.pdbid_molid2chain[i+"_"+b];else{let e="Misc";("protein"===g[O]&&"nucleotide"===g[O]&&n.resi!=I||"protein"!==g[O]&&"nucleotide"!==g[O]&&(n.resn.substr(0,3)!=T.substr(0,3)||n.resi!=I||"solvent"===g[O]||"HOH"===n.resn))&&(++F,n.resi_ori=n.resi,n.resi=F,l=!0),n.chain=e}if(n.chain=n.chain.trim(),"mmdbid"!==s&&"align"!==s||(n.structure=i,"mmdbid"===s&&void 0!==d.mmdbid_q&&(d.mmdbid_q,d.mmdbid_t)),k=n.structure,O=k+"_"+n.chain,"mmdbid"===s||"align"===s){l||(n.resi_ori=n.resi,d.bUsePdbNum?n.resi=n.resi_ori:n.resi=n.ids.r);let e=n.resn.indexOf(" ");-1!==e&&0!=e&&(n.resn=n.resn.substr(0,e))}O!==A&&(E=0),n.resi!==E&&(O!==A?(y=void 0,w=void 0):(y=C,w=v)),n.coord="mmdbid"===s?new THREE.Vector3(n.coord[0],n.coord[1],n.coord[2]):new THREE.Vector3(n.coord.x,n.coord.y,n.coord.z);let r=c.utilsCls.residueName2Abbr(n.resn.substr(0,3));"mmdbid"!==s&&"align"!==s||!d.bFullUi||(void 0===d.mmdbMolidResid2mmdbChainResi&&(d.mmdbMolidResid2mmdbChainResi={}),d.mmdbMolidResid2mmdbChainResi[i+"_"+n.ids.m+"_"+n.ids.r]=i+"_"+n.chain+"_"+n.resi),d.pmin.min(n.coord),d.pmax.max(n.coord),d.psum.add(n.coord);let o=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"protein"===g[O]:"p"===n.mt,a=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"nucleotide"===g[O]:"n"===n.mt,u=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"solvent"===g[O]:"s"===n.mt,N=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"ligand"===g[O]||void 0!==g[O]&&-1!==g[O].indexOf("other")||void 0===g[O]:"l"===n.mt;if("Misc"!==n.chain&&"other"!==g[O]||"protein"===L[O]||"nucleotide"===L[O]||("CA"===n.name&&"C"===n.elem?L[O]="protein":"P"===n.name&&"P"===n.elem?L[O]="nucleotide":L[O]="chemical"),o||a?(o?(d.proteins[p]=1,"CA"===n.name&&(d.calphas[p]=1),"N"!==n.name&&"H"!==n.name&&"CA"!==n.name&&"HA"!==n.name&&"C"!==n.name&&"O"!==n.name&&(d.sidec[p]=1)):a&&(d.nucleotides[p]=1,("O3'"==n.name||"O3*"==n.name||H&&"P"==n.name)&&(d.nucleotidesO3[p]=1),-1===c.parasCls.nuclMainArray.indexOf(n.name)&&(d.ntbase[p]=1)),n.het=!1):u?(d.water[p]=1,n.het=!0):N&&("HOH"===n.resn||"O"===n.resn?d.water[p]=1:n.elem===n.resn?d.ions[p]=1:d.chemicals[p]=1,n.het=!0),"mmdbid"===s?n.het?n.color=c.parasCls.atomColors[n.elem]||c.parasCls.defaultAtomColor:n.color=void 0!==f[O]?c.parasCls.thr(f[O]):c.parasCls.chargeColors[n.resn]:void 0!==n.color&&(n.color=c.parasCls.thr(n.color))," "!==n.resn.charAt(0)&&" "===n.resn.charAt(1)&&(n.resn=n.resn.charAt(0)),n.het||"C"!==n.name||(C=p),n.het||"O"!==n.name||(v=p),!n.het&&"N"===n.name&&void 0!==y&&void 0!==w){let e=d.atoms[y].coord.distanceTo(d.atoms[w].coord),t=n.coord.x+(d.atoms[y].coord.x-d.atoms[w].coord.x)/e,s=n.coord.y+(d.atoms[y].coord.y-d.atoms[w].coord.y)/e,i=n.coord.z+(d.atoms[y].coord.z-d.atoms[w].coord.z)/e;n.hcoord=new THREE.Vector3(t,s,i)}"HOH"==n.resn&&(d.water[p]=1),d.atoms[p]=n,d.dAtoms[p]=1,d.hAtoms[p]=1;let U=n.structure+"_"+n.chain;void 0===d.chains[U]&&(d.chains[U]={}),d.chains[U][p]=1;let q=U+"_"+n.resi;void 0===d.residues[q]&&(d.residues[q]={}),d.residues[q][p]=1,R=O+"_"+n.resi,R!==x&&O!==A&&(M=!0,""!==S&&(void 0===d.structures[S]&&(d.structures[S]=[]),d.structures[S].push(A))),d.residueId2Name[q]=r;let $="-";if("helix"===n.ss?$="H":"sheet"===n.ss?$="E":n.het||a?$="o":(!n.het&&c.parasCls.residueColors.hasOwnProperty(n.resn.toUpperCase())||"coil"===n.ss)&&($="c"),d.secondaries[n.structure+"_"+n.chain+"_"+n.resi]=$,(n.resi!=E||b!=D)&&d.bFullUi&&(void 0===d.chainsSeq[U]&&(d.chainsSeq[U]=[],M=!1),!isNaN(n.resi)))if(M&&!P&&void 0!==d.chainsSeq[U][n.resi-1])d.chainsSeq[U][n.resi-1].name=r;else if(!M||!d.chainsSeq[U].hasOwnProperty(n.resi-1)){let e={};e.resi=n.resi,e.name=r,n.resi%10==0&&n.resi.toString(),d.chainsSeq[U].push(e),P=!0}E=n.resi,I=n.resi_ori,T=n.resn,S=k,A=O,x=R,D=b}for(let e in d.chemicals){let t=d.atoms[e];if("P"==t.elem&&t.bonds.length>=4)for(let e=t.bonds.length-1;e>=0;--e){"P"==d.atoms[t.bonds[e]].elem&&t.bonds.splice(e,1)}}for(let e in L)if(!(Object.keys(d.chains[e]).length<10)&&"chemical"!==L[e])for(let t in d.chains[e]){let s=d.atoms[t];delete d.chemicals[t],s.het=!1,"protein"===L[e]?(d.proteins[t]=1,"CA"===s.name&&(d.calphas[t]=1),"N"!==s.name&&"H"!==s.name&&"CA"!==s.name&&"HA"!==s.name&&"C"!==s.name&&"O"!==s.name&&(d.sidec[t]=1)):"nucleotide"===L[e]&&(d.nucleotides[t]=1,("O3'"==s.name||"O3*"==s.name||H&&"P"==s.name)&&(d.nucleotidesO3[t]=1),-1===c.parasCls.nuclMainArray.indexOf(s.name)&&(d.ntbase[t]=1))}if(void 0===d.structures[k]&&(d.structures[k]=[]),d.structures[k].push(O),d.bFullUi)if("mmdbid"===s||"mmcifid"===s)for(let i in e.sequences){let n=e.sequences[i],l=t+"_"+i;void 0!==d.mmdbid_q&&(d.mmdbid_q,d.mmdbid_t),d.ParserUtilsCls.getMissingResidues(n,s,l)}else if("align"===s)for(let e in d.chainid2seq){let t=d.chainid2seq[e];d.ParserUtilsCls.getMissingResidues(t,s,e)}if(d.loadPDBCls.setResidMapping(),"mmcifid"!==s)for(let e in h){let t=_[e],s=void 0===d.atoms[t].bonds?0:d.atoms[t].bonds.length;for(let e=0;ed.maxatomcnt||void 0!==d.biomtMatrices&&d.biomtMatrices.length*d.cnt>10*d.maxatomcnt)&&(d.opts.proteins="c alpha trace",d.opts.nucleotides="o3 trace"),d.center=d.ParserUtilsCls.getGeoCenter(d.pmin,d.pmax),d.maxD=d.ParserUtilsCls.getStructureSize(d.atoms,d.pmin,d.pmax,d.center),d.maxD<5&&(d.maxD=5),d.oriMaxD=d.maxD,("align"===s||o)&&(d.ssbondpnts={},d.loadPDBCls.setSsbond()),"mmdbid"===s&&1==Object.keys(d.structures).length){let t=e.disulfides;if(void 0!==t)for(let e=0,s=t.length;ep&&(p=e)),c[e]={resi:t,resn:i,aligned:n}}r=e[t][1];let u=r.moleculeId,g=s.pdbid_molid2chain[l+"_"+u],f=l+"_"+g;void 0===s.alnChainsAnTtl[d]&&(s.alnChainsAnTtl[d]=[]),void 0===s.alnChainsAnTtl[d][0]&&(s.alnChainsAnTtl[d][0]=[]),void 0===s.alnChainsAnTtl[d][1]&&(s.alnChainsAnTtl[d][1]=[]),void 0===s.alnChainsAnTtl[d][2]&&(s.alnChainsAnTtl[d][2]=[]),void 0===s.alnChainsAnTtl[d][3]&&(s.alnChainsAnTtl[d][3]=[]),void 0===s.alnChainsAnTtl[d][4]&&(s.alnChainsAnTtl[d][4]=[]),void 0===s.alnChainsAnTtl[d][5]&&(s.alnChainsAnTtl[d][5]=[]),void 0===s.alnChainsAnTtl[d][6]&&(s.alnChainsAnTtl[d][6]=[]),s.alnChainsAnTtl[d][0].push(f),s.alnChainsAnTtl[d][1].push(d),s.alnChainsAnTtl[d][2].push(""),s.alnChainsAnTtl[d][3].push(""),s.alnChainsAnTtl[d][4].push(f),s.alnChainsAnTtl[d][5].push(d),s.alnChainsAnTtl[d][6].push("");let b=1;s.chainsMapping[d]||(s.chainsMapping[d]={}),s.chainsMapping[f]||(s.chainsMapping[f]={});for(let e=h;e<=p;++e){let t,o,p,m=s.bUsePdbNum?s.ParserUtilsCls.getResi(f,r.sequence[e][0]-1):r.sequence[e][0],u="~"===r.sequence[e][2]?"-":r.sequence[e][2],C=r.sequence[e][3]?1:0,y=c[e].aligned+C;2===y?(c[e].resn===u?(t="#FF0000",p="icn3d-cons",s.consHash1[d+"_"+c[e].resi]=1,s.consHash2[f+"_"+m]=1):(t="#0000FF",p="icn3d-ncons",s.nconsHash1[d+"_"+c[e].resi]=1,s.nconsHash2[f+"_"+m]=1),s.chainsMapping[d][d+"_"+c[e].resi]=c[e].resn+c[e].resi,s.chainsMapping[f][f+"_"+m]=c[e].resn+c[e].resi,o="#"+s.showAnnoCls.getColorhexFromBlosum62(c[e].resn,u)):(t=i.htmlCls.GREY8,p="icn3d-nalign",s.nalignHash1[d+"_"+c[e].resi]=1,s.nalignHash2[f+"_"+m]=1),void 0===s.alnChainsSeq[d]&&(s.alnChainsSeq[d]=[]);let v={};v.mmdbid=n,v.chain=a,v.resi=c[e].resi,v.resn=""===v.resi||"icn3d-nalign"===p?c[e].resn.toLowerCase():c[e].resn,v.aligned=y,v.color=""===v.resi?i.htmlCls.GREYC:t,v.color2=""===v.resi?i.htmlCls.GREYC:o,v.class=p,s.alnChainsSeq[d].push(v),""!==c[e].resi&&(void 0===s.alnChains[d]&&(s.alnChains[d]={}),$.extend(s.alnChains[d],s.residues[d+"_"+c[e].resi])),void 0===s.alnChainsSeq[f]&&(s.alnChainsSeq[f]=[]),v={},v.mmdbid=l,v.chain=g,v.resi=m,v.resn=""===v.resi||"icn3d-nalign"===p?u.toLowerCase():u,v.aligned=y,v.color=""===v.resi?i.htmlCls.GREYC:t,v.color2=""===v.resi?i.htmlCls.GREYC:o,v.class=p,s.alnChainsSeq[f].push(v),""!==v.resi&&(void 0===s.alnChains[f]&&(s.alnChains[f]={}),$.extend(s.alnChains[f],s.residues[f+"_"+m])),void 0===s.alnChainsAnno[d]&&(s.alnChainsAnno[d]=[]),void 0===s.alnChainsAnno[d][0]&&(s.alnChainsAnno[d][0]=[]),void 0===s.alnChainsAnno[d][1]&&(s.alnChainsAnno[d][1]=[]),void 0===s.alnChainsAnno[d][2]&&(s.alnChainsAnno[d][2]=[]),void 0===s.alnChainsAnno[d][3]&&(s.alnChainsAnno[d][3]=[]),e===h&&(void 0===s.alnChainsAnno[d][4]&&(s.alnChainsAnno[d][4]=[]),void 0===s.alnChainsAnno[d][5]&&(s.alnChainsAnno[d][5]=[]),void 0===s.alnChainsAnno[d][6]&&(s.alnChainsAnno[d][6]=[]),s.alnChainsAnno[d][4].push(s.pdbid_chain2title[f]),s.alnChainsAnno[d][5].push(s.pdbid_chain2title[d]),s.alnChainsAnno[d][6].push(""));let w=d+"_"+c[e].resi,_=f+"_"+m,S=s.secondaries[w],A=s.secondaries[_];A?s.alnChainsAnno[d][0].push(A):s.alnChainsAnno[d][0].push("-"),S?s.alnChainsAnno[d][1].push(S):s.alnChainsAnno[d][1].push("-");let x=".";b%5==0&&(x="*"),b%10==0&&(x="|"),s.alnChainsAnno[d][2].push(x);let k="";b%10==0&&(k=b.toString()),s.alnChainsAnno[d][3].push(k),++b}}e={}}getPosFromResi(e,t){let s=this.icn3d;s.icn3dui;let i,n=s.resid2ncbi[e+"_"+t];if(n){i=n.substr(n.lastIndexOf("_")+1)-1}return i}getResnFromResi(e,t){let s=this.icn3d,i=s.icn3dui,n=this.getPosFromResi(e,t);if(!n)return"?";let l=e+"_"+t,r="";return r=void 0===s.residues[l]?s.chainsSeq[e][n]?s.chainsSeq[e][n].name:"?":i.utilsCls.residueName2Abbr(s.firstAtomObjCls.getFirstAtomObj(s.residues[l]).resn.substr(0,3)),r}setSeqAlignChain(e,t,s){let i,n,l,r,o,a,d,c,h,p,m,u=this.icn3d,g=u.icn3dui,f={},b=!!s;if(b){if(o=s[1],a=s[0],t=s[2],d=o.indexOf("_"),c=a.indexOf("_"),i=o.substr(0,d).toUpperCase(),n=a.substr(0,c).toUpperCase(),l=o.substr(d+1),r=a.substr(d+1),i==n&&l==r){let e=u.chainsSeq[n+"_"+r].length;u.qt_start_end[t]={q_start:1,q_end:e,t_start:1,t_end:e}}}else{let d=s[0].indexOf("_"),c=e.indexOf("_");if(i=u.mmdbid_t,n=e.substr(0,c).toUpperCase(),l=s[0].substr(d+1),r=e.substr(c+1),i==n&&l==r){let e=u.chainsSeq[u.mmdbid_q+"_"+u.chain_q].length;u.qt_start_end[t]={q_start:1,q_end:e,t_start:1,t_end:e}}o=i+"_"+l,a=n+"_"+r,void 0!==n&&u.mmdbid_t}u.conservedName1=o+"_cons",u.nonConservedName1=o+"_ncons",u.notAlignedName1=o+"_nalign",u.conservedName2=a+"_cons",u.nonConservedName2=a+"_ncons",u.notAlignedName2=a+"_nalign",u.consHash1={},u.nconsHash1={},u.nalignHash1={},u.consHash2={},u.nconsHash2={},u.nalignHash2={},u.alnChains={},u.alnChainsSeq[o]=[],u.alnChains[o]={},u.alnChainsSeq[a]=[],u.alnChains[a]={},u.alnChainsAnno[o]=[],u.alnChainsAnTtl[o]=[],void 0===u.alnChainsAnTtl[o]&&(u.alnChainsAnTtl[o]=[]);for(let e=0;e<7;++e)void 0===u.alnChainsAnTtl[o][e]&&(u.alnChainsAnTtl[o][e]=[]);u.alnChainsAnTtl[o][0].push(a),u.alnChainsAnTtl[o][1].push(o),u.alnChainsAnTtl[o][2].push(""),u.alnChainsAnTtl[o][3].push(""),u.alnChainsAnTtl[o][4].push(a),u.alnChainsAnTtl[o][5].push(o),u.alnChainsAnTtl[o][6].push("");let C=0,y=0;if(void 0===u.qt_start_end[t])return;let v=1;u.chainsMapping[o]||(u.chainsMapping[o]={}),u.chainsMapping[a]||(u.chainsMapping[a]={});let w={},_={};for(let e=0,s=u.qt_start_end[t].length;e0){let e=v;for(let t=C+1,i=s;tc&&(c=t)}}}"tmalign"==n.cfg.aligntool&&(s=!0);let p=Object.keys(a);p.sort((function(e,t){return parseInt(e)-parseInt(t)}));let m=-999,u=0,g=0,f=[],b=0;for(let e=0,t=p.length;e0&&i.resid2ncbi[t]!=i.resid2ncbi[m]+1&&i.resid2ncbi[t]!=i.resid2ncbi[m]){g=m;for(let e=0,t=f.length;ec)continue;let o={},p=r.indexOf("_");o.mmdbid=r.substr(0,p),o.chain=r.substr(p+1),o.resi=t,o.resn=a[t]?i.chainsSeq[r][e].name.toUpperCase():i.chainsSeq[r][e].name.toLowerCase(),o.aligned=!!a[t],o.color=a[t]?"#FF0000":n.htmlCls.GREYC,o.color2=a[t]?"#FF0000":n.htmlCls.GREYC,o.class=a[t]?"icn3d-align":"icn3d-nalign",i.alnChainsSeq[r].push(o),a[t]&&($.extend(i.alnChains[r],i.residues[r+"_"+o.resi]),l=n.hashUtilsCls.unionHash(l,i.residues[r+"_"+o.resi]))}let C=[0];for(let i=0,r=t.length;in)for(let e=0,t=u-m;e=n)for(let e=0,s=t-n;e0?void 0!==n?p.alnChainsAnno[t][0].push(n):p.alnChainsAnno[t][0].push("-"):console.log("Error: ic.alnChainsAnno[chainid1] is undefined")}}}class is{constructor(e){this.icn3d=e}getStructureId(e,t,s){let i=this.icn3d;i.icn3dui;let n=e;return(e==i.defaultPdbId||s)&&(n=1===t?e:e+t.toString()),n}loadPDB(e,t,s,i,n,l,r,o){let a,d,c=this.icn3d,h=c.icn3dui,p={},m=!1,u=e.split("\n"),g={},f={};c.atoms||(l=!1),n||l?(c.oriNStru=c.structures?Object.keys(c.structures).length:0,d=c.oriNStru+1,a=c.atoms?Object.keys(c.atoms).length:0):(c.init(),d=1,a=0);let b,C,y,v,w,_,S,A=[],x=[],k=[],O=[],R=[],E=[],I="",T="",M="",P={},D=t||c.defaultPdbId,H=D,F="",L=!1;for(let e in u){let r=u[e],o=r.substr(0,6);if("HEADER"!==o||L||t)if("TITLE "===o){let e=r.substr(10).replace(/ALPHAFOLD MONOMER V2.0 PREDICTION FOR /gi,"");c.molTitle+=e.trim()+" "}else if("HELIX "===o){c.bSecondaryStructure=!0;let e=""==r.substr(18,2).trim()?"A":r.substr(18,2).trim(),t=parseInt(r.substr(21,4)),s=parseInt(r.substr(33,4));for(let i=t;i<=s;++i){let n=H+"_"+e+"_"+i;O.push(n),i===t&&R.push(n),i===s&&E.push(n)}}else if("SHEET "===o){void 0!==s&&s||(c.bSecondaryStructure=!0);let e=""==r.substr(20,2).trim()?"A":r.substr(20,2).trim(),t=parseInt(r.substr(22,4)),i=parseInt(r.substr(33,4));for(let s=t;s<=i;++s){let n=H+"_"+e+"_"+s;A.push(n),s===t&&x.push(n),s===i&&k.push(n)}}else if("HBOND "===o)void 0!==s&&s||(c.bSecondaryStructure=!0);else if("SSBOND"===o){c.bSsbondProvided=!0;let e=D+"_"+(" "==r.substr(15,1)?"A":r.substr(15,1))+"_"+r.substr(17,4).trim(),t=D+"_"+(" "==r.substr(29,1)?"A":r.substr(29,1))+"_"+r.substr(31,4).trim();void 0===c.ssbondpnts[D]&&(c.ssbondpnts[D]=[]),c.ssbondpnts[D].push(e),c.ssbondpnts[D].push(t)}else if("REMARK"===o){let e=parseInt(r.substr(7,3));if(-1!==r.indexOf("1/2 of bilayer thickness:"))c.halfBilayerSize=parseFloat(r.substr(r.indexOf(":")+1).trim());else if(210==e)"EXPERIMENT TYPE"==r.substr(11,32).trim()&&"NMR"==r.substr(45).trim()&&(m=!0);else if(350==e&&"BIOMT"==r.substr(13,5)){let e=parseInt(r[18])-1,t=parseInt(r.substr(21,2))-1;null==c.biomtMatrices[t]&&(c.biomtMatrices[t]=(new THREE.Matrix4).identity()),c.biomtMatrices[t].elements[e]=parseFloat(r.substr(24,9)),c.biomtMatrices[t].elements[e+4]=parseFloat(r.substr(34,9)),c.biomtMatrices[t].elements[e+8]=parseFloat(r.substr(44,9)),c.biomtMatrices[t].elements[e+12]=parseFloat(r.substr(54,14))}else if(465==e&&" "==r.substr(18,1)&&" "==r.substr(20,1)&&"S"!=r.substr(21,1)){let e=r.substr(15,3),t=r.substr(18,2).trim(),s=r.substr(21,5).trim(),i=D+"_"+t;void 0===c.chainMissingResidueArray[i]&&(c.chainMissingResidueArray[i]=[]);let n={};n.resi=s,n.name=h.utilsCls.residueName2Abbr(e).toLowerCase(),""!=F&&t==F&&t!=F||(c.chainMissingResidueArray[i].push(n),F=t)}else 900==e&&void 0===c.emd&&"RELATED DB: EMDB"==r.substr(34).trim()&&(c.emd=r.substr(23,11).trim())}else if("SOURCE"===o&&void 0===c.organism&&"ORGANISM_COMMON"==r.substr(11,15).trim())c.organism=r.substr(28).toLowerCase().trim(),c.organism=c.organism.substr(0,c.organism.length-1);else if("ENDMDL"===o)++d,D=c.defaultPdbId,H=this.getStructureId(D,d,n),m||(A=[],x=[],k=[],O=[],R=[],E=[]),L=!1;else if("JRNL "===o)"PMID"===r.substr(12,4)&&(c.pmid=r.substr(19).trim());else if("ATOM "===o||"HETATM"===o){H=this.getStructureId(D,d,n);let e=r.substr(16,1);++a,P[parseInt(r.substr(6,5))]=a;let t=r.substr(76,2).trim();""===t&&(t=r.substr(12,2).trim());let l=r.substr(12,4).trim(),u=r.substr(17,3),F=r.substr(20,2).trim();""===F&&(F="A");let L=r.substr(22,5).trim(),N=L;if(s&&"DUM"===u&&(t=l,F="MEM",N=1,L=1),i&&"DUM"===u)break;b=H+"_"+F,y=b+"_"+L,C=b+"_"+N;let U=parseFloat(r.substr(30,8)),q=parseFloat(r.substr(38,8)),$=parseFloat(r.substr(46,8)),j=new THREE.Vector3(U,q,$),B={het:"H"===o[0],serial:a,name:l,alt:e,resn:u,structure:H,chain:F,resi:N,coord:j,b:parseFloat(r.substr(60,8)),elem:t,bonds:[],ss:"coil",ssbegin:!1,ssend:!1};if(B.het||"C"!==B.name||(v=a),B.het||"O"!==B.name||(_=a),!B.het&&"N"===B.name&&void 0!==w&&void 0!==S){let e=c.atoms[w].coord.distanceTo(c.atoms[S].coord),t=B.coord.x+(c.atoms[w].coord.x-c.atoms[S].coord.x)/e,s=B.coord.y+(c.atoms[w].coord.y-c.atoms[S].coord.y)/e,i=B.coord.z+(c.atoms[w].coord.z-c.atoms[S].coord.z)/e;B.hcoord=new THREE.Vector3(t,s,i)}c.atoms[a]=B,c.dAtoms[a]=1,c.hAtoms[a]=1,p[a]=1,this.isSecondary(C,A,m)?(c.atoms[a].ss="sheet",this.isSecondary(C,x,m)&&(c.atoms[a].ssbegin=!0),this.isSecondary(C,k,m)&&(c.atoms[a].ssend=!0)):this.isSecondary(C,O,m)&&(c.atoms[a].ss="helix",this.isSecondary(C,R,m)&&(c.atoms[a].ssbegin=!0),this.isSecondary(C,E,m)&&(c.atoms[a].ssend=!0));let z="-";if(z="helix"===c.atoms[a].ss?"H":"sheet"===c.atoms[a].ss?"E":!c.atoms[a].het&&h.parasCls.residueColors.hasOwnProperty(c.atoms[a].resn.toUpperCase())?"c":"o",c.secondaries[C]=z,y!==M){let e=h.utilsCls.residueName2Abbr(u);if(c.residueId2Name[C]=e,1!==a&&""!==T&&(c.residues[T]=f),C!==T&&(f={}),b!==I){w=void 0,S=void 0,1!==a&&""!==I&&(void 0===c.chains[I]&&(c.chains[I]={}),c.chains[I]=h.hashUtilsCls.unionHash(c.chains[I],g)),g={},void 0===c.structures[H.toString()]&&(c.structures[H.toString()]=[]),c.structures[H.toString()].includes(b)||c.structures[H.toString()].push(b),void 0===c.chainsSeq[b]&&(c.chainsSeq[b]=[]);let t={};t.resi=N,t.name=e,c.chainsSeq[b].push(t)}else{w=v,S=_;let t={};t.resi=N,t.name=e,c.chainsSeq[b].push(t)}}g[a]=1,f[a]=1,I=b,T=C,M=y}else if("CONECT"===o){let e=parseInt(r.substr(6,5));for(let t=0;t<4;++t){let s=parseInt(r.substr([11,16,21,26][t],5));isNaN(s)||void 0!==c.atoms[P[e]]&&c.atoms[P[e]].bonds.push(P[s])}}else"TER"===o.substr(0,3)&&++a;else D=r.substr(62).trim(),""==D&&(D=l?c.defaultPdbId:c.inputid&&-1==c.inputid.indexOf("/")?c.inputid.substr(0,10):c.defaultPdbId),H=this.getStructureId(D,d,n),c.molTitle="",L=!0}c.residues[C]=f,void 0===c.chains[b]&&(c.chains[b]={}),c.chains[b]=h.hashUtilsCls.unionHash2Atoms(c.chains[b],g,c.atoms),n||this.adjustSeq(c.chainMissingResidueArray);let N=Object.keys(c.structures);for(let e=0,t=N.length;e=l?n:l,o=new Array(s+i),a=0,d=0,c=0,h=!1;for(;ar&&i>r&&(h=!0),s<=r&&i>r?s>i||h?(o[c]=t[d],d++):(o[c]=e[a],a++):s>r&&i<=r?s<=i||h?(o[c]=e[a],a++):(o[c]=t[d],d++):s<=i?(o[c]=e[a],a++):(o[c]=t[d],d++),c++}if(a4||Math.abs(l.y-r.y)>4||Math.abs(l.z-r.z)>4||(l.x-r.x)*(l.x-r.x)+(l.y-r.y)*(l.y-r.y)+(l.z-r.z)*(l.z-r.z)<16&&(void 0===e.ssbondpnts[s]&&(e.ssbondpnts[s]=[]),e.ssbondpnts[s].push(o),e.ssbondpnts[s].push(a)))}}}getChainCalpha(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r={};for(let o in e){if(void 0!==i){if(o.split("_")[0]!==i)continue}let a=Object.keys(e[o]),d=[],c=0,h=0;for(let e=0,i=a.length;e3?i.resn.trim().substr(0,3):i.resn.trim();if(!l.parasCls.chargeColors.hasOwnProperty(e))continue;s?i.resi_ori:i.resi,d.push(i.coord.clone()),++c,h=i.resi}}if(c>0){r[t[a[0]].chain]=d}}return{chainresiCalphaHash:r,center:n.center.clone()}}isSecondary(e,t,s){if(this.icn3d.icn3dui,s){let s=e.substr(e.indexOf("_")+1),i=!1;for(let e=0,n=t.length;e0&&(d=!0);for(let n=0,l=t.length;na&&(a=l),s.push(l)}o.push(s)}if(!d)return void(n.bRender&&alert("These structures can not be aligned..."));a<1e-6&&(a=1);for(let e=0,s=t.length;ep[e]=4&&(n.rmsd_suprTmp=l.rmsdSuprCls.getRmsdSuprCls(c,a,p),void 0!==n.rmsd_suprTmp.rot))){let e=n.rmsd_suprTmp.rot;if(null===e[0])continue;let i=n.rmsd_suprTmp.trans1,r=n.rmsd_suprTmp.trans2,a=n.rmsd_suprTmp.rmsd;if(aRealignment RMSD: "+a.toPrecision(4)+" Å

    "),l.cfg.bSidebyside||l.htmlCls.dialogCls.openDlg("dl_rmsd","Realignment RMSD"),n.q_rotation=[],n.q_trans_sub=[],n.t_trans_add=[],n.q_rotation.push({x1:e[0],y1:e[1],z1:e[2],x2:e[3],y2:e[4],z2:e[5],x3:e[6],y3:e[7],z3:e[8]}),n.q_trans_sub.push(i),n.t_trans_add.push({x:-r.x,y:-r.y,z:-r.z}),l.cfg.aligntool="vast";//!= 'tmalign'; let c=0,h="query",p=o.substr(0,o.indexOf("_")),m=!0;n.chainalignParserCls.transformStructure(p,c,h,m);let u="";for(let e=0,i=s.length;e8)return s;let g=[];g[0]=n[0]*r[0]+n[1]*r[1]+n[2]*r[2],g[1]=n[3]*r[0]+n[4]*r[1]+n[5]*r[2],g[2]=n[6]*r[0]+n[7]*r[1]+n[8]*r[2],g[0]-=n[0]*a[0]+n[1]*a[1]+n[2]*a[2],g[1]-=n[3]*a[0]+n[4]*a[1]+n[5]*a[2],g[2]-=n[6]*a[0]+n[7]*a[1]+n[8]*a[2];let f=0;return f=c[0]*g[0],f+=c[1]*g[1],f+=c[2]*g[2],f/=p*m,f<.866?s:(g[0]=l[0]*r[0]+l[1]*r[1]+l[2]*r[2],g[1]=l[3]*r[0]+l[4]*r[1]+l[5]*r[2],g[2]=l[6]*r[0]+l[7]*r[1]+l[8]*r[2],g[0]-=l[0]*a[0]+l[1]*a[1]+l[2]*a[2],g[1]-=l[3]*a[0]+l[4]*a[1]+l[5]*a[2],g[2]-=l[6]*a[0]+l[7]*a[1]+l[8]*a[2],f=c[0]*g[0],f+=c[1]*g[1],f+=c[2]*g[2],f/=p*m,f<.866?s:(u=0,u+=Math.pow(e.q_rotation.x1-t.q_rotation.x1,2),u+=Math.pow(e.q_rotation.y1-t.q_rotation.y1,2),u+=Math.pow(e.q_rotation.z1-t.q_rotation.z1,2),u+=Math.pow(e.q_rotation.x2-t.q_rotation.x2,2),u+=Math.pow(e.q_rotation.y2-t.q_rotation.y2,2),u+=Math.pow(e.q_rotation.z2-t.q_rotation.z2,2),u+=Math.pow(e.q_rotation.x3-t.q_rotation.x3,2),u+=Math.pow(e.q_rotation.y3-t.q_rotation.y3,2),u+=Math.pow(e.q_rotation.z3-t.q_rotation.z3,2),Math.sqrt(u)))}GetRotMatrix(e,t,s){this.icn3d.icn3dui;let i=[];return i&&(i[0]=e.q_rotation.x1/t,i[1]=e.q_rotation.y1/t,i[2]=e.q_rotation.z1/t,i[3]=e.q_rotation.x2/t,i[4]=e.q_rotation.y2/t,i[5]=e.q_rotation.z2/t,i[6]=e.q_rotation.x3/t,i[7]=e.q_rotation.y3/t,i[8]=e.q_rotation.z3/t,2!=s?(i[9]=e.t_trans_add.x/t,i[10]=e.t_trans_add.y/t,i[11]=e.t_trans_add.z/t,i[12]=-e.q_trans_sub.x/t,i[13]=-e.q_trans_sub.y/t,i[14]=-e.q_trans_sub.z/t):(i[9]=-e.q_trans_add.x/t,i[10]=-e.q_trans_add.y/t,i[11]=-e.q_trans_add.z/t,i[12]=0,i[13]=0,i[14]=0)),i}cbu_dist(e,t,s){return er&&(s.push(e[n].leaves),i.push(e[n].dist));return{clusters:s,scores:i}}}class ls{constructor(e){this.icn3d=e}async applyCommand(e){let t=this.icn3d,s=t.icn3dui;t.bAddCommands=!1;let i=e.split("|||")[0].split("%7C%7C%7C")[0].replace(/\s+/g," ").trim(),n=i.toLowerCase();if("share link"==n)await t.shareLinkCls.shareLink();else if("export state file"==n);else if(0==n.indexOf("export canvas"))setTimeout((async function(){let e=n.substr(13).trim();t.scaleFactor=""===e?1:parseInt(e);let s=""!==e;await t.shareLinkCls.shareLink(!0,s)}),500);else if("export interactions"==n)t.viewInterPairsCls.exportInteractions();else if("export stl file"==n)setTimeout((function(){t.export3DCls.exportStlFile("")}),500);else if("export vrml file"==n)setTimeout((function(){t.export3DCls.exportVrmlFile("")}),500);else if("export stl stabilizer file"==n)setTimeout((function(){t.threeDPrintCls.hideStabilizer(),t.threeDPrintCls.resetAfter3Dprint(),t.threeDPrintCls.addStabilizer(),t.export3DCls.exportStlFile("_stab")}),500);else if("export vrml stabilizer file"==n)setTimeout((function(){t.threeDPrintCls.hideStabilizer(),t.threeDPrintCls.resetAfter3Dprint(),t.threeDPrintCls.addStabilizer(),t.export3DCls.exportVrmlFile("_stab")}),500);else if("export pdb"==n)s.htmlCls.setHtmlCls.exportPdb();else if("export pdb missing atoms"==n)await t.scapCls.exportPdbProfix(!1);else if("export pdb hydrogen"==n)await t.scapCls.exportPdbProfix(!0);else if("export secondary structure"==n)s.htmlCls.setHtmlCls.exportSecondary();else if("select all"==n)t.selectionCls.selectAll();else if("show all"==n)t.selectionCls.showAll();else if("select complement"==n)t.resid2specCls.selectComplement();else if("set pk atom"==n)t.pk=1,t.opts.pk="atom";else if("set pk off"==n)t.pk=0,t.opts.pk="no",t.drawCls.draw(),t.hlObjectsCls.removeHlObjects();else if("set pk residue"==n)t.pk=2,t.opts.pk="residue";else if("set pk strand"==n)t.pk=3,t.opts.pk="strand";else if("set pk domain"==n)t.pk=4,t.opts.pk="domain";else if("set pk chain"==n)t.pk=5,t.opts.pk="chain";else if("set surface wireframe on"==n)t.opts.wireframe="yes",t.applyMapCls.applySurfaceOptions();else if("set surface wireframe off"==n)t.opts.wireframe="no",t.applyMapCls.applySurfaceOptions();else if("set map wireframe on"==n)t.opts.mapwireframe="yes",t.applyMapCls.applyMapOptions();else if("set map wireframe off"==n)t.opts.mapwireframe="no",t.applyMapCls.applyMapOptions();else if("set emmap wireframe on"==n)t.opts.emmapwireframe="yes",t.applyMapCls.applyEmmapOptions();else if("set emmap wireframe off"==n)t.opts.emmapwireframe="no",t.applyMapCls.applyEmmapOptions();else if("set surface neighbors on"==n)t.bConsiderNeighbors=!0,t.applyMapCls.applySurfaceOptions();else if("set surface neighbors off"==n)t.bConsiderNeighbors=!1,t.applyMapCls.applySurfaceOptions();else if("set axis on"==n)t.opts.axis="yes";else if("set pc1 axis"==n)t.pc1=!0,t.axesCls.setPc1Axes();else if("set axis off"==n)t.opts.axis="no",t.pc1=!1;else if("set fog on"==n)t.opts.fog="yes",t.fogCls.setFog(!0);else if("set fog off"==n)t.opts.fog="no",t.fogCls.setFog(!0);else if("set slab on"==n)t.opts.slab="yes";else if("set slab off"==n)t.opts.slab="no";else if("set assembly on"==n)t.bAssembly=!0;else if("set assembly off"==n)t.bAssembly=!1;else if("set chemicalbinding show"==n)t.setOptionCls.setOption("chemicalbinding","show");else if("set chemicalbinding hide"==n)t.setOptionCls.setOption("chemicalbinding","hide");else if("set hbonds off"==n)t.hBondCls.hideHbonds(),t.drawCls.draw();else if("set salt bridge off"==n)t.saltbridgeCls.hideSaltbridge(),t.drawCls.draw();else if("set contact off"==n)t.contactCls.hideContact(),t.drawCls.draw();else if("set halogen pi off"==n)t.piHalogenCls.hideHalogenPi(),t.drawCls.draw();else if("hydrogens"==n)t.showInterCls.showHydrogens(),t.drawCls.draw();else if("set hydrogens off"==n)t.showInterCls.hideHydrogens(),t.drawCls.draw();else if("close popup"==n)t.resizeCanvasCls.closeDialogs();else if("set stabilizer off"==n)t.threeDPrintCls.hideStabilizer(),t.drawCls.draw();else if("set disulfide bonds off"==n)t.opts.ssbonds="no",t.drawCls.draw();else if("set cross linkage off"==n)t.opts.clbonds="no",t.drawCls.draw();else if("set lines off"==n)t.labels.distance=[],t.lines.distance=[],t.drawCls.draw();else if("set labels off"==n){for(let e in t.labels)t.labels[e]=[];t.drawCls.draw()}else if("set mode all"==n)t.definedSetsCls.setModeAndDisplay("all");else if("set mode selection"==n)t.definedSetsCls.setModeAndDisplay("selection");else if("set view detailed view"==n)t.annotationCls.setAnnoViewAndDisplay("detailed view");else if("set view overview"==n)t.annotationCls.setAnnoViewAndDisplay("overview");else if("set annotation custom"==n)t.annotationCls.setAnnoTabCustom();else if("set annotation interaction"==n)t.annotationCls.setAnnoTabInteraction();else if("set annotation ptm"==n)await t.annotationCls.setAnnoTabPTM();else if("set annotation cdd"==n)t.annotationCls.setAnnoTabCdd();else if("set annotation site"==n)t.annotationCls.setAnnoTabSite();else if("set annotation ssbond"==n)t.annotationCls.setAnnoTabSsbond();else if("set annotation crosslink"==n)t.annotationCls.setAnnoTabCrosslink();else if("set annotation transmembrane"==n)await t.annotationCls.setAnnoTabTransmem();else if("highlight level up"==n)t.resid2specCls.switchHighlightLevelUp();else if("highlight level down"==n)t.resid2specCls.switchHighlightLevelDown();else if(0==n.indexOf("hide annotation")){let e=n.lastIndexOf(" "),s=n.substr(e+1);"all"==s?t.annotationCls.hideAnnoTabAll():"custom"==s?t.annotationCls.hideAnnoTabCustom():"clinvar"==s?t.annotationCls.hideAnnoTabClinvar():"snp"==s?t.annotationCls.hideAnnoTabSnp():"cdd"==s?t.annotationCls.hideAnnoTabCdd():"3ddomain"==s?t.annotationCls.hideAnnoTab3ddomain():"site"==s?t.annotationCls.hideAnnoTabSite():"ptm"==s?t.annotationCls.hideAnnoTabPTM():"interaction"==s?t.annotationCls.hideAnnoTabInteraction():"ssbond"==s?t.annotationCls.hideAnnoTabSsbond():"crosslink"==s?t.annotationCls.hideAnnoTabCrosslink():"transmembrane"==s&&t.annotationCls.hideAnnoTabTransmem()}else if("add residue labels"==n)t.residueLabelsCls.addResidueLabels(t.hAtoms),t.drawCls.draw();else if("add residue number labels"==n)t.residueLabelsCls.addResidueLabels(t.hAtoms,void 0,void 0,!0),t.drawCls.draw();else if("add atom labels"==n)t.residueLabelsCls.addAtomLabels(t.hAtoms),t.drawCls.draw();else if("add element labels"==n)t.residueLabelsCls.addAtomLabels(t.hAtoms,!0),t.drawCls.draw();else if("add chain labels"==n)t.analysisCls.addChainLabels(t.hAtoms),t.drawCls.draw();else if("add terminal labels"==n)t.analysisCls.addTerminiLabels(t.hAtoms),t.drawCls.draw();else if("rotate left"==n)t.bStopRotate=!1,t.ROT_DIR="left",t.resizeCanvasCls.rotStruc("left");else if("rotate right"==n)t.bStopRotate=!1,t.ROT_DIR="right",t.resizeCanvasCls.rotStruc("right");else if("rotate up"==n)t.bStopRotate=!1,t.ROT_DIR="up",t.resizeCanvasCls.rotStruc("up");else if("rotate down"==n)t.bStopRotate=!1,t.ROT_DIR="down",t.resizeCanvasCls.rotStruc("down");else if("rotate x"==n){let e=new THREE.Vector3(1,0,0),s=.5*Math.PI;t.transformCls.setRotation(e,s)}else if("rotate y"==n){let e=new THREE.Vector3(0,1,0),s=.5*Math.PI;t.transformCls.setRotation(e,s)}else if("rotate z"==n){let e=new THREE.Vector3(0,0,1),s=.5*Math.PI;t.transformCls.setRotation(e,s)}else if("reset"===n)t.selectionCls.resetAll();else if("reset orientation"===n)t.transformCls.resetOrientation(),t.drawCls.draw();else if("reset thickness"==n)t.threeDPrintCls.resetAfter3Dprint(),t.drawCls.draw();else if("clear selection"==n)t.hlObjectsCls.removeHlObjects(),t.hlUpdateCls.removeHl2D(),t.bShowHighlight=!1,t.bSelectResidue=!1;else if("zoom selection"==n)t.transformCls.zoominSelection(),t.drawCls.draw();else if("center selection"==n)t.applyCenterCls.centerSelection(),t.drawCls.draw();else if("show selection"==n)t.selectionCls.showSelection();else if("hide selection"==n)t.selectionCls.hideSelection();else if("output selection"==n)t.threeDPrintCls.outputSelection();else if("toggle selection"==n)t.selectionCls.toggleSelection();else if("toggle highlight"==n)t.hlUpdateCls.toggleHighlight();else if("stabilizer"==n)t.threeDPrintCls.addStabilizer(),t.threeDPrintCls.prepareFor3Dprint();else if("disulfide bonds"==n)t.showInterCls.showSsbonds();else if("cross linkage"==n)t.showInterCls.showClbonds();else if("back"==n)await t.resizeCanvasCls.back();else if("forward"==n)await t.resizeCanvasCls.forward();else if("clear all"==n)t.selectionCls.selectAll();else if("defined sets"==n)t.definedSetsCls.showSets();else if("delete selected sets"==n)t.definedSetsCls.deleteSelectedSets();else if("view interactions"==n)void 0===s.cfg.mmdbid&&void 0===s.cfg.gi||t.ParserUtilsCls.set2DDiagrams(t.inputid);else if("show annotations all chains"==n)t.annotationCls.showAnnoAllChains();else if("save color"==n)t.setOptionCls.saveColor();else if("apply saved color"==n)t.setOptionCls.applySavedColor();else if("save style"==n)t.setOptionCls.saveStyle();else if("apply saved style"==n)t.setOptionCls.applySavedStyle();else if("select main chains"==n)t.selectionCls.selectMainChains();else if("select side chains"==n)t.selectionCls.selectSideChains();else if("select main side chains"==n)t.selectionCls.selectMainSideChains();else if("realign"==n)t.realignParserCls.realign();else if(-1!=n.indexOf("realign predefined ")){let e="realign predefined ",n=i.substr(e.length),l=n.indexOf(" "),r=n.substr(0,l).split(",");s.cfg.resdef=n.substr(l+1).replace(/:/gi,";"),await t.realignParserCls.realignChainOnSeqAlign(void 0,r,!0,!0)}else if("area"==n)t.analysisCls.calculateArea();else if("table inter count only"==n)$(".icn3d-border").hide();else if("table inter details"==n)$(".icn3d-border").show();else if("setoption map nothing"==n)t.setOptionCls.setOption("map","nothing");else if("setoption emmap nothing"==n)t.setOptionCls.setOption("emmap","nothing");else if("setoption phimap nothing"==n)t.setOptionCls.setOption("phimap","nothing");else if("setoption phisurface nothing"==n)t.setOptionCls.setOption("phisurface","nothing");else if("clear symd symmetry"==n)t.symdArray=[];else if("show axis"==n)t.bAxisOnly=!0;else if(0==i.indexOf("define helix sets")){let e=i.split(" | ")[1].split(" ")[1];t.addTrackCls.defineSecondary(e,"helix")}else if(0==i.indexOf("define sheet sets")){let e=i.split(" | ")[1].split(" ")[1];t.addTrackCls.defineSecondary(e,"sheet")}else if(0==i.indexOf("define coil sets")){let e=i.split(" | ")[1].split(" ")[1];t.addTrackCls.defineSecondary(e,"coil")}else if(0==i.indexOf("select interaction")){let e=i.substr(i.lastIndexOf(" ")+1).split(",");if(null!==e){let s=e[0].split("_")[0];t.b2DShown||t.ParserUtilsCls.download2Ddgm(s.toUpperCase()),t.diagram2dCls.selectInteraction(e[0],e[1])}}else if(0==i.indexOf("select saved atoms")||0==i.indexOf("select sets")){i=i.replace(/aligned_protein/g,"protein_aligned");let e=i.split(" | "),s=e[0].replace(/,/g," or "),n=19;0==i.indexOf("select sets")&&(n=12);let l=s.substr(n),r=l;2==e.length&&(r=e[1].substr(5)),t.definedSetsCls.selectCombinedSets(l,r)}else if(-1!==i.indexOf("select chain")){let e=i.substr(i.lastIndexOf(" ")+1).split(",");for(let s=0,i=e.length;s6?e[6].substr(e[6].lastIndexOf(" ")+1):0,d=e.length>7?e[7].substr(e[7].lastIndexOf(" ")+1):1;t.analysisCls.addLine(parseFloat(s[1]),parseFloat(s[3]),parseFloat(s[5]),parseFloat(i[1]),parseFloat(i[3]),parseFloat(i[5]),l,r,o,parseFloat(a),parseFloat(d)),t.drawCls.draw()}else if(0==n.indexOf("add sphere"))this.addShape(n,"sphere");else if(0==n.indexOf("add cube"))this.addShape(n,"cube");else if(0==n.indexOf("clear shape"))t.shapeCmdHash={};else if(0==n.indexOf("clear line between sets"))t.lines.cylinder=[];else if(0==i.indexOf("add label")){let e,n,l,r,o,a,d,c=i.split(" | "),h=c[0].substr("add label".length+1),p=!1;for(let t=1,s=c.length;t=5&&(e=l[4].substr(5)),l.length>=6&&(s=l[5].substr(6)),l.length>=7&&(n=l[6].substr(4)),$("#"+t.pre+"anno_custom")[0].checked=!0,$("[id^="+t.pre+"custom]").show(),"0"==s&&(s=void 0),t.addTrackCls.checkGiSeq(r,o,a,e,s,n,0)}else if(0==n.indexOf("remove one stabilizer")){let e=n.split(" | ")[1].split(" "),s=[];s.push(parseInt(e[0])),s.push(parseInt(e[1])),t.threeDPrintCls.removeOneStabilizer(s),t.drawCls.draw()}else if(0==n.indexOf("add one stabilizer")){let e=n.split(" | ")[1].split(" ");void 0===t.pairArray&&(t.pairArray=[]),t.pairArray.push(parseInt(e[0])),t.pairArray.push(parseInt(e[1])),t.drawCls.draw()}else if(0==n.indexOf("select planes z-axis")){let e=n.split(" ");if(5==e.length){let s=parseFloat(e[3]),i=parseFloat(e[4]);t.selectionCls.selectBtwPlanes(s,i)}}else if(0==n.indexOf("adjust membrane z-axis")){let e=n.split(" ");if(5==e.length){let s=parseFloat(e[3]),i=parseFloat(e[4]);t.selectionCls.adjustMembrane(s,i)}}else if(0==n.indexOf("toggle membrane"))t.selectionCls.toggleMembrane();else if(0==i.indexOf("calc buried surface")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(" ");if(2==s.length){let e=s[0].split(","),i=s[1].split(",");t.analysisCls.calcBuriedSurface(e,i)}}}else if(0==i.indexOf("dist ")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(" ");if(2==s.length){let e=s[0].split(","),i=s[1].split(",");t.analysisCls.measureDistTwoSets(e,i)}}}else if(0==i.indexOf("disttable")){let e=i.split(" | ");if(2==e.length){let i=e[1].split(" ");if(2==i.length){let e=i[0].split(","),n=i[1].split(",");t.analysisCls.measureDistManySets(e,n),s.htmlCls.dialogCls.openDlg("dl_disttable","Distance among the sets")}}}else if(0==i.indexOf("display interaction 3d")||0==i.indexOf("view interaction pairs")||0==i.indexOf("save1 interaction pairs")||0==i.indexOf("save2 interaction pairs")||0==i.indexOf("line graph interaction pairs")||0==i.indexOf("scatterplot interaction pairs")){let e=i.split(" | ");if(e.length>=3){let s=e[1].split(" ");if(2==s.length){let n,l,r=s[0].split(","),o=s[1].split(","),a=-1!==e[2].indexOf("hbonds"),d=-1!==e[2].indexOf("salt bridge"),c=-1!==e[2].indexOf("interactions"),h=-1!==e[2].indexOf("halogen"),p=-1!==e[2].indexOf("pi-cation"),m=-1!==e[2].indexOf("pi-stacking");if(e.length>=4&&(n="true"==e[3]),e.length>=5){let s=e[4].split(" ");s.length>=4&&($("#"+t.pre+"hbondthreshold").val(s[1]),$("#"+t.pre+"saltbridgethreshold").val(s[2]),$("#"+t.pre+"contactthreshold").val(s[3]),7==s.length&&($("#"+t.pre+"halogenthreshold").val(s[4]),$("#"+t.pre+"picationthreshold").val(s[5]),$("#"+t.pre+"pistackingthreshold").val(s[6])))}0==i.indexOf("display interaction 3d")?l="3d":0==i.indexOf("view interaction pairs")?l="view":0==i.indexOf("save1 interaction pairs")?l="save1":0==i.indexOf("save2 interaction pairs")?l="save2":0==i.indexOf("line graph interaction pairs")?l="linegraph":0==i.indexOf("scatterplot interaction pairs")&&(l="scatterplot"),await t.viewInterPairsCls.viewInteractionPairs(r,o,n,l,a,d,c,h,p,m)}}}else if(0==i.indexOf("export pairs")){let e=i.split(" | ");if(3==e.length){let s=e[1].split(" ");if(2==s.length){let i=s[0].split(","),n=s[1].split(","),l=e[2].split(" ")[1];t.showInterCls.pickCustomSphere(l,i,n,t.bSphereCalc),t.bSphereCalc=!0;let r=t.viewInterPairsCls.exportSpherePairs(),o=t.inputid?t.inputid:"custom";t.saveFileCls.saveFile(o+"_sphere_pairs.html","html",r)}}}else if(0==n.indexOf("graph label")){let e=n.lastIndexOf(" "),t=n.substr(e+1);$("#"+s.svgid+"_label").val(t),$("#"+s.svgid+" text").removeClass(),$("#"+s.svgid+" text").addClass(t)}else if(0==n.indexOf("cartoon label")){let e=n.lastIndexOf(" "),t=n.substr(e+1);$("#"+s.svgid_ct+"_label").val(t),$("#"+s.svgid_ct+" text").removeClass(),$("#"+s.svgid_ct+" text").addClass(t)}else if(0==n.indexOf("line graph scale")){let e=n.lastIndexOf(" "),i=n.substr(e+1);$("#"+s.linegraphid+"_scale").val(i),$("#"+s.linegraphid).attr("width",(t.linegraphWidth*parseFloat(i)).toString()+"px")}else if(0==n.indexOf("scatterplot scale")){let e=n.lastIndexOf(" "),i=n.substr(e+1);$("#"+s.scatterplotid+"_scale").val(i),$("#"+s.scatterplotid).attr("width",(t.scatterplotWidth*parseFloat(i)).toString()+"px")}else if(0==n.indexOf("contactmap scale")){let e=n.lastIndexOf(" "),i=n.substr(e+1);$("#"+s.contactmapid+"_scale").val(i),$("#"+s.contactmapid).attr("width",(t.contactmapWidth*parseFloat(i)).toString()+"px")}else if(0==n.indexOf("alignerrormap scale")){let e=n.lastIndexOf(" "),i=n.substr(e+1);$("#"+s.alignerrormapid+"_scale").val(i),$("#"+s.alignerrormapid).attr("width",(t.alignerrormapWidth*parseFloat(i)).toString()+"px")}else if(0==n.indexOf("graph force")){let e=n.lastIndexOf(" ");s.htmlCls.force=parseInt(n.substr(e+1)),$("#"+s.svgid+"_force").val(s.htmlCls.force),t.getGraphCls.handleForce()}else if(0==n.indexOf("hide edges")){let e=n.lastIndexOf(" ");s.htmlCls.hideedges=parseInt(n.substr(e+1)),$("#"+s.svgid+"_hideedges").val(s.htmlCls.hideedges),s.htmlCls.hideedges?(s.htmlCls.contactInsideColor="FFF",s.htmlCls.hbondInsideColor="FFF",s.htmlCls.ionicInsideColor="FFF"):(s.htmlCls.contactInsideColor="DDD",s.htmlCls.hbondInsideColor="AFA",s.htmlCls.ionicInsideColor="8FF"),void 0!==t.graphStr&&t.bRender&&s.htmlCls.force&&t.drawGraphCls.drawGraph(t.graphStr,t.pre+"dl_graph")}else if(0==n.indexOf("reset interaction pairs"))t.viewInterPairsCls.resetInteractionPairs();else if(0==n.indexOf("side by side")){let e=n.split(" | ")[1],t="_blank";window.open(e,t)}else if(0==i.indexOf("your note")){let e=i.split(" | ");t.yournote=e[1],$("#"+t.pre+"yournote").val(t.yournote),s.cfg.shownote&&(document.title=t.yournote)}else if(0==n.indexOf("cross structure interaction"))t.crossstrucinter=parseInt(n.substr(n.lastIndexOf(" ")+1)),$("#"+t.pre+"crossstrucinter").val(t.crossstrucinter);else if("replay on"==n)await t.resizeCanvasCls.replayon();else if("replay off"==n)await t.resizeCanvasCls.replayoff();else if(0==n.indexOf("contact map")){let e=n.split(" | ");if(3===e.length){let s=parseFloat(e[1].split(" ")[1]),i=e[2].split(" ")[1];await t.contactMapCls.contactMap(s,i)}}else if(0==n.indexOf("pickatom")){let e=parseInt(n.substr(n.lastIndexOf(" ")+1));t.pAtom=t.atoms[e],t.pickingCls.showPicking(t.pAtom)}else if(0==i.indexOf("set color spectrum")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(","),i=!0;t.setColorCls.setColorAcrossSets(s,i)}}else if(0==i.indexOf("set residues color spectrum")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(","),i=!0;t.setColorCls.setColorBySets(s,i)}}else if(0==i.indexOf("set color rainbow")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(","),i=!1;t.setColorCls.setColorAcrossSets(s,i)}}else if(0==i.indexOf("set residues color rainbow")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(","),i=!1;t.setColorCls.setColorBySets(s,i)}}else if(0==i.indexOf("color")){let e=i.split(" | "),n=e[0].substr(e[0].indexOf(" ")+1);if(t.opts.color=n,"residue custom"==n&&2==e.length){t.customResidueColors=JSON.parse(e[1]);for(let e in t.customResidueColors)t.customResidueColors[e.toUpperCase()]=s.parasCls.thr("#"+t.customResidueColors[e])}else if("align custom"==n&&3==e.length){let s=e[1],i=e[2].split(", ");t.queryresi2score={},t.queryresi2score[s]={};for(let e=0,n=i.length;e=4?this.setQueryresi2score(e):"area"==n&&2==e.length&&(t.midpercent=e[1],$("#"+t.pre+"midpercent").val(t.midpercent));t.setColorCls.setColorByOptions(t.opts,t.hAtoms),t.hlUpdateCls.updateHlAll(),t.getGraphCls.updateGraphColor()}else if(0==i.indexOf("remove legend"))$("#"+s.pre+"legend").hide();else if(0==i.indexOf("custom tube")){let e=i.split(" | ");this.setQueryresi2score(e),t.setOptionCls.setStyle("proteins","custom tube")}else if(0==n.indexOf("style")){let e=n.substr(n.indexOf(" ")+1),s=e.substr(0,e.indexOf(" ")),i=e.substr(e.indexOf(" ")+1);t.setOptionCls.setStyle(s,i)}else if(0==n.indexOf("window")){let e=n.substr(n.indexOf(" ")+1);setTimeout((function(){"aligned sequences"==e?s.htmlCls.dialogCls.openDlg("dl_alignment","Select residues in aligned sequences"):"interaction table"==e?s.htmlCls.dialogCls.openDlg("dl_allinteraction","Show interactions"):"interaction graph"==e?s.htmlCls.dialogCls.openDlg("dl_linegraph","Show interactions between two lines of residue nodes"):"interaction scatterplot"==e?s.htmlCls.dialogCls.openDlg("dl_scatterplot","Show interactions as scatterplot"):"force-directed graph"==e&&s.htmlCls.dialogCls.openDlg("dl_graph","Force-directed graph")}),1e3)}else if(0==n.indexOf("set theme")){let e=n.substr(n.lastIndexOf(" ")+1);s.htmlCls.setMenuCls.setTheme(e)}else if(0==n.indexOf("set double color")){let e=n.substr(n.lastIndexOf(" ")+1);"on"==e?(t.bDoublecolor=!0,t.setOptionCls.setStyle("proteins","ribbon")):"off"==e&&(t.bDoublecolor=!1)}else if(0==n.indexOf("adjust dialog")){let e=n.substr(n.lastIndexOf(" ")+1);t.scapCls.adjust2DWidth(e)}else if(0==n.indexOf("glycans cartoon")){let e=n.substr(n.lastIndexOf(" ")+1);t.bGlycansCartoon="yes"==e}else if(0==n.indexOf("save html")){let e=n.substr(n.lastIndexOf(" ")+1);s.htmlCls.eventsCls.saveHtml(e)}else if(0==n.indexOf("resdef"))s.cfg.resdef=n.substr(n.indexOf(" ")+1);else if(0==n.indexOf("vast_search_chainid")){t.chainidArray=i.substr(i.indexOf(" ")+1).split(",");let e=!0,s=!0;await t.realignParserCls.realignChainOnSeqAlign(void 0,t.chainidArray,e,s)}else if(0==n.indexOf("ig refnum off"))await t.refnumCls.hideIgRefNum();else if(0==n.indexOf("custom refnum")){let e=i.split(" | ")[1].replace(/\\n/g,"\n");await t.refnumCls.parseCustomRefFile(e)}else if(-1!==n.indexOf("select displayed set"))t.hAtoms=s.hashUtilsCls.cloneHash(t.viewSelectionAtoms),t.hlUpdateCls.updateHlAll();else if(-1!==n.indexOf("select prop")){let e,s,n=i.split(" | "),l=n[0].substr("select prop".length+1);if(2==n.length){let t=n[1].split("_");e=t[0],s=t[1]}t.resid2specCls.selectProperty(l,e,s)}else if(-1!==n.indexOf("select each residue"))t.selectionCls.saveEachResiInSel();else if(0==n.indexOf("select")&&-1!==n.indexOf("name")){let e=i.split(" | "),s="",n="",l="";for(let t=0,i=e.length;t1&&(n=e[1].substr(e[1].indexOf(" ")+1)),e.length>2&&(l=e[2].substr(e[2].indexOf(" ")+1)),-1!==s.indexOf(" or ")?await t.selByCommCls.selectByCommand(s,n,l):await t.selByCommCls.selectBySpec(s,n,l)}s.htmlCls.clickMenuCls.setLogCmd(i,!1),t.bAddCommands=!0}setStrengthPara(e){let t=this.icn3d;if(t.icn3dui,e.length>=5){let s=e[4].split(" ");s.length>=4&&($("#"+t.pre+"hbondthreshold").val(s[1]),$("#"+t.pre+"saltbridgethreshold").val(s[2]),$("#"+t.pre+"contactthreshold").val(s[3]),s.length>=7&&($("#"+t.pre+"halogenthreshold").val(s[4]),$("#"+t.pre+"picationthreshold").val(s[5]),$("#"+t.pre+"pistackingthreshold").val(s[6])))}if(6==e.length){let s=e[5].split(" ");s.length>=6&&($("#"+t.pre+"dist_ss").val(s[0]),$("#"+t.pre+"dist_coil").val(s[1]),$("#"+t.pre+"dist_hbond").val(s[2]),$("#"+t.pre+"dist_inter").val(s[3]),$("#"+t.pre+"dist_ssbond").val(s[4]),$("#"+t.pre+"dist_ionic").val(s[5]),9==s.length&&($("#"+t.pre+"dist_halogen").val(s[6]),$("#"+t.pre+"dist_pication").val(s[7]),$("#"+t.pre+"dist_pistacking").val(s[8])))}}getThresholdNameArrays(e){this.icn3d.icn3dui.htmlCls.clickMenuCls.SetChainsAdvancedMenu();let t,s=e.split(" | "),i=parseFloat(s[0].substr(s[0].lastIndexOf(" ")+1)),n=[],l=[];if(s.length>=2&&s[1].length>4){let e=s[1].split(" ");e.length>1&&(l=e[1].split(",")),e.length>2&&(n=e[2].split(","))}else l=["selected"],n=["non-selected"];return 3==s.length&&(t="true"==s[2]),{threshold:i,nameArray2:l,nameArray:n,bHbondCalc:t}}setQueryresi2score(e){let t=this.icn3d,s=t.icn3dui,i=e[1],n=e[2].split(" ")[1].split("_"),l=e[3];void 0===t.queryresi2score&&(t.queryresi2score={}),t.queryresi2score[i]={};for(let e=parseInt(n[0]),s=0;e<=parseInt(n[1]);++e,++s)"_"!=l[s]&&(t.queryresi2score[i][e]=11.11111111111111*parseInt(l[s]));if(e.length>4){let i=e[4].split(" ");t.startColor=i[1],t.midColor=i[2],t.endColor=i[3];let n=s.htmlCls.clickMenuCls.setLegendHtml();$("#"+s.pre+"dl_legend").html(n),s.htmlCls.dialogCls.openDlg("dl_legend","Color Range")}}addShape(e,t){let s=this.icn3d,i=s.icn3dui;s.shapeCmdHash[e]=1;let n=e.split(" | "),l=n[1].split(" "),r=n[2].substr(n[2].lastIndexOf(" ")+1),o=n[3].substr(n[3].lastIndexOf(" ")+1),a=n[4].substr(n[4].lastIndexOf(" ")+1);r="#"+r.replace(/\#/g,"");let d=i.parasCls.thr(r),c=new THREE.Vector3(parseFloat(l[1]),parseFloat(l[3]),parseFloat(l[5]));"sphere"==t?s.sphereCls.createSphereBase(c,d,parseFloat(a),void 0,void 0,void 0,parseFloat(o)):s.boxCls.createBox_base(c,parseFloat(a),d,void 0,void 0,void 0,parseFloat(o))}getMenuFromCmd(e){this.icn3d.icn3dui;let t="Windows > View Sequences & Annotations",s="Analysis > H-Bonds & Interactions",i=s+" > 2D Graph(Force-Directed)",n="View > Rotate > Auto Rotation > Rotate ",l="View > Rotate > Rotate 90 deg > ",r="Select > Select on 3D > ",o="Analysis > Label > ",a="File > 3D Printing > ";return 0==(e=e.trim()).indexOf("load")?"File > Retrieve by ID, Align":0==e.indexOf("set map")&&-1==e.indexOf("set map wireframe")?"Style > Electron Density":0==e.indexOf("set emmap")&&-1==e.indexOf("set emmap wireframe")?"Style > EM Density Map":0==e.indexOf("set phi")?"Analysis > Load Potential > URL(CORS) Phi/Cube":0==e.indexOf("set delphi")?"Analysis > DelPhi Potential":0==e.indexOf("setoption map")?"Style > Remove Map":0==e.indexOf("setoption emmap")?"Style > Remove EM Map":0==e.indexOf("view annotations")?t:0==e.indexOf("set annotation all")?t+': "All" checkbox':0==e.indexOf("set annotation clinvar")?t+': "ClinVar" checkbox':0==e.indexOf("set annotation snp")?t+': "SNP" checkbox':0==e.indexOf("set annotation 3ddomain")?t+': "3D Domains" checkbox':0==e.indexOf("view interactions")?"Windows > View 2D Diagram":0==e.indexOf("symmetry")?"Analysis > Symmetry":0==e.indexOf("realign on seq align")?"File > Realign Selection > on Sequence Alignment":0==e.indexOf("realign")?"File > Realign Selection > Residue by Residue":0==e.indexOf("graph interaction pairs")?s+" > 2D Graph(Force-Directed)":0==e.indexOf("export canvas")?"File > Save File > iCn3D PNG Image":"export stl file"==e?a+"STL":"export vrml file"==e?a+"VRML(Color)":"export stl stabilizer file"==e?a+"STL W/ Stabilizers":"export vrml stabilizer file"==e?a+"VRML(Color, W/ Stabilizers)":"select all"==e?'Select > All; or Toggle to "All"(next to "Help")':"show all"==e?"View > View Full Structure":"select complement"==e?"Select > Inverse":"set pk atom"==e?r+"Atom":"set pk residue"==e?r+"Residue":"set pk strand"==e?r+"Strand/Helix":"set pk domain"==e?r+"3D Domain":"set pk chain"==e?r+"Chain":"set surface wireframe on"==e?"Style > Surface Wireframe > Yes":"set surface wireframe off"==e?"Style > Surface Wireframe > No":"set map wireframe on"==e?"Style > Map Wireframe > Yes":"set map wireframe off"==e?"Style > Map Wireframe > No":"set emmap wireframe on"==e?"Style > EM Map Wireframe > Yes":"set emmap wireframe off"==e?"Style > EM Map Wireframe > No":"set surface neighbors on"==e?"Style > Surface Type > ... with Context":"set axis on"==e?"View > XYZ-axes > Show":"set axis off"==e?"View > XYZ-axes > Hide":"set fog on"==e?"View > Fog for Selection > On":"set fog off"==e?"View > Fog for Selection > Off":"set slab on"==e?"View > Slab for Selection > On":"set slab off"==e?"View > Slab for Selection > Off":"set assembly on"==e?"Analysis > Assembly > Biological Assembly":"set assembly off"==e?"Analysis > Assembly > Asymmetric Unit":"set chemicalbinding show"==e?"Analysis > Chem. Binding > Show":"set chemicalbinding hide"==e?"Analysis > Chem. Binding > Hide":"set hbonds off"==e||"set salt bridge off"==e||"set contact off"==e||"set halogen pi off"==e?s+" > Reset":"hydrogens"==e?"Style > Hydrogens > Show":"set hydrogens off"==e?"Style > Hydrogens > Hide":"set stabilizer off"==e?"File > 3D Printing > Remove All Stabilizers":"set disulfide bonds off"==e?"Analysis > Disulfide Bonds > Hide":"set cross linkage off"==e?"Analysis > Cross-Linkages > Hide":"set lines off"==e?"Analysis > Distance > Hide":"set labels off"==e?"Analysis > Label > Remove":"set mode all"==e?'Toggle to "All"(next to "Help")':"set mode selection"==e?'Toggle to "Selection"(next to "Help")':"set view detailed view"==e?t+': "Details" tab':"set view overview"==e?t+': "Summary" tab':"set annotation custom"==e?t+': "Custom" checkbox':"set annotation interaction"==e?t+': "Interactions" checkbox':"set annotation ptm"==e?t+': "PTM" checkbox':"set annotation cdd"==e?t+': "Conserved Domains" checkbox':"set annotation site"==e?t+': "Functional Sites" checkbox':"set annotation ssbond"==e?t+': "Disulfide Bonds" checkbox':"set annotation crosslink"==e?t+': "Cross-Linkages" checkbox':"set annotation transmembrane"==e?t+': "Transmembrane" checkbox':"highlight level up"==e?"Keyboard Arrow Up":"highlight level down"==e?"Keyboard Arrow Down":0==e.indexOf("hide annotation")?t+": checkboxes off":"add residue labels"==e?o+"per Residue":"add residue number labels"==e?o+"per Residue & Number":"add atom labels"==e?o+"per Atom":"add chain labels"==e?o+"per Chain":"add terminal labels"==e?o+"N- & C- Termini":"rotate left"==e?n+"Left; or Key l":"rotate right"==e?n+"Right; or Key j":"rotate up"==e?n+"Up; or Key i":"rotate down"==e?n+"Down; or Key m":"rotate x"==e?l+"X-axis":"rotate y"==e?l+"Y-axis":"rotate z"==e?l+"Z-axis":"reset"==e?"View > Reset > All":"reset orientation"==e?"View > Reset > Orientation":"clear selection"==e?"Select > Clear Selection":"zoom selection"==e?"Select > Zoom in Selection":"center selection"==e?"Select > Center Selection":"show selection"==e?"Select > View Only Selection":"hide selection"==e?"Select > Hide Selection":"output selection"==e?"Select > Clear Selection":"toggle highlight"==e?"Select > Toggle Highlight":"stabilizer"==e?"File > 3D Printing > Add all Stabilizers":"disulfide bonds"==e?"Analysis > Disulfide Bonds > Show":"cross linkage"==e?"Analysis > Cross-Linkages > Show":"back"==e?"View > Undo":"forward"==e?"View > Redo":"clear all"==e?"Select > Clear Selection":"defined sets"==e?"Windows > Defined Sets":"delete selected sets"==e?'Windows > Defined Sets: "Delete Selected Sets" button':"view interactions"==e?"Windows > View Interactions":"show annotations all chains"==e?t+': "Show All Chains" button':"save color"==e?"Color > Save Color":"apply saved color"==e?"Color > Apply Saved Color":"save style"==e?"Style > Save Style":"apply saved style"==e?"Style > Apply Saved Style":"select main chains"==e?"Select > Main Chains":"select side chains"==e?"Select > Side Chains":"select main side chains"==e?"Select > Main & Side Chains":"area"==e?"View > Surface Area":"table inter count only"==e?s+': "Set 1" button: "Show Count Only" button':"table inter details"==e?s+': "Set 1" button: "Show Details" button':0==e.indexOf("define helix sets")?t+': "Helix Sets" button':0==e.indexOf("define sheet sets")?t+': "Sheet Sets" button':0==e.indexOf("define coil sets")?t+': "Coil Sets" button':0==e.indexOf("select interaction")?"Windows > View 2D Diagram: click on edges":0==e.indexOf("select saved atoms")||0==e.indexOf("select sets")?"Windows > Defined Sets: select in menu":-1!==e.indexOf("select chain")?t+": click on chain names":-1!==e.indexOf("select alignChain")?"Windows > View Aligned Sequences: click on chain names":0==e.indexOf("select zone cutoff")?"Select > by Distance":0==e.indexOf("set surface opacity")?"Style > Surface Opacity":0==e.indexOf("set label scale")?"View > Label Scale":0==e.indexOf("set surface")?"Style > Surface Type":0==e.indexOf("set camera")?"View > Camera":0==e.indexOf("set background")?"Style > Background":0==e.indexOf("set thickness")?"File > 3D Printing > Set Thickness":0==e.indexOf("set highlight color")?"Select > Highlight Color":0==e.indexOf("set highlight style")?"Select > Highlight Style":0==e.indexOf("add line")||0==e.indexOf("add label")?"Analysis > Distance > between Two Atoms":0==e.indexOf("dist")?"Analysis > Distance > between Two Sets":0==e.indexOf("msa")?t+': "Add Track" button: "FASTA Alignment" button':0==e.indexOf("add track")?t+': "Add Track" button':0==e.indexOf("remove one stabilizer")?"File > 3D Printing > Remove One Stablizer":0==e.indexOf("add one stabilizer")?"File > 3D Printing > Add One Stablizer":0==e.indexOf("select planes z-axis")?"View > Select between Two X-Y Planes":0==e.indexOf("adjust membrane z-axis")?"View > Adjust Membrane":0==e.indexOf("toggle membrane")?"View > Toggle Membrane":0==e.indexOf("calc buried surface")?s+': "Buried Surface Area" button':0==e.indexOf("display interaction 3d")?s+': "3D Display Interactions" button':0==e.indexOf("view interaction pairs")?s+': "Highlight Interactions in Table" button':0==e.indexOf("save1 interaction pairs")?s+': "Set 1" button':0==e.indexOf("save2 interaction pairs")?s+': "Set 2" button':0==e.indexOf("line graph interaction pairs")?s+': "2D Interaction Network" button':0==e.indexOf("scatterplot interaction pairs")?s+': "2D Interaction Map" button':0==e.indexOf("graph label")?i+': "Label Size" menu':0==e.indexOf("graph force")?i+': "Force on Nodes" menu':0==e.indexOf("hide edges")?i+': "Internal Edges" menu':0==e.indexOf("reset interaction pairs")?s+" > Reset":0==e.indexOf("side by side")?"View > Side by Side":0==e.indexOf("your note")?"Windows > Your Notes / Window Title":0==e.indexOf("pickatom")?"Hold Alt key and click on 3D structure":0==e.indexOf("color")?"Color menu":0==e.indexOf("custom tube")?t+': "Custom Color/Tube" button: "Custom Tube" button':0==e.indexOf("style")?"Style menu":-1!==e.indexOf("select displayed set")?"Select > Displayed Set":-1!==e.indexOf("select prop")?"Select > by Property":0==e.indexOf("select")&&-1!==e.indexOf("name")?t+": drag on residues to select":-1!==e.indexOf("select $")||-1!==e.indexOf("select .")||-1!==e.indexOf("select :")||-1!==e.indexOf("select @")?"Select > Advanced; or other selection":-1!==e.indexOf("replay on")?"File > Replay Each Step > On":-1!==e.indexOf("replay off")?"File > Replay Each Step > Off":-1!==e.indexOf("set theme")?"Style > Theme Color":-1!==e.indexOf("set double color")?"Style > Two-color Helix":""}}class rs{constructor(e){this.icn3d=e}setProtNuclLigInMenu(){let e=this.icn3d;if(e.icn3dui,Object.keys(e.proteins).length>0&&(e.defNames2Residues.proteins=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.proteins)),e.defNames2Descr.proteins="proteins",e.defNames2Command.proteins="select :proteins"),Object.keys(e.nucleotides).length>0&&(e.defNames2Residues.nucleotides=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.nucleotides)),e.defNames2Descr.nucleotides="nucleotides",e.defNames2Command.nucleotides="select :nucleotides"),Object.keys(e.chemicals).length>0)if(e.bOpm){let t={},s={};for(let i in e.chemicals){let n=e.atoms[i],l=n.structure+"_"+n.chain+"_"+n.resi;"DUM"===n.resn?s[l]=1:t[l]=1}Object.keys(t).length>0&&(e.defNames2Residues.chemicals=Object.keys(t),e.defNames2Descr.chemicals="chemicals",e.defNames2Command.chemicals="select :chemicals"),Object.keys(s).length>0&&(e.defNames2Residues.membrane=Object.keys(s),e.defNames2Descr.membrane="membrane",e.defNames2Command.membrane="select :membrane")}else e.defNames2Residues.chemicals=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.chemicals)),e.defNames2Descr.chemicals="chemicals",e.defNames2Command.chemicals="select :chemicals";Object.keys(e.ions).length>0&&(e.defNames2Residues.ions=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.ions)),e.defNames2Descr.ions="ions",e.defNames2Command.ions="select :ions"),Object.keys(e.water).length>0&&(e.defNames2Residues.water=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.water)),e.defNames2Descr.water="water",e.defNames2Command.water="select :water"),this.setTransmemInMenu(e.halfBilayerSize,-e.halfBilayerSize)}setPredefinedInMenu(){let e=this.icn3d,t=e.icn3dui;if(this.setChainsInMenu(),this.setProtNuclLigInMenu(),void 0!==t.cfg.mmdbid||void 0!==t.cfg.gi||void 0!==t.cfg.chainalign||void 0!==t.cfg.mmdbafid)for(let t in e.tddomains)e.selectionCls.selectResidueList(e.tddomains[t],t,t,!1,!1);if((void 0!==t.cfg.align||void 0!==t.cfg.chainalign&&2==e.chainidArray.length)&&e.bFullUi){e.selectionCls.selectResidueList(e.consHash1,e.conservedName1,e.conservedName1,!1,!1),e.selectionCls.selectResidueList(e.consHash2,e.conservedName2,e.conservedName2,!1,!1),e.selectionCls.selectResidueList(e.nconsHash1,e.nonConservedName1,e.nonConservedName1,!1,!1),e.selectionCls.selectResidueList(e.nconsHash2,e.nonConservedName2,e.nonConservedName2,!1,!1),e.selectionCls.selectResidueList(e.nalignHash1,e.notAlignedName1,e.notAlignedName1,!1,!1),e.selectionCls.selectResidueList(e.nalignHash2,e.notAlignedName2,e.notAlignedName2,!1,!1);let s={};for(let i in e.alnChains)s=t.hashUtilsCls.unionHash(s,e.alnChains[i]);let i=e.firstAtomObjCls.getResiduesFromAtoms(s),n="protein_aligned",l="aligned protein and nucleotides",r="select "+e.resid2specCls.residueids2spec(Object.keys(i));e.selectionCls.addCustomSelection(Object.keys(i),n,l,r,!0)}}setAtomMenu(e){let t=this.icn3d;t.icn3dui;let s="",i=void 0!==t.defNames2Residues?Object.keys(t.defNames2Residues):[],n=void 0!==t.defNames2Atoms?Object.keys(t.defNames2Atoms):[],l=i.concat(n).sort(),r=[];l.forEach((e=>{-1===$.inArray(e,r)&&r.push(e)}));for(let i=0,n=r.length;i0&&(n=t.atoms[e[0]])}else if(void 0!==t.defNames2Residues&&t.defNames2Residues.hasOwnProperty(o)){let e=t.defNames2Residues[o];e.length>0&&(l=t.residues[e[0]],l&&(n=t.atoms[Object.keys(l)[0]]))}let a=void 0===n||void 0===n.color||"FFFFFF"===n.color.getHexString().toUpperCase()?"DDDDDD":n.color.getHexString(),d=void 0!==n&&void 0!==n.color?a:"000000";-1!=e.indexOf(o)?s+="":s+=""}return s}setChainsInMenu(){let e=this.icn3d;e.icn3dui;for(let t in e.chains)if(e.chainsSeq[t]&&e.chainsSeq[t].length>1){e.defNames2Residues[t]=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.chains[t])),e.defNames2Descr[t]=t;let s=t.indexOf("_"),i=t.substr(0,s),n=t.substr(s+1);e.defNames2Command[t]="select $"+i+"."+n}if(1==Object.keys(e.structures)){let t=Object.keys(e.structures)[0];e.defNames2Residues[t]=Object.keys(e.residues),e.defNames2Descr[t]=t,e.defNames2Command[t]="select $"+t}else{let t=Object.keys(e.residues),s={};for(let e=0,i=t.length;ee?l[a]=1:o.coord.z0&&(i.defNames2Residues["transmembrane"+o]=Object.keys(n),i.defNames2Descr["transmembrane"+o]="transmembrane"+o,i.defNames2Command["transmembrane"+o]="select :transmembrane"+o),Object.keys(l).length>0&&(i.defNames2Residues["extracellular"+o]=Object.keys(l),i.defNames2Descr["extracellular"+o]="extracellular"+o,i.defNames2Command["extracellular"+o]="select :extracellular"+o),Object.keys(r).length>0&&(i.defNames2Residues["intracellular"+o]=Object.keys(r),i.defNames2Descr["intracellular"+o]="intracellular"+o,i.defNames2Command["intracellular"+o]="select :intracellular"+o)}}showSets(){let e=this.icn3d,t=e.icn3dui;t.bNode||(t.htmlCls.dialogCls.openDlg("dl_definedsets","Select sets"),$("#"+e.pre+"dl_setsmenu").show(),$("#"+e.pre+"dl_setoperations").show(),$("#"+e.pre+"dl_command").hide(),$("#"+e.pre+"atomsCustom").resizable());let s=t.hashUtilsCls.cloneHash(e.hAtoms),i=t.hashUtilsCls.cloneHash(e.dAtoms);void 0!==e.bSetChainsAdvancedMenu&&e.bSetChainsAdvancedMenu&&!e.bResetSets||(this.setPredefinedInMenu(),e.bSetChainsAdvancedMenu=!0),e.hAtoms=t.hashUtilsCls.cloneHash(s),e.dAtoms=t.hashUtilsCls.cloneHash(i),e.hlUpdateCls.updateHlMenus()}clickCustomAtoms(){let e=this.icn3d,t=e.icn3dui,s=this;$("#"+e.pre+"atomsCustom").change((function(e){let i=s.icn3d,n=$(this).val();if(i.nameArray=n,null!==n){let e=!1;s.changeCustomAtoms(n,e),t.htmlCls.clickMenuCls.setLogCmd("select sets "+n.join(" "+i.setOperation+" "),!0),i.bSelectResidue=!1}})),t.myEventCls.onIds("#"+e.pre+"atomsCustom","focus",(function(e){let i=s.icn3d;t.utilsCls.isMobile()&&$("#"+i.pre+"atomsCustom").val("")}))}deleteSelectedSets(){let e=this.icn3d;e.icn3dui;let t=$("#"+e.pre+"atomsCustom").val();for(let s=0;s0)for(let n=0,l=t.defNames2Residues[e].length;n0)for(let s=0,n=t.defNames2Atoms[e].length;s0&&(n[0]=i.commands[0]);let l=e.trim().split("\n");i.commands=l;let r=l[0].indexOf("command=");if(t&&-1!=r){let e=l[0].substr(0,r-1);i.commands.splice(0,1,e)}i.STATENUMBER=i.commands.length,i.commands=n.concat(i.commands),i.STATENUMBER=i.commands.length,i.CURRENTNUMBER=0,i.bReplay?await this.replayFirstStep(i.CURRENTNUMBER):await this.execCommands(i.CURRENTNUMBER,i.STATENUMBER-1,i.STATENUMBER,s)}async execCommands(e,t,s,i){let n=this.icn3d;n.icn3dui,n.bRender=!1,i||n.reinitAfterLoad(),await this.execCommandsBase(e,t,s)}getNameArray(e){let t=this.icn3d;t.icn3dui;let s=e.split(" | "),i=[];return 2==s.length&&(i=s[1].split(","),t.hAtoms=t.definedSetsCls.getAtomsFromNameArray(i)),i}async execCommandsBase(e,t,s,i){let n,l=this.icn3d,r=l.icn3dui,o=this;for(n=e;n<=t;++n){let i=n===s-1;if(!l.commands[n].trim())continue;if(!l.atoms&&-1==l.commands[n].indexOf("load"))continue;let a=l.commands[n].split("|||"),d=a[0].trim();if(-1!==d.indexOf("load")){if(0===t&&e===t)return void(l.bNotLoadStructure?(l.hAtoms=r.hashUtilsCls.cloneHash(l.atoms),1===l.commands.length&&(l.bAddCommands=!0),i&&this.renderFinalStep(s)):(await o.applyCommandLoad(l.commands[n]),1===l.commands.length&&(l.bAddCommands=!0),i&&o.renderFinalStep(s)));l.bNotLoadStructure?(l.hAtoms=r.hashUtilsCls.cloneHash(l.atoms),l.backForward&&this.renderFinalStep(1)):(await o.applyCommandLoad(l.commands[n]),l.backForward&&o.renderFinalStep(1))}else if(0==d.indexOf("set map")&&-1==d.indexOf("set map wireframe")){let e=a[0].trim().split(" | ")[0].substr(8).split(" ");3==e.length&&"sigma"==e[1]&&(e[2],e[0],await o.applyCommandMap(a[0].trim()))}else if(0==d.indexOf("set emmap")&&-1==d.indexOf("set emmap wireframe")){let e=a[0].trim().substr(10).split(" ");2==e.length&&"percentage"==e[0]&&(e[1],await o.applyCommandEmmap(a[0].trim()))}else if(0==d.indexOf("set phi"))await l.delphiCls.applyCommandPhi(a[0].trim());else if(0==d.indexOf("set delphi"))await l.delphiCls.applyCommandDelphi(a[0].trim());else if(0==d.indexOf("view annotations"))Object.keys(l.proteins).length>0&&await o.applyCommandAnnotationsAndCddSite(a[0].trim());else if(0==d.indexOf("set annotation clinvar"))Object.keys(l.proteins).length>0&&await o.applyCommandClinvar(a[0].trim());else if(0==d.indexOf("set annotation snp"))Object.keys(l.proteins).length>0&&await o.applyCommandSnp(a[0].trim());else if(0==d.indexOf("set annotation ptm"))Object.keys(l.proteins).length>0&&await o.applyCommandPTM(a[0].trim());else if(0==d.indexOf("ig refnum on"))await l.refnumCls.showIgRefNum();else if(0==d.indexOf("set annotation 3ddomain"))Object.keys(l.proteins).length>0&&o.applyCommand3ddomain(a[0].trim());else if(0==d.indexOf("set annotation all"))Object.keys(l.proteins).length>0&&(await o.applyCommandClinvar(a[0].trim()),await o.applyCommandSnp(a[0].trim()),o.applyCommand3ddomain(a[0].trim())),await l.annotationCls.setAnnoTabAll();else if(0==d.indexOf("view interactions")&&void 0!==r.cfg.align)await o.applyCommandViewinteraction(a[0].trim());else if(0==d.indexOf("symmetry")){l.bAxisOnly=!1;let e=d.substr(d.indexOf(" ")+1);l.symmetrytitle="none"===e?void 0:e,"none"!==e&&await l.symdCls.retrieveSymmetry(Object.keys(l.structures)[0]),l.drawCls.draw()}else if(0==d.indexOf("symd symmetry"))l.bAxisOnly=!1,await l.symdCls.applyCommandSymd(d),l.drawCls.draw();else if(0==d.indexOf("scap"))await l.scapCls.applyCommandScap(d);else if(0==d.indexOf("realign on seq align"))this.getNameArray(d),await o.applyCommandRealign(d);else if(0==d.indexOf("realign on structure align msa")){let e=this.getNameArray(d);r.cfg.aligntool="vast",await l.realignParserCls.realignOnStructAlignMsa(e)}else if(0==d.indexOf("realign on structure align"))this.getNameArray(d),r.cfg.aligntool="vast",await l.realignParserCls.realignOnStructAlign();else if(0==d.indexOf("realign on tmalign msa")){let e=this.getNameArray(d);r.cfg.aligntool="tmalign",await l.realignParserCls.realignOnStructAlignMsa(e)}else if(0==d.indexOf("realign on tmalign"))this.getNameArray(d),r.cfg.aligntool="tmalign",await l.realignParserCls.realignOnStructAlign();else if(0==d.indexOf("realign on vastplus"))o.getHAtoms(l.commands[n]),await l.vastplusCls.realignOnVastplus();else if(0==d.indexOf("graph interaction pairs"))await o.applyCommandGraphinteraction(d);else if(0==d.indexOf("cartoon 2d domain"))await o.applyCommandCartoon2d(d);else if(0==d.indexOf("set half pae map"))await o.applyCommandAfmap(d);else if(0==d.indexOf("set full pae map"))await o.applyCommandAfmap(d,!0);else if(0==d.indexOf("export pqr"))await r.htmlCls.setHtmlCls.exportPqr();else if(0==d.indexOf("cartoon 2d chain")||0==d.indexOf("cartoon 2d secondary")){let e=d.lastIndexOf(" "),t=d.substr(e+1);await l.cartoon2dCls.draw2Dcartoon(t)}else await l.applyCommandCls.applyCommand(l.commands[n])}(n===s||i)&&this.renderFinalStep(n)}pressCommandtext(){let e=this.icn3d,t=e.icn3dui,s=this;$("#"+e.pre+"logtext").keypress((async function(e){let i=s.icn3d;if(i.bAddLogs=!1,13==(e.keyCode?e.keyCode:e.which)){e.preventDefault();let n=$(this).val();i.bRender=!0;let l=n.split("\n"),r=i.logs.length;for(let e=r,n=l.length;e "+i.logs.join("\n> ")+"\n> ").scrollTop($("#"+i.pre+"logtext")[0].scrollHeight)}i.bAddLogs=!0}))}async applyCommandLoad(e){let t=this.icn3d,s=t.icn3dui;t.bAddCommands=!1;let i=e.split("|||")[0].replace(/\s\s/g," ").trim();if(-1!==i.indexOf("load")){let e=i.split(" | "),n=e[0];if(e.length>1){let t=e[e.length-1].indexOf(" ");s.cfg.inpara=e[e.length-1].substr(t+1),"undefined"===s.cfg.inpara&&(s.cfg.inpara="")}let l=n.substr(n.lastIndexOf(" ")+1);if(t.structures.hasOwnProperty(l))return;if(t.inputid=l,-1!==i.indexOf("load mmtf"))s.cfg.mmtfid=l,await t.mmtfParserCls.downloadMmtf(l);else if(-1!==i.indexOf("load pdb"))s.cfg.pdbid=l,await t.pdbParserCls.downloadPdb(l);else if(-1!==i.indexOf("load af"))s.cfg.afid=l,await t.pdbParserCls.downloadPdb(l,!0);else if(-1!==i.indexOf("load opm"))s.cfg.opmid=l,await t.opmParserCls.downloadOpm(l);else if(-1!==i.indexOf("load mmcif"))s.cfg.mmcifid=l,await t.mmcifParserCls.downloadMmcif(l);else if(-1!==i.indexOf("load mmdb ")||-1!==i.indexOf("load mmdb1 "))s.cfg.mmdbid=l,s.cfg.bu=1,await t.mmdbParserCls.downloadMmdb(l);else if(-1!==i.indexOf("load mmdb0"))s.cfg.mmdbid=l,s.cfg.bu=0,await t.mmdbParserCls.downloadMmdb(l);else if(-1!==i.indexOf("load mmdbaf1"))s.cfg.mmdbafid=l,s.cfg.bu=1,await t.chainalignParserCls.downloadMmdbAf(l);else if(-1!==i.indexOf("load mmdbaf0"))s.cfg.mmdbafid=l,s.cfg.bu=0,await t.chainalignParserCls.downloadMmdbAf(l);else if(-1!==i.indexOf("load gi"))s.cfg.gi=l,await t.mmdbParserCls.downloadGi(l);else if(-1!==i.indexOf("load refseq"))s.cfg.refseqid=l,await t.mmdbParserCls.downloadRefseq(l);else if(-1!==i.indexOf("load seq_struct_ids "))t.bSmithwm=!1,t.bLocalSmithwm=!1,await t.mmdbParserCls.downloadBlast_rep_id(l);else if(-1!==i.indexOf("load seq_struct_ids_smithwm "))t.bSmithwm=!0,await t.mmdbParserCls.downloadBlast_rep_id(l);else if(-1!==i.indexOf("load seq_struct_ids_local_smithwm "))t.bLocalSmithwm=!0,await t.mmdbParserCls.downloadBlast_rep_id(l);else if(-1!==i.indexOf("load cid"))s.cfg.cid=l,await t.sdfParserCls.downloadCid(l);else if(-1!==i.indexOf("load alignment"))if(s.cfg.align=l,s.cfg.inpara||-1==s.cfg.inpara.indexOf("atype=2"))await t.alignParserCls.downloadAlignment(s.cfg.align);else{let e=2;await t.chainalignParserCls.downloadMmdbAf(s.cfg.align,void 0,e)}else if(-1!==i.indexOf("load chainalignment")){let e=i.split(" | ");e.length>1&&-1!=e[1].indexOf("resnum")&&(s.cfg.resnum=e[1].substr(e[1].indexOf("resnum")+7)),e.length>2&&-1!=e[2].indexOf("resdef")&&(s.cfg.resdef=e[2].substr(e[1].indexOf("resdef")+7)),e.length>3&&-1!=e[3].indexOf("aligntool")&&(s.cfg.aligntool=e[3].substr(e[1].indexOf("aligntool")+10)),s.cfg.chainalign=l,await t.chainalignParserCls.downloadChainalignment(l,s.cfg.resnum,s.cfg.resdef)}else if(-1!==i.indexOf("load url")){let i=e[1],n=void 0!==i?i.indexOf("type "):-1,r="pdb";-1!==n&&(r=i.substr(n+5)),s.cfg.url=l,await t.pdbParserCls.downloadUrl(l,r)}}t.bAddCommands=!0}applyCommandMap(e){let t=this.icn3d;t.icn3dui;let s=e.split(" | "),i=s[0].substr(8).split(" ");if(3==i.length&&"sigma"==i[1]){let e=i[2],n=i[0];2==s.length?t.dsn6ParserCls.dsn6ParserBase(s[1],n,e):t.dsn6ParserCls.dsn6Parser(t.inputid,n,e)}}applyCommandEmmap(e){let t=this.icn3d;t.icn3dui;let s=e.substr(10).split(" ");if(2==s.length&&"percentage"==s[0]){let e=s[1],i="em";t.densityCifParserCls.densityCifParser(t.inputid,i,e,t.emd)}}async applyCommandRealign(e){let t=this.icn3d;t.icn3dui,await t.realignParserCls.realignOnSeqAlign()}async applyCommandRealignByStruct(e){let t=this.icn3d;t.icn3dui,t.drawCls.draw(),await t.realignParserCls.realignOnStructAlign()}async applyCommandAfmap(e,t){let s=this.icn3d;s.icn3dui;let i=e.substr(e.lastIndexOf(" ")+1);await s.contactMapCls.afErrorMap(i,t)}async applyCommandGraphinteraction(e){let t=this.icn3d;t.icn3dui;let s=e.split(" | ");if(s.length>=3){let e,i=s[1].split(" "),n=i[0].split(","),l=i[1].split(","),r=-1!==s[2].indexOf("hbonds"),o=-1!==s[2].indexOf("salt bridge"),a=-1!==s[2].indexOf("interactions"),d=-1!==s[2].indexOf("halogen"),c=-1!==s[2].indexOf("pi-cation"),h=-1!==s[2].indexOf("pi-stacking");s.length>=4&&(e="true"==s[3]),t.applyCommandCls.setStrengthPara(s),await t.viewInterPairsCls.viewInteractionPairs(n,l,e,"graph",r,o,a,d,c,h)}}async applyCommandCartoon2d(e){let t=this.icn3d;t.icn3dui;let s=e.substr(e.lastIndexOf(" ")+1);await t.cartoon2dCls.draw2Dcartoon(s)}async applyCommandAnnotationsAndCddSite(e){let t=this.icn3d;t.icn3dui,"view annotations"==e&&await t.showAnnoCls.showAnnotations()}async applyCommandClinvar(e){let t=this.icn3d;t.icn3dui;let s=e.lastIndexOf(" ");e.substr(s+1),await t.annotationCls.setAnnoTabClinvar()}async applyCommandSnp(e){let t=this.icn3d;t.icn3dui;let s=e.lastIndexOf(" ");e.substr(s+1),await t.annotationCls.setAnnoTabSnp()}async applyCommandPTM(e){let t=this.icn3d;t.icn3dui;let s=e.lastIndexOf(" ");e.substr(s+1),await t.annotationCls.setAnnoTabPTM()}applyCommand3ddomain(e){let t=this.icn3d;t.icn3dui;let s=e.lastIndexOf(" "),i=e.substr(s+1);"3ddomain"!=i&&"all"!=i||t.annotationCls.setAnnoTab3ddomain()}async applyCommandViewinteraction(e){let t=this.icn3d,s=t.icn3dui;if(void 0!==s.cfg.align||void 0!==s.cfg.chainalign){let e=Object.keys(t.structures);await t.ParserUtilsCls.set2DDiagramsForAlign(e[0].toUpperCase(),e[1].toUpperCase())}}renderFinalStep(e){let t=this.icn3d,s=t.icn3dui;t.bCommandLoad=!1,t.ParserUtilsCls.hideLoading(),e+1===t.commands.length&&(t.bAddCommands=!0),t.bRender=!0;let i=t.commands[e-1]?t.commands[e-1].split("|||"):[];if(2==i.length){let e=JSON.parse(i[1]);t._zoomFactor=e.factor,t.mouseChange.x=e.mouseChange.x,t.mouseChange.y=e.mouseChange.y,t.quaternion._x=e.quaternion._x,t.quaternion._y=e.quaternion._y,t.quaternion._z=e.quaternion._z,t.quaternion._w=e.quaternion._w}if(t.selectionCls.oneStructurePerWindow(),1===e||t.hAtoms&&t.atoms&&Object.keys(t.hAtoms).length===Object.keys(t.atoms).length||void 0!==t.optsHistory[e-1]&&t.optsHistory[e-1].hasOwnProperty("hlatomcount")&&t.optsHistory[e-1].hlatomcount===Object.keys(t.atoms).length)if(t.optsHistory.length>=e){let s=t.optsHistory[e-1].pk;"no"===s?t.pk=0:"atom"===s?t.pk=1:"residue"===s?t.pk=2:"strand"===s&&(t.pk=3),t.hlUpdateCls.updateHlAll(),t.drawCls.draw()}else t.hlUpdateCls.updateHlAll(),t.drawCls.draw();else t.hlUpdateCls.updateHlAll(),t.drawCls.draw();s.cfg.closepopup&&(setTimeout((function(){t.resizeCanvasCls.closeDialogs()}),100),t.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH,s.htmlCls.HEIGHT,!0)),t.bTransparentSurface&&t.bRender&&t.drawCls.render()}async replayFirstStep(e){let t=this.icn3d,s=t.icn3dui;t.reinitAfterLoad(),await this.execCommandsBase(e,e,t.STATENUMBER);let i=t.commands[e],n=t.commands[e].indexOf("|");-1!=n&&(i=t.commands[e].substr(0,n));let l=i.length>20?i.substr(0,20)+"...":i,r=t.applyCommandCls.getMenuFromCmd(i);$("#"+t.pre+"replay_cmd").html("Cmd: "+l),$("#"+t.pre+"replay_menu").html("Menu: "+r),s.htmlCls.clickMenuCls.setLogCmd(i,!0),t.bCommandLoad=!1,t.ParserUtilsCls.hideLoading(),t.bRender=!0,t.drawCls.draw()}getHAtoms(e){let t=this.icn3d;t.icn3dui;let s=e.split("|||")[0].trim().split(" | ");if(2==s.length){let e=s[1].split(",");t.hAtoms=t.definedSetsCls.getAtomsFromNameArray(e)}}}class as{constructor(e){this.icn3d=e}async selectByCommand(e,t,s){let i=this.icn3d,n=i.icn3dui;if(0===e.indexOf("saved atoms")){let s=12,n=e.substr(s);i.definedSetsCls.selectCombinedSets(n,t)}else{let l=e.replace(/ AND /g," and ").replace(/ OR /g," or ").replace(/ or and /g," and ").replace(/ and /g," or and ").replace(/ or not /g," not ").replace(/ not /g," or not "),r=("select"===l.trim().substr(0,6)?l.trim().substr(7):l.trim()).split(" or "),o={};for(let e=0,t=r.length;e1||1==o.length&&"*"!==o[0])&&(h=!1);let C,y,v,w,_=[],S=[];if(_="*"===t?Object.keys(l.structures):t.split(","),"*"===s){let e=Object.keys(l.chains);for(let t=0,s=e.length;t1&&"3"===x[t][0]&&isNaN(x[t][1])&&"-"!==x[t][0]){i=x[t].toUpperCase().substr(1),m=!0}else if(""===x[t]||isNaN(parseInt(x[t]))){if("*"===x[t])h=!0;else if("proteins"!==x[t]&&"nucleotides"!==x[t]&&"chemicals"!==x[t]&&"ions"!==x[t]&&"water"!==x[t]){s=x[t].toUpperCase(),p=!0}}else v=x[t],w=v,n=!0;for(let a=0,u=S.length;a1?e.substr(0,l-1)===n.atoms[i].name.substr(0,l-1)&&(0===s?t[i]=1:t.hasOwnProperty(i)||delete t[i]):"*"!==e&&e!==n.atoms[i].name||(0===s?t[i]=1:t.hasOwnProperty(i)||delete t[i]),t}}class ds{constructor(e){this.icn3d=e}selectAll(){let e=this.icn3d;e.icn3dui,this.selectAll_base(),e.hlObjectsCls.removeHlObjects(),e.hlUpdateCls.removeHl2D(),e.hlUpdateCls.removeHlMenus(),e.bSelectResidue=!1,e.bSelectAlignResidue=!1,e.hlUpdateCls.removeSeqResidueBkgd(),e.hlUpdateCls.update2DdgmContent(),$("#"+e.pre+"dl_annotations > .icn3d-annotation").show(),e.definedSetsCls.setMode("all"),e.saveFileCls.showTitle()}selectAll_base(){let e=this.icn3d,t=e.icn3dui;e.hAtoms={},e.dAtoms={};for(let s in e.chains)e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.chains[s]);e.dAtoms=t.hashUtilsCls.cloneHash(e.hAtoms),e.viewSelectionAtoms=t.hashUtilsCls.cloneHash(e.hAtoms),e.ALTERNATE_STRUCTURE=-1}selectAChain(e,t,s,i){let n=this.icn3d,l=n.icn3dui;t=t.replace(/\s/g,"");let r=void 0!==s||s?"select alignChain "+e:"select chain "+e;void 0!==i&&i?(n.hAtoms=l.hashUtilsCls.unionHash(n.hAtoms,n.chains[e]),void 0===n.nameArray&&(n.nameArray=[])):(n.hAtoms={},n.nameArray=[]),n.nameArray.push(e);let o,a=s?n.alnChainsSeq[e]:n.chainsSeq[e];o=void 0===a?0:a.length;let d={};for(let t=0,s=o;t0){if(void 0!==i&&i?void 0===r.nameArray&&(r.nameArray=[]):(r.hAtoms={},r.nameArray=[]),l)for(let t in e)r.hAtoms[t]=1;else for(let t in e)for(let e in r.residues[t])r.hAtoms[e]=1;let o,a;t=t.replace(/\s/g,""),r.nameArray.push(t),l?(o="select "+r.resid2specCls.atoms2spec(r.hAtoms),a=!1):(o="select "+r.resid2specCls.residueids2spec(Object.keys(e)),a=!0);let d=Object.keys(e);this.addCustomSelection(d,t,s,o,a),(void 0===n||n)&&r.hlUpdateCls.updateHlAll(r.nameArray,void 0,i)}}selectMainChains(){let e=this.icn3d,t=e.icn3dui.hashUtilsCls.cloneHash(e.hAtoms);e.hAtoms=e.applyDisplayCls.selectMainChainSubset(t),e.hlUpdateCls.showHighlight()}selectSideChains(){let e=this.icn3d,t=e.icn3dui,s=t.hashUtilsCls.cloneHash(e.hAtoms);e.hAtoms={};for(let i in s)(e.proteins.hasOwnProperty(i)&&"N"!==e.atoms[i].name&&"H"!==e.atoms[i].name&&"C"!==e.atoms[i].name&&"O"!==e.atoms[i].name&&("CA"!==e.atoms[i].name||"C"!==e.atoms[i].elem)&&"HA"!==e.atoms[i].name||e.nucleotides.hasOwnProperty(i)&&-1===t.parasCls.nuclMainArray.indexOf(e.atoms[i].name))&&(e.hAtoms[i]=1);e.hlUpdateCls.showHighlight()}selectMainSideChains(){let e=this.icn3d,t=e.icn3dui,s=e.firstAtomObjCls.getResiduesFromAtoms(e.hAtoms);e.hAtoms={};for(let i in s)e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.residues[i]),e.dAtoms=t.hashUtilsCls.unionHash(e.dAtoms,e.residues[i]);e.drawCls.draw(),e.hlUpdateCls.showHighlight()}clickShow_selected(){let e=this.icn3d,t=e.icn3dui,s=this;t.myEventCls.onIds(["#"+e.pre+"show_selected","#"+e.pre+"mn2_show_selected"],"click",(function(e){s.icn3d,s.showSelection(),t.htmlCls.clickMenuCls.setLogCmd("show selection",!0)}))}clickHide_selected(){let e=this.icn3d,t=e.icn3dui,s=this;t.myEventCls.onIds("#"+e.pre+"mn2_hide_selected","click",(function(e){s.icn3d,s.hideSelection(),t.htmlCls.clickMenuCls.setLogCmd("hide selection",!0)}))}getGraphDataForDisplayed(){let e=this.icn3d;e.icn3dui;let t=JSON.parse(e.graphStr),s=e.firstAtomObjCls.getResiduesFromAtoms(e.dAtoms),i=[],n=[],l={};for(let e=0,n=t.nodes.length;e0)if(1==s.pk){let n=!0;this.selectResidueList(s.hAtoms,e,t,void 0,void 0,n),this.updateSelectionNameDesc(),i.htmlCls.clickMenuCls.setLogCmd("select "+s.resid2specCls.atoms2spec(s.hAtoms)+" | name "+e,!0)}else this.selectResidueList(s.selectedResidues,e,t),this.updateSelectionNameDesc(),i.htmlCls.clickMenuCls.setLogCmd("select "+s.resid2specCls.residueids2spec(Object.keys(s.selectedResidues))+" | name "+e,!0)}saveSelInCommand(){let e=this.icn3d,t=e.icn3dui;e.selectedResidues=e.firstAtomObjCls.getResiduesFromCalphaAtoms(e.hAtoms),t.htmlCls.clickMenuCls.setLogCmd("select "+e.resid2specCls.residueids2spec(Object.keys(e.selectedResidues)),!0)}saveEachResiInSel(){let e=this.icn3d;e.icn3dui,e.selectionCls.saveSelectionPrep(),e.selectedResidues={},e.selectedResidues=e.firstAtomObjCls.getResiduesFromCalphaAtoms(e.hAtoms);for(let t in e.selectedResidues){let s={};s[t]=1;let i=t+"_"+e.selectedResidues[t];this.selectResidueList(s,i,i)}}removeSelection(){let e=this.icn3d;e.icn3dui,e.bAnnotations||e.hlUpdateCls.removeSeqChainBkgd(),e.bCtrl||e.bShift||(e.hlUpdateCls.removeSeqResidueBkgd(),e.hlUpdateCls.removeSeqChainBkgd()),e.selectedResidues={},e.bSelectResidue=!1,e.hAtoms={},e.hlObjectsCls.removeHlObjects(),e.hlUpdateCls.removeHl2D()}resetAll(){let e=this.icn3d,t=e.icn3dui;e.maxD=e.oriMaxD,e.center=e.oriCenter.clone(),e.opts=t.hashUtilsCls.cloneHash(e.optsOri),e.setOptionCls.setStyle("sidec","nothing"),e.reinitAfterLoad(),e.loadScriptCls.renderFinalStep(1),e.definedSetsCls.setMode("all"),e.selectionCls.selectAll(),t.htmlCls.clickMenuCls.setLogCmd("reset",!0),e.hlUpdateCls.removeSeqChainBkgd(),e.hlUpdateCls.removeSeqResidueBkgd(),e.hlUpdateCls.removeHl2D(),e.hlUpdateCls.removeHlMenus()}async loadSelection(e){let t=this.icn3d,s=t.icn3dui,i=e.trim().split("\n");for(let e=0,n=i.length;e=t&&l.coord.z<=e)){i[l.structure+"_"+l.chain+"_"+l.resi]=1}}let n="z_planes_"+e+"_"+t,l=n;this.selectResidueList(i,n,l,!1)}}class cs{constructor(e){this.icn3d=e}residueids2spec(e){var t=this.icn3d;t.icn3dui;let s="";if(void 0!==e){let i,n,l,r,o,a,d,c=e.sort((function(e,t){if(""!==e&&!isNaN(e))return parseInt(e)-parseInt(t);{let s=e.lastIndexOf("_"),i=t.lastIndexOf("_");if(e.substr(0,s)t.substr(0,i))return 1;if(e.substr(0,s)==t.substr(0,i)){if(parseInt(e.substr(s+1))parseInt(t.substr(i+1)))return 1;if(parseInt(e.substr(s+1))==parseInt(t.substr(i+1)))return 0}}})),h="",p=0,m=1!=Object.keys(t.structures).length;for(let e=0,u=c.length;e0&&(s+=p===d?m?"$"+o+"."+a+":"+d+" or ":"."+a+":"+d+" or ":m?"$"+o+"."+a+":"+d+"-"+p+" or ":"."+a+":"+d+"-"+p+" or "),d=n;else if(h===i){let e=t.ParserUtilsCls.getResiNCBI(h,p);t.ParserUtilsCls.getResiNCBI(i,n)!=e+1&&(s+=p===d?m?"$"+o+"."+a+":"+d+" or ":"."+a+":"+d+" or ":m?"$"+o+"."+a+":"+d+"-"+p+" or ":"."+a+":"+d+"-"+p+" or ",d=n)}h=i,p=n}}r=h.indexOf("_"),o=h.substr(0,r),a=h.substr(r+1),s+=p===d?m?"$"+o+"."+a+":"+d:"."+a+":"+d:m?"$"+o+"."+a+":"+d+"-"+p:"."+a+":"+d+"-"+p}return s}atoms2spec(e){var t=this.icn3d;t.icn3dui;let s,i="",n=0,l={},r={},o={};for(let a in e)s=t.atoms[a],n>0&&(i+=" or "),i+="$"+s.structure+"."+s.chain+":"+s.resi+"@"+s.name,l[s.structure]=1,r[s.structure+"_"+s.chain]=1,o[s.structure+"_"+s.chain+"_"+s.resi]=1,++n;if(1==Object.keys(o).length){let e="\\$"+s.structure+"\\."+s.chain+":"+s.resi;i=i.replace(new RegExp(e,"g"),"")}else if(1==Object.keys(r).length){let e="\\$"+s.structure+"\\."+s.chain;i=i.replace(new RegExp(e,"g"),"")}else if(1==Object.keys(l).length){let e="\\$"+s.structure;i=i.replace(new RegExp(e,"g"),"")}return i}atoms2residues(e){var t=this.icn3d;t.icn3dui;let s={};for(let t=0,i=e.length;t=parseInt(t)&&e.b<=parseInt(s)&&(i.hAtoms=n.hashUtilsCls.unionHash(i.hAtoms,i.residues[e.structure+"_"+e.chain+"_"+e.resi]))}}else if("percent out"==e){i.bCalcArea=!0,i.opts.surface="solvent accessible surface",i.applyMapCls.applySurfaceOptions(),i.bCalcArea=!1,i.hAtoms={};for(let e in i.resid2area){let l=e.lastIndexOf("_"),r=e.substr(l+1);if(n.parasCls.residueArea.hasOwnProperty(r)){let o=parseInt(i.resid2area[e]/n.parasCls.residueArea[r]*100);if(o>=t&&o<=s){let t=e.substr(0,l);i.hAtoms=n.hashUtilsCls.unionHash(i.hAtoms,i.residues[t])}}}}i.hAtoms=n.hashUtilsCls.intHash(i.hAtoms,l),i.drawCls.draw(),i.hlUpdateCls.updateHlAll()}selectComplement(){let e=this.icn3d,t=e.icn3dui,s={};for(let t in e.atoms)e.hAtoms.hasOwnProperty(t)||(s[t]=1);e.hAtoms=t.hashUtilsCls.cloneHash(s),e.hlUpdateCls.updateHlAll()}switchHighlightLevel(){var e=this.icn3d.icn3dui;if(e.bNode)return;let t=this;document.addEventListener("keydown",(function(s){let i=t.icn3d;38===s.keyCode?(s.preventDefault(),0!=Object.keys(i.pickedAtomList).length&&i.hAtoms.hasOwnProperty(i.firstAtomObjCls.getFirstAtomObj(i.pickedAtomList).serial)||(i.pickedAtomList=e.hashUtilsCls.cloneHash(i.hAtoms)),t.switchHighlightLevelUp(),e.htmlCls.clickMenuCls.setLogCmd("highlight level up",!0)):40===s.keyCode&&(s.preventDefault(),0!=Object.keys(i.pickedAtomList).length&&i.hAtoms.hasOwnProperty(i.firstAtomObjCls.getFirstAtomObj(i.pickedAtomList).serial)||(i.pickedAtomList=e.hashUtilsCls.cloneHash(i.hAtoms)),t.switchHighlightLevelDown(),e.htmlCls.clickMenuCls.setLogCmd("highlight level down",!0))}))}switchHighlightLevelUp(){var e=this.icn3d,t=e.icn3dui;if(!t.bNode){if(e.bShift||e.bCtrl||e.hlObjectsCls.removeHlObjects(),void 0!==e.pickedAtomList&&0!==Object.keys(e.pickedAtomList).length||(e.pickedAtomList=t.hashUtilsCls.cloneHash(e.hAtoms)),0===Object.keys(e.pickedAtomList).length&&(e.pickedAtomList=e.dAtoms),1===e.highlightlevel){e.highlightlevel=2;let s=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);e.bShift||e.bCtrl?e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.residues[s.structure+"_"+s.chain+"_"+s.resi]):e.hAtoms=t.hashUtilsCls.cloneHash(e.residues[s.structure+"_"+s.chain+"_"+s.resi])}else if(2===e.highlightlevel){e.highlightlevel=3;let s=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);e.bShift||e.bCtrl?e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.pickingCls.selectStrandHelixFromAtom(s)):e.hAtoms=t.hashUtilsCls.cloneHash(e.pickingCls.selectStrandHelixFromAtom(s))}else if(3===e.highlightlevel){let s;if(void 0!==t.cfg.mmdbid||void 0!==t.cfg.gi){e.highlightlevel=4;let i=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);s=e.pickingCls.select3ddomainFromAtom(i),e.bShift||e.bCtrl?e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,s):e.hAtoms=t.hashUtilsCls.cloneHash(s)}if(void 0===t.cfg.mmdbid&&void 0===t.cfg.gi||0==Object.keys(s).length){e.highlightlevel=5;let s=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);e.bShift||e.bCtrl?e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.chains[s.structure+"_"+s.chain]):e.hAtoms=t.hashUtilsCls.cloneHash(e.chains[s.structure+"_"+s.chain])}}else if(4===e.highlightlevel){e.highlightlevel=5;let s=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);e.bShift||e.bCtrl?e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.chains[s.structure+"_"+s.chain]):e.hAtoms=t.hashUtilsCls.cloneHash(e.chains[s.structure+"_"+s.chain])}else if(5===e.highlightlevel||6===e.highlightlevel){e.highlightlevel=6;let s=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);e.bShift||e.bCtrl||(e.hAtoms={});let i=e.structures[s.structure];for(let s=0,n=i.length;s3e4)return void(e?console.log("The maximum number of allowed atoms is 30,000. Please try it again with selected chains..."):alert("The maximum number of allowed atoms is 30,000. Please try it again with selected chains..."));let o="";return o+=s.cfg.cid?t.saveFileCls.getAtomPDB(n,!0):t.saveFileCls.getAtomPDB(n),o+=t.saveFileCls.getAtomPDB(i,!0,void 0,!0),o}async CalcPhi(e,t,s,i,n){let l=this.icn3d;l.icn3dui;let r=await this.CalcPhiPrms(e,t,s,i,n);this.loadPhiData(r,s,i),l.bAjaxPhi=!0,i?l.setOptionCls.setOption("phisurface","phi"):l.setOptionCls.setOption("phimap","phi")}CalcPhiPrms(e,t,s,i,n){let l=this.icn3d,r=l.icn3dui;l.loadPhiFrom="delphi";let o=r.htmlCls.baseUrl+"delphi/delphi.cgi",a=r.cfg.cid?r.cfg.cid:Object.keys(l.structures).toString(),d={};if(n)d={pqr2phi:n,gsize:e,salt:t,pdbid:a};else{let s=this.getPdbStr();d={pdb2phi:s,gsize:e,salt:t,pdbid:a}}return new Promise((function(e,t){$.ajax({url:o,type:"POST",data:d,dataType:"binary",responseType:"arraybuffer",cache:!0,beforeSend:function(){l.ParserUtilsCls.showLoading()},complete:function(){l.ParserUtilsCls.hideLoading()},success:function(t){e(t)},error:function(e,t,s){}})}))}PhiParser(e,t,s,i){let n=this.icn3d;n.icn3dui;let l=this,r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="phiurl"==t||"phiurl2"==t?"arraybuffer":"text",r.onreadystatechange=function(){if(4==this.readyState)if(200==this.status){let e=r.response;"phiurl"==t||"phiurl2"==t?l.loadPhiData(e,s,i):l.loadCubeData(e,s,i),n.bAjaxPhi=!0,i?n.setOptionCls.setOption("phisurface","phi"):n.setOptionCls.setOption("phimap","phi")}else alert("The potential file is unavailable...");else n.ParserUtilsCls.showLoading()},r.send()}loadPhiData(e,t,s){let i=this.icn3d;i.icn3dui;let n={filetype:"phi"},l=e.buffer&&e.buffer instanceof ArrayBuffer?e.buffer:e,r=new Float32Array(l.slice(l.byteLength-24,l.byteLength-8));n.scale=r[0];let o=r[1],a=r[2],d=r[3];n.n=new Int32Array(l.slice(l.byteLength-8,l.byteLength-4)),n.xExtent=n.yExtent=n.zExtent=n.n;let c=1/n.scale*((n.n-1)/2);n.ori=new THREE.Vector3(o-c,a-c,d-c);let h=new Float32Array(l.slice(110,l.byteLength-56));n.bSurface=s,i.mapData.headerPhi=n,i.mapData.dataPhi=h,i.mapData.contourPhi=t;let p=new THREE.Matrix4;p.identity(),p.multiply((new THREE.Matrix4).makeTranslation(n.ori.x,n.ori.y,n.ori.z)),i.mapData.matrixPhi=p}loadCubeData(e,t,s){let i=this.icn3d;i.icn3dui;let n={filetype:"cube"},l=e.split("\n"),r=[];r.push(parseFloat(l[0].substr(0,10))),r.push(parseFloat(l[0].substr(10,6))),r.push(parseFloat(l[0].substr(16,10))),r.push(parseFloat(l[0].substr(26,10))),r.push(parseFloat(l[0].substr(36,10))),n.scale=r[0];let o=r[2],a=r[3],d=r[4];n.n=r[1],n.xExtent=n.yExtent=n.zExtent=n.n;let c=1/n.scale*((n.n-1)/2);n.ori=new THREE.Vector3(o-c,a-c,d-c);let h=[];for(let e=7,t=l.length;e0)e.bShowRefnum=!0,e.hAtomsRefnum={},await e.showAnnoCls.showAnnotations(),e.annotationCls.setAnnoViewAndDisplay("detailed view");else if(e.refpdbArray=["1bqu_fn3","1cd8_igv","1cdh_cd4","1dr9_cd80","1hnf_cd2","1hxm_d","1hxm_g","1ifr_lamin","1ncn_cd86","1t6v_vnar","1yjd_cd28","2atp_a","2atp_b","2dm3_iset","3kys_tead1","3pv7_ncr","4f9l_cd277","4gos_vtc","4i0k_cd276","4jqi_b","4z18_cd274","4zqk_pd1","4zt1_e","5esv_vh","5esv_vl","6al5_cd19","6jxr_a","6jxr_b","6jxr_d","6jxr_e","6jxr_g","6oil_vista","6rp8_at","6rp8_t","6umt_cd273","6x4g_cd275","6x4g_icos","7xq8_a","7xq8_b","q71h61_ild","q9um44_hhl"],e.pdbDataArray)await s.parseRefPdbData(e.pdbDataArray);else{let i=[];for(let s=0,n=e.refpdbArray.length;sl[d])&&(l[d]=o[0].score,i.bNode||console.log(d+" TM-score: "+l[d]+" matched "+s.refpdbArray[a[1]]),s.domainid2index[d]=a[1],r[d]=o[0].segs,s.domainid2ig2kabat[d]=o[0].ig2kabat,s.domainid2ig2imgt[d]=o[0].ig2imgt))}for(let e in s.domainid2index){let t=e.split("-")[0];s.chainid2index.hasOwnProperty(t)||(s.chainid2index[t]=[]),s.chainid2index[t].push(s.domainid2index[e])}for(let e in r){let t=e.split("-")[0];o[t]||(o[t]=[]),o[t]=o[t].concat(r[e])}s.resid2refnum||(s.resid2refnum={}),s.refnum2residArray||(s.refnum2residArray={}),s.chainsMapping||(s.chainsMapping={});for(let e in o){let t,l=o[e];if(!i.bNode){let t="";for(let i=0,n=s.chainid2index[e].length;i0?(s.bShowRefnum=!0,s.hAtomsRefnum={},await s.showAnnoCls.showAnnotations(),s.annotationCls.setAnnoViewAndDisplay("detailed view")):alert("No Ig reference numbers are assigned based on the reference structures in iCn3D...")}getLabelFromRefnum(e,t,s){this.icn3d.icn3dui;let i=parseInt(e);return i<100?" "+e:i>=100&&i<1e3?s?" "+e:"A^"+e:i>=1e3&&i<1200?"A"+e:i>=1200&&i<1300?"A'"+e:i>=1300&&i<1400?"A*"+e:i>=1400&&i<2e3?"A"==t.substr(0,1)?t+e:"A"+e:i>=2e3&&i<3e3?"B"+e:i>=3e3&&i<4e3?"C"+e:i>=4e3&&i<5e3?"C'"+e:i>=5e3&&i<6e3?"C''"+e:i>=6e3&&i<7e3?"D"+e:i>=7e3&&i<8e3?"E"+e:i>=8e3&&i<9e3?"F"+e:i>=9e3&&i<9400?"G"+e:i>=9400&&i<9500?"G*"+e:i>=9500?"G"+e:void 0}async parseCustomRefFile(e){let t=this.icn3d;t.icn3dui,t.bShowCustomRefnum=!0;let s=e.split("\n");t.resid2refnum||(t.resid2refnum={}),t.refnum2residArray||(t.refnum2residArray={}),t.chainsMapping||(t.chainsMapping={});let i=[];for(let e=0,t=s.length;e1e4)return void alert("The maximum number of allowed atoms is 10,000. Please try it again with smaller sets...");let o="";o+=e.saveFileCls.getAtomPDB(n);let a,d={pdb:o,pdbid:Object.keys(e.structures).toString()};try{a=await t.getAjaxPostPromise(i,d,!0);let n,l,o,c=a.rcsb_struct_symmetry,h="none";if(void 0!==c){let i;void 0!==e.rmsd_supr&&void 0!==e.rmsd_supr.rot&&(n=e.rmsd_supr.rot,l=e.rmsd_supr.trans1,o=e.rmsd_supr.trans2),void 0===e.symdArray&&(e.symdArray=[]);for(let t=0,n=c.length;tThe selected residues have no detected symmetry with a Z score of "+a.zscore+" from the program SymD."),t.htmlCls.dialogCls.openDlg("dl_symd","Dynamically Calculated Symmetry Using SymD");else{let n=a.seqalign.replace(/ /g,"").split(","),l=a.nres,o=a.shift,d=a.rmsd,h=Object.keys(r),p={},m={},u=[],g=[],f=0,b=0,C={};for(let e=0,s=n[0].length;et&&(t=C[s].length,e=s);let s=Object.keys(p),i=Object.keys(m);for(let t=0,n=C[e].length;tSymD. The Z score "+a.zscore+" is greater than the threshold Z score 8. The RMSD is "+d+' angstrom.

    The following sequence alignment shows the residue mapping of the best aligned sets: "symOri" and "symPerm", which are also available in the menu "Analysis > Defined Sets".
    ',$("#"+e.pre+"symd_info").html(A),s.setSeqAlignForSymmetry(w,_,S);let x=!1,k=t.htmlCls.alignSeqCls.getAlignSequencesAnnotations(Object.keys(e.alnChains),void 0,void 0,x,S);A=$("#"+e.pre+"dl_sequence2").html()+k.sequencesHtml,$("#"+e.pre+"dl_sequence2").html(A),$("#"+e.pre+"dl_sequence2").width(t.htmlCls.RESIDUE_WIDTH*k.maxSeqCnt+200),t.htmlCls.dialogCls.openDlg("dl_alignment","Select residues in aligned sequences from SymD");let O=Object.keys(e.defNames2Residues).length+Object.keys(e.defNames2Atoms).length,R="symOri"+O;e.selectionCls.selectResidueList(y,R,R),e.selectionCls.updateSelectionNameDesc(),t.htmlCls.clickMenuCls.setLogCmd("select "+e.resid2specCls.residueids2spec(Object.keys(y))+" | name "+R,!1),R="symPerm"+O,e.selectionCls.selectResidueList(v,R,R),e.selectionCls.updateSelectionNameDesc(),t.htmlCls.clickMenuCls.setLogCmd("select "+e.resid2specCls.residueids2spec(Object.keys(v))+" | name "+R,!1),R="symBoth"+O,y=t.hashUtilsCls.unionHash(y,v),e.selectionCls.selectResidueList(y,R,R),e.selectionCls.updateSelectionNameDesc(),t.htmlCls.clickMenuCls.setLogCmd("select "+e.resid2specCls.residueids2spec(Object.keys(y))+" | name "+R,!1)}}else $("#"+e.pre+"dl_symd").html("
    The selected residues have no detected symmetry with a Z score of "+a.zscore+" from the program SymD."),t.htmlCls.dialogCls.openDlg("dl_symd","Dynamically Calculated Symmetry Using SymD");e.symdtitle="none"===h?void 0:h,e.drawCls.draw()}catch(s){return $("#"+e.pre+"dl_symd").html("
    The web service can not determine the symmetry of the input set."),t.htmlCls.dialogCls.openDlg("dl_symd","Dynamically Calculated Symmetry Using SymD"),void e.ParserUtilsCls.hideLoading()}}getResObj(e){this.icn3d.icn3dui;let t=e.substr(0,e.indexOf(" ")),s=e.indexOf("$"),i=e.indexOf("."),n=e.indexOf(":"),l=e.substr(s+1,i-s-1),r=e.substr(i+1,n-i-1),o=e.substr(n+1);return{resn:t,resid:l+"_"+r+"_"+o,resi:o,aligned:!0}}setSeqAlignForSymmetry(e,t,s){let i=this.icn3d,n=i.icn3dui;i.conservedName1="symOri_cons",i.conservedName2="symPerm_cons",i.consHash1={},i.consHash2={},i.alnChainsAnTtl={},i.alnChainsAnno={},i.alnChainsSeq={},i.alnChains={},i.alnChainsSeq={};let l={};for(let r=0,o=e.length;rThis structure has no symmetry."),void i.htmlCls.dialogCls.openDlg("dl_symmetry","Symmetry")}let r,o,a,d=t.rcsb_struct_symmetry;if(void 0!==d){void 0!==s.rmsd_supr&&void 0!==s.rmsd_supr.rot&&(r=s.rmsd_supr.rot,o=s.rmsd_supr.trans1,a=s.rmsd_supr.trans2),s.symmetryHash={};for(let e=0,t=d.length;eThis structure has no symmetry.");else{let e="",t=0;for(let i in s.symmetryHash){e+="",++t}$("#"+s.pre+"selectSymmetry").html(e)}}else $("#"+s.pre+"dl_symmetry").html("
    This structure has no symmetry.");i.htmlCls.dialogCls.openDlg("dl_symmetry","Symmetry")}getPolygonColor(e){let t=this.icn3d.icn3dui,s=e.substr(0,1);return"C"==s?t.parasCls.thr(16747520):"D"==s?t.parasCls.thr(65535):"T"==s?t.parasCls.thr(15631086):"O"==s?t.parasCls.thr(16753920):"I"==s?t.parasCls.thr(65280):t.parasCls.thr(11119017)}getAxisColor(e,t){let s=this.icn3d.icn3dui,i=e.substr(0,1);return"C"==i?s.parasCls.thr(16711680):"D"==i?2==t?s.parasCls.thr(65535):s.parasCls.thr(16711680):"T"==i?2==t?s.parasCls.thr(65535):s.parasCls.thr(65280):"O"==i||"I"==i?2==t?s.parasCls.thr(65535):3==t?s.parasCls.thr(65280):s.parasCls.thr(16711680):s.parasCls.thr(16711680)}}class bs{constructor(e){this.icn3d=e}alignSW(e,t,s,i,n,l,r){this.icn3d.icn3dui;let o=this.bsa_align(r,e,t,[s,i],[n,l]),a="score: "+o[0]+"\n";a+="start: "+o[1]+"\n",a+="cigar: "+this.bsa_cigar2str(o[2])+"\n\n",a+="alignment:\n\n";let d=this.bsa_cigar2gaps(e,t,o[1],o[2]),c={};return c.score=o[0],c.start=o[1],c.cigar=this.bsa_cigar2str(o[2]),c.target=d[0],c.query=d[1],c}bsg_enc_seq(e,t){if(this.icn3d.icn3dui,null==t)return null;let s=[];s.length=e.length;for(let i=0;i0&&(s=-s),i=0;i=2&&"number"==typeof t[0]&&"number"==typeof t[1]){if(null==s)return null;let e="number"==typeof s?s:s[s.length-1]+1;i=this.bsa_gen_score_matrix(e,t[0],t[1])}else i=t;for(let e=0;eo.length?d:o.length;l=null==l||l<0?c:l;let h,p,m=o.target>d?o.target-d:d-o.target;l=l>m?l:m,"number"==typeof n?(h=0,p=n>0?n:-n):(h=n[0]>0?n[0]:-n[0],p=n[1]>0?n[1]:-n[1]);let u,g=h+p,f=-1073741824,b=[],C=[],y=[],v=0,w=-1,_=-1;if(e)for(let e=0;e<=d;++e)b[e]=C[e]=0;else{b[0]=0,C[0]=-g-g;for(let e=1;e<=d;++e)e>=l?b[e]=C[e]=f:(b[e]=-(g+p*(e-1)),C[e]=-(g+g+p*e))}for(let t=0;tl?t-l:0,u=t+l+10?f:-(g+p*t),n=m>0?f:-(g+g+p*t));for(let t=m;t=o?0:1,a=a>=o?a:o,l=a>=n?l:2,a=a>=n?a:n,l=!e||a>0?l:64,i=a,c=r>a?c:t,r=r>a?r:a,a-=g,a=!e||a>0?a:0,o-=p,l|=o>a?4:0,o=o>a?o:a,C[t]=o,n-=p,l|=n>a?32:0,n=n>a?n:a,s[t]=l}b[u]=i,C[u]=e?0:f,r>v&&(v=r,w=t,_=c)}if(e&&0==v)return null;u=e?v:b[d];let S,A,x,k=[],O=0,R=0;for(e?(A=w,x=_,_!=d-1&&this.push_cigar(k,4,d-1-_)):(A=o.length-1,x=(A+l+1=0&&x>=0&&(S=y[A][x-(A>l?A-l:0)],O=S>>(O<<1)&3,!(0==O&&S>>6));)0==O&&(O=3&S),0==O?(this.push_cigar(k,0,1),--A,--x):1==O?(this.push_cigar(k,2,1),--A):(this.push_cigar(k,1,1),--x);e?(x>=0&&this.push_cigar(k,4,x+1),R=A+1):(A>=0&&this.push_cigar(k,2,A+1),x>=0&&this.push_cigar(k,1,x+1));for(let e=0;e>1;++e)S=k[e],k[e]=k[k.length-1-e],k[k.length-1-e]=S;return[u,R,k]}push_cigar(e,t,s){this.icn3d.icn3dui,0==e.length||t!=(15&e[e.length-1])?e.push(s<<4|t):e[e.length-1]+=s<<4}bsa_cigar2gaps(e,t,s,i){this.icn3d.icn3dui;let n="",l="",r="",o=0,a=s;for(let s=0;s>4;0==r?(n+=t.substr(o,d),l+=e.substr(a,d),o+=d,a+=d):1==r?(n+=t.substr(o,d),l+=Array(d+1).join("-"),o+=d):2==r?(n+=Array(d+1).join("-"),l+=e.substr(a,d),a+=d):4==r&&(o+=d)}let d=l.toUpperCase(),c=n.toUpperCase();for(let e=0;e>4).toString()+"MIDNSHP=XB".charAt(15&e[s]));return t.join("")}}class Cs{constructor(e){this.icn3d=e}calculateArea(){var e=this.icn3d,t=e.icn3dui;e.bCalcArea=!0,e.opts.surface="solvent accessible surface",e.applyMapCls.applySurfaceOptions(),$("#"+e.pre+"areavalue").val(e.areavalue),$("#"+e.pre+"areatable").html(e.areahtml),t.htmlCls.dialogCls.openDlg("dl_area","Surface area calculation"),e.bCalcArea=!1}calcBuriedSurface(e,t){var s=this.icn3d,i=s.icn3dui;if(0==e.length)alert("Please select the first set");else{let n=i.hashUtilsCls.cloneHash(s.hAtoms),l=s.definedSetsCls.getAtomsFromNameArray(e),r=s.definedSetsCls.getAtomsFromNameArray(t);s.bCalcArea=!0,s.opts.surface="solvent accessible surface",s.hAtoms=i.hashUtilsCls.cloneHash(l),s.applyMapCls.applySurfaceOptions();let o=s.areavalue,a=i.hashUtilsCls.cloneHash(s.resid2area);s.hAtoms=i.hashUtilsCls.cloneHash(r),s.applyMapCls.applySurfaceOptions();let d=s.areavalue,c=i.hashUtilsCls.cloneHash(s.resid2area);s.hAtoms=i.hashUtilsCls.unionHash(s.hAtoms,l),s.applyMapCls.applySurfaceOptions();let h=s.areavalue,p=i.hashUtilsCls.cloneHash(s.resid2area),m=0,u=0,g=0,f=0;for(let e in a)p.hasOwnProperty(e)&&(f+=parseFloat(p[e]));u=(o-f).toFixed(2);for(let e in c)p.hasOwnProperty(e)&&(g+=parseFloat(p[e]));m=(d-g).toFixed(2),s.bCalcArea=!1,s.hAtoms=i.hashUtilsCls.cloneHash(n);let b=(parseFloat(d)+parseFloat(o)-parseFloat(h)).toFixed(2),C="
    Calculate solvent accessible surface area in the interface:

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

    ",$("#"+s.pre+"dl_buriedarea").html(C),i.htmlCls.dialogCls.openDlg("dl_buriedarea","Buried solvent accessible surface area in the interface"),i.htmlCls.clickMenuCls.setLogCmd("buried surface "+b,!1)}}measureDistTwoSets(e,t){var s=this.icn3d,i=s.icn3dui;if(0==e.length||0==t.length)alert("Please select two sets");else{let n=i.hashUtilsCls.cloneHash(s.hAtoms),l=s.definedSetsCls.getAtomsFromNameArray(e),r=s.definedSetsCls.getAtomsFromNameArray(t),o=s.contactCls.getExtent(l),a=s.contactCls.getExtent(r),d=new THREE.Vector3(o[2][0],o[2][1],o[2][2]),c=new THREE.Vector3(a[2][0],a[2][1],a[2][2]);s.hAtoms=i.hashUtilsCls.cloneHash(n),void 0===s.distPnts&&(s.distPnts=[]),s.distPnts.push(d),s.distPnts.push(c);let h=$("#"+s.pre+"distancecolor2").val();this.addLine(d.x,d.y,d.z,c.x,c.y,c.z,h,!0,"distance");let p=0,m=0,u=d.clone().add(c).multiplyScalar(.5),g=(parseInt(10*d.distanceTo(c))/10).toString()+" A";this.addLabel(g,u.x,u.y,u.z,p,h,m,"distance"),s.drawCls.draw()}}measureDistManySets(e,t){var s=this.icn3d,i=s.icn3dui;if(0==e.length||0==t.length)alert("Please select sets for distance calculation...");else{let n=i.hashUtilsCls.cloneHash(s.hAtoms),l={};for(let i=0,n=e.length;i"+t[e]+" (Å)"}r+="";for(let s=0,i=e.length;s"+i+" (Å)";for(let e=0,s=t.length;e'+l[i][s]+"":r+="0"}r+=""}r+="

    ",$("#"+i.pre+"dl_disttable").html(r)}}addLine(e,t,s,i,n,l,r,o,a,d,c){var h=this.icn3d;h.icn3dui;let p={};p.position1=new THREE.Vector3(e,t,s),p.position2=new THREE.Vector3(i,n,l),p.color=r,p.dashed=o,p.radius=d,p.opacity=c,void 0===h.lines[a]&&(h.lines[a]=[]),void 0!==a?h.lines[a].push(p):(void 0===h.lines.custom&&(h.lines.custom=[]),h.lines.custom.push(p)),h.hlObjectsCls.removeHlObjects()}addLineFromPicking(e){var t=this.icn3d,s=t.icn3dui;let i=$("#"+t.pre+e+"color").val();t.pAtom.coord.x,t.pAtom2.coord.x,t.pAtom.coord.y,t.pAtom2.coord.y,t.pAtom.coord.z,t.pAtom2.coord.z;let n="stabilizer"!=e;s.htmlCls.clickMenuCls.setLogCmd("add line | x1 "+t.pAtom.coord.x.toPrecision(4)+" y1 "+t.pAtom.coord.y.toPrecision(4)+" z1 "+t.pAtom.coord.z.toPrecision(4)+" | x2 "+t.pAtom2.coord.x.toPrecision(4)+" y2 "+t.pAtom2.coord.y.toPrecision(4)+" z2 "+t.pAtom2.coord.z.toPrecision(4)+" | color "+i+" | dashed "+n+" | type "+e,!0),this.addLine(t.pAtom.coord.x,t.pAtom.coord.y,t.pAtom.coord.z,t.pAtom2.coord.x,t.pAtom2.coord.y,t.pAtom2.coord.z,i,n,e),t.pickpair=!1}addLabel(e,t,s,i,n,l,r,o){var a=this.icn3d;a.icn3dui;let d={};"0"!==n&&""!==n&&"undefined"!==n||(n=void 0),"0"!==l&&""!==l&&"undefined"!==l||(l=void 0),"0"!==r&&""!==r&&"undefined"!==r||(r=void 0);let c=new THREE.Vector3;c.x=t,c.y=s,c.z=i,d.position=c,d.text=e,d.size=n,d.color=l,d.background=r,void 0===a.labels[o]&&(a.labels[o]=[]),void 0!==o?a.labels[o].push(d):(void 0===a.labels.custom&&(a.labels.custom=[]),a.labels.custom.push(d)),a.hlObjectsCls.removeHlObjects()}addChainLabels(e){var t=this.icn3d;let s=t.icn3dui.hashUtilsCls.intHash(t.hAtoms,e);void 0===t.labels.chain&&(t.labels.chain=[]);let i=t.firstAtomObjCls.getChainsFromAtoms(s);for(let e in i){let s={};s.position=t.applyCenterCls.centerAtoms(t.chains[e]).center;let i=e.indexOf("_"),n=e.substr(i+1),l=t.showSeqCls.getProteinName(e);l.length>20&&(l=l.substr(0,20)+"..."),s.text="Chain "+n+": "+l,s.size=18,t.firstAtomObjCls.getFirstCalphaAtomObj(t.chains[e]).color.getHexString().toUpperCase(),s.color="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd,s.background="#FFFFFF",t.labels.chain.push(s)}t.hlObjectsCls.removeHlObjects()}addTerminiLabels(e){var t=this.icn3d,s=t.icn3dui;let i,n="#FFFFFF";i=s.hashUtilsCls.unionHash(i,t.proteins),i=s.hashUtilsCls.unionHash(i,t.nucleotides);let l=s.hashUtilsCls.intHash(t.dAtoms,i),r=s.hashUtilsCls.intHash(l,e);void 0===t.labels.chain&&(t.labels.chain=[]);let o=t.firstAtomObjCls.getChainsFromAtoms(r);for(let e in o){let i=s.hashUtilsCls.intHash(l,t.chains[e]),r=Object.keys(i),o=t.atoms[r[0]],a=t.atoms[r[r.length-1]],d={},c={};d.position=o.coord,c.position=a.coord,d.text="N-",c.text="C-",t.nucleotides.hasOwnProperty(o.serial)&&(d.text="5'",c.text="3'"),d.size=18,c.size=18,o.color.getHexString().toUpperCase(),a.color.getHexString().toUpperCase(),d.color="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd,c.color="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd,d.background=n,c.background=n,t.labels.chain.push(d),t.labels.chain.push(c)}t.hlObjectsCls.removeHlObjects()}}class ys{constructor(e){this.icn3d=e}draw2Ddgm(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=.667,o={},a={},d={},c={},h={};if(void 0===e)return"";for(let s in e.moleculeInfor){let i="#"+("000000"+e.moleculeInfor[s].color.toString(16)).slice(-6),l=e.moleculeInfor[s].chain.trim();void 0===h[l]?h[l]=1:++h[l];let r=t+"_"+(1===h[l]?l:l+h[l].toString());void 0!==n.mmdbid_q&&(n.mmdbid_q,n.mmdbid_t),o[s]=r,a[s]=i,d[s]=e.moleculeInfor[s].name,c[r]=s}if(void 0===i||!i)for(let s=0,i=e.intracResidues.length;s";p+=""+t.toUpperCase()+"
    ",p+="";let m={},u=[],g="",f="",b={};if(i)for(let e in n.dAtoms){let t=n.atoms[e];b[c[t.structure+"_"+t.chain]]=1}let C=Object.keys(e.moleculeInfor),y=Object.keys(e.intrac),v=[];for(let e=0,t=C.length;e0)for(let t in e.intrac){let s=e.intrac[t];for(let e=0,i=s.intrac.length;e0&&(y="#"+n.atoms[e[0]].color.getHexString().toUpperCase())}let S="";n.bInitial&&void 0!==s&&(void 0!==n.alignmolid2color&&n.alignmolid2color[s].hasOwnProperty(l)?(S=n.alignmolid2color[s][l],y="#FF0000"):y="#FFFFFF");let A=d[l],x=" ",k=" ";if(void 0!==c){let e=c.indexOf("_");k=c.substr(e+1),x=k.length>1?k.substr(0,1)+"..":k}else c="Misc";void 0===y&&(y="#FFFFFF");let O=1;if(n.bInitial&&void 0!==n.alnChains[c]){let e=0;for(let t in n.alnChains[c]){let s=n.atoms[t].color.getHexString().toUpperCase();"FF0000"!==s&&"00FF00"!==s||++e}O=1*e/Object.keys(n.chains[c]).length}if(O<.2&&(O=.2),-1===v.indexOf(l)){for(let e=0,t=h.intrac.length;e1){let s=0,i=0;for(let e=0,t=w[l].length;e",p+="Interaction of chain "+c+" with chain "+h+"",p+="",p+="",p+="Interaction of chain "+h+" with chain "+c+"",p+=""}return p+=f+g,p+="",p+="",n.html2ddgm+=p,$("#"+n.pre+"dl_2ddgm").html(n.html2ddgm),p}set2DdgmNote(e){let t="
    Nodes:
    ";return this.icn3d.icn3dui.utilsCls.isMac()?(t+="Protein
    ",t+="Nucleotide
    ",t+="Chemical
    ",t+="Biopolymer
    "):(t+="OProtein
    ",t+="Nucleotide
    ",t+="Chemical
    ",t+="Biopolymer
    "),t+="
    Lines:
    Interactions at 4 Å
    ",e&&(t+="Numbers in red:
    Aligned chains"),t+="

    ",t}highlightNode(e,t,s,i){let n=this.icn3d.icn3dui;i<.2&&(i=.2);if("rect"===e){$(t).attr("stroke",n.htmlCls.ORANGE),$(t).attr("stroke-width",3);let e=Number($(s).attr("x")),l=Number($(s).attr("y")),r=Number($(s).attr("width")),o=Number($(s).attr("height"));$(t).attr("x",e+r/2*(1-i)),$(t).attr("y",l+o/2*(1-i)),$(t).attr("width",r*i),$(t).attr("height",o*i)}else if("circle"===e)$(t).attr("stroke",n.htmlCls.ORANGE),$(t).attr("stroke-width",3),$(t).attr("r",Number($(s).attr("r"))*i);else if("polygon"===e){$(t).attr("stroke",n.htmlCls.ORANGE),$(t).attr("stroke-width",3);let e=Number($(s).attr("x")),l=Number($(s).attr("y")),r=Number($(s).attr("x0d")),o=Number($(s).attr("y0d")),a=Number($(s).attr("x1d")),d=Number($(s).attr("y1d")),c=Number($(s).attr("x2d")),h=Number($(s).attr("y2d")),p=Number($(s).attr("x3d")),m=Number($(s).attr("y3d"));$(t).attr("points",(e+r*i).toString()+", "+(l+o*i).toString()+", "+(e+a*i).toString()+", "+(l+d*i).toString()+", "+(e+c*i).toString()+", "+(l+h*i).toString()+", "+(e+p*i).toString()+", "+(l+m*i).toString())}}removeLineGraphSelection(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"dl_linegraph circle").attr("stroke","#000000"),$("#"+e.pre+"dl_linegraph circle").attr("stroke-width",1),$("#"+e.pre+"dl_linegraph svg line.icn3d-hlline").attr("stroke","#FFF")}removeScatterplotSelection(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"dl_scatterplot circle").attr("stroke","#000000"),$("#"+e.pre+"dl_scatterplot circle").attr("stroke-width",1),$("#"+e.pre+"dl_scatterplot rect").attr("stroke","#000000"),$("#"+e.pre+"dl_scatterplot rect").attr("stroke-width",1)}click2Ddgm(){let e=this.icn3d,t=e.icn3dui,s=this;$(document).on("click","#"+e.pre+"dl_2ddgm .icn3d-node",(function(e){let i=s.icn3d;e.stopImmediatePropagation(),Object.keys(i.hAtoms).length1)s="inter_"+e+"_"+t;else{let i=e.indexOf("_"),n=t.indexOf("_");s="inter_"+e.substr(i+1)+"_"+t.substr(n+1)}i="select the atoms in chain "+e+" interacting with chain "+t+" in a distance of 4 angstrom";let o="select interaction "+e+","+t;n.selectionCls.addCustomSelection(r,s,i,o,!0)}draw2DProtein(e,t,s,i,n,l,r,o,a,d,c){this.icn3d.icn3dui;let h=20*d,p="";return p+="Chain "+i+": "+l+"",p+="",p+="",p+=""+n+"",""!==r&&(p+=""+r+""),p+="",p}draw2DNucleotide(e,t,s,i,n,l,r,o,a,d,c){this.icn3d.icn3dui;let h=30*d,p=30*d,m="";return m+="Chain "+i+": "+l+"",m+="",m+="",m+=""+n+"",""!==r&&(m+=""+r+""),m+="",m}draw2DChemical(e,t,s,i,n,l,r,o,a,d,c,h){this.icn3d.icn3dui;let p,m,u,g,f,b,C,y,v=30*d;if(h){let s=.5*v/Math.sqrt(3),i=.5*v;p=e-s,m=t-i,u=e+3*s,g=t-i,f=e+s,b=t+i,C=e-3*s,y=t+i}else{let s=.5*v,i=.5*v;p=e-s,m=t,u=e,g=t+i,f=e+s,b=t,C=e,y=t-i}let w=p-e,_=m-t,S=u-e,A=g-t,x=f-e,k=b-t,O=C-e,R=y-t,E="";return E+="Chain "+i+": "+l+"",E+="",E+="",E+=""+n+"",""!==r&&(E+=""+r+""),E+="",E}}class vs{constructor(e){this.icn3d=e}async draw2Dcartoon(e,t){let s=this.icn3d,i=s.icn3dui,n=this;if(i.htmlCls.clickMenuCls.setLogCmd("cartoon 2d "+e,!0),s.cartoon2dType=e,t){let t=n.getCartoonSvg(e,s.graphStr);$("#"+i.svgid_ct).html(t)}else{await this.getNodesLinksForSetCartoon(e),s.graphStr=n.getCartoonData(e,s.node_link);let t=n.getCartoonSvg(e,s.graphStr);$("#"+i.svgid_ct).html(t),n.setEventsForCartoon2d(),i.htmlCls.dialogCls.openDlg("dl_2dctn","2D Cartoon")}}getCartoonSvg(e,t){let s=this.icn3d,i=s.icn3dui,n="",l="",r=JSON.parse(t);s.ctnNodeHash={};for(let t=0,i=r.nodes.length;t":"domain"==e?n+="":"secondary"==e&&(a=s.ctnNodeHash[l].x2,d=i.htmlCls.width2d-s.ctnNodeHash[l].y2,c=s.ctnNodeHash[o].x1,h=i.htmlCls.width2d-s.ctnNodeHash[o].y1,n+="");let p=l+"--"+o;n+="Interaction of "+e+" "+this.getLabelFromId(l,e)+" with "+e+" "+this.getLabelFromId(o,e)+"",n+="",s.nodeid2lineid.hasOwnProperty(l)||(s.nodeid2lineid[l]=[]),s.nodeid2lineid.hasOwnProperty(o)||(s.nodeid2lineid[o]=[]),s.nodeid2lineid[l].push(p),s.nodeid2lineid[o].push(p)}return n+=l,n}setEventsForCartoon2d(){let e=this.icn3d,t=e.icn3dui;$("#"+t.svgid_ct+" .icn3d-ctnode").draggable({start:function(e,t){let s=parseFloat(e.target.getAttribute("cx")),i=parseFloat(e.target.getAttribute("cy"));e.target.setAttribute("cx",s),e.target.setAttribute("cy",i);let n=e.target.getAttribute("ang");if(n)e.target.setAttribute("transform","rotate("+n+","+s+","+i+")");else{let t=parseFloat(e.target.getAttribute("x1")),s=parseFloat(e.target.getAttribute("y1")),i=parseFloat(e.target.getAttribute("x2")),n=parseFloat(e.target.getAttribute("y2"));e.target.setAttribute("x1",t),e.target.setAttribute("y1",s),e.target.setAttribute("x2",i),e.target.setAttribute("y2",n)}},drag:function(s,i){let n=$("#"+t.svgid_ct).offset().left,l=$("#"+t.svgid_ct).offset().top,r=s.target.getAttribute("id"),o=s.target.getAttribute("ang"),a=s.clientX-n,d=s.clientY-l,c=parseFloat(s.target.getAttribute("cx")),h=parseFloat(s.target.getAttribute("cy")),p=(a-c)/e.resizeRatioX,m=(d-h)/e.resizeRatioY,u=parseFloat($("#"+r+"_text").attr("x")),g=parseFloat($("#"+r+"_text").attr("y"));if($("#"+r+"_text").attr("x",u+p),$("#"+r+"_text").attr("y",g+m),s.target.setAttribute("cx",a),s.target.setAttribute("cy",d),o)s.target.setAttribute("transform","rotate("+o+","+a+","+d+")");else{let e=parseFloat(s.target.getAttribute("x1")),t=parseFloat(s.target.getAttribute("y1")),i=parseFloat(s.target.getAttribute("x2")),n=parseFloat(s.target.getAttribute("y2"));if(s.target.setAttribute("x1",e+p),s.target.setAttribute("y1",t+m),s.target.setAttribute("x2",i+p),s.target.setAttribute("y2",n+m),"S"==r.substr(0,1)){let e=parseFloat($("#"+r+"_box").attr("x1")),t=parseFloat($("#"+r+"_box").attr("y1")),s=parseFloat($("#"+r+"_box").attr("x2")),i=parseFloat($("#"+r+"_box").attr("y2"));$("#"+r+"_box").attr("x1",e+p),$("#"+r+"_box").attr("y1",t+m),$("#"+r+"_box").attr("x2",s+p),$("#"+r+"_box").attr("y2",i+m)}}if(e.nodeid2lineid[r])for(let t=0,s=e.nodeid2lineid[r].length;t";return u+=""+e+" "+m+"","H"==t.substr(0,1)?u+="":(u+="",u+=""),u+=""+m+"",u+="",u}drawOval(e,t,s,i,n,l,r,o,a,d){let c=this.icn3d.icn3dui,h=this.getLabelFromId(t,e);i=c.htmlCls.width2d-i,r=180-r;let p="chain"==e?"":"";return p+=""+e+" "+h+"",p+="",p+="",p+=" ",p+=" ",p+="",p+="",p+="":" from='"+a+"' to='"+d+"' />",p+=""+h+"",p+="",p}getCartoonData(e,t){let s=this.icn3d;s.icn3dui;let i,n,l=[],r=[];l=t.node;let o=[],a={},d=0;for(let e=0,t=l.length;e0?n.y=s.htmlCls.width2d-n.y:n.y=-n.y,n}async getNodesLinksForSetCartoon(e){let t,s,i,n,l,r=this.icn3d,o=r.icn3dui,a=this,d=[],c=[],h=0,p=o.htmlCls.defaultValue,m="",u="",g="",f=!1,b=!0;if("chain"==e){let e={};for(let t in r.hAtoms){let s=r.atoms[t];if("DUM"==s.chain)continue;let i=s.structure+"_"+s.chain;(r.proteins.hasOwnProperty(t)||r.nucleotides.hasOwnProperty(t))&&(e.hasOwnProperty(i)||(e[i]={}),e[i][s.serial]=s)}let t=r.contactCls.getExtent(r.atoms),s=9999,i=9999,n=-9999,a=-9999,h=-9999,p=[];for(let d in e){r.hAtom={},r.hAtoms=o.hashUtilsCls.cloneHash(r.chains[d]);let e=r.axesCls.setPc1Axes(),c=e[0],m=e[1].distanceTo(e[0]),u=e[2].distanceTo(e[0]),g=180*new THREE.Vector2(e[1].x-e[0].x,e[1].y-e[0].y).angle()/Math.PI;g>180&&(g-=180);let f=Object.keys(r.hAtoms)[0],b=r.atoms[f];l=d,c=this.projectTo2d(c);let C=c.x,y=c.y;Cn&&(n=C),ya&&(a=y);let v=.5;m=v*o.htmlCls.width2d*m/(t[1][0]-t[0][0]),u=v*o.htmlCls.width2d*u/(t[1][1]-t[0][1]),m>h&&(h=m),u>h&&(h=u),p.push({id:d,r:l,x:C,y:y,rx:m,ry:u,ang:g,c:b.color.getHexString()})}let m=h+2,u=n-s,g=a-i;for(let e=0,t=p.length;e1&&(e+="__"+S.structure),a.push(e)),g==S.chain&&f&&S.ssend){let o=this.projectTo2d(t.coord.clone()),d=o.x,g=o.y,x=this.projectTo2d(S.coord.clone()),k=x.x,O=x.y;s=.5*(d+k),i=.5*(g+O),d=.5*(s+d),g=.5*(i+g),k=.5*(s+k),O=.5*(i+O),dw&&(w=d),g_&&(_=g),kw&&(w=k),O_&&(_=O),f=!1,b=!0,n+="-"+S.resi,l+="-"+S.resi,n+="__"+S.chain,Object.keys(r.structures).length>1&&(n+="__"+S.structure);for(let t=0,s=a.length;t0&&m==S.chain&&c.push('{"source": "'+u+'", "target": "'+n+'", "v": '+p+', "c": "'+t.color.getHexString().toUpperCase()+'"}'),A.push({id:n,r:l,ss:C,x:s,y:i,x1:d,y1:g,x2:k,y2:O,c:S.color.getHexString()}),m=S.chain,u=n,++h}}}let x=S+2,k=w-y,O=_-v;for(let e=0,t=A.length;e1&&(v+="__"+i.substr(0,i.indexOf("_")));let w=g[b],_=f[b];t.hAtoms={};for(let e=0,n=w.length;e180&&(O-=180);let R=Object.keys(t.hAtoms)[0],E=t.atoms[R];A=this.projectTo2d(A);let I=A.x,T=A.y;Ic&&(c=I),Th&&(h=T);let M=.5;x=M*s.htmlCls.width2d*x/(o[1][0]-o[0][0]),k=M*s.htmlCls.width2d*k/(o[1][1]-o[0][1]),x>p&&(p=x),k>p&&(p=k),void 0!==C&&n.push('{"source": "'+C+'", "target": "'+v+'", "v": '+l+', "c": "'+y.color.getHexString().toUpperCase()+'"}'),m.push({id:v,from:w+"",to:_+"",x:I,y:T,rx:x,ry:k,ang:O,c:E.color.getHexString()}),C=v,y=E}}let g=p+2,f=c-a,b=h-d;for(let e=0,t=m.length;e=2?d+"_"+e[1]:Object.keys(i.chains)[0];for(let e=0,t=o.length;es.transformCls.rotateCountMax)return s.transformCls.resetOrientation(),!1;if(++s.transformCls.rotateCount,t)if("left"===e)s.ROT_DIR="left";else if("right"===e)s.ROT_DIR="right";else if("up"===e)s.ROT_DIR="up";else{if("down"!==e)return!1;s.ROT_DIR="down"}if("left"===e&&"left"===s.ROT_DIR)s.transformCls.rotateLeft(1);else if("right"===e&&"right"===s.ROT_DIR)s.transformCls.rotateRight(1);else if("up"===e&&"up"===s.ROT_DIR)s.transformCls.rotateUp(1);else{if("down"!==e||"down"!==s.ROT_DIR)return!1;s.transformCls.rotateDown(1)}setTimeout((function(){i.rotStruc(e)}),100)}async back(){var e=this.icn3d;e.icn3dui,e.backForward=!0,e.STATENUMBER--,e.bAddCommands=!1,e.bAddLogs=!1,e.bNotLoadStructure=!0,e.STATENUMBER<1?e.STATENUMBER=1:await e.loadScriptCls.execCommands(0,e.STATENUMBER-1,e.STATENUMBER,!0),e.setStyleCls.adjustIcon(),e.bAddCommands=!0,e.bAddLogs=!0}async forward(){var e=this.icn3d;e.icn3dui,e.backForward=!0,e.STATENUMBER++,e.bAddCommands=!1,e.bAddLogs=!1,e.bNotLoadStructure=!0,e.STATENUMBER>e.commands.length?e.STATENUMBER=e.commands.length:await e.loadScriptCls.execCommands(0,e.STATENUMBER-1,e.STATENUMBER,!0),e.setStyleCls.adjustIcon(),e.bAddCommands=!0,e.bAddLogs=!0}async replayon(){var e=this.icn3d;e.icn3dui,e.CURRENTNUMBER=0,e.bReplay=1,$("#"+e.pre+"replay").show(),e.commands.length>0&&await e.loadScriptCls.replayFirstStep(e.CURRENTNUMBER)}async replayoff(){var e=this.icn3d;e.icn3dui,e.bReplay=0,$("#"+e.pre+"replay").hide(),++e.CURRENTNUMBER,await e.loadScriptCls.execCommands(e.CURRENTNUMBER,e.STATENUMBER-1,e.STATENUMBER)}closeDialogs(){var e=this.icn3d,t=e.icn3dui;let s=["dl_2ddgm","dl_2dctn","dl_alignment","dl_sequence2","dl_definedsets","dl_setsmenu","dl_command","dl_setoperations","dl_vast","dl_foldseek","dl_mmtfid","dl_pdbid","dl_afid","dl_opmid","dl_pdbfile","dl_pdbfile_app","dl_rescolorfile","dl_customcolor","dl_align","dl_alignaf","dl_chainalign","dl_chainalign2","dl_chainalign3","dl_mutation","dl_mol2file","dl_sdffile","dl_xyzfile","dl_afmapfile","dl_urlfile","dl_mmciffile","dl_mmcifid","dl_mmdbid","dl_mmdbafid","dl_blast_rep_id","dl_yournote","dl_gi","dl_refseqid","dl_cid","dl_pngimage","dl_state","dl_fixedversion","dl_selection","dl_dsn6","dl_dsn6url","dl_clr","dl_symmetry","dl_symd","dl_contact","dl_hbonds","dl_realign","dl_realignbystruct","dl_allinteracton","dl_interactionsorted","dl_linegraph","dl_linegraphcolor","dl_scatterplot","dl_scatterploitcolor","dl_contactmap","dl_alignerrormap","dl_elecmap2fofc","dl_elecmapfofc","dl_emmap","dl_aroundsphere","dl_adjustmem","dl_selectplane","dl_addlabel","dl_addlabelselection","dl_labelColor","dl_distance","dl_stabilizer","dl_disttwosets","dl_distmanysets","dl_stabilizer_rm","dl_thickness","dl_thickness2","dl_addtrack","dl_addtrack_tabs","dl_saveselection","dl_copyurl","dl_selectannotations","dl_annotations_tabs","dl_anno_view_tabs","dl_annotations","dl_graph","dl_svgcolor","dl_area","dl_colorbyarea","dl_rmsd","dl_buriedarea","dl_propbypercentout","dl_propbybfactor","dl_legend","dl_disttable"];for(let i in s){let n=s[i];t.cfg.notebook?$("#"+e.pre+n).hide():$("#"+e.pre+n).hasClass("ui-dialog-content")&&$("#"+e.pre+n).dialog("isOpen")&&$("#"+e.pre+n).dialog("close").remove()}t.cfg.notebook||this.resizeCanvas(t.htmlCls.WIDTH,t.htmlCls.HEIGHT,!0)}}class _s{constructor(e){this.icn3d=e}resetOrientation(){let e=this.icn3d;e.icn3dui;let t=!1;if(e.commands.length>0){let s=e.commands[0].split("|||");if(2==s.length){let i=JSON.parse(s[1]);e._zoomFactor=i.factor,e.mouseChange.x=i.mouseChange.x,e.mouseChange.y=i.mouseChange.y,e.quaternion._x=i.quaternion._x,e.quaternion._y=i.quaternion._y,e.quaternion._z=i.quaternion._z,e.quaternion._w=i.quaternion._w,t=!0}}t||(e._zoomFactor=1,e.mouseChange=new THREE.Vector2(0,0),e.quaternion=new THREE.Quaternion(0,0,0,1)),e.maxD=e.oriMaxD,e.center=e.oriCenter.clone(),"show"==e.ori_chemicalbinding?e.bSkipChemicalbinding=!1:"hide"==e.ori_chemicalbinding&&(e.bSkipChemicalbinding=!0)}rotateLeft(e){let t=this.icn3d,s=t.icn3dui,i=new THREE.Vector3(0,1,0),n=-e/180*Math.PI;t.bControlGl&&!s.bNode?i.applyQuaternion(window.cam.quaternion).normalize():i.applyQuaternion(t.cam.quaternion).normalize();let l=new THREE.Quaternion;l.setFromAxisAngle(i,-n);let r={};r.quaternion=l,r.update=!0,t.bControlGl&&!s.bNode?window.controls.update(r):t.controls.update(r),t.bRender&&t.drawCls.render()}rotateRight(e){let t=this.icn3d,s=t.icn3dui,i=new THREE.Vector3(0,1,0),n=e/180*Math.PI;t.bControlGl&&!s.bNode?i.applyQuaternion(window.cam.quaternion).normalize():i.applyQuaternion(t.cam.quaternion).normalize();let l=new THREE.Quaternion;l.setFromAxisAngle(i,-n);let r={};r.quaternion=l,r.update=!0,t.bControlGl&&!s.bNode?window.controls.update(r):t.controls.update(r),t.bRender&&t.drawCls.render()}rotateUp(e){this.icn3d.icn3dui,this.rotate_base(-e)}rotateDown(e){this.icn3d.icn3dui,this.rotate_base(e)}rotate_base(e){let t=this.icn3d,s=t.icn3dui,i=new THREE.Vector3(1,0,0),n=e/180*Math.PI;t.bControlGl&&!s.bNode?i.applyQuaternion(window.cam.quaternion).normalize():i.applyQuaternion(t.cam.quaternion).normalize();let l=new THREE.Quaternion;l.setFromAxisAngle(i,-n);let r={};r.quaternion=l,r.update=!0,t.bControlGl&&!s.bNode?window.controls.update(r):t.controls.update(r),t.bRender&&t.drawCls.render()}setRotation(e,t){let s=this.icn3d,i=s.icn3dui;s.bControlGl&&!i.bNode&&window.cam?e.applyQuaternion(window.cam.quaternion).normalize():s.cam&&e.applyQuaternion(s.cam.quaternion).normalize();let n=new THREE.Quaternion;n.setFromAxisAngle(e,-t);let l={};l.quaternion=n,l.update=!0,s.bControlGl&&!i.bNode&&window.controls?window.controls.update(l):s.controls&&s.controls.update(l),s.bRender&&s.drawCls.render()}translateLeft(e){this.icn3d.icn3dui,this.translate_base(-e,0)}translateRight(e){this.icn3d.icn3dui,this.translate_base(e,0)}translateUp(e){this.icn3d.icn3dui,this.translate_base(0,-e)}translateDown(e){this.icn3d.icn3dui,this.translate_base(0,e)}translate_base(e,t){let s=this.icn3d,i=s.icn3dui,n=new THREE.Vector2(0,0);n.x+=e/100,n.y+=t/100;let l={};l.mouseChange=n,l.update=!0,s.bControlGl&&!i.bNode?window.controls.update(l):s.controls.update(l),s.bRender&&s.drawCls.render()}zoominSelection(e){let t=this.icn3d,s=t.icn3dui,i={};if(i._zoomFactor=1/t._zoomFactor,i.update=!0,t.bControlGl&&!s.bNode?window.controls&&window.controls.update(i):t.controls&&t.controls.update(i),void 0===e&&(e=s.hashUtilsCls.hash2Atoms(t.hAtoms,t.atoms)),Object.keys(e).length>1){let s=t.applyCenterCls.centerAtoms(e);t.maxD=s.maxD,t.maxD<5&&(t.maxD=5),t.center=s.center,t.applyCenterCls.setCenter(t.center),t.cameraCls.setCamera()}}getTransformationStr(e){this.icn3d.icn3dui;let t={factor:1,mouseChange:{x:0,y:0},quaternion:{_x:0,_y:0,_z:0,_w:1}};return t.factor=parseFloat(e.factor).toPrecision(4),t.mouseChange.x=parseFloat(e.mouseChange.x).toPrecision(4),t.mouseChange.y=parseFloat(e.mouseChange.y).toPrecision(4),t.quaternion._x=parseFloat(e.quaternion._x).toPrecision(4),t.quaternion._y=parseFloat(e.quaternion._y).toPrecision(4),t.quaternion._z=parseFloat(e.quaternion._z).toPrecision(4),t.quaternion._w=parseFloat(e.quaternion._w).toPrecision(4),"1.0000"==t.factor&&(t.factor=1),"0.0000"==t.mouseChange.x&&(t.mouseChange.x=0),"0.0000"==t.mouseChange.y&&(t.mouseChange.y=0),"0.0000"==t.quaternion._x&&(t.quaternion._x=0),"0.0000"==t.quaternion._y&&(t.quaternion._y=0),"0.0000"==t.quaternion._z&&(t.quaternion._z=0),"1.0000"==t.quaternion._w&&(t.quaternion._w=1),JSON.stringify(t)}}class Ss{constructor(e){this.icn3d=e}saveFile(e,t,s){let i,n=this.icn3d,l=n.icn3dui;if("command"===t){let e=n.loadCmd?n.loadCmd+"\n":"";for(let t=0,s=n.commands.length;t'+""+document.getElementById(e).innerHTML+""}savePng(e,t,s){let i=this.icn3d,n=i.icn3dui;if(n.bNode)return"";let l=$("#"+e).width(),r=$("#"+e).height();s&&(r=l);let o=document.getElementById(e),a=o.getBBox(),d=o.cloneNode(!0);i.lineGraphCls.copyStylesInline(d,o);let c=document.createElement("CANVAS");c.width=l,c.height=r;let h=c.getContext("2d");h.clearRect(0,0,a.width,a.height);let p=this.getSvgXml(e,l,r,s),m=window.URL||window.webkitURL||window,u=new Blob([p],{type:"image/svg+xml;charset=utf-8"}),g=new Image;g.src=m.createObjectURL(u),g.onload=function(){if(h.drawImage(g,0,0),m.revokeObjectURL(this.src),n.utilsCls.isIE()){let e=c.msToBlob();e&&(saveAs(e,t),c.remove())}else c.toBlob((function(e){e&&(saveAs(e,t),c.remove())}))}}exportCustomAtoms(e){var t=this.icn3d;t.icn3dui;let s="",i=void 0!==t.defNames2Residues?Object.keys(t.defNames2Residues).sort():[];for(let n=0,l=i.length;n0)if(s){let s={};for(let e=0,l=t.length;e1,_=1,S="",A="",x={};for(let h in e){let e=r.atoms[h];if(s&&e.het)continue;if(e.structure!=S){a+=v,v="",_>1&&(a+="\nENDMDL\n"),w&&(a+="MODEL "+_+"\n");let t=n?"Mutated chain_residue "+Object.keys(n)+"; ":"";i||(a+=this.getPDBHeader(_-1,y,t,l)),S=e.structure,++_}else e.chain!=A&&(A&&(a+="TER\n"),A=e.chain);let p=e.chain+"_"+e.resi;if(n&&n.hasOwnProperty(p)){x.hasOwnProperty(p)||(a+=n[p],x[p]=1);continue}let m="";m+=e.het?"HETATM":"ATOM ",m+=h.toString().padStart(5," "),m+=" ";let u=e.name.trim();isNaN(u.substr(0,1))||(u=u.substr(1)+u.substr(0,1)),4==u.length?m+=u:(m+=" ",u=u.replace(/\*/g,"'"),"O1P"==u?u="OP1":"O2P"==u?u="OP2":"C5M"==u&&(u="C7 "),m+=u.padEnd(3," ")),m+=" ";let g=e.resn;if(m+=g.length<=3?g.padStart(3," "):g.substr(0,3),e.chain.length>=2){m+=e.chain.replace(/_/gi,"").substr(0,2)}else 1==e.chain.length?m+=" "+e.chain.substr(0,1):0==e.chain.length&&(m+=" A");let f=e.resi;!isNaN(f)&&e.chain.length>3&&!isNaN(e.chain.substr(3))&&(f=f-1+parseInt(e.chain.substr(3)));let b=parseInt(f);m+=b.toString().length<=4?b.toString().padStart(4," "):b.toString().substr(0,4);let C=e.resi.toString().substr(e.resi.toString().length-1,1);if(isNaN(C)?m+=C:m+=" ",m+=" ".padStart(3," "),m+=e.coord.x.toFixed(3).toString().padStart(8," "),m+=e.coord.y.toFixed(3).toString().padStart(8," "),m+=e.coord.z.toFixed(3).toString().padStart(8," "),t&&e.het){let t=1.5,s=0;"C"==e.elem?t=1.908:"N"==e.elem?t=1.824:"O"==e.elem?t=1.6612:"H"==e.elem?t=1.25:"S"==e.elem?t=2:"P"==e.elem?t=2.1:o.parasCls.vdwRadii.hasOwnProperty(e.elem)&&(t=o.parasCls.vdwRadii[e.elem]),void 0!==o.cfg.cid&&void 0!==e.crg?s=e.crg:d.hasOwnProperty(h)?s=1.38:c.hasOwnProperty(h)?s=-.595:o.parasCls.ionCharges.hasOwnProperty(e.elem)&&(s=o.parasCls.ionCharges[e.elem]),m+=s.toFixed(4).toString().padStart(8," "),m+=t.toFixed(4).toString().padStart(7," ")}else m+="1.00".padStart(6," "),m+=e.b?parseFloat(e.b).toFixed(2).toString().padStart(6," "):" ".padStart(6," "),m+=" ".padStart(10," "),m+=e.elem.padStart(2," "),m+=" ".padStart(2," ");if(e.het&&e.bonds.length>0){v+="CONECT"+h.toString().padStart(5," ");let t={};for(let s=0,i=e.bonds.length;s50?n.molTitle.substr(0,47)+"...":n.molTitle;-1!=e.indexOf('"')&&(e=""),s&&(e=s+e),l+="TITLE "+e+"\n"}return t&&t[r]&&(l+=t[r]),l}showTitle(){var e=this.icn3d,t=e.icn3dui;if(void 0!==e.molTitle&&""!==e.molTitle){let s=e.molTitle,i="black"==e.opts.background?t.htmlCls.GREYD:"black";if(void 0===e.inputid)e.molTitle.length>40&&(s=e.molTitle.substr(0,40)+"..."),$("#"+e.pre+"title").html(s);else if(void 0!==t.cfg.cid){let t=this.getLinkToStructureSummary();$("#"+e.pre+"title").html("PubChem CID "+e.inputid.toUpperCase()+": "+s)}else if(void 0!==t.cfg.align)s="VAST+ alignment of "+Object.keys(e.structures),$("#"+e.pre+"title").html(s);else if(void 0!==t.cfg.chainalign){s="Dynamic Structure Alignment of Chains: "+t.cfg.chainalign.split(","),$("#"+e.pre+"title").html(s)}else if(void 0!==t.cfg.mmdbafid){let t=Object.keys(e.structures);if(t.length>1)s="Multiple structures: "+t,$("#"+e.pre+"title").html(s);else if(1==t.length){let e=this.getLinkToStructureSummary();this.setStructureTitle(e,s,i)}}else{let e=this.getLinkToStructureSummary();this.setStructureTitle(e,s,i)}}else $("#"+e.pre+"title").html("")}setStructureTitle(e,t,s){var i=this.icn3d,n=i.icn3dui;i.molTitle.length>40&&(t=i.molTitle.substr(0,40)+"...");let l=i.inputid.toUpperCase(),r=isNaN(i.inputid)&&i.inputid.length>5?"AlphaFold ID":"PDB ID";if(-1!=i.inputid.indexOf("http")&&(r="Data from",e=i.inputid,l=i.inputid),n.cfg.refseqid&&(r="NCBI Protein Acc."),i.inputid&&i.inputid.substr(0,4)!=i.defaultPdbId)if(n.cfg.blast_rep_id){let e=n.cfg.oriQuery_id?n.cfg.oriQuery_id:n.cfg.query_id,s=n.cfg.oriBlast_rep_id?n.cfg.oriBlast_rep_id:n.cfg.blast_rep_id;e.length>20&&(e=e.substr(0,17)+"..."),l="Query: "+e+"; target: "+s,$("#"+i.pre+"title").html(l+", "+t)}else $("#"+i.pre+"title").html(r+" "+l+": "+t);else $("#"+i.pre+"title").html(t)}getLinkToStructureSummary(e){var t=this.icn3d,s=t.icn3dui;let i="https://www.ncbi.nlm.nih.gov/structure/?term=";if(i=void 0!==s.cfg.cid?"https://www.ncbi.nlm.nih.gov/pccompound/?term=":void 0!==s.cfg.refseqid?"https://www.ncbi.nlm.nih.gov/protein/":void 0!==s.cfg.afid?"https://alphafold.ebi.ac.uk/search/text/":Object.keys(t.structures).length>1?"https://www.ncbi.nlm.nih.gov/structure/?term=":s.htmlCls.baseUrl+"pdb/",void 0===t.inputid)i="https://www.ncbi.nlm.nih.gov/pccompound/?term="+t.molTitle;else{let n=t.inputid.split("_");1===n.length?(i+=t.inputid,e&&s.htmlCls.clickMenuCls.setLogCmd("link to "+t.inputid+": "+i,!1)):2===n.length&&(s.cfg.afid?i+=n[0]+" "+n[1]:i+=n[0]+" OR "+n[1],e&&s.htmlCls.clickMenuCls.setLogCmd("link to structures "+n[0]+" and "+n[1]+": "+i,!1))}return i}setEntrezLinks(e){var t=this.icn3d,s=t.icn3dui;let i,n=Object.keys(t.structures);if(1===n.length){i="https://www.ncbi.nlm.nih.gov/"+e+"/?term="+n[0],s.htmlCls.clickMenuCls.setLogCmd("Entrez "+e+" about PDB "+n[0]+": "+i,!1);let l=t.structures&&Object.keys(t.structures).length>0?"_blank":"_self";window.open(i,l)}else if(2===n.length){i="https://www.ncbi.nlm.nih.gov/"+e+"/?term="+n[0]+" OR "+n[1],s.htmlCls.clickMenuCls.setLogCmd("Entrez "+e+" about PDB "+n[0]+" OR "+n[1]+": "+i,!1);let l=t.structures&&Object.keys(t.structures).length>0?"_blank":"_self";window.open(i,l)}}}class As{constructor(e){this.icn3d=e}async shareLink(e,t){let s=this.icn3d,i=s.icn3dui,n=this.shareLinkUrl(),l=n.length>4e3||0!==n.indexOf("http");e&&(n+="&random="+parseInt(1e3*Math.random()));let r=Object.keys(s.structures).join("_");if(r==s.defaultPdbId&&(s.filename?r=s.filename:s.inputid&&(r=s.inputid)),e){if(t||s.bInputfile||l)return void s.saveFileCls.saveFile(r+"_icn3d_loadable.png","png")}else{if(s.bInputfile&&!s.bInputUrlfile)return void alert("Share Link does NOT work when the data are from custom files. Please save 'iCn3D PNG Image' in the File menu and open it in iCn3D.");if(l)return void alert("The url is more than 4000 characters and may not work. Please save 'iCn3D PNG Image' or 'State File' and open them in iCn3D.");i.htmlCls.clickMenuCls.setLogCmd("share link: "+n,!1)}let o=await this.getShareLinkPrms(n,e),a="Problem in getting shortened URL";if(void 0!==o.shortLink&&(a=o.shortLink,e)){let e=a.split("/"),t=e[e.length-1];s.saveFileCls.saveFile(r+"-"+t+".png","png");let i='\n\n",s.saveFileCls.saveFile(r+"-"+t+".html","html",i)}e&&void 0===o.shortLink&&s.saveFileCls.saveFile(r+"_icn3d_loadable.png","png");let d=a.split("page.link/");2==d.length&&(a="https://structure.ncbi.nlm.nih.gov/icn3d/share.html?"+d[1]),$("#"+s.pre+"ori_url").val(n),$("#"+s.pre+"short_url").val(a),$("#"+s.pre+"short_url_title").val(a+"&t="+s.yournote),e||i.htmlCls.dialogCls.openDlg("dl_copyurl","Copy a Share Link URL")}getShareLinkPrms(e,t){let s=this.icn3d,i=s.icn3dui;return new Promise((function(n,l){$.ajax({url:"https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=AIzaSyBxl9CgM0dY5lagHL4UOhEpLWE1fuwdnvc",type:"POST",data:{longDynamicLink:"https://icn3d.page.link/?link="+encodeURIComponent(e)},dataType:"json",success:function(e){n(e)},error:function(n,l,r){let o="Problem in getting shortened URL";$("#"+s.pre+"ori_url").val(e),$("#"+s.pre+"short_url").val(o),$("#"+s.pre+"short_url_title").val(o+"&t="+s.yournote),t||i.htmlCls.dialogCls.openDlg("dl_copyurl","Copy a Share Link URL")}})}))}shareLinkUrl(e){let t=this.icn3d,s=t.icn3dui,i=s.htmlCls.baseUrl+"icn3d/full.html?";if(s.cfg.bSidebyside&&(i=s.htmlCls.baseUrl+"icn3d/full2.html?"),t.bInputUrlfile){i=window.location.href.split("?")[0]+"?"+t.inputurl+"&"}let n,l={};for(let e in t.cfg){let s=t.cfg[e];"inpara"!==e&&"command"!==e&&"usepdbnum"!==e&&"date"!==e&&"v"!==e&&void 0!==s&&("width"===e&&"100%"===s||"height"===e&&"100%"===s||"resize"===e&&!0===s||"showmenu"===e&&!0===s||"showtitle"===e&&!0===s||"showcommand"===e&&!0===s||"mobilemenu"===e&&!1===s||"showanno"===e&&!1===s||"showseq"===e&&!1===s||"showalignseq"===e&&!1===s||"show2d"===e&&!1===s||"showsets"===e&&!1===s||"rotate"===e&&"right"===s||"command"!==e&&("options"===e?Object.keys(s).length>0&&(l[e]=JSON.stringify(s)):!0===s?l[e]=1:!1===s?l[e]=0:""!==s&&(l[e]=s)))}t.bAfMem?l.afmem="on":(s.cfg.afid||1==Object.keys(t.structures).length&&Object.keys(t.structures)[0].length>5)&&(l.afmem="off");let r=-1;void 0!==s.cfg.inpara&&(r=s.cfg.inpara.indexOf("&command=")),n=-1!==r?s.cfg.inpara.substr(0,r):s.cfg.inpara;let o=!1;if(!t.bInputUrlfile){let e=n&&n.substr(1)?n.substr(1).split("&"):[];for(let t=0,s=e.length;tp){u=t.commands[p].split("|||")[0].split("&command=")[0].trim(),-1!==u.indexOf(f)&&++b}let C,y=p+1,v="";for(let e=t.commands.length;y0&&b%2==0&&u!==f&&(i+=f+"; "),i+=u+"|||"+t.transformCls.getTransformationStr(m),g+=u+"|||"+t.transformCls.getTransformationStr(m)+"\n"),g=g.replace(/!/g,Object.keys(t.structures)[0]+"_"),(t.bInputfile&&!t.bInputUrlfile||t.bInputUrlfile&&t.bAppend||i.length>4e3)&&(i=g),void 0!==t.structures&&1==Object.keys(t.structures).length&&void 0!==t.inputid&&(C=Object.keys(t.structures)[0],i=i.replace(new RegExp(C+"_","g"),"!")),void 0!==s.cfg.blast_rep_id&&(i=i.replace(new RegExp("blast_rep_id=!","g"),"blast_rep_id="+C+"_")),i}getPngText(){let e,t=this.icn3d;t.icn3dui;let s="";if(t.bInputfile)e=this.shareLinkUrl(true),"http"==e.substr(0,4)?s+="\nShare Link: "+e:(s+="\nStart of type file======\n",s+=t.InputfileType+"\n",s+="End of type file======\n",s+="Start of data file======\n",s+=t.saveFileCls.getAtomPDB(t.atoms),s+="End of data file======\n",s+="Start of state file======\n",s+=e+"\n",s+="End of state file======\n");else{e=this.shareLinkUrl(),e.length>4e3||0!==e.indexOf("http")?(e=this.shareLinkUrl(true),s+="\nStart of state file======\n",s+=e+"\n",s+="End of state file======\n"):s+="\nShare Link: "+e}return s=s.replace(/!/g,Object.keys(t.structures)[0]+"_"),s}}class xs{constructor(e){this.icn3d=e}setThichknessFor3Dprint(){let e=this.icn3d,t=e.icn3dui;e.lineRadius=1,e.coilWidth=1.2,e.cylinderRadius=.8,e.crosslinkRadius=.8,e.traceRadius=1,e.dotSphereScale=.6,e.sphereRadius=1.5,e.ribbonthickness=1,e.helixSheetWidth=2,e.nucleicAcidWidth=1.4,t.htmlCls.setHtmlCls.setCookieForThickness()}prepareFor3Dprint(){let e=this.icn3d,t=e.icn3dui;if(e.bShowHighlight=!1,e.hlObjectsCls.removeHlObjects(),e.bDashedLines=!1,e.bSetThickness||void 0!==t.cfg.cid||this.setThichknessFor3Dprint(),void 0!==e.lines.hbond)for(let t=0,s=e.lines.hbond.length;tt.substr(0,s))return 1;if(e.substr(0,s)==t.substr(0,s)){if(parseInt(e.substr(s+1))parseInt(t.substr(i+1)))return 1;if(parseInt(e.substr(s+1))==parseInt(t.substr(i+1)))return 0}}})),i="";for(let e=0,t=s.length;e"}let n=e.inputid?e.inputid:"custom";e.saveFileCls.saveFile(n+"_residues.txt","html",i)}addStabilizer(){let e=this.icn3d,t=e.icn3dui,s=3.5;if(Object.keys(e.dAtoms).length>0){let i,n={},l=12.25,r=3.2*3.2;for(let t in e.dAtoms){let s=e.atoms[t];!e.nucleotides.hasOwnProperty(s.serial)||"N1"!==s.name&&"N2"!==s.name&&"N3"!==s.name&&"N4"!==s.name&&"N6"!==s.name&&"O2"!==s.name&&"O6"!==s.name||(i=s.structure+"_"+s.chain+"_"+s.resi+"_"+s.name,n[i]=s)}let o=Object.keys(n),a=o.length;void 0===e.pairArray&&(e.pairArray=[]);for(let t=0;ts)continue;let h=Math.abs(n[a].coord.y-n[d].coord.y);if(h>s)continue;let p=Math.abs(n[a].coord.z-n[d].coord.z);if(p>s)continue;let m=c*c+h*h+p*p;m>l||ms+1||rs+2||rs+4||r0&&o.length>0)if(a){let t=parseInt((r.length+.5)/2);e.pairArray.push(o[0]),e.pairArray.push(r[t])}else{let t=10,s=parseInt(r.length/(t+1));for(let i=0,n=o.length;i1&&t.bAssembly&&(t.threshbox=180/Math.pow(t.biomtMatrices.length,.33),t.applyMapCls.removeSurfaces(),t.applyMapCls.applySurfaceOptions(),t.applyMapCls.removeMaps(),t.applyMapCls.applyMapOptions(),t.applyMapCls.removeEmmaps(),t.applyMapCls.applyEmmapOptions());let s=this.saveStlFile(),i=t.inputid?t.inputid:"custom";if(t.saveFileCls.saveFile(i+e+".stl","binary",s),void 0!==t.biomtMatrices&&t.biomtMatrices.length>1&&t.bAssembly&&Object.keys(t.dAtoms).length*t.biomtMatrices.length>t.maxAtoms3DMultiFile){alert(t.biomtMatrices.length+" files will be generated for this assembly. Please merge these files using some software and 3D print the merged file.");let n=new THREE.Matrix4;n.identity();let l=1;for(let r=0;r1&&t.bAssembly&&(t.threshbox=180/Math.pow(t.biomtMatrices.length,.33),t.applyMapCls.removeSurfaces(),t.applyMapCls.applySurfaceOptions(),t.applyMapCls.removeMaps(),t.applyMapCls.applyMapOptions(),t.applyMapCls.removeEmmaps(),t.applyMapCls.applyEmmapOptions());let s=this.saveVrmlFile(),i=t.inputid?t.inputid:"custom";if(t.saveFileCls.saveFile(i+e+".wrl","text",s),void 0!==t.biomtMatrices&&t.biomtMatrices.length>1&&t.bAssembly&&Object.keys(t.dAtoms).length*t.biomtMatrices.length>t.maxAtoms3DMultiFile){alert(t.biomtMatrices.length+" files will be generated for this assembly. Please merge these files using some software and 3D print the merged file.");let i=new THREE.Matrix4;i.identity();let n=1;for(let l=0;l7e4)return alert("Please display a subset of the structure to export 3D files. Then merge the files for 3D printing..."),[""];t.threeDPrintCls.prepareFor3Dprint();let i=0;i+=this.getFaceCnt(t.mdl),i+=this.getFaceCnt(t.mdl_ghost);let n=[],l=new Uint8Array(84),r="STL file for the structure(s) ",o=Object.keys(t.structures);for(let e=0,t=o.length;e80&&(r=r.substr(0,80));for(let e=0;e<80;++e)e1&&t.bAssembly&&Object.keys(t.dAtoms).length*t.biomtMatrices.length<=t.maxAtoms3DMultiFile?this.updateArray(l,s.convertTypeCls.passInt32([i*t.biomtMatrices.length]),80):this.updateArray(l,s.convertTypeCls.passInt32([i]),80),n.push(new Blob([l],{type:"application/octet-stream"})),n=this.processStlMeshGroup(t.mdl,n,e),n=this.processStlMeshGroup(t.mdl_ghost,n,e),void 0!==t.biomtMatrices&&t.biomtMatrices.length>1&&t.bAssembly&&Object.keys(t.dAtoms).length*t.biomtMatrices.length<=t.maxAtoms3DMultiFile){let e=new THREE.Matrix4;e.identity();for(let s=0;s5e4)return alert("Please display a subset of the structure to export 3D files. Then merge the files for 3D printing..."),[""];t.threeDPrintCls.prepareFor3Dprint();let s=[];s.push("#VRML V2.0 utf8\n");let i=0,n=this.processVrmlMeshGroup(t.mdl,s,i,e);if(s=n.vrmlStrArray,i=n.vertexCnt,n=this.processVrmlMeshGroup(t.mdl_ghost,s,i,e),s=n.vrmlStrArray,i=n.vertexCnt,void 0!==t.biomtMatrices&&t.biomtMatrices.length>1&&t.bAssembly&&Object.keys(t.dAtoms).length*t.biomtMatrices.length<=t.maxAtoms3DMultiFile){let e=new THREE.Matrix4;e.identity();for(let l=0;l0?h.z=-1:h.z=1,s.cam===s.perspectiveCamera?(s.cam_z>0?h.z=-1:h.z=1,h.unproject(s.cam),s.raycaster.set(s.cam.position,h.sub(s.cam.position).normalize())):s.cam===s.orthographicCamera&&(s.cam_z>0?h.z=1:h.z=-1,h.unproject(s.cam),s.raycaster.set(h,new THREE.Vector3(0,0,-1).transformDirection(s.cam.matrixWorld)));let p=this.isIntersect(s.objects,s.mdl,t,d,c);p||(p=this.isIntersect(s.objects_ghost,s.mdl_ghost,t,d,c))}isIntersect(e,t,s,i,n){let l=this.icn3d;l.icn3dui;let r=l.raycaster.intersectObjects(e),o=!1,a=t.position;if(r.length>0){r[0].point.sub(a);let e=l.rayThreshold,t=this.getAtomsFromPosition(r[0].point,e);for(;!t&&e<10;)e+=.5,t=this.getAtomsFromPosition(r[0].point,e);t?(o=!0,l.pickpair?s&&(l.pAtomNum%2==0?l.pAtom=t:l.pAtom2=t,++l.pAtomNum):l.pAtom=t,s?l.pickingCls.showPicking(t):l.pickingCls.showPicking(t,i,n)):console.log("No atoms were found in 10 andstrom range")}return o}getAtomsFromPosition(e,t){let s,i=this.icn3d,n=i.icn3dui;for(s in null==t&&(t=1),i.dAtoms){let l=i.atoms[s];if(i.ions.hasOwnProperty(s)&&"sphere"===i.opts.ions){let s=n.parasCls.vdwRadii[l.elem.toUpperCase()];if(Math.abs(l.coord.x-e.x)-s>t)continue;if(Math.abs(l.coord.y-e.y)-s>t)continue;if(Math.abs(l.coord.z-e.z)-s>t)continue}else{if(l.coord.xe.x+t)continue;if(l.coord.ye.y+t)continue;if(l.coord.ze.z+t)continue}return l}return null}}class Rs{constructor(e){this.icn3d=e}setControl(){let e=this.icn3d,t=e.icn3dui;if(t.bNode)return;let s=this;e.WIDTH=e.container.width(),e.HEIGHT=e.container.height(),e.applyCenterCls.setWidthHeight(e.WIDTH,e.HEIGHT),e._zoomFactor=1,e.mouseChange=new THREE.Vector2(0,0),e.quaternion=new THREE.Quaternion(0,0,0,1),e.container.bind("contextmenu",(function(e){e.preventDefault()})),e.typetext=!1,$(document).bind("keyup",(function(t){16===t.keyCode&&(e.bShift=!1),17!==t.keyCode&&224!==t.keyCode&&91!==t.keyCode||(e.bCtrl=!1)})),$("input[type=text], textarea").focus((function(){e.typetext=!0})),$("input[type=text], textarea").blur((function(){e.typetext=!1})),$(document).bind("keydown",(function(s){if((s.shiftKey||16===s.keyCode)&&(e.bShift=!0),(s.ctrlKey||17===s.keyCode||224===s.keyCode||91===s.keyCode)&&(e.bCtrl=!0),!e.bControlGl&&!e.controls||e.bControlGl&&!window.controls)return;e.bStopRotate=!0;let i=e.bShift?90:5;if(!e.typetext)if(90===s.keyCode){let s={};e.bControlGl&&!t.bNode?window.cam===e.perspectiveCamera?s._zoomFactor=.9:window.cam===e.orthographicCamera&&(e._zoomFactor<.1?e._zoomFactor=.1:e._zoomFactor>1&&(e._zoomFactor=1),s._zoomFactor=.8*e._zoomFactor,s._zoomFactor<.1&&(s._zoomFactor=.1)):e.cam===e.perspectiveCamera?s._zoomFactor=.9:e.cam===e.orthographicCamera&&(e._zoomFactor<.1?e._zoomFactor=.1:e._zoomFactor>1&&(e._zoomFactor=1),s._zoomFactor=.8*e._zoomFactor,s._zoomFactor<.1&&(s._zoomFactor=.1)),s.update=!0,e.bControlGl&&!t.bNode?window.controls.update(s):e.controls.update(s),e.bRender&&e.drawCls.render()}else if(88===s.keyCode){let s={};e.bControlGl&&!t.bNode?window.cam===e.perspectiveCamera?s._zoomFactor=1.03:window.cam===e.orthographicCamera&&(e._zoomFactor>10?e._zoomFactor=10:e._zoomFactor<1&&(e._zoomFactor=1),s._zoomFactor=1.01*e._zoomFactor,s._zoomFactor>10&&(s._zoomFactor=10)):e.cam===e.perspectiveCamera?s._zoomFactor=1.03:e.cam===e.orthographicCamera&&(e._zoomFactor>10?e._zoomFactor=10:e._zoomFactor<1&&(e._zoomFactor=1),s._zoomFactor=1.01*e._zoomFactor,s._zoomFactor>10&&(s._zoomFactor=10)),s.update=!0,e.bControlGl&&!t.bNode?window.controls.update(s):e.controls.update(s),e.bRender&&e.drawCls.render()}else if(76===s.keyCode){let t=new THREE.Vector3(0,1,0),s=-i/180*Math.PI;e.transformCls.setRotation(t,s)}else if(74===s.keyCode){let t=new THREE.Vector3(0,1,0),s=i/180*Math.PI;e.transformCls.setRotation(t,s)}else if(73===s.keyCode){let t=new THREE.Vector3(1,0,0),s=-i/180*Math.PI;e.transformCls.setRotation(t,s)}else if(77===s.keyCode){let t=new THREE.Vector3(1,0,0),s=i/180*Math.PI;e.transformCls.setRotation(t,s)}else 65===s.keyCode&&Object.keys(e.structures).length>1&&e.alternateCls.alternateWrapper()})),e.container.bind("mouseup",(function(t){e.isDragging=!1})),e.container.bind("touchend",(function(t){e.isDragging=!1})),e.container.bind("mousedown",(function(s){if(e.isDragging=!0,e.scene){if(e.bStopRotate=!0,e.pk&&(s.altKey||s.ctrlKey||s.shiftKey||18===s.keyCode||16===s.keyCode||17===s.keyCode||224===s.keyCode||91===s.keyCode)){e.highlightlevel=e.pk;let t=!0;e.rayCls.rayCaster(s,t)}e.bControlGl&&!t.bNode?(window.controls.handleResize(),window.controls.update()):(e.controls.handleResize(),e.controls.update()),e.bRender&&e.drawCls.render()}})),e.container.bind("touchstart",(function(s){if(s.preventDefault(),e.isDragging=!0,!e.scene)return;e.bStopRotate=!0,$("#"+e.pre+"popup").hide();e.rayCls.rayCaster(s,!0),e.bControlGl&&!t.bNode?(window.controls.handleResize(),window.controls.update()):(e.controls.handleResize(),e.controls.update()),e.bRender&&e.drawCls.render()})),e.container.bind("mousemove touchmove",(function(e){s.mouseMove(e)})),e.container.bind("mousewheel",(function(s){s.preventDefault(),e.scene&&(e.bStopRotate=!0,e.bControlGl&&!t.bNode?(window.controls.handleResize(),window.controls.update()):(e.controls.handleResize(),e.controls.update()),e.bRender&&e.drawCls.render())})),e.container.bind("DOMMouseScroll",(function(s){s.preventDefault(),e.scene&&(e.bStopRotate=!0,e.bControlGl&&!t.bNode?(window.controls.handleResize(),window.controls.update()):(e.controls.handleResize(),e.controls.update()),e.bRender&&e.drawCls.render())}))}mouseMove(e){let t=this.icn3d,s=t.icn3dui;if(s.bNode)return;if(e.preventDefault(),!t.scene)return;$("#"+t.pre+"popup").hide();if(t.rayCls.rayCaster(e,!1),t.bControlGl&&!s.bNode){window.controls.handleResize(),window.controls.update();for(let e in window.icn3duiHash){let t=window.icn3duiHash[e].icn3d;t.bRender&&t.drawCls.render()}}else t.controls.handleResize(),t.controls.update(),t.bRender&&t.drawCls.render()}}class Es{constructor(e){this.icn3d=e}showPicking(e,t,s){let i=this.icn3d,n=i.icn3dui;if(void 0!==n.cfg.cid&&0!=i.pk&&(i.pk=1),i.highlightlevel=i.pk,this.showPickingBase(e,t,s),0!=i.pk)if(void 0!==t&&void 0!==s){null!=n.cfg.showmenu&&1==n.cfg.showmenu&&(s+=n.htmlCls.MENU_HEIGHT);let l=1==i.pk?e.resn+e.resi+"@"+e.name:e.resn+e.resi;void 0!==i.structures&&Object.keys(i.structures).length>1?(l=e.structure+"_"+e.chain+" "+l,$("#"+i.pre+"popup").css("width","160px")):$("#"+i.pre+"popup").css("width","80px"),$("#"+i.pre+"popup").html(l),$("#"+i.pre+"popup").css("top",s).css("left",t+20).show()}else{i.hlUpdateCls.updateHlAll();let t={};t.factor=i._zoomFactor,t.mouseChange=i.mouseChange,t.quaternion={},t.quaternion._x=parseFloat(i.quaternion._x).toPrecision(5),t.quaternion._y=parseFloat(i.quaternion._y).toPrecision(5),t.quaternion._z=parseFloat(i.quaternion._z).toPrecision(5),t.quaternion._w=parseFloat(i.quaternion._w).toPrecision(5),n.htmlCls.clickMenuCls.setLogCmd("pickatom "+e.serial,!0),i.selectionCls.saveSelInCommand(),i.bSphereCalc=!1,i.bHbondCalc=!1}}showPickingBase(e,t,s){this.icn3d.icn3dui,void 0===t&&void 0===s&&this.showPickingHilight(e)}showPickingHilight(e){let t=this.icn3d,s=t.icn3dui;if(t.bShift||t.bCtrl||t.hlObjectsCls.removeHlObjects(),t.pickedAtomList={},1===t.pk)t.pickedAtomList[e.serial]=1;else if(2===t.pk){let s=e.structure+"_"+e.chain+"_"+e.resi;t.pickedAtomList=t.residues[s]}else if(3===t.pk)t.pickedAtomList=this.selectStrandHelixFromAtom(e);else if(4===t.pk)t.pickedAtomList=this.select3ddomainFromAtom(e);else if(5===t.pk){let s=e.structure+"_"+e.chain;t.pickedAtomList=t.chains[s]}0===t.pk?t.bShowHighlight=!1:t.bShowHighlight=!0;let i=Object.keys(t.hAtoms).length==Object.keys(t.atoms).length?{}:s.hashUtilsCls.intHash(t.hAtoms,t.pickedAtomList),n=Object.keys(i).length;if(t.bShift||t.bCtrl)if(t.bShift){if(void 0===t.prevPickedAtomList)t.hAtoms=s.hashUtilsCls.unionHash(t.hAtoms,t.pickedAtomList);else{let e=t.firstAtomObjCls.getFirstAtomObj(t.prevPickedAtomList),i=t.firstAtomObjCls.getFirstAtomObj(t.pickedAtomList);if(e.structure+"_"+e.chain!=i.structure+"_"+i.chain)t.hAtoms=s.hashUtilsCls.unionHash(t.hAtoms,t.pickedAtomList);else{let e;e=s.hashUtilsCls.unionHash(e,t.prevPickedAtomList),e=s.hashUtilsCls.unionHash(e,t.pickedAtomList);let i=t.firstAtomObjCls.getFirstAtomObj(e),n=t.firstAtomObjCls.getLastAtomObj(e);for(let e=i.serial;e<=n.serial;++e)t.hAtoms[e]=1}}t.prevPickedAtomList=s.hashUtilsCls.cloneHash(t.pickedAtomList)}else t.bCtrl&&(t.hAtoms=n>0?s.hashUtilsCls.exclHash(t.hAtoms,t.pickedAtomList):s.hashUtilsCls.unionHash(t.hAtoms,t.pickedAtomList));else t.hAtoms=s.hashUtilsCls.cloneHash(t.pickedAtomList);t.hlObjectsCls.removeHlObjects(),t.hlObjectsCls.addHlObjects()}select3ddomainFromAtom(e){let t,s=this.icn3d,i=s.icn3dui,n=e.structure+"_"+e.chain,l=n+"_"+e.resi;for(let e in s.tddomains){let i=e.indexOf("_3d_domain");if(e.substr(0,i)==n&&-1!==Object.keys(s.tddomains[e]).indexOf(l)){t=e;break}}let r={};for(let e in s.tddomains[t])r=i.hashUtilsCls.unionHash(r,s.residues[e]);return r}selectStrandHelixFromAtom(e){let t=this.icn3d,s=t.icn3dui,i=e,n=e,l={},r=i.resi;if(!i.ssbegin&&!isNaN(i.resi)){for(let e=i.resi-1;e>0;--e){let s=i.structure+"_"+i.chain+"_"+e;if(!t.residues.hasOwnProperty(s))break;let n=t.firstAtomObjCls.getFirstCalphaAtomObj(t.residues[s]);if(r=n.resi,"coil"!==i.ss&&n.ss===i.ss&&n.ssbegin||"coil"===i.ss&&n.ss!==i.ss){"coil"===i.ss&&n.ss!==i.ss&&(r=parseInt(n.resi)+1);break}}for(let e=r;e<=i.resi;++e){let n=i.structure+"_"+i.chain+"_"+e;l=s.hashUtilsCls.unionHash(l,s.hashUtilsCls.hash2Atoms(t.residues[n],t.atoms))}}let o=n.resi,a=t.firstAtomObjCls.getLastAtomObj(t.chains[n.structure+"_"+n.chain]).resi;for(let e=parseInt(n.resi)+1;e<=parseInt(a);++e){let s=n.structure+"_"+n.chain+"_"+e;if(!t.residues.hasOwnProperty(s))break;let i=t.firstAtomObjCls.getFirstCalphaAtomObj(t.residues[s]);if(o=i.resi,"coil"!==n.ss&&i.ss===n.ss&&i.ssend||"coil"===n.ss&&i.ss!==n.ss){"coil"!==n.ss||i.ss===n.ss||isNaN(i.resi)||(o=i.resi-1);break}}for(let e=parseInt(n.resi)+1;e<=parseInt(o);++e){let i=n.structure+"_"+n.chain+"_"+e;l=s.hashUtilsCls.unionHash(l,s.hashUtilsCls.hash2Atoms(t.residues[i],t.atoms))}return l}}class Is{constructor(e){this.icn3d=e,this.xrSessionIsGranted=!1}createButton(e,t){let s=this.icn3d,i=s.icn3dui;t&&console.error('THREE.VRButton: The "options" parameter has been removed. Please set the reference space type via renderer.xr.setReferenceSpaceType() instead.');const n=document.createElement("button");function l(){n.style.display="",n.style.cursor="auto",n.style.left="calc(33% - 75px)",n.style.width="150px",n.onmouseenter=null,n.onmouseleave=null,n.onclick=null}let r=this;if("xr"in navigator)return n.id=i.pre+"VRButton",n.style.display="none",(o=n).style.position="absolute",o.style.bottom="20px",o.style.padding="12px 6px",o.style.border="1px solid #fff",o.style.borderRadius="4px",o.style.background="#000",o.style.color="#f8b84e",o.style.font="bold 13px sans-serif",o.style.textAlign="center",o.style.opacity="0.8",o.style.outline="none",o.style.zIndex="999",navigator.xr.isSessionSupported("immersive-vr").then((function(t){t?function(){let t=null;async function i(s){s.addEventListener("end",l),await e.xr.setSession(s),n.textContent="EXIT VR",t=s}function l(){s.transformCls.resetOrientation(),s.bVr=!1,s.drawCls.draw(),t.removeEventListener("end",l),n.textContent="ENTER VR",t=null}n.style.display="",n.style.cursor="pointer",n.style.left="calc(33% - 50px)",n.style.width="100px",n.textContent="ENTER VR",n.onmouseenter=function(){n.style.opacity="1.0"},n.onmouseleave=function(){n.style.opacity="0.8"},n.onclick=function(){if(s.bImpo=!1,s.bVr=!0,s.drawCls.draw(s.bVr),null===t){const e={optionalFeatures:["local-floor","bounded-floor","hand-tracking","layers"]};navigator.xr.requestSession("immersive-vr",e).then(i)}else t.end()}}():(l(),n.style.display="none"),t&&r.xrSessionIsGranted&&n.click()})).catch((function(e){l(),console.warn("Exception when trying to call xr.isSessionSupported",e),n.style.display="none"})),n;return document.createElement("span");var o}registerSessionGrantedListener(){"xr"in navigator&&navigator.xr.addEventListener("sessiongranted",(()=>{this.xrSessionIsGranted=!0}))}}class Ts{constructor(e){this.icn3d=e,this.xrSessionIsGranted=!1}createButton(e,t={}){let s=this.icn3d,i=s.icn3dui;const n=document.createElement("button");function l(){n.style.display="",n.style.cursor="auto",n.style.left="calc(66% - 50px)",n.style.width="150px",n.onmouseenter=null,n.onmouseleave=null,n.onclick=null}function r(e){e.style.position="absolute",e.style.bottom="20px",e.style.padding="12px 6px",e.style.border="1px solid #fff",e.style.borderRadius="4px",e.style.background="#000",e.style.color="#f8b84e",e.style.font="bold 13px sans-serif",e.style.textAlign="center",e.style.opacity="0.8",e.style.outline="none",e.style.zIndex="999"}if(i.utilsCls.isAndroid()&&i.utilsCls.isChrome()){if("xr"in navigator)return n.id=i.pre+"ARButton",n.style.display="none",r(n),navigator.xr.isSessionSupported("immersive-ar").then((function(i){i?function(){if(void 0===t.domOverlay){const e=document.createElement("div");e.style.display="none",document.body.appendChild(e);const s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("width",38),s.setAttribute("height",38),s.style.position="absolute",s.style.right="20px",s.style.top="20px",s.addEventListener("click",(function(){i.end()})),e.appendChild(s);const n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d","M 12,12 L 28,28 M 28,12 12,28"),n.setAttribute("stroke","#fff"),n.setAttribute("stroke-width",2),s.appendChild(n),void 0===t.optionalFeatures&&(t.optionalFeatures=[]),t.optionalFeatures.push("dom-overlay"),t.domOverlay={root:e}}let i=null;async function l(s){s.addEventListener("end",r),e.xr.setReferenceSpaceType("local"),await e.xr.setSession(s),n.textContent="STOP AR",t.domOverlay.root.style.display="",i=s}function r(){s.transformCls.resetOrientation(),s.bAr=!1,s.drawCls.draw(),i.removeEventListener("end",r),n.textContent="START AR",t.domOverlay.root.style.display="none",i=null}n.style.display="",n.style.cursor="pointer",n.style.left="calc(66% - 50px)",n.style.width="100px",n.textContent="START AR",n.onmouseenter=function(){n.style.opacity="1.0"},n.onmouseleave=function(){n.style.opacity="0.8"},n.onclick=function(){s.bImpo=!1,s.opts.background="transparent",s.bAr=!0,s.drawCls.draw(s.bAr),null===i?navigator.xr.requestSession("immersive-ar",t).then(l):i.end()}}():(l(),n.style.display="none")})).catch((function(e){l(),console.warn("Exception when trying to call xr.isSessionSupported",e),n.style.display="none"})),n;return document.createElement("span")}return n.id=i.pre+"ARButton",n.style.display="none",r(n),l(),n.style.display="none",n}}class Ms{constructor(e){let t,s,i,n=e;if(this.icn3dui=e,this.id=this.icn3dui.pre+"canvas",this.pre=this.icn3dui.pre,this.container=$("#"+this.id),this.oriContainer=$("#"+this.id),this.bControlGl=!1,this.maxatomcnt=1e5,this.overdraw=0,this.bDrawn=!1,this.bOpm=!1,this.crossstrucinter=0,this.bSecondaryStructure=!1,this.bHighlight=1,this.renderOrderPicking=-1,this.bInitial=!0,this.bDoublecolor=!1,this.originSize=1,this.ALTERNATE_STRUCTURE=-1,this.bUsePdbNum=!0,!this.icn3dui.bNode){let e=document.createElement("canvas");t=!(!window.WebGLRenderingContext||!e.getContext("webgl")&&!e.getContext("experimental-webgl")),e.remove(),e=document.createElement("canvas"),s=!(!window.WebGLRenderingContext||!e.getContext("webgl2")),e.remove(),i="xr"in navigator,t?(s&&i?(this.renderer=new THREE.WebGLRenderer({canvas:this.oriContainer.get(0),antialias:!0,preserveDrawingBuffer:!0,sortObjects:!1,alpha:!0}),this.renderer.xr.enabled=!0):this.renderer=new THREE.WebGL1Renderer({canvas:this.oriContainer.get(0),antialias:!0,preserveDrawingBuffer:!0,sortObjects:!1,alpha:!0}),this.overdraw=0):alert("Currently your web browser has a problem on WebGL. If you are using Chrome, open a new tab for the same URL and WebGL may work again.")}this.frac=new THREE.Color(.1,.1,.1),this.shininess=40,this.emissive=1118481,this.light1=.6,this.light2=.4,this.light3=.2,this.lineRadius=.1,this.coilWidth=.3,this.cylinderRadius=.4,this.crosslinkRadius=.4,this.traceRadius=.4,this.dotSphereScale=.3,this.sphereRadius=1.5,this.cylinderHelixRadius=1.6,this.ribbonthickness=.2,this.helixSheetWidth=1.3,this.nucleicAcidWidth=.8,this.scaleFactor=1,this.labelScale=1,this.resizeRatioX=1,this.resizeRatioY=1,this.bImpo=!0,this.bInstanced=!0,this.chainMissingResidueArray={},this._zoomFactor=1,this.transparentRenderOrder=!1,this.AFUniprotVersion="v4",this.defaultPdbId="stru",this.icn3dui.bNode||(s&&i?(this.bExtFragDepth=!0,this.bImpo=!0,this.bInstanced=!0):(this.bExtFragDepth=this.renderer.extensions.get("EXT_frag_depth"),this.bExtFragDepth?console.log("EXT_frag_depth is supported. All spheres and cylinders are drawn using shaders."):(this.bImpo=!1,console.log("EXT_frag_depth is NOT supported. All spheres and cylinders are drawn using geometry.")),this.bInstanced=this.renderer.extensions.get("ANGLE_instanced_arrays"),this.bInstanced?console.log("ANGLE_instanced_arrays is supported. Assembly is drawn with one copy of the asymmetric unit using hardware instancing."):console.log("ANGLE_instanced_arrays is NOT supported. Assembly is drawn by making copies of the asymmetric unit."))),this.posArray=new Array,this.colorArray=new Array,this.pos2Array=new Array,this.color2Array=new Array,this.radiusArray=new Array,this.posArraySphere=new Array,this.colorArraySphere=new Array,this.radiusArraySphere=new Array,this.axis=!1,this.pk=1,this.highlightlevel=1,this.pickpair=!1,this.pAtomNum=0,this.pAtom=void 0,this.pAtom2=void 0,this.bCtrl=!1,this.bShift=!1,this.bStopRotate=!1,this.bCalphaOnly=!1,this.bConsiderNeighbors=!1,this.bShowCrossResidueBond=!0,this.bExtrude=!0,this.effects={none:this.renderer},this.maxD=500,this.oriMaxD=this.maxD,this.cam_z=2*this.maxD,this.commands=[],this.optsHistory=[],this.logs=[],this.bRender=!0,this.hColor=new THREE.Color(16777011),this.sphereGeometry=new THREE.SphereGeometry(1,32,32),this.boxGeometry=new THREE.BoxGeometry(1,1,1),this.cylinderGeometry=new THREE.CylinderGeometry(1,1,1,32,1),this.cylinderGeometryOutline=new THREE.CylinderGeometry(1,1,1,32,1,!0),this.axisDIV=15,this.strandDIV=6,this.tubeDIV=8,this.nucleicAcidStrandDIV=6,this.linewidth=1,this.hlLineRadius=.1,this.threshbox=180,this.maxAtoms3DMultiFile=4e4,this.tsHbond=3.8,this.tsIonic=6,this.tsContact=4,this.tsHalogen=3.8,this.tsPication=6,this.tsPistacking=5.5,this.LABELSIZE=30,this.rayThreshold=.5,this.colorBlackbkgd="#ffff00",this.colorWhitebkgd="#000000",this.optsOri={},this.optsOri.camera="perspective",this.optsOri.background="black",this.optsOri.color="chain",this.optsOri.proteins="ribbon",this.optsOri.sidec="nothing",this.optsOri.nucleotides="nucleotide cartoon",this.optsOri.ntbase="nothing",this.optsOri.surface="nothing",this.optsOri.opacity="1.0",this.optsOri.wireframe="no",this.optsOri.map="nothing",this.optsOri.mapwireframe="yes",this.optsOri.emmap="nothing",this.optsOri.emmapwireframe="yes",this.optsOri.phimap="nothing",this.optsOri.phimapwireframe="yes",this.optsOri.phisurface="nothing",this.optsOri.phisurftype="nothing",this.optsOri.phisurfop="1.0",this.optsOri.phisurfwf="yes",this.optsOri.chemicals="stick",this.optsOri.water="nothing",this.optsOri.ions="sphere",this.optsOri.hbonds="no",this.optsOri.saltbridge="no",this.optsOri.contact="no",this.optsOri.halogen="no",this.optsOri["pi-cation"]="no",this.optsOri["pi-stacking"]="no",this.optsOri.ssbonds="yes",this.optsOri.clbonds="yes",this.optsOri.rotationcenter="molecule center",this.optsOri.axis="no",this.optsOri.fog="no",this.optsOri.slab="no",this.optsOri.pk="residue",this.optsOri.chemicalbinding="hide",this.opts=n.hashUtilsCls.cloneHash(this.optsOri),this.sheetcolor="green",this.bShowHighlight=!0,this.mapData={},this.bFullUi=!0,this.divid=this.icn3dui.cfg.divid,this.inputid="",this.setOperation="or",this.ROT_DIR="right",this.currSelectedSets=[],this.selectedResidues={},this.ncbi2resid={},this.resid2ncbi={},this.shapeCmdHash={},this.bHideSelection=!0,this.bSelectResidue=!1,this.bSelectAlignResidue=!1,this.bAnnoShown=!1,this.bSetChainsAdvancedMenu=!1,this.b2DShown=!1,this.bCrashed=!1,this.bAddCommands=!0,this.bAddLogs=!0,this.bNotLoadStructure=!1,this.InputfileData="",this.bVr=!1,this.bAr=!1,this.startColor="blue",this.midColor="white",this.endColor="red",this.startValue=0,this.midValue=50,this.endValue=100,this.crosslinkRadius=.4,this.sceneCls=new Ee(this),this.cameraCls=new Ie(this),this.fogCls=new Te(this),this.boxCls=new Me(this),this.brickCls=new Pe(this),this.curveStripArrowCls=new De(this),this.curveCls=new He(this),this.cylinderCls=new Fe(this),this.lineCls=new Le(this),this.reprSubCls=new Ne(this),this.sphereCls=new Ue(this),this.stickCls=new qe(this),this.strandCls=new $e(this),this.stripCls=new je(this),this.tubeCls=new Be(this),this.cartoonNuclCls=new ze(this),this.surfaceCls=new Je(this),this.labelCls=new Ve(this),this.axesCls=new We(this),this.glycanCls=new Ye(this),this.applyCenterCls=new Ze(this),this.applyClbondsCls=new et(this),this.applyDisplayCls=new tt(this),this.applyMapCls=new lt(this),this.applyOtherCls=new st(this),this.applySsbondsCls=new it(this),this.applySymdCls=new nt(this),this.hlObjectsCls=new Dt(this),this.residueLabelsCls=new rt(this),this.alternateCls=new dt(this),this.drawCls=new ct(this),this.firstAtomObjCls=new hs(this),this.impostorCls=new ot(this),this.instancingCls=new at(this),this.contactCls=new ht(this),this.hBondCls=new pt(this),this.piHalogenCls=new mt(this),this.saltbridgeCls=new ut(this),this.loadPDBCls=new is(this),this.vastplusCls=new ns(this),this.transformCls=new _s(this),this.setStyleCls=new gt(this),this.setColorCls=new ft(this),this.threeDPrintCls=new xs(this),this.export3DCls=new ks(this),this.annoCddSiteCls=new yt(this),this.annoContactCls=new vt(this),this.annoPTMCls=new wt(this),this.annoCrossLinkCls=new _t(this),this.annoDomainCls=new St(this),this.annoSnpClinVarCls=new At(this),this.annoSsbondCls=new xt(this),this.annoTransMemCls=new kt(this),this.domain3dCls=new Ot(this),this.addTrackCls=new Rt(this),this.annotationCls=new Et(this),this.showAnnoCls=new It(this),this.showSeqCls=new Tt(this),this.hlSeqCls=new Mt(this),this.hlUpdateCls=new Pt(this),this.lineGraphCls=new Ht(this),this.getGraphCls=new Ft(this),this.showInterCls=new Lt(this),this.viewInterPairsCls=new Nt(this),this.drawGraphCls=new Ut(this),this.contactMapCls=new qt(this),this.alignParserCls=new $t(this),this.chainalignParserCls=new jt(this),this.dsn6ParserCls=new Bt(this),this.mmcifParserCls=new zt(this),this.mmdbParserCls=new Gt(this),this.mmtfParserCls=new Vt(this),this.mol2ParserCls=new Wt(this),this.opmParserCls=new Yt(this),this.pdbParserCls=new Xt(this),this.sdfParserCls=new Kt(this),this.xyzParserCls=new Qt(this),this.realignParserCls=new Jt(this),this.densityCifParserCls=new Zt(this),this.ParserUtilsCls=new es(this),this.loadAtomDataCls=new ts(this),this.setSeqAlignCls=new ss(this),this.applyCommandCls=new ls(this),this.definedSetsCls=new rs(this),this.legendTableCls=new Ct(this),this.loadScriptCls=new os(this),this.selByCommCls=new as(this),this.selectionCls=new ds(this),this.resid2specCls=new cs(this),this.delphiCls=new ps(this),this.dsspCls=new ms(this),this.refnumCls=new us(this),this.scapCls=new gs(this),this.symdCls=new fs(this),this.alignSWCls=new bs(this),this.analysisCls=new Cs(this),this.resizeCanvasCls=new ws(this),this.saveFileCls=new Ss(this),this.setOptionCls=new bt(this),this.shareLinkCls=new As(this),this.diagram2dCls=new ys(this),this.cartoon2dCls=new vs(this),this.rayCls=new Os(this),this.controlCls=new Rs(this),this.pickingCls=new Es(this),this.VRButtonCls=new Is(this),this.ARButtonCls=new Ts(this),this.matShader=this.setColorCls.setOutlineColor("yellow")}}Ms.prototype.init=function(e){this.init_base(),this.molTitle="",this.ssbondpnts={},this.clbondpnts={},this.biomtMatrices=[],this.bAssembly=!0,this.bDrawn=!1,this.bSecondaryStructure=!1,this.bHighlight=1,this.axes=[]},Ms.prototype.init_base=function(e){this.resetConfig(),this.structures={},this.chains={},this.tddomains={},this.residues={},this.secondaries={},this.alnChains={},this.chainsSeq={},this.chainsColor={},this.chainsGene={},this.chainsAn={},this.chainsAnTitle={},this.chainsMapping={},this.resid2refnum={},this.residIgLoop={},this.refnum2residArray={},this.bShowRefnum=!1,this.alnChainsSeq={},this.alnChainsAnno={},this.alnChainsAnTtl={},this.pickedAtomList={},this.prevHighlightObjects=[],this.prevHighlightObjects_ghost=[],this.prevSurfaces=[],this.prevMaps=[],this.prevEmmaps=[],this.prevPhimaps=[],this.prevOtherMesh=[],this.defNames2Residues={},this.defNames2Atoms={},this.defNames2Descr={},this.defNames2Command={},this.residueId2Name={},this.atoms={},this.dAtoms={},this.hAtoms={},this.proteins={},this.sidec={},this.ntbase={},this.nucleotides={},this.nucleotidesO3={},this.chemicals={},this.ions={},this.water={},this.calphas={},this.hbondpnts=[],this.saltbridgepnts=[],this.contactpnts=[],this.stabilizerpnts=[],this.halogenpnts=[],this.picationpnts=[],this.pistackingpnts=[],this.distPnts=[],this.doublebonds={},this.triplebonds={},this.aromaticbonds={},this.atomPrevColors={},this.style2atoms={},this.labels={},this.lines={},this.resids2inter={},this.resids2interAll={},this.transformCls.rotateCount=0,this.transformCls.rotateCountMax=20,e&&(this.commands=[]),this.axes=[],this.bGlycansCartoon=0,this.bMembrane=1,this.bCmdWindow=0,this.chainMissingResidueArray={},this.nTotalGap=0},Ms.prototype.reinitAfterLoad=function(){let e=this,t=e.icn3dui;e.resetConfig(),e.setStyleCls.setAtomStyleByOptions(),e.setColorCls.setColorByOptions(e.opts,e.atoms),e.dAtoms=t.hashUtilsCls.cloneHash(e.atoms),e.hAtoms=t.hashUtilsCls.cloneHash(e.atoms),e.prevHighlightObjects=[],e.prevHighlightObjects_ghost=[],e.prevSurfaces=[],e.prevMaps=[],e.prevEmmaps=[],e.prevPhimaps=[],e.prevOtherMesh=[],e.labels={},e.lines={},e.shapeCmdHash={},e.bAssembly=!0},Ms.prototype.resetConfig=function(){let e=this,t=e.icn3dui;if(this.opts=t.hashUtilsCls.cloneHash(this.optsOri),void 0===t.cfg.align&&void 0===t.cfg.chainalign||(this.opts.color="identity",this.opts.proteins="c alpha trace",this.opts.nucleotides="o3 trace"),void 0!==t.cfg.cid&&(this.opts.color="atom",this.opts.pk="atom",this.opts.chemicals="ball and stick"),void 0!==t.cfg.afid&&(this.opts.color="confidence"),void 0!==t.cfg.blast_rep_id&&(this.opts.color="conservation"),void 0!==t.cfg.mmdbafid){let s=t.cfg.mmdbafid.split(",");if(s.length>1)e.opts.color="structure";else if(1==s.length){let t=s[0];isNaN(t)&&t.length>5?this.opts.color="confidence":e.opts.color="chain"}}void 0!==t.cfg.options&&$.extend(this.opts,t.cfg.options)};class Ps{constructor(e){this.cfg=e,this.pre=this.cfg.divid+"_",this.REVISION="3.23.2",this.bNode=Object.keys(window).length<2,void 0===this.cfg.command&&(this.cfg.command=""),void 0===this.cfg.width&&(this.cfg.width="100%"),void 0===this.cfg.height&&(this.cfg.height="100%"),void 0===this.cfg.resize&&(this.cfg.resize=!0),void 0===this.cfg.showmenu&&(this.cfg.showmenu=!0),void 0===this.cfg.showtitle&&(this.cfg.showtitle=!0),void 0===this.cfg.showcommand&&(this.cfg.showcommand=!0),void 0===this.cfg.mobilemenu&&(this.cfg.mobilemenu=!1),void 0===this.cfg.closepopup&&(this.cfg.closepopup=!1),void 0===this.cfg.showanno&&(this.cfg.showanno=!1),void 0===this.cfg.showseq&&(this.cfg.showseq=!1),void 0===this.cfg.showalignseq&&(this.cfg.showalignseq=!1),void 0===this.cfg.show2d&&(this.cfg.show2d=!1),void 0===this.cfg.showsets&&(this.cfg.showsets=!1),void 0===this.cfg.rotate&&(this.cfg.rotate="right"),void 0===this.cfg.hidelicense&&(this.cfg.hidelicense=!1),this.hashUtilsCls=new t(this),this.utilsCls=new s(this),this.parasCls=new i(this),this.myEventCls=new n(this),this.rmsdSuprCls=new l(this),this.subdivideCls=new r(this),this.convertTypeCls=new o(this),this.htmlCls=new g(this)}allCustomEvents(){}}Ps.prototype.show3DStructure=async function(e){let t=this;t.cfg.menuicon?(t.htmlCls.wifiStr=' ',t.htmlCls.licenseStr=' '):(t.htmlCls.wifiStr="",t.htmlCls.licenseStr=""),t.setIcn3d();let s=t.icn3d;t.utilsCls.isSessionStorageSupported()&&s.setStyleCls.getCommandsBeforeCrash();let i=t.htmlCls.WIDTH,n=t.htmlCls.HEIGHT;t.oriWidth=i,t.oriHeight=n,t.htmlCls.eventsCls.allEventFunctions(),this.allCustomEvents();let l=0;if((null==t.cfg.showmenu||t.cfg.showmenu)&&(l+=t.htmlCls.MENU_HEIGHT),(null==t.cfg.showcommand||t.cfg.showcommand)&&(l+=t.htmlCls.CMD_HEIGHT),null!=t.cfg.showmenu&&0==t.cfg.showmenu?t.htmlCls.setMenuCls.hideMenu():t.htmlCls.setMenuCls.showMenu(),null!=t.cfg.showtitle&&0==t.cfg.showtitle?$("#"+s.pre+"title").hide():$("#"+s.pre+"title").show(),$("#"+s.pre+"viewer").width(i).height(parseInt(n)+l),$("#"+s.pre+"canvas").width(i).height(parseInt(n)),$("#"+s.pre+"canvas").resizable({resize:function(e,i){t.htmlCls.WIDTH=i.size.width,t.htmlCls.HEIGHT=i.size.height,void 0===s||t.icn3d.bFullscreen||s.resizeCanvasCls.resizeCanvas(t.htmlCls.WIDTH,t.htmlCls.HEIGHT,!0)}}),void 0!==t.cfg.usepdbnum?t.icn3d.bUsePdbNum=t.cfg.usepdbnum:void 0!==t.cfg.date?t.icn3d.bUsePdbNum=parseInt(t.cfg.date)>=20201222:"1tup"==t.cfg.mmdbid&&1==t.cfg.showanno&&1==t.cfg.show2d&&1==t.cfg.showsets||"118496"==t.cfg.mmdbid&&0==t.cfg.showanno&&-1!=t.cfg.inpara.indexOf("bu=1")||"163605,1,91105,1,1,1"==t.cfg.align&&-1!=t.cfg.inpara.indexOf("atype=1")?t.icn3d.bUsePdbNum=!1:t.icn3d.bUsePdbNum=!0,t.cfg.replay?(s.bReplay=1,$("#"+s.pre+"replay").show()):(s.bReplay=0,$("#"+s.pre+"replay").hide()),t.utilsCls.isMobile()&&(s.threshbox=60),t.cfg.controlGl&&(s.bControlGl=!0,s.container=s.bControlGl&&!t.bNode?$(document):$("#"+s.id)),s.setStyleCls.handleContextLost(),s.applyCenterCls.setWidthHeight(i,n),s.ori_chemicalbinding=s.opts.chemicalbinding,void 0!==t.cfg.bCalphaOnly&&(s.bCalphaOnly=t.cfg.bCalphaOnly),s.opts=t.hashUtilsCls.cloneHash(s.opts),s.STATENUMBER=s.commands.length,t.utilsCls.isSessionStorageSupported()&&s.bCrashed){s.bCrashed=!1;let e=s.commandsBeforeCrash.split("|||")[0],i=e.substr(e.lastIndexOf(" ")+1);if(i===t.cfg.mmtfid||i===t.cfg.pdbid||i===t.cfg.opmid||i===t.cfg.mmdbid||i===t.cfg.gi||i===t.cfg.blast_rep_id||i===t.cfg.cid||i===t.cfg.mmcifid||i===t.cfg.align||i===t.cfg.chainalign||i===t.cfg.mmdbafid)return void await s.loadScriptCls.loadScript(s.commandsBeforeCrash,!0)}if(s.molTitle="",s.loadCmd,t.htmlCls.clickMenuCls.getHiddenMenusFromCache(),t.htmlCls.clickMenuCls.applyShownMenus(),e){if(s.init(),s.bInputfile=!0,s.InputfileType="pdb",s.InputfileData=s.InputfileData?s.InputfileData+"\nENDMDL\n"+e:e,await s.pdbParserCls.loadPdbData(e),void 0!==t.cfg.resdef&&void 0!==t.cfg.chains){let e=Object.keys(s.structures),i=t.cfg.chains.split(" | "),n=[];if(e.length==i.length){for(let t=0,s=e.length;t0&&(l+=","),l+=n[e].substr(0,n[e].indexOf("_"));s.chainidArray=[e].concat(n),s.chainidArray=s.chainalignParserCls.addPostfixForChainids(s.chainidArray),t.htmlCls.clickMenuCls.setLogCmd("resdef "+t.cfg.resdef,!0),s.loadCmd="vast_search_chainid "+s.chainidArray,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),s.bMmdbafid=!0;let r=!0;await s.chainalignParserCls.downloadMmdbAf(l,r)}}else if(void 0!==t.cfg.url){s.bInputUrlfile=!0;let e=t.cfg.url.split("|"),i=e[0],n=e[1];s.molTitle="",s.inputid=n,s.inputurl="type="+i+"&url="+encodeURIComponent(n),s.loadCmd="load url "+n+" | type "+i,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.pdbParserCls.downloadUrl(n,i,t.cfg.command)}else if(void 0!==t.cfg.mmtfid)s.inputid=t.cfg.mmtfid,s.loadCmd="load mmtf "+t.cfg.mmtfid,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.mmtfParserCls.downloadMmtf(t.cfg.mmtfid);else if(void 0!==t.cfg.pdbid)s.inputid=t.cfg.pdbid,s.loadCmd="load pdb "+t.cfg.pdbid,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.pdbParserCls.downloadPdb(t.cfg.pdbid);else if(void 0!==t.cfg.afid){s.inputid=t.cfg.afid,s.loadCmd="load af "+t.cfg.afid,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0);let e=!0;await s.pdbParserCls.downloadPdb(t.cfg.afid,e)}else if(void 0!==t.cfg.opmid)s.inputid=t.cfg.opmid,s.loadCmd="load opm "+t.cfg.opmid,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.opmParserCls.downloadOpm(t.cfg.opmid);else if(void 0!==t.cfg.mmdbid)s.inputid=t.cfg.mmdbid,s.loadCmd="load mmdb "+t.cfg.mmdbid+" | parameters "+t.cfg.inpara,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.mmdbParserCls.downloadMmdb(t.cfg.mmdbid);else if(void 0!==t.cfg.gi)s.loadCmd="load gi "+t.cfg.gi,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.mmdbParserCls.downloadGi(t.cfg.gi);else if(void 0!==t.cfg.refseqid)s.inputid=t.cfg.refseqid,s.loadCmd="load refseq "+t.cfg.refseqid,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.mmdbParserCls.downloadRefseq(t.cfg.refseqid);else if(void 0!==t.cfg.blast_rep_id)if(s.inputid=t.cfg.query_id+","+t.cfg.blast_rep_id,t.cfg.oriQuery_id=t.cfg.query_id,t.cfg.oriBlast_rep_id=t.cfg.blast_rep_id,"Query"!==t.cfg.query_id.substr(0,5)&&void 0===t.cfg.rid)"icn3d"==t.cfg.from&&"1TSR_A"==t.cfg.blast_rep_id&&"NP_001108451.1"==t.cfg.query_id&&(t.cfg.command="view annotations; set annotation cdd; set annotation site; set view detailed view; select chain 1TSR_A; show selection"),"smithwm"==t.cfg.alg?(s.loadCmd="load seq_struct_ids_smithwm "+t.cfg.query_id+","+t.cfg.blast_rep_id,s.bSmithwm=!0):"local_smithwm"==t.cfg.alg?(s.loadCmd="load seq_struct_ids_local_smithwm "+t.cfg.query_id+","+t.cfg.blast_rep_id,s.bLocalSmithwm=!0):(s.loadCmd="load seq_struct_ids "+t.cfg.query_id+","+t.cfg.blast_rep_id,s.bSmithwm=!1,s.bLocalSmithwm=!1),t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.mmdbParserCls.downloadBlast_rep_id(t.cfg.query_id+","+t.cfg.blast_rep_id);else if(void 0!==t.cfg.rid){let e="https://blast.ncbi.nlm.nih.gov/Blast.cgi?RESULTS_FILE=on&FORMAT_TYPE=JSON2_S&FORMAT_OBJECT=Alignment&CMD=Get&RID="+t.cfg.rid,i=await t.getAjaxPromise(e,"json",!1,"The RID "+t.cfg.rid+" may have expired...");for(let e=0,n=i.BlastOutput2.length;e
    ",s="All atoms  ";e.utilsCls.setViewerWidthHeight(e),e.utilsCls.isMobile()||e.cfg.mobilemenu?e.htmlCls.setMenuCls.setTopMenusHtmlMobile(e.cfg.divid,t,s):e.htmlCls.setMenuCls.setTopMenusHtml(e.cfg.divid,t,s),e.icn3d=new Ms(e),e.icn3d.controlCls.setControl(),e.setDialogAjax()},Ps.prototype.getAjaxPromise=function(e,t,s,i,n,l){let r=this;return new Promise((function(o,a){$.ajax({url:e,dataType:t,cache:!0,beforeSend:function(){s&&r.icn3d.ParserUtilsCls.showLoading()},complete:function(){l&&r.icn3d.ParserUtilsCls.hideLoading()},success:function(e){o(e)},error:function(){i&&alert(i),n&&console.log(n),a("error")}})}))},Ps.prototype.getAjaxPostPromise=function(e,t,s,i,n,l,r){let o=this;return r=r||"json",new Promise((function(a,d){$.ajax({url:e,type:"POST",data:t,dataType:r,cache:!0,beforeSend:function(){s&&o.icn3d.ParserUtilsCls.showLoading()},complete:function(){l&&o.icn3d.ParserUtilsCls.hideLoading()},success:function(e){a(e)},error:function(){i&&alert(i),n&&console.log(n),d("error")}})}))},Ps.prototype.setDialogAjax=function(){this.bNode||$.ui.dialog.prototype._makeDraggableBase||($.ui.dialog.prototype._makeDraggableBase=$.ui.dialog.prototype._makeDraggable,$.ui.dialog.prototype._makeDraggable=function(){this._makeDraggableBase(),this.uiDialog.draggable("option","containment",!1)}),$.ajaxTransport("+binary",(function(e,t,s){if(window.FormData&&(e.dataType&&"binary"==e.dataType||e.data&&(window.ArrayBuffer&&e.data instanceof ArrayBuffer||window.Blob&&e.data instanceof Blob)))return{send:function(t,s){let i=new XMLHttpRequest,n=e.url,l=e.type,r=e.async||!0,o=e.responseType||"blob",a=e.data||null;i.addEventListener("load",(function(){let t={};t[e.dataType]=i.response,s(i.status,i.statusText,t,i.getAllResponseHeaders())})),i.open(l,n,r);for(let e in t)i.setRequestHeader(e,t[e]);i.responseType=o,i.send(a)},abort:function(){s.abort()}}}))};return e.ARButton=Ts,e.AddTrack=Rt,e.AlignParser=$t,e.AlignSW=bs,e.AlignSeq=m,e.Alternate=dt,e.Analysis=Cs,e.AnnoCddSite=yt,e.AnnoContact=vt,e.AnnoCrossLink=_t,e.AnnoDomain=St,e.AnnoSnpClinVar=At,e.AnnoSsbond=xt,e.AnnoTransMem=kt,e.Annotation=Et,e.ApplyCenter=Ze,e.ApplyClbonds=et,e.ApplyCommand=ls,e.ApplyDisplay=tt,e.ApplyMap=lt,e.ApplyOther=st,e.ApplySsbonds=it,e.ApplySymd=nt,e.Axes=We,e.Box=Me,e.Brick=Pe,e.Camera=Ie,e.CartoonNucl=ze,e.ChainalignParser=jt,e.ClickMenu=a,e.Contact=ht,e.Control=Rs,e.ConvertTypeCls=o,e.Curve=He,e.CurveStripArrow=De,e.Cylinder=Fe,e.DefinedSets=rs,e.Delphi=ps,e.DensityCifParser=Zt,e.Diagram2d=ys,e.Dialog=c,e.Domain3d=Ot,e.Draw=ct,e.DrawGraph=Ut,e.Dsn6Parser=Bt,e.Dssp=ms,e.ElectronMap=Qe,e.Events=p,e.Export3D=ks,e.FirstAtomObj=hs,e.Fog=Te,e.GetGraph=Ft,e.Glycan=Ye,e.HBond=pt,e.HashUtilsCls=t,e.HlObjects=Dt,e.HlSeq=Mt,e.HlUpdate=Pt,e.Html=g,e.Impostor=ot,e.Instancing=at,e.Label=Ve,e.Line=Le,e.LineGraph=Ht,e.LoadAtomData=ts,e.LoadPDB=is,e.LoadScript=os,e.MarchingCube=Xe,e.MmcifParser=zt,e.MmdbParser=Gt,e.MmtfParser=Vt,e.Mol2Parser=Wt,e.MyEventCls=n,e.OpmParser=Yt,e.ParasCls=i,e.ParserUtils=es,e.PdbParser=Xt,e.PiHalogen=mt,e.Picking=Es,e.ProteinSurface=Ke,e.Ray=Os,e.RealignParser=Jt,e.Refnum=us,e.ReprSub=Ne,e.Resid2spec=cs,e.ResidueLabels=rt,e.ResizeCanvas=ws,e.RmsdSuprCls=l,e.Saltbridge=ut,e.SaveFile=Ss,e.Scap=gs,e.Scene=Ee,e.SdfParser=Kt,e.SelectByCommand=as,e.Selection=ds,e.SetColor=ft,e.SetDialog=h,e.SetHtml=u,e.SetMenu=d,e.SetOption=bt,e.SetSeqAlign=ss,e.SetStyle=gt,e.ShareLink=As,e.ShowAnno=It,e.ShowInter=Lt,e.ShowSeq=Tt,e.Sphere=Ue,e.Stick=qe,e.Strand=$e,e.Strip=je,e.SubdivideCls=r,e.Surface=Je,e.Symd=fs,e.ThreeDPrint=xs,e.Transform=_s,e.Tube=Be,e.UtilsCls=s,e.VRButton=Is,e.Vastplus=ns,e.ViewInterPairs=Nt,e.XyzParser=Qt,e.iCn3D=Ms,e.iCn3DUI=Ps,e.printMsg=class{constructor(){console.log("This is a message from the icn3d package")}},Object.defineProperty(e,"__esModule",{value:!0}),e}({}); diff --git a/build/icn3d.module.js b/build/icn3d.module.js index 7b6af3fe..2880e55d 100644 --- a/build/icn3d.module.js +++ b/build/icn3d.module.js @@ -11586,7 +11586,7 @@ class SetDialog { html += me.htmlCls.divStr + "dl_mmdbafid' class='" + dialogClass + "' style='max-width:600px'>"; html += "List of PDB, MMDB, or AlphaFold UniProt structures: " + me.htmlCls.inputTextStr + "id='" + me.pre + "mmdbafid' placeholder='e.g., 1HHO,4N7N,P69905,P01942' size=30>

    "; html += "
    " + me.htmlCls.buttonStr + "reload_mmdbaf' style='width:150px'>Load Biological Unit" + me.htmlCls.buttonStr + "reload_mmdbaf_asym' style='margin-left:30px; width:250px'>Load Asymmetric Unit (All Chains)" + "

    "; - html += "
    or
    " + me.htmlCls.buttonStr + "reload_mmdbaf_append' style='width:150px'>Append Biological Unit" + me.htmlCls.buttonStr + "reload_mmdbaf_asym_append' style='margin-left:30px; width:250px'>Append Asymmetric ; Unit (All Chains)" + "

    "; + html += "
    or
    " + me.htmlCls.buttonStr + "reload_mmdbaf_append' style='width:150px'>Append Biological Unit" + me.htmlCls.buttonStr + "reload_mmdbaf_asym_append' style='margin-left:30px; width:250px'>Append Asymmetric Unit (All Chains)" + "

    "; html += 'Note: The "biological unit" is the biochemically active form of a biomolecule,
    "; html += "List of PDB, MMDB, or AlphaFold UniProt structures: " + me.htmlCls.inputTextStr + "id='" + me.pre + "mmdbafid' placeholder='e.g., 1HHO,4N7N,P69905,P01942' size=30>

    "; html += "
    " + me.htmlCls.buttonStr + "reload_mmdbaf' style='width:150px'>Load Biological Unit" + me.htmlCls.buttonStr + "reload_mmdbaf_asym' style='margin-left:30px; width:250px'>Load Asymmetric Unit (All Chains)" + "

    "; - html += "
    or
    " + me.htmlCls.buttonStr + "reload_mmdbaf_append' style='width:150px'>Append Biological Unit" + me.htmlCls.buttonStr + "reload_mmdbaf_asym_append' style='margin-left:30px; width:250px'>Append Asymmetric ; Unit (All Chains)" + "

    "; + html += "
    or
    " + me.htmlCls.buttonStr + "reload_mmdbaf_append' style='width:150px'>Append Biological Unit" + me.htmlCls.buttonStr + "reload_mmdbaf_asym_append' style='margin-left:30px; width:250px'>Append Asymmetric Unit (All Chains)" + "

    "; html += 'Note: The "biological unit" is the biochemically active form of a biomolecule,
    0.0 ){"," cameraPos = rayDirection * posT + rayOrigin;"," interior = true;"," flag2 = true;"," return false;","}else{"," cameraNormal = normalize( cameraPos - cameraSpherePos );","}"," #else","if( calcDepth( cameraPos ) <= 0.0 ){"," cameraPos = rayDirection * posT + rayOrigin;"," interior = true;"," return false;","}else{"," cameraNormal = normalize( cameraPos - cameraSpherePos );","}"," #endif",""," cameraNormal = normalize( cameraPos - cameraSpherePos );"," cameraNormal *= float(!interior) * 2.0 - 1.0;"," return !interior;","","}","","void main(void){",""," bool flag = Impostor( cameraPos, cameraNormal );",""," #ifdef NEAR_CLIP"," if( calcClip( cameraPos ) > 0.0 )"," discard;"," #endif",""," // FIXME not compatible with custom clipping plane"," //Set the depth based on the new cameraPos."," gl_FragDepthEXT = calcDepth( cameraPos );"," if( !flag ){",""," // clamp to near clipping plane and add a tiny value to"," // make spheres with a greater radius occlude smaller ones"," #ifdef NEAR_CLIP","if( flag2 ){"," gl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( nearClip - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );","}else if( gl_FragDepthEXT >= 0.0 ){"," gl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );","}"," #else","if( gl_FragDepthEXT >= 0.0 ){"," gl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );","}"," #endif",""," }",""," // bugfix (mac only?)"," if (gl_FragDepthEXT < 0.0)"," discard;"," if (gl_FragDepthEXT > 1.0)"," discard;",""," #ifdef PICKING",""," gl_FragColor = vec4( vPickingColor, objectId );",""," #else",""," vec3 vNormal = cameraNormal;"," vec3 vViewPosition = -cameraPos;",""," vec4 diffuseColor = vec4( diffuse, opacity );"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveLight = emissive;",""," #include color_fragment"," #include roughnessmap_fragment"," #include metalnessmap_fragment",""," // don't use include normal_fragment"," vec3 normal = normalize( vNormal );",""," #include lights_physical_fragment"," //include lights_template"," #include lights_fragment_begin"," #include lights_fragment_end",""," vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;",""," gl_FragColor = vec4( outgoingLight, diffuseColor.a );"," //gl_FragColor = vec4( reflectedLight.directSpecular, diffuseColor.a );",""," #include premultiplied_alpha_fragment"," #include tonemapping_fragment"," #include encodings_fragment"," //include fog_fragment"," #ifdef USE_FOG"," #ifdef USE_LOGDEPTHBUF_EXT"," float depth = gl_FragDepthEXT / gl_FragCoord.w;"," #else"," float depth = gl_FragCoord.z / gl_FragCoord.w;"," #endif"," #ifdef FOG_EXP2"," float fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );"," #else"," float fogFactor = smoothstep( fogNear, fogFar, depth );"," #endif"," gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );"," #endif",""," #endif","","}"].join("\n"),$NGL_shaderTextHash["SphereImpostor.vert"]=["uniform mat4 projectionMatrixInverse;","uniform float nearClip;","","varying float vRadius;","varying float vRadiusSq;","varying vec3 vPoint;","varying vec3 vPointViewPosition;","varying float fogDepth;","varying float fogNear;","varying float fogFar;","","attribute vec2 mapping;","//attribute vec3 position;","attribute float radius;","","#ifdef PICKING"," #include unpack_clr"," attribute float primitiveId;"," varying vec3 vPickingColor;","#else"," #include color_pars_vertex","#endif","","//include matrix_scale","float matrixScale( in mat4 m ){"," vec4 r = m[ 0 ];"," return sqrt( r[ 0 ] * r[ 0 ] + r[ 1 ] * r[ 1 ] + r[ 2 ] * r[ 2 ] );","}","","const mat4 D = mat4("," 1.0, 0.0, 0.0, 0.0,"," 0.0, 1.0, 0.0, 0.0,"," 0.0, 0.0, 1.0, 0.0,"," 0.0, 0.0, 0.0, -1.0",");","","mat4 transposeTmp( in mat4 inMatrix ) {"," vec4 i0 = inMatrix[0];"," vec4 i1 = inMatrix[1];"," vec4 i2 = inMatrix[2];"," vec4 i3 = inMatrix[3];",""," mat4 outMatrix = mat4("," vec4(i0.x, i1.x, i2.x, i3.x),"," vec4(i0.y, i1.y, i2.y, i3.y),"," vec4(i0.z, i1.z, i2.z, i3.z),"," vec4(i0.w, i1.w, i2.w, i3.w)"," );"," return outMatrix;","}","","//------------------------------------------------------------------------------","// Compute point size and center using the technique described in:","// 'GPU-Based Ray-Casting of Quadratic Surfaces'","// by Christian Sigg, Tim Weyrich, Mario Botsch, Markus Gross.","//","// Code based on","/*=========================================================================",""," Program: Visualization Toolkit"," Module: Quadrics_fs.glsl and Quadrics_vs.glsl",""," Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen"," All rights reserved."," See Copyright.txt or http://www.kitware.com/Copyright.htm for details.",""," This software is distributed WITHOUT ANY WARRANTY; without even"," the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR"," PURPOSE. See the above copyright notice for more information.",""," =========================================================================*/","","// .NAME Quadrics_fs.glsl and Quadrics_vs.glsl","// .SECTION Thanks","// ","//","// This file is part of the PointSprites plugin developed and contributed by","//","// Copyright (c) CSCS - Swiss National Supercomputing Centre","// EDF - Electricite de France","//","// John Biddiscombe, Ugo Varetto (CSCS)","// Stephane Ploix (EDF)","//","// ","//","// Contributions by Alexander Rose","// - ported to WebGL","// - adapted to work with quads","void ComputePointSizeAndPositionInClipCoordSphere(){",""," vec2 xbc;"," vec2 ybc;",""," mat4 T = mat4("," radius, 0.0, 0.0, 0.0,"," 0.0, radius, 0.0, 0.0,"," 0.0, 0.0, radius, 0.0,"," position.x, position.y, position.z, 1.0"," );",""," mat4 R = transposeTmp( projectionMatrix * modelViewMatrix * T );"," float A = dot( R[ 3 ], D * R[ 3 ] );"," float B = -2.0 * dot( R[ 0 ], D * R[ 3 ] );"," float C = dot( R[ 0 ], D * R[ 0 ] );"," xbc[ 0 ] = ( -B - sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," xbc[ 1 ] = ( -B + sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," float sx = abs( xbc[ 0 ] - xbc[ 1 ] ) * 0.5;",""," A = dot( R[ 3 ], D * R[ 3 ] );"," B = -2.0 * dot( R[ 1 ], D * R[ 3 ] );"," C = dot( R[ 1 ], D * R[ 1 ] );"," ybc[ 0 ] = ( -B - sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," ybc[ 1 ] = ( -B + sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," float sy = abs( ybc[ 0 ] - ybc[ 1 ] ) * 0.5;",""," gl_Position.xy = vec2( 0.5 * ( xbc.x + xbc.y ), 0.5 * ( ybc.x + ybc.y ) );"," gl_Position.xy -= mapping * vec2( sx, sy );"," gl_Position.xy *= gl_Position.w;","","}","","void main(void){",""," #ifdef PICKING"," vPickingColor = unpackColor( primitiveId );"," #else"," #include color_vertex"," #endif",""," vRadius = radius * matrixScale( modelViewMatrix );",""," vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );"," // avoid clipping, added again in fragment shader"," mvPosition.z -= vRadius;",""," gl_Position = projectionMatrix * vec4( mvPosition.xyz, 1.0 );"," ComputePointSizeAndPositionInClipCoordSphere();","",""," vRadiusSq = vRadius * vRadius;"," vec4 vPoint4 = projectionMatrixInverse * gl_Position;"," vPoint = vPoint4.xyz / vPoint4.w;"," vPointViewPosition = -mvPosition.xyz / mvPosition.w;","","}"].join("\n"),$NGL_shaderTextHash["CylinderImpostor.frag"]=["#define STANDARD","#define IMPOSTOR","","// Open-Source PyMOL is Copyright (C) Schrodinger, LLC.","//","// All Rights Reserved","//","// Permission to use, copy, modify, distribute, and distribute modified","// versions of this software and its built-in documentation for any","// purpose and without fee is hereby granted, provided that the above","// copyright notice appears in all copies and that both the copyright","// notice and this permission notice appear in supporting documentation,","// and that the name of Schrodinger, LLC not be used in advertising or","// publicity pertaining to distribution of the software without specific,","// written prior permission.","//","// SCHRODINGER, LLC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,","// INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN","// NO EVENT SHALL SCHRODINGER, LLC BE LIABLE FOR ANY SPECIAL, INDIRECT OR","// CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS","// OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE","// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE","// USE OR PERFORMANCE OF THIS SOFTWARE.","","// Contributions by Alexander Rose","// - ported to WebGL","// - dual color","// - pk color","// - custom clipping","// - three.js lighting","","uniform vec3 diffuse;","uniform vec3 emissive;","uniform float roughness;","uniform float metalness;","uniform float opacity;","uniform float nearClip;","uniform mat4 projectionMatrix;","uniform float ortho;","","varying vec3 axis;","varying vec4 base_radius;","varying vec4 end_b;","varying vec3 U;","varying vec3 V;","varying vec4 w;","","#ifdef PICKING"," uniform float objectId;"," varying vec3 vPickingColor;","#else"," varying vec3 vColor1;"," varying vec3 vColor2;"," #include common"," #include fog_pars_fragment"," #include bsdfs"," #include lights_pars_begin"," #include lights_physical_pars_fragment","#endif","","bool interior = false;","","float distSq3( vec3 v3a, vec3 v3b ){"," return ("," ( v3a.x - v3b.x ) * ( v3a.x - v3b.x ) +"," ( v3a.y - v3b.y ) * ( v3a.y - v3b.y ) +"," ( v3a.z - v3b.z ) * ( v3a.z - v3b.z )"," );","}","","// Calculate depth based on the given camera position.","float calcDepth( in vec3 cameraPos ){"," vec2 clipZW = cameraPos.z * projectionMatrix[2].zw + projectionMatrix[3].zw;"," return 0.5 + 0.5 * clipZW.x / clipZW.y;","}","","float calcClip( vec3 cameraPos ){"," return dot( vec4( cameraPos, 1.0 ), vec4( 0.0, 0.0, 1.0, nearClip - 0.5 ) );","}","","void main(){",""," vec3 point = w.xyz / w.w;",""," // unpacking"," vec3 base = base_radius.xyz;"," float vRadius = base_radius.w;"," vec3 end = end_b.xyz;"," float b = end_b.w;",""," vec3 end_cyl = end;"," vec3 surface_point = point;",""," vec3 ray_target = surface_point;"," vec3 ray_origin = vec3(0.0);"," vec3 ray_direction = mix(normalize(ray_origin - ray_target), vec3(0.0, 0.0, 1.0), ortho);"," mat3 basis = mat3( U, V, axis );",""," vec3 diff = ray_target - 0.5 * (base + end_cyl);"," vec3 P = diff * basis;",""," // angle (cos) between cylinder cylinder_axis and ray direction"," float dz = dot( axis, ray_direction );",""," float radius2 = vRadius*vRadius;",""," // calculate distance to the cylinder from ray origin"," vec3 D = vec3(dot(U, ray_direction),"," dot(V, ray_direction),"," dz);"," float a0 = P.x*P.x + P.y*P.y - radius2;"," float a1 = P.x*D.x + P.y*D.y;"," float a2 = D.x*D.x + D.y*D.y;",""," // calculate a dicriminant of the above quadratic equation"," float d = a1*a1 - a0*a2;"," if (d < 0.0)"," // outside of the cylinder"," discard;",""," float dist = (-a1 + sqrt(d)) / a2;",""," // point of intersection on cylinder surface"," vec3 new_point = ray_target + dist * ray_direction;",""," vec3 tmp_point = new_point - base;"," vec3 _normal = normalize( tmp_point - axis * dot(tmp_point, axis) );",""," ray_origin = mix( ray_origin, surface_point, ortho );",""," // test caps"," float front_cap_test = dot( tmp_point, axis );"," float end_cap_test = dot((new_point - end_cyl), axis);",""," // to calculate caps, simply check the angle between"," // the point of intersection - cylinder end vector"," // and a cap plane normal (which is the cylinder cylinder_axis)"," // if the angle < 0, the point is outside of cylinder"," // test front cap",""," #ifndef CAP"," vec3 new_point2 = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;"," vec3 tmp_point2 = new_point2 - base;"," #endif",""," // flat"," if (front_cap_test < 0.0)"," {"," // ray-plane intersection"," float dNV = dot(-axis, ray_direction);"," if (dNV < 0.0)"," discard;"," float near = dot(-axis, (base)) / dNV;"," vec3 front_point = ray_direction * near + ray_origin;"," // within the cap radius?"," if (dot(front_point - base, front_point-base) > radius2)"," discard;",""," #ifdef CAP"," new_point = front_point;"," _normal = axis;"," #else"," new_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;"," dNV = dot(-axis, ray_direction);"," near = dot(axis, end_cyl) / dNV;"," new_point2 = ray_direction * near + ray_origin;"," if (dot(new_point2 - end_cyl, new_point2-base) < radius2)"," discard;"," interior = true;"," #endif"," }",""," // test end cap","",""," // flat"," if( end_cap_test > 0.0 )"," {"," // ray-plane intersection"," float dNV = dot(axis, ray_direction);"," if (dNV < 0.0)"," discard;"," float near = dot(axis, end_cyl) / dNV;"," vec3 end_point = ray_direction * near + ray_origin;"," // within the cap radius?"," if( dot(end_point - end_cyl, end_point-base) > radius2 )"," discard;",""," #ifdef CAP"," new_point = end_point;"," _normal = axis;"," #else"," new_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;"," dNV = dot(-axis, ray_direction);"," near = dot(-axis, (base)) / dNV;"," new_point2 = ray_direction * near + ray_origin;"," if (dot(new_point2 - base, new_point2-base) < radius2)"," discard;"," interior = true;"," #endif"," }",""," gl_FragDepthEXT = calcDepth( new_point );",""," #ifdef NEAR_CLIP"," if( calcClip( new_point ) > 0.0 ){"," dist = (-a1 - sqrt(d)) / a2;"," new_point = ray_target + dist * ray_direction;"," if( calcClip( new_point ) > 0.0 )"," discard;"," interior = true;"," gl_FragDepthEXT = calcDepth( new_point );"," if( gl_FragDepthEXT >= 0.0 ){"," gl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( nearClip - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );"," }"," }else if( gl_FragDepthEXT <= 0.0 ){"," dist = (-a1 - sqrt(d)) / a2;"," new_point = ray_target + dist * ray_direction;"," interior = true;"," gl_FragDepthEXT = calcDepth( new_point );"," if( gl_FragDepthEXT >= 0.0 ){"," gl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );"," }"," }"," #else"," if( gl_FragDepthEXT <= 0.0 ){"," dist = (-a1 - sqrt(d)) / a2;"," new_point = ray_target + dist * ray_direction;"," interior = true;"," gl_FragDepthEXT = calcDepth( new_point );"," if( gl_FragDepthEXT >= 0.0 ){"," gl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );"," }"," }"," #endif",""," // this is a workaround necessary for Mac"," // otherwise the modified fragment won't clip properly"," if (gl_FragDepthEXT < 0.0)"," discard;"," if (gl_FragDepthEXT > 1.0)"," discard;",""," #ifdef PICKING",""," gl_FragColor = vec4( vPickingColor, objectId );",""," #else",""," vec3 vViewPosition = -new_point;"," vec3 vNormal = _normal;"," vec3 vColor;",""," if( distSq3( new_point, end_cyl ) < distSq3( new_point, base ) ){"," if( b < 0.0 ){"," vColor = vColor1;"," }else{"," vColor = vColor2;"," }"," }else{"," if( b > 0.0 ){"," vColor = vColor1;"," }else{"," vColor = vColor2;"," }"," }",""," vec4 diffuseColor = vec4( diffuse, opacity );"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveLight = emissive;",""," #include color_fragment"," //ifdef USE_COLOR"," //diffuseColor.r *= vColor[0];"," //diffuseColor.g *= vColor[1];"," //diffuseColor.b *= vColor[2];"," //endif"," #include roughnessmap_fragment"," #include metalnessmap_fragment",""," // don't use include normal_fragment"," vec3 normal = normalize( vNormal );",""," #include lights_physical_fragment"," //include lights_template"," #include lights_fragment_begin"," #include lights_fragment_end",""," vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;",""," gl_FragColor = vec4( outgoingLight, diffuseColor.a );"," //gl_FragColor = vec4( reflectedLight.directSpecular, diffuseColor.a );",""," #include premultiplied_alpha_fragment"," #include tonemapping_fragment"," #include encodings_fragment"," //include fog_fragment"," #ifdef USE_FOG"," #ifdef USE_LOGDEPTHBUF_EXT"," float depth = gl_FragDepthEXT / gl_FragCoord.w;"," #else"," float depth = gl_FragCoord.z / gl_FragCoord.w;"," #endif"," #ifdef FOG_EXP2"," float fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );"," #else"," float fogFactor = smoothstep( fogNear, fogFar, depth );"," #endif"," gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );"," #endif",""," #endif","","}"].join("\n"),$NGL_shaderTextHash["CylinderImpostor.vert"]=["// Open-Source PyMOL is Copyright (C) Schrodinger, LLC.","//","// All Rights Reserved","//","// Permission to use, copy, modify, distribute, and distribute modified","// versions of this software and its built-in documentation for any","// purpose and without fee is hereby granted, provided that the above","// copyright notice appears in all copies and that both the copyright","// notice and this permission notice appear in supporting documentation,","// and that the name of Schrodinger, LLC not be used in advertising or","// publicity pertaining to distribution of the software without specific,","// written prior permission.","//","// SCHRODINGER, LLC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,","// INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN","// NO EVENT SHALL SCHRODINGER, LLC BE LIABLE FOR ANY SPECIAL, INDIRECT OR","// CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS","// OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE","// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE","// USE OR PERFORMANCE OF THIS SOFTWARE.","","// Contributions by Alexander Rose","// - ported to WebGL","// - dual color","// - pk color","// - shift","","attribute vec3 mapping;","attribute vec3 position1;","attribute vec3 position2;","attribute float radius;","","varying vec3 axis;","varying vec4 base_radius;","varying vec4 end_b;","varying vec3 U;","varying vec3 V;","varying vec4 w;","varying float fogDepth;","varying float fogNear;","varying float fogFar;","","#ifdef PICKING"," #include unpack_clr"," attribute float primitiveId;"," varying vec3 vPickingColor;","#else"," //attribute vec3 color;"," attribute vec3 color2;"," varying vec3 vColor1;"," varying vec3 vColor2;","#endif","","uniform mat4 modelViewMatrixInverse;","uniform float ortho;","","//include matrix_scale","float matrixScale( in mat4 m ){"," vec4 r = m[ 0 ];"," return sqrt( r[ 0 ] * r[ 0 ] + r[ 1 ] * r[ 1 ] + r[ 2 ] * r[ 2 ] );","}","","void main(){",""," #ifdef PICKING"," vPickingColor = unpackColor( primitiveId );"," #else"," vColor1 = color;"," vColor2 = color2;"," #endif",""," // vRadius = radius;"," base_radius.w = radius * matrixScale( modelViewMatrix );",""," //vec3 center = position;"," vec3 center = ( position2 + position1 ) / 2.0;"," vec3 dir = normalize( position2 - position1 );"," float ext = length( position2 - position1 ) / 2.0;",""," // using cameraPosition fails on some machines, not sure why"," // vec3 cam_dir = normalize( cameraPosition - mix( center, vec3( 0.0 ), ortho ) );"," vec3 cam_dir;"," if( ortho == 0.0 ){"," cam_dir = ( modelViewMatrixInverse * vec4( 0, 0, 0, 1 ) ).xyz - center;"," }else{"," cam_dir = ( modelViewMatrixInverse * vec4( 0, 0, 1, 0 ) ).xyz;"," }"," cam_dir = normalize( cam_dir );",""," vec3 ldir;",""," float b = dot( cam_dir, dir );"," end_b.w = b;"," // direction vector looks away, so flip"," if( b < 0.0 )"," ldir = -ext * dir;"," // direction vector already looks in my direction"," else"," ldir = ext * dir;",""," vec3 left = normalize( cross( cam_dir, ldir ) );"," left = radius * left;"," vec3 up = radius * normalize( cross( left, ldir ) );",""," // transform to modelview coordinates"," axis = normalize( normalMatrix * ldir );"," U = normalize( normalMatrix * up );"," V = normalize( normalMatrix * left );",""," vec4 base4 = modelViewMatrix * vec4( center - ldir, 1.0 );"," base_radius.xyz = base4.xyz / base4.w;",""," vec4 top_position = modelViewMatrix * vec4( center + ldir, 1.0 );"," vec4 end4 = top_position;"," end_b.xyz = end4.xyz / end4.w;",""," w = modelViewMatrix * vec4("," center + mapping.x*ldir + mapping.y*left + mapping.z*up, 1.0"," );",""," gl_Position = projectionMatrix * w;",""," // avoid clipping (1.0 seems to induce flickering with some drivers)"," gl_Position.z = 0.99;","","}"].join("\n"),$NGL_shaderTextHash["SphereInstancing.frag"]=$NGL_shaderTextHash["SphereImpostor.frag"],$NGL_shaderTextHash["SphereInstancing.vert"]=["uniform mat4 projectionMatrixInverse;","uniform float nearClip;","","varying float vRadius;","varying float vRadiusSq;","varying vec3 vPoint;","varying vec3 vPointViewPosition;","varying float fogDepth;","varying float fogNear;","varying float fogFar;","","attribute vec2 mapping;","//attribute vec3 position;","attribute float radius;","attribute vec4 matrix1;","attribute vec4 matrix2;","attribute vec4 matrix3;","attribute vec4 matrix4;","","#ifdef PICKING"," #include unpack_clr"," attribute float primitiveId;"," varying vec3 vPickingColor;","#else"," #include color_pars_vertex","#endif","","//include matrix_scale","float matrixScale( in mat4 m ){"," vec4 r = m[ 0 ];"," return sqrt( r[ 0 ] * r[ 0 ] + r[ 1 ] * r[ 1 ] + r[ 2 ] * r[ 2 ] );","}","","const mat4 D = mat4("," 1.0, 0.0, 0.0, 0.0,"," 0.0, 1.0, 0.0, 0.0,"," 0.0, 0.0, 1.0, 0.0,"," 0.0, 0.0, 0.0, -1.0",");","","mat4 transposeTmp( in mat4 inMatrix ) {"," vec4 i0 = inMatrix[0];"," vec4 i1 = inMatrix[1];"," vec4 i2 = inMatrix[2];"," vec4 i3 = inMatrix[3];",""," mat4 outMatrix = mat4("," vec4(i0.x, i1.x, i2.x, i3.x),"," vec4(i0.y, i1.y, i2.y, i3.y),"," vec4(i0.z, i1.z, i2.z, i3.z),"," vec4(i0.w, i1.w, i2.w, i3.w)"," );"," return outMatrix;","}","","//------------------------------------------------------------------------------","// Compute point size and center using the technique described in:","// 'GPU-Based Ray-Casting of Quadratic Surfaces'","// by Christian Sigg, Tim Weyrich, Mario Botsch, Markus Gross.","//","// Code based on","/*=========================================================================",""," Program: Visualization Toolkit"," Module: Quadrics_fs.glsl and Quadrics_vs.glsl",""," Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen"," All rights reserved."," See Copyright.txt or http://www.kitware.com/Copyright.htm for details.",""," This software is distributed WITHOUT ANY WARRANTY; without even"," the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR"," PURPOSE. See the above copyright notice for more information.",""," =========================================================================*/","","// .NAME Quadrics_fs.glsl and Quadrics_vs.glsl","// .SECTION Thanks","// ","//","// This file is part of the PointSprites plugin developed and contributed by","//","// Copyright (c) CSCS - Swiss National Supercomputing Centre","// EDF - Electricite de France","//","// John Biddiscombe, Ugo Varetto (CSCS)","// Stephane Ploix (EDF)","//","// ","//","// Contributions by Alexander Rose","// - ported to WebGL","// - adapted to work with quads","void ComputePointSizeAndPositionInClipCoordSphere(vec4 updatePosition){",""," vec2 xbc;"," vec2 ybc;",""," mat4 T = mat4("," radius, 0.0, 0.0, 0.0,"," 0.0, radius, 0.0, 0.0,"," 0.0, 0.0, radius, 0.0,"," updatePosition.x, updatePosition.y, updatePosition.z, 1.0"," );",""," mat4 R = transposeTmp( projectionMatrix * modelViewMatrix * T );"," float A = dot( R[ 3 ], D * R[ 3 ] );"," float B = -2.0 * dot( R[ 0 ], D * R[ 3 ] );"," float C = dot( R[ 0 ], D * R[ 0 ] );"," xbc[ 0 ] = ( -B - sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," xbc[ 1 ] = ( -B + sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," float sx = abs( xbc[ 0 ] - xbc[ 1 ] ) * 0.5;",""," A = dot( R[ 3 ], D * R[ 3 ] );"," B = -2.0 * dot( R[ 1 ], D * R[ 3 ] );"," C = dot( R[ 1 ], D * R[ 1 ] );"," ybc[ 0 ] = ( -B - sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," ybc[ 1 ] = ( -B + sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," float sy = abs( ybc[ 0 ] - ybc[ 1 ] ) * 0.5;",""," gl_Position.xy = vec2( 0.5 * ( xbc.x + xbc.y ), 0.5 * ( ybc.x + ybc.y ) );"," gl_Position.xy -= mapping * vec2( sx, sy );"," gl_Position.xy *= gl_Position.w;","","}",""," mat4 computeMat(vec4 v1, vec4 v2, vec4 v3, vec4 v4) {"," return mat4("," v1.x, v1.y, v1.z, v1.w,"," v2.x, v2.y, v2.z, v2.w,"," v3.x, v3.y, v3.z, v3.w,"," v4.x, v4.y, v4.z, v4.w"," );"," }","","void main(void){",""," #ifdef PICKING"," vPickingColor = unpackColor( primitiveId );"," #else"," #include color_vertex"," #endif",""," vRadius = radius * matrixScale( modelViewMatrix );",""," mat4 matrix = computeMat(matrix1, matrix2, matrix3, matrix4);"," vec4 updatePosition = matrix * vec4(position, 1.0);","","// vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );"," vec4 mvPosition = modelViewMatrix * vec4( updatePosition.xyz, 1.0 );"," // avoid clipping, added again in fragment shader"," mvPosition.z -= vRadius;","","// gl_Position = projectionMatrix * vec4( mvPosition.xyz, 1.0 );"," gl_Position = projectionMatrix * vec4( mvPosition.xyz, 1.0 );"," ComputePointSizeAndPositionInClipCoordSphere(updatePosition);","",""," vRadiusSq = vRadius * vRadius;"," vec4 vPoint4 = projectionMatrixInverse * gl_Position;"," vPoint = vPoint4.xyz / vPoint4.w;"," vPointViewPosition = -mvPosition.xyz / mvPosition.w;","","}"].join("\n"),$NGL_shaderTextHash["CylinderInstancing.frag"]=$NGL_shaderTextHash["CylinderImpostor.frag"],$NGL_shaderTextHash["CylinderInstancing.vert"]=["// Open-Source PyMOL is Copyright (C) Schrodinger, LLC.","//","// All Rights Reserved","//","// Permission to use, copy, modify, distribute, and distribute modified","// versions of this software and its built-in documentation for any","// purpose and without fee is hereby granted, provided that the above","// copyright notice appears in all copies and that both the copyright","// notice and this permission notice appear in supporting documentation,","// and that the name of Schrodinger, LLC not be used in advertising or","// publicity pertaining to distribution of the software without specific,","// written prior permission.","//","// SCHRODINGER, LLC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,","// INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN","// NO EVENT SHALL SCHRODINGER, LLC BE LIABLE FOR ANY SPECIAL, INDIRECT OR","// CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS","// OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE","// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE","// USE OR PERFORMANCE OF THIS SOFTWARE.","","// Contributions by Alexander Rose","// - ported to WebGL","// - dual color","// - pk color","// - shift","","attribute vec3 mapping;","attribute vec3 position1;","attribute vec3 position2;","attribute float radius;","attribute vec4 matrix1;","attribute vec4 matrix2;","attribute vec4 matrix3;","attribute vec4 matrix4;","","varying vec3 axis;","varying vec4 base_radius;","varying vec4 end_b;","varying vec3 U;","varying vec3 V;","varying vec4 w;","varying float fogDepth;","varying float fogNear;","varying float fogFar;","","#ifdef PICKING"," #include unpack_clr"," attribute float primitiveId;"," varying vec3 vPickingColor;","#else"," //attribute vec3 color;"," attribute vec3 color2;"," varying vec3 vColor1;"," varying vec3 vColor2;","#endif","","uniform mat4 modelViewMatrixInverse;","uniform float ortho;","","//include matrix_scale","float matrixScale( in mat4 m ){"," vec4 r = m[ 0 ];"," return sqrt( r[ 0 ] * r[ 0 ] + r[ 1 ] * r[ 1 ] + r[ 2 ] * r[ 2 ] );","}",""," mat4 computeMat(vec4 v1, vec4 v2, vec4 v3, vec4 v4) {"," return mat4("," v1.x, v1.y, v1.z, v1.w,"," v2.x, v2.y, v2.z, v2.w,"," v3.x, v3.y, v3.z, v3.w,"," v4.x, v4.y, v4.z, v4.w"," );"," }","","void main(){",""," #ifdef PICKING"," vPickingColor = unpackColor( primitiveId );"," #else"," vColor1 = color;"," vColor2 = color2;"," #endif",""," // vRadius = radius;"," base_radius.w = radius * matrixScale( modelViewMatrix );",""," //vec3 center = ( position2 + position1 ) / 2.0;",""," mat4 matrix = computeMat(matrix1, matrix2, matrix3, matrix4);"," vec4 updatePosition1 = matrix * vec4(position1, 1.0);"," vec4 updatePosition2 = matrix * vec4(position2, 1.0);"," vec3 center = ( updatePosition2.xyz + updatePosition1.xyz ) / 2.0;",""," //vec3 dir = normalize( position2 - position1 );"," vec3 dir = normalize( updatePosition2.xyz - updatePosition1.xyz );"," float ext = length( position2 - position1 ) / 2.0;",""," // using cameraPosition fails on some machines, not sure why"," // vec3 cam_dir = normalize( cameraPosition - mix( center, vec3( 0.0 ), ortho ) );"," vec3 cam_dir;"," if( ortho == 0.0 ){"," cam_dir = ( modelViewMatrixInverse * vec4( 0, 0, 0, 1 ) ).xyz - center;"," }else{"," cam_dir = ( modelViewMatrixInverse * vec4( 0, 0, 1, 0 ) ).xyz;"," }"," cam_dir = normalize( cam_dir );",""," vec3 ldir;",""," float b = dot( cam_dir, dir );"," end_b.w = b;"," // direction vector looks away, so flip"," if( b < 0.0 )"," ldir = -ext * dir;"," // direction vector already looks in my direction"," else"," ldir = ext * dir;",""," vec3 left = normalize( cross( cam_dir, ldir ) );"," left = radius * left;"," vec3 up = radius * normalize( cross( left, ldir ) );",""," // transform to modelview coordinates"," axis = normalize( normalMatrix * ldir );"," U = normalize( normalMatrix * up );"," V = normalize( normalMatrix * left );",""," vec4 base4 = modelViewMatrix * vec4( center - ldir, 1.0 );"," base_radius.xyz = base4.xyz / base4.w;",""," vec4 top_position = modelViewMatrix * vec4( center + ldir, 1.0 );"," vec4 end4 = top_position;"," end_b.xyz = end4.xyz / end4.w;",""," w = modelViewMatrix * vec4("," center + mapping.x*ldir + mapping.y*left + mapping.z*up, 1.0"," );",""," gl_Position = projectionMatrix * w;",""," // avoid clipping (1.0 seems to induce flickering with some drivers)"," gl_Position.z = 0.99;","","}"].join("\n"),$NGL_shaderTextHash["Instancing.frag"]=["#define STANDARD","uniform vec3 diffuse;","uniform vec3 emissive;","uniform float roughness;","uniform float metalness;","uniform float opacity;","uniform float nearClip;","uniform float clipRadius;","uniform mat4 projectionMatrix;","uniform float ortho;","varying float bCylinder;","","#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || ( !defined( PICKING ) && !defined( NOLIGHT ) )"," varying vec3 vViewPosition;","#endif","","#if defined( RADIUS_CLIP )"," varying vec3 vClipCenter;","#endif","","#if defined( PICKING )"," uniform float objectId;"," varying vec3 vPickingColor;","#elif defined( NOLIGHT )"," varying vec3 vColor;","#else"," #ifndef FLAT_SHADED"," varying vec3 vNormal;"," #endif"," #include common"," #include color_pars_fragment"," #include fog_pars_fragment"," #include bsdfs"," #include lights_pars_begin"," #include lights_physical_pars_fragment","#endif","","void main(){"," #include nearclip_fragment"," #include radiusclip_fragment",""," #if defined( PICKING )",""," gl_FragColor = vec4( vPickingColor, objectId );",""," #elif defined( NOLIGHT )",""," gl_FragColor = vec4( vColor, opacity );",""," #else",""," vec4 diffuseColor = vec4( diffuse, opacity );"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveLight = emissive;",""," #include color_fragment"," #include roughnessmap_fragment"," #include metalnessmap_fragment"," #include normal_flip"," #include normal_fragment_begin",""," //include dull_interior_fragment",""," #include lights_physical_fragment"," //include lights_template"," #include lights_fragment_begin"," #include lights_fragment_end",""," vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;",""," #include interior_fragment",""," gl_FragColor = vec4( outgoingLight, diffuseColor.a );",""," #include premultiplied_alpha_fragment"," #include tonemapping_fragment"," #include encodings_fragment"," #include fog_fragment",""," #include opaque_back_fragment",""," #endif","","}"].join("\n"),$NGL_shaderTextHash["Instancing.vert"]=["#define STANDARD","","uniform mat4 projectionMatrixInverse;","uniform float nearClip;","uniform vec3 clipCenter;","attribute vec4 matrix1;","attribute vec4 matrix2;","attribute vec4 matrix3;","attribute vec4 matrix4;","attribute float cylinder;","varying float bCylinder;","","#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || ( !defined( PICKING ) && !defined( NOLIGHT ) )"," varying vec3 vViewPosition;","#endif","","#if defined( RADIUS_CLIP )"," varying vec3 vClipCenter;","#endif","","#if defined( PICKING )"," #include unpack_color"," attribute float primitiveId;"," varying vec3 vPickingColor;","#elif defined( NOLIGHT )"," varying vec3 vColor;","#else"," #include color_pars_vertex"," #ifndef FLAT_SHADED"," varying vec3 vNormal;"," #endif","#endif","","#include common",""," mat4 computeMat(vec4 v1, vec4 v2, vec4 v3, vec4 v4) {"," return mat4("," v1.x, v1.y, v1.z, v1.w,"," v2.x, v2.y, v2.z, v2.w,"," v3.x, v3.y, v3.z, v3.w,"," v4.x, v4.y, v4.z, v4.w"," );"," }","","void main(){"," bCylinder = cylinder;",""," mat4 matrix = computeMat(matrix1, matrix2, matrix3, matrix4);"," vec4 updatePosition = matrix * vec4(position, 1.0);",""," #if defined( PICKING )"," vPickingColor = unpackColor( primitiveId );"," #elif defined( NOLIGHT )"," vColor = color;"," #else"," #include color_vertex"," //include beginnormal_vertex"," //vec3 objectNormal = vec3( normal );"," vec3 objectNormal = vec3(matrix * vec4(normal,0.0));"," #include defaultnormal_vertex"," // Normal computed with derivatives when FLAT_SHADED"," #ifndef FLAT_SHADED"," vNormal = normalize( transformedNormal );"," #endif"," #endif",""," //include begin_vertex"," vec3 transformed = updatePosition.xyz;"," //include project_vertex"," vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );"," gl_Position = projectionMatrix * mvPosition;",""," #if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || ( !defined( PICKING ) && !defined( NOLIGHT ) )"," vViewPosition = -mvPosition.xyz;"," #endif",""," #if defined( RADIUS_CLIP )"," vClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;"," #endif",""," #include nearclip_vertex","","}"].join("\n"),THREE.RenderableObject=function(){"use strict";this.id=0,this.object=null,this.z=0},THREE.RenderableFace=function(){"use strict";this.id=0,this.v1=new THREE.RenderableVertex,this.v2=new THREE.RenderableVertex,this.v3=new THREE.RenderableVertex,this.normalModel=new THREE.Vector3,this.vertexNormalsModel=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3],this.vertexNormalsLength=0,this.color=new THREE.Color,this.material=null,this.uvs=[new THREE.Vector2,new THREE.Vector2,new THREE.Vector2],this.z=0},THREE.RenderableVertex=function(){"use strict";this.position=new THREE.Vector3,this.positionWorld=new THREE.Vector3,this.positionScreen=new THREE.Vector4,this.visible=!0},THREE.RenderableVertex.prototype.copy=function(e){"use strict";this.positionWorld.copy(e.positionWorld),this.positionScreen.copy(e.positionScreen)},THREE.RenderableLine=function(){"use strict";this.id=0,this.v1=new THREE.RenderableVertex,this.v2=new THREE.RenderableVertex,this.vertexColors=[new THREE.Color,new THREE.Color],this.material=null,this.z=0},THREE.RenderableSprite=function(){"use strict";this.id=0,this.object=null,this.x=0,this.y=0,this.z=0,this.rotation=0,this.scale=new THREE.Vector2,this.material=null},THREE.Projector=function(){"use strict";var e,t,i,o,n,r,a,s,c,d,l,u=[],p=0,f=[],v=0,h=[],m=0,g=[],y=0,E=[],_=0,b={objects:[],lights:[],elements:[]},w=(new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3),T=new THREE.Vector4,x=new THREE.Box3(new THREE.Vector3(-1,-1,-1),new THREE.Vector3(1,1,1)),C=new THREE.Box3,R=new Array(3),S=(new Array(4),new THREE.Matrix4),L=new THREE.Matrix4,A=(new THREE.Matrix4,new THREE.Matrix3,new THREE.Frustum);new THREE.Vector4,new THREE.Vector4;this.projectVector=function(e,t){console.warn("THREE.Projector: .projectVector() is now vector.project()."),e.project(t)},this.unprojectVector=function(e,t){console.warn("THREE.Projector: .unprojectVector() is now vector.unproject()."),e.unproject(t)},this.pkRay=function(e,t){console.error("THREE.Projector: .pkRay() is now raycaster.setFromCamera().")};var I=new function(){var e=[],t=[],c=null,d=null,u=new THREE.Matrix3,p=function(e){var t=e.position,i=e.positionWorld,o=e.positionScreen;i.copy(t).applyMatrix4(l),o.copy(i).applyMatrix4(L);var n=1/o.w;o.x*=n,o.y*=n,o.z*=n,e.visible=o.x>=-1&&o.x<=1&&o.y>=-1&&o.y<=1&&o.z>=-1&&o.z<=1},E=function(e,t,i){return!0===e.visible||!0===t.visible||!0===i.visible||(R[0]=e.positionScreen,R[1]=t.positionScreen,R[2]=i.positionScreen,x.isIntersectionBox(C.setFromPoints(R)))},_=function(e,t,i){return(i.positionScreen.x-e.positionScreen.x)*(t.positionScreen.y-e.positionScreen.y)-(i.positionScreen.y-e.positionScreen.y)*(t.positionScreen.x-e.positionScreen.x)<0};return{setObject:function(i){d=(c=i).material,u.getNormalMatrix(c.matrixWorld),e.length=0,t.length=0},projectVertex:p,checkTriangleVisibility:E,checkBackfaceCulling:_,pushVertex:function(e,t,n){(i=function(){if(o===v){var e=new THREE.RenderableVertex;return f.push(e),v++,o++,e}return f[o++]}()).position.set(e,t,n),p(i)},pushNormal:function(t,i,o){e.push(t,i,o)},pushUv:function(e,i){t.push(e,i)},pushLine:function(e,t){var i=f[e],o=f[t];(a=function(){if(s===y){var e=new THREE.RenderableLine;return g.push(e),y++,s++,e}return g[s++]}()).id=c.id,a.v1.copy(i),a.v2.copy(o),a.z=(i.positionScreen.z+o.positionScreen.z)/2,a.material=c.material,b.elements.push(a)},pushTriangle:function(i,o,a){var s=f[i],l=f[o],p=f[a];if(!1!==E(s,l,p)&&(d.side===THREE.DoubleSide||!0===_(s,l,p))){(n=function(){if(r===m){var e=new THREE.RenderableFace;return h.push(e),m++,r++,e}return h[r++]}()).id=c.id,n.v1.copy(s),n.v2.copy(l),n.v3.copy(p),n.z=(s.positionScreen.z+l.positionScreen.z+p.positionScreen.z)/3;for(var v=0;v<3;v++){var g=3*arguments[v],y=n.vertexNormalsModel[v];y.set(e[g],e[g+1],e[g+2]),y.applyMatrix3(u).normalize();var w=2*arguments[v];n.uvs[v].set(t[w],t[w+1])}n.vertexNormalsLength=3,n.material=c.material,b.elements.push(n)}}}};function O(){if(d===_){var e=new THREE.RenderableSprite;return E.push(e),_++,d++,e}return E[d++]}function N(e,t){return e.z!==t.z?t.z-e.z:e.id!==t.id?e.id-t.id:0}this.projectScene=function(i,n,a,f){r=0,s=0,d=0,b.elements.length=0,!0===i.autoUpdate&&i.updateMatrixWorld(),void 0===n.parent&&n.updateMatrixWorld(),S.copy(n.matrixWorldInverse.copy(n.matrixWorld).invert()),L.multiplyMatrices(n.projectionMatrix,S),A.setFromMatrix(L),t=0,b.objects.length=0,b.lights.length=0,i.traverseVisible(function(i){if(i instanceof THREE.Light)b.lights.push(i);else if(i instanceof THREE.Mesh||i instanceof THREE.Line||i instanceof THREE.Sprite){if(!1===i.material.visible)return;!1!==i.frustumCulled&&!0!==A.intersectsObject(i)||((e=function(){if(t===p){var e=new THREE.RenderableObject;return u.push(e),p++,t++,e}return u[t++]}()).id=i.id,e.object=i,w.setFromMatrixPosition(i.matrixWorld),w.applyProjection(L),e.z=w.z,b.objects.push(e))}}),!0===a&&b.objects.sort(N);for(var v=0,h=b.objects.length;v0)for(v=0;v=-1&&T.z<=1&&((c=O()).id=m.id,c.x=T.x*j,c.y=T.y*j,c.z=T.z,c.object=m,c.rotation=m.rotation,c.scale.x=m.scale.x*Math.abs(c.x-(T.x+n.projectionMatrix.elements[0])/(T.w+n.projectionMatrix.elements[12])),c.scale.y=m.scale.y*Math.abs(c.y-(T.y+n.projectionMatrix.elements[5])/(T.w+n.projectionMatrix.elements[13])),c.material=m.material,b.elements.push(c))}}return!0===f&&b.elements.sort(N),b}},THREE.TrackballControls=function(e,t,i){"use strict";var o=this;this.STATE={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4},this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.screen={left:0,top:0,width:0,height:0},this.rotateSpeed=1,this.zoomSpeed=1.2,this.panSpeed=.3,this.noRotate=!1,this.noZoom=!1,this.noPan=!1,this.noRoll=!1,this.staticMoving=!1,this.dynamicDampingFactor=.2,this.minDistance=0,this.maxDistance=1/0,this.keys=[65,83,68],this.target=new THREE.Vector3;var n=new THREE.Vector3;this._state=this.STATE.NONE;var r=this.STATE.NONE,a=new THREE.Vector3;this._rotateStart=new THREE.Vector3,this._rotateEnd=new THREE.Vector3,this._zoomStart=new THREE.Vector2,this._zoomEnd=new THREE.Vector2;var s=0,c=0;this._panStart=new THREE.Vector2,this._panEnd=new THREE.Vector2,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.up0=this.object.up.clone();var d={type:"change"},l={type:"start"},u={type:"end"};this.handleResize=function(){if(this.domElement===document)this.screen.left=0,this.screen.top=0,this.screen.width=window.innerWidth,this.screen.height=window.innerHeight;else{var e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}},this.handleEvent=function(e){"function"==typeof this[e.type]&&this[e.type](e)};var p,f,v,h,m,g,y,E,_,b=(p=new THREE.Vector2,function(e,t){return p.set((e-o.screen.left)/o.screen.width,(t-o.screen.top)/o.screen.height),p}),w=(f=new THREE.Vector3,v=new THREE.Vector3,h=new THREE.Vector3,function(e,t){h.set((e-.5*o.screen.width-o.screen.left)/(.5*o.screen.width),(.5*o.screen.height+o.screen.top-t)/(.5*o.screen.height),0);var i=h.length();return o.noRoll?i1?h.normalize():h.z=Math.sqrt(1-i*i),a.copy(o.object.position).sub(o.target),f.copy(o.object.up).setLength(h.y),f.add(v.copy(o.object.up).cross(a).setLength(h.x)),f.add(a.setLength(h.z)),f});function T(e){!1===o.enabled||Object.keys(window).length<2||(window.removeEventListener("keydown",T),r=o._state,o._state===o.STATE.NONE&&(e.keyCode!==o.keys[o.STATE.ROTATE]||o.noRotate?e.keyCode!==o.keys[o.STATE.ZOOM]||o.noZoom?e.keyCode!==o.keys[o.STATE.PAN]||o.noPan||(o._state=o.STATE.PAN):o._state=o.STATE.ZOOM:o._state=o.STATE.ROTATE))}function x(e){!1===o.enabled||Object.keys(window).length<2||(e.stopPropagation(),o._state!==o.STATE.ROTATE||o.noRotate?o._state!==o.STATE.ZOOM||o.noZoom?o._state!==o.STATE.PAN||o.noPan||o._panEnd.copy(b(e.pageX,e.pageY)):o._zoomEnd.copy(b(e.pageX,e.pageY)):o._rotateEnd.copy(w(e.pageX,e.pageY)))}function C(e){!1===o.enabled||Object.keys(window).length<2||(e.stopPropagation(),o._state=o.STATE.NONE,document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",C),o.dispatchEvent(u))}function R(e){if(!(!1===o.enabled||Object.keys(window).length<2)){e.stopPropagation();var t=0;e.wheelDelta?t=e.wheelDelta/40:e.detail&&(t=-e.detail/3),o._zoomStart.y=.005*t,o.dispatchEvent(l),o.dispatchEvent(u)}}this.rotateCamera=(m=new THREE.Vector3,g=new THREE.Quaternion,function(e,t){var n;void 0===e&&(n=Math.acos(o._rotateStart.dot(o._rotateEnd)/o._rotateStart.length()/o._rotateEnd.length())),(n||void 0!==e)&&(void 0===e?(m.crossVectors(o._rotateStart,o._rotateEnd).normalize(),n*=o.rotateSpeed,g.setFromAxisAngle(m,-n)):g.copy(e),void 0===i||void 0===i.quaternion||void 0!==t&&!0!==t||i.quaternion.multiplyQuaternions(g,i.quaternion),a.applyQuaternion(g),o.object.up.applyQuaternion(g),o._rotateEnd.applyQuaternion(g),o.staticMoving?o._rotateStart.copy(o._rotateEnd):(g.setFromAxisAngle(m,n*(o.dynamicDampingFactor-1)),o._rotateStart.applyQuaternion(g)))}),this.zoomCamera=function(e,t){var n;o._state===o.STATE.TOUCH_ZOOM_PAN?(void 0!==e?n=e:(n=s/c,s=c),a.multiplyScalar(n),void 0===i||void 0===i._zoomFactor||void 0!==t&&!0!==t||(i._zoomFactor*=n,i.fogCls.setFog())):(n=void 0!==e?e:1+(o._zoomEnd.y-o._zoomStart.y)*o.zoomSpeed,void 0===i||void 0===i._zoomFactor||void 0!==t&&!0!==t||(i._zoomFactor*=n,i.fogCls.setFog()),1!==n&&(a.multiplyScalar(n),o.staticMoving?o._zoomStart.copy(o._zoomEnd):o._zoomStart.y+=(o._zoomEnd.y-o._zoomStart.y)*this.dynamicDampingFactor))},this.panCamera=(y=new THREE.Vector2,E=new THREE.Vector3,_=new THREE.Vector3,function(e,t){void 0!==e?(y=e,void 0===i||void 0===i.mouseChange||void 0!==t&&!0!==t||i.mouseChange.add(e)):(y.copy(o._panEnd).sub(o._panStart),void 0===i||void 0===i.mouseChange||void 0!==t&&!0!==t||i.mouseChange.add(o._panEnd).sub(o._panStart)),y.lengthSq()&&(y.multiplyScalar(a.length()*o.panSpeed),_.copy(a).cross(o.object.up).setLength(y.x),_.add(E.copy(o.object.up).setLength(y.y)),o.object.position.add(_),o.target.add(_),o.staticMoving?o._panStart.copy(o._panEnd):o._panStart.add(y.subVectors(o._panEnd,o._panStart).multiplyScalar(o.dynamicDampingFactor)))}),this.checkDistances=function(){o.noZoom&&o.noPan||(a.lengthSq()>o.maxDistance*o.maxDistance&&o.object.position.addVectors(o.target,a.setLength(o.maxDistance)),a.lengthSq()1e-6&&(o.dispatchEvent(d),n.copy(o.object.position))},this.reset=function(){o._state=o.STATE.NONE,r=o.STATE.NONE,o.target.copy(o.target0),o.object.position.copy(o.position0),o.object.up.copy(o.up0),a.subVectors(o.object.position,o.target),o.object.lookAt(o.target),o.dispatchEvent(d),n.copy(o.object.position)},Object.keys(window).length>=2&&(this.domElement.addEventListener("contextmn",function(e){},!1),this.domElement.addEventListener("mousedown",function(e){!1===o.enabled||Object.keys(window).length<2||(e.stopPropagation(),o._state===o.STATE.NONE&&(o._state=e.button),o._state!==o.STATE.ROTATE||o.noRotate?o._state!==o.STATE.ZOOM||o.noZoom?o._state!==o.STATE.PAN||o.noPan||(o._panStart.copy(b(e.pageX,e.pageY)),o._panEnd.copy(o._panStart)):(o._zoomStart.copy(b(e.pageX,e.pageY)),o._zoomEnd.copy(o._zoomStart)):(o._rotateStart.copy(w(e.pageX,e.pageY)),o._rotateEnd.copy(o._rotateStart)),document.addEventListener("mousemove",x,!1),document.addEventListener("mouseup",C,!1),o.dispatchEvent(l))},!1),this.domElement.addEventListener("mousewheel",R,!1),this.domElement.addEventListener("DOMMouseScroll",R,!1),this.domElement.addEventListener("touchstart",function(e){if(!(!1===o.enabled||Object.keys(window).length<2)){switch(e.touches.length){case 1:o._state=o.STATE.TOUCH_ROTATE,o._rotateStart.copy(w(e.touches[0].pageX,e.touches[0].pageY)),o._rotateEnd.copy(o._rotateStart);break;case 2:o._state=o.STATE.TOUCH_ZOOM_PAN;var t=e.touches[0].pageX-e.touches[1].pageX,i=e.touches[0].pageY-e.touches[1].pageY;c=s=Math.sqrt(t*t+i*i);var n=(e.touches[0].pageX+e.touches[1].pageX)/2,r=(e.touches[0].pageY+e.touches[1].pageY)/2;o._panStart.copy(b(n,r)),o._panEnd.copy(o._panStart);break;default:o._state=o.STATE.NONE}o.dispatchEvent(l)}},!1),this.domElement.addEventListener("touchend",function(e){if(!(!1===o.enabled||Object.keys(window).length<2)){switch(e.touches.length){case 1:o._rotateEnd.copy(w(e.touches[0].pageX,e.touches[0].pageY)),o._rotateStart.copy(o._rotateEnd);break;case 2:s=c=0;var t=(e.touches[0].pageX+e.touches[1].pageX)/2,i=(e.touches[0].pageY+e.touches[1].pageY)/2;o._panEnd.copy(b(t,i)),o._panStart.copy(o._panEnd)}o._state=o.STATE.NONE,o.dispatchEvent(u)}},!1),this.domElement.addEventListener("touchmove",function(e){if(!(!1===o.enabled||Object.keys(window).length<2))switch(e.stopPropagation(),e.touches.length){case 1:o._rotateEnd.copy(w(e.touches[0].pageX,e.touches[0].pageY));break;case 2:var t=e.touches[0].pageX-e.touches[1].pageX,i=e.touches[0].pageY-e.touches[1].pageY;c=Math.sqrt(t*t+i*i);var n=(e.touches[0].pageX+e.touches[1].pageX)/2,r=(e.touches[0].pageY+e.touches[1].pageY)/2;o._panEnd.copy(b(n,r));break;default:o._state=o.STATE.NONE}},!1),Object.keys(window).length>=2&&window.addEventListener("keydown",T,!1),Object.keys(window).length>=2&&window.addEventListener("keyup",function(e){!1===o.enabled||Object.keys(window).length<2||(o._state=r,window.addEventListener("keydown",T,!1))},!1)),this.handleResize(),this.update()},THREE.TrackballControls.prototype=Object.create(THREE.EventDispatcher.prototype),THREE.TrackballControls.prototype.constructor=THREE.TrackballControls,THREE.OrthographicTrackballControls=function(e,t,i){this.icn3d;var o=this,n={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4};this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.screen={left:0,top:0,width:0,height:0},this.rotateSpeed=.5,this.zoomSpeed=1.2;this.zoomSpeed*=.01,this.panSpeed=.03,this.noRotate=!1,this.noZoom=!1,this.noPan=!1,this.noRoll=!1,this.staticMoving=!1,this.dynamicDampingFactor=.2,this.keys=[65,83,68],this.target=new THREE.Vector3;var r=new THREE.Vector3;this._state=n.NONE;var a=n.NONE,s=new THREE.Vector3;this._rotateStart=new THREE.Vector3,this._rotateEnd=new THREE.Vector3,this._zoomStart=new THREE.Vector2,this._zoomEnd=new THREE.Vector2;var c=1,d=0,l=0;this._panStart=new THREE.Vector2,this._panEnd=new THREE.Vector2,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.up0=this.object.up.clone(),this.left0=this.object.left,this.right0=this.object.right,this.top0=this.object.top,this.bottom0=this.object.bottom,this.center0=new THREE.Vector2((this.left0+this.right0)/2,(this.top0+this.bottom0)/2);var u={type:"change"},p={type:"start"},f={type:"end"};this.handleResize=function(){if(this.domElement===document)this.screen.left=0,this.screen.top=0,this.screen.width=window.innerWidth,this.screen.height=window.innerHeight;else{var e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}this.left0=this.object.left,this.right0=this.object.right,this.top0=this.object.top,this.bottom0=this.object.bottom,this.center0.set((this.left0+this.right0)/2,(this.top0+this.bottom0)/2)},this.handleEvent=function(e){"function"==typeof this[e.type]&&this[e.type](e)};var v,h,m,g,y,E,_,b,w,T=(v=new THREE.Vector2,function(e,t){return v.set((e-o.screen.left)/o.screen.width,(t-o.screen.top)/o.screen.height),v}),x=(h=new THREE.Vector3,m=new THREE.Vector3,g=new THREE.Vector3,function(e,t){g.set((e-.5*o.screen.width-o.screen.left)/(.5*o.screen.width),(.5*o.screen.height+o.screen.top-t)/(.5*o.screen.height),0);var i=g.length();return o.noRoll?i1?g.normalize():g.z=Math.sqrt(1-i*i),s.copy(o.object.position).sub(o.target),h.copy(o.object.up).setLength(g.y),h.add(m.copy(o.object.up).cross(s).setLength(g.x)),h.add(s.setLength(g.z)),h});function C(e){!1===o.enabled||Object.keys(window).length<2||(window.removeEventListener("keydown",C),a=o._state,o._state===n.NONE&&(e.keyCode!==o.keys[n.ROTATE]||o.noRotate?e.keyCode!==o.keys[n.ZOOM]||o.noZoom?e.keyCode!==o.keys[n.PAN]||o.noPan||(o._state=n.PAN):o._state=n.ZOOM:o._state=n.ROTATE))}function R(e){!1===o.enabled||Object.keys(window).length<2||(e.stopPropagation(),o._state!==n.ROTATE||o.noRotate?o._state!==n.ZOOM||o.noZoom?o._state!==n.PAN||o.noPan||o._panEnd.copy(T(e.pageX,e.pageY)):o._zoomEnd.copy(T(e.pageX,e.pageY)):o._rotateEnd.copy(x(e.pageX,e.pageY)))}function S(e){!1===o.enabled||Object.keys(window).length<2||(e.stopPropagation(),o._state=n.NONE,document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",S),o.dispatchEvent(f))}function L(e){if(!(!1===o.enabled||Object.keys(window).length<2)){e.stopPropagation();var t=0;e.wheelDelta?t=e.wheelDelta/40:e.detail&&(t=-e.detail/3),o._zoomStart.y=.01*t,o.dispatchEvent(p),o.dispatchEvent(f)}}this.rotateCamera=(y=new THREE.Vector3,E=new THREE.Quaternion,function(e,t){var n;void 0===e&&(n=Math.acos(o._rotateStart.dot(o._rotateEnd)/o._rotateStart.length()/o._rotateEnd.length())),(n||void 0!==e)&&(void 0===e?(y.crossVectors(o._rotateStart,o._rotateEnd).normalize(),n*=o.rotateSpeed,E.setFromAxisAngle(y,-n)):E.copy(e),void 0===i||void 0===i.quaternion||void 0!==t&&!0!==t||i.quaternion.multiplyQuaternions(E,i.quaternion),s.applyQuaternion(E),o.object.up.applyQuaternion(E),o._rotateEnd.applyQuaternion(E),o.staticMoving?o._rotateStart.copy(o._rotateEnd):(E.setFromAxisAngle(y,n*(o.dynamicDampingFactor-1)),o._rotateStart.applyQuaternion(E)))}),this.zoomCamera=function(e,t){var r;o._state===n.TOUCH_ZOOM_PAN?void 0!==e?r=e:(r=d/l,d=l):r=void 0!==e?e:1+(o._zoomEnd.y-o._zoomStart.y)*o.zoomSpeed/.01,void 0===i||void 0===i._zoomFactor||void 0!==t&&!0!==t||(i._zoomFactor*=r),1!==r&&(c=r,o.object.left=c*o.left0+(1-c)*o.center0.x,o.object.right=c*o.right0+(1-c)*o.center0.x,o.object.top=c*o.top0+(1-c)*o.center0.y,o.object.bottom=c*o.bottom0+(1-c)*o.center0.y,o.staticMoving?o._zoomStart.copy(o._zoomEnd):o._zoomStart.y+=(o._zoomEnd.y-o._zoomStart.y)*this.dynamicDampingFactor)},this.panCamera=(_=new THREE.Vector2,b=new THREE.Vector3,w=new THREE.Vector3,function(e,t){void 0!==e?(_=e,void 0===i||void 0===i.mouseChange||void 0!==t&&!0!==t||i.mouseChange.add(e)):(_.copy(o._panEnd).sub(o._panStart),void 0===i||void 0===i.mouseChange||void 0!==t&&!0!==t||i.mouseChange.add(o._panEnd).sub(o._panStart)),_.lengthSq()&&(_.multiplyScalar(s.length()*o.panSpeed),w.copy(s).cross(o.object.up).setLength(_.x),w.add(b.copy(o.object.up).setLength(_.y)),o.object.position.add(w),o.target.add(w),o.staticMoving?o._panStart.copy(o._panEnd):o._panStart.add(_.subVectors(o._panEnd,o._panStart).multiplyScalar(o.dynamicDampingFactor)))}),this.update=function(e){s.subVectors(o.object.position,o.target),o.noRotate||(void 0!==e&&void 0!==e.quaternion?o.rotateCamera(e.quaternion,e.update):o.rotateCamera()),o.noZoom||(void 0!==e&&void 0!==e._zoomFactor?o.zoomCamera(e._zoomFactor,e.update):o.zoomCamera(),o.object.updateProjectionMatrix()),o.noPan||(void 0!==e&&void 0!==e.mouseChange?o.panCamera(e.mouseChange,e.update):o.panCamera()),o.object.position.addVectors(o.target,s),o.object.lookAt(o.target),r.distanceToSquared(o.object.position)>1e-6&&(o.dispatchEvent(u),r.copy(o.object.position))},this.reset=function(){o._state=n.NONE,a=n.NONE,o.target.copy(o.target0),o.object.position.copy(o.position0),o.object.up.copy(o.up0),s.subVectors(o.object.position,o.target),o.object.left=o.left0,o.object.right=o.right0,o.object.top=o.top0,o.object.bottom=o.bottom0,o.object.lookAt(o.target),o.dispatchEvent(u),r.copy(o.object.position)},Object.keys(window).length>=2&&(this.domElement.addEventListener("contextmn",function(e){},!1),this.domElement.addEventListener("mousedown",function(e){!1===o.enabled||Object.keys(window).length<2||(e.stopPropagation(),o._state===n.NONE&&(o._state=e.button),o._state!==n.ROTATE||o.noRotate?o._state!==n.ZOOM||o.noZoom?o._state!==n.PAN||o.noPan||(o._panStart.copy(T(e.pageX,e.pageY)),o._panEnd.copy(o._panStart)):(o._zoomStart.copy(T(e.pageX,e.pageY)),o._zoomEnd.copy(o._zoomStart)):(o._rotateStart.copy(x(e.pageX,e.pageY)),o._rotateEnd.copy(o._rotateStart)),document.addEventListener("mousemove",R,!1),document.addEventListener("mouseup",S,!1),o.dispatchEvent(p))},!1),this.domElement.addEventListener("mousewheel",L,!1),this.domElement.addEventListener("DOMMouseScroll",L,!1),this.domElement.addEventListener("touchstart",function(e){if(!(!1===o.enabled||Object.keys(window).length<2)){switch(e.touches.length){case 1:o._state=n.TOUCH_ROTATE,o._rotateStart.copy(x(e.touches[0].pageX,e.touches[0].pageY)),o._rotateEnd.copy(o._rotateStart);break;case 2:o._state=n.TOUCH_ZOOM_PAN;var t=e.touches[0].pageX-e.touches[1].pageX,i=e.touches[0].pageY-e.touches[1].pageY;l=d=Math.sqrt(t*t+i*i);var r=(e.touches[0].pageX+e.touches[1].pageX)/2,a=(e.touches[0].pageY+e.touches[1].pageY)/2;o._panStart.copy(T(r,a)),o._panEnd.copy(o._panStart);break;default:o._state=n.NONE}o.dispatchEvent(p)}},!1),this.domElement.addEventListener("touchend",function(e){if(!(!1===o.enabled||Object.keys(window).length<2)){switch(e.touches.length){case 1:o._rotateEnd.copy(x(e.touches[0].pageX,e.touches[0].pageY)),o._rotateStart.copy(o._rotateEnd);break;case 2:d=l=0;var t=(e.touches[0].pageX+e.touches[1].pageX)/2,i=(e.touches[0].pageY+e.touches[1].pageY)/2;o._panEnd.copy(T(t,i)),o._panStart.copy(o._panEnd)}o._state=n.NONE,o.dispatchEvent(f)}},!1),this.domElement.addEventListener("touchmove",function(e){if(!(!1===o.enabled||Object.keys(window).length<2))switch(e.stopPropagation(),e.touches.length){case 1:o._rotateEnd.copy(x(e.touches[0].pageX,e.touches[0].pageY));break;case 2:var t=e.touches[0].pageX-e.touches[1].pageX,i=e.touches[0].pageY-e.touches[1].pageY;l=Math.sqrt(t*t+i*i);var r=(e.touches[0].pageX+e.touches[1].pageX)/2,a=(e.touches[0].pageY+e.touches[1].pageY)/2;o._panEnd.copy(T(r,a));break;default:o._state=n.NONE}},!1),window.addEventListener("keydown",C,!1),window.addEventListener("keyup",function(e){!1===o.enabled||Object.keys(window).length<2||(o._state=a,window.addEventListener("keydown",C,!1))},!1)),this.handleResize(),this.update()},THREE.OrthographicTrackballControls.prototype=Object.create(THREE.EventDispatcher.prototype),THREE.OrthographicTrackballControls.prototype.constructor=THREE.OrthographicTrackballControls;var MMTF={};function initIcn3dpyMMTF(e){function t(e,t,i){for(var o=(e.byteLength,0),n=i.length;n>o;o++){var r=i.charCodeAt(o);if(128>r)e.setUint8(t++,r>>>0&127|0);else if(2048>r)e.setUint8(t++,r>>>6&31|192),e.setUint8(t++,r>>>0&63|128);else if(65536>r)e.setUint8(t++,r>>>12&15|224),e.setUint8(t++,r>>>6&63|128),e.setUint8(t++,r>>>0&63|128);else{if(!(1114112>r))throw new Error("bad codepoint "+r);e.setUint8(t++,r>>>18&7|240),e.setUint8(t++,r>>>12&63|128),e.setUint8(t++,r>>>6&63|128),e.setUint8(t++,r>>>0&63|128)}}}function i(e){for(var t=0,i=0,o=e.length;o>i;i++){var n=e.charCodeAt(i);if(128>n)t+=1;else if(2048>n)t+=2;else if(65536>n)t+=3;else{if(!(1114112>n))throw new Error("bad codepoint "+n);t+=4}}return t}function o(e){var o=new ArrayBuffer(function e(t){var o=typeof t;if("string"===o){if(32>(n=i(t)))return 1+n;if(256>n)return 2+n;if(65536>n)return 3+n;if(4294967296>n)return 5+n}if(t instanceof Uint8Array){if(256>(n=t.byteLength))return 2+n;if(65536>n)return 3+n;if(4294967296>n)return 5+n}if("number"===o){if(Math.floor(t)!==t)return 9;if(t>=0){if(128>t)return 1;if(256>t)return 2;if(65536>t)return 3;if(4294967296>t)return 5;throw new Error("Number too big 0x"+t.toString(16))}if(t>=-32)return 1;if(t>=-128)return 2;if(t>=-32768)return 3;if(t>=-2147483648)return 5;throw new Error("Number too small -0x"+t.toString(16).substr(1))}if("boolean"===o||null===t)return 1;if("object"===o){var n,r=0;if(Array.isArray(t)){n=t.length;for(var a=0;n>a;a++)r+=e(t[a])}else{var s=Object.keys(t);for(n=s.length,a=0;n>a;a++){var c=s[a];r+=e(c)+e(t[c])}}if(16>n)return 1+r;if(65536>n)return 3+r;if(4294967296>n)return 5+r;throw new Error("Array or object too long 0x"+n.toString(16))}throw new Error("Unknown type "+o)}(e));return function e(o,n,r){var a=typeof o;if("string"===a){if(32>(s=i(o)))return n.setUint8(r,160|s),t(n,r+1,o),1+s;if(256>s)return n.setUint8(r,217),n.setUint8(r+1,s),t(n,r+2,o),2+s;if(65536>s)return n.setUint8(r,218),n.setUint16(r+1,s),t(n,r+3,o),3+s;if(4294967296>s)return n.setUint8(r,219),n.setUint32(r+1,s),t(n,r+5,o),5+s}if(o instanceof Uint8Array){var s=o.byteLength,c=new Uint8Array(n.buffer);if(256>s)return n.setUint8(r,196),n.setUint8(r+1,s),c.set(o,r+2),2+s;if(65536>s)return n.setUint8(r,197),n.setUint16(r+1,s),c.set(o,r+3),3+s;if(4294967296>s)return n.setUint8(r,198),n.setUint32(r+1,s),c.set(o,r+5),5+s}if("number"===a){if(!isFinite(o))throw new Error("Number not finite: "+o);if(Math.floor(o)!==o)return n.setUint8(r,203),n.setFloat64(r+1,o),9;if(o>=0){if(128>o)return n.setUint8(r,o),1;if(256>o)return n.setUint8(r,204),n.setUint8(r+1,o),2;if(65536>o)return n.setUint8(r,205),n.setUint16(r+1,o),3;if(4294967296>o)return n.setUint8(r,206),n.setUint32(r+1,o),5;throw new Error("Number too big 0x"+o.toString(16))}if(o>=-32)return n.setInt8(r,o),1;if(o>=-128)return n.setUint8(r,208),n.setInt8(r+1,o),2;if(o>=-32768)return n.setUint8(r,209),n.setInt16(r+1,o),3;if(o>=-2147483648)return n.setUint8(r,210),n.setInt32(r+1,o),5;throw new Error("Number too small -0x"+(-o).toString(16).substr(1))}if(null===o)return n.setUint8(r,192),1;if("boolean"===a)return n.setUint8(r,o?195:194),1;if("object"===a){var d=0,l=Array.isArray(o);if(l)s=o.length;else{var u=Object.keys(o);s=u.length}if(16>s?(n.setUint8(r,s|(l?144:128)),d=1):65536>s?(n.setUint8(r,l?220:222),n.setUint16(r+1,s),d=3):4294967296>s&&(n.setUint8(r,l?221:223),n.setUint32(r+1,s),d=5),l)for(var p=0;s>p;p++)d+=e(o[p],n,r+d);else for(p=0;s>p;p++){var f=u[p];d+=e(f,n,r+d),d+=e(o[f],n,r+d)}return d}throw new Error("Unknown type "+a)}(e,new DataView(o),0),new Uint8Array(o)}function n(e,t,i){return t?new e(t.buffer,t.byteOffset,t.byteLength/(i||1)):void 0}function r(e){return n(DataView,e)}function a(e){return n(Uint8Array,e)}function s(e){return n(Int8Array,e)}function c(e){return n(Int32Array,e,4)}function d(e,t){var i=e.length/2;t||(t=new Int16Array(i));for(var o=0,n=0;i>o;++o,n+=2)t[o]=e[n]<<8^e[n+1]<<0;return t}function l(e,t){var i=e.length/4;t||(t=new Int32Array(i));for(var o=0,n=0;i>o;++o,n+=4)t[o]=e[n]<<24^e[n+1]<<16^e[n+2]<<8^e[n+3]<<0;return t}function u(e,t){var i=e.length;t||(t=new Uint8Array(4*i));for(var o=r(t),n=0;i>n;++n)o.setInt32(4*n,e[n]);return a(t)}function p(e,t,i){var o=e.length,n=1/t;i||(i=new Float32Array(o));for(var r=0;o>r;++r)i[r]=e[r]*n;return i}function f(e,t,i){var o=e.length;i||(i=new Int32Array(o));for(var n=0;o>n;++n)i[n]=Math.round(e[n]*t);return i}function v(e,t){var i,o;if(!t){var n=0;for(i=0,o=e.length;o>i;i+=2)n+=e[i+1];t=new e.constructor(n)}var r=0;for(i=0,o=e.length;o>i;i+=2)for(var a=e[i],s=e[i+1],c=0;s>c;++c)t[r]=a,++r;return t}function h(e){if(0===e.length)return new Int32Array;var t,i,o=2;for(t=1,i=e.length;i>t;++t)e[t-1]!==e[t]&&(o+=2);var n=new Int32Array(o),r=0,a=1;for(t=1,i=e.length;i>t;++t)e[t-1]!==e[t]?(n[r]=e[t-1],n[r+1]=a,a=1,r+=2):++a;return n[r]=e[e.length-1],n[r+1]=a,n}function m(e,t){var i=e.length;t||(t=new e.constructor(i)),i&&(t[0]=e[0]);for(var o=1;i>o;++o)t[o]=e[o]+t[o-1];return t}function g(e,t){var i=e.length;t||(t=new e.constructor(i)),t[0]=e[0];for(var o=1;i>o;++o)t[o]=e[o]-e[o-1];return t}function y(e,t){var i,o,n=e instanceof Int8Array?127:32767,r=-n-1,a=e.length;if(!t){var s=0;for(i=0;a>i;++i)e[i]r&&++s;t=new Int32Array(s)}for(i=0,o=0;a>i;){for(var c=0;e[i]===n||e[i]===r;)c+=e[i],++i;c+=e[i],++i,t[o]=c,++o}return t}function E(e,t,i){return p(y(e,c(i)),t,i)}function _(e,t,i){var o,r,a,s=y(e,c(i));return o=s,r=t,a=n(Float32Array,s,4),p(m(o,c(a)),r,a)}function b(e,t,i){return function(e,t){var i,o=t?127:32767,n=-o-1,r=e.length,a=0;for(i=0;r>i;++i)0===(d=e[i])?++a:d>0?(a+=Math.ceil(d/o),d%o==0&&(a+=1)):(a+=Math.ceil(d/n),d%n==0&&(a+=1));var s=t?new Int8Array(a):new Int16Array(a),c=0;for(i=0;r>i;++i){var d;if((d=e[i])>=0)for(;d>=o;)s[c]=o,++c,d-=o;else for(;n>=d;)s[c]=n,++c,d-=n;s[c]=d,++c}return s}(g(f(e,t),o),i);var o}function w(e,t,i,o){var n=new ArrayBuffer(12+o.byteLength),r=new Uint8Array(n),a=new DataView(n);return a.setInt32(0,e),a.setInt32(4,t),i&&r.set(i,8),r.set(o,12),r}function T(e){return w(2,e.length,void 0,a(e))}function x(e){return w(4,e.length,void 0,u(e))}function C(e,t){return w(5,e.length/t,u([t]),a(e))}function R(e){return w(6,e.length,void 0,u(h(e)))}function S(e){return w(8,e.length,void 0,u(h(g(e))))}function L(e,t){return w(9,e.length,u([t]),u(h(f(e,t))))}function A(e,t){return w(10,e.length,u([t]),function(e,t){var i=e.length;t||(t=new Uint8Array(2*i));for(var o=r(t),n=0;i>n;++n)o.setInt16(2*n,e[n]);return a(t)}(b(e,t)))}function I(e){var t={};return D.forEach(function(i){void 0!==e[i]&&(t[i]=e[i])}),e.bondAtomList&&(t.bondAtomList=x(e.bondAtomList)),e.bondOrderList&&(t.bondOrderList=T(e.bondOrderList)),t.xCoordList=A(e.xCoordList,1e3),t.yCoordList=A(e.yCoordList,1e3),t.zCoordList=A(e.zCoordList,1e3),e.bFactorList&&(t.bFactorList=A(e.bFactorList,100)),e.atomIdList&&(t.atomIdList=S(e.atomIdList)),e.altLocList&&(t.altLocList=R(e.altLocList)),e.occupancyList&&(t.occupancyList=L(e.occupancyList,100)),t.groupIdList=S(e.groupIdList),t.groupTypeList=x(e.groupTypeList),e.secStructList&&(t.secStructList=T(e.secStructList)),e.insCodeList&&(t.insCodeList=R(e.insCodeList)),e.sequenceIndexList&&(t.sequenceIndexList=S(e.sequenceIndexList)),t.chainIdList=C(e.chainIdList,4),e.chainNameList&&(t.chainNameList=C(e.chainNameList,4)),t}function O(e){function t(e){for(var t={},i=0;e>i;i++){t[r()]=r()}return t}function i(t){var i=e.subarray(a,a+t);return a+=t,i}function o(t){var i=e.subarray(a,a+t);a+=t;if(t>65535){for(var o=[],n=0;ni;i++)t[i]=r();return t}function r(){var r,c,d=e[a];if(0==(128&d))return a++,d;if(128==(240&d))return a++,t(c=15&d);if(144==(240&d))return a++,n(c=15&d);if(160==(224&d))return a++,o(c=31&d);if(224==(224&d))return r=s.getInt8(a),a++,r;switch(d){case 192:return a++,null;case 194:return a++,!1;case 195:return a++,!0;case 196:return c=s.getUint8(a+1),a+=2,i(c);case 197:return c=s.getUint16(a+1),a+=3,i(c);case 198:return c=s.getUint32(a+1),a+=5,i(c);case 202:return r=s.getFloat32(a+1),a+=5,r;case 203:return r=s.getFloat64(a+1),a+=9,r;case 204:return r=e[a+1],a+=2,r;case 205:return r=s.getUint16(a+1),a+=3,r;case 206:return r=s.getUint32(a+1),a+=5,r;case 208:return r=s.getInt8(a+1),a+=2,r;case 209:return r=s.getInt16(a+1),a+=3,r;case 210:return r=s.getInt32(a+1),a+=5,r;case 217:return c=s.getUint8(a+1),a+=2,o(c);case 218:return c=s.getUint16(a+1),a+=3,o(c);case 219:return c=s.getUint32(a+1),a+=5,o(c);case 220:return c=s.getUint16(a+1),a+=3,n(c);case 221:return c=s.getUint32(a+1),a+=5,n(c);case 222:return c=s.getUint16(a+1),a+=3,t(c);case 223:return c=s.getUint32(a+1),a+=5,t(c)}throw new Error("Unknown type 0x"+d.toString(16))}var a=0,s=new DataView(e.buffer);return r()}function N(e,t,i,o){switch(e){case 1:return function(e,t){var i=e.length;t||(t=new Float32Array(i/4));for(var o=r(t),n=r(e),a=0,s=0,c=i/4;c>a;++a,s+=4)o.setFloat32(s,n.getFloat32(s),!0);return t}(t);case 2:return s(t);case 3:return d(t);case 4:return l(t);case 5:return a(t);case 6:return v(l(t),new Uint8Array(i));case 7:return v(l(t));case 8:return m(v(l(t)),h);case 9:return n=l(t),u=l(o)[0],p(v(n,c(f)),u,f);case 10:return _(d(t),l(o)[0]);case 11:return p(d(t),l(o)[0]);case 12:return E(d(t),l(o)[0]);case 13:return E(s(t),l(o)[0]);case 14:return y(d(t));case 15:return y(s(t))}var n,u,f,h}function P(e,t){var i=(t=t||{}).ignoreFields,o={};return j.forEach(function(t){var n,a,s,c,d,l=!!i&&-1!==i.indexOf(t),u=e[t];l||void 0===u||(u instanceof Uint8Array?o[t]=N.apply(null,(a=r(n=u),s=a.getInt32(0),c=a.getInt32(4),d=n.subarray(8,12),[s,n=n.subarray(12),c,d])):o[t]=u)}),o}function M(e){return String.fromCharCode.apply(null,e).replace(/\0/g,"")}function H(e,t){return e instanceof ArrayBuffer&&(e=new Uint8Array(e)),P(e instanceof Uint8Array?O(e):e,t)}function z(e,t,i,o){var n=new XMLHttpRequest;n.addEventListener("load",function(){try{var e=H(n.response);i(e)}catch(e){o(e)}},!0),n.addEventListener("error",o,!0),n.responseType="arraybuffer",n.open("GET",t+e.toUpperCase()),n.send()}var D=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"],j=D.concat(["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"]),F="//mmtf.rcsb.org/v1.0/",V=F+"full/",U=F+"reduced/";return e.encode=function(e){return o(I(e))},e.decode=H,e.traverse=function(e,t,i){var o,n,r,a,s,c,d=(i=i||{}).firstModelOnly,l=t.onModel,u=t.onChain,p=t.onGroup,f=t.onAtom,v=t.onBond,h=0,m=0,g=0,y=0,E=0,_=-1,b=e.chainNameList,w=e.secStructList,T=e.insCodeList,x=e.sequenceIndexList,C=e.atomIdList,R=e.bFactorList,S=e.altLocList,L=e.occupancyList,A=e.bondAtomList,I=e.bondOrderList;for(o=0,n=e.chainsPerModel.length;n>o&&!(d&&h>0);++o){var O=e.chainsPerModel[h];for(l&&l({chainCount:O,modelIndex:h}),r=0;O>r;++r){var N=e.groupsPerChain[m];if(u){var P=M(e.chainIdList.subarray(4*m,4*m+4)),H=null;b&&(H=M(b.subarray(4*m,4*m+4))),u({groupCount:N,chainIndex:m,modelIndex:h,chainId:P,chainName:H})}for(a=0;N>a;++a){var z=e.groupList[e.groupTypeList[g]],D=z.atomNameList.length;if(p){var j=null;w&&(j=w[g]);var F=null;e.insCodeList&&(F=String.fromCharCode(T[g]));var V=null;x&&(V=x[g]),p({atomCount:D,groupIndex:g,chainIndex:m,modelIndex:h,groupId:e.groupIdList[g],groupType:e.groupTypeList[g],groupName:z.groupName,singleLetterCode:z.singleLetterCode,chemCompType:z.chemCompType,secStruct:j,insCode:F,sequenceIndex:V})}for(s=0;D>s;++s){if(f){var U=null;C&&(U=C[y]);var k=null;R&&(k=R[y]);var G=null;S&&(G=String.fromCharCode(S[y]));var B=null;L&&(B=L[y]),f({atomIndex:y,groupIndex:g,chainIndex:m,modelIndex:h,atomId:U,element:z.elementList[s],atomName:z.atomNameList[s],formalCharge:z.formalChargeList[s],xCoord:e.xCoordList[y],yCoord:e.yCoordList[y],zCoord:e.zCoordList[y],bFactor:k,altLoc:G,occupancy:B})}y+=1}if(v){var X=z.bondAtomList;for(s=0,c=z.bondOrderList.length;c>s;++s)v({atomIndex1:y-D+X[2*s],atomIndex2:y-D+X[2*s+1],bondOrder:z.bondOrderList[s]})}g+=1}m+=1}if(E=_+1,_=y-1,v&&A)for(s=0,c=A.length;c>s;s+=2){var q=A[s],W=A[s+1];(q>=E&&_>=q||W>=E&&_>=W)&&v({atomIndex1:q,atomIndex2:W,bondOrder:I?I[s/2]:null})}h+=1}},e.fetch=function(e,t,i){z(e,V,t,i)},e.fetchReduced=function(e,t,i){z(e,U,t,i)},e.version="v1.0.1",e.fetchUrl=V,e.fetchReducedUrl=U,e.encodeMsgpack=o,e.encodeMmtf=I,e.decodeMsgpack=O,e.decodeMmtf=P,e}MMTF=initIcn3dpyMMTF(MMTF),function(e,t,i){var o,n="__instance__",r="firstChild",a=setTimeout;function s(e){return void 0!==e}function c(e){return"object"==typeof e}function d(e){return Object.keys(e).length}function l(e,t,i){return ei?i:e}function u(e,t){return parseInt(e,t||10)}function p(e){return Math.round(e)}function f(e){var t,i,o,n,r,a,s,c,d=+e[0],l=+e[1],u=+e[2];switch(a=u*(1-l),s=u*(1-(r=6*d-(n=Math.floor(6*d)))*l),c=u*(1-(1-r)*l),n=n||0,s=s||0,c=c||0,n%6){case 0:t=u,i=c,o=a;break;case 1:t=s,i=u,o=a;break;case 2:t=a,i=u,o=c;break;case 3:t=a,i=s,o=u;break;case 4:t=c,i=a,o=u;break;case 5:t=u,i=a,o=s}return[p(255*t),p(255*i),p(255*o)]}function v(e){return m(f(e))}function h(e){var t,i=+e[0],o=+e[1],n=+e[2],r=Math.max(i,o,n),a=Math.min(i,o,n),s=r-a,c=0===r?0:s/r,d=r/255;switch(r){case a:t=0;break;case i:t=o-n+s*(o
    ';var H,z=_[r].children,D=N([0,1,1]),j=z[0],F=z[1],V=j[r],U=F[r],k=0,G=0,B=0,X=0,q=0,W=0,Y=0,Z=0,Q=v(D);function K(e,t){e&&"h"!==e||M("change:h",t),e&&"sv"!==e||M("change:sv",t),M("change",t)}function $(){return _.parentNode}function J(n,r){n||((u||r||p).appendChild(_),m.visible=!0),Y=O(_).w,Z=O(_).h;var a=O(F),s=O(U),c=O(j).h,d=a.w,h=a.h,g=O(V).h,y=s.w,E=s.h;if(n){function L(e){var t=e.target,o=t===i||A(t,i)===i;o?J():m.exit(),M(o?"enter":"exit",[m])}_.style.left=_.style.top="-9999px",!1!==o&&C(o,i,L),m.create=function(){return J(1),M("create",[m]),m},m.destroy=function(){return!1!==o&&R(o,i,L),m.exit(),P(!1),M("destroy",[m]),m}}else ee();function z(e){f(D);var t=f([D[0],1,1]);F.style.backgroundColor="rgb("+t.join(",")+")",P(D),I(e)}function q(e){var t,i,o,n,r,a;B&&(i=l(S(j,t=e).y,0,c),D[0]=(c-i)/c,V.style.top=i-g/2+"px",z(t),Q=v(D),k||(M("drag:h",[Q,m]),M("drag",[Q,m]),K("h",[Q,m]))),X&&(n=S(F,o=e),r=l(n.x,0,d),a=l(n.y,0,h),D[1]=1-(d-r)/d,D[2]=(h-a)/h,U.style.right=d-r-y/2+"px",U.style.top=a-E/2+"px",z(o),Q=v(D),G||(M("drag:sv",[Q,m]),M("drag",[Q,m]),K("sv",[Q,m]))),k=0,G=0}function W(e){var t=e.target,n=B?"h":"sv",r=[v(D),m],a=t===i||A(t,i)===i,s=t===_||A(t,_)===_;a||s?s&&(M("stop:"+n,r),M("stop",r),K(n,r)):$()&&!1!==o&&(m.exit(),M("exit",[m]),K(0,r)),B=0,X=0}function te(e){k=1,B=1,q(e),I(e),M("start:h",[Q,m]),M("start",[Q,m]),K("h",[Q,m])}function ie(e){G=1,X=1,q(e),I(e),M("start:sv",[Q,m]),M("start",[Q,m]),K("sv",[Q,m])}H=function(){D=N(D),z(),V.style.top=c-g/2-c*+D[0]+"px",U.style.right=d-y/2-d*+D[1]+"px",U.style.top=h-E/2-h*+D[2]+"px"},m.exit=function(i){return $()&&($().removeChild(_),m.visible=!1),R(b,j,te),R(b,F,ie),R(w,t,q),R(T,t,W),R(x,e,ee),m},H(),n||(C(b,j,te),C(b,F,ie),C(w,t,q),C(T,t,W),C(x,e,ee))}function ee(){return m.fit()}return J(1),a(function(){var e=[v(D),m];M("create",e),K(0,e)},0),m.fit=function(t){var o=O(e),n=O(h),r=o.w-n.w,a=o.h-h.clientHeight,d=L(e),u=L(i);if(q=u.l+d.l,W=u.t+d.t+O(i).h,c(t))s(t[0])&&(q=t[0]),s(t[1])&&(W=t[1]);else{var p=d.l,f=d.t,v=d.l+o.w-Y-r,g=d.t+o.h-Z-a;q=l(q,p,v)>>0,W=l(W,f,g)>>0}return _.style.left=q+"px",_.style.top=W+"px",M("fit",[m]),m},m.set=function(e){return s(e)?("string"==typeof e&&(e=g.parse(e)),P(e),H(),m):N()},m.get=function(e){return N(e)},m.target=i,m.picker=_,m.visible=!1,m.on=function(e,t,i){return s(e)?s(t)?(s(E[e])||(E[e]={}),s(i)||(i=d(E[e])),E[e][i]=t,m):E[e]:E},m.off=function(e,t){return s(e)?s(t)?(delete E[e][t],m):(E[e]={},m):(E={},m)},m.fire=M,m.hooks=E,m.enter=function(e){return J(0,e)},m}).version="1.3.9",o[n]={},o.each=function(e,t){return a(function(){var t,i=o[n];for(t in i)e(i[t],t,i)},0===t?0:t||1),o},o.parse=b,o._HSV2RGB=f,o._HSV2HEX=v,o._RGB2HSV=h,o._HEX2HSV=g,o._HEX2RGB=function(e){return[+(t=y(e))[0]/255,+t[1]/255,+t[2]/255];var t},o.HSV2RGB=function(e){return f(E(e))},o.HSV2HEX=function(e){return v(E(e))},o.RGB2HSV=function(e){return _(h(e))},o.RGB2HEX=m,o.HEX2HSV=function(e){return _(g(e))},o.HEX2RGB=y}(window,document);var saveAs=function(e){"use strict";if(!(void 0===e||"undefined"!=typeof navigator&&/MSIE [1-9]\./.test(navigator.userAgent))){var t=function(){return e.URL||e.webkitURL||e},i=e.document.createElementNS("http://www.w3.org/1999/xhtml","a"),o="download"in i,n=/constructor/i.test(e.HTMLElement)||e.safari,r=/CriOS\/[\d]+/.test(navigator.userAgent),a=e.setImmediate||e.setTimeout,s=function(e){a(function(){throw e},0)},c=function(e){setTimeout(function(){"string"==typeof e?t().revokeObjectURL(e):e.remove()},4e4)},d=function(e){return/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob([String.fromCharCode(65279),e],{type:e.type}):e},l=function(l,u,p){p||(l=d(l));var f,v=this,h="application/octet-stream"===(l?l.type:void 0),m=function(){!function(e,t,i){for(var o=(t=[].concat(t)).length;o--;){var n=e["on"+t[o]];if("function"==typeof n)try{n.call(e,i||e)}catch(e){s(e)}}}(v,"writestart progress write writeend".split(" "))};if(v.readyState=v.INIT,o)return f||(f=t().createObjectURL(l)),void a(function(){var e,t;i.href=f,i.download=u,e=i,t=new MouseEvent("click"),e.dispatchEvent(t),m(),c(f),v.readyState=v.DONE},0);!function(){if((r||h&&n)&&e.FileReader){var i=new FileReader;return i.onloadend=function(){var t=r?i.result:i.result.replace(/^data:[^;]*;/,"data:attachment/file;");e.open(t,"_blank")||(e.location.href=t),t=void 0,v.readyState=v.DONE,m()},i.readAsDataURL(l),void(v.readyState=v.INIT)}f||(f=t().createObjectURL(l)),h?e.location.href=f:e.open(f,"_blank")||(e.location.href=f);v.readyState=v.DONE,m(),c(f)}()},u=l.prototype;return"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(e,t,i){return t=t||e.name||"download",i||(e=d(e)),navigator.msSaveOrOpenBlob(e,t)}:(u.abort=function(){},u.readyState=u.INIT=0,u.WRITING=1,u.DONE=2,u.error=u.onwritestart=u.onprogress=u.onwrite=u.onabort=u.onerror=u.onwriteend=null,function(e,t,i){return new l(e,t||e.name||"download",i)})}}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this);!function(e){"use strict";var t=e.HTMLCanvasElement&&e.HTMLCanvasElement.prototype,i=e.Blob&&function(){try{return Boolean(new Blob)}catch(e){return!1}}(),o=i&&e.Uint8Array&&function(){try{return 100===new Blob([new Uint8Array(100)]).size}catch(e){return!1}}(),n=e.BlobBuilder||e.WebKitBlobBuilder||e.MozBlobBuilder||e.MSBlobBuilder,r=/^data:((.*?)(;charset=.*?)?)(;base64)?,/,a=(i||n)&&e.atob&&e.ArrayBuffer&&e.Uint8Array&&function(e){var t,a,s,c,d,l,u,p,f;if(!(t=e.match(r)))throw new Error("invalid data URI");for(a=t[2]?t[1]:"text/plain"+(t[3]||";charset=US-ASCII"),s=!!t[4],c=e.slice(t[0].length),d=s?atob(c):decodeURIComponent(c),l=new ArrayBuffer(d.length),u=new Uint8Array(l),p=0;p0||window.navigator.userAgent.match(/Trident.*rv\:11\./))}isMobile(){return this.icn3dui,/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)}isMac(){return this.icn3dui,/Mac/i.test(window.navigator.userAgent)}isAndroid(){return this.icn3dui,/android/i.test(window.navigator.userAgent.toLowerCase())}isChrome(){return this.icn3dui,navigator.userAgent.includes("Chrome")&&navigator.vendor.includes("Google Inc")}isSessionStorageSupported(){return this.icn3dui,window.sessionStorage}isLocalStorageSupported(){return this.icn3dui,window.localStorage}hexToRgb(e,t){this.icn3dui;let s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return s?{r:parseInt(s[1],16),g:parseInt(s[2],16),b:parseInt(s[3],16),a:t}:null}isCalphaPhosOnly(e){this.icn3dui;let t=!1,s=0,i=0;for(let t in e){if(!(s<100))break;{let s=e[t].name.trim();"CA"!==s&&"P"!==s&&"O3'"!==s&&"O3*"!==s&&++i}++s}return i<.5*s&&(t=!0),t}hasCovalentBond(e,t){let s=this.icn3dui,i=s.parasCls.covalentRadii[e.elem.toUpperCase()]+s.parasCls.covalentRadii[t.elem.toUpperCase()],n=e.coord.x-t.coord.x,l=e.coord.y-t.coord.y,r=e.coord.z-t.coord.z;return n*n+l*l+r*r<("N"==e.elem&&"H"==t.elem.substr(0,1)||"N"==t.elem&&"H"==e.elem.substr(0,1)?2.2:1.3)*i*i}residueName2Abbr(e){this.icn3dui;let t=e.indexOf(" ");switch(t>0&&(e=e.substr(0,t)),e){case" A":case" DA":case"DA":case"ALA":return"A";case" C":case" DC":case"DC":case"CYS":return"C";case" G":case" DG":case"DG":case"GLY":return"G";case" T":case" DT":case"DT":case"THR":return"T";case" U":case" DU":case"DU":case"SEC":return"U";case" I":case" DI":case"DI":case"ILE":return"I";case"ARG":return"R";case"ASN":return"N";case"ASP":return"D";case"GLU":return"E";case"GLN":return"Q";case"HIS":return"H";case"LEU":return"L";case"LYS":return"K";case"MET":return"M";case"PHE":return"F";case"PRO":return"P";case"SER":return"S";case"TRP":return"W";case"TYR":return"Y";case"VAL":return"V";case"HOH":case"WAT":return"O";default:return e.trim()}}residueAbbr2Name(e){if(this.icn3dui,(e=e.toUpperCase()).length>1)return e;switch(e){case"A":return"ALA";case"R":return"ARG";case"N":return"ASN";case"D":return"ASP";case"C":return"CYS";case"E":return"GLU";case"Q":return"GLN";case"G":return"GLY";case"H":return"HIS";case"I":return"ILE";case"L":return"LEU";case"K":return"LYS";case"M":return"MET";case"F":return"PHE";case"P":return"PRO";case"S":return"SER";case"T":return"THR";case"W":return"TRP";case"Y":return"TYR";case"V":return"VAL";case"O":return"HOH";default:return e.trim()}}getJSONFromArray(e){this.icn3dui;let t="";for(let s=0,i=e.length;sd?1:ah?1:cs&&(e.htmlCls.WIDTH=s),i&&e.htmlCls.HEIGHT>i&&(e.htmlCls.HEIGHT=i)}sumArray(e){let t=0;for(let s=0,i=e.length;sRed and blue membranes indicate extracellular and intracellular membranes, respectively.

    "}}class i{constructor(e){this.icn3dui=e,this.glycanHash={GLC:{c:"1E90FF",s:"sphere"},BGC:{c:"1E90FF",s:"sphere"},NAG:{c:"1E90FF",s:"cube"},NDG:{c:"1E90FF",s:"cube"},GCS:{c:"1E90FF",s:"cube"},PA1:{c:"1E90FF",s:"cube"},GCU:{c:"1E90FF",s:"cone"},BDP:{c:"1E90FF",s:"cone"},G6D:{c:"1E90FF",s:"cone"},DDA:{c:"1E90FF",s:"cylinder"},B6D:{c:"1E90FF",s:"cylinder"},XXM:{c:"1E90FF",s:"cylinder"},MAN:{c:"00FF00",s:"sphere"},BMA:{c:"00FF00",s:"sphere"},BM3:{c:"00FF00",s:"cube"},"95Z":{c:"00FF00",s:"cube"},MAV:{c:"00FF00",s:"cone"},BEM:{c:"00FF00",s:"cone"},RAM:{c:"00FF00",s:"cone"},RM4:{c:"00FF00",s:"cone"},TYV:{c:"00FF00",s:"cylinder"},ARA:{c:"00FF00",s:"cylinder"},ARB:{c:"00FF00",s:"cylinder"},KDN:{c:"00FF00",s:"cylinder"},KDM:{c:"00FF00",s:"cylinder"},"6PZ":{c:"00FF00",s:"cylinder"},GMH:{c:"00FF00",s:"cylinder"},BDF:{c:"00FF00",s:"cylinder"},GAL:{c:"FFFF00",s:"sphere"},GLA:{c:"FFFF00",s:"sphere"},NGA:{c:"FFFF00",s:"cube"},A2G:{c:"FFFF00",s:"cube"},X6X:{c:"FFFF00",s:"cube"},"1GN":{c:"FFFF00",s:"cube"},ADA:{c:"FFFF00",s:"cone"},GTR:{c:"FFFF00",s:"cone"},LDY:{c:"FFFF00",s:"cylinder"},KDO:{c:"FFFF00",s:"cylinder"},T6T:{c:"FFFF00",s:"cylinder"},GUP:{c:"A52A2A",s:"sphere"},GL0:{c:"A52A2A",s:"sphere"},LGU:{c:"A52A2A",s:"cone"},ABE:{c:"A52A2A",s:"cylinder"},XYS:{c:"A52A2A",s:"cylinder"},XYP:{c:"A52A2A",s:"cylinder"},SOE:{c:"A52A2A",s:"cylinder"},PZU:{c:"FF69B4",s:"cylinder"},RIP:{c:"FF69B4",s:"cylinder"},"0MK":{c:"FF69B4",s:"cylinder"},ALL:{c:"8A2BE2",s:"sphere"},AFD:{c:"8A2BE2",s:"sphere"},NAA:{c:"8A2BE2",s:"cube"},SIA:{c:"8A2BE2",s:"cylinder"},SIB:{c:"8A2BE2",s:"cylinder"},AMU:{c:"8A2BE2",s:"cylinder"},X0X:{c:"1E90FF",s:"cone"},X1X:{c:"1E90FF",s:"cone"},NGC:{c:"1E90FF",s:"cylinder"},NGE:{c:"1E90FF",s:"cylinder"},"4N2":{c:"A0522D",s:"sphere"},HSQ:{c:"A0522D",s:"cube"},IDR:{c:"A0522D",s:"cone"},MUR:{c:"A0522D",s:"cylinder"},FUC:{c:"FF0000",s:"cone"},FUL:{c:"FF0000",s:"cone"}},this.nucleotidesArray=[" G"," A"," T"," C"," U"," DG"," DA"," DT"," DC"," DU","G","A","T","C","U","DG","DA","DT","DC","DU"],this.ionsArray=[" K"," NA"," MG"," AL"," CA"," TI"," MN"," FE"," NI"," CU"," ZN"," AG"," BA"," F"," CL"," BR"," I","K","NA","MG","AL","CA","TI","MN","FE","NI","CU","ZN","AG","BA","F","CL","BR","I"],this.cationsTrimArray=["K","NA","MG","AL","CA","TI","MN","FE","NI","CU","ZN","AG","BA"],this.anionsTrimArray=["F","CL","BR","I"],this.ionCharges={K:1,NA:1,MG:2,AL:3,CA:2,TI:3,MN:2,FE:3,NI:2,CU:2,ZN:2,AG:1,BA:2},this.vdwRadii={H:1.08,HE:1.34,LI:1.75,BE:2.05,B:1.47,C:1.49,N:1.41,O:1.4,F:1.39,NE:1.68,NA:1.84,MG:2.05,AL:2.11,SI:2.07,P:1.92,S:1.82,CL:1.83,AR:1.93,K:2.05,CA:2.21,SC:2.16,TI:1.87,V:1.79,CR:1.89,MN:1.97,FE:1.94,CO:1.92,NI:1.84,CU:1.86,ZN:2.1,GA:2.08,GE:2.15,AS:2.06,SE:1.93,BR:1.98,KR:2.12,RB:2.16,SR:2.24,Y:2.19,ZR:1.86,NB:2.07,MO:2.09,TC:2.09,RU:2.07,RH:1.95,PD:2.02,AG:2.03,CD:2.3,IN:2.36,SN:2.33,SB:2.25,TE:2.23,I:2.23,XE:2.21,CS:2.22,BA:2.51,LA:2.4,CE:2.35,PR:2.39,ND:2.29,PM:2.36,SM:2.29,EU:2.33,GD:2.37,TB:2.21,DY:2.29,HO:2.16,ER:2.35,TM:2.27,YB:2.42,LU:2.21,HF:2.12,TA:2.17,W:2.1,RE:2.17,OS:2.16,IR:2.02,PT:2.09,AU:2.17,HG:2.09,TL:2.35,PB:2.32,BI:2.43,PO:2.29,AT:2.36,RN:2.43,FR:2.56,RA:2.43,AC:2.6,TH:2.37,PA:2.43,U:2.4,NP:2.21,PU:2.56,AM:2.56,CM:2.56,BK:2.56,CF:2.56,ES:2.56,FM:2.56},this.covalentRadii={H:.31,HE:.28,LI:1.28,BE:.96,B:.84,C:.76,N:.71,O:.66,F:.57,NE:.58,NA:1.66,MG:1.41,AL:1.21,SI:1.11,P:1.07,S:1.05,CL:1.02,AR:1.06,K:2.03,CA:1.76,SC:1.7,TI:1.6,V:1.53,CR:1.39,MN:1.39,FE:1.32,CO:1.26,NI:1.24,CU:1.32,ZN:1.22,GA:1.22,GE:1.2,AS:1.19,SE:1.2,BR:1.2,KR:1.16,RB:2.2,SR:1.95,Y:1.9,ZR:1.75,NB:1.64,MO:1.54,TC:1.47,RU:1.46,RH:1.42,PD:1.39,AG:1.45,CD:1.44,IN:1.42,SN:1.39,SB:1.39,TE:1.38,I:1.39,XE:1.4,CS:2.44,BA:2.15,LA:2.07,CE:2.04,PR:2.03,ND:2.01,PM:1.99,SM:1.98,EU:1.98,GD:1.96,TB:1.94,DY:1.92,HO:1.92,ER:1.89,TM:1.9,YB:1.87,LU:1.87,HF:1.75,TA:1.7,W:1.62,RE:1.51,OS:1.44,IR:1.41,PT:1.36,AU:1.36,HG:1.32,TL:1.45,PB:1.46,BI:1.48,PO:1.4,AT:1.5,RN:1.5,FR:2.6,RA:2.21,AC:2.15,TH:2.06,PA:2,U:1.96,NP:1.9,PU:1.87,AM:1.8,CM:1.69},this.atomColors={H:this.thr(16777215),He:this.thr(16761035),HE:this.thr(16761035),Li:this.thr(11674146),LI:this.thr(11674146),B:this.thr(65280),C:this.thr(11184810),N:this.thr(255),O:this.thr(15728640),F:this.thr(14329120),Na:this.thr(255),NA:this.thr(255),Mg:this.thr(2263842),MG:this.thr(2263842),Al:this.thr(8421520),AL:this.thr(8421520),Si:this.thr(14329120),SI:this.thr(14329120),P:this.thr(16753920),S:this.thr(16762930),Cl:this.thr(65280),CL:this.thr(65280),Ca:this.thr(8421520),CA:this.thr(8421520),Ti:this.thr(8421520),TI:this.thr(8421520),Cr:this.thr(8421520),CR:this.thr(8421520),Mn:this.thr(8421520),MN:this.thr(8421520),Fe:this.thr(16753920),FE:this.thr(16753920),Ni:this.thr(10824234),NI:this.thr(10824234),Cu:this.thr(10824234),CU:this.thr(10824234),Zn:this.thr(10824234),ZN:this.thr(10824234),Br:this.thr(10824234),BR:this.thr(10824234),Ag:this.thr(8421520),AG:this.thr(8421520),I:this.thr(10494192),Ba:this.thr(16753920),BA:this.thr(16753920),Au:this.thr(14329120),AU:this.thr(14329120)},this.atomnames={H:"Hydrogen",HE:"Helium",LI:"Lithium",B:"Boron",C:"Carbon",N:"Nitrogen",O:"Oxygen",F:"Fluorine",NA:"Sodium",MG:"Magnesium",AL:"Aluminum",SI:"Silicon",P:"Phosphorus",S:"Sulfur",CL:"Chlorine",CA:"Calcium",TI:"Titanium",CR:"Chromium",MN:"Manganese",FE:"Iron",NI:"Nickel",CU:"Copper",ZN:"Zinc",BR:"Bromine",AG:"Silver",I:"Iodine",BA:"Barium",AU:"Gold"},this.defaultAtomColor=this.thr(13421772),this.stdChainColors=[this.thr(16711935),this.thr(255),this.thr(10053171),this.thr(65433),this.thr(16750848),this.thr(16737894),this.thr(3329330),this.thr(2003199),this.thr(16416882),this.thr(16753920),this.thr(52945),this.thr(16738740),this.thr(65280),this.thr(255),this.thr(16711680),this.thr(16776960),this.thr(65535),this.thr(16711935),this.thr(3978097),this.thr(4620980),this.thr(13458524),this.thr(16770229),this.thr(11529966),this.thr(15631086),this.thr(25600),this.thr(139),this.thr(9109504),this.thr(13468991),this.thr(35723),this.thr(9699539)],this.backgroundColors={black:this.thr(0),grey:this.thr(13421772),white:this.thr(16777215),transparent:this.thr(16777215)},this.residueColors={ALA:this.thr(13158600),ARG:this.thr(1334015),ASN:this.thr(56540),ASP:this.thr(15075850),CYS:this.thr(15132160),GLN:this.thr(56540),GLU:this.thr(15075850),GLY:this.thr(15461355),HIS:this.thr(8553170),ILE:this.thr(1016335),LEU:this.thr(1016335),LYS:this.thr(1334015),MET:this.thr(15132160),PHE:this.thr(3289770),PRO:this.thr(14456450),SER:this.thr(16422400),THR:this.thr(16422400),TRP:this.thr(11819700),TYR:this.thr(3289770),VAL:this.thr(1016335),ASX:this.thr(16738740),GLX:this.thr(16738740),G:this.thr(32768),A:this.thr(6324479),T:this.thr(16744448),C:this.thr(16711680),U:this.thr(16744448),DG:this.thr(32768),DA:this.thr(6324479),DT:this.thr(16744448),DC:this.thr(16711680),DU:this.thr(16744448)},this.residueArea={ALA:247,ARG:366,ASN:290,ASP:285,CYS:271,GLN:336,GLU:325,GLY:217,HIS:340,ILE:324,LEU:328,LYS:373,MET:346,PHE:366,PRO:285,SER:265,THR:288,TRP:414,TYR:387,VAL:293,ASX:290,GLX:336,G:520,A:507,T:515,C:467,U:482,DG:520,DA:507,DT:515,DC:467,DU:482},this.defaultResidueColor=this.thr(12492910),this.chargeColors={" G":this.thr(16711680)," A":this.thr(16711680)," T":this.thr(16711680)," C":this.thr(16711680)," U":this.thr(16711680)," DG":this.thr(16711680)," DA":this.thr(16711680)," DT":this.thr(16711680)," DC":this.thr(16711680)," DU":this.thr(16711680),G:this.thr(16711680),A:this.thr(16711680),T:this.thr(16711680),C:this.thr(16711680),U:this.thr(16711680),DG:this.thr(16711680),DA:this.thr(16711680),DT:this.thr(16711680),DC:this.thr(16711680),DU:this.thr(16711680),ARG:this.thr(255),LYS:this.thr(255),ASP:this.thr(16711680),GLU:this.thr(16711680),HIS:this.thr(8421631),GLY:this.thr(8947848),PRO:this.thr(8947848),ALA:this.thr(8947848),VAL:this.thr(8947848),LEU:this.thr(8947848),ILE:this.thr(8947848),PHE:this.thr(8947848),SER:this.thr(8947848),THR:this.thr(8947848),ASN:this.thr(8947848),GLN:this.thr(8947848),TYR:this.thr(8947848),MET:this.thr(8947848),CYS:this.thr(8947848),TRP:this.thr(8947848)},this.hydrophobicColors={" G":this.thr(16711680)," A":this.thr(16711680)," T":this.thr(16711680)," C":this.thr(16711680)," U":this.thr(16711680)," DG":this.thr(16711680)," DA":this.thr(16711680)," DT":this.thr(16711680)," DC":this.thr(16711680)," DU":this.thr(16711680),G:this.thr(16711680),A:this.thr(16711680),T:this.thr(16711680),C:this.thr(16711680),U:this.thr(16711680),DG:this.thr(16711680),DA:this.thr(16711680),DT:this.thr(16711680),DC:this.thr(16711680),DU:this.thr(16711680),ARG:this.thr(255),LYS:this.thr(255),ASP:this.thr(16711680),GLU:this.thr(16711680),HIS:this.thr(8421631),TRP:this.thr().setHSL(1/3,1,.5),PHE:this.thr().setHSL(1/3,1,.6945945945945946),TYR:this.thr().setHSL(1/3,1,.745945945945946),LEU:this.thr().setHSL(1/3,1,.5+.645/1.85),ILE:this.thr().setHSL(1/3,1,.5+.77/1.85),CYS:this.thr().setHSL(1/3,1,.5+.805/1.85),MET:this.thr().setHSL(1/3,1,.5+.81/1.85),GLY:this.thr().setHSL(1/6,1,.5+.285/.58),VAL:this.thr().setHSL(1/6,1,.5+.255/.58),SER:this.thr().setHSL(1/6,1,.8879310344827587),THR:this.thr().setHSL(1/6,1,.8793103448275862),ALA:this.thr().setHSL(1/6,1,.853448275862069),ASN:this.thr().setHSL(1/6,1,.6379310344827587),PRO:this.thr().setHSL(1/6,1,.6120689655172413),GLN:this.thr().setHSL(1/6,1,.5)},this.normalizedHPColors={" G":this.thr(16777215)," A":this.thr(16777215)," T":this.thr(16777215)," C":this.thr(16777215)," U":this.thr(16777215)," DG":this.thr(16777215)," DA":this.thr(16777215)," DT":this.thr(16777215)," DC":this.thr(16777215)," DU":this.thr(16777215),G:this.thr(16777215),A:this.thr(16777215),T:this.thr(16777215),C:this.thr(16777215),U:this.thr(16777215),DG:this.thr(16777215),DA:this.thr(16777215),DT:this.thr(16777215),DC:this.thr(16777215),DU:this.thr(16777215),ARG:this.thr(16777215),LYS:this.thr(16777215),ASP:this.thr(16777215),GLU:this.thr(16777215),HIS:this.thr(16777215),TRP:this.thr().setHSL(1/3,1,.5),PHE:this.thr().setHSL(1/3,1,.644),TYR:this.thr().setHSL(1/3,1,.682),LEU:this.thr().setHSL(1/3,1,.758),ILE:this.thr().setHSL(1/3,1,.808),CYS:this.thr().setHSL(1/3,1,.5+.322),MET:this.thr().setHSL(1/3,1,.5+.324),GLY:this.thr().setHSL(1/3,1,.872),VAL:this.thr().setHSL(1/3,1,.884),SER:this.thr().setHSL(1/3,1,.896),THR:this.thr().setHSL(1/3,1,.898),ALA:this.thr().setHSL(1/3,1,.904),ASN:this.thr().setHSL(1/3,1,.954),PRO:this.thr().setHSL(1/3,1,.9600000000000001),GLN:this.thr().setHSL(1/3,1,.986)},this.hydrophobicValues={" G":3," A":3," T":3," C":3," U":3," DG":3," DA":3," DT":3," DC":3," DU":3,G:3,A:3,T:3,C:3,U:3,DG:3,DA:3,DT:3,DC:3,DU:3,ARG:1,LYS:1,ASP:3,GLU:3,HIS:2,TRP:-1.85,PHE:-1.13,TYR:-.94,LEU:-.56,ILE:-.31,CYS:-.24,MET:-.23,GLY:.01,VAL:.07,SER:.13,THR:.14,ALA:.17,ASN:.42,PRO:.45,GLN:.58},this.residueAbbrev={ALA:"A (Ala)",ARG:"R (Arg)",ASN:"N (Asn)",ASP:"D (Asp)",CYS:"C (Cys)",GLN:"Q (Gln)",GLU:"E (Glu)",GLY:"G (Gly)",HIS:"H (His)",ILE:"I (Ile)",LEU:"L (Leu)",LYS:"K (Lys)",MET:"M (Met)",PHE:"F (Phe)",PRO:"P (Pro)",SER:"S (Ser)",THR:"T (Thr)",TRP:"W (Trp)",TYR:"Y (Tyr)",VAL:"V (Val)",ASX:"X (Asx)",GLX:"X (Glx)",G:"Guanine",A:"Adenine",T:"Thymine",C:"Cytosine",U:"Uracil",DG:"deoxy-Guanine",DA:"deoxy-Adenine",DT:"deoxy-Thymine",DC:"deoxy-Cytosine",DU:"deoxy-Uracil"},this.ssColors={helix:this.thr(16711680),sheet:this.thr(32768),coil:this.thr(6324479)},this.ssColors2={helix:this.thr(16711680),sheet:this.thr(16762880),coil:this.thr(6324479)},this.resn2restype={ALA:1,ARG:4,ASN:7,ASP:10,CYS:13,GLN:16,GLU:19,GLY:22,HIS:25,ILE:28,LEU:31,LYS:34,MET:37,PHE:40,PRO:43,SER:46,THR:49,TRP:52,TYR:55,VAL:58},this.nuclMainArray=["C1'","C1*","C2'","C2*","C3'","C3*","C4'","C4*","C5'","C5*","O3'","O3*","O4'","O4*","O5'","O5*","P","OP1","O1P","OP2","O2P"],this.b62ResArray=["A","R","N","D","C","Q","E","G","H","I","L","K","M","F","P","S","T","W","Y","V","B","Z","X","*"],this.b62Matrix=[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0,-4],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1,-4],[-2,0,6,1,-3,0,0,0,1,-3,-3,0,-2,-3,-2,1,0,-4,-2,-3,3,0,-1,-4],[-2,-2,1,6,-3,0,2,-1,-1,-3,-4,-1,-3,-3,-1,0,-1,-4,-3,-3,4,1,-1,-4],[0,-3,-3,-3,9,-3,-4,-3,-3,-1,-1,-3,-1,-2,-3,-1,-1,-2,-2,-1,-3,-3,-2,-4],[-1,1,0,0,-3,5,2,-2,0,-3,-2,1,0,-3,-1,0,-1,-2,-1,-2,0,3,-1,-4],[-1,0,0,2,-4,2,5,-2,0,-3,-3,1,-2,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-2,0,-1,-3,-2,-2,6,-2,-4,-4,-2,-3,-3,-2,0,-2,-2,-3,-3,-1,-2,-1,-4],[-2,0,1,-1,-3,0,0,-2,8,-3,-3,-1,-2,-1,-2,-1,-2,-2,2,-3,0,0,-1,-4],[-1,-3,-3,-3,-1,-3,-3,-4,-3,4,2,-3,1,0,-3,-2,-1,-3,-1,3,-3,-3,-1,-4],[-1,-2,-3,-4,-1,-2,-3,-4,-3,2,4,-2,2,0,-3,-2,-1,-2,-1,1,-4,-3,-1,-4],[-1,2,0,-1,-3,1,1,-2,-1,-3,-2,5,-1,-3,-1,0,-1,-3,-2,-2,0,1,-1,-4],[-1,-1,-2,-3,-1,0,-2,-3,-2,1,2,-1,5,0,-2,-1,-1,-1,-1,1,-3,-1,-1,-4],[-2,-3,-3,-3,-2,-3,-3,-3,-1,0,0,-3,0,6,-4,-2,-2,1,3,-1,-3,-3,-1,-4],[-1,-2,-2,-1,-3,-1,-1,-2,-2,-3,-3,-1,-2,-4,7,-1,-1,-4,-3,-2,-2,-1,-2,-4],[1,-1,1,0,-1,0,0,0,-1,-2,-2,0,-1,-2,-1,4,1,-3,-2,-2,0,0,0,-4],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,1,5,-2,-2,0,-1,-1,0,-4],[-3,-3,-4,-4,-2,-2,-3,-2,-2,-3,-2,-3,-1,1,-4,-3,-2,11,2,-3,-4,-3,-2,-4],[-2,-2,-2,-3,-2,-1,-2,-3,2,-1,-1,-2,-1,3,-3,-2,-2,2,7,-1,-3,-2,-1,-4],[0,-3,-3,-3,-1,-2,-2,-3,-3,3,1,-2,1,-1,-2,-2,0,-3,-1,4,-3,-2,-1,-4],[-2,-1,3,4,-3,0,1,-1,0,-3,-4,0,-3,-3,-2,0,-1,-4,-3,-3,4,1,-1,-4],[-1,0,0,1,-3,3,4,-2,0,-3,-3,1,-1,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,0,0,-2,-1,-1,-1,-1,-1,-4],[-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,1]]}thr(e){return this.icn3dui,"#0"==e&&(e="#000"),new THREE.Color(e)}}class n{constructor(e){this.icn3dui=e}onId(e,t,s){if(this.icn3dui,!(Object.keys(window).length<2)&&("#"==e.substr(0,1)&&(e=e.substr(1)),document.getElementById(e))){t.split(" ").forEach((t=>{document.getElementById(e).addEventListener(t,s)}))}}onIds(e,t,s){let i=this.icn3dui;Array.isArray(e)?e.forEach((e=>{i.myEventCls.onId(e,t,s)})):i.myEventCls.onId(e,t,s)}}class l{constructor(e){this.icn3dui=e}getRmsdSuprCls(e,t,s){let i,n,l,r,o,a,d,c,h,p,m,u,g,f=this.icn3dui,b=new Array(9),C=new THREE.Vector3,y=new THREE.Vector3,v=[],w=[],_=new Array(3),S=new Array(3),A=new Array(3),x=new Array(3),k=new Array(3),O=new Array(3);if(i=0,s<=1)return{rot:void 0,trans1:void 0,trans2:void 0,rmsd:999};let R=s;for(n=0;n0?(b[0]=x[0]*_[0]+k[0]*S[0]+O[0]*A[0],b[1]=x[0]*_[1]+k[0]*S[1]+O[0]*A[1],b[2]=x[0]*_[2]+k[0]*S[2]+O[0]*A[2],b[3]=x[1]*_[0]+k[1]*S[0]+O[1]*A[0],b[4]=x[1]*_[1]+k[1]*S[1]+O[1]*A[1],b[5]=x[1]*_[2]+k[1]*S[2]+O[1]*A[2],b[6]=x[2]*_[0]+k[2]*S[0]+O[2]*A[0],b[7]=x[2]*_[1]+k[2]*S[1]+O[2]*A[1],b[8]=x[2]*_[2]+k[2]*S[2]+O[2]*A[2]):(b[0]=x[0]*_[0]+k[0]*S[0]-O[0]*A[0],b[1]=x[0]*_[1]+k[0]*S[1]-O[0]*A[1],b[2]=x[0]*_[2]+k[0]*S[2]-O[0]*A[2],b[3]=x[1]*_[0]+k[1]*S[0]-O[1]*A[0],b[4]=x[1]*_[1]+k[1]*S[1]-O[1]*A[1],b[5]=x[1]*_[2]+k[1]*S[2]-O[1]*A[2],b[6]=x[2]*_[0]+k[2]*S[0]-O[2]*A[0],b[7]=x[2]*_[1]+k[2]*S[1]-O[2]*A[1],b[8]=x[2]*_[2]+k[2]*S[2]-O[2]*A[2]),c=Math.sqrt(c),h=Math.sqrt(h),p=Math.sqrt(p),g=c+h+u*p,m=a+d-2*g,i=m>0?Math.sqrt(m):void 0,{rot:b,trans1:E,trans2:I,rmsd:i})}eigen_values(e){let t,s,i,n,l,r,o,a,d,c,h,p,m,u,g,f,b,C,y,v;if(this.icn3dui,t=e[0],s=e[1],i=e[2],n=e[3],l=e[4],r=e[5],o=e[6],a=e[7],d=e[8],c=-(t+l+d),h=t*l+(t+l)*d-r*a-s*n-i*o,p=-t*l*d+t*r*a+s*n*d-s*r*o-i*n*a+i*l*o,m=-c*c/3+h,u=c*c*c/13.5-c*h/3+p,g=.25*u*u+m*m*m/27,g<0){let e,t;e=Math.sqrt(.25*u*u-g),t=Math.acos(-.5*u/e),C=2*Math.cbrt(e)*Math.cos(t/3)}else f=Math.cbrt(-.5*u+Math.sqrt(g)),b=Math.cbrt(-.5*u-Math.sqrt(g)),C=f+b;return C-=c/3,c+=C,p/=-C,y=.5*(-c+Math.sqrt(c*c-4*p)),v=.5*(-c-Math.sqrt(c*c-4*p)),y_&&(_=Math.abs(d)),Math.abs(c)>_&&(_=Math.abs(c)),Math.abs(h)>_&&(_=Math.abs(h)),Math.abs(p)>_&&(_=Math.abs(p)),Math.abs(m)>_&&(_=Math.abs(m)),Math.abs(u)>_&&(_=Math.abs(u)),Math.abs(g)>_&&(_=Math.abs(g)),Math.abs(f)>_&&(_=Math.abs(f)),_<1e-10)return r=3,{k:r,v1:t,v2:s,v3:i};if(o=0,a/=_,d/=_,c/=_,h/=_,p/=_,m/=_,u/=_,g/=_,f/=_,Math.abs(a)_&&(w=a,a=h,h=w,w=d,d=p,p=w,w=c,c=m,m=w,_=Math.abs(d)),Math.abs(g)>_&&(w=a,a=u,u=w,w=d,d=g,g=w,w=c,c=f,f=w),y=m-p*c/d,v=f-g*c/d,Math.abs(y)_&&(w=a,a=h,h=w,w=d,d=p,p=w,w=c,c=m,m=w,_=Math.abs(a)),Math.abs(c)>_&&(w=a,a=u,u=w,w=d,d=g,g=w,w=c,c=f,f=w),b=p-h*d/a,C=m-h*c/a,y=g-u*d/a,v=f-u*c/a,Math.abs(b)0&&(1==o?(a=s[0],d=s[1],c=s[2],w=Math.sqrt(a*a+d*d+c*c),s[0]=a/w,s[1]=d/w,s[2]=c/w):2==o?(a=t[0],d=t[1],c=t[2],h=s[0],p=s[1],m=s[2],w=a*h+d*p+c*m,Math.abs(w)>=n&&(s[0]=a+w*h,s[1]=d+w*p,s[2]=c+w*m,h=s[0],p=s[1],m=s[2]),w=Math.sqrt(a*a+d*d+c*c),t[0]=a/w,t[1]=d/w,t[2]=c/w,w=Math.sqrt(h*h+p*p+m*m),s[0]=h/w,s[1]=p/w,s[2]=m/w):(a=t[0],d=t[1],c=t[2],w=Math.sqrt(a*a+d*d+c*c),t[0]=a/w,t[1]=d/w,t[2]=c/w)),{k:r,v1:t,v2:s,v3:i}}getEigenForSelection(e,t){let s,i=this.icn3dui,n=new THREE.Vector3,l=[];for(s=0;s0&&Math.abs(l[0].x-e[0].x)<=6&&Math.abs(l[0].y-e[0].y)<=6&&Math.abs(l[0].z-e[0].z)<=6?(p.push(l[0]),m=1):m=0,p.push(e[0]);for(let t=1,s=e.length-1;t0&&Math.abs(r[0].x-e[e.length-1].x)<=6&&Math.abs(r[0].y-e[e.length-1].y)<=6&&Math.abs(r[0].z-e[e.length-1].z)<=6&&(p.push(r[0]),++g),u>1&&Math.abs(r[0].x-r[1].x)<=6&&Math.abs(r[0].y-r[1].y)<=6&&Math.abs(r[0].z-r[1].z)<=6&&(p.push(r[1]),++g);let f=[],b=[],C=[];o&&(g=u>0?u-1:0);let y;for(let e=-1,n=p.length,l=1/s;e<=n-3;++e){y=e-m;let r=p[-1===e?0:e],o=p[e+1],u=p[e+2],v=p[e===n-3?n-1:e+3],w=0,_=a.subdivideCls.getKnot(1,w,r,o),S=a.subdivideCls.getKnot(1,_,o,u),A=a.subdivideCls.getKnot(1,S,u,v);_-w<1e-4&&(_=w+1),S-_<1e-4&&(S=_+1),A-S<1e-4&&(A=S+1),e>-1&&(void 0===i||i[y+1])&&e>=-1+m&&e<=n-3-g+1&&(d=d.concat(f),c=c.concat(b),h=h.concat(C)),f=[],b=[],C=[];let x=(S-_)*l;for(let l=0;l=-1+m&&e<=n-3-g&&i[y+1]&&l<=parseInt(s/2)&&(d.push(new THREE.Vector3(k,O,R)),c.push(i[y+1]),h.push(t[y+1])),e>=-1+m&&e<=n-3-g+1&&i[y+2]&&l>parseInt(s/2)&&(f.push(new THREE.Vector3(k,O,R)),b.push(i[y+2]),C.push(t[y+2]))):e>=-1+m&&e<=n-3-g&&(d.push(new THREE.Vector3(k,O,R)),c.push(y+1),h.push(t[y+1]))}}i&&!i[y+1]||(d=d.concat(f),c=c.concat(b),h=h.concat(C),d.push(p[p.length-1-g]),c.push(p.length-1-g),h.push(t[p.length-1-g])),f=[],b=[],C=[],p=[];let v=[];return v.push(d),v.push(c),v.push(h),v}getKnot(e,t,s,i){return this.icn3dui,s.distanceTo(i)+t}getValueFromKnot(e,t,s,i,n,l,r,o,a){this.icn3dui;let d,c,h=(r-l)/(s-t),p=(o-r)/(i-s),m=(a-o)/(n-i),u=(s+i)*(s+i)-4*(t*s+i*n-t*n);return 0==u?(d=9999,c=9999):(d=6*(3*p*s+2*h*n+m*s-2*h*s-2*p*n-p*i-m*s)/u,c=6*(3*p*i+2*m*t+h*s-2*p*t-2*m*i-h*i-p*s)/u),p*(e-s)+r+((2*d+c)/6/(s-i)*(e-s)*(e-i)*(e-i)+(2*c+d)/6/(i-s)*(e-s)*(e-s)*(e-i))}}class o{constructor(e){this.icn3dui=e}passFloat32(e,t){let s=this.icn3dui,i=e.length;t||(t=new Uint8Array(4*i));let n=s.convertTypeCls.getDataView(t);for(let t=0;t  Very high (pLDDT > 90)
      Confident (90 > pLDDT > 70)
      Low (70 > pLDDT > 50)
      Very low (pLDDT < 50)
    '}setLegendHtml(e){let t=this.icn3dui.icn3d,s="
    ";if(e)s+=this.setAlphaFoldLegend();else{s+="
    StructureChainResidue Number
    "+s[e].substr(0,t)+""+s[e].substr(t+1,n-t-1)+""+s[e].substr(n+1)+"
    "+t.startValue+""+t.midValue+""+t.endValue+"
    "}return s}SetChainsAdvancedMenu(){let e=this.icn3dui,t=e.icn3d;if(void 0===t.bSetChainsAdvancedMenu||!t.bSetChainsAdvancedMenu){let s=e.hashUtilsCls.cloneHash(t.hAtoms);t.definedSetsCls.setPredefinedInMenu(),t.bSetChainsAdvancedMenu=!0,t.hAtoms=e.hashUtilsCls.cloneHash(s)}}setSetsMenus(e,t){let s=this.icn3dui,i=s.icn3d;this.SetChainsAdvancedMenu();let n=e,l=e+"2",r=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+s.pre+n).length&&$("#"+s.pre+n).html(" "+r),!t&&$("#"+s.pre+l).length&&$("#"+s.pre+l).html(" "+r),$("#"+s.pre+n).resizable(),t||$("#"+s.pre+l).resizable()}applyShownMenus(){let e=this.icn3dui;e.icn3d;let t=[];for(let s in e.htmlCls.allMenus)e.htmlCls.shownMenus.hasOwnProperty(s)?$("#"+e.pre+s).parent().show():($("#"+e.pre+s).parent().hide(),t.push(s));Object.keys(e.htmlCls.shownMenus).length==Object.keys(e.htmlCls.allMenus).length?$(".icn3d-menusep").show():$(".icn3d-menusep").hide(),localStorage&&localStorage.setItem("hiddenmenus",JSON.stringify(t))}getHiddenMenusFromCache(){let e=this.icn3dui;e.icn3d,e.htmlCls.shownMenus={};let t=localStorage?localStorage.getItem("hiddenmenus"):"";if(t&&"[]"!=t){let s=JSON.parse(t);for(let t in e.htmlCls.allMenus)-1==s.indexOf(t)&&(e.htmlCls.shownMenus[t]=1)}else e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.allMenus)}displayShownMenus(){let e=this.icn3dui;e.icn3d;let t="
    ";t+="",t+="";for(let s in e.htmlCls.allMenusSel){if("uniclr"==s.substr(0,6)||"mn5_opacity"==s.substr(0,11)||"mn6_labelscale"==s.substr(0,14)||"faq_"==s.substr(0,4)||"dev_"==s.substr(0,4))continue;"mn1_searchstru"==s?t+="
    FileSelectViewStyleColorAnalysisHelp
    ":("mn2_definedsets"==s||"mn2_show_selected"==s||"mn3_proteinwrap"==s||e.cfg.cid&&"mn3_ligwrap"==s||"mn4_clrwrap"==s||"mn6_selectannotations"==s||"abouticn3d"==s)&&(t+="");let i=e.htmlCls.shownMenus.hasOwnProperty(s)?"checked":"",n=e.htmlCls.allMenusSel[s];t+=""+e.htmlCls.allMenus[s]+"
    "}t+="
    ",$("#"+e.pre+"menulist").html(t)}clickMenu1(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds("#"+e.pre+"mn1_vastplus","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_vastplus","Please input PDB ID for VAST+")})),e.myEventCls.onIds("#"+e.pre+"mn1_vast","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_vast","Please input chain or PDB file for VAST")})),e.myEventCls.onIds("#"+e.pre+"mn1_foldseek","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_foldseek","Submit your selection to Foldseek")})),e.myEventCls.onIds("#"+e.pre+"mn1_mmtfid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmtfid","Please input MMTF ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_pdbid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pdbid","Please input PDB ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_afid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_afid","Please input AlphaFold UniProt ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_refseqid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_refseqid","Please input NCBI Protein Accession")})),e.myEventCls.onIds("#"+e.pre+"mn1_opmid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_opmid","Please input OPM PDB ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_align","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_align","Align two PDB structures")})),e.myEventCls.onIds("#"+e.pre+"mn1_alignaf","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_alignaf","Align two AlphaFold structures")})),e.myEventCls.onIds("#"+e.pre+"mn1_chainalign","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_chainalign","Align multiple chains by structure alignment")})),e.myEventCls.onIds("#"+e.pre+"mn1_chainalign2","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_chainalign2","Align multiple chains by sequence alignment")})),e.myEventCls.onIds("#"+e.pre+"mn1_chainalign3","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_chainalign3","Align multiple chains residue by residue")})),e.myEventCls.onIds("#"+e.pre+"mn1_mutation","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mutation","Show the mutations in 3D")})),e.myEventCls.onIds("#"+e.pre+"mn1_pdbfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pdbfile","Please input PDB File")})),e.myEventCls.onIds(["#"+e.pre+"mn1_pdbfile_app","#"+e.pre+"tool_pdbfile"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pdbfile_app","Please append PDB Files")})),e.myEventCls.onIds("#"+e.pre+"mn1_mol2file","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mol2file","Please input Mol2 File")})),e.myEventCls.onIds("#"+e.pre+"mn1_sdffile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_sdffile","Please input SDF File")})),e.myEventCls.onIds("#"+e.pre+"mn1_xyzfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_xyzfile","Please input XYZ File")})),e.myEventCls.onIds("#"+e.pre+"mn1_afmapfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_afmapfile","Please input AlphaFold PAE File")})),e.myEventCls.onIds("#"+e.pre+"mn1_urlfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_urlfile","Load data by URL")})),e.myEventCls.onIds("#"+e.pre+"mn1_fixedversion","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_fixedversion","Open Share Link URL in the archived version of iCn3D")})),e.myEventCls.onIds("#"+e.pre+"reload_fixedversion","click",(function(s){let i=e.icn3d,n=$("#"+e.pre+"sharelinkurl").val();t.setLogCmd("open "+n,!1),localStorage.setItem("fixedversion","1");let l=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(n,l)})),e.myEventCls.onIds("#"+e.pre+"mn1_mmciffile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmciffile","Please input mmCIF File")})),e.myEventCls.onIds("#"+e.pre+"mn1_mmcifid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmcifid","Please input mmCIF ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_mmdbid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmdbid","Please input MMDB or PDB ID")})),e.myEventCls.onIds(["#"+e.pre+"mn1_mmdbafid",,"#"+e.pre+"tool_mmdbafid"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmdbafid","Please input PDB/MMDB/AlphaFold UniProt IDs")})),e.myEventCls.onIds("#"+e.pre+"mn1_blast_rep_id","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_blast_rep_id","Align sequence to structure")})),e.myEventCls.onIds("#"+e.pre+"mn1_gi","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_gi","Please input protein gi")})),e.myEventCls.onIds("#"+e.pre+"mn1_cid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_cid","Please input PubChem CID")})),e.myEventCls.onIds("#"+e.pre+"mn1_pngimage","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pngimage","Please input the PNG image")})),e.myEventCls.onIds("#"+e.pre+"mn1_state","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_state","Please input the state file")})),e.myEventCls.onIds("#"+e.pre+"mn1_selection","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_selection","Please input the selection file")})),e.myEventCls.onIds("#"+e.pre+"mn1_dsn6","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_dsn6","Please input the DSN6 file to display electron density map")})),e.myEventCls.onIds(["#"+e.pre+"mn1_delphi","#"+e.pre+"mn1_delphi2","#"+e.pre+"tool_delphi"],"click",(function(t){e.icn3d.loadPhiFrom="delphi",$("#"+e.pre+"dl_delphi_tabs").tabs(),e.htmlCls.dialogCls.openDlg("dl_delphi","Please set parameters to display DelPhi potential map")})),e.myEventCls.onIds("#"+e.pre+"mn1_phi","click",(function(t){e.icn3d.loadPhiFrom="phi",$("#"+e.pre+"dl_phi_tabs").tabs(),$("#"+e.pre+"phitab1_tabs").tabs(),$("#"+e.pre+"phitab2_tabs").tabs(),e.htmlCls.dialogCls.openDlg("dl_phi","Please input local phi or cube file to display DelPhi potential map")})),e.myEventCls.onIds("#"+e.pre+"mn1_phiurl","click",(function(t){e.icn3d.loadPhiFrom="phiurl",$("#"+e.pre+"dl_phiurl_tabs").tabs(),$("#"+e.pre+"phiurltab1_tabs").tabs(),$("#"+e.pre+"phiurltab2_tabs").tabs(),e.htmlCls.dialogCls.openDlg("dl_phiurl","Please input URL phi or cube file to display DelPhi potential map")})),e.myEventCls.onIds("#"+e.pre+"mn1_dsn6url","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_dsn6url","Please input the DSN6 file to display electron density map")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportState","click",(function(s){let i=e.icn3d;t.setLogCmd("export state file",!1);let n=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(n+"_statefile.txt","command")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportPdbRes","click",(function(s){e.icn3d,e.htmlCls.setHtmlCls.exportPdb(),t.setLogCmd("export pdb",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportSecondary","click",(function(s){e.icn3d,e.htmlCls.setHtmlCls.exportSecondary(),t.setLogCmd("export secondary structure",!0)})),e.myEventCls.onIds(["#"+e.pre+"delphipdb","#"+e.pre+"phipdb"],"click",(function(s){let i=e.icn3d,n=i.saveFileCls.getSelectedResiduePDB();t.setLogCmd("export PDB of selected residues",!1);let l=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(l+"_icn3d_residues.pdb","text",[n])})),e.myEventCls.onIds(["#"+e.pre+"delphipqr","#"+e.pre+"phipqr","#"+e.pre+"phiurlpqr"],"click",(async function(s){e.icn3d,await e.htmlCls.setHtmlCls.exportPqr(),t.setLogCmd("export pqr",!0)})),e.myEventCls.onIds("#"+e.pre+"profixpdb","click",(async function(s){let i=e.icn3d;await i.scapCls.exportPdbProfix(!1),t.setLogCmd("export pdb missing atoms",!0)})),e.myEventCls.onIds("#"+e.pre+"profixpdbh","click",(async function(s){let i=e.icn3d;await i.scapCls.exportPdbProfix(!0),t.setLogCmd("export pdb hydrogen",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportStl","click",(function(s){let i=e.icn3d;t.setLogCmd("export stl file",!1),i.export3DCls.exportStlFile("")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportVrml","click",(function(s){let i=e.icn3d;t.setLogCmd("export vrml file",!1),i.export3DCls.exportVrmlFile("")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportStlStab","click",(function(s){let i=e.icn3d;t.setLogCmd("export stl stabilizer file",!1),i.threeDPrintCls.hideStabilizer(),i.threeDPrintCls.resetAfter3Dprint(),i.threeDPrintCls.addStabilizer(),i.export3DCls.exportStlFile("_stab")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportVrmlStab","click",(function(s){let i=e.icn3d;t.setLogCmd("export vrml stabilizer file",!1),i.threeDPrintCls.hideStabilizer(),i.threeDPrintCls.resetAfter3Dprint(),i.threeDPrintCls.addStabilizer(),i.export3DCls.exportVrmlFile("_stab")})),e.myEventCls.onIds("#"+e.pre+"mn6_exportInteraction","click",(async function(s){let i=e.icn3d;t.setLogCmd("export interactions",!1),void 0!==e.cfg.mmdbid&&await i.viewInterPairsCls.retrieveInteractionData(),i.viewInterPairsCls.exportInteractions()})),e.myEventCls.onIds(["#"+e.pre+"mn1_exportCanvas","#"+e.pre+"saveimage"],"click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas",!1);await i.shareLinkCls.shareLink(!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas1","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 1",!0),i.scaleFactor=1,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas2","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 2",!0),i.scaleFactor=2,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas4","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 4",!0),i.scaleFactor=4,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas8","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 8",!0),i.scaleFactor=8,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCounts","click",(function(s){let i=e.icn3d;t.setLogCmd("export counts",!1);let n='

    Total Count for atoms with coordinates:
    ';n+="",n+="
    Structure CountChain CountResidue CountAtom Count
    "+Object.keys(i.structures).length+""+Object.keys(i.chains).length+""+Object.keys(i.residues).length+""+Object.keys(i.atoms).length+"

    ",n+="Counts by Chain for atoms with coordinates:
    ";let l=Object.keys(i.chains);for(let e=0,t=l.length;e"}n+="
    StructureChainResidue CountAtom Count
    "+r+""+o+""+Object.keys(a).length+""+Object.keys(i.chains[t]).length+"

    ";let r=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(r+"_counts.html","html",n)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportSelections","click",(function(s){let i=e.icn3d;t.setLogCmd("export all selections",!1),t.SetChainsAdvancedMenu();let n=i.saveFileCls.exportCustomAtoms(),l=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(l+"_selections.txt","text",[n])})),e.myEventCls.onIds("#"+e.pre+"mn1_exportSelDetails","click",(function(s){let i=e.icn3d;t.setLogCmd("export all selections with details",!1),t.SetChainsAdvancedMenu();let n=i.saveFileCls.exportCustomAtoms(!0),l=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(l+"_sel_details.txt","text",[n])})),e.myEventCls.onIds(["#"+e.pre+"mn1_sharelink","#"+e.pre+"tool_sharelink"],"click",(async function(t){let s=e.icn3d;await s.shareLinkCls.shareLink()})),e.myEventCls.onIds("#"+e.pre+"mn1_replayon","click",(async function(s){let i=e.icn3d;await i.resizeCanvasCls.replayon(),t.setLogCmd("replay on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_replayoff","click",(async function(s){let i=e.icn3d;await i.resizeCanvasCls.replayoff(),t.setLogCmd("replay off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_menuall","click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.allMenus),t.applyShownMenus()})),e.myEventCls.onIds("#"+e.pre+"mn1_menusimple","click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.simpleMenus),t.applyShownMenus()})),e.myEventCls.onIds("#"+e.pre+"mn1_menupref","click",(function(s){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_menupref","Select Menus"),t.getHiddenMenusFromCache(),t.displayShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"apply_menupref","#"+e.pre+"apply_menupref2"],"click",(function(s){e.icn3d;var i=document.querySelectorAll('form[name="'+e.pre+'selmenu"] input:checked');for(var n of(e.htmlCls.shownMenus={},i))e.htmlCls.shownMenus[n.value]=1;t.applyShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"reset_menupref","#"+e.pre+"reset_menupref2"],"click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.simpleMenus),t.applyShownMenus(),t.displayShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"reset_menupref_all","#"+e.pre+"reset_menupref_all2"],"click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.allMenus),t.applyShownMenus(),t.displayShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"savepref","#"+e.pre+"savepref2"],"click",(function(t){let s=e.icn3d,i="[";var n=document.querySelectorAll('form[name="'+e.pre+'selmenu"] input:not(:checked)');let l=0;for(var r of n)l>0&&(i+=", "),i+='"'+r.value+'"',++l;i+="]",s.saveFileCls.saveFile("icn3d_menus_pref.txt","text",[i])})),e.myEventCls.onIds("#"+e.pre+"reload_menupreffile","click",(function(s){e.icn3d,e.cfg.notebook||dialog.dialog("close");let i=$("#"+e.pre+"menupreffile")[0].files[0];if(i){e.htmlCls.setHtmlCls.fileSupport();let s=new FileReader;s.onload=function(s){let i=s.target.result,n=JSON.parse(i);e.htmlCls.shownMenus={};for(let t in e.htmlCls.allMenus)-1==n.indexOf(t)&&(e.htmlCls.shownMenus[t]=1);t.applyShownMenus(),t.displayShownMenus()},s.readAsText(i)}else alert("Please select a file before clicking 'Load'")})),e.myEventCls.onIds("#"+e.pre+"mn1_menuloadpref","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_menuloadpref","Please input the menu preference file")})),e.myEventCls.onIds("#"+e.pre+"mn1_link_structure","click",(function(t){let s=e.icn3d,i=s.saveFileCls.getLinkToStructureSummary(!0),n=s.structures&&Object.keys(s.structures).length>0?"_blank":"_self";window.open(i,n)})),e.myEventCls.onIds("#"+e.pre+"mn1_link_bind","click",(function(s){let i=e.icn3d;url="https://www.ncbi.nlm.nih.gov/pccompound?LinkName=pccompound_structure&from_uid="+i.inputid,t.setLogCmd("link to 3D protein structures bound to CID "+i.inputid+": "+url,!1);let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(url,n)})),e.myEventCls.onIds("#"+e.pre+"mn1_link_vast","click",(function(s){let i=e.icn3d;if(void 0===i.inputid)url="https://www.ncbi.nlm.nih.gov/pccompound?term="+i.molTitle,t.setLogCmd("link to compounds "+i.molTitle+": "+url,!1);else{let s;if(void 0!==e.cfg.cid)s="https://www.ncbi.nlm.nih.gov/pccompound?LinkName=pccompound_pccompound_3d&from_uid="+i.inputid,t.setLogCmd("link to compounds with structure similar to CID "+i.inputid+": "+s,!1);else{let n=i.inputid.split("_");1===n.length?(s=e.htmlCls.baseUrl+"vastplus/vastplus.cgi?uid="+i.inputid,t.setLogCmd("link to structures similar to "+i.inputid+": "+s,!1)):2===n.length&&(s=e.htmlCls.baseUrl+"vastplus/vastplus.cgi?uid="+n[0],t.setLogCmd("link to structures similar to "+n[0]+": "+s,!1))}}let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(url,n)})),e.myEventCls.onIds("#"+e.pre+"mn1_link_pubmed","click",(function(s){let i=e.icn3d;if(void 0===i.inputid){let e;e="https://www.ncbi.nlm.nih.gov/pubmed/?term="+i.molTitle,t.setLogCmd("link to literature about "+i.molTitle+": "+e,!1);let s=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(e,s)}else if(i.pmid){let e,s=i.pmid.toString().split("_");1===s.length?(e="https://www.ncbi.nlm.nih.gov/pubmed/"+i.pmid,t.setLogCmd("link to PubMed ID "+i.pmid+": "+e,!1)):2===s.length&&(e="https://www.ncbi.nlm.nih.gov/pubmed/?term="+s[0]+" OR "+s[1],t.setLogCmd("link to PubMed IDs "+s[0]+", "+s[1]+": "+e,!1));let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(e,n)}else if(isNaN(i.inputid)){let e,s=i.inputid.toString().split("_");1===s.length?(e="https://www.ncbi.nlm.nih.gov/pubmed/?term="+i.inputid,t.setLogCmd("link to literature about PDB "+i.inputid+": "+e,!1)):2===s.length&&(e="https://www.ncbi.nlm.nih.gov/pubmed/?term="+s[0]+" OR "+s[1],t.setLogCmd("link to literature about PDB "+s[0]+" OR "+s[1]+": "+e,!1));let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(e,n)}else void 0!==e.cfg.cid?alert("No literature information is available for this compound in the SDF file."):alert("No literature information is available for this structure.")})),e.myEventCls.onIds("#"+e.pre+"mn1_link_protein","click",(function(s){let i=e.icn3d,n=Object.keys(i.structures),l=Object.keys(i.chains),r="";for(let e=0,t=l.length;e0&&(r=r.substr(0,r.length-4));let o="https://www.ncbi.nlm.nih.gov/protein/?term="+r;t.setLogCmd("link to Entrez protein about PDB "+n+": "+o,!1);let a=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(o,a)}))}clickMenu2(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds(["#"+e.pre+"mn6_selectannotations","#"+e.pre+"tool_selectannotations"],"click",(async function(s){let i=e.icn3d;await i.showAnnoCls.showAnnotations(),t.setLogCmd("view annotations",!0)})),e.myEventCls.onIds("#"+e.pre+"mn2_selectall","click",(function(s){let i=e.icn3d;t.setLogCmd("select all",!0),i.selectionCls.selectAll(),i.hlUpdateCls.removeHlAll(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"clearall","click",(function(s){let i=e.icn3d;t.setLogCmd("clear all",!0),i.bSelectResidue=!1,i.selectionCls.selectAll(),i.hlUpdateCls.removeHlAll(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn2_selectdisplayed","click",(function(s){let i=e.icn3d;t.setLogCmd("select displayed set",!0),i.hAtoms=e.hashUtilsCls.cloneHash(i.viewSelectionAtoms),i.hlUpdateCls.updateHlAll()})),e.myEventCls.onIds("#"+e.pre+"mn2_fullstru","click",(function(s){let i=e.icn3d;t.setLogCmd("show all",!0),i.selectionCls.showAll()})),e.myEventCls.onIds("#"+e.pre+"mn2_selectcomplement","click",(function(s){let i=e.icn3d;Object.keys(i.hAtoms).lengthnon-selected"+n),$("#"+e.pre+"atomsCustomSphere2").length&&$("#"+e.pre+"atomsCustomSphere2").html(" "+n),e.htmlCls.dialogCls.openDlg("dl_aroundsphere","Select a sphere around a set of residues"),i.bSphereCalc=!1,$("#"+e.pre+"atomsCustomSphere").resizable(),$("#"+e.pre+"atomsCustomSphere2").resizable()})),e.myEventCls.onIds(["#"+e.pre+"mn2_select_chain","#"+e.pre+"definedSets"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_select_chain","Select Structure/Chain/Custom Selection")}))}clickMenu3(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds(["#"+e.pre+"mn3_proteinsRibbon","#"+e.pre+"tool_proteinsRibbon"],"click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","ribbon"),t.setLogCmd("style proteins ribbon",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsStrand","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","strand"),t.setLogCmd("style proteins strand",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsCylinder","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","cylinder and plate"),t.setLogCmd("style proteins cylinder and plate",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsSchematic","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","schematic"),t.setLogCmd("style proteins schematic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsCalpha","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","c alpha trace"),t.setLogCmd("style proteins c alpha trace",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsBackbone","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","backbone"),t.setLogCmd("style proteins backbone",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsBfactor","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","b factor tube"),t.setLogCmd("style proteins b factor tube",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsLines","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","lines"),t.setLogCmd("style proteins lines",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsStick","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","stick"),t.setLogCmd("style proteins stick",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn3_proteinsBallstick","#"+e.pre+"tool_proteinsBallstick"],"click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","ball and stick"),t.setLogCmd("style proteins ball and stick",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn3_proteinsSphere","#"+e.pre+"tool_proteinsSphere"],"click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","sphere"),t.setLogCmd("style proteins sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsNo","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","nothing"),t.setLogCmd("style proteins nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecLines","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","lines2"),t.setLogCmd("style sidec lines2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecStick","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","stick2"),t.setLogCmd("style sidec stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","ball and stick2"),t.setLogCmd("style sidec ball and stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","sphere2"),t.setLogCmd("style sidec sphere2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecNo","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","nothing"),t.setLogCmd("style sidec nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseLines","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","lines2"),t.setLogCmd("style ntbase lines2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseStick","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","stick2"),t.setLogCmd("style ntbase stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","ball and stick2"),t.setLogCmd("style ntbase ball and stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","sphere2"),t.setLogCmd("style ntbase sphere2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseNo","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","nothing"),t.setLogCmd("style ntbase nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclCartoon","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","nucleotide cartoon"),t.setLogCmd("style nucleotides nucleotide cartoon",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclBackbone","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","backbone"),t.setLogCmd("style nucleotides backbone",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclSchematic","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","schematic"),t.setLogCmd("style nucleotides schematic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclPhos","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","o3 trace"),t.setLogCmd("style nucleotides o3 trace",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclLines","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","lines"),t.setLogCmd("style nucleotides lines",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclStick","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","stick"),t.setLogCmd("style nucleotides stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","ball and stick"),t.setLogCmd("style nucleotides ball and stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","sphere"),t.setLogCmd("style nucleotides sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclNo","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","nothing"),t.setLogCmd("style nucleotides nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligLines","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","lines"),t.setLogCmd("style chemicals lines",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligStick","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","stick"),t.setLogCmd("style chemicals stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","ball and stick"),t.setLogCmd("style chemicals ball and stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligSchematic","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","schematic"),t.setLogCmd("style chemicals schematic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","sphere"),t.setLogCmd("style chemicals sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligNo","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","nothing"),t.setLogCmd("style chemicals nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_glycansCartYes","click",(function(s){let i=e.icn3d;i.bGlycansCartoon=!0,i.drawCls.draw(),t.setLogCmd("glycans cartoon yes",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_glycansCartNo","click",(function(s){let i=e.icn3d;i.bGlycansCartoon=!1,i.drawCls.draw(),t.setLogCmd("glycans cartoon no",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_hydrogensYes","click",(function(s){let i=e.icn3d;i.showInterCls.showHydrogens(),i.drawCls.draw(),t.setLogCmd("hydrogens",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_hydrogensNo","click",(function(s){let i=e.icn3d;i.showInterCls.hideHydrogens(),i.drawCls.draw(),t.setLogCmd("set hydrogens off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ionsSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("ions","sphere"),t.setLogCmd("style ions sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ionsDot","click",(function(s){e.icn3d.setOptionCls.setStyle("ions","dot"),t.setLogCmd("style ions dot",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ionsNo","click",(function(s){e.icn3d.setOptionCls.setStyle("ions","nothing"),t.setLogCmd("style ions nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_waterSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("water","sphere"),t.setLogCmd("style water sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_waterDot","click",(function(s){e.icn3d.setOptionCls.setStyle("water","dot"),t.setLogCmd("style water dot",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_waterNo","click",(function(s){e.icn3d.setOptionCls.setStyle("water","nothing"),t.setLogCmd("style water nothing",!0)}))}clickMenu4(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrum","click",(function(s){e.icn3d.setOptionCls.setOption("color","spectrum"),t.setLogCmd("color spectrum",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrumChain","click",(function(s){e.icn3d.setOptionCls.setOption("color","spectrum for chains"),t.setLogCmd("color spectrum for chains",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrumAcrossSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorSpectrumAcross").length&&$("#"+e.pre+"atomsCustomColorSpectrumAcross").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorspectrumacrosssets","Please select sets to apply spectrum color for sets"),$("#"+e.pre+"atomsCustomColorSpectrumAcross").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrumSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorSpectrum").length&&$("#"+e.pre+"atomsCustomColorSpectrum").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorspectrumbysets","Please select sets to apply spectrum color for residues"),$("#"+e.pre+"atomsCustomColorSpectrum").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrRainbowAcrossSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorRainbowAcross").length&&$("#"+e.pre+"atomsCustomColorRainbowAcross").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorrainbowacrosssets","Please select sets to apply rainbow color for sets"),$("#"+e.pre+"atomsCustomColorRainbowAcross").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrRainbowSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorRainbow").length&&$("#"+e.pre+"atomsCustomColorRainbow").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorrainbowbysets","Please select sets to apply rainbow color for residues"),$("#"+e.pre+"atomsCustomColorRainbow").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrRainbow","click",(function(s){e.icn3d.setOptionCls.setOption("color","rainbow"),t.setLogCmd("color rainbow",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrRainbowChain","#"+e.pre+"tool_clrRainbowChain"],"click",(function(s){e.icn3d.setOptionCls.setOption("color","rainbow for chains"),t.setLogCmd("color rainbow for chains",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrChain","#"+e.pre+"tool_clrChain"],"click",(function(s){e.icn3d.setOptionCls.setOption("color","chain"),t.setLogCmd("color chain",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrStructure","click",(function(s){e.icn3d.setOptionCls.setOption("color","structure"),t.setLogCmd("color structure",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrdomain","click",(function(s){e.icn3d.setOptionCls.setOption("color","domain"),t.setLogCmd("color domain",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrsets","click",(function(s){e.icn3d.setOptionCls.setOption("color","defined sets"),t.setLogCmd("color defined sets",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrSSGreen","#"+e.pre+"tool_clrSSGreen"],"click",(function(s){let i=e.icn3d;i.sheetcolor="green",i.setOptionCls.setOption("color","secondary structure green"),t.setLogCmd("color secondary structure green",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSSYellow","click",(function(s){let i=e.icn3d;i.sheetcolor="yellow",i.setOptionCls.setOption("color","secondary structure yellow"),t.setLogCmd("color secondary structure yellow",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSSSpectrum","click",(function(s){e.icn3d.setOptionCls.setOption("color","secondary structure spectrum"),t.setLogCmd("color secondary structure spectrum",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrResidue","click",(function(s){e.icn3d.setOptionCls.setOption("color","residue"),t.setLogCmd("color residue",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrResidueCustom","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_rescolorfile","Please input the file on residue colors")})),e.myEventCls.onIds("#"+e.pre+"reload_rescolorfile","click",(function(s){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close");let n=$("#"+e.pre+"rescolorfile")[0].files[0];if(n){e.htmlCls.setHtmlCls.fileSupport();let s=new FileReader;s.onload=function(s){let n=s.target.result.replace(/#/g,"");i.customResidueColors=JSON.parse(n);for(let t in i.customResidueColors)i.customResidueColors[t.toUpperCase()]=e.parasCls.thr("#"+i.customResidueColors[t]);i.setOptionCls.setOption("color","residue custom"),t.setLogCmd("color residue custom | "+n,!0)},s.readAsText(n)}else alert("Please select a file before clicking 'Load'")})),e.myEventCls.onIds("#"+e.pre+"reload_customcolorfile","click",(function(s){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close"),i.startColor=$("#"+e.pre+"startColor").val(),i.midColor=$("#"+e.pre+"midColor").val(),i.endColor=$("#"+e.pre+"endColor").val();let n=t.setLegendHtml();$("#"+e.pre+"dl_legend").html(n),e.htmlCls.dialogCls.openDlg("dl_legend","Color range"),i.addTrackCls.setCustomFile("color",i.startColor,i.midColor,i.endColor)})),e.myEventCls.onIds("#"+e.pre+"mn6_customref","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_customref","Set custom reference numbers")})),e.myEventCls.onIds("#"+e.pre+"reload_customreffile","click",(function(s){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close");let n=$("#"+i.pre+"cstreffile")[0].files[0];if(n){e.utilsCls.checkFileAPI();let s=new FileReader;s.onload=async function(e){let s=e.target.result;await i.refnumCls.parseCustomRefFile(s),s=s.replace(/\r/g,"").replace(/\n/g,"\\n"),t.setLogCmd("custom refnum | "+s,!0)},s.readAsText(n)}else alert("Please select a file before clicking 'Apply'")})),e.myEventCls.onIds("#"+e.pre+"remove_legend","click",(function(s){e.icn3d,$("#"+e.pre+"legend").hide(),t.setLogCmd("remove legend",!0)})),e.myEventCls.onIds("#"+e.pre+"reload_customtubefile","click",(function(t){let s=e.icn3d;e.cfg.notebook||dialog.dialog("close"),s.addTrackCls.setCustomFile("tube")})),e.myEventCls.onIds("#"+e.pre+"mn4_clrCharge","click",(function(s){e.icn3d.setOptionCls.setOption("color","charge"),t.setLogCmd("color charge",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrHydrophobic","click",(function(s){e.icn3d.setOptionCls.setOption("color","hydrophobic"),t.setLogCmd("color hydrophobic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrNormalizedHP","click",(function(s){e.icn3d.setOptionCls.setOption("color","normalized hydrophobic"),t.setLogCmd("color normalized hydrophobic",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrAtom","#"+e.pre+"tool_clrAtom"],"click",(function(s){e.icn3d.setOptionCls.setOption("color","atom"),t.setLogCmd("color atom",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrBfactor","click",(function(s){e.icn3d.setOptionCls.setOption("color","b factor"),t.setLogCmd("color b factor",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrConfidence","click",(function(s){e.icn3d.setOptionCls.setOption("color","confidence"),t.setLogCmd("color confidence",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrIgstrand","click",(function(s){e.icn3d.setOptionCls.setOption("color","ig strand"),t.setLogCmd("color ig strand",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrArea","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_colorbyarea","Color based on residue's solvent accessibility")})),e.myEventCls.onIds("#"+e.pre+"applycolorbyarea","click",(function(s){let i=e.icn3d;i.midpercent=$("#"+e.pre+"midpercent").val(),i.setOptionCls.setOption("color","area"),t.setLogCmd("color area | "+i.midpercent,!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrBfactorNorm","click",(function(s){e.icn3d.setOptionCls.setOption("color","b factor percentile"),t.setLogCmd("color b factor percentile",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrIdentity","click",(function(s){e.icn3d.setOptionCls.setOption("color","identity"),t.setLogCmd("color identity",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrConserved","click",(function(s){e.icn3d.setOptionCls.setOption("color","conservation"),t.setLogCmd("color conservation",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrCustom","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_clr","Color picker")})),$(document).on("click",".icn3d-color-rad-text",(function(s){let i=e.icn3d;s.stopImmediatePropagation(),s.preventDefault();let n=$(this).attr("color");i.setOptionCls.setOption("color",n),t.setLogCmd("color "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSave","click",(function(s){e.icn3d.setOptionCls.saveColor(),t.setLogCmd("save color",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrApplySave","click",(function(s){e.icn3d.setOptionCls.applySavedColor(),t.setLogCmd("apply saved color",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_styleSave","click",(function(s){e.icn3d.setOptionCls.saveStyle(),t.setLogCmd("save style",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_styleApplySave","click",(function(s){e.icn3d.setOptionCls.applySavedStyle(),t.setLogCmd("apply saved style",!0)}))}clickMenu5(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds("#"+e.pre+"mn5_neighborsYes","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.applyMapCls.removeLastSurface(),i.applyMapCls.applySurfaceOptions(),i.bRender&&i.drawCls.render(),t.setLogCmd("set surface neighbors on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_neighborsNo","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.applyMapCls.removeLastSurface(),i.applyMapCls.applySurfaceOptions(),i.bRender&&i.drawCls.render(),t.setLogCmd("set surface neighbors off",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn5_surfaceVDW","#"+e.pre+"tool_surfaceVDW"],"click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.setOptionCls.setOption("surface","Van der Waals surface"),t.setLogCmd("set surface Van der Waals surface",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceSAS","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.setOptionCls.setOption("surface","solvent accessible surface"),t.setLogCmd("set surface solvent accessible surface",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceMolecular","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.setOptionCls.setOption("surface","molecular surface"),t.setLogCmd("set surface molecular surface",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceVDWContext","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.setOptionCls.setOption("surface","Van der Waals surface with context"),t.setLogCmd("set surface Van der Waals surface with context",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceSASContext","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.setOptionCls.setOption("surface","solvent accessible surface with context"),t.setLogCmd("set surface solvent accessible surface with context",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceMolecularContext","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.setOptionCls.setOption("surface","molecular surface with context"),t.setLogCmd("set surface molecular surface with context",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceNo","click",(function(s){e.icn3d.setOptionCls.setOption("surface","nothing"),t.setLogCmd("set surface nothing",!0)})),$(document).on("click","."+e.pre+"mn5_opacity",(function(s){let i=e.icn3d;i.transparentRenderOrder=!1;let n=$(this).attr("v");i.setOptionCls.setOption("opacity",n),t.setLogCmd("set surface opacity "+n,!0)})),$(document).on("click","."+e.pre+"mn5_opacityslow",(function(s){let i=e.icn3d;i.transparentRenderOrder=!0;let n=$(this).attr("v");i.setOptionCls.setOption("opacity",n),t.setLogCmd("set surface2 opacity "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_wireframeYes","click",(function(s){e.icn3d.setOptionCls.setOption("wireframe","yes"),t.setLogCmd("set surface wireframe on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_wireframeNo","click",(function(s){e.icn3d.setOptionCls.setOption("wireframe","no"),t.setLogCmd("set surface wireframe off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_elecmap2fofc","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_elecmap2fofc","2Fo-Fc Electron Density Map")})),e.myEventCls.onIds("#"+e.pre+"mn5_elecmapfofc","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_elecmapfofc","Fo-Fc Electron Density Map")})),e.myEventCls.onIds(["#"+e.pre+"mn5_elecmapNo","#"+e.pre+"elecmapNo2","#"+e.pre+"elecmapNo3","#"+e.pre+"elecmapNo4","#"+e.pre+"elecmapNo5"],"click",(function(s){e.icn3d.setOptionCls.setOption("map","nothing"),t.setLogCmd("setoption map nothing",!0)})),e.myEventCls.onIds(["#"+e.pre+"delphimapNo","#"+e.pre+"phimapNo","#"+e.pre+"phiurlmapNo","#"+e.pre+"mn1_phimapNo"],"click",(function(s){e.icn3d.setOptionCls.setOption("phimap","nothing"),t.setLogCmd("setoption phimap nothing",!0)})),e.myEventCls.onIds(["#"+e.pre+"delphimapNo2","#"+e.pre+"phimapNo2","#"+e.pre+"phiurlmapNo2"],"click",(function(s){e.icn3d.setOptionCls.setOption("phisurface","nothing"),t.setLogCmd("setoption phisurface nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"applymap2fofc","click",(function(s){let i=e.icn3d,n=parseFloat($("#"+e.pre+"sigma2fofc").val());i.dsn6ParserCls.dsn6Parser(i.inputid,"2fofc",n),t.setLogCmd("set map 2fofc sigma "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"applymapfofc","click",(function(s){let i=e.icn3d,n=parseFloat($("#"+e.pre+"sigmafofc").val());i.dsn6ParserCls.dsn6Parser(i.inputid,"fofc",n),t.setLogCmd("set map fofc sigma "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_mapwireframeYes","click",(function(s){e.icn3d.setOptionCls.setOption("mapwireframe","yes"),t.setLogCmd("set map wireframe on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_mapwireframeNo","click",(function(s){e.icn3d.setOptionCls.setOption("mapwireframe","no"),t.setLogCmd("set map wireframe off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_emmap","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_emmap","EM Density Map")})),e.myEventCls.onIds(["#"+e.pre+"mn5_emmapNo","#"+e.pre+"emmapNo2"],"click",(function(s){e.icn3d.setOptionCls.setOption("emmap","nothing"),t.setLogCmd("setoption emmap nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"applyemmap","click",(function(s){let i=e.icn3d,n=parseFloat($("#"+e.pre+"empercentage").val());i.densityCifParserCls.densityCifParser(i.inputid,"em",n,i.emd),t.setLogCmd("set emmap percentage "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_emmapwireframeYes","click",(function(s){e.icn3d.setOptionCls.setOption("emmapwireframe","yes"),t.setLogCmd("set emmap wireframe on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_emmapwireframeNo","click",(function(s){e.icn3d.setOptionCls.setOption("emmapwireframe","no"),t.setLogCmd("set emmap wireframe off",!0)}))}clickMenu6(){let e=this.icn3dui,t=e.icn3d;if(e.bNode)return;let s=this;e.myEventCls.onIds("#"+e.pre+"mn6_assemblyYes","click",(function(t){let i=e.icn3d;i.bAssembly=!0,s.setLogCmd("set assembly on",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_assemblyNo","click",(function(t){let i=e.icn3d;i.bAssembly=!1,s.setLogCmd("set assembly off",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_igrefYes","click",(async function(t){let i=e.icn3d;s.setLogCmd("ig refnum on",!0),await i.refnumCls.showIgRefNum()})),e.myEventCls.onIds("#"+e.pre+"mn6_igrefNo","click",(async function(t){let i=e.icn3d;s.setLogCmd("ig refnum off",!0),await i.refnumCls.hideIgRefNum()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelAtoms","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addAtomLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add atom labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelElements","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addAtomLabels(i.hAtoms,!0),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add element labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelResidues","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addResidueLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add residue labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelResnum","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addResidueLabels(i.hAtoms,void 0,void 0,!0),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add residue number labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelChains","click",(function(t){let i=e.icn3d;i.analysisCls.addChainLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add chain labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelTermini","click",(function(t){let i=e.icn3d;i.analysisCls.addTerminiLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add terminal labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelYes","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_addlabel","Add custom labels by selection"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelSelection","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_addlabelselection","Add custom labels by the selected")})),e.myEventCls.onIds("#"+e.pre+"mn6_labelColor","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_labelColor","Change color for all labels")})),e.myEventCls.onIds(["#"+e.pre+"mn2_saveselection","#"+e.pre+"tool_saveselection"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_saveselection","Save the selected")})),e.myEventCls.onIds(["#"+e.pre+"mn6_addlabelNo","#"+e.pre+"removeLabels"],"click",(function(t){let i=e.icn3d;i.labelcolor=void 0,i.pickpair=!1;s.setLogCmd("set labels off",!0);for(let e in i.labels)i.labels[e]=[];i.drawCls.draw()})),$(document).on("click","."+e.pre+"mn6_labelscale",(function(t){let i=e.icn3d,n=$(this).attr("v");i.labelScale=n,i.drawCls.draw(),s.setLogCmd("set label scale "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_distanceYes","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_distance","Measure the distance of atoms"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0,s.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_distTwoSets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_disttwosets","Measure the distance between two sets"),s.setSetsMenus("atomsCustomDist"),i.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_distManySets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_distmanysets","Measure the pairwise distance among many sets"),s.setSetsMenus("atomsCustomDistTable"),i.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_distanceNo","click",(function(t){let i=e.icn3d;i.pickpair=!1;s.setLogCmd("set lines off",!0),i.labels.distance=[],i.lines.distance=[],i.distPnts=[],i.pk=2,i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn5_cartoonshape","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_cartoonshape","Draw cartoon for a set");s.setSetsMenus("cartoonshape",!0),i.bCartoonshape=!0})),e.myEventCls.onIds("#"+e.pre+"mn5_linebtwsets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_linebtwsets","Draw a line between two sets"),s.setSetsMenus("linebtwsets"),i.bLinebtwsets=!0})),e.myEventCls.onIds(["#"+e.pre+"mn2_selectedcenter","#"+e.pre+"zoomin_selection","#"+e.pre+"tool_selectedcenter"],"click",(function(t){let i=e.icn3d;i.transformCls.zoominSelection(),i.drawCls.draw(),s.setLogCmd("zoom selection",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_center","click",(function(t){let i=e.icn3d;i.applyCenterCls.centerSelection(),i.drawCls.draw(),s.setLogCmd("center selection",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_resetOrientation","#"+e.pre+"resetOrientation","#"+e.pre+"tool_resetOrientation"],"click",(function(t){let i=e.icn3d;i.transformCls.resetOrientation(),i.drawCls.draw(),s.setLogCmd("reset orientation",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_chemicalbindingshow","#"+e.pre+"chemicalbindingshow"],"click",(function(t){e.icn3d.setOptionCls.setOption("chemicalbinding","show"),s.setLogCmd("set chemicalbinding show",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_chemicalbindinghide","#"+e.pre+"chemicalbindinghide"],"click",(function(t){e.icn3d.setOptionCls.setOption("chemicalbinding","hide"),s.setLogCmd("set chemicalbinding hide",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_sidebyside","click",(function(t){let i=e.icn3d;if(i.bInputfile)return void alert("Side-by-Side does NOT work when the input is from a local file.");let n=i.shareLinkCls.shareLinkUrl(void 0);n=n.replace("full.html","full2.html"),n+="&closepopup=1";let l=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(n,l),s.setLogCmd("side by side | "+n,!0)})),$(document).on("click","."+e.pre+"mn6_rotate",(function(t){let i=e.icn3d,n=$(this).attr("v").toLowerCase(),l=n.split(" ")[1];s.setLogCmd(n,!0),i.bStopRotate=!1,i.transformCls.rotateCount=0,i.transformCls.rotateCountMax=6e3,i.ROT_DIR=l,i.resizeCanvasCls.rotStruc(l)})),$(document).on("click","."+e.pre+"mn6_rotate90",(function(t){let i,n=e.icn3d,l=$(this).attr("v").toLowerCase(),r=l.split("-")[0];s.setLogCmd(l,!0),"x"==r?i=new THREE.Vector3(1,0,0):"y"==r?i=new THREE.Vector3(0,1,0):"z"==r&&(i=new THREE.Vector3(0,0,1));let o=.5*Math.PI;n.transformCls.setRotation(i,o)})),e.myEventCls.onIds("#"+e.pre+"mn6_cameraPers","click",(function(t){e.icn3d.setOptionCls.setOption("camera","perspective"),s.setLogCmd("set camera perspective",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_cameraOrth","click",(function(t){e.icn3d.setOptionCls.setOption("camera","orthographic"),s.setLogCmd("set camera orthographic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_bkgdBlack","click",(function(t){e.icn3d.setStyleCls.setBackground("black")})),e.myEventCls.onIds("#"+e.pre+"tool_bkgd","click",(function(t){let s=e.icn3d;"black"==s.opts.background?s.setStyleCls.setBackground("white"):s.setStyleCls.setBackground("black")})),e.myEventCls.onIds("#"+e.pre+"mn6_bkgdGrey","click",(function(t){e.icn3d.setStyleCls.setBackground("grey")})),e.myEventCls.onIds(["#"+e.pre+"mn6_bkgdWhite","#"+e.pre+"tool_bkgdWhite"],"click",(function(t){e.icn3d.setStyleCls.setBackground("white")})),e.myEventCls.onIds("#"+e.pre+"mn6_bkgdTransparent","click",(function(t){e.icn3d.setStyleCls.setBackground("transparent")})),e.myEventCls.onIds("#"+e.pre+"mn6_showfogYes","click",(function(t){let i=e.icn3d;i.opts.fog="yes",i.fogCls.setFog(!0),i.drawCls.draw(),s.setLogCmd("set fog on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showfogNo","click",(function(t){let i=e.icn3d;i.opts.fog="no",i.fogCls.setFog(!0),i.drawCls.draw(),s.setLogCmd("set fog off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showslabYes","click",(function(t){e.icn3d.setOptionCls.setOption("slab","yes"),s.setLogCmd("set slab on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showslabNo","click",(function(t){e.icn3d.setOptionCls.setOption("slab","no"),s.setLogCmd("set slab off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showaxisYes","click",(function(t){e.icn3d.setOptionCls.setOption("axis","yes"),s.setLogCmd("set axis on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showaxisSel","click",(function(t){let i=e.icn3d;i.pc1=!0,i.axesCls.setPc1Axes(),s.setLogCmd("set pc1 axis",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showaxisNo","click",(function(t){let i=e.icn3d;i.pc1=!1,i.axes=[],i.setOptionCls.setOption("axis","no"),s.setLogCmd("set axis off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_symmetry","click",(async function(t){let s=e.icn3d;s.bAxisOnly=!1,await s.symdCls.retrieveSymmetry(Object.keys(s.structures)[0])})),e.myEventCls.onIds("#"+e.pre+"mn6_symd","click",(async function(t){let i=e.icn3d;i.bAxisOnly=!1,await i.symdCls.retrieveSymd(),i.bSymd=!0,s.setLogCmd("symd symmetry",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_clear_sym","click",(function(t){let i=e.icn3d;i.symdArray=[],i.drawCls.draw(),s.setLogCmd("clear symd symmetry",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_axes_only","click",(function(t){let i=e.icn3d;i.bAxisOnly=!0,i.drawCls.draw(),s.setLogCmd("show axis",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_area","click",(function(t){e.icn3d.analysisCls.calculateArea(),s.setLogCmd("area",!0)})),e.myEventCls.onIds("#"+e.pre+"applysymmetry","click",(function(t){let i=e.icn3d;i.bAxisOnly=!1;let n=$("#"+e.pre+"selectSymmetry").val();i.symmetrytitle="none"===n?void 0:n,i.drawCls.draw(),s.setLogCmd("symmetry "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"clearsymmetry","click",(function(t){let i=e.icn3d;i.symmetrytitle=void 0,i.drawCls.draw(),s.setLogCmd("symmetry none",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_hbondsYes","#"+e.pre+"hbondsYes"],"click",(function(t){let i=e.icn3d;s.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomHbond").length&&$("#"+e.pre+"atomsCustomHbond").html(" "+n),$("#"+e.pre+"atomsCustomHbond2").length&&$("#"+e.pre+"atomsCustomHbond2").html(" "+n),e.htmlCls.dialogCls.openDlg("dl_hbonds","Hydrogen bonds/interactions between two sets of atoms"),i.bHbondCalc=!1,$("#"+e.pre+"atomsCustomHbond").resizable(),$("#"+e.pre+"atomsCustomHbond2").resizable()})),e.myEventCls.onIds(["#"+e.pre+"mn6_contactmap"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_contact","Set contact map")})),e.myEventCls.onIds("#"+e.pre+"mn6_hbondsNo","click",(function(t){let s=e.icn3d;s.showInterCls.hideHbondsContacts(),s.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerYes","click",(function(t){let i=e.icn3d;i.threeDPrintCls.addStabilizer(),i.threeDPrintCls.prepareFor3Dprint(),s.setLogCmd("stabilizer",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerNo","click",(function(t){let i=e.icn3d;s.setLogCmd("set stabilizer off",!0),i.threeDPrintCls.hideStabilizer(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerOne","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_stabilizer","Add One Stabilizer"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerRmOne","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_stabilizer_rm","Remove One Stabilizer"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0})),e.myEventCls.onIds("#"+e.pre+"mn1_thicknessSet","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_thickness","Set Thickness for 3D Printing")})),e.myEventCls.onIds("#"+e.pre+"mn3_setThickness","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_thickness2","Style Preferences")})),e.myEventCls.onIds("#"+e.pre+"mn6_ssbondsYes","click",(function(t){let i=e.icn3d;s.setLogCmd("disulfide bonds",!0),i.showInterCls.showSsbonds()})),e.myEventCls.onIds("#"+e.pre+"mn6_ssbondsExport","click",(function(t){e.icn3d.viewInterPairsCls.exportSsbondPairs(),s.setLogCmd("export disulfide bond pairs",!1)})),e.myEventCls.onIds("#"+e.pre+"mn6_ssbondsNo","click",(function(t){let i=e.icn3d;i.opts.ssbonds="no";s.setLogCmd("set disulfide bonds off",!0),i.lines.ssbond=[],i.setOptionCls.setStyle("sidec","nothing")})),e.myEventCls.onIds("#"+e.pre+"mn6_clbondsYes","click",(function(t){let i=e.icn3d;s.setLogCmd("cross linkage",!0),i.showInterCls.showClbonds()})),e.myEventCls.onIds("#"+e.pre+"mn6_clbondsExport","click",(function(t){e.icn3d.viewInterPairsCls.exportClbondPairs(),s.setLogCmd("export cross linkage pairs",!1)})),e.myEventCls.onIds("#"+e.pre+"mn6_clbondsNo","click",(function(t){let i=e.icn3d;i.opts.clbonds="no";s.setLogCmd("set cross linkage off",!0),i.lines.clbond=[],i.setOptionCls.setStyle("sidec","nothing")})),$("#"+e.pre+"newvs2").on("submit",(function(){let s=t.saveFileCls.getAtomPDB(t.hAtoms);return $("#"+e.pre+"pdbstr").val(s),!0})),$("#"+e.pre+"fssubmit").on("click",(function(){let e=t.saveFileCls.getAtomPDB(t.hAtoms),s=window.open("","_blank");s.document.body.innerHTML="\n\nLoading Foldseek\n\n\n\n
    Foldseek is loading...
    \n",$.ajax({url:"https://search.foldseek.com/api/ticket",type:"POST",data:{q:e,database:["afdb50","afdb-swissprot","gmgcl_id","pdb100","afdb-proteome","mgnify_esm30"],mode:"3diaa"},dataType:"text",success:function(e){s.location="https://search.foldseek.com/queue/"+JSON.parse(e).id},error:function(e,t,s){console.log("Error in submitting data to Foldseek...")}})}))}setLogCmd(e,t,s){var i=this.icn3dui,n=i.icn3d;if(""===e.trim())return!1;let l=e.indexOf("|||");-1!==l&&(e=e.substr(0,l));let r={};if(r.factor=n._zoomFactor,r.mouseChange=n.mouseChange,r.quaternion={},r.quaternion._x=parseFloat(n.quaternion._x).toPrecision(5),r.quaternion._y=parseFloat(n.quaternion._y).toPrecision(5),r.quaternion._z=parseFloat(n.quaternion._z).toPrecision(5),r.quaternion._w=parseFloat(n.quaternion._w).toPrecision(5),t&&n.bAddCommands)if(n.STATENUMBER "+n.logs.join("\n> ")+"\n> "),$("#"+i.pre+"logtext")[0]&&$("#"+i.pre+"logtext").scrollTop($("#"+i.pre+"logtext")[0].scrollHeight)}n.setStyleCls.adjustIcon()}}class d{constructor(e){this.icn3dui=e}getLink(e,t,s,i){return this.icn3dui.htmlCls.setHtmlCls.getLink(e,t,s,i)}getMenuText(e,t,s,i,n){return this.icn3dui.htmlCls.setHtmlCls.getMenuText(e,t,s,i,n)}getMenuUrl(e,t,s,i,n){return this.icn3dui.htmlCls.setHtmlCls.getMenuUrl(e,t,s,i,n)}getMenuSep(){return this.icn3dui.htmlCls.setHtmlCls.getMenuSep()}getLinkWrapper(e,t,s,i,n,l){let r=this.icn3dui;return r.icn3d,r.htmlCls.setHtmlCls.getLinkWrapper(e,t,s,i,n,l)}getLinkWrapper2(e,t,s,i,n){let l=this.icn3dui;return l.icn3d,l.htmlCls.setHtmlCls.getLinkWrapper2(e,t,s,i,n)}getRadio(e,t,s,i,n,l){return this.icn3dui.htmlCls.setHtmlCls.getRadio(e,t,s,i,n,l)}getRadClr(e,t,s,i,n,l,r){return this.icn3dui.htmlCls.setHtmlCls.getRadioColor(e,t,s,i,n,l,r)}setTopMenusHtml(e,t,s){let i=this.icn3dui;if(i.bNode)return"";let n="black"==i.htmlCls.opts.background?i.htmlCls.GREYD:"black",l="";l+="
    ",l+=i.htmlCls.divStr+"popup' class='icn3d-text icn3d-popup'>
    ",l+=this.setReplayHtml(),l+="\x3c!--https://forum.jquery.com/topic/looking-for-a-jquery-horizontal-menu-bar--\x3e",l+=i.htmlCls.divStr+"mnlist' style='position:absolute; z-index:999; float:left; display:table-row; margin-top: -2px;'>",l+="";let r='",l+=r+this.setMenu2()+"",l+=r+this.setMenu2b()+"",l+=r+this.setMenu3()+"",l+=r+this.setMenu4()+"",l+=r+this.setMenu5()+"",l+=r+this.setMenu6()+"",i.htmlCls.shownMenus=i.hashUtilsCls.cloneHash(i.htmlCls.simpleMenus),l+=r+"
    "+t,l+="
    "+s,l+=r+'
    '+i.htmlCls.space2+'Toolbar '+i.htmlCls.space2+'
    ",l+=r+'
    '+i.htmlCls.space2+' ?
    ',l+="
    ",l+="
    ';if(l+=r+this.setMenu1()+"
    ",l+="",l+=this.setTools(),l+=i.htmlCls.divStr+"title' class='icn3d-commandTitle' style='font-size:1.2em; font-weight:normal; position:absolute; z-index:1; float:left; display:table-row; margin: 85px 0px 0px 5px; color:"+n+"; width:"+i.htmlCls.WIDTH+"px'>",l+=i.htmlCls.divStr+"viewer' style='position:relative; width:100%; height:100%; background-color: "+i.htmlCls.GREYD+";'>",l+=i.htmlCls.divStr+"mnLogSection'>",l+="
    ",l+=" ",void 0===i.cfg.mmtfid){let e="top:180px; font-size: 1.8em;";l+=i.htmlCls.divStr+"wait' style='position:absolute; left:50px; "+e+" color: #444444;'>Loading data..."}l+="Your browser does not support WebGL.",(void 0===i.cfg.showcommand||i.cfg.showcommand)&&(l+=this.setLogWindow()),l+="",l+="",l+=i.htmlCls.setDialogCls.setDialogs(),l+=i.htmlCls.setDialogCls.setCustomDialogs(),$("#"+e).html(l),$("accordion").accordion({collapsible:!0,active:!1,heightStyle:"content"}),$("accordion div").removeClass("ui-accordion-content ui-corner-all ui-corner-bottom ui-widget-content"),$(".icn3d-mn-item").menu({position:{my:"left top",at:"right top"}}),$(".icn3d-mn-item").hover((function(){}),(function(){$("accordion").accordion("option","active","none")})),$("#"+i.pre+"accordion1").hover((function(){$("#"+i.pre+"accordion1 div").css("display","block")}),(function(){$("#"+i.pre+"accordion1 div").css("display","none")})),$("#"+i.pre+"accordion2").hover((function(){$("#"+i.pre+"accordion2 div").css("display","block")}),(function(){$("#"+i.pre+"accordion2 div").css("display","none")})),$("#"+i.pre+"accordion2b").hover((function(){$("#"+i.pre+"accordion2b div").css("display","block")}),(function(){$("#"+i.pre+"accordion2b div").css("display","none")})),$("#"+i.pre+"accordion3").hover((function(){$("#"+i.pre+"accordion3 div").css("display","block")}),(function(){$("#"+i.pre+"accordion3 div").css("display","none")})),$("#"+i.pre+"accordion4").hover((function(){$("#"+i.pre+"accordion4 div").css("display","block")}),(function(){$("#"+i.pre+"accordion4 div").css("display","none")})),$("#"+i.pre+"accordion5").hover((function(){$("#"+i.pre+"accordion5 div").css("display","block")}),(function(){$("#"+i.pre+"accordion5 div").css("display","none")})),$("#"+i.pre+"accordion6").hover((function(){$("#"+i.pre+"accordion6 div").css("display","block")}),(function(){$("#"+i.pre+"accordion6 div").css("display","none")}))}setTopMenusHtmlMobile(e,t,s){let i=this.icn3dui;if(i.bNode)return"";let n="black"==i.htmlCls.opts.background?i.htmlCls.GREYD:"black",l="";if(l+="
    ",l+=i.htmlCls.divStr+"popup' class='icn3d-text icn3d-popup'>
    ",l+=this.setReplayHtml(),!i.utilsCls.isMobile()){let e=i.htmlCls.WIDTH-40+5;l+=i.htmlCls.buttonStr+"fullscreen' style='position:absolute; z-index:1999; display:block; padding:0px; margin: 12px 0px 0px "+e+"px; width:30px; height:34px; border-radius:4px; border:none; background-color:#f6f6f6;' title='Full screen'>",l+="",l+="",l+="",l+="",l+=""}l+="\x3c!--https://forum.jquery.com/topic/looking-for-a-jquery-horizontal-menu-bar--\x3e",l+=i.htmlCls.divStr+"mnlist' style='position:absolute; z-index:999; float:left; display:block; margin: 5px 0px 0px 5px;'>",l+="
    ",l+="",i.cfg.notebook?l+="

    ":l+="

    ",l+="
    ";let r="
  • File",l+=this.setMenu1_base(),l+=r+">Select",l+=this.setMenu2_base(),l+=r+">View",l+=this.setMenu2b_base(),l+=r+" id='"+i.pre+"style'>Style",l+=this.setMenu3_base(),l+=r+" id='"+i.pre+"color'>Color",l+=this.setMenu4_base(),l+=r+">Analysis",l+=this.setMenu5_base(),l+=r+">Help",l+=this.setMenu6_base(),i.htmlCls.shownMenus=i.hashUtilsCls.cloneHash(i.htmlCls.simpleMenus),l+="
  • "+t,l+="
    "+s,l+="
  • Alternate",l+="",l+="
  • ",l+="
    ",l+="
    ",l+="",l+=i.htmlCls.divStr+"title' class='icn3d-commandTitle' style='font-size:1.2em; font-weight:normal; position:absolute; z-index:1; float:left; display:block; margin: 12px 0px 0px 40px; color:"+n+"; width:"+(i.htmlCls.WIDTH-40).toString()+"px'>",l+=i.htmlCls.divStr+"viewer' style='position:relative; width:100%; height:100%; background-color: "+i.htmlCls.GREYD+";'>",l+=i.htmlCls.divStr+"mnLogSection'>",l+="
    ",l+="",void 0===i.cfg.mmtfid){let e="top:180px; font-size: 1.8em;";l+=i.htmlCls.divStr+"wait' style='position:absolute; left:50px; "+e+" color: #444444;'>Loading data..."}l+="Your browser does not support WebGL.",(void 0===i.cfg.showcommand||i.cfg.showcommand)&&(l+=this.setLogWindow()),l+="",l+="",l+=i.htmlCls.setDialogCls.setDialogs(),l+=i.htmlCls.setDialogCls.setCustomDialogs(),$("#"+e).html(l),$("accordion").accordion({collapsible:!0,active:!1,heightStyle:"content"}),$("accordion div").removeClass("ui-accordion-content ui-corner-all ui-corner-bottom ui-widget-content"),$(".icn3d-mn-item").menu({position:{my:"left top",at:"right top"}}),$(".icn3d-mn-item").hover((function(){}),(function(){$("accordion").accordion("option","active","none")})),$("#"+i.pre+"accordion0").hover((function(){$("#"+i.pre+"accordion0 div").css("display","block")}),(function(){$("#"+i.pre+"accordion0 div").css("display","none")}))}setReplayHtml(e){let t=this.icn3dui;if(t.bNode)return"";let s="";return s+=t.htmlCls.divStr+"replay' style='display:none; position:absolute; z-index:9999; top:"+parseInt(t.htmlCls.HEIGHT-100).toString()+"px; left:20px;'>",s+="
    ",s+='',s+="",s+='',s+='',s+="",s+="
    ",s+=t.htmlCls.divStr+"replay_menu' style='background-color:#DDDDDD; padding:3px; font-weight:bold;'>",s+=t.htmlCls.divStr+"replay_cmd' style='background-color:#DDDDDD; padding:3px; max-width:250px'>",s+="",s}setTools(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+=e.htmlCls.divStr+"selection' style='display:none;'>
    ",t+="",t+=this.setTools_base(),t+="
    ",t+="
    ",t}setButton(e,t,s,i,n){let l=this.icn3dui;return l.bNode?"":(n=void 0!==n?"color:"+n:"","
    ")}setIcon(e,t,s,i,n,l,r){let o=this.icn3dui;if(o.bNode)return"";let a,d=r?"color:#f8b84e; ":"color:#1c94c4; ",c=" background-color:#EEE; ",h="text"==e?"":"cursor:pointer;";return a=l?'
    '+i+"
    ":'',"link"==e?''+a+"":a}setTools_base(){if(this.icn3dui.bNode)return"";let e="",t="regular",s="",i="";return e+=s+this.setIcon(t,"tool_mmdbafid","Input PDB/MMDB/AlphaFold IDs","id",void 0,!0)+"",e+=s+this.setIcon(t,"tool_pdbfile","Input PDB Files (appendable)","file-alt")+"",e+=s+this.setIcon(t,"tool_sharelink","Get Share Link","link")+"",e+=s+this.setIcon(t,"saveimage","Save iCn3D PNG Image","camera")+"",e+=i+this.setIcon(t,"tool_definedsets","Defined Sets","object-group")+"",e+=s+this.setIcon(t,"tool_aroundsphere","Select by Distance","dot-circle")+"",e+=s+this.setIcon(t,"tool_saveselection","Save Selection as a Set","save")+"",e+=s+this.setIcon(t,"toggleHighlight","Toggle Highlight","highlighter")+"",e+=i+this.setIcon(t,"show_selected","View Selection","eye")+"",e+=s+this.setIcon(t,"tool_selectedcenter","Zoom in Selection","search-plus")+"",e+=s+this.setIcon(t,"alternate","Alternate the Structures by keying the letter 'a'","a",void 0,!0,!0)+"",e+=s+this.setIcon(t,"tool_resetOrientation","Reset Orientation","undo-alt")+"",e+=i+this.setIcon(t,"tool_proteinsRibbon","Style Ribbon for proteins","dna")+"",e+=s+this.setIcon(t,"tool_proteinsSphere","Style Sphere for proteins","volleyball-ball")+"",e+=s+this.setIcon(t,"tool_surfaceVDW","Show Van der Waals Surface","cloud")+"",e+=s+this.setIcon(t,"tool_bkgd","Toggle Background Color","adjust")+"",e+=i+this.setIcon(t,"tool_clrRainbowChain","Color Rainbow for Chains","rainbow")+"",e+=s+this.setIcon(t,"tool_clrSSGreen","Color by Secondary Structures","ring")+"",e+=s+this.setIcon(t,"tool_clrChain","Color by Chains","layer-group")+"",e+=s+this.setIcon(t,"tool_clrAtom","Color by Atoms","atom")+"",e+=i+this.setIcon(t,"tool_selectannotations","Sequences & Annotations","grip-lines")+"",e+=s+this.setIcon(t,"hbondsYes","Interactions","users")+"",e+=s+this.setIcon(t,"tool_delphi","Delphi Potentials","cloud-meatball")+"",e+=s+this.setIcon(t,"removeLabels","Remove Labels","remove-format")+"",e+=i+this.setIcon("link","tool-gallery","Gallery","image","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#gallery")+"",e+=s+this.setIcon("link","tool-video","Videos","file-video","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#videos")+"",e+=s+this.setIcon("link","tool-github","iCn3D GitHub","code","https://github.com/ncbi/icn3d")+"",e+=s+this.setIcon("link","tool-hints","Transform Hints","info-circle","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#useicn3d")+"",e+="",e}setTheme(e){let t,s,i,n,l,r=this.icn3dui;if(r.bNode)return"";r.htmlCls.themecolor=e,"orange"==e?(t="#e78f08",s="#f6a828",i="ui-bg_gloss-wave_35_f6a828_500x100.png",n="ui-icons_ef8c08_256x240.png",l="#eb8f00"):"black"==e?(t="#333333",s="#333333",i="ui-bg_gloss-wave_25_333333_500x100.png",n="ui-icons_222222_256x240.png",l="#222222"):"blue"==e&&(t="#4297d7",s="#5c9ccc",i="ui-bg_gloss-wave_55_5c9ccc_500x100.png",n="ui-icons_228ef1_256x240.png",l="#444"),$(".ui-widget-header").css({border:"1px solid "+t,background:s+' url("https://www.ncbi.nlm.nih.gov/Structure/icn3d/lib/images/'+i+'") 50% 50% repeat-x',color:"#fff","font-weight":"bold"}),$(".ui-button .ui-icon").css({"background-image":"url(https://www.ncbi.nlm.nih.gov/Structure/icn3d/lib/images/"+n+")"}),$(".ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited").css({color:l,"text-decoration":"none"})}setLogWindow(e,t){let s=this.icn3dui;if(s.bNode)return"";let i,n="",l=s.htmlCls.setHtmlCls.getCookie("cmdwindow");return""!=l?(i=void 0!==t?t:parseInt(l),1==i?(s.htmlCls.LOG_HEIGHT=180,s.htmlCls.CMD_HEIGHT=.8*s.htmlCls.LOG_HEIGHT,e||(n+=s.htmlCls.divStr+"cmdlog' style='float:left; margin-top: 5px; width: 100%;'>"),n+=""):(s.htmlCls.LOG_HEIGHT=65,s.htmlCls.CMD_HEIGHT=.8*s.htmlCls.LOG_HEIGHT,e||(n+=s.htmlCls.divStr+"cmdlog' style='float:left; margin-top: 5px; width: 100%;'>"),n+="")):(i=0,s.htmlCls.LOG_HEIGHT=65,s.htmlCls.CMD_HEIGHT=.8*s.htmlCls.LOG_HEIGHT,e||(n+=s.htmlCls.divStr+"cmdlog' style='float:left; margin-top: 5px; width: 100%;'>"),n+=""),e||(n+=""),e&&(s.htmlCls.clickMenuCls.setLogCmd("set cmdwindow "+i,!0),$("#"+s.pre+"cmdlog").html(n)),n}setMenu1(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
    ",t+="",t+="

    File

    ",t+="
    ",t+=this.setMenu1_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu1_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getMenuUrl("mn1_searchstru","https://www.ncbi.nlm.nih.gov/structure","Search Structure "+e.htmlCls.wifiStr,1,1),t+=this.getMenuText("mn1_searchsimilar","Search Similar",void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_vastplus","NCBI VAST+ (PDB Complex)"+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_vast","NCBI VAST (PDB Chain)"+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_foldseek","Foldseek (PDB & AlphaFold)"+e.htmlCls.wifiStr,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn1_retrievebyid","Retrieve by ID",void 0,1,1),t+="
        ",t+=this.getLink("mn1_mmdbafid","PDB/MMDB/AlphaFold IDs"+e.htmlCls.wifiStr,1,2),t+=this.getLink("mn1_mmdbid","NCBI MMDB ID (annotation) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_mmtfid","RCSB MMTF ID (fast) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_pdbid","RCSB PDB ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getMenuText("mn1_afwrap","AlphaFold Structures",void 0,void 0,2),t+="
          ",t+=this.getLink("mn1_afid","UniProt ID "+e.htmlCls.wifiStr,void 0,3),t+=this.getLink("mn1_refseqid","NCBI Protein Accession "+e.htmlCls.wifiStr,void 0,3),t+="
        ",t+=this.getLink("mn1_opmid","OPM PDB ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_mmcifid","RCSB mmCIF ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_cid","PubChem CID "+e.htmlCls.wifiStr,1,2),t+="
      ",t+="",t+=this.getMenuText("mn1_openfile","Open File",void 0,1,1),t+="
        ",t+=this.getLink("mn1_pdbfile_app","PDB Files (appendable)",1,2),t+=this.getLink("mn1_mmciffile","mmCIF File",void 0,2),t+=this.getLink("mn1_mol2file","Mol2 File",void 0,2),t+=this.getLink("mn1_sdffile","SDF File",void 0,2),t+=this.getLink("mn1_xyzfile","XYZ File",void 0,2),t+=this.getLink("mn1_afmapfile","AlphaFold PAE File",void 0,2),t+=this.getLink("mn1_urlfile","URL(CORS) "+e.htmlCls.wifiStr,void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_pngimage","iCn3D PNG Image",1,2),t+=this.getLink("mn1_state","State/Script File",void 0,2),t+=this.getLink("mn1_fixedversion","Share Link in Archived Ver. "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_selection","Selection File",void 0,2),t+=this.getMenuSep(),t+=this.getMenuText("mn1_dsn6wrap","Electron Density(DSN6)",void 0,void 0,2),t+="
          ",t+=this.getLink("mn1_dsn6","Local File",void 0,3),t+=this.getLink("mn1_dsn6url","URL(CORS) "+e.htmlCls.wifiStr,void 0,3),t+="
        ",t+="
      ",t+="",t+=this.getMenuText("mn1_alignwrap","Align",void 0,1,1),t+="
        ",t+=this.getMenuText("mn1_chainalignwrap","Multiple Chains",void 0,1,2),t+="
          ",t+=this.getRadio("mn1_chainalignRad","mn1_chainalign","by Structure Alignment "+e.htmlCls.wifiStr,void 0,1,3),t+=this.getRadio("mn1_chainalignRad","mn1_chainalign2","by Sequence Alignment "+e.htmlCls.wifiStr,void 0,1,3),t+=this.getRadio("mn1_chainalignRad","mn1_chainalign3","Residue by Residue",void 0,void 0,3),t+="
        ",t+="",t+=this.getMenuText("mn1_aligntwostru","Protein Complexes",void 0,void 0,2),t+="
          ",t+=this.getLink("mn1_align","Two PDB Structures "+e.htmlCls.wifiStr,void 0,3),t+=this.getLink("mn1_alignaf","Two AlphaFold Structures "+e.htmlCls.wifiStr,void 0,3),t+="
        ",t+=this.getLink("mn1_blast_rep_id","Sequence to Structure",void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_realignWrap","Realign Selection",void 0,void 0,1),t+="
        ",t+=this.getMenuText("mn2_chainrealignwrap","Multiple Chains",void 0,void 0,2),t+="
          ",t+=this.getRadio("mn2_realign","mn2_realignonstruct","by Structure Alignment "+e.htmlCls.wifiStr,void 0,void 0,3),t+=this.getRadio("mn2_realign","mn2_realignonseqalign","by Sequence Alignment "+e.htmlCls.wifiStr,void 0,void 0,3),t+=this.getRadio("mn2_realign","mn2_realignresbyres","Residue by Residue",void 0,void 0,3),t+="
        ",t+=this.getLink("mn2_realigntwostru","Protein Complexes",void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn1_3dpprint","3D Printing",void 0,1,1),t+="
        ",void 0===e.cfg.cid?(t+=this.getLink("mn1_exportVrmlStab","WRL/VRML(Color, W/ Stab.)",1,2),t+=this.getLink("mn1_exportStlStab","STL(W/ Stabilizers)",1,2),t+=this.getMenuSep(),t+=this.getLink("mn1_exportVrml","WRL/VRML(Color)",void 0,2),t+=this.getLink("mn1_exportStl","STL",void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_stabilizerYes","Add All Stabilizers",void 0,2),t+=this.getLink("mn1_stabilizerNo","Remove All Stabilizers",void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_stabilizerOne","Add One Stabilizer",void 0,2),t+=this.getLink("mn1_stabilizerRmOne","Remove One Stabilizer",void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_thicknessSet","Set Thickness",void 0,2)):(t+=this.getLink("mn1_exportVrml","VRML(Color)",1,2),t+=this.getLink("mn1_exportStl","STL",1,2)),t+="
      ",t+="",t+=this.getMenuText("mn1_savefile","Save File",void 0,1,1),t+="
        ",t+=this.getMenuText("mn1_savepngimage","iCn3D PNG Image",void 0,1,2),t+="
          ",t+=this.getLink("mn1_exportCanvas","Original Size & HTML",1,3),t+=this.getLink("mn1_exportCanvas1","Original Size",void 0,3),t+=this.getLink("mn1_exportCanvas2","2X Large",void 0,3),t+=this.getLink("mn1_exportCanvas4","4X Large",void 0,3),t+=this.getLink("mn1_exportCanvas8","8X Large",void 0,3),t+="
        ",t+="",t+=this.getLink("mn1_exportState","State File",void 0,2),t+=this.getLink("mn1_exportSelections","Selection File",void 0,2),t+=this.getLink("mn1_exportSelDetails","Selection Details",void 0,2),t+=this.getLink("mn1_exportCounts","Residue Counts",void 0,2),t+=this.getLink("mn1_exportPdbRes","PDB",1,2),t+=this.getLink("profixpdb","PDB with Missing Atoms",void 0,2),t+=this.getLink("profixpdbh","PDB with Hydrogens",void 0,2),void 0===e.cfg.cid&&(t+=this.getLink("mn1_exportSecondary","Secondary Structure",void 0,2)),t+="

      • ",t+="
      ",t+="",t+=this.getLink("mn1_sharelink","Share Link "+e.htmlCls.wifiStr,1,1),t+=this.getLink("mn1_replayon","Replay Each Step",void 0,1),t+=this.getMenuSep(),t+=this.getMenuText("mn1_menuwrap","Customize Menus",void 0,1,1),t+="
        ",t+=this.getLink("mn1_menuall","All Menus",1,2),t+=this.getLink("mn1_menusimple","Simple Menus",1,2),t+=this.getMenuSep(),t+=this.getLink("mn1_menupref","Preferences",1,2),t+=this.getLink("mn1_menuloadpref","Load Preferences",1,2),t+="
      ",t+="",t+="

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

    Select

    ",t+="
    ",t+=this.setMenu2_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu2_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getLink("mn2_definedsets","Defined Sets",1,1),t+=this.getLink("mn2_selectall","All",void 0,1),t+=this.getLink("mn2_selectdisplayed","Displayed Set",void 0,1),t+=this.getLink("mn2_aroundsphere","by Distance",1,1),t+=this.getMenuText("mn2_selbyprop","by Property",void 0,void 0,1),t+="
        ",t+=this.getLink("mn2_propPos","Positive",void 0,2),t+=this.getLink("mn2_propNeg","Negative",void 0,2),t+=this.getLink("mn2_propHydro","Hydrophobic",void 0,2),t+=this.getLink("mn2_propPolar","Polar",void 0,2),t+=this.getLink("mn2_propBfactor","B-factor/pLDDT",void 0,2),t+=this.getLink("mn2_propSolAcc","Solvent Accessibility",void 0,2),t+="
      ",t+="",t+=this.getLink("mn2_selectcomplement","Inverse",void 0,1),t+=this.getLink("mn2_selectmainchains","Main Chains",void 0,1),t+=this.getLink("mn2_selectsidechains","Side Chains",void 0,1),t+=this.getLink("mn2_selectmainsidechains","Main & Side Chains",void 0,1),t+=this.getLink("mn2_command","Advanced",void 0,1),void 0===e.cfg.cid?(t+=this.getMenuText("mn2_selon3d","Select on 3D",void 0,1,1),t+="
        ",t+='
      • "Alt"+Click: start selection
      • ',t+='
      • "Ctrl"+Click: union selection
      • ',t+='
      • "Shift"+Click: range Selection
      • ',t+=this.getMenuSep(),t+=this.getRadio("mn2_pk","mn2_pkChain","Chain",void 0,1,2),void 0===e.cfg.mmdbid&&void 0===e.cfg.gi||(t+=this.getRadio("mn2_pk","mn2_pkDomain","3D Domain",void 0,void 0,2)),t+=this.getRadio("mn2_pk","mn2_pkStrand","Strand/Helix",void 0,void 0,2),t+=this.getRadio("mn2_pk","mn2_pkResidue","Residue",!0,1,2),t+=this.getRadio("mn2_pk","mn2_pkYes","Atom",void 0,1,2),t+=this.getRadio("mn2_pk","mn2_pkNo","None",void 0,void 0,2),t+="
      ",t+=""):e.utilsCls.isMobile()?t+="
    • Touch to pick
    • ":t+='
    • Picking with
      "Alt" + Click
    • ',t+=this.getMenuSep(),t+=this.getLink("mn2_saveselection","Save Selection",1,1),t+=this.getLink("clearall","Clear Selection",void 0,1),t+=this.getLink("mn2_saveresidue","Save Res. in Sel.",1,1),t+=this.getMenuSep(),t+=this.getMenuText("mn2_hlcolor","Highlight Color",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn2_hl_clr","mn2_hl_clrYellow","Yellow",!0,void 0,2),t+=this.getRadio("mn2_hl_clr","mn2_hl_clrGreen","Green",void 0,void 0,2),t+=this.getRadio("mn2_hl_clr","mn2_hl_clrRed","Red",void 0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_hlstyle","Highlight Style",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn2_hl_style","mn2_hl_styleOutline","Outline",!0,void 0,2),t+=this.getRadio("mn2_hl_style","mn2_hl_styleObject","3D Objects",void 0,void 0,2),t+="
      ",t+="",t+=this.getLink("toggleHighlight2","Toggle Highlight",1,1),t+="

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

    View

    ",t+="
    ",t+=this.setMenu2b_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu2b_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getLink("mn2_show_selected","View Selection",1,1),t+=this.getLink("mn2_hide_selected","Hide Selection",1,1),t+=this.getLink("mn2_selectedcenter","Zoom in Selection",1,1),t+=this.getLink("mn6_center","Center Selection",1,1),t+=this.getLink("mn2_fullstru","View Full Structure"),t+=this.getLinkWrapper("mn2_alternate",'Alternate(Key "a")',"mn2_alternateWrap",void 0,1),void 0!==e.cfg.opmid?t+=this.getLinkWrapper("togglemem","Toggle Membrane","togglememli",void 0,1):void 0===e.cfg.cid&&(t+=this.getLinkWrapper("togglemem","Toggle Membrane","togglememli",void 0,1,!0)),void 0!==e.cfg.opmid&&(t+=this.getLinkWrapper("adjustmem","Adjust Membrane","adjustmemli",void 0,1),t+=this.getLinkWrapper("selectplane","Select between
      Two X-Y Planes","selectplaneli",void 0,1)),t+=this.getMenuSep(),t+=this.getMenuText("mn2_vrarhints","VR & AR Hints",void 0,1,1),t+="
        ",t+=this.getMenuUrl("vrhint",e.htmlCls.baseUrl+"icn3d/icn3d.html#vr","VR: VR Headsets",1,2),t+=this.getMenuUrl("arhint",e.htmlCls.baseUrl+"icn3d/icn3d.html#ar","AR: Chrome in Android",1,2),t+="
      ",t+="",t+=this.getLink("mn6_sidebyside","Side by Side",1,1),t+=this.getMenuText("mn2_rotate","Rotate",void 0,1,1),t+="
        ",t+=this.getMenuText("mn2_rotate90","Rotate 90°",void 0,void 0,2),t+="
          ",t+=this.getRadio("mn6_rotate90","mn6_rotatex","X-axis(Shift + Key M)",void 0,void 0,2),t+=this.getRadio("mn6_rotate90","mn6_rotatey","Y-axis(Shift + Key J)",void 0,void 0,2),t+=this.getRadio("mn6_rotate90","mn6_rotatez","Z-axis",void 0,void 0,2),t+="
        ",t+="",t+=this.getMenuText("mn2_rotateauto","Auto Rotation",void 0,1,2),t+="
          ",t+=this.getRadio("mn6_rotate","mn6_rotateleft","Rotate Left",void 0,1,3),t+=this.getRadio("mn6_rotate","mn6_rotateright","Rotate Right",void 0,1,3),t+=this.getRadio("mn6_rotate","mn6_rotateup","Rotate Up",void 0,1,3),t+=this.getRadio("mn6_rotate","mn6_rotatedown","Rotate Down",void 0,1,3),t+="
        ",t+="",t+="
      ",t+="",t+=this.getMenuText("mn2_camera","Camera",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_camera","mn6_cameraPers","Perspective",!0,void 0,2),t+=this.getRadio("mn6_camera","mn6_cameraOrth","Orthographic",void 0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_fog","Fog for Selection",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_showfog","mn6_showfogYes","On",void 0,void 0,2),t+=this.getRadio("mn6_showfog","mn6_showfogNo","Off",!0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_slab","Slab for Selection",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_showslab","mn6_showslabYes","On",void 0,void 0,2),t+=this.getRadio("mn6_showslab","mn6_showslabNo","Off",!0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_axes","XYZ-axes",void 0,1),t+="
        ",t+=this.getRadio("mn6_showaxis","mn6_showaxisYes","Original",void 0,void 0,2),t+=this.getRadio("mn6_showaxis","mn6_showaxisSel","Prin. Axes on Sel.",void 0,void 0,2),t+=this.getRadio("mn6_showaxis","mn6_showaxisNo","Hide",!0,void 0,2),t+="
      ",t+="",t+=this.getMenuSep(),t+=this.getMenuText("mn2_resetwrap","Reset",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_reset","reset","All",void 0,1,2),t+=this.getRadio("mn6_reset","mn6_resetOrientation","Orientation",void 0,1,2),t+="
      ",t+="",t+=this.getLink("mn6_back","Undo",void 0,1),t+=this.getLink("mn6_forward","Redo",void 0,1),t+=this.getLink("mn6_fullscreen","Full Screen",void 0,1),t+="

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

    Style

    ",t+="
    ",t+=this.setMenu3_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu3_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";t+="
      ",void 0===e.cfg.cid&&(t+=this.getMenuText("mn3_proteinwrap","Proteins",void 0,1,1),t+="
        ",void 0!==e.cfg.align||void 0!==e.cfg.chainalign?t+=this.getRadio("mn3_proteins","mn3_proteinsRibbon","Ribbon",void 0,1,2):t+=this.getRadio("mn3_proteins","mn3_proteinsRibbon","Ribbon",!0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsStrand","Strand",void 0,void 0,2),t+=this.getRadio("mn3_proteins","mn3_proteinsCylinder","Cylinder and Plate",void 0,void 0,2),t+=this.getRadio("mn3_proteins","mn3_proteinsSchematic","Schematic",void 0,1,2),void 0!==e.cfg.align||void 0!==e.cfg.chainalign?t+=this.getRadio("mn3_proteins","mn3_proteinsCalpha","C Alpha Trace",!0,1,2):t+=this.getRadio("mn3_proteins","mn3_proteinsCalpha","C Alpha Trace",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsBackbone","Backbone",void 0,void 0,2),t+=this.getRadio("mn3_proteins","mn3_proteinsBfactor","B-factor Tube",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsLines","Lines",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsStick","Stick",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsBallstick","Ball and Stick",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_sidecwrap","Side Chains",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_sidec","mn3_sidecLines","Lines",void 0,1,2),t+=this.getRadio("mn3_sidec","mn3_sidecStick","Stick",void 0,1,2),t+=this.getRadio("mn3_sidec","mn3_sidecBallstick","Ball and Stick",void 0,1,2),t+=this.getRadio("mn3_sidec","mn3_sidecSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_sidec","mn3_sidecNo","Hide",!0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_nuclwrap","Nucleotides",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_nucl","mn3_nuclCartoon","Cartoon",!0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclPhos","O3' Trace",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclBackbone","Backbone",void 0,void 0,2),t+=this.getRadio("mn3_nucl","mn3_nuclSchematic","Schematic",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclLines","Lines",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclStick","Stick",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclBallstick","Ball and Stick",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_ntbasewrap","Nucl. Bases",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_ntbase","mn3_ntbaseLines","Lines",void 0,1,2),t+=this.getRadio("mn3_ntbase","mn3_ntbaseStick","Stick",void 0,1,2),t+=this.getRadio("mn3_ntbase","mn3_ntbaseBallstick","Ball and Stick",void 0,1,2),t+=this.getRadio("mn3_ntbase","mn3_ntbaseSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_ntbase","mn3_ntbaseNo","Hide",!0,1,2),t+="
      ",t+=""),t+=this.getMenuText("mn3_ligwrap","Chemicals",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_lig","mn3_ligLines","Lines",void 0,1,2),void 0===e.cfg.cid?(t+=this.getRadio("mn3_lig","mn3_ligStick","Stick",!0,1,2),t+=this.getRadio("mn3_lig","mn3_ligBallstick","Ball and Stick",void 0,1,2)):(t+=this.getRadio("mn3_lig","mn3_ligStick","Stick",void 0,1,2),t+=this.getRadio("mn3_lig","mn3_ligBallstick","BalHydrogensl and Stick",!0,1,2)),t+=this.getRadio("mn3_lig","mn3_ligSchematic","Schematic",void 0,1,2),t+=this.getRadio("mn3_lig","mn3_ligSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_lig","mn3_ligNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_hydrogenswrap","Hydrogens",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_hydrogens","mn3_hydrogensYes","Show",!0,1,2),t+=this.getRadio("mn3_hydrogens","mn3_hydrogensNo","Hide",void 0,1,2),t+="
      ",t+="",void 0===e.cfg.cid&&(t+=this.getMenuText("mn3_glycanwrap","Glycans",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn3_glycansCart","mn3_glycansCartYes","Show Cartoon",void 0,void 0,2),t+=this.getRadio("mn3_glycansCart","mn3_glycansCartNo","Hide Cartoon",!0,void 0,2),t+="
      ",t+=""),t+=this.getMenuText("mn3_ionswrap","Ions",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_ions","mn3_ionsSphere","Sphere",!0,1,2),t+=this.getRadio("mn3_ions","mn3_ionsDot","Dot",void 0,1,2),t+=this.getRadio("mn3_ions","mn3_ionsNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_waterwrap","Water",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_water","mn3_waterSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_water","mn3_waterDot","Dot",void 0,1,2),t+=this.getRadio("mn3_water","mn3_waterNo","Hide",!0,1,2),t+="
      ",t+="",t+=this.getLink("mn3_setThickness","Preferences",void 0,1),t+=this.getMenuSep(),t+=this.getLink("mn3_styleSave","Save Style",void 0,2),t+=this.getLink("mn3_styleApplySave","Apply Saved Style",void 0,2),t+=this.getMenuSep(),t+=this.getMenuText("mn5_surfacewrap","Surface Type",void 0,1,1),t+="
        ",t+=this.getRadio("mn5_surface","mn5_surfaceVDW","Van der Waals",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceVDWContext","VDW with Context",void 0,void 0,2),t+=this.getRadio("mn5_surface","mn5_surfaceMolecular","Molecular Surface",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceMolecularContext","MS with Context",void 0,void 0,2),t+=this.getRadio("mn5_surface","mn5_surfaceSAS","Solvent Accessible",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceSASContext","SA with Context",void 0,void 0,2),t+="
      ",t+="",t+=this.getLink("mn5_surfaceNo","Remove Surface",1,1),t+=this.getMenuText("mn5_surfaceop","Surface Opacity",void 0,1,1),t+="
        ",t+=this.getMenuText("mn5_surfaceopfast","Fast Transparency",void 0,1,2),t+="
          ",t+=this.getRadio("mn5_opacity","mn5_opacity10","1.0",!0,1,3);for(let e=9;e>0;--e)t+=this.getRadio("mn5_opacity","mn5_opacity0"+e,"0."+e,1,3);t+="
        ",t+="",t+=this.getMenuText("mn5_surfaceopslow","Slow Transparency",void 0,void 0,2),t+="
          ",t+=this.getRadio("mn5_opacityslow","mn5_opacityslow10","1.0",!0,void 0,3);for(let e=9;e>0;--e)t+=this.getRadio("mn5_opacityslow","mn5_opacityslow0"+e,"0."+e,void 0,void 0,3);return t+="
        ",t+="",t+="
      ",t+=this.getMenuText("mn5_wireframewrap","Surface Wireframe",void 0,1,1),t+="
        ",t+=this.getRadio("mn5_wireframe","mn5_wireframeYes","Yes",void 0,1,2),t+=this.getRadio("mn5_wireframe","mn5_wireframeNo","No",!0,1,2),t+="
      ",t+="",t+=this.getMenuSep(),t+=this.getLink("mn5_cartoonshape","Cartoon for a Set",void 0,1),t+=this.getLink("mn5_linebtwsets","Line btw. Two Sets",void 0,1),void 0===e.cfg.cid&&void 0===e.cfg.align&&void 0===e.cfg.chainalign&&void 0===e.cfg.mmdbaf&&(t+=this.getMenuSep(),t+=this.getLinkWrapper2("mn5_map","Electron Density","mapWrapper1",void 0,1),t+="
        ",t+=this.getLink("mn5_elecmap2fofc","2Fo-Fc Map",void 0,2),t+=this.getLink("mn5_elecmapfofc","Fo-Fc Map",void 0,2),t+=this.getLinkWrapper("mn5_elecmapNo","Remove Map","mapWrapper2",void 0,2),t+="
      ",t+="",t+=this.getLinkWrapper2("mn5_map3","Map Wireframe","mapWrapper3",void 0,1),t+="
        ",t+=this.getRadio("mn5_mapwireframe","mn5_mapwireframeYes","Yes",!0,void 0,2),t+=this.getRadio("mn5_mapwireframe","mn5_mapwireframeNo","No",void 0,void 0,2),t+="
      ",t+="",void 0===e.cfg.mmtfid&&(t+=this.getLinkWrapper("mn5_emmap","EM Density Map","emmapWrapper1",void 0,1),t+=this.getLinkWrapper("mn5_emmapNo","Remove EM Map","emmapWrapper2",void 0,1),t+=this.getLinkWrapper2("mn5_emmap3","EM Map Wireframe","emmapWrapper3",void 0,1),t+="
        ",t+=this.getRadio("mn5_emmapwireframe","mn5_emmapwireframeYes","Yes",!0,void 0,2),t+=this.getRadio("mn5_emmapwireframe","mn5_emmapwireframeNo","No",void 0,void 0,2),t+="
      ",t+="")),t+=this.getMenuSep(),t+=this.getMenuText("mn6_bkgdwrap","Background",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_bkgd","mn6_bkgdTransparent","Transparent",void 0,1,2),t+=this.getRadio("mn6_bkgd","mn6_bkgdBlack","Black",!0,1,2),t+=this.getRadio("mn6_bkgd","mn6_bkgdGrey","Gray",void 0,1,2),t+=this.getRadio("mn6_bkgd","mn6_bkgdWhite","White",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn6_themewrap","Dialog Color",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_theme","mn6_themeBlue","Blue",!0,void 0,2),t+=this.getRadio("mn6_theme","mn6_themeOrange","Orange",void 0,void 0,2),t+=this.getRadio("mn6_theme","mn6_themeBlack","Black",void 0,void 0,2),t+="
      ",t+="",t+="

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

    Color

    ",t+="
    ",t+=this.setMenu4_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu4_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getMenuText("mn4_clrwrap","Unicolor","icn3d-menupd",1,1),t+="
        ",t+=this.getMenuText("uniclrRedwrap","Red",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrRed1","Red","F00",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed2","Indian Red","CD5C5C",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed3","Light Coral","F08080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed4","Salmon","FA8072",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed5","Dark Salmon","E9967A",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed6","Light Salmon","FFA07A",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed7","Crimson","DC143C",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed8","Fire Brick","B22222",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed9","Dark Red","8B0000",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrPinkwrap","Pink",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrPink1","Pink","FFC0CB",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink2","Light Pink","FFB6C1",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink3","Hot Pink","FF69B4",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink4","Deep Pink","FF1493",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink5","Medium Violet Red","C71585",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink6","Pale Violet Red","DB7093",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrOrangewrap","Orange",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrOran1","Orange","FFA500",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran2","Dark Orange","FF8C00",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran3","Orange Red","FF4500",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran4","Tomato","FF6347",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran5","Coral","FF7F50",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran6","Light Salmon","FFA07A",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrYellowwrap","Yellow",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrYllw1","Yellow","FF0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw2","Gold","FFD700",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw3","Light Yellow","FFFFE0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw4","Lemon Chiffon","FFFACD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw5","Light Golden Rod","FAFAD2",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw6","Papaya Whip","FFEFD5",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw7","Moccasin","FFE4B5",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw8","Peach Puff","FFDAB9",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw9","Pale Golden Rod","EEE8AA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw10","Khaki","F0E68C",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw11","Dark Khaki","BDB76B",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrMagentawrap","Magenta",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrMgnt1","Magenta","F0F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt2","Orchid","DA70D6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt3","Violet","EE82EE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt4","Plum","DDA0DD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt5","Thistle","D8BFD8",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt6","Lavender","E6E6FA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt7","Medium Orchid","BA55D3",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt8","Medium Purple","9370DB",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt9","Rebecca Purple","663399",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt10","Blue Violet","8A2BE2",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt11","Dark Violet","9400D3",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt12","Dark Orchid","9932CC",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt13","Dark Magenta","8B008B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt14","Purple","800080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt15","Indigo","4B0082",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt16","Slat Blue","6A5ACD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt17","Dark Slate Blue","483D8B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt18","Medium Slat Blue","6A5ACD",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrGreenwrap","Green",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrGrn1","Green","0F0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn2","Dark Green","006400",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn3","Yellow Green","9ACD32",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn4","Olive Drab","6B8E23",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn5","Olive","808000",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn6","Dark Olive Green","556B2F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn7","Medium Aquamarine","66CDAA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn8","Dark Sea Green","8FBC8B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn9","Lignt Sea Green","20B2AA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn10","Dark Cyan","008B8B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn11","Teal","008080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn12","Forest Green","228B22",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn13","Sea Green","2E8B57",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn14","Medium Sea Green","3CB371",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn15","Spring Green","00FF7F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn16","Medium Spring","00FA9A",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn17","Light Green","90EE90",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn18","Pale Green","98FB98",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn19","Lime Green","32CD32",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn20","Lawn Green","7CFC00",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn21","Chartreuse","7FFF00",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn22","Green Yellow","ADFF2F",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrCyanwrap","Cyan",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrCyan1","Cyan","0FF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan2","Light Cyan","E0FFFF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan3","Pale Turquoise","AFEEEE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan4","Aquamarine","7FFFD4",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan5","Turquoise","40E0D0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan6","Medium Turquoise","48D1CC",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan7","Dark Turquoise","00CED1",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrBluewrap","Blue",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrBlue1","Blue","00F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue2","Medium Blue","0000CD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue3","Dark Blue","00008B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue4","Navy","000080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue5","Midnight Blue","191970",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue6","Royal Blue","4169E1",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue7","Medium Slate Blue","7B68EE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue8","Corn Flower Blue","6495ED",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue9","Dodger Blue","1E90FF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue10","Deep Sky Blue","00BFFF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue11","Light Sky Blue","87CEFA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue12","Sky Blue","87CEEB",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue13","Light Blue","ADD8E6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue14","Powder Blue","B0E0E6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue15","Light Steel Blue","B0C4DE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue16","Steel Blue","4682B4",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue17","Cadet Blue","5F9EA0",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrBrownwrap","Brown",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrBrown1","Brown","A52A2A",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown2","Maroon","800000",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown3","Sienna","A0522D",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown4","Saddle Brown","8B4513",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown5","Chocolate","D2691E",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown6","Peru","CD853F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown7","Dark Golden Rod","B8860B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown8","Golden Rod","DAA520",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown9","Sandy Brown","F4A460",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown10","Rosy Brown","BC8F8F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown11","Tan","D2B48C",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown12","Burlywood","DEB887",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown13","Wheat","F5DEB3",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown14","Navajo White","FFDEAD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown15","Bisque","FFE4C4",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown16","Blanched Almond","FFEBCD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown17","Corn Silk","FFF8DC",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrWhitewrap","White",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrWhite1","White","FFF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite2","Snow","FFFAFA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite3","Honey Dew","F0FFF0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite4","Mint Cream","F5FFFA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite5","Azure","F0FFFF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite6","Alice Blue","F0F8FF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite7","Ghost White","F8F8FF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite8","White Smoke","F5F5F5",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite9","Sea Shell","FFF5EE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite10","Beige","F5F5DC",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite11","Old Lace","FDF5E6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite12","Floral White","FFFAF0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite13","Ivory","FFFFF0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite14","Antique White","FAEBD7",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite15","Linen","FAF0E6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite16","Lavenderblush","FFF0F5",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite17","Misty Rose","FFE4E1",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrGraywrap","Gray",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrGray1","Gray","808080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray2","Dim Gray","696969",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray3","Light Slate Gray","778899",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray4","Slate Gray","708090",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray5","Dark Slate Gray","2F4F4F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray6","Black","000000",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray7","Dark Gray","A9A9A9",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray8","Silver","C0C0C0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray9","Light Gray","D3D3D3",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray10","Gainsboro","DCDCDC",void 0,1,3),t+="
        ",t+="
      ",t+=this.getRadio("mn4_clr","mn4_clrCustom","Color Picker",void 0,void 0,1),t+=this.getMenuSep(),void 0===e.cfg.cid?(t+=this.getMenuText("mn4_clrRainbowwrap","Rainbow (R-V)","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrRainbow","for Selection",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrRainbowChain","for Chains",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrRainbowSets","for Sets",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrRainbowAcrossSets","across Sets",void 0,void 0,2),t+="
      ",t+=this.getMenuText("mn4_clrSpectrumwrap","Spectrum (V-R)","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrSpectrum","for Selection",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSpectrumChain","for Chains",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSpectrumSets","for Sets",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrSpectrumAcrossSets","across Sets",void 0,void 0,2),t+="
      ",t+=this.getMenuText("mn4_clrSSwrap","Secondary","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrSSGreen","Sheet in Green",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSSYellow","Sheet in Yellow",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSSSpectrum","Spectrum",void 0,void 0,2),t+="
      ",t+=this.getRadio("mn4_clr","mn4_clrCharge","Charge",void 0,1,1),t+=this.getMenuText("mn4_hydrophobicwrap","Hydrophobicity","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrNormalizedHP","Normalized",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrHydrophobic","Wimley-White",void 0,void 0,2),t+="
      ",t+=this.getMenuText("mn4_clrBfactorwrap","B-factor","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrBfactor","Original",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrBfactorNorm","Percentile",void 0,1,2),t+="
      ",t+=this.getRadio("mn4_clr","mn4_clrArea",'Solvent
      Accessibility',void 0,void 0,1),t+=this.getRadio("mn4_clr","mn4_clrStructure","Structure",void 0,1,1),void 0!==e.cfg.align||void 0!==e.cfg.chainalign||void 0!==e.cfg.blast_rep_id?t+=this.getRadio("mn4_clr","mn4_clrChain","Chain",void 0,1,1):t+=this.getRadio("mn4_clr","mn4_clrChain","Chain",!0,1,1),t+=this.getRadio("mn4_clr","mn4_clrdomain","3D Domain",void 0,void 0,1),void 0===e.cfg.cid&&(t+=this.getMenuText("mn4_clrsetswrap","Defined Sets","icn3d-menupd",void 0,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrsets",'Rainbow for Selected Sets
        in "Analysis > Defined Sets"',void 0,void 0,2),t+="
      ",t+=""),t+=this.getMenuText("mn4_clrResiduewrap","Residue","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrResidue","Default",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrResidueCustom","Custom",void 0,void 0,2),t+="
      ",t+=this.getRadio("mn4_clr","mn4_clrAtom","Atom",void 0,1,1),void 0!==e.cfg.align||void 0!==e.cfg.chainalign?(t+=this.getRadio("mn4_clr","mn4_clrIdentity","Identity",!0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrConserved","Conservation",void 0,void 0,2)):void 0!==e.cfg.blast_rep_id?(t+=this.getRadio("mn4_clr","mn4_clrIdentity","Identity",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrConserved","Conservation",!0,void 0,2)):(t+=this.getRadio("mn4_clr","mn4_clrIdentity","Identity",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrConserved","Conservation",void 0,void 0,2)),t+=this.getRadio("mn4_clr","mn4_clrConfidence",'AlphaFold
      Confidence',void 0,1,1)):t+=this.getRadio("mn4_clr","mn4_clrAtom","Atom",!0,1,1),t+=this.getMenuSep(),t+=this.getLink("mn4_clrSave","Save Color",void 0,1),t+=this.getLink("mn4_clrApplySave","Apply Saved Color",void 0,1),t+="

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

     Analysis

    ",t+="
    ",t+=this.setMenu5_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu5_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";t+="
      ",void 0===e.cfg.cid&&(t+=this.getLink("mn6_selectannotations","Seq. & Annotations "+e.htmlCls.wifiStr,1,1),t+=this.getLink("mn2_alignment","Aligned Seq. "+e.htmlCls.wifiStr,void 0,1),void 0===e.cfg.mmdbid&&void 0===e.cfg.gi&&void 0===e.cfg.blast_rep_id&&void 0===e.cfg.align&&void 0===e.cfg.chainalign||(t+=this.getLink("mn2_2ddgm","2D Diagram "+e.htmlCls.wifiStr,1,1)),t+=this.getMenuText("2dctnwrap","2D Cartoon",void 0,void 0,1),t+="
        ",t+=this.getLink("2dctn_chain","Chain Level",void 0,2),t+=this.getLink("2dctn_domain","Domain Level",void 0,2),t+=this.getLink("2dctn_secondary","Helix/Sheet Level",void 0,2),t+="
      ",t+="",t+=this.getLink("definedsets2","Defined Sets",1,1),t+=this.getMenuSep(),t+=this.getLink("mn6_hbondsYes","Interactions",1,1),t+=this.getMenuText("mn1_window","Bring to Front",void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_window_table","Interaction Table",void 0,2),t+=this.getLink("mn1_window_linegraph","2D Interaction Network",void 0,2),t+=this.getLink("mn1_window_scatterplot","2D Interaction Map",void 0,2),t+=this.getLink("mn1_window_graph","2D Graph(Force-Directed)",void 0,2),t+="
      ",t+="",t+=this.getLink("mn6_contactmap","Contact Map",void 0,1),e.cfg.notebook||(t+=this.getLink("mn1_mutation","Mutation "+e.htmlCls.wifiStr,1,1))),e.cfg.notebook||e.cfg.hidelicense||(t+=this.getMenuText("mn1_delphiwrap","DelPhi Potential",void 0,1,1),t+="
        ",t+=this.getLink("mn1_delphi","DelPhi Potential "+e.htmlCls.licenseStr,1,2),t+=this.getMenuText("mn1_phiwrap","Load PQR/Phi",void 0,void 0,2),t+="
          ",t+=this.getLink("mn1_phi","Local PQR/Phi/Cube File",void 0,3),t+=this.getLink("mn1_phiurl","URL PQR/Phi/Cube File",void 0,3),t+="
        ",t+="",t+=this.getLink("delphipqr","Download PQR",void 0,2),t+="
      ",t+=""),t+=this.getMenuSep(),t+=this.getMenuText("mn6_distancewrap","Distance",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_distance","mn6_distanceYes","between Two Atoms",void 0,1,2),t+=this.getRadio("mn6_distance","mn6_distTwoSets","between Two Sets",void 0,void 0,2),t+=this.getRadio("mn6_distance","mn6_distManySets","Among Many Sets",void 0,void 0,2),t+=this.getRadio("mn6_distance","mn6_distanceNo","Hide",!0,1,2),t+="
      ",t+="",t+=this.getLink("mn6_area","Surface Area",1,1),t+=this.getMenuText("mn6_addlabelwrap","Label",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_addlabel","mn6_addlabelYes","by Picking Atoms",void 0,void 0,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelSelection","per Selection",void 0,void 0,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelAtoms","per Atom",void 0,void 0,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelElements","per Atom Element",void 0,1,2),void 0===e.cfg.cid&&(t+=this.getRadio("mn6_addlabel","mn6_addlabelResidues","per Residue",void 0,1,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelResnum","per Residue & Number",void 0,1,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelChains","per Chain",void 0,void 0,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelTermini","N- & C-Termini",void 0,1,2)),t+=this.getMenuSep(),t+=this.getRadio("mn6_addlabel","mn6_labelColor","Change Label Color",void 0,1,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelNo","Remove",!0,1,2),t+="
      ",t+="",t+=this.getMenuText("labelscalewrap","Label Scale",void 0,1,1),t+="
        ";for(let e=1;e<=4;++e){let s=2*e;t+=this.getRadio("mn6_labelscale","mn6_labelscale0"+s,"0."+s,void 0,1,2)}for(let e=1;e<=5;++e)t+=1==e?this.getRadio("mn6_labelscale","mn6_labelscale"+e+"0",e+".0",!0,1,2):this.getRadio("mn6_labelscale","mn6_labelscale"+e+"0",e+".0",void 0,1,2);if(t+="
      ",t+="",t+=this.getMenuSep(),void 0===e.cfg.cid){t+=this.getMenuText("mn6_chemicalbindingwrap","Chem. Binding",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_chemicalbinding","mn6_chemicalbindingshow","Show",void 0,void 0,2),t+=this.getRadio("mn6_chemicalbinding","mn6_chemicalbindinghide","Hide",!0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn6_ssbondswrap","Disulfide Bonds",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_ssbonds","mn6_ssbondsYes","Show",!0,1,2),t+=this.getRadio("mn6_ssbonds","mn6_ssbondsExport","Export Pairs",void 0,void 0,2),t+=this.getRadio("mn6_ssbonds","mn6_ssbondsNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn6_clbondswrap","Cross-Linkages",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_clbonds","mn6_clbondsYes","Show",!0,void 0,2),t+=this.getRadio("mn6_clbonds","mn6_clbondsExport","Export Pairs",void 0,void 0,2),t+=this.getRadio("mn6_clbonds","mn6_clbondsNo","Hide",void 0,void 0,2),t+="
      ",t+="";let s=void 0!==e.cfg.mmtfid||void 0!==e.cfg.pdbid||void 0!==e.cfg.opmid||void 0!==e.cfg.mmcifid||void 0!==e.cfg.mmdbid||void 0!==e.cfg.mmdbafid||void 0!==e.cfg.gi||void 0!==e.cfg.blast_rep_id;s&&(t+=this.getMenuText("assemblyWrapper","Assembly",void 0,1,1),t+="
        ",e.cfg.bu?(t+=this.getRadio("mn6_assembly","mn6_assemblyYes","Biological Assembly",!0,1,2),t+=this.getRadio("mn6_assembly","mn6_assemblyNo","Asymmetric Unit",void 0,1,2)):(t+=this.getRadio("mn6_assembly","mn6_assemblyYes","Biological Assembly",void 0,1,2),t+=this.getRadio("mn6_assembly","mn6_assemblyNo","Asymmetric Unit",!0,1,2)),t+="
      ",t+=""),t+=this.getMenuText("mn6_symmetrywrap","Symmetry",void 0,void 0,1),t+="
        ",s&&(t+=this.getLink("mn6_symmetry","from PDB(precalculated) "+e.htmlCls.wifiStr,void 0,2)),t+=this.getLink("mn6_symd","from SymD(Dynamic) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn6_clear_sym","Clear SymD Symmetry",void 0,2),t+=this.getLink("mn6_axes_only","Show Axes Only",void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn6_igrefwrap","Ref. Number",void 0,void 0,1),t+="
        ",t+=this.getLink("mn6_customref","Custom Ref. Number",void 0,2),t+="
      ",t+="",t+=this.getMenuSep()}return t+=this.getLink("mn6_yournote","Window Title",void 0,1),void 0!==e.cfg.cid?(t+=this.getMenuText("mn1_linkwrap","Links",void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_link_structure","Compound Summary "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_vast","Similar Compounds "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_bind","Structures Bound "+e.htmlCls.wifiStr,void 0,2),t+="
      ",t+=""):(t+=this.getMenuText("mn1_linkwrap","Links",void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_link_structure","Structure Summary "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_vast","Similar Structures "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_pubmed","Literature "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_protein","Protein "+e.htmlCls.wifiStr,void 0,2),t+="
      ",t+=""),t+="

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

    Help

    ",t+="
    ",t+=this.setMenu6_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu6_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getMenuUrl("abouticn3d",e.htmlCls.baseUrl+"icn3d/icn3d.html#about","About iCn3D "+e.REVISION+"",1,1),t+=this.getMenuUrl("gallery",e.htmlCls.baseUrl+"icn3d/icn3d.html#gallery","Live Gallery "+e.htmlCls.wifiStr,1,1),t+=this.getMenuUrl("video",e.htmlCls.baseUrl+"icn3d/icn3d.html#videos","iCn3D Videos",1,1),t+=this.getMenuText("mn6_faq","FAQ",void 0,1,1),t+="
        ",t+=this.getMenuUrl("faq_viewstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#viewstru","View structure",1,2),t+=this.getMenuUrl("faq_tfstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#tfstru","Transform Structure",1,2),t+=this.getMenuUrl("faq_selsubset",e.htmlCls.baseUrl+"icn3d/icn3d.html#selsubset","Select Subsets",1,2),t+=this.getMenuUrl("faq_stylecolor",e.htmlCls.baseUrl+"icn3d/icn3d.html#changestylecolor","Change Style/Color",1,2),t+=this.getMenuUrl("faq_savework",e.htmlCls.baseUrl+"icn3d/icn3d.html#saveview","Save Work",1,2),t+=this.getMenuUrl("faq_showanno",e.htmlCls.baseUrl+"icn3d/icn3d.html#showanno","Show Annotations",1,2),t+=this.getMenuUrl("faq_exportanno",e.htmlCls.baseUrl+"icn3d/icn3d.html#exportanno","Export Annotations",1,2),t+=this.getMenuUrl("faq_interanal",e.htmlCls.baseUrl+"icn3d/icn3d.html#interanalysis","Interaction Analysis",1,2),t+=this.getMenuUrl("faq_mutanal",e.htmlCls.baseUrl+"icn3d/icn3d.html#mutationanalysis","Mutation Analysis",1,2),t+=this.getMenuUrl("faq_elecpot",e.htmlCls.baseUrl+"icn3d/icn3d.html#elecpot","Electrostatic Pot.",1,2),t+=this.getMenuUrl("faq_simipdb",e.htmlCls.baseUrl+"icn3d/icn3d.html#simivast","Similar PDB",1,2),t+=this.getMenuUrl("faq_simialphapdb",e.htmlCls.baseUrl+"icn3d/icn3d.html#simifoldseek","Similar AlphaFold/PDB",1,2),t+=this.getMenuUrl("faq_alnstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#alignmul","Align Multiple Structures",1,2),t+=this.getMenuUrl("faq_batchanal",e.htmlCls.baseUrl+"icn3d/icn3d.html#batchanalysis","Batch Analysis",1,2),t+=this.getMenuUrl("faq_embedicn3d",e.htmlCls.baseUrl+"icn3d/icn3d.html#embedicn3d","Embed iCn3D",1,2),t+="
      ",t+="",t+=this.getMenuUrl("citing",e.htmlCls.baseUrl+"icn3d/icn3d.html#citing","Citing iCn3D",void 0,1),t+=this.getMenuText("mn6_source","Source Code",void 0,1,1),t+="
        ",t+=this.getMenuUrl("github","https://github.com/ncbi/icn3d","GitHub (browser) "+e.htmlCls.wifiStr,1,2),t+=this.getMenuUrl("npm","https://www.npmjs.com/package/icn3d","npm (Node.js) "+e.htmlCls.wifiStr,1,2),t+=this.getMenuUrl("notebook","https://pypi.org/project/icn3dpy","Jupyter Notebook "+e.htmlCls.wifiStr,1,2),t+="
      ",t+="",t+=this.getMenuText("mn6_develop","Develop",void 0,void 0,1),t+="
        ",t+=this.getMenuUrl("dev_embedicn3d2",e.htmlCls.baseUrl+"icn3d/icn3d.html#HowToUse","Embed iCn3D",void 0,2),t+=this.getMenuUrl("dev_urlpara",e.htmlCls.baseUrl+"icn3d/icn3d.html#parameters","URL Parameters",void 0,2),t+=this.getMenuUrl("dev_command",e.htmlCls.baseUrl+"icn3d/icn3d.html#commands","Commands",void 0,2),t+=this.getMenuUrl("dev_datastru",e.htmlCls.baseUrl+"icn3d/icn3d.html#datastructure","Data Structure",void 0,2),t+=this.getMenuUrl("dev_classstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#classstructure","Class Structure",void 0,2),t+=this.getMenuUrl("dev_addclass",e.htmlCls.baseUrl+"icn3d/icn3d.html#addclass","Add New Classes",void 0,2),t+=this.getMenuUrl("dev_modfunc",e.htmlCls.baseUrl+"icn3d/icn3d.html#modifyfunction","Modify Functions",void 0,2),t+=this.getMenuUrl("dev_restful",e.htmlCls.baseUrl+"icn3d/icn3d.html#restfulapi","RESTful APIs",void 0,2),t+=this.getMenuUrl("dev_contributor",e.htmlCls.baseUrl+"icn3d/icn3d.html#contributors","iCn3D Contributors",void 0,2),t+="
      ",t+="",t+=this.getMenuUrl("helpdoc",e.htmlCls.baseUrl+"icn3d/docs/icn3d_help.html","Help Doc "+e.htmlCls.wifiStr,1,1),t+=this.getMenuSep(),t+=this.getMenuText("mn6_tfhint","Transform Hints",void 0,1,1),t+="
        ",t+=this.getMenuText("mn6_rotate","Rotate",void 0,1,2),t+="
          ",t+="
        • Left Mouse (Click & Drag)
        • ",t+="
        • Key l: Left
        • ",t+="
        • Key j: Right
        • ",t+="
        • Key i: Up
        • ",t+="
        • Key m: Down
        • ",t+="
        • Shift + Key l: Left 90°
        • ",t+="
        • Shift + Key j: Right 90°
        • ",t+="
        • Shift + Key i: Up 90°
        • ",t+="
        • Shift + Key m: Down 90°
        • ",t+="
        ",t+="",t+=this.getMenuText("mn6_zoom","Zoom",void 0,1,2),t+="
          ",t+="
        • Middle Mouse
          (Pinch & Spread)
        • ",t+="
        • Key z: Zoom in
        • ",t+="
        • Key x: Zoom out
        • ",t+="
        ",t+="",t+=this.getMenuText("mn6_translate","Translate",void 0,1,2),t+="
          ",t+="
        • Right Mouse
          (Two Finger Click & Drag)
        • ",t+="
        ",t+="",t+="
      ",t+="",t+=this.getMenuUrl("selhints",e.htmlCls.baseUrl+"icn3d/icn3d.html#selsubset","Selection Hints",void 0,1),t+=this.getMenuUrl("helpdesk","https://support.nlm.nih.gov/support/create-case/","Write to Help Desk",1,1),t+="

    • ",t+="
    ",t}hideMenu(){let e=this.icn3dui;e.bNode||(void 0!==$("#"+e.pre+"mnlist")[0]&&($("#"+e.pre+"mnlist")[0].style.display="none"),void 0!==$("#"+e.pre+"mnLogSection")[0]&&($("#"+e.pre+"mnLogSection")[0].style.display="none"),void 0!==$("#"+e.pre+"cmdlog")[0]&&($("#"+e.pre+"cmdlog")[0].style.display="none"),$("#"+e.pre+"title")[0].style.margin="10px 0 0 10px")}showMenu(){let e=this.icn3dui;e.bNode||(void 0!==$("#"+e.pre+"mnlist")[0]&&($("#"+e.pre+"mnlist")[0].style.display="block"),void 0!==$("#"+e.pre+"mnLogSection")[0]&&($("#"+e.pre+"mnLogSection")[0].style.display="block"),void 0!==$("#"+e.pre+"cmdlog")[0]&&($("#"+e.pre+"cmdlog")[0].style.display="block"))}}class c{constructor(e){this.icn3dui=e}openDlg(e,t){let s=this.icn3dui;s.icn3d,s.bNode||(e=s.pre+e,s.cfg.notebook?this.openDlgNotebook(e,t):this.openDlgRegular(e,t),s.htmlCls.themecolor||(s.htmlCls.themecolor="blue"),s.htmlCls.setMenuCls.setTheme(s.htmlCls.themecolor))}addSaveButton(e){let t=this.icn3dui;t.icn3d,t.bNode||void 0!==this.dialogHashSave&&this.dialogHashSave.hasOwnProperty(e)||($("#"+e).parent().children(".ui-dialog-titlebar").append("
    "),void 0===this.dialogHashSave&&(this.dialogHashSave={}),this.dialogHashSave[e]=1)}addHideButton(e){let t=this.icn3dui;t.icn3d,t.bNode||void 0!==this.dialogHashHide&&this.dialogHashHide.hasOwnProperty(e)||($("#"+e).parent().children(".ui-dialog-titlebar").append("
    "),void 0===this.dialogHashHide&&(this.dialogHashHide={}),this.dialogHashHide[e]=1)}getDialogStatus(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t={},s={},i=$("#"+e.pre+"dl_selectannotations").hasClass("ui-dialog-content"),n=$("#"+e.pre+"dl_graph").hasClass("ui-dialog-content"),l=$("#"+e.pre+"dl_linegraph").hasClass("ui-dialog-content"),r=$("#"+e.pre+"dl_scatterplot").hasClass("ui-dialog-content"),o=$("#"+e.pre+"dl_contactmap").hasClass("ui-dialog-content"),a=$("#"+e.pre+"dl_alignerrormap").hasClass("ui-dialog-content"),d=$("#"+e.pre+"dl_interactionsorted").hasClass("ui-dialog-content"),c=$("#"+e.pre+"dl_alignment").hasClass("ui-dialog-content"),h=$("#"+e.pre+"dl_2ddgm").hasClass("ui-dialog-content"),p=$("#"+e.pre+"dl_2dctn").hasClass("ui-dialog-content"),m=$("#"+e.pre+"dl_definedsets").hasClass("ui-dialog-content");return t.bSelectannotationsInit2=!1,t.bGraph2=!1,t.bLineGraph2=!1,t.bScatterplot2=!1,t.bTable2=!1,t.bAlignmentInit2=!1,t.bTwoddgmInit2=!1,t.bTwodctnInit2=!1,t.bSetsInit2=!1,s.dl_selectannotations="bSelectannotationsInit2",s.dl_graph="bGraph2",s.dl_linegraph="bLineGraph2",s.dl_scatterplot="bScatterplot2",s.dl_contactmap="bContactmap2",s.dl_alignerrormap="bAlignerrormap2",s.dl_interactionsorted="bTable2",s.dl_alignment="bAlignmentInit2",s.dl_2ddgm="bTwoddgmInit2",s.dl_2dctn="bTwodctnInit2",s.dl_definedsets="bSetsInit2",i&&(t.bSelectannotationsInit2=$("#"+e.pre+"dl_selectannotations").dialog("isOpen")),n&&(t.bGraph2=$("#"+e.pre+"dl_graph").dialog("isOpen")),l&&(t.bLineGraph2=$("#"+e.pre+"dl_linegraph").dialog("isOpen")),r&&(t.bScatterplot2=$("#"+e.pre+"dl_scatterplot").dialog("isOpen")),o&&(t.bContactmap2=$("#"+e.pre+"dl_contactmap").dialog("isOpen")),a&&(t.bAlignerror2=$("#"+e.pre+"dl_alignerrormap").dialog("isOpen")),d&&(t.bTable2=$("#"+e.pre+"dl_interactionsorted").dialog("isOpen")),c&&(t.bAlignmentInit2=$("#"+e.pre+"dl_alignment").dialog("isOpen")),h&&(t.bTwoddgmInit2=$("#"+e.pre+"dl_2ddgm").dialog("isOpen")),p&&(t.bTwodctnInit2=$("#"+e.pre+"dl_2dctn").dialog("isOpen")),m&&(t.bSetsInit2=$("#"+e.pre+"dl_definedsets").dialog("isOpen")),{status:t,id2flag:s}}openDlgHalfWindow(e,t,s,i){let n=this.icn3dui,l=n.icn3d;if(n.bNode)return;let r=this,o=n.htmlCls.width2d+20;l.resizeCanvasCls.resizeCanvas(n.htmlCls.WIDTH-s,n.htmlCls.HEIGHT,i);let a,d=n.htmlCls.HEIGHT,c=s;a=!n.cfg.showmenu||n.utilsCls.isMobile()||n.cfg.mobilemenu?{my:"left top",at:"right top",of:"#"+n.pre+"viewer",collision:"none"}:{my:"left top",at:"right top+40",of:"#"+n.pre+"viewer",collision:"none"},n.cfg.resize=!1,window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:d,width:c,modal:!1,position:a,close:function(t){let s=r.getDialogStatus(),i=s.status,a=s.id2flag,d=!1;for(let t in a){let s=e===n.pre+t;for(let e in i)i.hasOwnProperty(e)||(s=s&&!i[e]);d=d||s}if(d)if(i.bTwoddgmInit2||i.bTwodctnInit2||i.bSetsInit2){let e=n.utilsCls.isMobile()?n.htmlCls.WIDTH:n.htmlCls.WIDTH-o;l.resizeCanvasCls.resizeCanvas(e,n.htmlCls.HEIGHT,!0),i.bTwoddgmInit2&&r.openDlg2Ddgm(n.pre+"dl_2ddgm",void 0,i.bSetsInit2),i.bTwodctnInit2&&r.openDlg2Ddgm(n.pre+"dl_2dctn",void 0,i.bSetsInit2),i.bSetsInit2&&r.openDlg2Ddgm(n.pre+"dl_definedsets")}else l.resizeCanvasCls.resizeCanvas(n.htmlCls.WIDTH,n.htmlCls.HEIGHT,!0)},resize:function(t){if(e==n.pre+"dl_selectannotations")l.annotationCls.hideFixedTitle();else if(e==n.pre+"dl_graph"){let t=$("#"+e).width(),s=$("#"+e).height();d3.select("#"+n.svgid).attr("width",t).attr("height",s)}else if(e==n.pre+"dl_linegraph"||e==n.pre+"dl_scatterplot"||e==n.pre+"dl_contactmap"||e==n.pre+"dl_alignerrormap"){let t=status.bTwoddgmInit2||status.bSetsInit2?(n.htmlCls.WIDTH-o)/2:n.htmlCls.WIDTH/2,s=$("#"+e).width()/t;if(e==n.pre+"dl_linegraph"){let e=l.linegraphWidth*s;$("#"+n.linegraphid).attr("width",e)}else if(e==n.pre+"dl_scatterplot"){let e=l.scatterplotWidth*s;$("#"+n.scatterplotid).attr("width",e)}else if(e==n.pre+"dl_contactmap"){let e=l.contactmapWidth*s;$("#"+n.contactmapid).attr("width",e)}else if(e==n.pre+"dl_alignerrormap"){let e=l.alignerrormapWidth*s;$("#"+n.alignerrormapid).attr("width",e)}}}}),this.addSaveButton(e),this.addHideButton(e)}openDlg2Ddgm(e,t,s){let i=this.icn3dui,n=i.icn3d;if(i.bNode)return;let l,r,o=this,a=i.htmlCls.width2d+20;e===i.pre+"dl_definedsets"?(l="right top",r="Select sets"):e!==i.pre+"dl_2ddgm"&&e!==i.pre+"dl_2dctn"||(l=s?"right top+240":"right top",r=e===i.pre+"dl_2ddgm"?"2D Diagram":"2D Cartoon");let d={my:"left top+"+i.htmlCls.MENU_HEIGHT,at:l,of:"#"+i.pre+"viewer",collision:"none"};window.dialog=$("#"+e).dialog({autoOpen:!0,title:r,height:"auto",width:a,modal:!1,position:d,close:function(e){let t=o.getDialogStatus().status;t.bSelectannotationsInit2||t.bGraph2||t.bLineGraph2||t.bScatterplot2||t.bTable2||t.bAlignmentInit2||n.resizeCanvasCls.resizeCanvas(i.htmlCls.WIDTH,i.htmlCls.HEIGHT,!0)},resize:function(t,s){e==i.pre+"dl_2dctn"&&(n.resizeRatioX=s.size.width/i.htmlCls.width2d,n.resizeRatioY=s.size.height/(i.htmlCls.width2d+70))},resizeStop:function(e,t){n.resizeRatioX=t.size.width/i.htmlCls.width2d,n.resizeRatioY=t.size.height/(i.htmlCls.width2d+70)}}),this.addSaveButton(e),this.addHideButton(e)}openDlgRegular(e,t){let s=this.icn3dui,i=s.icn3d;if(s.bNode)return;let n=400,l=150,r=s.htmlCls.width2d+20,o=this.getDialogStatus().status;if(e===s.pre+"dl_selectannotations"||e===s.pre+"dl_graph"||e===s.pre+"dl_linegraph"||e===s.pre+"dl_scatterplot"||e===s.pre+"dl_contactmap"||e===s.pre+"dl_alignerrormap"||e===s.pre+"dl_interactionsorted"||e===s.pre+"dl_alignment"){let a=.5*s.htmlCls.WIDTH-.5*r;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)this.openDlgHalfWindow(e,t,a,!0),(o.bTwoddgmInit2||o.bTwodctnInit2||o.bSetsInit2)&&(i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-a-r,s.htmlCls.HEIGHT,!0),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,o.bSetsInit2),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,o.bSetsInit2),o.bSetsInit2&&this.openDlg2Ddgm(s.pre+"dl_definedsets"));else{i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH,.5*s.htmlCls.HEIGHT,!0),l=.5*s.htmlCls.HEIGHT,n=s.htmlCls.WIDTH;let a={my:"left top",at:"left bottom+32",of:"#"+s.pre+"canvas",collision:"none"};window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:l,width:n,modal:!1,position:a,close:function(t){if(!((e!==s.pre+"dl_selectannotations"||o.bAlignmentInit2||o.bGraph2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_graph"||o.bSelectannotationsInit2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_alignment"||o.bSelectannotationsInit2||o.bGraph2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_interactionsorted"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_linegraph"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_scatterplot"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_contactmap"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bAlignerrormap2)&&(e!==s.pre+"dl_alignerrormap"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2)))if(o.bTwoddgmInit2||o.bTwodctnInit2||o.bSetsInit2){let e=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(e,s.htmlCls.HEIGHT,!0),o.bTwoddgmInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,o.bSetsInit2),o.bTwodctnInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,o.bSetsInit2),o.bSetsInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_definedsets")}else i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH,s.htmlCls.HEIGHT,!0)},resize:function(t){if(e==s.pre+"dl_selectannotations")i.annotationCls.hideFixedTitle();else if(e==s.pre+"dl_graph"){let t=$("#"+e).width(),i=$("#"+e).height();d3.select("#"+s.svgid).attr("width",t).attr("height",i)}else if(e==s.pre+"dl_linegraph"||e==s.pre+"dl_scatterplot"||e==s.pre+"dl_contactmap"||e==s.pre+"dl_alignerrormap"){let t=o.bTwoddgmInit2||o.bSetsInit2?(s.htmlCls.WIDTH-r)/2:s.htmlCls.WIDTH/2,n=$("#"+e).width()/t;if(e==s.pre+"dl_linegraph"){let e=i.linegraphWidth*n;$("#"+s.linegraphid).attr("width",e)}else if(e==s.pre+"dl_scatterplot"){let e=i.scatterplotWidth*n;$("#"+s.scatterplotid).attr("width",e)}else if(e==s.pre+"dl_contactmap"){let e=i.contactmapWidth*n;$("#"+s.contactmapid).attr("width",e)}else if(e==s.pre+"dl_alignerrormap"){let e=i.alignerrormapWidth*n;$("#"+s.alignerrormapid).attr("width",e)}}}}),this.addSaveButton(e),this.addHideButton(e)}}else if(e===s.pre+"dl_2ddgm"||e===s.pre+"dl_2dctn"){let t=0;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)(o.bSelectannotationsInit2||o.bGraph2||o.bLineGraph2||o.bScatterplot2||o.bTable2||o.bAlignmentInit2)&&(t=.5*s.htmlCls.WIDTH-.5*r),i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-t-r,s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,void 0,o.bSetsInit2);else{let t=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(t,.5*s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT,o.bSetsInit2)}}else{let a;if(l="auto",n="auto",e===s.pre+"dl_addtrack"?n="50%":e===s.pre+"dl_menupref"&&(n=600,l=500),e===s.pre+"dl_definedsets"){let t=0;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)(o.bSelectannotationsInit2||o.bGraph2||o.bLineGraph2||o.bScatterplot2||o.bTable2||o.bAlignmentInit2)&&(t=.5*s.htmlCls.WIDTH-.5*r),i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-t-r,s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,!0),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,!0);else{let t=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(t,.5*s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",.5*s.htmlCls.HEIGHT,!0),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",.5*s.htmlCls.HEIGHT,!0)}}else s.utilsCls.isMobile()?a={my:"left top",at:"left bottom-50",of:"#"+s.pre+"canvas",collision:"none"}:e===s.pre+"dl_allinteraction"||e===s.pre+"dl_buriedarea"?(a={my:"right top",at:"right top+50",of:"#"+i.divid,collision:"none"},n=700,l=500):a=e===s.pre+"dl_rmsd"||e===s.pre+"dl_legend"?{my:"left bottom",at:"left+20 bottom-20",of:"#"+s.pre+"canvas",collision:"none"}:e===s.pre+"dl_symd"?{my:"left top",at:"right-200 bottom-200",of:"#"+s.pre+"canvas",collision:"none"}:s.cfg.align?{my:"left top",at:"left top+90",of:"#"+s.pre+"canvas",collision:"none"}:{my:"left top",at:"left top+50",of:"#"+s.pre+"canvas",collision:"none"},window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:l,width:n,modal:!1,position:a}),this.addSaveButton(e),this.addHideButton(e)}$(".ui-dialog .ui-button span").removeClass("ui-icon-closethick").addClass("ui-icon-close")}openDlgNotebook(e,t){let s=this.icn3dui,i=s.icn3d;if(s.bNode)return;let n=400,l=150,r=s.htmlCls.width2d+20;e===s.pre+"dl_selectannotations"||e===s.pre+"dl_graph"||e===s.pre+"dl_linegraph"||e===s.pre+"dl_scatterplot"||e===s.pre+"dl_contactmap"||e===s.pre+"dl_alignerrormap"||e===s.pre+"dl_interactionsorted"||e===s.pre+"dl_alignment"?($("#"+e).show(),l=.5*s.htmlCls.HEIGHT,n=s.htmlCls.WIDTH,$("#"+e).width(n),$("#"+e).height(l),$("#"+e).resize((function(t){let n=s.htmlCls.WIDTH/2,l=$("#"+e).width()/n;if(e==s.pre+"dl_selectannotations")i.annotationCls.hideFixedTitle();else if(e==s.pre+"dl_graph"){let t=$("#"+e).width(),i=$("#"+e).height();d3.select("#"+s.svgid).attr("width",t).attr("height",i)}else if(e==s.pre+"dl_linegraph"){let e=i.linegraphWidth*l;$("#"+s.linegraphid).attr("width",e)}else if(e==s.pre+"dl_scatterplot"){let e=i.scatterplotWidth*l;$("#"+s.scatterplotid).attr("width",e)}else if(e==s.pre+"dl_contactmap"){let e=i.contactmapWidth*l;$("#"+s.contactmapid).attr("width",e)}else if(e==s.pre+"dl_alignerrormap"){let e=i.alignerrormapWidth*l;$("#"+s.alignerrormapid).attr("width",e)}}))):(i.bRender&&$("#"+e).show(),l="auto",n="auto",e===s.pre+"dl_addtrack"?n="50%":e===s.pre+"dl_2ddgm"||e===s.pre+"dl_2dctn"||e===s.pre+"dl_definedsets"?n=r:e!==s.pre+"dl_allinteraction"&&e!==s.pre+"dl_buriedarea"||(n=700,l=500),$("#"+e).width(n),$("#"+e).height(l))}}class h{constructor(e){this.icn3dui=e}setCustomDialogs(){let e=this.icn3dui;if(e.icn3d,e.bNode)return"";return""}getHtmlAlignResidueByResidue(e,t,s){let i=this.icn3dui;i.icn3d;let n="";return n+="All chains will be aligned to the first chain in the comma-separated chain IDs. Each chain ID has the form of PDBID_chain (e.g., 1HHO_A, case sensitive) or UniprotID (e.g., P69905 for AlphaFold structures).

    ",n+="Chain IDs: "+i.htmlCls.inputTextStr+"id='"+i.pre+e+"' value='P69905,P01942,1HHO_A' size=50>

    ",n+='Each alignment is defined as " | "-separated residue lists in one line. "10-50" means a range of residues from 10 to 50.

    ",n+=i.htmlCls.buttonStr+s+"'>Align Residue by Residue
    ",n}setDialogs(){let e=this.icn3dui,t=e.icn3d;if(e.bNode)return"";let s="";e.htmlCls.optionStr="":s.htmlCls.optionStr+"'"+l+"'>"+l+""}return i}setColorHints(){let e=this.icn3dui;e.icn3d;let t="";return t+=e.htmlCls.divNowrapStr+'Green: H-Bonds; ',t+='Cyan: Salt Bridge/Ionic; ',t+='Grey: contacts',t+=e.htmlCls.divNowrapStr+'Magenta: Halogen Bonds; ',t+='Red: π-Cation; ',t+='Blue: π-Stacking',t}setThicknessHtml(e){let t=this.icn3dui,s=t.icn3d,i="",n="3dprint"==e?"1":"0.1",l="3dprint"==e?"1.2":"0.3",r="3dprint"==e?"0.8":"0.4",o="3dprint"==e?"0.8":"0.4",a="3dprint"==e?"1":"0.4",d="3dprint"==e?"0.6":"0.3",c="3dprint"==e?"1":"0.2",h="3dprint"==e?"2":"1.3",p="3dprint"==e?"1.4":"0.8",m=40,u=.6,g=.4,f=.2,b=0,C=1,y=0;if("style"==e){if(""!=this.getCookie("shininess")&&(m=parseFloat(this.getCookie("shininess"))),""!=this.getCookie("light1")&&(u=parseFloat(this.getCookie("light1")),g=parseFloat(this.getCookie("light2")),f=parseFloat(this.getCookie("light3"))),""!=this.getCookie("lineRadius")){n=parseFloat(this.getCookie("lineRadius")),l=parseFloat(this.getCookie("coilWidth")),r=parseFloat(this.getCookie("cylinderRadius"));let e=this.getCookie("crosslinkRadius");o=isNaN(e)?s.crosslinkRadius:parseFloat(e),a=parseFloat(this.getCookie("traceRadius")),d=parseFloat(this.getCookie("dotSphereScale")),c=parseFloat(this.getCookie("ribbonthickness")),h=parseFloat(this.getCookie("helixSheetWidth")),p=parseFloat(this.getCookie("nucleicAcidWidth"))}""!=this.getCookie("glycan")&&(b=parseFloat(this.getCookie("glycan"))),""!=this.getCookie("membrane")&&(C=parseFloat(this.getCookie("membrane"))),""!=this.getCookie("cmdwindow")&&(y=parseFloat(this.getCookie("cmdwindow"))),i+="Note: The following parameters will be saved in cache. You just need to set them once.

    ",i+="1. Shininess: "+t.htmlCls.inputTextStr+"id='"+t.pre+"shininess' value='"+m+"' size=4>"+t.htmlCls.space3+"(for the shininess of the 3D objects, default 40)

    ",i+="2. Three directional lights:
    ",i+="Key Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light1' value='"+u+"' size=4>"+t.htmlCls.space3+"(for the light strength of the key light, default 0.6)
    ",i+="Fill Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light2' value='"+g+"' size=4>"+t.htmlCls.space3+"(for the light strength of the fill light, default 0.4)
    ",i+="Back Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light3' value='"+f+"' size=4>"+t.htmlCls.space3+"(for the light strength of the back light, default 0.2)

    ",i+="3. Thickness:
    "}return i+="Line Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"linerad_"+e+"' value='"+n+"' size=4>"+t.htmlCls.space3+"(for stabilizers, hydrogen bonds, distance lines, default 0.1)
    ",i+="Coil Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"coilrad_"+e+"' value='"+l+"' size=4>"+t.htmlCls.space3+"(for coils, default 0.3)
    ",i+="Stick Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"stickrad_"+e+"' value='"+r+"' size=4>"+t.htmlCls.space3+"(for sticks, default 0.4)
    ",i+="Cross-Linkage Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"crosslinkrad_"+e+"' value='"+o+"' size=4>"+t.htmlCls.space3+"(for cross-linkages, default 0.4)
    ",i+="Trace Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"tracerad_"+e+"' value='"+a+"' size=4>"+t.htmlCls.space3+"(for C alpha trace, O3' trace, default 0.4)
    ",i+="Ribbon Thickness: "+t.htmlCls.inputTextStr+"id='"+t.pre+"ribbonthick_"+e+"' value='"+c+"' size=4>"+t.htmlCls.space3+"(for helix and sheet ribbons, nucleotide ribbons, default 0.2)
    ",i+="Protein Ribbon Width: "+t.htmlCls.inputTextStr+"id='"+t.pre+"prtribbonwidth_"+e+"' value='"+h+"' size=4>"+t.htmlCls.space3+"(for helix and sheet ribbons, default 1.3)
    ",i+="Nucleotide Ribbon Width: "+t.htmlCls.inputTextStr+"id='"+t.pre+"nucleotideribbonwidth_"+e+"' value='"+p+"' size=4>"+t.htmlCls.space3+"(for nucleotide ribbons, default 0.8)
    ",i+="Ball Scale: "+t.htmlCls.inputTextStr+"id='"+t.pre+"ballscale_"+e+"' value='"+d+"' size=4>"+t.htmlCls.space3+"(for styles 'Ball and Stick' and 'Dot', default 0.3)
    ","style"==e&&(i+="
    4. Show Glycan Cartoon: "+t.htmlCls.inputTextStr+"id='"+t.pre+"glycan' value='"+b+"' size=4>"+t.htmlCls.space3+"(0: hide, 1: show, default 0)
    ",i+="
    5. Show Membrane: "+t.htmlCls.inputTextStr+"id='"+t.pre+"membrane' value='"+C+"' size=4>"+t.htmlCls.space3+"(0: hide, 1: show, default 1)
    ",i+="
    6. Enlarge Command Window: "+t.htmlCls.inputTextStr+"id='"+t.pre+"cmdwindow' value='"+y+"' size=4>"+t.htmlCls.space3+"(0: Regular, 1: Large, default 0)

    "),i+=t.htmlCls.spanNowrapStr+""+t.htmlCls.buttonStr+"apply_thickness_"+e+"'>Apply   ",i+=t.htmlCls.spanNowrapStr+""+t.htmlCls.buttonStr+"reset_thickness_"+e+"'>Reset",i}getCookie(e){let t=e+"=",s=decodeURIComponent(document.cookie).split(";");for(let e=0;e":(n+='
    ',n+="
    Selection: Name: "+s.htmlCls.inputTextStr+"id='"+s.pre+"seq_command_name"+e+"' value='seq_"+l+"' size='5'> "+s.htmlCls.space2+"

    ",n+=s.htmlCls.divStr+"seqguide"+e+"' style='display:none; white-space:normal;' class='icn3d-box'>"),n+=this.getSelectionHints();return n+="Residue labeling: standard residue with coordinates: UPPER case letter; nonstandard residue with coordinates: the first UPPER case letter plus a period except that water residue uses the letter 'O'; residue missing coordinates: lower case letter."+(s.utilsCls.isMac()&&!s.utilsCls.isMobile()?"

    Turn on scroll bar: System preferences -> General -> show scroll bars -> check Always":"")+"
    ",n}setAlignSequenceGuide(e,t){let s=this.icn3dui,i=s.icn3d,n="";let l=i&&i.defNames2Atoms?Object.keys(i.defNames2Atoms).length:1;n+='
    ',n+="
    Selection: Name: "+s.htmlCls.inputTextStr+"id='"+s.pre+"alignseq_command_name' value='alseq_"+l+"' size='10'> "+s.htmlCls.space2+"

    ",n+=s.htmlCls.divStr+"alignseqguide' style='display:none; white-space:normal;' class='icn3d-box'>",n+=this.getSelectionHints();return n+="Residue labeling: aligned residue with coordinates: UPPER case letter; non-aligned residue with coordinates: lower case letter which can be highlighted; residue missing coordinates: lower case letter which can NOT be highlighted."+(s.utilsCls.isMac()&&!s.utilsCls.isMobile()?"

    Turn on scroll bar: System preferences -> General -> show scroll bars -> check Always":"")+"
    ",n}getSelectionHints(){let e=this.icn3dui;e.icn3d;let t="";if(e.utilsCls.isMobile())t+='Select Aligned Sequences: touch to select, touch again to deselect, multiple selection is allowed without Ctrl key, click "Save Selection" to save the current selection.
    ';else{t+='Select on 1D sequences: drag to select, drag again to deselect, multiple selection is allowed without Ctrl key, click "Save Selection" to save the current selection.

    ',t+="Select on 2D interaction diagram: click on the nodes or lines. The nodes are chains and can be united with the Ctrl key. The lines are interactions and can NOT be united. Each click on the lines selects half of the lines, i.e., select the interacting residues in one of the two chains.

    ",t+="Select on 3D structures: "+(e.utilsCls.isMobile()?"use finger to pick":'hold "Alt" and use mouse to pick')+', click the second time to deselect, hold "Ctrl" to union selection, hold "Shift" to select a range, press the up/down arrow to switch among atom/residue/strand/chain/structure, click "Save Selection" to save the current selection.

    ',t+='Save the current selection(either on 3D structure, 2D interactions, or 1D sequence): open the menu "Select -> Save Selection", specify the name and description for the selection, and click "Save".

    '}return t}addGsizeSalt(e){let t=this.icn3dui;t.icn3d;let s="";s+="Grid Size: ",s+="Salt Concentration: M
    ",s}getFootHtml(e,t){let s=this.icn3dui;s.icn3d;let i="
    ";return"delphi"==e?s.cfg.cid?i+="Note: Partial charges(MMFF94) are from PubChem Compound SDF files.

    ":(i+="Note: Only the selected residues are used for DelPhi potential calculation by solving linear Poisson-Boltzmann equation.",i+='

    ',i+=s.htmlCls.divStr+t+"' style='display:none;'>",i+="
    The hydrogens and partial charges of proteins and nucleotides are added using DelPhiPKa with the Amber charge and size files. The hydrogens of ligands are added using Open Babel. The partial charges of ligands are calculated using Antechamber with the Gasteiger charge method. All partial charges are calculated at pH 7.

    ",i+='Lipids are treated as ligands. Please use "HETATM" instead of "ATOM " for each lipid atom in your PDB file. Each phosphate in lipids is assigned with a charge of -1. You can download PQR and modify it, or prepare your PQR file using other tools. Then load the PQR file at the menu "Analysis > Load PQR/Potential".

    ',i+="
    "):(i+="Note: Always load a PDB file before loading a PQR or DelPhi potential file.",i+='

    ',i+=s.htmlCls.divStr+t+"' style='display:none;'>",i+='The PDB file can be loaded in the URL with "pdbid=" or at "File > Open File". The PQR file can be prepared at the menu "Analysis > Download PQR" with your modification or using other tools. The DelPhi potential file can be calculated at DelPhi Web Server and be exported as a Cube file. ',"url"==e&&(i+="The PQR or potential file can be accessed in a URL if it is located in the same host as iCn3D."),i+="

    ",i+=""),i+="",i}getPotentialHtml(e,t){let s=this.icn3dui;s.icn3d;let i,n,l,r,o,a="";r="Equipotential Map",o="Surface with Potential","delphi"==e?n="delphi":"local"==e?(i="pqr",n="phi",l="cube"):"url"==e&&(i="pqrurl",n="phiurl",l="cubeurl"),a+=s.htmlCls.divStr+"dl_"+n+"' class='"+t+"'>",a+=s.htmlCls.divStr+"dl_"+n+"_tabs' style='border:0px;'>",a+="",a+=s.htmlCls.divStr+n+"tab1'>","delphi"==e&&(a+=this.addGsizeSalt(n)+"
    "),a+="Potential contour at: kT/e(25.6mV at 298K)

    ","delphi"==e?(a+=s.htmlCls.buttonStr+"reload_"+n+"file' style='margin-top: 6px;'>Equipotential Map",a+=s.htmlCls.buttonStr+n+"mapNo' style='margin-left:30px;'>Remove Map
    "):"local"==e?(a+=s.htmlCls.divStr+n+"tab1_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo'>Remove Map",a+=s.htmlCls.divStr+n+"tab1_"+i+"'>",a+=this.addGsizeSalt(i)+"
    ",a+="PQR File: "+s.htmlCls.inputFileStr+"id='"+s.pre+i+"file'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+n+"'>",a+="Phi File: "+s.htmlCls.inputFileStr+"id='"+s.pre+n+"file'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+l+"'>",a+="Cube File: "+s.htmlCls.inputFileStr+"id='"+s.pre+l+"file'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=""):"url"==e&&(a+=s.htmlCls.divStr+n+"tab1_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo'>Remove Map",a+=s.htmlCls.divStr+n+"tab1_"+i+"2'>",a+=this.addGsizeSalt(i)+"
    ",a+="PQR URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+i+"file'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+n+"2'>",a+="Phi URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+n+"file'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+l+"2'>",a+="Cube URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+l+"file'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=""),a+="
    "+this.getFootHtml(e,n+"tab1_foot"),a+="",a+=s.htmlCls.divStr+n+"tab2'>","delphi"==e&&(a+=this.addGsizeSalt(n)+"
    "),a+="Surface with max potential at: kT/e(25.6mV at 298K)

    ",a+="Surface: ",a+="Opacity: ",a+="Wireframe:
    ",a+="
    ","delphi"==e?(a+=s.htmlCls.buttonStr+"reload_"+n+"file2' style='margin-top: 6px;'>Surface with Potential",a+=s.htmlCls.buttonStr+n+"mapNo2' style='margin-left:30px;'>Remove Surface
    "):"local"==e?(a+=s.htmlCls.divStr+n+"tab2_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo2'>Remove Surface",a+=s.htmlCls.divStr+n+"tab2_"+i+"'>",a+=this.addGsizeSalt(i+"2")+"
    ",a+="PQR File: "+s.htmlCls.inputFileStr+"id='"+s.pre+i+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+n+"'>",a+="Phi File: "+s.htmlCls.inputFileStr+"id='"+s.pre+n+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+l+"'>",a+="Cube File: "+s.htmlCls.inputFileStr+"id='"+s.pre+l+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=""):"url"==e&&(a+=s.htmlCls.divStr+n+"tab2_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo2'>Remove Surface",a+=s.htmlCls.divStr+n+"tab2_"+i+"2'>",a+=this.addGsizeSalt(i+"2")+"
    ",a+="PQR URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+i+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+n+"2'>",a+="Phi URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+n+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+l+"2'>",a+="Cube URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+l+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=""),a+="
    "+this.getFootHtml(e,n+"tab2_foot"),a+="",a+="",a+="",a}async exportPqr(e){let t=this.icn3dui,s=t.icn3d,i={},n={},l=t.hashUtilsCls.intHash(s.dAtoms,s.hAtoms);for(let e in l)s.atoms[e],s.ions.hasOwnProperty(e)?i[e]=1:n[e]=1;let r=e?"pdb":"pqr";if(t.cfg.cid){let t="",l=!e;t+=s.saveFileCls.getAtomPDB(n,l)+s.saveFileCls.getAtomPDB(i,l);let o=s.inputid?s.inputid:"custom";s.saveFileCls.saveFile(o+"_icn3d."+r,"text",[t])}else{if(t.utilsCls.isCalphaPhosOnly(t.hashUtilsCls.hash2Atoms(n,s.atoms)))return void alert("The potential will not be shown because the side chains are missing in the structure...");let l="";l+=s.saveFileCls.getAtomPDB(n),l+=s.saveFileCls.getAtomPDB(i,!0,void 0,!0);let o="https://www.ncbi.nlm.nih.gov/Structure/delphi/delphi.fcgi",a={pdb2pqr:l,pdbid:t.cfg.cid?t.cfg.cid:Object.keys(s.structures).toString()},d=await t.getAjaxPostPromise(o,a,!0,void 0,void 0,!0,"text");if(e){let e=d.split("\n"),s="";for(let i=0,n=e.length;i PNG Image" in the Data menu...');else if(-1!=l){let t=e.substr(l+n.length);s.htmlCls.clickMenuCls.setLogCmd("load iCn3D PNG image "+$("#"+s.pre+"pngimage").val(),!1),window.open(t,"_self")}else if(-1!=o){let n="Start of data file======\n",l=e.indexOf(n);i.bInputfile=-1!=l;let a,d=t?t.replace(/;/g,"\n"):"";if(i.bInputfile){let t=e.indexOf("End of data file======\n"),s=e.substr(l+n.length,t-l-n.length);i.InputfileData=i.InputfileData?i.InputfileData+"\nENDMDL\n"+s:s;let c="Start of type file======\n",h=e.indexOf(c),p=e.indexOf("End of type file======\n"),m=e.substr(h+c.length,p-h-c.length-1);i.InputfileType=m;let u=e.indexOf("End of state file======\n");a=e.substr(o+r.length,u-o-r.length),a=decodeURIComponent(a+"\n"+d),"pdb"===m?(await i.pdbParserCls.loadPdbData(s),i.commands=[],i.optsHistory=[]):("mol2"===m?await i.mol2ParserCls.loadMol2Data(s):"sdf"===m?await i.sdfParserCls.loadSdfData(s):"xyz"===m?await i.xyzParserCls.loadXyzData(s):"mmcif"===m&&await i.mmcifParserCls.loadMmcifData(s),i.commands=[],i.optsHistory=[])}else{let t=e.indexOf("End of state file======\n");a=e.substr(o+r.length,t-o-r.length),a=decodeURIComponent(a+"\n"+d),i.commands=[],i.optsHistory=[]}await i.loadScriptCls.loadScript(a,!0),s.htmlCls.clickMenuCls.setLogCmd("load iCn3D PNG image "+$("#"+s.pre+"pngimage").val(),!1)}}fileSupport(){window.File&&window.FileReader&&window.FileList&&window.Blob||alert("The File APIs are not fully supported in this browser.")}getLinkColor(){let e="";return e+=", linkmap: {\n",e+='3: {"type": "peptidebond", "c":""},\n',e+='4: {"type": "ssbond", "c":"FFA500"},\n',e+='5: {"type": "ionic", "c":"0FF"},\n',e+='6: {"type": "ionicInside", "c":"FFF"},\n',e+='11: {"type": "contact", "c":"888"},\n',e+='12: {"type": "contactInside", "c":"FFF"},\n',e+='13: {"type": "hbond", "c":"0F0"},\n',e+='14: {"type": "hbondInside", "c":"FFF"},\n',e+='15: {"type": "clbond", "c":"006400"},\n',e+='17: {"type": "halogen", "c":"F0F"},\n',e+='18: {"type": "halogenInside", "c":"FFF"},\n',e+='19: {"type": "pication", "c":"F00"},\n',e+='20: {"type": "picationInside", "c":"FFF"},\n',e+='21: {"type": "pistacking", "c":"00F"},\n',e+='22: {"type": "pistackingInside", "c":"FFF"}\n',e+="}}\n",', linkmap: {\n3: {"type": "peptidebond", "c":""},\n4: {"type": "ssbond", "c":"FFA500"},\n5: {"type": "ionic", "c":"0FF"},\n6: {"type": "ionicInside", "c":"FFF"},\n11: {"type": "contact", "c":"888"},\n12: {"type": "contactInside", "c":"FFF"},\n13: {"type": "hbond", "c":"0F0"},\n14: {"type": "hbondInside", "c":"FFF"},\n15: {"type": "clbond", "c":"006400"},\n17: {"type": "halogen", "c":"F0F"},\n18: {"type": "halogenInside", "c":"FFF"},\n19: {"type": "pication", "c":"F00"},\n20: {"type": "picationInside", "c":"FFF"},\n21: {"type": "pistacking", "c":"00F"},\n22: {"type": "pistackingInside", "c":"FFF"}\n}}\n'}setCookieForThickness(){let e=this.icn3dui,t=e.icn3d;if(!e.bNode){let e=3650;this.setCookie("lineRadius",t.lineRadius,e),this.setCookie("coilWidth",t.coilWidth,e),this.setCookie("cylinderRadius",t.cylinderRadius,e),this.setCookie("crosslinkRadius",t.crosslinkRadius,e),this.setCookie("traceRadius",t.traceRadius,e),this.setCookie("dotSphereScale",t.dotSphereScale,e),this.setCookie("ribbonthickness",t.ribbonthickness,e),this.setCookie("helixSheetWidth",t.helixSheetWidth,e),this.setCookie("nucleicAcidWidth",t.nucleicAcidWidth,e)}}setLineThickness(e,t){let s=this.icn3dui,i=s.icn3d;if(i.bSetThickness=!0,"style"==e&&(t&&($("#"+s.pre+"shininess").val("40"),$("#"+s.pre+"light1").val("0.6"),$("#"+s.pre+"light2").val("0.4"),$("#"+s.pre+"light3").val("0.2"),$("#"+s.pre+"glycan").val("0"),$("#"+s.pre+"membrane").val("1"),$("#"+s.pre+"cmdwindow").val("0")),i.shininess=parseFloat($("#"+s.pre+"shininess").val()),i.light1=parseFloat($("#"+s.pre+"light1").val()),i.light2=parseFloat($("#"+s.pre+"light2").val()),i.light3=parseFloat($("#"+s.pre+"light3").val()),i.bGlycansCartoon=parseInt($("#"+s.pre+"glycan").val()),i.bMembrane=parseInt($("#"+s.pre+"membrane").val()),i.bCmdWindow=parseInt($("#"+s.pre+"cmdwindow").val())),t&&($("#"+s.pre+"linerad_"+e).val(.1),$("#"+s.pre+"coilrad_"+e).val(.3),$("#"+s.pre+"stickrad_"+e).val(.4),$("#"+s.pre+"crosslinkrad_"+e).val(.4),$("#"+s.pre+"tracerad_"+e).val(.4),$("#"+s.pre+"ballscale_"+e).val(.3),$("#"+s.pre+"ribbonthick_"+e).val(.2),$("#"+s.pre+"prtribbonwidth_"+e).val(1.3),$("#"+s.pre+"nucleotideribbonwidth_"+e).val(.8)),i.lineRadius=parseFloat($("#"+s.pre+"linerad_"+e).val()),i.coilWidth=parseFloat($("#"+s.pre+"coilrad_"+e).val()),i.cylinderRadius=parseFloat($("#"+s.pre+"stickrad_"+e).val()),i.crosslinkRadius=parseFloat($("#"+s.pre+"crosslinkrad_"+e).val()),i.traceRadius=parseFloat($("#"+s.pre+"tracerad_"+e).val()),i.dotSphereScale=parseFloat($("#"+s.pre+"ballscale_"+e).val()),i.ribbonthickness=parseFloat($("#"+s.pre+"ribbonthick_"+e).val()),i.helixSheetWidth=parseFloat($("#"+s.pre+"prtribbonwidth_"+e).val()),i.nucleicAcidWidth=parseFloat($("#"+s.pre+"nucleotideribbonwidth_"+e).val()),!s.bNode){let e=3650;this.setCookie("shininess",i.shininess,e),this.setCookie("light1",i.light1,e),this.setCookie("light2",i.light2,e),this.setCookie("light3",i.light3,e),this.setCookie("glycan",i.bGlycansCartoon,e),this.setCookie("membrane",i.bMembrane,e),this.setCookie("cmdwindow",i.bCmdWindow,e)}if(this.setCookieForThickness(),e=t){let e="reset thickness";s.htmlCls.clickMenuCls.setLogCmd(e,!0),i.bSetThickness=!1,i.threeDPrintCls.resetAfter3Dprint()}else s.htmlCls.clickMenuCls.setLogCmd("set thickness | linerad "+i.lineRadius+" | coilrad "+i.coilWidth+" | stickrad "+i.cylinderRadius+" | crosslinkrad "+i.crosslinkRadius+" | tracerad "+i.traceRadius+" | ribbonthick "+i.ribbonthickness+" | proteinwidth "+i.helixSheetWidth+" | nucleotidewidth "+i.nucleicAcidWidth+" | ballscale "+i.dotSphereScale,!0),s.htmlCls.clickMenuCls.setLogCmd("set glycan "+i.bGlycansCartoon,!0),s.htmlCls.clickMenuCls.setLogCmd("set membrane "+i.bMembrane,!0),s.htmlCls.clickMenuCls.setLogCmd("set cmdwindow "+i.bCmdWindow,!0);i.drawCls.draw()}setCookie(e,t,s){let i=new Date;i.setTime(i.getTime()+24*s*60*60*1e3);let n="expires="+i.toUTCString();document.cookie=e+"="+t+";"+n+";path=/"}updateSurfPara(e){let t=this.icn3dui,s=t.icn3d;s.phisurftype=$("#"+t.pre+e+"surftype").val(),s.phisurfop=$("#"+t.pre+e+"surfop").val(),s.phisurfwf=$("#"+t.pre+e+"surfwf").val()}exportPdb(){let e=this.icn3dui,t=e.icn3d,s="",i=e.hashUtilsCls.intHash(t.dAtoms,t.hAtoms);if(s+=t.saveFileCls.getAtomPDB(i),!e.bNode){let e=t.inputid?t.inputid:"custom";t.saveFileCls.saveFile(e+"_icn3d.pdb","text",[s])}return s}exportSecondary(){let e=this.icn3dui,t=e.icn3d,s="",i=e.hashUtilsCls.intHash(t.dAtoms,t.hAtoms);if(s+=t.saveFileCls.getSecondary(i),!e.bNode){let e=t.inputid?t.inputid:"custom";t.saveFileCls.saveFile(e+"_icn3d_ss.txt","text",[s])}return s}}class g{constructor(e){let t=e;this.icn3dui=e,this.cfg=this.icn3dui.cfg,this.opts={},this.opts.background="black",this.allMenus={},this.allMenusSel={},this.simpleMenus={},this.shownMenus={},this.WIDTH=400,this.HEIGHT=400,this.RESIDUE_WIDTH=10,t.utilsCls.isMobile()||this.cfg.mobilemenu?this.MENU_HEIGHT=0:this.MENU_HEIGHT=40,this.LOG_HEIGHT=65,this.MENU_WIDTH=750,this.LESSWIDTH=20,this.LESSWIDTH_RESIZE=20,this.LESSHEIGHT=20,this.width2d=200,this.CMD_HEIGHT=.8*this.LOG_HEIGHT,this.EXTRAHEIGHT=this.MENU_HEIGHT+this.CMD_HEIGHT,null!=this.cfg.showmenu&&0==this.cfg.showmenu&&(this.EXTRAHEIGHT-=this.MENU_HEIGHT),null!=this.cfg.showcommand&&0==this.cfg.showcommand&&(this.EXTRAHEIGHT-=this.CMD_HEIGHT),this.GREY8="#AAAAAA",this.GREYB="#CCCCCC",this.GREYC="#DDDDDD",this.GREYD="#EEEEEE",this.ORANGE="#FFA500",this.themecolor="blue",this.defaultValue=1,this.ssValue=3,this.coilValue=3,this.contactValue=11,this.contactInsideValue=12,this.hbondValue=13,this.hbondInsideValue=14,this.ssbondValue=4,this.ionicValue=5,this.ionicInsideValue=6,this.clbondValue=15,this.halogenValue=17,this.halogenInsideValue=18,this.picationValue=19,this.picationInsideValue=20,this.pistackingValue=21,this.pistackingInsideValue=22,this.contactColor="888",this.contactInsideColor="FFF",this.hbondColor="0F0",this.hbondInsideColor="FFF",this.ssbondColor="FFA500",this.ionicColor="0FF",this.ionicInsideColor="FFF",this.clbondColor="006400",this.halogenColor="F0F",this.halogenInsideColor="FFF",this.picationColor="F00",this.picationInsideColor="FFF",this.pistackingColor="00F",this.pistackingInsideColor="FFF",this.hideedges=1,this.force=4,this.simulation=void 0,this.baseUrl=window&&window.location&&"structure.ncbi.nlm.nih.gov"==window.location.hostname?"https://structure.ncbi.nlm.nih.gov/Structure/":"https://www.ncbi.nlm.nih.gov/Structure/",this.divStr="
    ",this.spanNowrapStr="",this.inputTextStr="=2.0 are supported.")));const a=new pe(o,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});a.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===r[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}a.setExtensions(l),a.setPlugins(r),a.parse(s,i)}parseAsync(e,t){const s=this;return new Promise((function(i,n){s.parse(e,t,i,n)}))}}function b(){let e={};return{get:function(t){return e[t]},add:function(t,s){e[t]=s},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const C={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class y{constructor(e){this.parser=e,this.name=C.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,i=t.length;s=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,n.source,l)}}class R{constructor(e){this.parser=e,this.name=C.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,i=s.json,n=i.textures[e];if(!n.extensions||!n.extensions[t])return null;const l=n.extensions[t],r=i.images[l.source];let o=s.textureLoader;if(r.uri){const e=s.options.manager.getHandler(r.uri);null!==e&&(o=e)}return this.detectSupport().then((function(n){if(n)return s.loadTextureImage(e,l.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class E{constructor(e){this.name=C.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const e=s.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),n=this.parser.options.meshoptDecoder;if(!n||!n.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([i,n.ready]).then((function(t){const s=e.byteOffset||0,i=e.byteLength||0,l=e.count,r=e.byteStride,o=new ArrayBuffer(l*r),a=new Uint8Array(t[0],s,i);return n.decodeGltfBuffer(new Uint8Array(o),l,r,a,e.mode,e.filter),o}))}return null}}const I="glTF",T=1313821514,M=5130562;class P{constructor(e){this.name=C.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:THREE.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==I)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-12,i=new DataView(e,12);let n=0;for(;n",t).replace("#include ",s).replace("#include ",i).replace("#include ",n).replace("#include ",l)},Object.defineProperties(this,{specular:{get:function(){return r.specular.value},set:function(e){r.specular.value=e}},specularMap:{get:function(){return r.specularMap.value},set:function(e){r.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return r.glossiness.value},set:function(e){r.glossiness.value=e}},glossinessMap:{get:function(){return r.glossinessMap.value},set:function(e){r.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class L{constructor(){this.name=C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity"]}getMaterialType(){return F}extendParams(e,t,s){const i=t.extensions[this.name];e.color=new Color(1,1,1),e.opacity=1;const n=[];if(Array.isArray(i.diffuseFactor)){const t=i.diffuseFactor;e.color.fromArray(t),e.opacity=t[3]}if(void 0!==i.diffuseTexture&&n.push(s.assignTexture(e,"map",i.diffuseTexture,sRGBEncoding)),e.emissive=new Color(0,0,0),e.glossiness=void 0!==i.glossinessFactor?i.glossinessFactor:1,e.specular=new Color(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),void 0!==i.specularGlossinessTexture){const t=i.specularGlossinessTexture;n.push(s.assignTexture(e,"glossinessMap",t)),n.push(s.assignTexture(e,"specularMap",t,sRGBEncoding))}return Promise.all(n)}createMaterial(e){const t=new F(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=TangentSpaceNormalMap,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t}}class N{constructor(){this.name=C.KHR_MESH_QUANTIZATION}}class U extends THREE.Interpolant{constructor(e,t,s,i){super(e,t,s,i)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,i=this.valueSize,n=e*i*3+i;for(let e=0;e!==i;e++)t[e]=s[n+e];return t}}U.prototype.beforeStart_=U.prototype.copySampleValue_,U.prototype.afterEnd_=U.prototype.copySampleValue_,U.prototype.interpolate_=function(e,t,s,i){const n=this.resultBuffer,l=this.sampleValues,r=this.valueSize,o=2*r,a=3*r,d=i-t,c=(s-t)/d,h=c*c,p=h*c,m=e*a,u=m-a,g=-2*p+3*h,f=p-h,b=1-g,C=f-h+c;for(let e=0;e!==r;e++){const t=l[u+e+r],s=l[u+e+o]*d,i=l[m+e+r],a=l[m+e]*d;n[e]=b*t+C*s+g*i+f*a}return n};const q=new THREE.Quaternion;class j extends U{interpolate_(e,t,s,i){const n=super.interpolate_(e,t,s,i);return q.fromArray(n).normalize().toArray(n),n}}const B=0,z=1,G=2,V=3,W=4,Y=5,X=6,K={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Q={9728:THREE.NearestFilter,9729:THREE.LinearFilter,9984:THREE.NearestMipmapNearestFilter,9985:THREE.LinearMipmapNearestFilter,9986:THREE.NearestMipmapLinearFilter,9987:THREE.LinearMipmapLinearFilter},J={33071:THREE.ClampToEdgeWrapping,33648:THREE.MirroredRepeatWrapping,10497:THREE.RepeatWrapping},Z={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ee={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},te={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},se={CUBICSPLINE:void 0,LINEAR:THREE.InterpolateLinear,STEP:THREE.InterpolateDiscrete},ie="OPAQUE",ne="MASK",le="BLEND";function re(e,t,s){for(const i in s.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=s.extensions[i])}function oe(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function ae(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let s=0,i=t.weights.length;s{const s=this.associations.get(e);null!=s&&this.associations.set(t,s);for(const[s,i]of e.children.entries())n(i,t.children[s])};return n(s,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s=2&&m.setY(t,c[e*l+1]),l>=3&&m.setZ(t,c[e*l+2]),l>=4&&m.setW(t,c[e*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m}))}loadTexture(e){const t=this.json,s=this.options,i=t.textures[e].source,n=t.images[i];let l=this.textureLoader;if(n.uri){const e=s.manager.getHandler(n.uri);null!==e&&(l=e)}return this.loadTextureImage(e,i,l)}loadTextureImage(e,t,s){const i=this,n=this.json,l=n.textures[e],r=n.images[t],o=(r.uri||r.bufferView)+":"+l.sampler;if(this.textureCache[o])return this.textureCache[o];const a=this.loadImageSource(t,s).then((function(t){t.flipY=!1,l.name&&(t.name=l.name);const s=(n.samplers||{})[l.sampler]||{};return t.magFilter=Q[s.magFilter]||LinearFilter,t.minFilter=Q[s.minFilter]||LinearMipmapLinearFilter,t.wrapS=J[s.wrapS]||RepeatWrapping,t.wrapT=J[s.wrapT]||RepeatWrapping,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=a,a}loadImageSource(e,t){const s=this,i=this.json,n=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const l=i.images[e],r=self.URL||self.webkitURL;let o=l.uri||"",a=!1;if(void 0!==l.bufferView)o=s.getDependency("bufferView",l.bufferView).then((function(e){a=!0;const t=new Blob([e],{type:l.mimeType});return o=r.createObjectURL(t),o}));else if(void 0===l.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(o).then((function(e){return new Promise((function(s,i){let l=s;!0===t.isImageBitmapLoader&&(l=function(e){const t=new Texture(e);t.needsUpdate=!0,s(t)}),t.load(THREE.LoaderUtils.resolveURL(e,n.path),l,void 0,i)}))})).then((function(e){var t;return!0===a&&r.revokeObjectURL(o),e.userData.mimeType=l.mimeType||((t=l.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),e}));return this.sourceCache[e]=d,d}assignTexture(e,t,s,i){const n=this;return this.getDependency("texture",s.index).then((function(l){if(void 0===s.texCoord||0==s.texCoord||"aoMap"===t&&1==s.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+s.texCoord+" for texture "+t+" not yet supported."),n.extensions[C.KHR_TEXTURE_TRANSFORM]){const e=void 0!==s.extensions?s.extensions[C.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=n.associations.get(l);l=n.extensions[C.KHR_TEXTURE_TRANSFORM].extendTexture(l,e),n.associations.set(l,t)}}return void 0!==i&&(l.encoding=i),e[t]=l,l}))}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const i=void 0===t.attributes.tangent,n=void 0!==t.attributes.color,l=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new PointsMaterial,Material.prototype.copy.call(t,s),t.color.copy(s.color),t.map=s.map,t.sizeAttenuation=!1,this.cache.add(e,t)),s=t}else if(e.isLine){const e="LineBasicMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new LineBasicMaterial,Material.prototype.copy.call(t,s),t.color.copy(s.color),this.cache.add(e,t)),s=t}if(i||n||l){let e="ClonedMaterial:"+s.uuid+":";s.isGLTFSpecularGlossinessMaterial&&(e+="specular-glossiness:"),i&&(e+="derivative-tangents:"),n&&(e+="vertex-colors:"),l&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=s.clone(),n&&(t.vertexColors=!0),l&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(s))),s=t}s.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),e.material=s}getMaterialType(){return MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,i=this.extensions,n=s.materials[e];let l;const r={},o=n.extensions||{},a=[];if(o[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=i[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];l=e.getMaterialType(),a.push(e.extendParams(r,n,t))}else if(o[C.KHR_MATERIALS_UNLIT]){const e=i[C.KHR_MATERIALS_UNLIT];l=e.getMaterialType(),a.push(e.extendParams(r,n,t))}else{const s=n.pbrMetallicRoughness||{};if(r.color=new Color(1,1,1),r.opacity=1,Array.isArray(s.baseColorFactor)){const e=s.baseColorFactor;r.color.fromArray(e),r.opacity=e[3]}void 0!==s.baseColorTexture&&a.push(t.assignTexture(r,"map",s.baseColorTexture,sRGBEncoding)),r.metalness=void 0!==s.metallicFactor?s.metallicFactor:1,r.roughness=void 0!==s.roughnessFactor?s.roughnessFactor:1,void 0!==s.metallicRoughnessTexture&&(a.push(t.assignTexture(r,"metalnessMap",s.metallicRoughnessTexture)),a.push(t.assignTexture(r,"roughnessMap",s.metallicRoughnessTexture))),l=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),a.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,r)}))))}!0===n.doubleSided&&(r.side=DoubleSide);const d=n.alphaMode||ie;if(d===le?(r.transparent=!0,r.depthWrite=!1):(r.transparent=!1,d===ne&&(r.alphaTest=void 0!==n.alphaCutoff?n.alphaCutoff:.5)),void 0!==n.normalTexture&&l!==MeshBasicMaterial&&(a.push(t.assignTexture(r,"normalMap",n.normalTexture)),r.normalScale=new Vector2(1,1),void 0!==n.normalTexture.scale)){const e=n.normalTexture.scale;r.normalScale.set(e,e)}return void 0!==n.occlusionTexture&&l!==MeshBasicMaterial&&(a.push(t.assignTexture(r,"aoMap",n.occlusionTexture)),void 0!==n.occlusionTexture.strength&&(r.aoMapIntensity=n.occlusionTexture.strength)),void 0!==n.emissiveFactor&&l!==MeshBasicMaterial&&(r.emissive=(new Color).fromArray(n.emissiveFactor)),void 0!==n.emissiveTexture&&l!==MeshBasicMaterial&&a.push(t.assignTexture(r,"emissiveMap",n.emissiveTexture,sRGBEncoding)),Promise.all(a).then((function(){let s;return s=l===F?i[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(r):new l(r),n.name&&(s.name=n.name),oe(s,n),t.associations.set(s,{materials:e}),n.extensions&&re(i,s,n),s}))}createUniqueName(e){const t=PropertyBinding.sanitizeNodeName(e||"");let s=t;for(let e=1;this.nodeNamesUsed[s];++e)s=t+"_"+e;return this.nodeNamesUsed[s]=!0,s}loadGeometries(e){const t=this,s=this.extensions,i=this.primitiveCache;function n(e){return s[C.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(s){return ue(s,e,t)}))}const l=[];for(let s=0,r=e.length;s0&&ae(h,n),h.name=t.createUniqueName(n.name||"mesh_"+e),oe(h,n),c.extensions&&re(i,h,c),t.assignFinalMaterial(h),a.push(h)}for(let s=0,i=a.length;s1?new Group:1===t.length?t[0]:new Object3D,r!==t[0])for(let e=0,s=t.length;e{const t=new Map;for(const[e,s]of n.associations)(e instanceof Material||e instanceof Texture)&&t.set(e,s);return e.traverse((e=>{const s=n.associations.get(e);null!=s&&t.set(e,s)})),t})(l),l}))}}function me(e,t,s,i){const n=s.nodes[e];return i.getDependency("node",e).then((function(e){if(void 0===n.skin)return e;let t;return i.getDependency("skin",n.skin).then((function(e){t=e;const s=[];for(let e=0,n=t.joints.length;e{const s=n[e];return s&&(l={profileId:e,profilePath:`${t}/${s.path}`,deprecated:!!s.deprecated}),!!l})),!l){if(!s)throw new Error("No matching profile name found");const e=n[s];if(!e)throw new Error(`No matching profile name found and default profile "${s}" missing.`);l={profileId:s,profilePath:`${t}/${e.path}`,deprecated:!!e.deprecated}}const r=await be(l.profilePath);let o;if(i){let t;if(t="any"===e.handedness?r.layouts[Object.keys(r.layouts)[0]]:r.layouts[e.handedness],!t)throw new Error(`No matching handedness, ${e.handedness}, in profile ${l.profileId}`);t.assetPath&&(o=l.profilePath.replace("profile.json",t.assetPath))}return{profile:r,assetPath:o}}const ye={xAxis:0,yAxis:0,button:0,state:fe.ComponentState.DEFAULT};class ve{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===fe.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(ye)}updateFromComponent({xAxis:e,yAxis:t,button:s,state:i}){const{normalizedXAxis:n,normalizedYAxis:l}=function(e=0,t=0){let s=e,i=t;if(Math.sqrt(e*e+t*t)>1){const n=Math.atan2(t,e);s=Math.cos(n),i=Math.sin(n)}return{normalizedXAxis:.5*s+.5,normalizedYAxis:.5*i+.5}}(e,t);switch(this.componentProperty){case fe.ComponentProperty.X_AXIS:this.value=this.states.includes(i)?n:.5;break;case fe.ComponentProperty.Y_AXIS:this.value=this.states.includes(i)?l:.5;break;case fe.ComponentProperty.BUTTON:this.value=this.states.includes(i)?s:0;break;case fe.ComponentProperty.STATE:this.valueNodeProperty===fe.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(i):this.value=this.states.includes(i)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}}class we{constructor(e,t){if(!(e&&t&&t.visualResponses&&t.gamepadIndices&&0!==Object.keys(t.gamepadIndices).length))throw new Error("Invalid arguments supplied");this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach((e=>{const s=new ve(t.visualResponses[e]);this.visualResponses[e]=s})),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:fe.ComponentState.DEFAULT,button:void 0!==this.gamepadIndices.button?0:void 0,xAxis:void 0!==this.gamepadIndices.xAxis?0:void 0,yAxis:void 0!==this.gamepadIndices.yAxis?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(e){if(this.values.state=fe.ComponentState.DEFAULT,void 0!==this.gamepadIndices.button&&e.buttons.length>this.gamepadIndices.button){const t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||1===this.values.button?this.values.state=fe.ComponentState.PRESSED:(t.touched||this.values.button>fe.ButtonTouchThreshold)&&(this.values.state=fe.ComponentState.TOUCHED)}void 0!==this.gamepadIndices.xAxis&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===fe.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>fe.AxisTouchThreshold&&(this.values.state=fe.ComponentState.TOUCHED)),void 0!==this.gamepadIndices.yAxis&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===fe.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>fe.AxisTouchThreshold&&(this.values.state=fe.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach((e=>{e.updateFromComponent(this.values)}))}}class _e{constructor(e,t,s){if(!e)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No profile supplied");this.xrInputSource=e,this.assetUrl=s,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach((e=>{const t=this.layoutDescription.components[e];this.components[e]=new we(e,t)})),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const e=[];return Object.values(this.components).forEach((t=>{e.push(t.data)})),e}updateFromGamepad(){Object.values(this.components).forEach((e=>{e.updateFromGamepad(this.xrInputSource.gamepad)}))}}class Se extends THREE.Object3D{constructor(){super(),this.motionController=null,this.envMap=null}setEnvironmentMap(e){return this.envMap==e||(this.envMap=e,this.traverse((e=>{e.isMesh&&(e.material.envMap=this.envMap,e.material.needsUpdate=!0)}))),this}updateMatrixWorld(e){super.updateMatrixWorld(e),this.motionController&&(this.motionController.updateFromGamepad(),Object.values(this.motionController.components).forEach((e=>{Object.values(e.visualResponses).forEach((e=>{const{valueNode:t,minNode:s,maxNode:i,value:n,valueNodeProperty:l}=e;t&&(l===fe.VisualResponseProperty.VISIBILITY?t.visible=n:l===fe.VisualResponseProperty.TRANSFORM&&(t.quaternion.slerpQuaternions(s.quaternion,i.quaternion,n),t.position.lerpVectors(s.position,i.position,n)))}))})))}}function Ae(e,t){!function(e,t){Object.values(e.components).forEach((e=>{const{type:s,touchPointNodeName:i,visualResponses:n}=e;if(s===fe.ComponentType.TOUCHPAD)if(e.touchPointNode=t.getObjectByName(i),e.touchPointNode){const t=new SphereGeometry(.001),s=new MeshBasicMaterial({color:255}),i=new Mesh(t,s);e.touchPointNode.add(i)}else console.warn(`Could not find touch dot, ${e.touchPointNodeName}, in touchpad component ${e.id}`);Object.values(n).forEach((e=>{const{valueNodeName:s,minNodeName:i,maxNodeName:n,valueNodeProperty:l}=e;if(l===fe.VisualResponseProperty.TRANSFORM){if(e.minNode=t.getObjectByName(i),e.maxNode=t.getObjectByName(n),!e.minNode)return void console.warn(`Could not find ${i} in the model`);if(!e.maxNode)return void console.warn(`Could not find ${n} in the model`)}e.valueNode=t.getObjectByName(s),e.valueNode||console.warn(`Could not find ${s} in the model`)}))}))}(e.motionController,t),e.envMap&&t.traverse((t=>{t.isMesh&&(t.material.envMap=e.envMap,t.material.needsUpdate=!0)})),e.add(t)}class xe{constructor(e=null){this.gltfLoader=e,this.path="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",this._assetCache={},this.gltfLoader||(this.gltfLoader=new f)}createControllerModel(e){const t=new Se;let s=null;return e.addEventListener("connected",(e=>{const i=e.data;"tracked-pointer"===i.targetRayMode&&i.gamepad&&Ce(i,this.path,"generic-trigger").then((({profile:e,assetPath:n})=>{t.motionController=new _e(i,e,n);const l=this._assetCache[t.motionController.assetUrl];if(l)s=l.scene.clone(),Ae(t,s);else{if(!this.gltfLoader)throw new Error("GLTFLoader not set.");this.gltfLoader.setPath(""),this.gltfLoader.load(t.motionController.assetUrl,(e=>{this._assetCache[t.motionController.assetUrl]=e,s=e.scene.clone(),Ae(t,s)}),null,(()=>{throw new Error(`Asset ${t.motionController.assetUrl} missing or malformed.`)}))}})).catch((e=>{console.warn(e)}))})),e.addEventListener("disconnected",(()=>{t.motionController=null,t.remove(s),s=null})),t}}class ke extends THREE.EventDispatcher{constructor(e){if(super(),void 0===e)return void console.error("ControllerGestures must be passed a renderer");const t=new THREE.Clock;this.controller1=e.xr.getController(0),this.controller1.userData.gestures={index:0},this.controller1.userData.selectPressed=!1,this.controller1.addEventListener("selectstart",i),this.controller1.addEventListener("selectend",n),this.controller2=e.xr.getController(1),this.controller2.userData.gestures={index:1},this.controller2.userData.selectPressed=!1,this.controller2.addEventListener("selectstart",i),this.controller2.addEventListener("selectend",n),this.doubleClickLimit=.2,this.pressMinimum=.4,this.right=new THREE.Vector3(1,0,0),this.up=new THREE.Vector3(0,1,0),this.type="unknown",this.prevTap="none",this.clock=t;const s=this;function i(){const e=this.userData.gestures;e.startPosition=void 0,e.startTime=t.getElapsedTime(),-1==s.type.indexOf("tap")&&(e.taps=0),s.type="unknown",this.userData.selectPressed=!0}function n(){const e=this.userData.gestures;e.endTime=t.getElapsedTime();e.endTime-e.startTime.05&&(e.startPosition=this.controller1.position.clone())),this.controller2.userData.selectPressed&&void 0===t.startPosition&&(i=s-t.startTime,i>.05&&(t.startPosition=this.controller2.position.clone())),!this.controller1.userData.selectPressed&&"tap"===this.type&&(i=this.clock.getElapsedTime()-e.endTime,i>this.doubleClickLimit)){switch(e.taps){case 1:self.prevTap="tap";break;case 2:this.dispatchEvent({type:"doubletap",position:this.controller1.position,matrixWorld:this.controller1.matrixWorld}),self.prevTap="doubletap"}this.type="unknown",e.taps=0}if("unknown"===this.type&&this.touch)"doubletap"==self.prevTap?(this.type="pinch",this.startDistance=this.controller1.position.distanceTo(this.controller2.position),this.dispatchEvent({type:"pinch",delta:new THREE.Vector3(0,0,0),scale:1,initialise:!0})):(this.type="pan",this.startPosition=this.controller1.position.clone(),this.dispatchEvent({type:"pan",delta:new THREE.Vector3(0,0,0),initialise:!0}));else if(("pinch"===this.type||"pan"===this.type)&&"doubletap"==self.prevTap&&this.controller2.position){const e=this.controller1.position.distanceTo(this.controller2.position)/this.startDistance,t=this.controller1.position.clone().sub(this.startPosition);this.dispatchEvent({type:"pinch",delta:t,scale:e})}}}class Oe{constructor(e,t){this.config=void 0===t?{panelSize:{width:1,height:1},width:512,height:512,opacity:.7,body:{fontFamily:"Arial",fontSize:30,padding:20,backgroundColor:"#000",fontColor:"#fff",borderRadius:6}}:t,void 0===this.config.width&&(this.config.width=512),void 0===this.config.height&&(this.config.height=512),void 0===this.config.body&&(this.config.body={fontFamily:"Arial",size:30,padding:20,backgroundColor:"#000",fontColor:"#fff",borderRadius:6});const s=this.config.body;void 0===s.borderRadius&&(s.borderRadius=6),void 0===s.fontFamily&&(s.fontFamily="Arial"),void 0===s.padding&&(s.padding=20),void 0===s.fontSize&&(s.fontSize=30),void 0===s.backgroundColor&&(s.backgroundColor="#000"),void 0===s.fontColor&&(s.fontColor="#fff"),Object.entries(this.config).forEach((([e,t])=>{if(!("object"!=typeof t||"panelSize"===e||t instanceof THREE.WebGLRenderer||t instanceof THREE.Scene)){const e=void 0!==t.position?t.position:{x:0,y:0};void 0!==e.left&&void 0===e.x&&(e.x=e.left),void 0!==e.top&&void 0===e.y&&(e.y=e.top);const s=void 0!==t.width?t.width:this.config.width,i=void 0!==t.height?t.height:this.config.height;void 0!==e.right&&void 0===e.x&&(e.x=this.config.width-e.right-s),void 0!==e.bottom&&void 0===e.y&&(e.y=this.config.height-e.bottom-i),void 0===e.x&&(e.x=0),void 0===e.y&&(e.y=0),t.position=e,void 0===t.type&&(t.type="text")}}));const i=this.createOffscreenCanvas(this.config.width,this.config.height);this.context=i.getContext("2d"),this.context.save();const n=void 0!==this.config.opacity?this.config.opacity:.7,l=new THREE.MeshBasicMaterial({transparent:!0,opacity:n});this.panelSize=void 0!==this.config.panelSize?this.config.panelSize:{width:1,height:1};const r=new THREE.PlaneGeometry(this.panelSize.width,this.panelSize.height);this.mesh=new THREE.Mesh(r,l),this.texture=new THREE.CanvasTexture(i),this.mesh.material.map=this.texture,this.scene=this.config.scene;if(Object.values(this.config).filter((e=>"input-text"===e.type)).length>0){this.keyboard=new Re(this.panelSize.width,this.config.renderer);this.keyboard.mesh.position.set(0,-.3,.2),this.mesh.add(this.keyboard.mesh)}if(void 0===e)this.content={body:""},this.config.body.type="text";else{this.content=e;Object.values(t).filter((e=>"button"===e.type||"scroll"===e.overflow||"input-text"===e.type)).length>0&&(void 0===t||void 0===t.renderer?console.warn("CanvasUI: button, scroll or input-text in the config but no renderer"):(this.renderer=t.renderer,this.initControllers()))}this.selectedElements=[void 0,void 0],this.selectPressed=[!1,!1],this.scrollData=[void 0,void 0],this.intersects=[void 0,void 0],this.needsUpdate=!0,this.update()}getIntersectY(e){const t=this.config.height||512,s=this.intersects[e];return void 0===s||void 0===s.uv?0:(1-s.uv.y)*t}initControllers(){this.vec3=new THREE.Vector3,this.mat4=new THREE.Matrix4,this.raycaster=new THREE.Raycaster;const e=this;function t(t){const s=t.target===e.controller?0:1,i=e.selectedElements[s];if(void 0!==i)if("button"==i.type)e.select(s);else if("input-text"==i.type&&e.keyboard)if(e.keyboard.visible)e.keyboard.linkedUI=void 0,e.keyboard.linkedText=void 0,e.keyboard.linkedElement=void 0,e.keyboard.visible=!1;else{let t;e.keyboard.linkedUI=e,Object.entries(e.config).forEach((([e,s])=>{s==i&&(t=e)}));const s=(.5-(i.position.y+i.height+e.config.body.padding)/e.config.height)*e.panelSize.height,n=Math.max(e.panelSize.width,e.panelSize.height)/2;e.keyboard.position.set(0,-n/1.5-s,.1),e.keyboard.linkedText=e.content[t],e.keyboard.linkedName=t,e.keyboard.linkedElement=i,e.keyboard.visible=!0}}function s(t){const s=t.target===e.controller?0:1;if(e.selectPressed[s]=!0,void 0!==e.selectedElements[s]&&"scroll"==e.selectedElements[s].overflow){const t=e.selectedElements[s];e.scrollData[s]={scrollY:t.scrollY,rayY:e.getIntersectY(s)}}}function i(t){const s=t.target===e.controller?0:1;e.selectPressed[s]=!1,void 0!==e.selectedElements[s]&&"scroll"==e.selectedElements[s].overflow&&(e.scrollData[s]=void 0)}if(this.controller=this.renderer.xr.getController(0),this.controller.addEventListener("select",t),this.controller.addEventListener("selectstart",s),this.controller.addEventListener("selectend",i),this.controller1=this.renderer.xr.getController(1),this.controller1.addEventListener("select",t),this.controller1.addEventListener("selectstart",s),this.controller1.addEventListener("selectend",i),this.scene){const e=.015,t=new THREE.IcosahedronBufferGeometry(e),s=new THREE.MeshBasicMaterial({color:170}),i=new THREE.Mesh(t,s);i.visible=!1,this.scene.add(i);const n=new THREE.Mesh(t,s);n.visible=!1,this.scene.add(n),this.intersectMesh=[i,n]}}setClip(e){const t=this.context;if(t.restore(),t.save(),void 0!==e.clipPath){const s=new Path2D(e.clipPath);t.clip(s)}else{const s=void 0!==e.position?e.position:{x:0,y:0},i=e.borderRadius||0,n=e.width||this.config.width,l=e.height||this.config.height;if(t.beginPath(),0!==i){const e=Math.PI/2;t.moveTo(s.x+i,s.y),t.arc(s.x+i,s.y+i,i,e,2*e,!0),t.lineTo(s.x,s.y+l-i),t.arc(s.x+i,s.y+l-i,i,0,e,!0),t.lineTo(s.x+n-i,s.y+l),t.arc(s.x+n-i,s.y+l-i,i,3*e,4*e,!0),t.lineTo(s.x+n,s.y+i),t.arc(s.x+n-i,s.y+i,i,2*e,3*e,!0),t.closePath(),t.clip()}else t.rect(s.x,s.y,n,l),t.clip()}}setPosition(e,t,s){void 0!==this.mesh&&this.mesh.position.set(e,t,s)}setRotation(e,t,s){void 0!==this.mesh&&this.mesh.rotation.set(e,t,s)}updateElement(e,t){let s=this.content[e];void 0!==s?("object"==typeof s?s.content=t:s=t,this.content[e]=s,this.needsUpdate=!0):console.warn(`CanvasGUI.updateElement: No ${e} found`)}get panel(){return this.mesh}getElementAtLocation(e,t){const s=this,i=Object.entries(this.config).filter((([i,n])=>{if(!("object"!=typeof n||"panelSize"===i||"body"===i||n instanceof THREE.WebGLRenderer||n instanceof THREE.Scene)){const i=n.position,l=void 0!==n.width?n.width:s.config.width,r=void 0!==n.height?n.height:s.config.height;return e>=i.x&&e=i.y&&t0?(this.hover(t,s[0].uv),this.intersects[t]=s[0],this.scroll(t)):(this.hover(t),this.intersects[t]=void 0,this.scroll(t))}update(){if(void 0===this.mesh)return;if(this.controller&&this.handleController(this.controller,0),this.controller1&&this.handleController(this.controller1,1),this.keyboard&&this.keyboard.visible&&this.keyboard.update(),!this.needsUpdate)return;let e=this.context;e.clearRect(0,0,this.config.width,this.config.height);const t=this.config.body.backgroundColor?this.config.body.backgroundColor:"#000";!this.config.body.fontFamily||this.config.body.fontFamily;const s=this.config.body.fontColor?this.config.body.fontColor:"#fff";!this.config.body.fontSize||this.config.body.fontSize,this.setClip(this.config.body),e.fillStyle=t,e.fillRect(0,0,this.config.width,this.config.height);const i=this;Object.entries(this.content).forEach((([t,n])=>{const l=void 0!==i.config[t]?i.config[t]:i.config.body;if("none"!==(void 0!==l.display?l.display:"block")){const r=void 0!==l.position?l.position:{x:0,y:0},o=void 0!==l.width?l.width:i.config.width,a=void 0!==l.height?l.height:i.config.height;"button"!=l.type||n.toLowerCase().startsWith("")||(void 0===l.borderRadius&&(l.borderRadius=6),void 0===l.textAlign&&(l.textAlign="center")),i.setClip(l);const d=n.toLowerCase().startsWith(""),c=void 0!==i.selectedElements[0]&&this.selectedElements[0]===l||void 0!==i.selectedElements[1]&&this.selectedElements[1]===l;if(void 0!==l.backgroundColor&&(c&&"button"==l.type&&void 0!==l.hover?e.fillStyle=l.hover:e.fillStyle=l.backgroundColor,e.fillRect(r.x,r.y,o,a)),"text"==l.type||"button"==l.type||"input-text"==l.type){let h=!1;if(c?(d||"button"!=l.type?e.fillStyle=void 0!==l.hover?l.hover:void 0!==l.fontColor?l.fontColor:s:e.fillStyle=void 0!==l.fontColor?l.fontColor:s,h=void 0===l.hover):e.fillStyle=void 0!==l.fontColor?l.fontColor:s,d){const t=n.toUpperCase().substring(6,n.length-7);e.save(),e.translate(r.x,r.y);const s=new Path2D(t);e.fill(s),e.restore()}else i.wrapText(t,n);h&&(e.beginPath(),e.strokeStyle="#fff",e.lineWidth=2,e.rect(r.x,r.y,o,a),e.stroke())}else if("img"==l.type)if(void 0===l.img)this.loadImage(n).then((e=>{console.log(`w: ${e.width} | h: ${e.height}`),l.img=e,i.needsUpdate=!0,i.update()})).catch((e=>console.error(e)));else{const t=o/(l.img.width/l.img.height);e.drawImage(l.img,r.x,r.y,o,t)}}})),this.needsUpdate=!1,this.texture.needsUpdate=!0}loadImage(e){return new Promise(((t,s)=>{const i=new THREE.Image;i.addEventListener("load",(()=>t(i))),i.addEventListener("error",(e=>s(e))),i.src=e}))}createOffscreenCanvas(e,t){const s=document.createElement("canvas");return s.width=e,s.height=t,s}fillRoundedRect(e,t,s,i,n){const l=this.context;l.beginPath(),l.moveTo(e+n,t),l.lineTo(e+s-n,t),l.quadraticCurveTo(e+s,t,e+s,t+n),l.lineTo(e+s,t+i-n),l.quadraticCurveTo(e+s,t+i,e+s-n,t+i),l.lineTo(e+n,t+i),l.quadraticCurveTo(e,t+i,e,t+i-n),l.lineTo(e,t+n),l.quadraticCurveTo(e,t,e+n,t),l.closePath(),l.fill()}lookAt(e){void 0!==this.mesh&&(e instanceof Vector3?this.mesh.lookAt(e):console.error("CanvasUI lookAt called parameter not a THREE.Vector3"))}get visible(){return void 0!==this.mesh&&this.mesh.visible}set visible(e){this.mesh&&(this.mesh.visible=e)}get position(){if(void 0!==this.mesh)return this.mesh.position}set position(e){void 0!==this.mesh&&(e instanceof Vector3?this.mesh.position.copy(e):console.error("CanvasUI trying to set the mesh position using a parameter that is not a THREE.Vector3"))}get quaternion(){if(void 0!==this.mesh)return this.mesh.quaternion}set quaternion(e){void 0!==this.mesh&&(e instanceof QUaternion?this.mesh.quaternion.copy(e):console.error("CanvasUI trying to set the mesh quaternion using a parameter that is not a THREE.Quaternion"))}wrapText(e,t){const s=t.split(" ");let i="";const n=[],l=void 0!==this.config[e]?this.config[e]:this.config.body,r=void 0!==l.width?l.width:this.config.width,o=void 0!==l.height?l.height:this.config.height,a=void 0!==l.position?l.position:{x:0,y:0},d=void 0!==l.padding?l.padding:void 0!==this.config.body.padding?this.config.body.padding:10,c=void 0!==l.paddingTop?l.paddingTop:d,h=void 0!==l.paddingLeft?l.paddingLeft:d,p=void 0!==l.paddingBottom?l.paddingBottom:d,m=void 0!==l.paddingRight?l.paddingRight:d,u={x:a.x+h,y:a.y+c,width:r-h-m,height:o-c-p},g=void 0!==l.textAlign?l.textAlign:void 0!==this.config.body.textAlign?this.config.body.textAlign:"left",f=void 0!==l.fontSize?l.fontSize:void 0!==this.config.body.fontSize?this.config.body.fontSize:30,b=void 0!==l.fontFamily?l.fontFamily:void 0!==this.config.body.fontFamily?this.config.body.fontFamily:"Arial",C=f+(void 0!==l.leading?l.leading:void 0!==this.config.body.leading?this.config.body.leading:8),y=this.context;y.textAlign=g,y.font=`${f}px '${b}'`,s.forEach((function(e){let t=s.length>1?`${i}${e} `:e,l=y.measureText(t);if(l.width>u.width&&e.length>1)if(0==i.length&&l.width>u.width){for(;l.width>u.width;){let s=0;do{s++,t=e.substr(0,s),l=y.measureText(t)}while(l.widthu.height&&"scroll"===l.overflow){void 0===l.scrollY&&(l.scrollY=0);const e=void 0!==l.fontColor?l.fontColor:this.config.body.fontColor;y.fillStyle="#aaa",this.fillRoundedRect(a.x+r-12,a.y,12,o,6),y.fillStyle="#666";const t=u.height/v,s=t*o,i=-l.scrollY*t;this.fillRoundedRect(a.x+r-12,a.y+i,12,s,6),y.fillStyle=e,w=l.scrollY,l.minScrollY=u.height-v}let _,S=w+u.y+f/2;switch(g){case"center":_=u.x+u.width/2;break;case"right":_=u.x+u.width;break;default:_=u.x}n.forEach((e=>{S+C>0&&y.fillText(e,_,S),S+=C}))}}class Re{constructor(e,t,s="EN"){const i=this.getConfig(s);i.panelSize={width:e,height:.5*e},i.height=256,i.body={backgroundColor:"#555"},i.renderer=t;const n=this.getContent(s);this.keyboard=new Oe(n,i),this.keyboard.mesh.visible=!1,this.shift=!1}get mesh(){return this.keyboard.mesh}getConfig(e){const t={};let s=10;const i=39.2,n=49,l="#333",r="#000";let o=s,a=s;for(let e=0;e<10;e++){const d={type:"button",position:{x:a,y:o},width:i,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e)};t[`btn${e}`]=d,a+=49.2}o+=59,a=s;for(let e=0;e<10;e++){const d={type:"button",position:{x:a,y:o},width:i,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+10)};t[`btn${e+10}`]=d,a+=49.2}o+=59,a=s;for(let e=0;e<9;e++){const d=0==e||8==e?1.5*i+5:i,c={type:"button",position:{x:a,y:o},width:d,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+20)};t[`btn${e+20}`]=c,a+=d+s}o+=59,a=s;for(let e=0;e<5;e++){const d=0==e||4==e?88.4:2==e?186.8:i,c={type:"button",position:{x:a,y:o},width:d,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+30)};0==e&&(c.fontSize=20),t[`btn${e+30}`]=c,a+=d+s}return t}getContent(e,t=0){let s,i={};switch(this.language=e,this.keyboardIndex=t,t){case 0:s=["q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","@","⇧","z","x","c","v","b","n","m","⇦","","?123",","," ",".","↲"];for(let e=0;e","_","`","~",":",";","⇦","","abc",","," ",".","↲"];for(let e=0;e=0;e--){let s=t.scene.children[e];t.scene.remove(s)}else t.scene=new THREE.Scene;if(void 0!==t.scene_ghost)for(let e=t.scene_ghost.children.length-1;e>=0;e--){let s=t.scene_ghost.children[e];t.scene_ghost.remove(s)}else t.scene_ghost=new THREE.Scene;if(""!=s.htmlCls.setHtmlCls.getCookie("shininess")){let e=parseFloat(s.htmlCls.setHtmlCls.getCookie("shininess"));t.shininess!=e&&s.htmlCls.clickMenuCls.setLogCmd("set shininess "+e,!0),t.shininess=e}if(!s.bNode&&""!=s.htmlCls.setHtmlCls.getCookie("light1")){let e=parseFloat(s.htmlCls.setHtmlCls.getCookie("light1")),i=parseFloat(s.htmlCls.setHtmlCls.getCookie("light2")),n=parseFloat(s.htmlCls.setHtmlCls.getCookie("light3"));t.light1==e&&t.light2==i&&t.light3==n||s.htmlCls.clickMenuCls.setLogCmd("set light | light1 "+e+" | light2 "+i+" | light3 "+n,!0),t.light1=e,t.light2=i,t.light3=n}t.directionalLight=new THREE.DirectionalLight(16777215,t.light1),t.directionalLight2=new THREE.DirectionalLight(16777215,t.light2),t.directionalLight3=new THREE.DirectionalLight(16777215,t.light3),t.cam_z>0?(t.directionalLight.position.set(-1,1,1),t.directionalLight2.position.set(1,1,1),t.directionalLight3.position.set(1,1,-1),t.lightPos=new THREE.Vector3(-1,1,1),t.lightPos2=new THREE.Vector3(1,1,1),t.lightPos3=new THREE.Vector3(1,1,-1)):(t.directionalLight.position.set(-1,1,-1),t.directionalLight2.position.set(1,1,-1),t.directionalLight3.position.set(1,1,1),t.lightPos=new THREE.Vector3(-1,1,-1),t.lightPos2=new THREE.Vector3(1,1,-1),t.lightPos3=new THREE.Vector3(1,1,1));let i=new THREE.AmbientLight(8947848);if(t.scene.add(t.directionalLight),t.scene.add(i),void 0!==t.mdl)for(let e=t.mdl.children.length-1;e>=0;e--){let s=t.mdl.children[e];s.geometry&&s.geometry.dispose(),s.material&&s.material.dispose(),t.mdl.remove(s)}if(void 0!==t.mdlImpostor){for(let e=t.mdlImpostor.children.length-1;e>=0;e--){let s=t.mdlImpostor.children[e];s.geometry&&s.geometry.dispose(),s.material&&s.material.dispose(),t.mdlImpostor.remove(s)}t.mdlImpostor.children.length=0}s.bNode||t.renderer.renderLists.dispose(),t.mdl=new THREE.Object3D,t.mdlImpostor=new THREE.Object3D,t.scene.add(t.mdl),t.scene.add(t.mdlImpostor),t.mdl_ghost=new THREE.Object3D,t.scene_ghost.add(t.mdl_ghost),t.objects=[],t.objects_ghost=[],t.raycaster=new THREE.Raycaster,t.projector=new THREE.Projector,t.mouse=new THREE.Vector2;let n=s.parasCls.backgroundColors[t.opts.background.toLowerCase()];s.bNode||("transparent"===t.opts.background.toLowerCase()?t.renderer.setClearColor(n,0):t.renderer.setClearColor(n,1)),t.perspectiveCamera=new THREE.PerspectiveCamera(20,t.container.whratio,.1,1e4),t.perspectiveCamera.position.set(0,0,t.cam_z),t.perspectiveCamera.lookAt(new THREE.Vector3(0,0,0)),t.orthographicCamera=new THREE.OrthographicCamera,t.orthographicCamera.position.set(0,0,t.cam_z),t.orthographicCamera.lookAt(new THREE.Vector3(0,0,0)),t.cams={perspective:t.perspectiveCamera,orthographic:t.orthographicCamera}}setVrAr(){let e=this.icn3d;e.icn3dui;let t=this;e.bSetVrAr=!0,e.bVr?(e.canvasUI=this.createUI(),e.raycasterVR=new THREE.Raycaster,e.workingMatrix=new THREE.Matrix4,e.workingVector=new THREE.Vector3,e.origin=new THREE.Vector3,e.dolly=new THREE.Object3D,e.dolly.position.z=5,e.dolly.add(e.cam),e.scene.add(e.dolly),e.dollyId=e.dolly.id,e.dummyCam=new THREE.Object3D,e.cam.add(e.dummyCam),e.clock=new THREE.Clock,e.controllers=this.getControllers(),e.controllers.forEach((s=>{s.addEventListener("connected",(function(e){try{const s={},i="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",n="generic-trigger";Ce(e.data,i,n).then((({profile:i,assetPath:n})=>{s.name=i.profileId,s.targetRayMode=e.data.targetRayMode,Object.entries(i.layouts).forEach((([e,t])=>{const i={};Object.values(t.components).forEach((e=>{i[e.rootNodeName]=e.gamepadIndices})),s[e]=i})),t.updateControllers(s)}))}catch(e){}})),s.addEventListener("disconnected",(function(){this.remove(this.children[0]),e.controllers.forEach((e=>{}))}))}))):e.bAr&&(e.gestures=new ke(e.renderer),e.scene.add(e.gestures.controller1),e.scene.add(e.gestures.controller2),e.gestures.addEventListener("doubletap",(e=>{t.positionCenter()})),e.gestures.addEventListener("pinch",(s=>{if(void 0!==s.initialise)t.startPosition=e.mdl.position.clone(),t.startScale=e.mdl.scale.clone();else{let i=1;const n=t.startScale.clone().multiplyScalar(s.scale*i);e.mdl.scale.copy(n)}})))}positionCenter(){let e=this.icn3d;e.icn3dui;const t=e.gestures.controller1;e.mdl.position.set(-.06,0,-.6).applyMatrix4(t.matrixWorld),e.mdl.scale.copy(new THREE.Vector3(.005,.005,.005))}setVrArButtons(){let e=this.icn3d,t=e.icn3dui;e.bSetVrArButtons=!0,t.bNode||($("#"+t.pre+"VRButton").remove(),$("#"+t.pre+"viewer").get(0).appendChild(e.VRButtonCls.createButton(e.renderer)),$("#"+t.pre+"ARButton").remove(),$("#"+t.pre+"viewer").get(0).appendChild(e.ARButtonCls.createButton(e.renderer)))}updateControllers(e){this.icn3d.icn3dui,this.addEventForController(e,"right"),this.addEventForController(e,"left")}addEventForController(e,t){let s=this.icn3d;s.icn3dui;const i="right"==t?s.renderer.xr.getController(0):s.renderer.xr.getController(1),n="right"==t?e.right:e.left;if(void 0!==n){let e=!1,t=!1;Object.keys(n).forEach((i=>{-1!=i.indexOf("trigger")&&(e=!0),-1!=i.indexOf("squeeze")&&(t=!0),-1==i.indexOf("thumbstick")&&-1==i.indexOf("touchpad")||(s.xAxisIndex=n[i].xAxis,s.yAxisIndex=n[i].yAxis)})),e&&(i.addEventListener("selectstart",(function(){this.userData.selectPressed=!0})),i.addEventListener("selectend",(function(){this.userData.selectPressed=!1,this.userData.selected=void 0}))),t&&(i.addEventListener("squeezestart",(function(){this.userData.squeezePressed=!0,s.cam.add(s.canvasUI.mesh)})),i.addEventListener("squeezeend",(function(){this.userData.squeezePressed=!1,s.cam.remove(s.canvasUI.mesh)})))}}createUI(){let e=this.icn3d;e.icn3dui;let t=94,s=50,i=44,n=12,l="#1c94c4",r="#ccc",o="#fbcb09";const a={panelSize:{width:2,height:1.2},height:300,select:{type:"button",position:{top:6,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},residue:{type:"button",position:{top:6,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.pk=2,e.cam.remove(e.canvasUI.mesh)}},secondarySelect:{type:"button",position:{top:6,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.pk=3,e.cam.remove(e.canvasUI.mesh)}},chainSelect:{type:"button",position:{top:6,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.pk=5,e.cam.remove(e.canvasUI.mesh)}},style:{type:"button",position:{top:62,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},ribbon:{type:"button",position:{top:62,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","ribbon"),e.setOptionCls.setStyle("nucleotides","nucleotide cartoon"),e.cam.remove(e.canvasUI.mesh)}},schematic:{type:"button",position:{top:62,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","schematic"),e.setOptionCls.setStyle("nucleotides","schematic"),e.cam.remove(e.canvasUI.mesh)}},stick:{type:"button",position:{top:62,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","stick"),e.setOptionCls.setStyle("nucleotides","stick"),e.cam.remove(e.canvasUI.mesh)}},sphere:{type:"button",position:{top:62,left:406},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","sphere"),e.setOptionCls.setStyle("nucleotides","sphere"),e.cam.remove(e.canvasUI.mesh)}},color:{type:"button",position:{top:118,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},rainbow:{type:"button",position:{top:118,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","rainbow for chains"),e.cam.remove(e.canvasUI.mesh)}},atomColor:{type:"button",position:{top:118,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","atom"),e.cam.remove(e.canvasUI.mesh)}},secondaryColor:{type:"button",position:{top:118,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","secondary structure green"),e.cam.remove(e.canvasUI.mesh)}},AlphaFold:{type:"button",position:{top:118,left:406},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","confidence"),e.cam.remove(e.canvasUI.mesh)}},unicolor:{type:"button",position:{top:174,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},red:{type:"button",position:{top:168,left:100},width:i,height:s,fontColor:"red",hover:o,onSelect:function(){e.setOptionCls.setOption("color","red"),e.cam.remove(e.canvasUI.mesh)}},green:{type:"button",position:{top:168,left:150},width:i,height:s,fontColor:"green",hover:o,onSelect:function(){e.setOptionCls.setOption("color","green"),e.cam.remove(e.canvasUI.mesh)}},blue:{type:"button",position:{top:168,left:200},width:i,height:s,fontColor:"blue",hover:o,onSelect:function(){e.setOptionCls.setOption("color","blue"),e.cam.remove(e.canvasUI.mesh)}},magenta:{type:"button",position:{top:168,left:250},width:i,height:s,fontColor:"magenta",hover:o,onSelect:function(){e.setOptionCls.setOption("color","magenta"),e.cam.remove(e.canvasUI.mesh)}},orange:{type:"button",position:{top:168,left:300},width:i,height:s,fontColor:"orange",hover:o,onSelect:function(){e.setOptionCls.setOption("color","FFA500"),e.cam.remove(e.canvasUI.mesh)}},cyan:{type:"button",position:{top:168,left:350},width:i,height:s,fontColor:"cyan",hover:o,onSelect:function(){e.setOptionCls.setOption("color","cyan"),e.cam.remove(e.canvasUI.mesh)}},gray:{type:"button",position:{top:168,left:400},width:i,height:s,fontColor:"gray",hover:o,onSelect:function(){e.setOptionCls.setOption("color","888888"),e.cam.remove(e.canvasUI.mesh)}},white:{type:"button",position:{top:168,left:450},width:i,height:s,fontColor:"white",hover:o,onSelect:function(){e.setOptionCls.setOption("color","white"),e.cam.remove(e.canvasUI.mesh)}},analysis:{type:"button",position:{top:230,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},interaction:{type:"button",position:{top:230,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){try{e.viewInterPairsCls.viewInteractionPairs(["selected"],["non-selected"],!1,"3d",1,1,1,1,1,1),e.cam.remove(e.canvasUI.mesh)}catch(e){}}},removeLabel:{type:"button",position:{top:230,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){for(let t in e.labels)e.labels[t]=[];e.drawCls.draw(),e.cam.remove(e.canvasUI.mesh)}},reset:{type:"button",position:{top:230,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.selectionCls.resetAll(),e.cam.remove(e.canvasUI.mesh)}},renderer:e.renderer},d=new Oe({select:"Select",residue:"Residue",secondarySelect:"SSE",chainSelect:"Chain",style:"Style",ribbon:"Ribbon",schematic:"Schem.",stick:"Stick",sphere:"Sphere",color:"Color",rainbow:"Rainbow",atomColor:"Atom",secondaryColor:"SSE",AlphaFold:"AlphaFold",unicolor:"UniColor",red:"M 50 15 L 15 15 L 15 50 L 50 50 Z",green:"M 50 15 L 15 15 L 15 50 L 50 50 Z",blue:"M 50 15 L 15 15 L 15 50 L 50 50 Z",magenta:"M 50 15 L 15 15 L 15 50 L 50 50 Z",orange:"M 50 15 L 15 15 L 15 50 L 50 50 Z",cyan:"M 50 15 L 15 15 L 15 50 L 50 50 Z",gray:"M 50 15 L 15 15 L 15 50 L 50 50 Z",white:"M 50 15 L 15 15 L 15 50 L 50 50 Z",analysis:"Analysis",interaction:"Interact",removeLabel:"No Label",reset:"Reset"},a);return d.mesh.position.set(0,0,-3),d}createUILog(){let e=this.icn3d;e.icn3dui;const t={panelSize:{width:2,height:2},height:512,info:{type:"text",overflow:"scroll",position:{top:6,left:6},width:506,height:506,backgroundColor:"#aaa",fontColor:"#000"},renderer:e.renderer},s=new Oe({info:"Debug info"},t);return s.mesh.position.set(0,-1,-2),s}getControllers(){let e=this.icn3d;e.icn3dui;const t=new xe,s=(new THREE.BufferGeometry).setFromPoints([new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,-1)]),i=new THREE.Line(s);i.name="line",i.scale.z=50;const n=[];for(let s=0;s<=1;s++){const l=e.renderer.xr.getController(s);e.dolly.add(l),l.add(i.clone()),l.userData.selectPressed=!1,e.cam.add(l),n.push(l);const r=e.renderer.xr.getControllerGrip(s);r.add(t.createControllerModel(r)),e.scene.add(r)}return n}}class Ie{constructor(e){this.icn3d=e}setCamera(){let e=this.icn3d,t=e.icn3dui;if(e.bControlGl&&!t.bNode){window.cam=e.cams[e.opts.camera.toLowerCase()];let s=e.maxD;if(window.cam===e.perspectiveCamera){let i=void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>e.maxatomcnt;i?window.camMaxDFactor=1:void 0!==window.camMaxDFactorFog?window.camMaxDFactor=window.camMaxDFactorFog:window.camMaxDFactor=3,window.cam_z>0?window.cam.position.z=s*window.camMaxDFactor:window.cam.position.z=-s*window.camMaxDFactor,"yes"===e.opts.slab?i?window.cam.near=.1:void 0!==window.camMaxDFactorFog?window.cam.near=s*window.camMaxDFactorFog-10:window.cam.near=s*window.camMaxDFactor:window.cam.near=.1,window.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.TrackballControls(window.cam,void 0,e):t.bNode?e.controls=new THREE.TrackballControls(e.cam,document,e):e.controls=new THREE.TrackballControls(e.cam,document.getElementById(e.id),e)}else window.cam===e.orthographicCamera&&(void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>10*e.maxatomcnt?window.cam.right=e.maxD/2*1.5:window.cam.right=e.maxD/2*2.5,window.cam.left=-window.cam.right,window.cam.top=window.cam.right/e.container.whratio,window.cam.bottom=-window.cam.right/e.container.whratio,"yes"===e.opts.slab?window.cam.near=2*e.maxD:window.cam.near=0,window.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.OrthographicTrackballControls(window.cam,void 0,e):t.bNode?e.controls=new THREE.OrthographicTrackballControls(e.cam,document,e):e.controls=new THREE.OrthographicTrackballControls(e.cam,document.getElementById(e.id),e));window.cam.updateProjectionMatrix()}e.cam=e.cams[e.opts.camera.toLowerCase()];let s=e.maxD;if(e.cam===e.perspectiveCamera){let i=void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>e.maxatomcnt;i?e.camMaxDFactor=1:void 0!==e.camMaxDFactorFog?e.camMaxDFactor=e.camMaxDFactorFog:e.camMaxDFactor=3,e.cam_z>0?e.cam.position.z=s*e.camMaxDFactor:e.cam.position.z=-s*e.camMaxDFactor,"yes"===e.opts.slab?i?e.cam.near=.1:void 0!==e.camMaxDFactorFog?e.cam.near=s*e.camMaxDFactorFog-10:e.cam.near=s*e.camMaxDFactor:e.cam.near=.1,e.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.TrackballControls(e.cam,void 0,e):t.bNode?e.controls=new THREE.TrackballControls(e.cam,document,e):e.controls=new THREE.TrackballControls(e.cam,document.getElementById(e.id),e)}else e.cam===e.orthographicCamera&&(void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>10*e.maxatomcnt?e.cam.right=e.maxD/2*1.5:e.cam.right=e.maxD/2*2.5,e.cam.left=-e.cam.right,e.cam.top=e.cam.right/e.container.whratio,e.cam.bottom=-e.cam.right/e.container.whratio,"yes"===e.opts.slab?e.cam.near=2*e.maxD:e.cam.near=0,e.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.OrthographicTrackballControls(e.cam,void 0,e):t.bNode?e.controls=new THREE.OrthographicTrackballControls(e.cam,document,e):e.controls=new THREE.OrthographicTrackballControls(e.cam,document.getElementById(e.id),e));e.cam.updateProjectionMatrix()}}class Te{constructor(e){this.icn3d=e}setFog(e){let t=this.icn3d,s=t.icn3dui.parasCls.backgroundColors[t.opts.background.toLowerCase()];if(e){let e=t.applyCenterCls.centerAtoms(t.hAtoms);t.maxD=e.maxD,t.maxD<25&&(t.maxD=25)}let i=void 0!==t.biomtMatrices&&t.biomtMatrices.length*t.cnt>t.maxatomcnt;if("yes"===t.opts.fog)if("perspective"===t.opts.camera)if(i)t.scene.fog=void 0,t.bSetFog=!1;else{let e=t._zoomFactor>1?1*t._zoomFactor:t._zoomFactor;t.scene.fog=new THREE.Fog(s,2.5*t.maxD*e,4*t.maxD*e),t.bSetFog=!0,t.camMaxDFactorFog=3}else"orthographic"===t.opts.camera&&(t.scene.fog=void 0,t.bSetFog=!1);else t.scene.fog=void 0,t.bSetFog=!1}}class Me{constructor(e){this.icn3d=e}createBox(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(o.bNode)return;void 0===t&&(t=.8),void 0===s&&(s=!1),void 0===i&&(i=.8),l?void 0===n&&(n=r.hColor):void 0===n&&(n=e.color);let a=s?t:(o.parasCls.vdwRadii[e.elem.toUpperCase()]||t)*(i||1);this.createBox_base(e.coord,a,n,l)}createBox_base(e,t,s,i,n,l,r){let o,a=this.icn3d;a.icn3dui.bNode||(void 0===r&&(r=l?.5:1),new THREE.BoxGeometry(1,1,1),o=new THREE.Mesh(a.boxGeometry,new THREE.MeshPhongMaterial({transparent:!0,opacity:r,specular:a.frac,shininess:a.shininess,emissive:a.emissive,color:s})),o.scale.x=o.scale.y=o.scale.z=t,o.position.copy(e),a.mdl.add(o),i?a.prevHighlightObjects.push(o):n?a.prevOtherMesh.push(o):a.objects.push(o))}createBoxRepresentation_P_CA(e,t,s){let i=this.icn3d;if(i.icn3dui.bNode)return;let n=this;i.reprSubCls.createRepresentationSub(e,(function(e){"CA"!==e.name&&"O3'"!==e.name&&"O3*"!==e.name||n.createBox(e,void 0,void 0,t,void 0,s)}))}}class Pe{constructor(e){this.icn3d=e}createBrick(e,t,s,i){let n=this.icn3d;if(n.icn3dui.bNode)return;let l=new THREE.CylinderGeometry(1,1,1,4,1),r=new THREE.Mesh(l,new THREE.MeshPhongMaterial({specular:n.frac,shininess:n.shininess,emissive:n.emissive,color:i}));r.position.copy(e).add(t).multiplyScalar(.5),r.matrixAutoUpdate=!1,r.lookAt(t.clone().sub(e)),r.updateMatrix(),r.matrix.multiply((new THREE.Matrix4).makeScale(s,s,e.distanceTo(t))).multiply((new THREE.Matrix4).makeRotationX(.5*Math.PI)),n.mdl.add(r)}}class De{constructor(e){this.icn3d=e}createCurveSubArrow(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u){if(this.icn3d.icn3dui.bNode)return;let g=[],f=[];g.push(e),f.push(o),this.prepareStrand(g,f,t,s,i,void 0,n,l,r,a,d,!1,c,h,p,m,u),g=[],f=[]}createStripArrow(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g){if(this.icn3d.icn3dui.bNode)return;let f=[],b=[];f.push(e),f.push(t),b.push(o),b.push(a),this.prepareStrand(f,b,void 0,s,i,n,l,void 0,r,d,c,!0,h,p,m,u,g),f=[],b=[]}prepareStrand(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g,f){let b=this.icn3d,C=b.icn3dui;if(1===d.length)return;let y=i,v=!u,w=[];w.push(i[i.length-2]),w.push(i[i.length-1]),n=n||b.axisDIV;let _,S,A,x,k=2/(a-1),O={};for(let e=0,s=t.length;e1)if(void 0!==d){let i,n,l=[];for(let r=0,o=p.length;r0&&i.tubeCls.createTube(a,"CA",i.coilWidth,s),Object.keys(d).length>0&&i.strandCls.createStrand(d,void 0,void 0,!0,0,i.helixSheetWidth,!1,2*i.ribbonthickness,s)):(Object.keys(a).length>0&&i.tubeCls.createTube(a,"CA",i.coilWidth),Object.keys(d).length>0&&i.strandCls.createStrand(d,void 0,void 0,!0,0,i.helixSheetWidth,!1,2*i.ribbonthickness))}createCylinderCurve(e,t,s,i,n){let l=this.icn3d;if(l.icn3dui.bNode)return;let r,o,a,d,c,h,p=null;for(a in e)if(d=e[a],!d.het&&(c=d.structure+"_"+d.chain,h=d.structure+"_"+r,-1!=t.indexOf(d.name))){if(null!==p&&r===d.chain&&l.ParserUtilsCls.getResiNCBI(h,o)+1===l.ParserUtilsCls.getResiNCBI(c,d.resi)&&Math.abs(p.coord.x-d.coord.x)<8&&Math.abs(p.coord.y-d.coord.y)<8&&Math.abs(p.coord.z-d.coord.z)<8){let e=p.coord.clone().add(d.coord).multiplyScalar(.5);if(n)1===n&&(this.createCylinder(p.coord,e,s,p.color,n),this.createCylinder(e,d.coord,s,d.color,n),l.sphereCls.createSphere(d,s,!0,1,n));else if(i){let t=l.lineCls.createSingleLine(p.coord,e,p.color,!1);l.mdl.add(t),l.objects.push(t),t=l.lineCls.createSingleLine(e,d.coord,d.color,!1),l.mdl.add(t),l.objects.push(t)}else this.createCylinder(p.coord,e,s,p.color),this.createCylinder(e,d.coord,s,d.color),l.sphereCls.createSphere(d,s,!0,1,n)}p=d,r=d.chain,o=d.resi,l.sphereCls.createSphere(d,s,!0,1,n),2===n&&l.boxCls.createBox(d,void 0,void 0,void 0,void 0,n)}if(null!==p&&r===d.chain&&l.ParserUtilsCls.getResiNCBI(h,o)+1===l.ParserUtilsCls.getResiNCBI(c,d.resi)&&Math.abs(p.coord.x-d.coord.x)<8&&Math.abs(p.coord.y-d.coord.y)<8&&Math.abs(p.coord.z-d.coord.z)<8){let e=p.coord.add(d.coord).multiplyScalar(.5);if(n)1===n&&(this.createCylinder(p.coord,e,s,p.color,n),this.createCylinder(e,d.coord,s,d.color,n),l.sphereCls.createSphere(d,s,!0,1,n));else if(i){let t=l.lineCls.createSingleLine(p.coord,e,p.color,!1);l.mdl.add(t),l.objects.push(t),t=l.lineCls.createSingleLine(e,d.coord,d.color,!1),l.mdl.add(t),l.objects.push(t)}else this.createCylinder(p.coord,e,s,p.color),this.createCylinder(e,d.coord,s,d.color)}}}class Le{constructor(e){this.icn3d=e}createLineRepresentation(e,t){let s=this.icn3d;if(s.icn3dui.bNode)return;let i=new THREE.BufferGeometry,n=[],l=[],r=0,o=0;s.reprSubCls.createRepresentationSub(e,void 0,(function(e,t){if(e.color===t.color)n[r++]=e.coord.x,n[r++]=e.coord.y,n[r++]=e.coord.z,n[r++]=t.coord.x,n[r++]=t.coord.y,n[r++]=t.coord.z,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b;else{let s=e.coord.clone().add(t.coord).multiplyScalar(.5);n[r++]=e.coord.x,n[r++]=e.coord.y,n[r++]=e.coord.z,n[r++]=s.x,n[r++]=s.y,n[r++]=s.z,n[r++]=t.coord.x,n[r++]=t.coord.y,n[r++]=t.coord.z,n[r++]=s.x,n[r++]=s.y,n[r++]=s.z,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b}}));if(i.setAttribute("position",new THREE.BufferAttribute(new Float32Array(n),3)),i.setAttribute("color",new THREE.BufferAttribute(new Float32Array(l),3)),2!==t){let e;1===t||(e=new THREE.LineSegments(i,new THREE.LineBasicMaterial({linewidth:s.linewidth,vertexColors:!0})),s.mdl.add(e)),1===t?s.prevHighlightObjects.push(e):s.objects.push(e)}else 2===t&&s.boxCls.createBoxRepresentation_P_CA(e,.8,t)}createConnCalphSidechain(e,t){let s=this.icn3d;if(s.icn3dui.bNode)return;let i={};for(let s in e){let n=e[s];if(!n.het&&n.style2===t){i[n.structure+"_"+n.chain+"_"+n.resi]=1}}let n=[],l=[];for(let e in i){let t=s.firstAtomObjCls.getFirstAtomObjByName(s.residues[e],"CA");if(void 0!==t)for(let e=0,i=t.bonds.length;e=t.bonds.length&&e.bonds.length>1)s=e.serial,l=e.bonds[0],d=e.bonds[1];else{if(!(t.bonds.length>=e.bonds.length&&t.bonds.length>1))return void console.log("Double bond was not drawn due to the undefined cross plane");s=t.serial,l=t.bonds[0],d=t.bonds[1]}let i=r.atoms[s].coord.clone();i.sub(r.atoms[l].coord);let n=r.atoms[s].coord.clone();n.sub(r.atoms[d].coord),i.cross(n),0==parseInt(1e4*i.length())&&(i=new THREE.Vector3(.2,.3,.5)),c=t.coord.clone(),c.sub(e.coord),c.cross(i).normalize().multiplyScalar(.2*o),0==parseInt(1e4*c.length())&&(i=new THREE.Vector3(.5,.3,.2),c.cross(i).normalize().multiplyScalar(.2*o))}e.color===t.color?r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),t.coord.clone().add(c),a,e.color,n),r.cylinderCls.createCylinder(e.coord.clone().sub(c),t.coord.clone().sub(c),a,e.color,n)):r.bImpo?r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),t.coord.clone().add(c),a,e.color,n,t.color),r.cylinderCls.createCylinder(e.coord.clone().sub(c),t.coord.clone().sub(c),a,e.color,n,t.color)):r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),i.clone().add(c),a,e.color,n),r.cylinderCls.createCylinder(t.coord.clone().add(c),i.clone().add(c),a,t.color,n),r.cylinderCls.createCylinder(e.coord.clone().sub(c),i.clone().sub(c),a,e.color,n),r.cylinderCls.createCylinder(t.coord.clone().sub(c),i.clone().sub(c),a,t.color,n))}else if(r.aromaticbonds.hasOwnProperty(l)){let s,l,d;if(e.bonds.length>t.bonds.length&&e.bonds.length>1)s=e.serial,l=e.bonds[0],d=e.bonds[1];else{if(!(t.bonds.length>1))return;s=t.serial,l=t.bonds[0],d=t.bonds[1]}let c=r.atoms[s].coord.clone();c.sub(r.atoms[l].coord);let h=r.atoms[s].coord.clone();h.sub(r.atoms[d].coord),c.cross(h);let p=t.coord.clone();p.sub(e.coord),p.cross(c).normalize().multiplyScalar(.2*o);let m=0;for(let s=0,i=e.bondOrder.length;so+1?(s=k.clone(),i=d.atoms[G[G.length-1-o-1]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random()))):d.bCalphaOnly&&"CA"===b.name&&(G.length>o+1?(s=k.clone(),i=d.atoms[G[G.length-1-o-1]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random())),s.normalize(),s.multiplyScalar(f),null!==E&&s.dot(E)<0&&s.negate(),E=s;for(let e=0,s=2/(t-1);e6||c&&Math.abs(S.y-c.y)>6||c&&Math.abs(S.z-c.z)>6;if((u!==b.chain||b.ssbegin||b.ssend||B===j-1||p)&&m[0].length>0){let c="CA",u=[],g=[];if(isNaN(d.atoms[P].resi))u=[];else{let e=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)-1).toString(),t=d.firstAtomObjCls.getAtomCoordFromResi(e,c);u=void 0!==t?[t]:[]}if(!isNaN(d.atoms[P].resi)){let e=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)+1).toString(),t=d.firstAtomObjCls.getAtomCoordFromResi(e,c);void 0!==t&&g.push(t);let s=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)+2).toString(),i=d.firstAtomObjCls.getAtomCoordFromResi(s,c);void 0!==i&&g.push(i)}if(!p){1===a||2===a?_.push(d.hColor):_.push(R),f=b.ssend&&"sheet"===b.ss?0:"coil"===I&&b.ssbegin||T&&b.ssbegin||"coil"===b.ss?n:l;let s,i,o=4;"O"===b.name?(s=A.clone(),s.sub(S)):d.bCalphaOnly&&"CA"===b.name&&(G.length>o?(s=S.clone(),i=d.atoms[G[G.length-1-o]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random())),s.normalize(),s.multiplyScalar(f),null!==E&&s.dot(E)<0&&s.negate(),E=s;for(let e=0,s=2/(t-1);e0){let e="CA",n=[],l=[];if(isNaN(d.atoms[P].resi))n=[];else{let t=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)-1).toString();d.firstAtomObjCls.getAtomCoordFromResi(t,e)}for(let e=0;!i&&e0;--e){let t=a.structure+"_"+a.chain+"_"+e;if(!c.residues.hasOwnProperty(t))break;let s=c.firstAtomObjCls.getFirstCalphaAtomObj(c.residues[t]);if(s.ss===a.ss&&s.ssbegin){g=s.resi;break}}for(let e=g;e0&&(o!==c.chain||Math.abs(c.coord.x-h.coord.x)>6||Math.abs(c.coord.y-h.coord.y)>6||Math.abs(c.coord.z-h.coord.z)>6||r.ParserUtilsCls.getResiNCBI(c.structure+"_"+o,a)+13||Math.abs(c.coord.y-h.coord.y)>3||Math.abs(c.coord.z-h.coord.z)>3))){if(2!==i){if(!isNaN(d.resi)&&!isNaN(h.resi)){let e=d.structure+"_"+d.chain+"_"+(parseInt(d.resi)-1).toString(),i=r.firstAtomObjCls.getAtomCoordFromResi(e,t);g=void 0!==i?[i]:[];let l=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+1).toString(),o=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+2).toString(),a=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+3).toString();if(r.residues.hasOwnProperty(l)){let e=r.firstAtomObjCls.getAtomFromResi(l,t);void 0!==e&&e.ssbegin&&(l=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+2).toString(),o=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+3).toString(),p.push(e.coord),n?u.push(this.getCustomtubesize(l)):u.push(this.getRadius(s,e)),m.push(e.color))}if(1==p.length&&r.residues.hasOwnProperty(l)){let e=r.firstAtomObjCls.getAtomFromResi(l,t);if(e){p.push(e.coord),m.push(e.color);let t=this.getRadius(s,c);u.push(t),l=o,o=a}}let b=r.firstAtomObjCls.getAtomCoordFromResi(l,t);void 0!==b&&f.push(b);let C=r.firstAtomObjCls.getAtomCoordFromResi(o,t);void 0!==C&&f.push(C)}C.push({pnts:p,colors:m,radii:u,prevone:g,nexttwo:f})}p=[],m=[],u=[],g=[],f=[],d=c,b=0}if(0==p.length&&!isNaN(c.resi)){let e=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)-1).toString();r.residues.hasOwnProperty(e)&&(h=r.firstAtomObjCls.getAtomFromResi(e,t),void 0!==h&&h.ssend&&(p.push(h.coord),n?u.push(this.getCustomtubesize(e)):u.push(this.getRadius(s,h)),m.push(h.color)))}let e;p.push(c.coord),e=n?this.getCustomtubesize(c.structure+"_"+c.chain+"_"+c.resi):this.getRadius(s,c),u.push(e),m.push(c.color),1===b&&(m[m.length-2]=c.color),o=c.chain,a=c.resi;let l=1.2;2!==i||c.ssbegin||r.boxCls.createBox(c,void 0,void 0,l,void 0,i),++b,h=c}if(2!==i){if(g=[],void 0!==d&&!isNaN(d.resi)){let e=d.structure+"_"+d.chain+"_"+(parseInt(d.resi)-1).toString(),s=r.firstAtomObjCls.getAtomCoordFromResi(e,t);g=void 0!==s?[s]:[]}if(f=[],void 0!==c&&!isNaN(c.resi)){let e=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+1).toString(),i=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+2).toString(),n=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+3).toString();if(1==p.length&&r.residues.hasOwnProperty(e)){let l=r.firstAtomObjCls.getAtomFromResi(e,t);if(l){p.push(l.coord),m.push(l.color);let t=this.getRadius(s,c);u.push(t),e=i,i=n}}let l=r.firstAtomObjCls.getAtomCoordFromResi(e,t);void 0!==l&&f.push(l);let o=r.firstAtomObjCls.getAtomCoordFromResi(i,t);void 0!==o&&f.push(o)}C.push({pnts:p,colors:m,radii:u,prevone:g,nexttwo:f})}for(let e=0,t=C.length;e1?a.parasCls.thr(t[t.length-2]):a.parasCls.thr(t[e]),f[y++]=d.r,f[y++]=d.g,f[y++]=d.b}}let x,k=0;for(let e=0,t=_.length-1;er&&(l=r,e=1);for(let t=0;t0&&t.b<=100?.01*t.b:t.b>100?1:s.coilWidth),i}}class ze{constructor(e){this.icn3d=e}drawCartoonNucleicAcid(e,t,s,i){this.drawStrandNucleicAcid(e,2,t,!0,void 0,s,i)}drawStrandNucleicAcid(e,t,s,i,n,l,r){let o,a,d,c=this.icn3d;if(c.icn3dui.bNode)return;2===r&&(t=void 0,l=void 0),n=n||c.nucleicAcidWidth,s=s||c.axisDIV,t=t||c.nucleicAcidStrandDIV;let h=[];for(d=0;dy?y=C:C=y);let v=.8*b/y;if(g.width=C,g.height=y,f.clearRect(0,0,C,y),h)if(f.fillStyle="rgba("+n.r+","+n.g+","+n.b+","+n.a+")",f.strokeStyle="rgba("+l.r+","+l.g+","+l.b+","+l.a+")",f.lineWidth=r,p){let e=.4*C;this.circle(f,0,0,C,y,e)}else{let e=0;this.roundRect(f,0,0,C,y,e)}f.font="Bold "+a+"px "+o,f.textAlign="center",f.textBaseline="middle",f.fillStyle="rgba("+u.r+", "+u.g+", "+u.b+", 1.0)",f.strokeStyle="rgba("+u.r+", "+u.g+", "+u.b+", 1.0)",f.fillText(e,.5*C,.5*y);let w=new THREE.Texture(g);w.needsUpdate=!0;let _=new THREE.SpriteMaterial({map:w,depthTest:!1,depthWrite:!1});_.map.minFilter=THREE.LinearFilter;let S=new THREE.Sprite(_);return p?S.scale.set(.3*d,.3*d,1):S.scale.set(v*d,d,1),S}roundRect(e,t,s,i,n,l){e.beginPath(),e.moveTo(t+l,s),e.lineTo(t+i-l,s),e.quadraticCurveTo(t+i,s,t+i,s+l),e.lineTo(t+i,s+n-l),e.quadraticCurveTo(t+i,s+n,t+i-l,s+n),e.lineTo(t+l,s+n),e.quadraticCurveTo(t,s+n,t,s+n-l),e.lineTo(t,s+l),e.quadraticCurveTo(t,s,t+l,s),e.closePath(),e.fill(),e.stroke()}circle(e,t,s,i,n,l){e.beginPath(),e.arc(t+i/2,.9*(s+n/2),l,0,2*Math.PI,!0),e.closePath(),e.fill(),e.stroke()}}class Ve{constructor(e){this.icn3d=e,this.textSpriteCls=new Ge(e)}createLabelRepresentation(e){let t=this.icn3d;t.icn3dui;let s=t.oriMaxD/100;s<.4&&(s=.4);let i=3*s*t.labelScale;for(let s in e){let n=void 0!==e[s]?e[s]:[],l="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd;for(let e=0,r=n.length;e.99999)h.set(0,0,0,1);else if(e.y<-.99999)h.set(1,0,0,0);else{let t=new THREE.Vector3;t.set(e.z,0,-e.x).normalize();let s=Math.acos(e.y);h.setFromAxisAngle(t,s)}return c.applyQuaternion(h),c.scale.set(l,n,l),c.position.copy(t),c}setPc1Axes(){let e=this.icn3d,t=e.icn3dui;if(t.bNode)return;let s=t.hashUtilsCls.intHash(e.hAtoms,e.dAtoms),i=[],n=Object.keys(s).length<100;for(let t in s){let s=e.atoms[t],l=s.structure+"_"+s.chain+"_"+s.resi;(n||""!=l)&&i.push(s.coord.clone())}let l=t.rmsdSuprCls.getEigenForSelection(i,i.length),r=new THREE.Vector3(l.h1[0],l.h1[1],l.h1[2]);if(0==l.k&&e.bRender)return void alert("Can't determine the first principal component. Please select a subset and try it again.");let o=e.applyCenterCls.centerAtoms(s),a=o.maxD,d=o.center,c=d.clone().add(r.normalize().multiplyScalar(.4*a)),h=new THREE.Vector3(l.h2[0],l.h2[1],l.h2[2]),p=d.clone().add(h.normalize().multiplyScalar(.3*a)),m=new THREE.Vector3(l.h3[0],l.h3[1],l.h3[2]),u=d.clone().add(m.normalize().multiplyScalar(.3*a));this.buildAxes(void 0,d,c,p,u,!0);let g=[d,c,p,u];return e.axes.push(g),e.drawCls.draw(),g}}class Ye{constructor(e){this.icn3d=e}showGlycans(){let e=this.icn3d,t=e.icn3dui;if(t.bNode)return;let s={},i=e.dAtoms;for(let n in i){let i=e.atoms[n];i.het&&-1!=t.parasCls.glycanHash.hasOwnProperty(i.resn)&&(void 0===s[i.resn]&&(s[i.resn]={}),"Misc"!=i.chain&&(s[i.resn][i.structure+"_"+i.chain+"_"+i.resi]=1))}let n=Object.keys(s);for(let i=0,l=n.length;i>2))+i+((2&t)>>1))*c+n+(1&t)]&this.ISDONE)<=3&&(t.push(t[i]),i=t.length-1,t.push(t[n]),n=t.length-1,t.push(t[l]),l=t.length-1),s.push(i),s.push(n),s.push(l)}}},Xe.prototype.laplacianSmooth=function(e,t,s){let i,n,l,r,o,a=new Array(t.length);for(i=0,n=t.length;ithis.origextent[1][0])&&(!(tthis.origextent[1][1])&&!(sthis.origextent[1][2]))},Ke.prototype.getFacesAndVertices=function(){let e,t,s=this.verts;for(e=0,t=s.length;eh&&(h=this.pmaxy-this.pminy),this.pmaxz-this.pminz>h&&(h=this.pmaxz-this.pminz),this.scaleFactor=(c-1)/h,this.scaleFactor=this.defaultScaleFactor,(this.bCalcArea||this.defaultScaleFactor*h>this.threshbox)&&(c=Math.floor(this.threshbox),this.scaleFactor=(this.threshbox-1)/h),this.pLength=Math.ceil(this.scaleFactor*(this.pmaxx-this.pminx))+1,this.pWidth=Math.ceil(this.scaleFactor*(this.pmaxy-this.pminy))+1,this.pHeight=Math.ceil(this.scaleFactor*(this.pmaxz-this.pminz))+1,this.finalScaleFactor.x=(this.pLength-1)/(this.pmaxx-this.pminx),this.finalScaleFactor.y=(this.pWidth-1)/(this.pmaxy-this.pminy),this.finalScaleFactor.z=(this.pHeight-1)/(this.pmaxz-this.pminz),this.boundingatom(t),this.cutRadius=this.probeRadius*this.scaleFactor,this.vpBits=new Uint8Array(this.pLength*this.pWidth*this.pHeight),this.vpDistance=new Float64Array(this.pLength*this.pWidth*this.pHeight),this.vpAtomID=new Int32Array(this.pLength*this.pWidth*this.pHeight),this.vpColor=[],this.vpPot=[]},Ke.prototype.boundingatom=function(e){let t,s,i,n,l=[];for(let r in this.vdwRadii){if(!this.vdwRadii.hasOwnProperty(r))continue;let o=this.vdwRadii[r];l[r]=e?(o+this.probeRadius)*this.scaleFactor+.5:o*this.scaleFactor+.5,i=l[r]*l[r],this.widxz[r]=Math.floor(l[r])+1,this.depty[r]=new Int32Array(this.widxz[r]*this.widxz[r]),n=0;for(let e=0;ei?this.depty[r][n]=-1:(s=Math.sqrt(i-t),this.depty[r][n]=Math.floor(s)),n++}},Ke.prototype.fillvoxels=function(e,t){let s,i,n,l;for(s=0,l=this.vpBits.length;sc&&(a=c),C>h&&(C=h),v>p&&(v=p);let w,_=g[o*m+d*u+y],S=g[a*m+d*u+y],A=g[o*m+C*u+y],x=g[o*m+d*u+v],k=g[a*m+C*u+y],O=g[o*m+C*u+v],R=g[a*m+d*u+v],E=g[a*m+C*u+v],I=r.x-o,T=r.y-d,M=r.z-y,P=((_*(1-I)+S*I)*(1-T)+(A*(1-I)+k*I)*T)*(1-M)+((x*(1-I)+R*I)*(1-T)+(O*(1-I)+E*I)*T)*M,D=s*f+i*b+n;this.vpPot[D]=P,P>this.isovalue&&(P=this.isovalue),P<-this.isovalue&&(P=-this.isovalue),P>0?(P/=1*this.isovalue,w=new THREE.Color(1-P,1-P,1)):(P/=-1*this.isovalue,w=new THREE.Color(1,1-P,1-P)),this.vpColor[D]=w}}for(s=0,l=this.vpBits.length;s=this.pLength||g>=this.pWidth||f>=this.pHeight)continue;let h=u*S+g*this.pHeight+f;if(this.vpBits[h]&this.INOUT){let p=t[this.vpAtomID[h]];p.serial!=e.serial&&(l=s+a-Math.floor(.5+this.scaleFactor*(p.x+this.ptranx)),r=i+d-Math.floor(.5+this.scaleFactor*(p.y+this.ptrany)),o=n+c-Math.floor(.5+this.scaleFactor*(p.z+this.ptranz)),a*a+d*d+c*c=this.pLength||p>=this.pWidth||m>=this.pHeight)continue;let u=h*S+p*this.pHeight+m;if(this.vpBits[u]&this.ISDONE){let h=t[this.vpAtomID[u]];h.serial!=e.serial&&(l=s+a-Math.floor(.5+this.scaleFactor*(h.x+this.ptranx)),r=i+d-Math.floor(.5+this.scaleFactor*(h.y+this.ptrany)),o=n+c-Math.floor(.5+this.scaleFactor*(h.z+this.ptranz)),a*a+d*d+c*c-1&&r-1&&a-1&&o=h)||(this.vpBits[n]|=this.ISBOUND))},Ke.prototype.fastoneshell=function(e,t){let s,i,n,l,r,o,a,d,c,h,p,m,u=[];if(0===e.length)return u;let g={ix:-1,iy:-1,iz:-1},f=this.pWidth*this.pHeight;for(a=0,c=e.length;a-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,h-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,h-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,hm&&(m=this.pmaxy-this.pminy),this.pmaxz-this.pminz>m&&(m=this.pmaxz-this.pminz),this.scaleFactor=1,this.pLength=Math.floor(.5+this.scaleFactor*(this.pmaxx-this.pminx))+1,this.pWidth=Math.floor(.5+this.scaleFactor*(this.pmaxy-this.pminy))+1,this.pHeight=Math.floor(.5+this.scaleFactor*(this.pmaxz-this.pminz))+1,this.cutRadius=this.probeRadius*this.scaleFactor,this.vpBits=new Uint8Array(this.pLength*this.pWidth*this.pHeight),this.vpAtomID=new Uint8Array(this.pLength*this.pWidth*this.pHeight)},Qe.prototype.transformMemPro=function(e,t,s,i){let n=e.clone();n.sub(s);let l=n.x*t[0]+n.y*t[1]+n.z*t[2]+i.x,r=n.x*t[3]+n.y*t[4]+n.z*t[5]+i.y,o=n.x*t[6]+n.y*t[7]+n.z*t[8]+i.z;return n.x=l,n.y=r,n.z=o,n},Qe.prototype.fillvoxels=function(e,t){let s,i,n,l,r,o;for(s=0,l=this.vpBits.length;sthis.pLength&&(o=this.pLength),p>this.pWidth&&(p=this.pWidth),b>this.pHeight&&(b=this.pHeight);let C,y=l[r*a+h*d+f],v=l[o*a+h*d+f],w=l[r*a+p*d+f],_=l[r*a+h*d+b],S=l[o*a+p*d+f],A=l[r*a+p*d+b],x=l[o*a+h*d+b],k=l[o*a+p*d+b],O=n.x-r,R=n.y-h,E=n.z-f,I=((y*(1-O)+v*O)*(1-R)+(w*(1-O)+S*O)*R)*(1-E)+((_*(1-O)+x*O)*(1-R)+(A*(1-O)+k*O)*R)*E;I>this.isovalue&&(I=this.isovalue),I<-this.isovalue&&(I=-this.isovalue),I>0?(I/=1*this.isovalue,C=new THREE.Color(1-I,1-I,1)):(I/=-1*this.isovalue,C=new THREE.Color(1,1-I,1-I)),this.icn3d.atoms[t[s]].color=C,this.icn3d.atomPrevColors[t[s]]=C}}else{for(let p in t){let f,b=e[t[p]];if("DUM"!==b.resn){if(void 0!==this.rmsd_supr&&void 0!==this.rmsd_supr.rot){f=this.transformMemPro(b.coord,g,u,m).applyMatrix4(c)}else f=b.coord.clone().applyMatrix4(c);for(s=Math.floor(f.x)-this.maxdist,l=Math.ceil(f.x)+this.maxdist;s<=l;++s)if(!(s<0||s>this.header.xExtent*this.scaleFactor-1))for(i=Math.floor(f.y)-this.maxdist,r=Math.ceil(f.y)+this.maxdist;i<=r;++i)if(!(i<0||i>this.header.yExtent*this.scaleFactor-1))for(n=Math.floor(f.z)-this.maxdist,o=Math.ceil(f.z)+this.maxdist;n<=o;++n){if(n<0||n>this.header.zExtent*this.scaleFactor-1)continue;let e=s*a+i*d+n;h.push(e)}}}for(s=0,l=h.length;s=this.isovalue?1:0:"fofc"==this.type?(this.vpBits[e]=this.dataArray[e]>=this.isovalue||this.dataArray[e]<=-this.isovalue?1:0,this.vpAtomID[e]=this.dataArray[e]>=0?1:0):"em"==this.type&&(this.vpBits[e]=this.dataArray[e]>=this.isovalue?1:0)}}}else for(s=0;s=this.isovalue||this.dataArray[e]<=-this.isovalue?1:0,this.vpAtomID[t]=this.dataArray[e]>=0?1:0)}for(s=0,l=this.vpBits.length;s-1&&r-1&&a-1&&o1?"Structure":"",a=Object.keys(i).length>1?"Chain":"";n+=""+o+a+"ResidueNumberSASA (Å2)Percent OutIn/Out";for(let e in l.resid2area){let d=e.lastIndexOf("_"),c=e.substr(d+1),h=r.utilsCls.getIdArray(e.substr(0,d));o=Object.keys(s).length>1?""+h[0]+"":"",a=Object.keys(i).length>1?""+h[1]+"":"";let p="",m="";l.resid2area[e]=(l.resid2area[e]/t).toFixed(2),r.parasCls.residueArea.hasOwnProperty(c)&&(m=parseInt(l.resid2area[e]/r.parasCls.residueArea[c]*100),m>100&&(m=100),m>=50&&(p="out"),m<20&&(p="in")),n+=''+o+a+""+c+''+h[2]+''+l.resid2area[e]+''+m+"%"+p+""}return n+="",void(l.areahtml=n)}let p,m,u,g=c.vertices,f=c.faces,b=r.parasCls.thr("#00FFFF"),C=r.parasCls.thr("#00FF00"),y=r.parasCls.thr("#ff0000"),v=r.parasCls.thr("#00FFFF"),w=r.parasCls.thr("#0000FF"),_=r.parasCls.thr("#FF0000");11!=t&&12!=t&&13!=t&&14!=t||void 0===l.rmsd_supr||void 0===l.rmsd_supr.rot||(p=l.rmsd_supr.rot,m=l.rmsd_supr.trans1,u=l.rmsd_supr.trans2);let S=(11==t||12==t||13==t||14==t&&"delphi"!=l.loadPhiFrom)&&void 0!==l.rmsd_supr&&void 0!==l.rmsd_supr.rot;n=new THREE.BufferGeometry;let A,x=[],k=[],O=[],R=0;for(let e=0,s=g.length;e0?-parseInt(C.z):parseInt(C.z),y.onBeforeRender=function(e,t,s,i,n,o){let a,d=new THREE.Vector3(0,0,0),c=i.getAttribute("position").array;for(let e=0,t=c.length;e0?-parseInt(a.z):parseInt(a.z)},l.mdl.add(y),11==t||12==t?l.prevMaps.push(y):13==t?l.prevEmmaps.push(y):14==t?l.prevPhimaps.push(y):l.prevSurfaces.push(y)}}else{let e=new THREE.Mesh(n,new THREE.MeshPhongMaterial({specular:l.frac,shininess:20,emissive:l.emissive,vertexColors:THREE.VertexColors,wireframe:s,opacity:i,transparent:!0,depthWrite:10==parseInt(10*i),side:THREE.DoubleSide}));e.renderOrder=-2,l.mdl.add(e),11==t||12==t?l.prevMaps.push(e):13==t?l.prevEmmaps.push(e):14==t?l.prevPhimaps.push(e):l.prevSurfaces.push(e)}c=null,g=null,f=null,n=null}transformMemPro(e,t,s,i,n){this.icn3d.icn3dui;let l=e.clone();l.sub(s),n&&console.log("sub coord: "+JSON.stringify(l));let r=l.x*t[0]+l.y*t[1]+l.z*t[2]+i.x,o=l.x*t[3]+l.y*t[4]+l.z*t[5]+i.y,a=l.x*t[6]+l.y*t[7]+l.z*t[8]+i.z;return l.x=r,l.y=o,l.z=a,n&&console.log("out coord: "+JSON.stringify(l)),l}SetupSurface(e){let t=this.icn3d;t.icn3dui;let s=e.threshbox,i=new Ke(t,s);i.initparm(e.extent,1!==e.type,e.bCalcArea,e.atomsToShow,e.header,e.data,e.matrix,e.isovalue,e.loadPhiFrom),i.fillvoxels(e.allatoms,e.extendedAtoms),i.buildboundary(),2===e.type&&(i.fastdistancemap(),i.boundingatom(!1),i.fillvoxelswaals(e.allatoms,e.extendedAtoms));let n=i.marchingcube();i.vpBits=null,i.vpDistance=null,i.vpAtomID=null;let l=i.getFacesAndVertices(e.atomsToShow);return l.area=n.area,l.serial2area=n.serial2area,l.scaleFactor=n.scaleFactor,i.faces=null,i.verts=null,l}SetupMap(e){let t=this.icn3d;t.icn3dui;let s,i=new Qe(t);return i.initparm(e.header,e.data,e.matrix,e.isovalue,e.center,e.maxdist,e.pmin,e.pmax,e.water,e.type,e.rmsd_supr,e.loadPhiFrom,e.icn3d),i.fillvoxels(e.allatoms,e.extendedAtoms),e.header.bSurface||i.buildboundary(),e.header.bSurface||i.marchingcube(),i.vpBits=null,i.vpAtomID=null,e.header.bSurface||(s=i.getFacesAndVertices(e.allatoms,e.atomsToShow)),i.faces=null,i.verts=null,s}}class Ze{constructor(e){this.icn3d=e}applyCenterOptions(e){let t,s=this.icn3d;switch(s.icn3dui,void 0===e&&(e=s.opts),e.rotationcenter.toLowerCase()){case"molecule center":void 0!==s.center&&this.setRotationCenter(s.center);break;case"pick center":void 0!==s.pAtom&&this.setRotationCenter(s.pAtom.coord);break;case"display center":t=this.centerAtoms(s.dAtoms).center,this.setRotationCenter(t);break;case"highlight center":t=this.centerAtoms(s.hAtoms).center,this.setRotationCenter(t)}}setRotationCenter(e){this.icn3d.icn3dui,this.setCenter(e)}setCenter(e){let t=this.icn3d;t.icn3dui,t.mdl.position.set(0,0,0),t.mdlImpostor.position.set(0,0,0),t.mdl_ghost.position.set(0,0,0),t.mdl.position.sub(e),t.mdlImpostor.position.sub(e),t.mdl_ghost.position.sub(e)}centerSelection(e,t){let s=this.icn3d,i=s.icn3dui;if(s.opts.rotationcenter="highlight center",void 0===e&&(e=i.hashUtilsCls.hash2Atoms(s.hAtoms,s.atoms)),t||(s._zoomFactor=1,s.mouseChange=new THREE.Vector2(0,0),s.quaternion=new THREE.Quaternion(0,0,0,1)),Object.keys(e).length>1){let t=this.centerAtoms(e);s.center=t.center,this.setCenter(s.center),s.cameraCls.setCamera()}}centerAtoms(e){let t=this.icn3d;t.icn3dui;let s=new THREE.Vector3(9999,9999,9999),i=new THREE.Vector3(-9999,-9999,-9999),n=new THREE.Vector3;for(let l in e){let e=t.atoms[l].coord;n.add(e),s.min(e),i.max(e)}let l=t.ParserUtilsCls.getGeoCenter(s,i);return{center:l,maxD:t.ParserUtilsCls.getStructureSize(e,s,i,l),pmin:s,pmax:i}}setWidthHeight(e,t){let s=this.icn3d;s.icn3dui,void 0===s.scaleFactor&&(s.scaleFactor=1),s.renderer.setSize(e*s.scaleFactor,t*s.scaleFactor),s.renderer.domElement.style.width=e*s.scaleFactor+"px",s.renderer.domElement.style.height=t*s.scaleFactor+"px",s.renderer.domElement.width=e*s.scaleFactor,s.renderer.domElement.height=t*s.scaleFactor,s.container.whratio=e/t}}class et{constructor(e){this.icn3d=e}applyClbondsOptions(e){let t=this.icn3d,s=t.icn3dui;if(void 0===e&&(e=t.opts),t.bCalcCrossLink||(t.clbondpnts={},t.clbondResid2serial={},this.applyClbondsOptions_base("chemical"),this.applyClbondsOptions_base("all"),t.bCalcCrossLink=!0),"yes"===e.clbonds.toLowerCase()&&"nothing"!==e.chemicals){let e="#006400",i=s.parasCls.thr(25600);if(t.lines.clbond=[],t.residuesHashClbonds={},t.structures){let n=Object.keys(t.structures);for(let l=0,r=n.length;l1&&"sphere"!==a[Object.keys(a)[0]].style&&"dot"!==a[Object.keys(a)[0]].style){if(void 0===i.bCid||!i.bCid)for(let e in a){let t=a[e],n=1;i.boxCls.createBox(t,void 0,void 0,n,void 0,s)}}else for(let e in o){let l=i.firstAtomObjCls.getFirstCalphaAtomObj(i.residues[e]),r=l,o=r.structure+"_"+r.chain+"_"+(parseInt(r.resi)-1).toString(),a=r.structure+"_"+r.chain+"_"+(parseInt(r.resi)+1).toString();if("cylinder and plate"===r.style&&"helix"===r.ss)for(let t in i.residues[e]){let e=i.atoms[t],n=1;i.boxCls.createBox(e,void 0,void 0,n,void 0,s)}else if("ribbon"===r.style&&"coil"===r.ss||"strand"===r.style&&"coil"===r.ss||"o3 trace"===r.style||"schematic"===r.style||"c alpha trace"===r.style||"b factor tube"===r.style||"cylinder and plate"===r.style&&"helix"!==r.ss){if(void 0!==l&&void 0!==l.style2&&"nothing"!==l.style2)continue;let e=!1;if(!isNaN(r.resi)&&!e&&i.residues.hasOwnProperty(a)){let s=Object.keys(i.residues[a])[0],l=n.hashUtilsCls.hash2Atoms(i.residues[a],i.atoms)[s];if(r.style===l.style&&!l.ssbegin||l.ssbegin){let s=i.residues[a];if(t=n.hashUtilsCls.unionHash(t,s),e=!0,l.ssbegin)for(let e in s)i.atoms[e].notshow=!0}}if(!isNaN(r.resi)&&!e&&i.residues.hasOwnProperty(o)){let s=Object.keys(i.residues[o])[0],l=n.hashUtilsCls.hash2Atoms(i.residues[o],i.atoms)[s];r.style===l.style&&(t=n.hashUtilsCls.unionHash(t,i.residues[o]),e=!0)}}else if("ribbon"===r.style&&"coil"!==r.ss&&r.ssend||"strand"===r.style&&"coil"!==r.ss&&r.ssend){if(void 0!==l&&void 0!==l.style2&&"nothing"!==l.style2)continue;let e=!1;if(!isNaN(r.resi)&&!e&&i.residues.hasOwnProperty(a)){let s=Object.keys(i.residues[a])[0];n.hashUtilsCls.hash2Atoms(i.residues[a],i.atoms)[s],t=n.hashUtilsCls.unionHash(t,i.residues[a]),e=!0}}}a={}}if(i.bInitial){if(""!=n.htmlCls.setHtmlCls.getCookie("membrane")){let e=parseInt(n.htmlCls.setHtmlCls.getCookie("membrane"));i.bMembrane!=e&&n.htmlCls.clickMenuCls.setLogCmd("set membrane "+e,!0),i.bMembrane=isNaN(e)?0:parseInt(e)}i.bMembrane?i.selectionCls.toggleMembrane(!0):i.selectionCls.toggleMembrane(!1)}i.setStyleCls.setStyle2Atoms(t);let d=.5*i.cylinderRadius;void 0!==i.labels&&delete i.labels.schematic;for(let e in i.style2atoms){let t=i.style2atoms[e],l=n.hashUtilsCls.intHash(t,i.nucleotides),r=n.utilsCls.isCalphaPhosOnly(n.hashUtilsCls.hash2Atoms(l,i.atoms));if("ribbon"===e)i.strandCls.createStrand(n.hashUtilsCls.hash2Atoms(t,i.atoms),2,void 0,!0,void 0,void 0,!1,i.ribbonthickness,s);else if("strand"===e)i.strandCls.createStrand(n.hashUtilsCls.hash2Atoms(t,i.atoms),null,null,null,null,null,!1,void 0,s);else if("cylinder and plate"===e)i.cylinderCls.createCylinderHelix(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderHelixRadius,s);else if("nucleotide cartoon"===e)r?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["P"],i.traceRadius,!1,s):(i.cartoonNuclCls.drawCartoonNucleicAcid(n.hashUtilsCls.hash2Atoms(t,i.atoms),null,i.ribbonthickness,s),2!==s&&i.cartoonNuclCls.drawNucleicAcidStick(n.hashUtilsCls.hash2Atoms(t,i.atoms),s));else if("o3 trace"===e)r?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["P"],i.traceRadius,!1,s):i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["O3'","O3*"],i.traceRadius,!1,s);else if("schematic"===e){let e=i.firstAtomObjCls.getFirstAtomObj(t);if(i.chemicals.hasOwnProperty(e.serial)){i.residueLabelsCls.addNonCarbonAtomLabels(n.hashUtilsCls.hash2Atoms(t,i.atoms));let e=!0;i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),d,d,void 0,s,e)}else i.residueLabelsCls.addResidueLabels(n.hashUtilsCls.hash2Atoms(t,i.atoms),!0),r?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["P"],i.traceRadius,!1,s):i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["O3'","O3*"],i.traceRadius,!1,s),i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["CA"],i.traceRadius,!1,s)}else"c alpha trace"===e?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["CA"],i.traceRadius,!1,s):"b factor tube"===e?i.tubeCls.createTube(n.hashUtilsCls.hash2Atoms(t,i.atoms),"CA",null,s,!1,!0):"custom tube"===e?i.tubeCls.createTube(n.hashUtilsCls.hash2Atoms(t,i.atoms),"CA",null,s,!0,!0):"lines"===e||"lines2"===e?(1===s?i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.hlLineRadius,i.hlLineRadius,void 0,s):i.lineCls.createLineRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),s),i.lineCls.createConnCalphSidechain(n.hashUtilsCls.hash2Atoms(t,i.atoms),e)):"stick"===e||"stick2"===e?(i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderRadius,i.cylinderRadius,void 0,s,void 0),i.lineCls.createConnCalphSidechain(n.hashUtilsCls.hash2Atoms(t,i.atoms),e)):"backbone"===e?(t=this.selectMainChainSubset(t),i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderRadius,i.cylinderRadius,void 0,s,void 0)):"ball and stick"===e||"ball and stick2"===e?(i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderRadius,.5*i.cylinderRadius,i.dotSphereScale,s,void 0),i.lineCls.createConnCalphSidechain(n.hashUtilsCls.hash2Atoms(t,i.atoms),e)):"sphere"===e||"sphere2"===e?i.sphereCls.createSphereRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.sphereRadius,void 0,void 0,s):"dot"===e&&i.sphereCls.createSphereRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.sphereRadius,!1,i.dotSphereScale,s)}if(i.cnt>i.maxmaxatomcnt&&i.init_base(),void 0!==i.labels&&Object.keys(i.labels).length>0){i.labelCls.hideLabels();for(let e in i.labels)"schematic"!=e&&this.changeLabelColor(i.labels[e]);i.labelCls.createLabelRepresentation(i.labels)}}changeLabelColor(e){let t=this.icn3d;if(t.icn3dui,e)for(let s=0,i=e.length;s0){this.updateStabilizer();let e="#FFFFFF",s=t.stabilizerpnts;t.lines.stabilizer=[];for(let i=0,n=Math.floor(s.length/2);i0)for(let e=0,s=t.distPnts.length;e0&&t.applySymdCls.applySymd(),void 0!==t.prevOtherMesh)for(let e=0,s=t.prevOtherMesh.length;e0&&(e=s.hashUtilsCls.hash2Atoms(t.chemicals,t.atoms));let i=4;if(void 0!==e){let n=t.contactCls.getAtomsWithinAtom(t.atoms,e,i),l=3.5;t.opts.hbonds="yes",Object.keys(n).length>0&&t.hBondCls.calculateChemicalHbonds(e,n,parseFloat(l)),t.bSetFog||t.transformCls.zoominSelection(s.hashUtilsCls.unionHash(e,n))}}else"hide"===e.chemicalbinding&&(t.hBondCls.hideHbonds(),t.bSetFog||t.transformCls.zoominSelection(t.atoms))}updateStabilizer(){let e=this.icn3d;if(e.icn3dui,e.stabilizerpnts=[],void 0!==e.pairArray)for(let t=0,s=e.pairArray.length;t=0;i--){let r=t.ssbondpnts[e][2*i],o=t.ssbondpnts[e][2*i+1],a={};a.color=n,a.dashed=!0;let d=[],c=[],h=[],p=[],m=!1,u=!1;for(let e in t.residues[r])"SG"===t.atoms[e].name&&(h.push(t.atoms[e].coord),d.push(t.atoms[e].serial),m=!0);if(!m)for(let e in t.residues[r])if("CA"===t.atoms[e].name){h.push(t.atoms[e].coord),d.push(t.atoms[e].serial),m=!0,u=!0;break}m=!1;for(let e in t.residues[o])"SG"===t.atoms[e].name&&(p.push(t.atoms[e].coord),c.push(t.atoms[e].serial),m=!0);if(!m)for(let e in t.residues[o])if("CA"===t.atoms[e].name){p.push(t.atoms[e].coord),c.push(t.atoms[e].serial),m=!0,u=!0;break}let g=u?7:3,f=!1;for(let e=0,t=h.length;e1&&(l=!0)}if(t)if(l){let t=Object.keys(r)[0];e=i.chains[t]}else{0==Object.keys(i.hAtoms).length&&(i.hAtoms=n.hashUtilsCls.cloneHash(i.dAtoms));let t,s=parseInt(Object.keys(i.hAtoms).length/u),l=0;for(let n in i.hAtoms)if(e[n]=1,t=n,++l,l>s)break;let r=i.atoms[t].structure+"_"+i.atoms[t].chain+"_"+i.atoms[t].resi;e=n.hashUtilsCls.unionHash(e,i.residues[r])}else{let t=Object.keys(i.structures)[0]+"_"+g;if(i.chains.hasOwnProperty(t)||(t=Object.keys(i.structures)[0]+"_"+g.toLowerCase()),!i.chains.hasOwnProperty(t)){t=Object.keys(i.chains)[0];for(let e in i.chains){let s=Object.keys(i.chains[e])[0];if(i.proteins.hasOwnProperty(s)){t=e;break}}}e=i.chains[t]}let a=s.clone().add(h).multiplyScalar(.5),c=new THREE.Vector3,p=0,f=h.clone().sub(s).normalize(),b=new THREE.Vector3(0,0,1),C=new THREE.Quaternion;C.setFromUnitVectors(f,b);let y=-9999;for(let t in e){let e=i.atoms[t].coord.clone();c.add(e),e.sub(a).applyQuaternion(C);let s=e.x*e.x+e.y*e.y;s>y&&(y=s),++p}let v=i.ParserUtilsCls.getMassCenter(c,p),w=new THREE.Line3(s,h),_=new THREE.Vector3;w.closestPointToPoint(v,!0,_);let S,A,x,k,O=Math.sqrt(y),R=v.clone().sub(_).normalize().multiplyScalar(O),E=a.clone().add(s.clone().sub(a).multiplyScalar(.83)).add(R),I=a.clone().add(h.clone().sub(a).multiplyScalar(.83)).add(R),T=2*Math.PI/o;for(let e=0;et&&(i.sphereCls.createSphereBase(r,colorPolygon,d,1,0),i.cylinderCls.createCylinder(e,r,d,colorPolygon,0),i.cylinderCls.createCylinder(s,r,d,colorPolygon,0),void 0!==n&&i.cylinderCls.createCylinder(c[n],r,d,colorPolygon,0),n=l)}}else if("O"==r)for(let e=0,t=c.length;e0&&(e.mdl.remove(e.prevSurfaces[e.prevSurfaces.length-1]),e.prevSurfaces.slice(e.prevSurfaces.length-1,1))}removeMaps(){let e=this.icn3d;e.icn3dui;for(let t=0,s=e.prevMaps.length;t0&&(e.mdl.remove(e.prevMaps[e.prevMaps.length-1]),e.prevMaps.slice(e.prevMaps.length-1,1))}removeLastEmmap(){let e=this.icn3d;e.icn3dui,e.prevEmmaps.length>0&&(e.mdl.remove(e.prevEmmaps[e.prevEmmaps.length-1]),e.prevEmmaps.slice(e.prevEmmaps.length-1,1))}removeLastPhimap(){let e=this.icn3d;e.icn3dui,e.prevPhimaps.length>0&&(e.mdl.remove(e.prevPhimaps[e.prevPhimaps.length-1]),e.prevPhimaps.slice(e.prevPhimaps.length-1,1))}}class rt{constructor(e){this.icn3d=e}addResidueLabels(e,t,s,i){let n=this.icn3d,l=n.icn3dui;if(l.bNode)return;let r=l.hashUtilsCls.intHash(n.hAtoms,e);t?void 0===n.labels.schematic&&(n.labels.schematic=[]):void 0===n.labels.residue&&(n.labels.residue=[]);let o="";for(let e in r){let s=n.atoms[e],r={},a=s.structure+"_"+s.chain+"_"+s.resi;if(!s.het&&("CA"===s.name||"O3'"===s.name||"O3*"===s.name)||n.water.hasOwnProperty(s.serial)||n.ions.hasOwnProperty(s.serial)||n.chemicals.hasOwnProperty(s.serial)&&a!==o){r.position=s.coord,r.bSchematic=0,t&&(r.bSchematic=1),r.text=l.utilsCls.residueName2Abbr(s.resn),i&&(r.text+=s.resi),r.size=18,r.factor=.3;let e=s.color.getHexString().toUpperCase();r.color=i?"black"!=n.opts.background?n.colorWhitebkgd:n.colorBlackbkgd:"CCCCCC"===e||"C8C8C8"===e?"#888888":"#"+e,r.background="#FFFFFF",t?n.labels.schematic.push(r):n.labels.residue.push(r)}o=a}n.hlObjectsCls.removeHlObjects()}addNonCarbonAtomLabels(e){let t=this.icn3d,s=t.icn3dui;if(s.bNode)return;let i=s.hashUtilsCls.intHash(t.hAtoms,e);void 0===t.labels.schematic&&(t.labels.schematic=[]);for(let e in i){let s=t.atoms[e];if(!t.residues.hasOwnProperty(s.structure+"_"+s.chain+"_"+s.resi))continue;if("C"===s.elem)continue;let i={};i.position=s.coord,i.bSchematic=1,i.text=s.elem,i.size=18,i.color="black"!=t.opts.background?t.colorWhitebkgd:s.color.getHexString(),i.background="#FFFFFF",t.labels.schematic.push(i)}t.hlObjectsCls.removeHlObjects()}addAtomLabels(e,t){let s=this.icn3d,i=s.icn3dui;if(i.bNode)return;let n=i.hashUtilsCls.intHash(s.hAtoms,e);n=i.hashUtilsCls.intHash(s.dAtoms,n),void 0===s.labels.residue&&(s.labels.residue=[]);for(let e in n){let i=s.atoms[e],n={};n.position=i.coord,n.bSchematic=0,n.text=t?i.elem:i.name.padEnd(2," "),n.size=18,t&&(n.bSchematic=!0);let l=i.color.getHexString().toUpperCase();n.color="black"!=s.opts.background?s.colorWhitebkgd:s.colorBlackbkgd,t&&(n.color="CCCCCC"===l||"C8C8C8"===l?"#888888":"#"+l),n.background="#FFFFFF",s.labels.residue.push(n)}s.hlObjectsCls.removeHlObjects()}}class ot{constructor(e){this.icn3d=e}onBeforeRender(e,t,s,i,n,l){let r=n.uniforms,o=[];if(r.objectId&&(r.objectId.value=SupportsReadPixelsFloat?this.id:this.id/255,o.push("objectId")),(r.modelViewMatrixInverse||r.modelViewMatrixInverseTranspose||r.modelViewProjectionMatrix||r.modelViewProjectionMatrixInverse)&&this.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,this.matrixWorld),r.modelViewMatrixInverse&&(r.modelViewMatrixInverse.value.copy(this.modelViewMatrix).invert(),o.push("modelViewMatrixInverse")),r.modelViewMatrixInverseTranspose&&(r.modelViewMatrixInverse?r.modelViewMatrixInverseTranspose.value.copy(r.modelViewMatrixInverse.value).transpose():r.modelViewMatrixInverseTranspose.value.copy(this.modelViewMatrix).invert().transpose(),o.push("modelViewMatrixInverseTranspose")),r.modelViewProjectionMatrix&&(s.updateProjectionMatrix(),r.modelViewProjectionMatrix.value.multiplyMatrices(s.projectionMatrix,this.modelViewMatrix),o.push("modelViewProjectionMatrix")),r.modelViewProjectionMatrixInverse){let e=new THREE.Matrix4;r.modelViewProjectionMatrix?(e.copy(r.modelViewProjectionMatrix.value),r.modelViewProjectionMatrixInverse.value.copy(e).invert()):(s.updateProjectionMatrix(),e.multiplyMatrices(s.projectionMatrix,this.modelViewMatrix),r.modelViewProjectionMatrixInverse.value.copy(e).invert()),o.push("modelViewProjectionMatrixInverse")}if(r.projectionMatrix&&(s.updateProjectionMatrix(),r.projectionMatrix.value.copy(s.projectionMatrix),o.push("projectionMatrix")),r.projectionMatrixInverse&&(s.updateProjectionMatrix(),r.projectionMatrixInverse.value.copy(s.projectionMatrix).invert(),o.push("projectionMatrixInverse")),o.length){let t=e.properties.get(n);if(t.program){let s=e.getContext(),i=t.program;s.useProgram(i.program);let n=i.getUniforms();o.forEach((function(e){n.setValue(s,e,r[e].value)}))}}}setParametersForShader(e){let t,s=this.icn3d,i=s.icn3dui.parasCls.backgroundColors[s.opts.background.toLowerCase()],n=2.5*s.maxD,l=4*s.maxD,r=void 0!==s.biomtMatrices&&s.biomtMatrices.length*s.cnt>s.maxatomcnt;"yes"===s.opts.slab?r?t=.1:void 0!==s.camMaxDFactorFog?(t=s.maxD*s.camMaxDFactorFog-10,n=2.5*s.maxD-t<0?0:2.5*s.maxD-t,l=4*s.maxD-t):t=s.maxD*s.camMaxDFactor:t=.1;let o=void 0!==e?e:1,a=s.shininess/100*.5;s.uniforms=THREE.UniformsUtils.merge([THREE.UniformsLib.common,{modelViewMatrix:{value:new THREE.Matrix4},modelViewMatrixInverse:{value:new THREE.Matrix4},modelViewMatrixInverseTranspose:{value:new THREE.Matrix4},modelViewProjectionMatrix:{value:new THREE.Matrix4},modelViewProjectionMatrixInverse:{value:new THREE.Matrix4},projectionMatrix:{value:new THREE.Matrix4},projectionMatrixInverse:{value:new THREE.Matrix4},diffuse:{type:"v3",value:[1,1,1]},emissive:{type:"v3",value:[.06,.06,.06]},roughness:{type:"f",value:.5},metalness:{type:"f",value:a},opacity:{type:"f",value:o},nearClip:{type:"f",value:t},ortho:{type:"f",value:0},shrink:{type:"f",value:.13},fogColor:{type:"v3",value:[i.r,i.g,i.b]},fogNear:{type:"f",value:n},fogFar:{type:"f",value:l},fogDensity:{type:"f",value:2}},THREE.UniformsLib.ambient,THREE.UniformsLib.lights]),s.defines={USE_COLOR:1,NEAR_CLIP:1,CAP:1},"yes"!==s.opts.fog||r||(s.defines.USE_FOG=1,"orthographic"===s.opts.camera&&(s.defines.FOG_EXP2=1)),s.bExtFragDepth&&(s.defines.USE_LOGDEPTHBUF_EXT=1)}drawImpostorShader(){this.icn3d.icn3dui.bNode||(this.setParametersForShader(),this.createImpostorShaderSphere("SphereImpostor"),this.createImpostorShaderCylinder("CylinderImpostor"))}getShader(e){this.icn3d.icn3dui;let t=$NGL_shaderTextHash[e];return t=t.replace(/#include\s+(\S+)/gim,(function(e,t){let s;return THREE.ShaderChunk.hasOwnProperty(t)&&(s=THREE.ShaderChunk[t]),s||""})),t}createImpostorShaderBase(e,t,s,i,n,l,r,o,a){let d=this.icn3d;d.icn3dui;let c=new THREE.ShaderMaterial({defines:d.defines,uniforms:d.uniforms,vertexShader:this.getShader(e+".vert"),fragmentShader:this.getShader(e+".frag"),depthTest:!0,depthWrite:!0,lights:!0});c.extensions.fragDepth=!0,"CylinderImpostor"==e?d.CylinderImpostorMaterial=c:"SphereImpostor"==e&&(d.SphereImpostorMaterial=c);let h,p,m=l*r,u=l*o,g=new(m>65535?Uint32Array:Uint16Array)(u);for(let e=0;e=0;t--){let s=a.children[t];s.onBeforeRender=e.impostorCls.onBeforeRender,s.frustumCulled=!1}l.add(a)}void 0!==e.mdl_ghost&&(a=e.mdl_ghost.clone(),this.applyMat(a,d),r.add(a));let c=e.center.clone();this.applyMat(c,d,!0),s.add(c),++t}e.mdl.add(n),e.mdlImpostor.add(l),e.mdl_ghost.add(r),void 0!==e.bSetInstancing&&e.bSetInstancing?(e.maxD=e.maxDAssembly,e.center=e.centerAssembly.clone(),e.applyCenterCls.setCenter(e.center),e.cameraCls.setCamera()):(e.maxD*=Math.sqrt(t),e.center=e.ParserUtilsCls.getMassCenter(s,t),e.maxDAssembly=e.maxD,e.centerAssembly=e.center.clone(),e.applyCenterCls.setCenter(e.center),e.cameraCls.setCamera()),e.bSetInstancing=!0}createInstancedGeometry(e){let t=this.icn3d,s=t.icn3dui,i=e.geometry,n=new THREE.InstancedBufferGeometry,l=[],r=[],o=[],a=[],d=[],c=[],h=[],p=[];if(t.bImpo&&"Cylinder"==e.type){t.instancedMaterial=this.getInstancedMaterial("CylinderInstancing");let e=s.hashUtilsCls.hashvalue2array(i.attributes.position1.array),r=s.hashUtilsCls.hashvalue2array(i.attributes.color.array),m=s.hashUtilsCls.hashvalue2array(i.attributes.position2.array),u=s.hashUtilsCls.hashvalue2array(i.attributes.color2.array),g=s.hashUtilsCls.hashvalue2array(i.index.array),f=s.hashUtilsCls.hashvalue2array(i.attributes.radius.array),b=s.hashUtilsCls.hashvalue2array(i.attributes.mapping.array);l=l.concat(e),o=o.concat(r),h=h.concat(m),p=p.concat(u),a=a.concat(g),d=d.concat(f),c=c.concat(b),n.setAttribute("position1",new THREE.BufferAttribute(new Float32Array(l),3)),n.setAttribute("color",new THREE.BufferAttribute(new Float32Array(o),3)),n.setAttribute("position2",new THREE.BufferAttribute(new Float32Array(h),3)),n.setAttribute("color2",new THREE.BufferAttribute(new Float32Array(p),3)),n.setAttribute("radius",new THREE.BufferAttribute(new Float32Array(d),1)),n.setAttribute("mapping",new THREE.BufferAttribute(new Float32Array(c),3)),n.setIndex(new THREE.BufferAttribute(new Uint32Array(a),1)),e=null,r=null,m=null,u=null,g=null,f=null,b=null}else if(t.bImpo&&"Sphere"==e.type){t.instancedMaterial=this.getInstancedMaterial("SphereInstancing");let e=s.hashUtilsCls.hashvalue2array(i.attributes.position.array),r=s.hashUtilsCls.hashvalue2array(i.attributes.color.array),h=s.hashUtilsCls.hashvalue2array(i.index.array),p=s.hashUtilsCls.hashvalue2array(i.attributes.radius.array),m=s.hashUtilsCls.hashvalue2array(i.attributes.mapping.array);l=l.concat(e),o=o.concat(r),a=a.concat(h),d=d.concat(p),c=c.concat(m),n.setAttribute("position",new THREE.BufferAttribute(new Float32Array(l),3)),n.setAttribute("color",new THREE.BufferAttribute(new Float32Array(o),3)),n.setAttribute("radius",new THREE.BufferAttribute(new Float32Array(d),1)),n.setAttribute("mapping",new THREE.BufferAttribute(new Float32Array(c),2)),n.setIndex(new THREE.BufferAttribute(new Uint32Array(a),1)),e=null,r=null,h=null,p=null,m=null}else{t.instancedMaterial=this.getInstancedMaterial("Instancing");let e=i.attributes.position?s.hashUtilsCls.hashvalue2array(i.attributes.position.array):[],d=i.attributes.normal?s.hashUtilsCls.hashvalue2array(i.attributes.normal.array):[],c=i.attributes.color?s.hashUtilsCls.hashvalue2array(i.attributes.color.array):[],h=i.index?s.hashUtilsCls.hashvalue2array(i.index.array):[];l=l.concat(e),r=r.concat(d),o=o.concat(c),a=a.concat(h);let p=[],m="CylinderGeometry"==i.type?1:0;for(let e=0,t=l.length/3;e0&&(e.dAtoms=t.hashUtilsCls.cloneHash(s)),e.bShowHighlight=!1}e.applyMapCls.removeSurfaces(),e.applyMapCls.applySurfaceOptions(),e.applyMapCls.removeMaps(),e.applyMapCls.applyMapOptions(),e.applyMapCls.removeEmmaps(),e.applyMapCls.applyEmmapOptions(),e.applyMapCls.removePhimaps(),e.axes=[],e.pc1&&e.axesCls.setPc1Axes(),e.drawCls.draw(),e.bShowHighlight=!0,e.opts.rotationcenter="molecule center"}alternateWrapper(){let e=this.icn3d;e.icn3dui,e.bAlternate=!0,this.alternateStructures(),e.bAlternate=!1}}class ct{constructor(e){this.icn3d=e}draw(e){let t=this.icn3d,s=t.icn3dui;if(!t.bRender||t.hAtoms&&0!=Object.keys(t.hAtoms)||(t.hAtoms=s.hashUtilsCls.cloneHash(t.atoms)),t.sceneCls.rebuildScene(),t.bImpo&&t.impostorCls.drawImpostorShader(),t.setColorCls.applyPrevColor(),void 0!==t.biomtMatrices&&t.biomtMatrices.length>1)if(t.bAssembly&&1==Object.keys(t.structures).length&&(void 0===s.cfg.mmdbid&&1==s.cfg.bu||void 0!==s.cfg.mmdbid&&1==s.cfg.bu&&Object.keys(t.atoms).length*t.biomtMatrices.length>t.maxatomcnt))t.instancingCls.drawSymmetryMates();else{let e=!0;t.applyCenterCls.centerSelection(void 0,e)}let i=void 0!==t.hAtoms?Object.keys(t.hAtoms).length:0;if(i>0&&i0){e.children[0].scale.z=t[0].distance,t[0].point.sub(r.mdl.position);let s=r.rayThreshold,i=r.rayCls.getAtomsFromPosition(t[0].point,s);for(;!i&&s<10;)s+=.5,i=r.rayCls.getAtomsFromPosition(t[0].point,s);i&&(r.pAtom=i,this.showPickingVr(r.pk,i))}}}}catch(e){}}showPickingVr(e,t){let s=this.icn3d;if(s.icn3dui,e||(e=2),1===e)s.hAtoms[t.serial]=1;else if(2===e){let e=t.structure+"_"+t.chain+"_"+t.resi;s.hAtoms=s.residues[e]}else if(3===e)s.hAtoms=s.pickingCls.selectStrandHelixFromAtom(t);else if(4===e)s.hAtoms=s.pickingCls.select3ddomainFromAtom(t);else if(5===e){let e=t.structure+"_"+t.chain;s.hAtoms=s.chains[e]}2===e?s.residueLabelsCls.addResidueLabels(s.hAtoms,void 0,void 0,!0):1===e&&s.residueLabelsCls.addAtomLabels(atoms),s.setOptionCls.setStyle("proteins",t.style)}render_base(){let e=this.icn3d,t=e.icn3dui,s=this;if(t.bNode)return;let i=e.bControlGl&&!t.bNode?window.cam:e.cam;if(e.directionalLight){let t=new THREE.Quaternion;t.setFromUnitVectors(new THREE.Vector3(0,0,e.cam_z).normalize(),i.position.clone().normalize()),e.directionalLight.position.copy(e.lightPos.clone().applyQuaternion(t).normalize()),e.directionalLight2.position.copy(e.lightPos2.clone().applyQuaternion(t).normalize()),e.directionalLight3.position.copy(e.lightPos3.clone().applyQuaternion(t).normalize())}if(e.bVr||e.renderer.setPixelRatio(window.devicePixelRatio),e.bVr){let t=.04;if(e.controllers){let i=this.updateGamepadState();for(let n=0,l=e.controllers.length;n{const i=e.gamepad.axes;let r=parseInt(1e3*i[t]),o=parseInt(-1e3*i[s]);n.push(r),l.push(o)})),{xArray:n,yArray:l}}return{xArray:[0,0],yArray:[0,0]}}}class ht{constructor(e){this.icn3d=e}getAtomsWithinAtom(e,t,s,i,n,l,r){let o=this.icn3d;o.icn3dui;let a=this.getNeighboringAtoms(e,t,s,r);i&&(o.resid2Residhash={});let d={};for(let e in t){let c,h,p=o.atoms[e],m=p.structure+"_"+p.chain+"_"+p.resi;for(let e in o.residues[m])if(o.atoms[e]&&("CA"===o.atoms[e].name&&"C"===o.atoms[e].elem||"O3'"===o.atoms[e].name||"O3*"===o.atoms[e].name)){c=o.atoms[e];break}void 0===c&&(c=p),i&&(h=p.resn+" $"+p.structure+"."+p.chain+":"+p.resi,void 0===o.resid2Residhash[h]&&(o.resid2Residhash[h]={}));let u=p.structure+"_"+p.chain+"_"+p.resi;for(let e in a){let m=a[e];if(!o.crossstrucinter&&p.structure!=m.structure)continue;if(!r&&m.serial in t)continue;if(o.bOpm&&"DUM"===m.resn)continue;let g=m.coord.distanceTo(p.coord);if(go?r:o,d=Math.sqrt(a),c=(d+s)*(d+s),h={};for(let r in e){let e=n.atoms[r];!i&&t.hasOwnProperty(e.serial)||(this.bOpm&&"DUM"===e.resn||e.coord.xl[1][0]+s||e.coord.yl[1][1]+s||e.coord.zl[1][2]+s||(e.coord.x-l[2][0])*(e.coord.x-l[2][0])+(e.coord.y-l[2][1])*(e.coord.y-l[2][1])+(e.coord.z-l[2][2])*(e.coord.z-l[2][2])e.coord.x?n:e.coord.x,l=l>e.coord.y?l:e.coord.y,r=r>e.coord.z?r:e.coord.z}return[[t,s,i],[n,l,r],[o/c,a/c,d/c]]}hideContact(){let e=this.icn3d;e.icn3dui,e.opts.contact="no",void 0===e.lines&&(e.lines={}),e.lines.contact=[],e.contactpnts=[];for(let t in e.atoms)e.atoms[t].style2="nothing";for(let t in e.sidec)e.hAtoms.hasOwnProperty(t)&&(e.atoms[t].style2=e.opts.sidec);for(let t in e.water)e.hAtoms.hasOwnProperty(t)&&(e.atoms[t].style=e.opts.water)}}class pt{constructor(e){this.icn3d=e}isHbondDonorAcceptor(e){let t=this.icn3d;if(t.icn3dui,"N"==e.name&&!e.het||"N"==e.elem&&"Arg"==e.resn||"N"==e.elem&&"Asn"==e.resn||"N"==e.elem&&"Gln"==e.resn||"N"==e.elem&&"Lys"==e.resn||"N"==e.elem&&"Trp"==e.resn)return"donor";if("O"==e.name&&!e.het||"S"==e.elem&&"Met"==e.resn||"O"==e.elem&&"Asn"==e.resn||"O"==e.elem&&"Asp"==e.resn||"O"==e.elem&&"Gln"==e.resn||"O"==e.elem&&"Glu"==e.resn)return"acceptor";if("S"==e.elem&&"Cys"==e.resn||"N"==e.elem&&"His"==e.resn||"O"==e.elem&&"Ser"==e.resn||"O"==e.elem&&"Thr"==e.resn||"O"==e.elem&&"Tyr"==e.resn)return"both";if("Pro"==e.resn)return"none";if("N"==e.elem){if("Asn"==e.resn||"Gln"==e.resn)return"both";let s=0,i=0;for(let i=0,n=e.bonds.length;i1?"ring":"donor":"none"}if("O"==e.elem&&1==e.bonds.length){if("Asn"==e.resn||"Gln"==e.resn)return"both";for(let s=0,i=e.bonds.length;s=2?"acceptor":"both"}if("O"==e.elem&&2==e.bonds.length){for(let s=0,i=e.bonds.length;s1);++t)"H"!=s.atoms[e.bonds[t]].elem&&(i=s.atoms[e.bonds[t]],l[r++].subVectors(s.atoms[e.bonds[t]].coord,e.coord));if(1===r)for(let t=0,n=i.bonds.length;t1);++t)"H"!=s.atoms[i.bonds[t]].elem&&s.atoms[i.bonds[t]].serial!=e.serial&&l[r++].subVectors(s.atoms[i.bonds[t]].coord,e.coord);if(2!==r)return;let o=l[0].cross(l[1]);return Math.abs(Math.PI/2-o.angleTo(n))}isValidHbond(e,t,s){let i=this.icn3d;i.icn3dui;let n,l,r=this.isHbondDonorAcceptor(e),o=this.isHbondDonorAcceptor(t),a=50*Math.PI/180,d=50*Math.PI/180,c=90*Math.PI/180,h=30*Math.PI/180;if("donor"==r&&("acceptor"==o||"both"==o||"ring"==o)||"acceptor"==o&&("donor"==r||"both"==r||"ring"==r))n=e,l=t;else if("acceptor"==r&&("donor"==o||"both"==o||"ring"==o)||"donor"==o&&("acceptor"==r||"both"==r||"ring"==r))l=e,n=t;else{if("both"!=r&&"ring"!=r||"both"!=o&&"ring"!=o)return!1;n=e,l=t,i.nucleotides.hasOwnProperty(e.serial)&&i.nucleotides.hasOwnProperty(t.serial)&&("ring"==r||"ring"==o)||(e.het||t.het)&&"ring"==r&&"ring"==o||(h=90*Math.PI/180)}let p=this.calcAngles(n,l),m=90*Math.PI/180;for(let e=0,t=p.length;ed)return!1;let u=this.calcPlaneAngle(n,l);if(void 0!==u&&u>h)return!1;let g=this.calcAngles(l,n),f=90*Math.PI/180;for(let e=0,t=g.length;ea)return!1;let b=this.calcPlaneAngle(l,n);return!(void 0!==b&&b>c)}calculateChemicalHbonds(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(0===Object.keys(e).length||0===Object.keys(t).length)return;r.resid2Residhash={};let a,d,c={},h=s*s;for(let t in e){let s=e[t],n=i?"LYS"===s.resn&&"N"===s.elem&&"N"!==s.name||"ARG"===s.resn&&("NH1"===s.name||"NH2"===s.name)||("GLU"===s.resn||"ASP"===s.resn)&&"O"===s.elem&&"O"!==s.name||s.het&&("N"===s.elem||"O"===s.elem||"S"===s.elem):"N"===s.elem||"O"===s.elem||"S"===s.elem&&(s.het||"Cys"===s.resn||"Met"===s.resn);n=r.bOpm?n&&"DUM"!==s.resn:n,n&&(a=s.structure+"_"+s.chain+"_"+s.resi,d=a+"_"+s.name,c[d]=s)}let p={},m={},u=.5,g=-27.888,f={};for(let e in t){let b=t[e],C=i?"LYS"===b.resn&&"N"===b.elem&&"N"!==b.name||"ARG"===b.resn&&("NH1"===b.name||"NH2"===b.name)||("GLU"===b.resn||"ASP"===b.resn)&&"O"===b.elem&&"O"!==b.name||b.het&&("N"===b.elem||"O"===b.elem||"S"===b.elem):"N"===b.elem||"O"===b.elem||"S"===b.elem&&(b.het||"Cys"===b.resn||"Met"===b.resn);if(C=r.bOpm?C&&"DUM"!==b.resn:C,C){a=b.structure+"_"+b.chain+"_"+b.resi,d=a+"_"+b.name;let e=b.resn+" $"+b.structure+"."+b.chain+":"+b.resi+"@"+b.name;void 0===r.resid2Residhash[e]&&(r.resid2Residhash[e]={});for(let t in c){if(i&&!(("LYS"!==b.resn&&"ARG"!==b.resn||"LYS"!==c[t].resn&&"ARG"!==c[t].resn)&&("GLU"!==b.resn&&"ASP"!==b.resn||"GLU"!==c[t].resn&&"ASP"!==c[t].resn)))continue;if(!r.crossstrucinter&&b.structure!=c[t].structure)continue;if(a==t.substr(0,t.lastIndexOf("_")))continue;let d=Math.abs(b.coord.x-c[t].coord.x);if(d>s)continue;let C=Math.abs(b.coord.y-c[t].coord.y);if(C>s)continue;let y=Math.abs(b.coord.z-c[t].coord.z);if(y>s)continue;let v=d*d+C*C+y*y;if(v>h)continue;if(!r.proteins.hasOwnProperty(b.serial)||!r.proteins.hasOwnProperty(c[t].serial)||"N"!==b.name&&"O"!==b.name||"O"!==c[t].name&&"N"!==c[t].name){if(!this.isValidHbond(b,c[t],s))continue}else{if(b.name===c[t].name)continue;if(b.structure==c[t].structure&&b.chain==c[t].chain&&Math.abs(b.resi-c[t].resi)<=1)continue;let e,i="N"===b.name?b:c[t],n="O"===b.name?b:c[t];if("Pro"===i.resn)continue;if(void 0===i.hcoord){if(!this.isValidHbond(b,c[t],s))continue}else{let s,l=i.hcoord,o=i.coord,a=n.structure+"_"+n.chain+"_"+n.resi;for(let e in r.residues[a])if("C"===r.atoms[e].name){s=r.atoms[e];break}if(!s)continue;let d=s.coord,h=n.coord,p=l.distanceTo(h),m=l.distanceTo(d),f=o.distanceTo(d),C=o.distanceTo(h);e=p2||f[c[t].serial]>2)continue;void 0===f[b.serial]?f[b.serial]=1:++f[b.serial],void 0===f[c[t].serial]?f[c[t].serial]=1:++f[c[t].serial],"graph"!==n&&(i?(r.saltbridgepnts.push({serial:b.serial,coord:b.coord}),r.saltbridgepnts.push({serial:c[t].serial,coord:c[t].coord})):(r.hbondpnts.push({serial:b.serial,coord:b.coord}),r.hbondpnts.push({serial:c[t].serial,coord:c[t].coord})));let w=c[t].structure+"_"+c[t].chain+"_"+c[t].resi;p=o.hashUtilsCls.unionHash(p,r.residues[a]),p=o.hashUtilsCls.unionHash(p,r.residues[w]),m[a]=1,m[w]=1;let _=c[t].resn+" $"+c[t].structure+"."+c[t].chain+":"+c[t].resi+"@"+c[t].name,S=a+"_"+b.resn+","+w+"_"+c[t].resn;void 0!==r.resids2interAll[S]&&void 0!==r.resids2interAll[S].ionic&&r.resids2interAll[S].ionic.hasOwnProperty(e+","+_)||(r.resid2Residhash[e][_]=v.toFixed(1),l||(void 0===r.resids2inter[S]&&(r.resids2inter[S]={}),void 0===r.resids2inter[S].hbond&&(r.resids2inter[S].hbond={}),r.resids2inter[S].hbond[e+","+_]=v.toFixed(1)),void 0===r.resids2interAll[S]&&(r.resids2interAll[S]={}),void 0===r.resids2interAll[S].hbond&&(r.resids2interAll[S].hbond={}),r.resids2interAll[S].hbond[e+","+_]=v.toFixed(1))}}}let b=Object.keys(m);if("graph"!==n)for(let e=0,t=b.length;en)return!1;let c=Math.abs(e.coord.y-t.coord.y);if(c>n)return!1;let h=Math.abs(e.coord.z-t.coord.z);if(h>n)return!1;let p=d*d+c*c+h*h;if(p>l)return!1;"graph"!==s&&("halogen"==i?(a.halogenpnts.push({serial:e.serial,coord:e.coord}),a.halogenpnts.push({serial:t.serial,coord:t.coord})):"pi-cation"==i?(a.picationpnts.push({serial:e.serial,coord:e.coord}),a.picationpnts.push({serial:t.serial,coord:t.coord})):"pi-stacking"==i&&(a.pistackingpnts.push({serial:e.serial,coord:e.coord}),a.pistackingpnts.push({serial:t.serial,coord:t.coord})));let m=t.resn+" $"+t.structure+"."+t.chain+":"+t.resi+"@"+t.name;a.resid2Residhash[r][m]=p.toFixed(1);let u=e.structure+"_"+e.chain+"_"+e.resi+"_"+e.resn+","+t.structure+"_"+t.chain+"_"+t.resi+"_"+t.resn;return o||(void 0===a.resids2inter[u]&&(a.resids2inter[u]={}),void 0===a.resids2inter[u][i]&&(a.resids2inter[u][i]={}),a.resids2inter[u][i][r+","+m]=p.toFixed(1)),void 0===a.resids2interAll[u]&&(a.resids2interAll[u]={}),void 0===a.resids2interAll[u][i]&&(a.resids2interAll[u][i]={}),a.resids2interAll[u][i][r+","+m]=p.toFixed(1),!0}getRingNormal(e){if(this.icn3d.icn3dui,e.length<3)return;let t=e[0].clone().sub(e[1]),s=e[1].clone().sub(e[2]);return t.cross(s).normalize()}getAromaticRings(e,t,s){let i=this.icn3d;i.icn3dui;let n=[],l=[],r=[],o=[];if("nucleotide"==s){let s=new THREE.Vector3,a=new THREE.Vector3;if("A"==e.trim().toUpperCase()||"DA"==e.trim().toUpperCase()||"G"==e.trim().toUpperCase()||"DG"==e.trim().toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"N1"==t.name||"C2"==t.name||"N3"==t.name||"C6"==t.name?(s.add(t.coord),r.push(t.coord)):"C4"==t.name||"C5"==t.name?(s.add(t.coord),a.add(t.coord),r.push(t.coord),o.push(t.coord)):"N7"!=t.name&&"C8"!=t.name&&"N9"!=t.name||(a.add(t.coord),o.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r))),5==o.length&&(a.multiplyScalar(.2),n.push(a),l.push(this.getRingNormal(o)))}else if("C"==e.trim().toUpperCase()||"DC"==e.trim().toUpperCase()||"T"==e.trim().toUpperCase()||"DT"==e.trim().toUpperCase()||"U"==e.trim().toUpperCase()||"DU"==e.trim().toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"N1"==t.name||"C2"==t.name||"N3"==t.name||"C6"==t.name?(s.add(t.coord),r.push(t.coord)):"C4"!=t.name&&"C5"!=t.name||(s.add(t.coord),r.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r)))}}else if("protein"==s){let s=new THREE.Vector3,a=new THREE.Vector3;if("PHE"==e.toUpperCase()||"TYR"==e.toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"CG"!=t.name&&"CD1"!=t.name&&"CE1"!=t.name&&"CZ"!=t.name&&"CE2"!=t.name&&"CD2"!=t.name||(s.add(t.coord),r.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r)))}else if("HIS"==e.toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"CG"!=t.name&&"ND1"!=t.name&&"CE1"!=t.name&&"NE2"!=t.name&&"CD2"!=t.name||(s.add(t.coord),r.push(t.coord))}5==r.length&&(s.multiplyScalar(.2),n.push(s),l.push(this.getRingNormal(r)))}else if("TRP"==e.toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"CZ2"==t.name||"CH2"==t.name||"CZ3"==t.name||"CE3"==t.name?(s.add(t.coord),r.push(t.coord)):"CD2"==t.name||"CE2"==t.name?(s.add(t.coord),a.add(t.coord),r.push(t.coord),o.push(t.coord)):"CG"!=t.name&&"CD1"!=t.name&&"NE1"!=t.name||(a.add(t.coord),o.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r))),5==o.length&&(a.multiplyScalar(.2),n.push(a),l.push(this.getRingNormal(o)))}}return{piPosArray:n,normalArray:l}}dfs_cycle(e,t,s){let i=this.icn3d;if(i.icn3dui,2==i.ring_color[e])return s;if(1==i.ring_color[e]){s++;let n=t;for(i.ring_mark[n]=s;n!=e;)n=i.ring_par[n],i.ring_mark[n]=s;return s}if(i.ring_par[e]=t,i.ring_color[e]=1,void 0!==i.atoms[e])for(let t=0,n=i.atoms[e].bonds.length;t=3&&o<=6&&a[0]&&a[1]&&a[2]&&a[3]){let i=a[0].clone().sub(a[1]).normalize(),r=a[1].clone().sub(a[2]).normalize(),d=a[2].clone().sub(a[3]).normalize(),c=i.cross(r).normalize(),h=c.dot(d);if(Math.abs(h)<.052){l.multiplyScalar(1/o);let i=t.atoms[n];s[e+"_pi"+n]={resn:i.resn,name:"pi"+n,coord:l,serial:i.serial,structure:i.structure,chain:i.chain,resi:i.resi,normal:c}}}}return s}hideHalogenPi(){let e=this.icn3d;e.icn3dui,e.opts.halogen="no",e.opts["pi-cation"]="no",e.opts["pi-stacking"]="no",void 0===e.lines&&(e.lines={}),e.lines.halogen=[],e.lines["pi-cation"]=[],e.lines["pi-stacking"]=[],e.halogenpnts=[],e.picationpnts=[],e.pistackingpnts=[];for(let t in e.atoms)e.atoms[t].style2="nothing";for(let t in e.sidec)e.hAtoms.hasOwnProperty(t)&&(e.atoms[t].style2=e.opts.sidec);for(let t in e.water)e.hAtoms.hasOwnProperty(t)&&(e.atoms[t].style=e.opts.water)}}class ut{constructor(e){this.icn3d=e}calculateIonicInteractions(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(0===Object.keys(e).length||0===Object.keys(t).length)return;r.resid2Residhash={};let a,d,c={},h={},p=s*s;for(let t in e){let s=e[t];if("ARG"===s.resn&&"NH2"===s.name||"GLU"===s.resn&&"OE2"===s.name||"ASP"===s.resn&&"OD2"===s.name)continue;let i=("LYS"===s.resn||"HIS"===s.resn)&&"N"===s.elem&&"N"!==s.name||"ARG"===s.resn&&("NH1"===s.name||"NH2"===s.name)||s.het&&-1!==o.parasCls.cationsTrimArray.indexOf(s.elem)||s.het&&"N"===s.elem&&1==s.bonds.length,n=this.isAnion(s);i=r.bOpm?i&&"DUM"!==s.resn:i,n=r.bOpm?n&&"DUM"!==s.resn:n,(i||n)&&(a=s.structure+"_"+s.chain+"_"+s.resi,d=a+"_"+s.name,i&&(c[d]=s),n&&(h[d]=s))}let m={},u={};for(let e in t){let i=t[e];if("ARG"===i.resn&&"NH2"===i.name||"GLU"===i.resn&&"OE2"===i.name||"ASP"===i.resn&&"OD2"===i.name)continue;let g=("LYS"===i.resn||"HIS"===i.resn)&&"N"===i.elem&&"N"!==i.name||"ARG"===i.resn&&("NH1"===i.name||"NH2"===i.name)||i.het&&-1!==o.parasCls.cationsTrimArray.indexOf(i.elem),f=this.isAnion(i);if(g=r.bOpm?g&&"DUM"!==i.resn:g,f=r.bOpm?f&&"DUM"!==i.resn:f,g||f){a=i.structure+"_"+i.chain+"_"+i.resi,d=a+"_"+i.name;let e=i.resn+" $"+i.structure+"."+i.chain+":"+i.resi+"@"+i.name;void 0===r.resid2Residhash[e]&&(r.resid2Residhash[e]={});let t={};g?t=h:f&&(t=c);let b,C=i.structure+"_"+i.chain+"_"+i.resi;g&&"ARG"===i.resn&&"NH1"===i.name?b=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[C],"NH2"):f&&"GLU"===i.resn&&"OE1"===i.name?b=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[C],"OE2"):f&&"ASP"===i.resn&&"OD1"===i.name&&(b=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[C],"OD2"));let y=void 0===b?i.coord:i.coord.clone().add(b.coord).multiplyScalar(.5);for(let d in t){if(a==d.substr(0,d.lastIndexOf("_")))continue;if(!r.crossstrucinter&&i.structure!=t[d].structure)continue;let c,h=t[d].structure+"_"+t[d].chain+"_"+t[d].resi;f&&"ARG"===t[d].resn&&"NH1"===t[d].name?c=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[h],"NH2"):g&&"GLU"===t[d].resn&&"OE1"===t[d].name?c=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[h],"OE2"):g&&"ASP"===t[d].resn&&"OD1"===t[d].name&&(c=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[h],"OD2"));let b=void 0===c?t[d].coord:t[d].coord.clone().add(c.coord).multiplyScalar(.5),C=Math.abs(y.x-b.x);if(C>s)continue;let v=Math.abs(y.y-b.y);if(v>s)continue;let w=Math.abs(y.z-b.z);if(w>s)continue;let _=C*C+v*v+w*w;if(_>p)continue;"graph"!==n&&(r.saltbridgepnts.push({serial:i.serial,coord:y}),r.saltbridgepnts.push({serial:t[d].serial,coord:b}));let S=t[d].structure+"_"+t[d].chain+"_"+t[d].resi;m=o.hashUtilsCls.unionHash(m,r.residues[a]),m=o.hashUtilsCls.unionHash(m,r.residues[S]),u[a]=1,u[S]=1;let A=t[d].resn+" $"+t[d].structure+"."+t[d].chain+":"+t[d].resi+"@"+t[d].name;r.resid2Residhash[e][A]=_.toFixed(1);let x=a+"_"+i.resn+","+S+"_"+t[d].resn;l||(void 0===r.resids2inter[x]&&(r.resids2inter[x]={}),void 0===r.resids2inter[x].ionic&&(r.resids2inter[x].ionic={}),r.resids2inter[x].ionic[e+","+A]=_.toFixed(1)),void 0===r.resids2interAll[x]&&(r.resids2interAll[x]={}),void 0===r.resids2interAll[x].ionic&&(r.resids2interAll[x].ionic={}),r.resids2interAll[x].ionic[e+","+A]=_.toFixed(1)}}}let g=Object.keys(u);if("graph"!==n)for(let e=0,t=g.length;e1?1/(n-1):1;for(let n in e){let e=t.atoms[n];e.color=e.het?s.parasCls.atomColors[e.elem]||s.parasCls.defaultAtomColor:s.parasCls.thr().setHSL(3/4*(1-i++*l),1,.45),t.atomPrevColors[n]=e.color}}colorRainbow(e){let t=this.icn3d,s=t.icn3dui,i=0,n=0;e=s.hashUtilsCls.intHash(e,t.hAtoms);for(let s in e){t.atoms[s].het||++n}let l=n>1?1/(n-1):1;for(let n in e){let e=t.atoms[n];e.color=e.het?s.parasCls.atomColors[e.elem]||s.parasCls.defaultAtomColor:s.parasCls.thr().setHSL(3/4*i++*l,1,.45),t.atomPrevColors[n]=e.color}}setColorAcrossSets(e,t){let s=this.icn3d,i=s.icn3dui,n=0,l=e.length,r=l>1?1/(l-1):1;for(let l=0,o=e.length;l0)this.setMmdbChainColor();else{let e=-1,s="",l=n.parasCls.stdChainColors.length;for(let r in t){let t=i.atoms[r];t.chain!=s&&(++e,e%=l),t.het?(t.color=n.parasCls.atomColors[t.elem],i.atomPrevColors[r]=t.color):(t.color=n.parasCls.stdChainColors[e],Object.keys(i.chainsColor).length>0&&this.updateChainsColor(t),i.atomPrevColors[r]=t.color),s=t.chain}}break;case"domain":s=0,l=0;let m=Object.keys(i.tddomains);l=m.length,r=l>1?1/(l-1):1;for(let e=0,t=m.length;e1?1/(l-1):1;for(let e=0;e Defined Sets", and try it again.');break;case"secondary structure green":i.sheetcolor="green";for(let e in t){let t=i.atoms[e];t.color=t.het?n.parasCls.atomColors[t.elem]||n.parasCls.defaultAtomColor:n.parasCls.ssColors[t.ss]||n.parasCls.thr(16711935),i.atomPrevColors[e]=t.color}break;case"secondary structure yellow":case"secondary structure":i.sheetcolor="yellow";for(let e in t){let t=i.atoms[e];t.color=t.het?n.parasCls.atomColors[t.elem]||n.parasCls.defaultAtomColor:n.parasCls.ssColors2[t.ss]||n.parasCls.thr(16711935),i.atomPrevColors[e]=t.color}break;case"secondary structure spectrum":s=0,l=0;let u,g,f=[],b=-9999;for(let e in t){if(!i.proteins.hasOwnProperty(e))continue;let t=i.atoms[e];-9999==b&&(u=parseInt(e)),-9999!=b&&(t.ss!=g.ss||Math.abs(t.resi-g.resi)>1||t.ssbegin&&g.ssend)&&("coil"==g.ss||f.push([u,b]),u=e),b=parseInt(e),g=t}"coil"==g.ss||f.push([u,b]),l=f.length,r=l>1?1/(l-1):1;for(let e=0,t=f.length;e100&&(e=100);let r=(i.middB-e)*i.spanBinv1,o=(e-i.middB)*i.spanBinv2;e=90?t.color=n.parasCls.thr().setRGB(0,.325,.839):e>=70&&e<90?t.color=n.parasCls.thr().setRGB(.396,.572,.953):e>=50&&e<70?t.color=n.parasCls.thr().setRGB(1,.859,.075):e<50&&(t.color=n.parasCls.thr().setRGB(1,.49,.271))}i.atomPrevColors[e]=t.color}break;case"b factor":i.middB=50,i.spanBinv1=.02,i.spanBinv2=.02;for(let e in t){let t=i.atoms[e];if(void 0===t.b||isNaN(t.b)||0==parseInt(1e3*t.b))t.color=n.parasCls.thr().setRGB(0,1,0);else{let e=t.b;e>100&&(e=100),e=t.structure.substr(0,4)!=i.defaultPdbId&&t.structure.length>5?100-e:e;let s=(i.middB-e)*i.spanBinv1,l=(e-i.middB)*i.spanBinv2;t.color=et.b&&(o=t.b),a5?100-t.b:t.b,s=i.bfactorArray.indexOf(e)/C;t.color=s<.5?n.parasCls.thr().setRGB(2*s,2*s,1):n.parasCls.thr().setRGB(1,2*(1-s),2*(1-s))}i.atomPrevColors[e]=t.color}break;case"area":if(void 0===i.resid2area){let e=n.hashUtilsCls.cloneHash(i.hAtoms);i.hAtoms=n.hashUtilsCls.cloneHash(i.atoms),i.bCalcArea=!0,i.opts.surface="solvent accessible surface",i.applyMapCls.applySurfaceOptions(),i.bCalcArea=!1,i.hAtoms=n.hashUtilsCls.cloneHash(e)}let y=void 0!==i.midpercent?i.midpercent:35;i.spanBinv1=.02,i.spanBinv2=.02;for(let e in t){let t=i.atoms[e],s=t.structure+"_"+t.chain+"_"+t.resi+"_"+t.resn,l=n.parasCls.residueArea.hasOwnProperty(t.resn)?i.resid2area[s]/n.parasCls.residueArea[t.resn]*100:y;l>100&&(l=100);let r=(y-l)*i.spanBinv1,o=(l-y)*i.spanBinv2;t.color=l

    ";if("atom"==e){let e=["proteins","nucleotides","chemicals","ions","water"];for(let i=0,n=e.length;i[e,s.parasCls.hydrophobicValues[e]]));r.sort(((e,t)=>parseFloat(e[1])-parseFloat(t[1])));var o=r.map((e=>[e[0],Object.keys(n[e[0]])[0]]));l+="
    ","normalized hydrophobic"==e?(l+="Dark green (W, F, Y, L, I, C, M): Hydrophobic
    ",l+="Light green (G, V, S, T, A, N, P, Q): Polar
    ",l+="Grey: Charged, not hydrophobic

    "):(l+="Green (W, F, Y, L, I, C, M): Hydrophobic
    ",l+="Yellow (G, V, S, T, A, N, P, Q): Polar
    ",l+="Red: Negatively Charged
    ",l+="Blue: Positively Charged

    ");let a=0;for(let e of o)s.parasCls.residueAbbrev[e[0]]&&(l+="
    ",l+="
    ",l+=s.parasCls.residueAbbrev[e[0]]+"
    ",a%4==3&&(l+="
    "),++a);l+="
    "}else"b factor"==e?(l+="
    B factor quantitates the uncertainty for each atom. A high B factor reflects that the position is less certain.

    ",l+=s.htmlCls.clickMenuCls.setLegendHtml()):"confidence"==e?l+=s.htmlCls.clickMenuCls.setLegendHtml(!0):(l="",i=!0);$("#"+s.pre+"dl_legend").html(l),s.htmlCls.dialogCls.openDlg("dl_legend","Color Legend"),i&&window.dialog&&window.dialog.dialog("close")}getColorLegendForElem(e,t){let s=this.icn3d,i=s.icn3dui,n="",l={};for(let e in t){let t=s.atoms[e],i=void 0===t||void 0===t.color||"FFFFFF"===t.color.getHexString().toUpperCase()?"DDDDDD":t.color.getHexString();void 0===l[t.elem]&&(l[t.elem]={}),l[t.elem][i]=1}if(Object.keys(l).length>0){n+=""+e+"
    ";let t=Object.keys(l).sort();for(let e=0,s=t.length;e";for(let e in l[s])n+="
    ";n+=i.parasCls.atomnames[s.toUpperCase()]+"

    "}n+="
    "}return n}getRes2color(e,t){let s=this.icn3d,i=s.icn3dui,n={},l=s.firstAtomObjCls.getResiduesFromAtoms(e);for(let e in l){let l=s.residues[e],r=s.firstAtomObjCls.getFirstAtomObj(l),o=t?r.resn:i.parasCls.residueAbbrev[r.resn],a=void 0===r||void 0===r.color||"FFFFFF"===r.color.getHexString().toUpperCase()?"DDDDDD":r.color.getHexString();null!=o&&(void 0===n[o]&&(n[o]={}),n[o][a]=1)}return n}getColorLegendForResidue(e){this.icn3d.icn3dui;let t="",s=this.getRes2color(e);if(Object.keys(s).length>0){t+="
    ";let e=Object.keys(s).sort(),i="",n=0;for(let l=0,r=e.length;l";for(let e in s[o])r+="
    ";r+=o+"
    ",n%4==3&&(r+="
    "),-1!=o.indexOf("(")?(t+=r,++n):i+=r}i&&(t+="
    "+i),t+="
    "}return t}getColorLegendForCharge(e){let t=this.icn3d;t.icn3dui;let s="",i=t.firstAtomObjCls.getResiduesFromAtoms(e),n={};for(let e in i){let s=t.residues[e],i=t.firstAtomObjCls.getFirstAtomObj(s);"ARG"==i.resn||"LYS"==i.resn?n.Positive=1:"HIS"==i.resn?n["Partial-Positive"]=1:"ASP"==i.resn||"GLU"==i.resn||t.nucleotides[i.serial]?n.Negative=1:n.Neutral=1}const l={Positive:"0000ff","Partial-Positive":"8080ff",Negative:"ff0000",Neutral:"888888"};let r=["Positive","Partial-Positive","Negative","Neutral"];s+="
    ";for(let e=0,t=r.length;e",s+="
    ",s+=t,s+="
    ")}return s+="
    (Charges are at pH 7)",s+="
    ",s}getColorLegendForIgstrand(e){this.icn3d.icn3dui;let t="";const s={"A^ Strand":"FF00FF","A Strand":"663399","A* Strand":"FFC0CB","A Strand":"9370db","B Strand":"ba55d3","C Strand":"0000FF","C' Strand":"6495ED","C'' Strand":"006400","D Strand":"00FF00","E Strand":"FFFF00","F Strand":"FFA500","G Strand":"FF0000","G* Strand":"8B0000",Loop:"CCCCCC"};t+="
    ";for(let e in s){t+="",t+="
    ",t+=e,t+="

    "}return t+="
    ",t}}class yt{constructor(e){this.icn3d=e}async showCddSiteAll(){let e=this.icn3d,t=e.icn3dui,s=this;e.chainid2pssmid={};let i=$.map(e.protein_chainid,(function(e){return e})),n=Object.keys(e.protein_chainid),l="https://www.ncbi.nlm.nih.gov/Structure/cdannots/cdannots.fcgi?fmt&frclive&live=lcl&queries="+i;if(1==Object.keys(e.structures).length&&(t.cfg.mmtfid||t.cfg.pdbid||t.cfg.opmid||t.cfg.mmdbid||t.cfg.gi||t.cfg.uniprotid||t.cfg.blast_rep_id||t.cfg.cid||t.cfg.mmcifid)||2==Object.keys(e.structures).length&&t.cfg.align){let e={};try{e.value=await t.getAjaxPromise(l,"jsonp"),s.parseCddData([e],n)}catch(e){return void s.getNoCdd(i)}}else{let i=[];for(let s=0,r=n.length;s',p=h,m=h,u=d.doms;n.bNode&&!i.resid2cdd[c]&&(i.resid2cdd[c]=[]);let g=l.setDomainFeature(u,c,!0,h,p,m);i.chainid2pssmid[c]={pssmid2name:g.pssmid2name,pssmid2fromArray:g.pssmid2fromArray,pssmid2toArray:g.pssmid2toArray};let f=g.acc2domain;h=g.html+"",p=g.html2+"",m=g.html3+"",$("#"+i.pre+"dt_cdd_"+c).html(h),$("#"+i.pre+"ov_cdd_"+c).html(p),$("#"+i.pre+"tt_cdd_"+c).html(m),h='
    ',p=h,m=h;let b=d.motifs;n.bNode&&!i.resid2site[c]&&(i.resid2site[c]=[]),g=l.setDomainFeature(b,c,!1,h,p,m,f),h=g.html,p=g.html2,m=g.html3;let C=a.data[e].sites,y=void 0!==C?C.length:0;for(let e=0;e17&&(s=s.substr(0,17)+"...");let l,r=C[e].title,o=[];for(let t=0,s=C[e].locs.length;t'+s+"
    ",u=''+t.toString()+" Res",g='';m+=d+u+"
    ",h+=d+u+g,p+=d+u+g;let f="site"+e.toString(),b=0,y=0,v=1;for(let t=0,s=i.giSeq[c].length;t1&&(l=s[0]+"..");let r=i.ParserUtilsCls.getResi(c,t);if(h+=''+s+"",n.bNode){let t={};t[c+"_"+r]="site: "+C[e].title,i.resid2site[c].push(t)}p+=i.showSeqCls.insertGapOverview(c,t);let o=n.cfg.blast_rep_id==c?Math.round(i.seqAnnWidth*t/(i.maxAnnoLength+i.nTotalGap)-b-y):Math.round(i.seqAnnWidth*t/i.maxAnnoLength-b-y);o>=0&&(p+='
     
    ',p+='
     
    ',b+=o,y+=v)}else h+="-";g=' '+t.toString()+" Residues",g+="
    ",g+="
    ",h+=g,p+=g}h+="",p+="",m+="",$("#"+i.pre+"dt_site_"+c).html(h),$("#"+i.pre+"ov_site_"+c).html(p),$("#"+i.pre+"tt_site_"+c).html(m)}}for(let e in i.protein_chainid)r.hasOwnProperty(e)||($("#"+i.pre+"dt_cdd_"+e).html(""),$("#"+i.pre+"ov_cdd_"+e).html(""),$("#"+i.pre+"tt_cdd_"+e).html(""),$("#"+i.pre+"dt_site_"+e).html(""),$("#"+i.pre+"ov_site_"+e).html(""),$("#"+i.pre+"tt_site_"+e).html(""));i.showAnnoCls.enableHlSeq(),i.bAjaxCddSite=!0}getNoCdd(e){let t=this.icn3d;t.icn3dui,console.log("No CDD data were found for the protein "+e+"...");for(let e in t.protein_chainid)$("#"+t.pre+"dt_cdd_"+e).html(""),$("#"+t.pre+"ov_cdd_"+e).html(""),$("#"+t.pre+"tt_cdd_"+e).html(""),$("#"+t.pre+"dt_site_"+e).html(""),$("#"+t.pre+"ov_site_"+e).html(""),$("#"+t.pre+"tt_site_"+e).html("");t.showAnnoCls.enableHlSeq(),t.bAjaxCddSite=!0}setDomainFeature(e,t,s,i,n,l,r){let o,a,d,c=this.icn3d,h=c.icn3dui;s&&(r={},o={},a={},d={});let p=void 0!==e?e.length:0,m=s?14:19,u=s?100:120;for(let g=0;gm&&(v=v.substr(0,m)+"...");let w=b+": "+C;s&&(o[p]=C);let _=e[g].locs;if(_)for(let e=0,r=_.length;e'+v+" ",E=''+S.toString()+" Res";l+=R+E+"
    ";let I='';i+=R+E+I,s&&(n+='
    '),n+='
    '+v+"
    ",n+=E+I;let T=b+g.toString();for(let e=0,n=c.giSeq[t].length;e1&&(l=n[0]+"..");let r=c.ParserUtilsCls.getResi(t,e);if(i+=''+n+"",h.bNode){let e={};e[t+"_"+r]=w,s?c.resid2cdd[t].push(e):c.resid2site[t].push(e)}}else i+="-";let M=c.firstAtomObjCls.getFirstCalphaAtomObj(c.chains[t]),P=void 0===M.color||"FFFFFF"===M.color.getHexString()?"DDDDDD":M.color.getHexString(),D=void 0!==M.color?P:"CCCCCC";if(h.cfg.blast_rep_id!=t)for(let s=0,i=r.length;s ',n+='
    '+C+"
    "}else{let s=[],i=[];for(let e=0,t=r.length;e ',n+='
    '+C+"
    "}}I=' '+S.toString()+" Residues",I+="
    ",I+="
    ",i+=I,n+=I,s&&(n+='')}}return{html:i,html2:n,html3:l,acc2domain:r,pssmid2name:o,pssmid2fromArray:a,pssmid2toArray:d}}showAnnoType(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui,a='
    ',d=a,c=a;if(0==n.length)return $("#"+r.pre+"dt_"+s+"_"+e).html(""),$("#"+r.pre+"ov_"+s+"_"+e).html(""),void $("#"+r.pre+"tt_"+s+"_"+e).html("");let h=i;i.length>17&&(i=i.substr(0,17)+"...");let p=[];for(let e=0,t=n.length;e'+i+"
    ",f=''+m.toString()+" Res";c+=g+f+"
    ";let b='';a+=g+f+b,d+=g+f+b;let C=s,y=0,v=0;for(let t=0,i=r.giSeq[e].length;t1&&(c=n[0]+"..");let h=i,p=e+"_"+i,m=n+i;if("ssbond"==s){m="Residue "+p+" has disulfide bond with";let t="";if(void 0!==l[p])for(let e=0,s=l[p].length;e'+c+"",d+=r.showSeqCls.insertGapOverview(e,t);let u=o.cfg.blast_rep_id==e?Math.round(r.seqAnnWidth*t/(r.maxAnnoLength+r.nTotalGap)-y-v):Math.round(r.seqAnnWidth*t/r.maxAnnoLength-y-v);u>=0&&(d+='
     
    ',d+='
     
    ',y+=u,v+=1)}else a+="-"}b=' '+m.toString()+" Residues",b+="",b+="
    ",a+=b,d+=b,a+="",d+="",c+="",$("#"+r.pre+"dt_"+s+"_"+e).html(a),$("#"+r.pre+"ov_"+s+"_"+e).html(d),$("#"+r.pre+"tt_"+s+"_"+e).html(c)}setToolTip(){let e=this.icn3d;e.icn3dui,$("[id^="+e.pre+"snp]").add("[id^="+e.pre+"clinvar]").add("[id^="+e.pre+"ssbond]").add("[id^="+e.pre+"crosslink]").tooltip({content:function(){return $(this).prop("title")},show:null,close:function(e,t){t.tooltip.hover((function(){$(this).stop(!0).fadeTo(400,1)}),(function(){$(this).fadeOut("400",(function(){$(this).remove()}))}))}})}}class vt{constructor(e){this.icn3d=e}showInteraction(e,t){this.icn3d.icn3dui,this.showInteraction_base(e,t)}showInteraction_base(e,t){let s=this.icn3d,i=s.icn3dui;i.bNode&&(s.resid2contact||(s.resid2contact={}),s.resid2contact[e]||(s.resid2contact[e]=[])),void 0===s.chainname2residues&&(s.chainname2residues={});let n=Object.keys(s.chains),l=e,r=Math.round(l.indexOf("_"));if(s.firstAtomObjCls.getFirstCalphaAtomObj(s.chains[l]),void 0===s.chainname2residues[l]){s.chainname2residues[l]={};let t=n.length;if(t>100&&void 0===i.cfg.mmdbid&&void 0===i.cfg.gi&&void 0===i.cfg.blast_rep_id&&void 0===i.cfg.align&&void 0===i.cfg.chainalign)return $("#"+s.pre+"dt_interaction_"+e).html(""),void $("#"+s.pre+"ov_interaction_"+e).html("");for(let e=0;e4)continue;let o,a=s.firstAtomObjCls.getFirstCalphaAtomObj(s.chains[t]);s.chemicals.hasOwnProperty(a.serial)?o="chemical":s.nucleotides.hasOwnProperty(a.serial)?o="nucleotide":s.ions.hasOwnProperty(a.serial)?o="ion":s.proteins.hasOwnProperty(a.serial)?o="protein":s.water.hasOwnProperty(a.serial)&&(o="water");let d=s.contactCls.getAtomsWithinAtom(i.hashUtilsCls.hash2Atoms(s.chains[l],s.atoms),i.hashUtilsCls.hash2Atoms(s.chains[t],s.atoms),4);if(0==Object.keys(d).length)continue;let c={};for(let e in d){let t=s.atoms[e];c[t.structure+"_"+t.chain+"_"+t.resi]=1}let h=t.substr(t.indexOf("_")+1)+"("+o+")";s.chainname2residues[l][h]=Object.keys(c)}}let o='
    ',a=o,d=o,c=0;for(let t in s.chainname2residues[e]){let n=s.chainname2residues[e][t];if(!n)continue;let l="Interact ."+t;l.length>17&&(l=l.substr(0,17)+"...");let r="Interact ."+t,h=[];for(let e=0,t=n.length;e'+l+"
    ",g=''+p.toString()+" Res";d+=u+g+"
    ";let f='';o+=u+g+f,a+=u+g+f;let b="inter"+c.toString(),C=0,y=0,v=1;for(let t=0,n=s.giSeq[e].length;t1&&(d=l[0]+"..");let c=n;if(o+=''+d+"",i.bNode){let t={};t[e+"_"+c]=r,s.resid2contact[e].push(t)}a+=s.showSeqCls.insertGapOverview(e,t);let h=i.cfg.blast_rep_id==e?Math.round(s.seqAnnWidth*t/(s.maxAnnoLength+s.nTotalGap)-C-y):Math.round(s.seqAnnWidth*t/s.maxAnnoLength-C-y);h>=0&&(a+='
     
    ',a+='
     
    ',C+=h,y+=v)}else o+="-"}f=' '+p.toString()+" Residues",f+="
    ",f+="
    ",o+=f,a+=f,++c}o+="",a+="",d+="",$("#"+s.pre+"dt_interaction_"+e).html(o),$("#"+s.pre+"ov_interaction_"+e).html(a),$("#"+s.pre+"tt_interaction_"+e).html(d),i.utilsCls.isMobile()?(s.hlSeqCls.selectSequenceMobile(),s.hlSeqCls.selectChainMobile()):s.hlSeqCls.selectSequenceNonMobile()}}class wt{constructor(e){this.icn3d=e}async showPTM(e,t,s,i,n){let l=this.icn3d,r=l.icn3dui,o=this,a=e.substr(0,e.indexOf("_")),d=e.substr(e.indexOf("_")+1);if("afmem"==s){let t={Transmembrane:[{begin:i,end:n}]};this.setAnnoPtmTransmem("transmem",t,e)}else if(a.length>5){let t,i="https://www.ebi.ac.uk/proteins/api/features/"+a;try{t=await r.getAjaxPromise(i,"json"),o.parsePTM(t,e,s)}catch{return void o.getNoPTM(e,s)}}else{let t,i=a.substr(0,4).toLowerCase(),n="https://www.ebi.ac.uk/pdbe/api/mappings/uniprot/"+i;try{t=await r.getAjaxPromise(n,"json");let a="";l.UPResi2ResiPosPerChain||(l.UPResi2ResiPosPerChain={}),l.UPResi2ResiPosPerChain[e]={};let c=t[i].UniProt,h=!1;for(let t in c){let s=c[t].mappings;for(let i=0,n=s.length;i',o+=r,a+=r;let d=s.substr(0,s.indexOf("_"));for(let c in t){let h=t[c],p=[],m=!1;for(let e=0,t=h.length;e5?p.push(e-1):i.UPResi2ResiPosPerChain&&i.UPResi2ResiPosPerChain[s][e]&&p.push(i.UPResi2ResiPosPerChain[s][e]),!m&&i.residues.hasOwnProperty(s+"_"+e)&&(m=!0)}if(0==p.length)continue;let u=p.length,g="ptm"==e?"PTM: "+c:"Transmembrane";g.length>17&&(g=g.substr(0,17)+"...");let f=c,b='
    '+g+"
    ",C=''+u.toString()+" Res",y='';a+=b+C+"
    ",r+=b+C+y,o+=b+C+y;let v=e+l.toString(),w=0,_=0,S=1;for(let e=0,t=i.giSeq[s].length;e1&&(l=t[0]+"..");let a=i.ParserUtilsCls.getResi(s,e);if(r+=''+t+"",n.bNode){let e={};e[s+"_"+a]=g,i.resid2ptm[s].push(e)}o+=i.showSeqCls.insertGapOverview(s,e);let d=n.cfg.blast_rep_id==s?Math.round(i.seqAnnWidth*e/(i.maxAnnoLength+i.nTotalGap)-w-_):Math.round(i.seqAnnWidth*e/i.maxAnnoLength-w-_);d>=0&&(o+='
     
    ',o+='
     
    ',w+=d,_+=S)}else r+="-";y=' '+u.toString()+" Residues",y+="
    ",y+="
    ",r+=y,o+=y,++l}r+="",o+="",a+="",$("#"+i.pre+"dt_"+e+"_"+s).html(r),$("#"+i.pre+"ov_"+e+"_"+s).html(o),$("#"+i.pre+"tt_"+e+"_"+s).html(a)}getNoPTM(e,t){let s=this.icn3d;s.icn3dui,console.log("No PTM data were found for the chain "+e+"...");let i="ptm"==t?"ptm":"transmem";$("#"+s.pre+"dt_"+i+"_"+e).html(""),$("#"+s.pre+"ov_"+i+"_"+e).html(""),$("#"+s.pre+"tt_"+i+"_"+e).html(""),s.showAnnoCls.enableHlSeq(),s.bAjaxPTM=!0}}class _t{constructor(e){this.icn3d=e}showCrosslink(e,t){let s=this.icn3d;s.icn3dui;let i=this;void 0===s.clbondpnts?setTimeout((function(){i.showCrosslink_base(e,t)}),1e3):this.showCrosslink_base(e,t)}showCrosslink_base(e,t){let s=this.icn3d;s.icn3dui.bNode&&(s.resid2crosslink||(s.resid2crosslink={}),s.resid2crosslink[e]||(s.resid2crosslink[e]=[]));let i=t,n={},l=i.substr(0,i.indexOf("_")),r=s.clbondpnts[l];if(void 0===r)return $("#"+s.pre+"dt_crosslink_"+e).html(""),$("#"+s.pre+"ov_crosslink_"+e).html(""),void $("#"+s.pre+"tt_crosslink_"+e).html("");for(let e=0,t=r.length;e',a=o,d=o,c=e.indexOf("_"),h=e.substr(c+1);if(s)n=e,i=t.domains[e]?t.domains[e].domains:[];else{let e,s=t.moleculeInfor;for(let t in s)if(s[t].chain===h){e=t,n=s[t].name;break}void 0!==e&&void 0!==t.domains[e]&&(i=t.domains[e].domains),void 0===i&&(i=[])}for(let t=0,s=i.length;t17?s.substr(0,17)+"...":s,h=i[t].intervals,p={},m={},u=[],g=[],f={},b=0;for(let e=0,t=h.length;e'+c+" ",y=''+b.toString()+" Res";d+=C+y+"
    ";let v='';o+=C+y+v,a+=C+y+v;let w="domain3d"+t.toString();for(let t=0,s=l.giSeq[e].length;t1&&(n=i[0]+"..");let r=s;o+=''+i+""}else o+="-"}let _=l.firstAtomObjCls.getFirstCalphaAtomObj(l.chains[e]),S=void 0===_.color||"FFFFFF"===_.color.getHexString()?"DDDDDD":_.color.getHexString(),A=void 0!==_.color?S:"CCCCCC";if(r.cfg.blast_rep_id!=e)for(let i=0,n=u.length;i ',a+='"}else{let i=[],n=[];for(let e=0,t=u.length;e ',a+='"}}v=' '+b.toString()+" Residues",v+="",v+="
    ",o+=v,a+=v}o+="",a+="",d+="",$("#"+l.pre+"dt_domain_"+e).html(o),$("#"+l.pre+"ov_domain_"+e).html(a),$("#"+l.pre+"tt_domain_"+e).html(d)}}class At{constructor(e){this.icn3d=e}async showSnp(e,t){this.icn3d.icn3dui,await this.showSnpClinvar(e,t,!0)}async showClinvar(e,t){this.icn3d.icn3dui,await this.showSnpClinvar(e,t,!1)}async showSnpClinvar(e,t,s){let i=this.icn3d.icn3dui,n=this,l=i.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainid="+t;try{let r=await i.getAjaxPromise(l,"jsonp"),o=r.snpgi,a=r.gi;if(s)await n.showSnpPart2(e,t,o);else{let s=o;[6137708,1942289,224510717,2624886,253723219,2554905,75765331,3660278,312207882,319443632,342350956,1827805,109157826,1065265,40889086,6730307,163931185,494469,163931091,60594093,55669745,18655489,17942684,6980537,166235465,6435586,4139398,4389047,364506122,78101667,262118402,20664221,2624640,158430173,494395,28948777,34810587,13399647,3660342,261278854,342350965,384482350,378792570,15988303,213424334,4558333,2098365,10835631,3318817,374074330,332639529,122919696,4389286,319443573,2781341,67464020,194709238,210061039,364506106,28949044,40889076,161172338,17943181,4557976,62738484,365813173,6137343,350610552,17942703,576308,223674070,15826518,1310997,93279697,4139395,255311799,157837067,361132363,357380836,146387678,383280379,1127268,299856826,13786789,1311054,46015217,3402130,381353319,30750059,218766885,340707375,27065817,355333104,2624634,62738384,241913553,304446010].includes(a)&&(s=a),await n.showClinvarPart2(e,t,s)}}catch(t){return void(s?n.processNoSnp(e):n.processNoClinvar(e))}}navClinVar(e){let t=this.icn3d;t.icn3dui;let s=this;t.currClin[e]=-1,$(document).on("click","#"+t.pre+e+"_prevclin",(function(t){let i=s.icn3d;t.stopImmediatePropagation();let n=void 0!==i.resi2disease_nonempty[e]?Object.keys(i.resi2disease_nonempty[e]).length:0;--i.currClin[e],i.currClin[e]<0&&(i.currClin[e]=n-1),s.showClinVarLabelOn3D(e)})),$(document).on("click","#"+t.pre+e+"_nextclin",(function(t){let i=s.icn3d;t.stopImmediatePropagation();let n=void 0!==i.resi2disease_nonempty[e]?Object.keys(i.resi2disease_nonempty[e]).length:0;++i.currClin[e],i.currClin[e]>n-1&&(i.currClin[e]=0),s.showClinVarLabelOn3D(e)}))}showClinVarLabelOn3D(e){let t,s,i=this.icn3d,n=i.icn3dui,l=Object.keys(i.resi2disease_nonempty[e]);t=e,s=t+"_"+(parseInt(l[i.currClin[e]])+i.baseResi[e]).toString();let r="",o=i.resi2disease_nonempty[e][l[i.currClin[e]]];for(let e=0,t=o.length;e0?o[0]:"N/A");let a=i.applyCenterCls.centerAtoms(n.hashUtilsCls.hash2Atoms(i.residues[s],i.atoms));r.length>30&&(r=r.substr(0,30)+"..."),i.selectionCls.removeSelection(),null==i.labels&&(i.labels={}),i.labels.clinvar=[];let d=i.LABELSIZE,c="black"!=i.opts.background?i.colorWhitebkgd:i.colorBlackbkgd;i.analysisCls.addLabel(r,a.center.x+1,a.center.y+1,a.center.z+1,d,c,void 0,"clinvar"),i.hAtoms={};for(let e in i.residues[s])i.hAtoms[e]=1;$("#clinvar_"+i.pre+s).addClass("icn3d-highlightSeq"),void 0===$("#"+i.pre+"modeswitch")[0]||$("#"+i.pre+"modeswitch")[0].checked||i.definedSetsCls.setMode("selection"),i.drawCls.draw()}getSnpLine(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g){let f=this.icn3d,b=f.icn3dui,C="",y=m?"clinvar":"snp",v=!1;for(let e in i){for(let t=0,s=i[e].length;t(from human)",i=" (based on human sequences and mapped to this structure by sequence similarity)"),C+=m?'":'"}else if(2==e&&m){let e=b.utilsCls.isMobile()?"none":"button";C+='
    ',C+='
    '}else C+='
    ';let w=y,_=0,S=0,A={},x={};for(let t=1,i=f.giSeq[h].length;t<=i;++t)if(void 0!==r[t]){++_;let i="";for(let n=0,r=s[t].length;n'+k+" Res":'',u)return C+"
    ";C+='';let O="",R=0,E=0;for(let t=1,a=f.giSeq[h].length;t<=a;++t)if(p){if(void 0!==r[t]){let e=f.giSeq[h][t-1],i=e;e.length>1&&(i=e[0]+"..");let n=f.ParserUtilsCls.getResi(h,t-1)+i+">";for(let e=0,i=s[t].length;e=0&&(C+='
     
    ',C+='
     
    ',R+=r,E+=1):r>0&&(C+='
     
    ',C+='
     
    ',R+=r,E+=1)}}else if(C+=f.showSeqCls.insertGap(h,t-1,"-"),void 0!==r[t])if(m||1!=e){let r=f.giSeq[h][t-1],a=r;r.length>1&&(a=r[0]+"..");let d,c=f.ParserUtilsCls.getResi(h,t-1),p="",u="
    ",y=s[t].length,v=0,_=0;if(2==e&&(v=0,_=y),m){d=1;let r=0;for(let e=v;e0?_+="; ":0!==e&&1!==e||(O='disease="'+v[t]+'"'),_+=v[t]+"("+w[t]+")",++S;""!=_&&(r"+s[t][e],u+=": "+_,C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(m,"snpin3d","3D with scap","SNP in 3D with scap",70,g)+"  ",u+=f.showAnnoCls.addSnpButton(m,"snpinter","Interactions","SNP Interactions in 3D",70,g)+"  ",u+=f.showAnnoCls.addSnpButton(m,"snppdb","PDB","Download SNP PDB",35,g)),u+="
    Links: ClinVar, dbSNP(rs"+i[t][e]+")",e
    "),++r)}r>d&&2==e&&(p+="..")}else{d=1;for(let e=v;e"+s[t][e],g)C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),0!=i[t][e]&&(u+="
    Link: dbSNP(rs"+i[t][e]+")"),e
    ");else{let s=l[t][e].split("; "),a=o[t][e].split("; "),d="",c=0;for(let t=0,i=s.length;t0?d+="; ":0!==e&&1!==e||(O='disease="'+s[t]+'"'),d+=s[t]+"("+a[t]+")",++c;""!=d?(u+=": "+d,C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),u+="
    Links: ClinVar, dbSNP(rs"+i[t][e]+")"):(C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),u+="
    Link: dbSNP(rs"+i[t][e]+")"),e
    ")}}y>d&&2==e&&(p+="..")}u+="
    ",m?"icn3d-clinvar"==A[t]||"icn3d-clinvar-path"==A[t]?C+=1==e?"":""==p||" "==p?"-":''+p+"":C+="-":C+=""==p||" "==p?"-":g?''+p+"":''+p+""}else C+="";else C+="-";return C+=1==e?' '+k+" Residues":'',C+="
    ",C+="
    ",C}processSnpClinvar(e,t,s,i,n){let l=this.icn3d,r=l.icn3dui,o='
    ',a=o,d=o,c='
    ',h=c,p=c,m=!i||n?e.data:e.split("\n"),u={},g={},f={};void 0===l.resi2disease_nonempty[t]&&(l.resi2disease_nonempty[t]={});let b={},C={},y={},v={},w={},_="";r.bNode&&(i?(l.resid2snp||(l.resid2snp={}),l.resid2snp[t]||(l.resid2snp[t]=[])):(l.resid2clinvar||(l.resid2clinvar={}),l.resid2clinvar[t]||(l.resid2clinvar[t]=[])));for(let e=0,s=m.length;e")+1),h=s[4],p=i?"":s[5],S=i?"":s[6],A=i?"":s[7],x=l.ParserUtilsCls.getResi(t,d-1);v[x]=1,""!=S&&(w[x]=1),g[d]=e+1,void 0===u[d]&&(u[d]=[]),u[d].push(c),void 0===C[d]&&(C[d]=[]),C[d].push(h),void 0===y[d]&&(y[d]=[]),y[d].push(p),void 0===f[d]&&(f[d]=[]),f[d].push(S),""!=S&&(void 0===l.resi2disease_nonempty[t][d]&&(l.resi2disease_nonempty[t][d]=[]),l.resi2disease_nonempty[t][d].push(S)),void 0===b[d]&&(b[d]=[]),b[d].push(A)}let S=Object.keys(v),A=Object.keys(w);if(i){let e=!1;o+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,void 0,i),o+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,void 0,i),d+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,!0,i),d+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,!0,i),a+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!0,e,void 0,i),o+="
    ",a+="
    ",d+="",$("#"+l.pre+"dt_snp_"+t).html(o),$("#"+l.pre+"ov_snp_"+t).html(a),$("#"+l.pre+"tt_snp_"+t).html(d)}else{let e=!0;c+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,void 0,i),c+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,void 0,i),p+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,!0,i),p+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,!0,i),h+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!0,e,void 0,i),c+="",h+="",p+="",$("#"+l.pre+"dt_clinvar_"+t).html(c),$("#"+l.pre+"ov_clinvar_"+t).html(h),$("#"+l.pre+"tt_clinvar_"+t).html(p),this.navClinVar(t,s)}l.showAnnoCls.enableHlSeq(),i?l.bAjaxSnp=!0:l.bAjaxClinvar=!0}async showClinvarPart2(e,t,s){let i=this.icn3d,n=i.icn3dui,l=this,r=n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainid_clinvar="+t;i.chainsGene[e]&&i.chainsGene[e].geneSymbol&&(r+="&gene="+i.chainsGene[e].geneSymbol);try{let s=await n.getAjaxPromise(r,"jsonp");if(s&&s.data&&s.data.length>0){let i=!1,n=s;l.processSnpClinvar(n,e,t,i)}else l.processNoClinvar(e)}catch(t){return void l.processNoClinvar(e)}}async showSnpPart2(e,t,s){let i=this.icn3d,n=i.icn3dui,l=this;if(void 0!==s){let s=n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainid_snp="+t;i.chainsGene[e]&&i.chainsGene[e].geneSymbol&&(s+="&gene="+i.chainsGene[e].geneSymbol);try{let i=await n.getAjaxPromise(s,"jsonp");if(i&&i.data&&i.data.length>0){let s=!0,n=!0;l.processSnpClinvar(i,e,t,s,n)}else l.processNoSnp(e)}catch(t){return void l.processNoSnp(e)}}else this.processNoSnp(e),console.log("No gi was found for the chain "+t+"...")}processNoClinvar(e){let t=this.icn3d;t.icn3dui,console.log("No ClinVar data were found for the protein "+e+"..."),$("#"+t.pre+"dt_clinvar_"+e).html(""),$("#"+t.pre+"ov_clinvar_"+e).html(""),t.showAnnoCls.enableHlSeq(),t.bAjaxClinvar=!0}processNoSnp(e){let t=this.icn3d;t.icn3dui,console.log("No SNP data were found for the protein "+e+"..."),$("#"+t.pre+"dt_snp_"+e).html(""),$("#"+t.pre+"ov_snp_"+e).html(""),t.showAnnoCls.enableHlSeq(),t.bAjaxSnp=!0}}class xt{constructor(e){this.icn3d=e}showSsbond(e,t){let s=this.icn3d;s.icn3dui;let i=this;void 0===s.ssbondpnts?setTimeout((function(){i.showSsbond_base(e,t)}),1e3):this.showSsbond_base(e,t)}showSsbond_base(e,t){let s=this.icn3d;s.icn3dui.bNode&&(s.resid2ssbond||(s.resid2ssbond={}),s.resid2ssbond[e]||(s.resid2ssbond[e]=[]));let i=t,n={},l=i.substr(0,i.indexOf("_")),r=s.ssbondpnts[l];if(void 0===r)return $("#"+s.pre+"dt_ssbond_"+e).html(""),$("#"+s.pre+"ov_ssbond_"+e).html(""),void $("#"+s.pre+"tt_ssbond_"+e).html("");for(let e=0,t=r.length;e-s.halfBilayerSize){i[t.structure+"_"+t.chain+"_"+t.resi]=1}}let n=Object.keys(i);s.annoCddSiteCls.showAnnoType(e,t,"transmem","Transmembrane",n)}}class Ot{constructor(e){this.icn3d=e,this.dcut=7,this.MAX_SSE=512,this.ctc_cnt=[];for(let e=0;e=this.curr_ratio+.01||f>this.split_ratio)return e;if(f>this.curr_ratio-.01&&Math.min(m,u)=0&&l[i]==t-e+i;i--);if(i<0)break;for(l[i]++,s=i+1;s-1;i++);for(l=Math.min(i-1,this.max_csz),this.curr_ne0=this.curr_ne1=0,this.curr_ratio=100,s=1;s<=l;s++)this.cut_size(s,i);if(this.top--,0==this.curr_ne0){for(n=this.stack[this.top],e=n;e-1;e++)this.parts[this.np++]=this.elements[e];this.parts[this.np++]=-1,this.n_doms++}else{if(this.save_ratios[this.saved++]=this.curr_ratio,this.curr_ne0>this.min_sse){for(n=this.stack[this.top],e=0;ethis.min_sse){for(n=this.stack[this.top],e=0;e0;)this.process_set()}output(e){let t,s;this.icn3d.icn3dui;let i=[];for(t=0;t<2*e;t++)i.push(0);for(t=s=0;st+n)break;let p=(t-a)*(t-a);p+=(s-c)*(s-c),p+=(i-h)*(i-h);let m=Math.sqrt(p);if(m>n)continue;let u={},g={};parseInt(e.rnum)this.MAX_SSE)return{subdomains:a,substruct:o};let g=h.length,f=r[g-1],b=this.c2b_AlphaContacts(g,i,n,l,t,r),C=[];for(let e=0;e0&&this.elt_size[s.sse-1]>=6&&0!=s.adj_strand2&&e++}for(let e=0;e0)for(let e=0;e0){let e=0;for(let t=0;t<=E;t++){let t=[];for(;e<2*u;){let s=this.parts[e++];if(0==s){I.push(t);break}t.push(s)}}}I.sort((function(e,t){return e[0]-t[0]}));for(let e=0,t=I.length;e=o.length)return{subdomains:a,substruct:o};let n=o[i],l=n.From,r=n.To;for(let e=l;e<=r;e++)s[e]=1;if(0==i&&l>1)for(let e=1;e0){let e=o[i-1].To,t=parseInt(.5*(l-e-1));if(t>0)for(let e=l-t;e<=l-1;e++)s[e]=1}if(i0)for(let e=r+1;e<=r+t;e++)s[e]=1}}let i,n=!1,l=[];for(let e=0;e0&&(d+=", "),d+='{"ss": [';let i=0;for(let s=0,r=n[e].length;s=r&&c<=o&&(i>0&&(d+=", "),d+="["+s+","+n+","+c+","+l[e].x1.toFixed(2)+","+l[e].y1.toFixed(2)+","+l[e].z1.toFixed(2)+","+l[e].x2.toFixed(2)+","+l[e].y2.toFixed(2)+","+l[e].z2.toFixed(2)+"]",++i))}}d+="]",d+=', "domain": [';let r=0;for(let i=0,l=n[e].length;i=l&&n<=a&&(r>0&&(d+=", "),d+="["+n+","+h+","+c.coord.x.toFixed(2)+","+c.coord.y.toFixed(2)+","+c.coord.z.toFixed(2)+"]",++r)}}d+="]}"}return d+="]}",d}}class Rt{constructor(e){this.icn3d=e}clickAddTrackButton(){let e=this.icn3d,t=e.icn3dui,s=this;t.myEventCls.onIds("#"+e.pre+"addtrack_button1","click",(async function(e){let i=s.icn3d;e.stopImmediatePropagation(),dialog.dialog("close");let n=$("#"+i.pre+"track_chainid").val(),l=$("#"+i.pre+"track_gi").val(),r=isNaN(l)?"Acc "+l:"gi "+l,o=t.htmlCls.baseUrl+"pwaln/pwaln.fcgi?from=track",a={targets:n,queries:l},d=await t.getAjaxPostPromise(o,a);s.alignSequenceToStructure(n,d,r)})),t.myEventCls.onIds("#"+e.pre+"addtrack_button2","click",(async function(e){let i=s.icn3d;e.stopImmediatePropagation(),dialog.dialog("close");let n=$("#"+i.pre+"track_chainid").val(),l=$("#"+i.pre+"track_fasta").val(),r=$("#"+i.pre+"fasta_title").val(),o=n.substr(0,n.indexOf("_")),a=n;if(5==o.length)a=a.substr(0,4);else if(o.length>5){a="";for(let e=0,t=i.chainsSeq[n].length;e"),a=o[1].indexOf("\n");o[1].substr(0,a);let d,c=o[1].substr(a+1).replace(/\n/g,""),h=[],p=[];for(let e=2,t=o.length;e0&&(u=f,i.targetGapHash[m+d]={from:m+d,to:u+C-1+d}),g=c[e],f=b,"-"!=c[e]?(++b,w=e,y||(v=e,y=!0)):++C;await i.annotationCls.resetAnnoAll();let _="",S=0;for(let e in i.targetGapHash)S>0&&(_+=" "),_+=e+"_"+i.targetGapHash[e].from+"_"+i.targetGapHash[e].to,++S;t.htmlCls.clickMenuCls.setLogCmd("msa | "+_,!0);let A={};for(let e=0,o=p.length;e0){void 0===i.queryresi2score&&(i.queryresi2score={}),void 0===i.queryresi2score[n]&&(i.queryresi2score[n]={});let e=p.length;for(let t in A){let s=parseInt(A[t]/e*100);i.queryresi2score[n][t]=s}let s=Object.keys(A),l=Math.min.apply(null,s),r=Math.max.apply(null,s),o="";for(let t=l;t<=r;++t)A.hasOwnProperty(t)?o+=Math.round(A[t]/e*9):o+="_";i.opts.color="align custom",i.setColorCls.setColorByOptions(i.opts,i.hAtoms),i.hlUpdateCls.updateHlAll(),i.drawCls.draw(),t.htmlCls.clickMenuCls.setLogCmd("color align custom | "+n+" | range "+l+"_"+r+" | "+o,!0)}})),t.myEventCls.onIds("#"+e.pre+"addtrack_button3","click",(function(e){let i=s.icn3d;e.stopImmediatePropagation(),dialog.dialog("close");let n=$("#"+i.pre+"track_chainid").val(),l=$("#"+i.pre+"track_bed")[0].files[0];if(l){window.File&&window.FileReader&&window.FileList&&window.Blob||alert("The File APIs are not fully supported in this browser.");let e=new FileReader;e.onload=function(e){let l,r=e.target.result.split("\n"),o=!1,a=!1;for(let e=0,d=r.length;e8||d.length<6)&&(a=!1),d.length<9&&(o=!1),d[0];let c,h,p=d[1],m=d[2],u=d[3];d.length,d.length>5&&(c=d[5]),d.length,d.length,d.length>8&&(h=d[8]),d.length,d.length,d.length;let g=u,f="51,51,51";o?f=h:a&&("+"==c&&l.length>0?f=l[0]:"-"==c&&l.length>1?f=l[1]:"."==c&&l.length>2&&(f=l[2]));let b="",C=[];for(let e=0,t=m;e1&&(s=t[0]);let l=i.ParserUtilsCls.getResi(n,e);if(a.hasOwnProperty(n+"_"+l)){let e=i.firstAtomObjCls.getFirstCalphaAtomObj(i.residues[n+"_"+l]),t=void 0===e.color||"FFFFFF"===e.color.getHexString().toUpperCase()?"DDDDDD":e.color.getHexString(),o=void 0!==e.color?t:"CCCCCC";r+=s,d.push("#"+o)}else r+="-",d.push("")}s.showNewTrack(n,l,r,d,void 0,"selection",void 0),t.htmlCls.clickMenuCls.setLogCmd("add track | chainid "+n+" | title "+l+" | text "+s.simplifyText(r)+" | type selection",!0)}))}showNewTrack(e,t,s,i,n,l,r,o,a,d){let c=this.icn3d,h=c.icn3dui,p=!1;"cannot be aligned"==s&&(p=!0);let m=s.replace(/-/g,"").length;if(!o)if(s.length>c.giSeq[e].length)s=s.substr(0,c.giSeq[e].length);else if(s.length20&&(u=u.substr(0,20));let g=h.htmlCls.RESIDUE_WIDTH*s.length+200;$("#"+c.pre+"dt_custom_"+e).append("
    "),$("#"+c.pre+"dt_custom_"+e+"_"+u).width(g),$("#"+c.pre+"ov_custom_"+e).append("
    "),$("#"+c.pre+"ov_custom_"+e+"_"+u).width(g),$("#"+c.pre+"tt_custom_"+e).append("
    "),$("#"+c.pre+"tt_custom_"+e+"_"+u).width(g);let f='
    ',b=f,C=f,y=parseInt(10*Math.random()),v='",w=''+m.toString()+" Pos";C+=v+w+"
    ";let _='';f+=v+w+_,b+=v+w+_;let S=e.indexOf("_"),A="cst"+e.substr(S+1),x=0,k=0,O=(void 0===l||"seq"===l||"custom"===l)&&-1==s.indexOf("cannot-be-aligned")&&-1==s.indexOf("cannot be aligned"),R="identity"===l&&-1==s.indexOf("cannot-be-aligned")&&-1==s.indexOf("cannot be aligned"),E={},I=0,T=1;v="";for(let t=0,a=s.length;t"+d+"",v+=c.showSeqCls.insertGapOverview(e,t);let g=h.cfg.blast_rep_id==e?Math.round(c.seqAnnWidth*t/(c.maxAnnoLength+c.nTotalGap)-x-k):Math.round(c.seqAnnWidth*t/c.maxAnnoLength-x-k);g<0&&(g=0),v+='
     
    ',s=void 0!==i&&""!=i[t]?i[t]:r?"rgb("+r+")":O?"#"+p:"#333",v+='
     
    ',x+=g,k+=1,++T}else f+=p?""+d+"":"-"}if(void 0!==a){v="";let s=[],i=[];for(let e=0,t=a.length;e 
    ',v+='"}}_=''+m.toString()+" Pos",_+="",_+="
    ",_+="",f+=_,b+=v+_,C+="",$("#"+c.pre+"dt_custom_"+e+"_"+u).html(f),$("#"+c.pre+"ov_custom_"+e+"_"+u).html(b),$("#"+c.pre+"tt_custom_"+e+"_"+u).html(C)}alignSequenceToStructure(e,t,s){let i,n,l,r=this.icn3d,o=r.icn3dui;void 0!==t.data&&(i=t.data[0].query,l=Object.keys(t.data[0].targets)[0],n=t.data[0].targets[l],n=n.hsps[0]);let a="",d=[],c={};if(void 0!==i&&void 0!==n){let h=n.scores.e_value.toPrecision(2);h>1e-200&&(h=parseFloat(h).toExponential()),n.scores.bit_score;let p=t.targets[l].seqdata,m=i.seqdata,u=n.segs;for(let e=0,t=u.length;e0&&(l=n+"H"+d+")","coil"==t&&(s.selectionCls.selectResidueList(r,l,l,o,a),o||(o=!0)),r={})),n=e+"_H"+d,r[p]=1,i.ssend&&(h=e+"_C(H"+d,"helix"==t&&(s.selectionCls.selectResidueList(r,n,n,o,a),o||(o=!0)),r={})):"E"==m?(i.ssbegin&&(++c,Object.keys(r).length>0&&(l=n+"S"+c+")","coil"==t&&(s.selectionCls.selectResidueList(r,l,l,o,a),o||(o=!0)),r={})),n=e+"_S"+c,r[p]=1,i.ssend&&(h=e+"_C(S"+c,"sheet"==t&&(s.selectionCls.selectResidueList(r,n,n,o,a),o||(o=!0)),r={})):(n=h+"-",r[p]=1)}}Object.keys(r).length>0&&(l=n+"Cterm)","coil"==t&&s.selectionCls.selectResidueList(r,l,l,o,a))}simplifyText(e){this.icn3d.icn3dui;let t,s,i="",n=!1,l=-1;for(t=0,s=(e=e.replace(/undefined/g," ")).length;t20)return!1;if(void 0!==o.giSeq&&void 0!==o.giSeq[e]){let r=this.getFullText(s);return s=r.text,this.showNewTrack(e,t,s,void 0,void 0,i,n,l),!1}setTimeout((function(){a.checkGiSeq(e,t,s,i,n,l,r+1)}),100)}getFullText(e){this.icn3d.icn3dui;let t="",s=[],i=[],n=e.split(","),l=-1;for(let e=0,r=n.length;ep?t+=c.substr(0,p):t+=c;for(let e=0;e0&&($("#"+e.pre+"anno_cdd")[0].checked?(this.setAnnoTabCdd(),t.htmlCls.clickMenuCls.setLogCmd("set annotation cdd",!0)):(this.hideAnnoTabCdd(),t.htmlCls.clickMenuCls.setLogCmd("hide annotation cdd",!0)))}showAnnoSelectedChains(){let e=this.icn3d,t=e.icn3dui,s={};for(let t in e.hAtoms){let i=e.atoms[t];s[i.structure+"_"+i.chain]=1}$("#"+e.pre+"dl_annotations > .icn3d-annotation").hide();for(let i in s){$("#"+e.pre+"anno_"+i).length&&$("#"+e.pre+"anno_"+i).show();let s=e.firstAtomObjCls.getFirstCalphaAtomObj(e.chains[i]);if(void 0!==s.resn){let i=t.utilsCls.residueName2Abbr(s.resn.substr(0,3));$("#"+e.pre+"anno_"+i).show()}}}showAnnoAllChains(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"dl_annotations > .icn3d-annotation").show()}setAnnoView(e){let t=this.icn3d;t.icn3dui.bNode||("detailed view"===e?(t.view="detailed view",$("#"+t.pre+"dl_anno_view_tabs").tabs("option","active",1)):(t.view="overview",$("#"+t.pre+"dl_anno_view_tabs").tabs("option","active",0)))}setAnnoDisplay(e,t){let s=this.icn3d;s.icn3dui;let i=["giseq","custom","site","ptm","snp","clinvar","cdd","domain","interaction","ssbond","crosslink","transmem"];for(let n in i){let l=i[n];$("[id^="+s.pre+t+"_"+l+"]").attr("style",e)}}showFixedTitle(){this.icn3d.icn3dui;this.setAnnoDisplay("display:block;","tt")}hideFixedTitle(){this.icn3d.icn3dui;this.setAnnoDisplay("display:none!important;","tt")}setAnnoViewAndDisplay(e){let t=this.icn3d;if(t.icn3dui,"detailed view"===e){this.setAnnoView("detailed view");let e="display:block;";this.setAnnoDisplay(e,"dt"),$("#"+t.pre+"seqguide_wrapper").attr("style",e),e="display:none;",this.setAnnoDisplay(e,"ov")}else{this.setAnnoView("overview"),this.hideFixedTitle();let e="display:none;";this.setAnnoDisplay(e,"dt"),$("#"+t.pre+"seqguide_wrapper").attr("style",e),e="display:block;",this.setAnnoDisplay(e,"ov")}}async updateClinvar(){let e=this.icn3d;if(e.icn3dui,void 0===e.bClinvarShown||!e.bClinvarShown)for(let t in e.protein_chainid){let s=e.protein_chainid[t];await e.annoSnpClinVarCls.showClinvar(t,s)}e.bClinvarShown=!0}async updateSnp(){let e=this.icn3d;if(e.icn3dui,void 0===e.bSnpShown||!e.bSnpShown)for(let t in e.protein_chainid){let s=e.protein_chainid[t];await e.annoSnpClinVarCls.showSnp(t,s)}e.bSnpShown=!0}updateDomain(){let e=this.icn3d;e.icn3dui,void 0!==e.bDomainShown&&e.bDomainShown||e.annoDomainCls.showDomainAll(),e.bDomainShown=!0}updateInteraction(){let e=this.icn3d;if(e.icn3dui,void 0===e.bInteractionShown||!e.bInteractionShown)for(let t in e.interactChainbase){let s=e.interactChainbase[t];e.annoContactCls.showInteraction(t,s)}e.bInteractionShown=!0}async updatePTM(){let e=this.icn3d;if(e.icn3dui,void 0===e.bPTMShown||!e.bPTMShown)for(let t in e.PTMChainbase){let s=e.PTMChainbase[t];await e.annoPTMCls.showPTM(t,s,"ptm")}e.bPTMShown=!0}updateSsbond(){let e=this.icn3d;if(e.icn3dui,void 0===e.bSSbondShown||!e.bSSbondShown)for(let t in e.ssbondChainbase){let s=e.ssbondChainbase[t];e.annoSsbondCls.showSsbond(t,s)}e.bSSbondShown=!0}updateCrosslink(){let e=this.icn3d;if(e.icn3dui,void 0===e.bCrosslinkShown||!e.bCrosslinkShown)for(let t in e.crosslinkChainbase){let s=e.crosslinkChainbase[t];e.annoCrossLinkCls.showCrosslink(t,s)}e.bCrosslinkShown=!0}async updateTransmem(){let e=this.icn3d,t=e.icn3dui;if(void 0===e.bTranememShown||!e.bTranememShown)for(let s in e.protein_chainid){let i=e.protein_chainid[s];if(void 0!==t.cfg.opmid)e.annoTransMemCls.showTransmem(s,i);else if(e.bAfMem&&e.afmem_start_end){let t=e.afmem_start_end[0],n=e.afmem_start_end[1];await e.annoPTMCls.showPTM(s,i,"afmem",t,n)}else await e.annoPTMCls.showPTM(s,i,"transmem")}e.bTranememShown=!0}}class It{constructor(e){this.icn3d=e}showAnnotations_part1(){let e=this.icn3d,t=e.icn3dui;if(t.htmlCls.dialogCls.openDlg("dl_selectannotations","Sequences and Annotations"),(void 0===e.bAssemblyNote||!e.bAssemblyNote)&&void 0!==e.asuCnt){let t="
    Assembly Tips: Only the asymmetric unit is shown in the sequence window.
    Click \"Assembly\" in the menu \"View\" to switch between asymmetric unit and biological assembly("+e.asuCnt+" asymmetric unit).
    ";$("#"+e.pre+"dl_annotations_tabs").append(t),e.bAssemblyNote=!0}e.bResetAnno&&(e.giSeq={},e.currClin={},e.resi2disease_nonempty={},e.baseResi={},e.matchedPos={},$("#"+t.pre+"dl_annotations").empty(),e.annotationCls.setAnnoView("overview"));let s={},i={},n={};if(void 0===e.bAnnoShown||!e.bAnnoShown||e.bResetAnno){e.protein_chainid={};let l,r=Object.keys(e.chains);void 0===e.giSeq&&(e.giSeq={}),void 0===e.currClin&&(e.currClin={}),void 0===e.resi2disease_nonempty&&(e.resi2disease_nonempty={}),void 0===e.baseResi&&(e.baseResi={}),void 0===e.matchedPos&&(e.matchedPos={}),l=t.bNode?500:t.cfg.notebook?t.htmlCls.WIDTH/2:$("#"+e.pre+"dl_selectannotations").dialog("option","width"),e.seqAnnWidth=l-120-60-50;for(let l=0,o=r.length;l1)e.protein_chainid[r[l]]=a;else if(e.nucleotides.hasOwnProperty(o.serial)&&e.chainsSeq[r[l]].length>1)s[r[l]]=a;else if(e.chainsSeq[r[l]].length>1)i[r[l]]=a;else{let t=e.chainsSeq[r[l]][0].name,s=r[l]+"_"+e.chainsSeq[r[l]][0].resi;void 0===n[t]&&(n[t]=[]),n[t].push(s)}if((void 0!==t.cfg.pdbid||void 0!==t.cfg.opmid||void 0!==t.cfg.mmcifid||void 0!==t.cfg.mmtfid)&&(e.proteins.hasOwnProperty(o.serial)||e.nucleotides.hasOwnProperty(o.serial)))for(let t=0,s=e.chainsSeq[r[l]].length;te.maxAnnoLength&&(e.protein_chainid.hasOwnProperty(t)||s.hasOwnProperty(t))&&(e.maxAnnoLength=e.chainsSeq[t].length)}return{nucleotide_chainid:s,chemical_chainid:i,chemical_set:n}}async showAnnotations(){let e=this.icn3d,t=e.icn3dui,s=this,i=this.showAnnotations_part1(),n=i.nucleotide_chainid,l=i.chemical_chainid,r=i.chemical_set;if(void 0===e.bAnnoShown||!e.bAnnoShown||e.bResetAnno)if(void 0===t.cfg.blast_rep_id){if(e.bFullUi){if(void 0!==t.cfg.mmtfid){let t=Object.keys(e.structures)[0];await e.mmcifParserCls.downloadMmcifSymmetry(t,"mmtfid")}await this.showAnnoSeqData(n,l,r)}}else if(void 0===t.cfg.blast_rep_id||e.bSmithwm||e.bLocalSmithwm){if(void 0!==t.cfg.blast_rep_id&&(e.bSmithwm||e.bLocalSmithwm)){let i,o,a=[t.cfg.blast_rep_id];if(-1!=t.cfg.query_id.indexOf(">")?o=t.cfg.query_id.substr(t.cfg.query_id.indexOf("\n")+1):!/\d/.test(t.cfg.query_id)||t.cfg.query_id.length>50?o=t.cfg.query_id:a.push(t.cfg.query_id),e.blastAcxn){let s=t.cfg.afid+"_A",n="";for(let t=0,i=e.chainsSeq[s].length;tProteins:

    ":"",a=e.chainsGene[s]&&e.chainsGene[s].geneId?"(Gene: "+e.chainsGene[s].geneSymbol+")":"",d=s.substr(0,s.indexOf("_")),c=d.length>5?''+s+"":s,h="
    "+o+"Annotations of "+c+": "+r+""+a+"   "+this.addButton(s,"icn3d-addtrack","Add Track","Add a custom track",60,i)+"   ";h+=this.addButton(s,"icn3d-customcolor","Custom Color/Tube","Use a custom file to define the colors or tubes in 3D structure",110,i)+"   ",h+=this.addButton(s,"icn3d-helixsets","Helix Sets",'Define sets for each helix in this chain and add them to the menu of "Defined Sets"',60,i)+" "+this.addButton(s,"icn3d-sheetsets","Sheet Sets",'Define sets for each sheet in this chain and add them to the menu of "Defined Sets"',60,i)+" "+this.addButton(s,"icn3d-coilsets","Coil Sets",'Define sets for each coil in this chain and add them to the menu of "Defined Sets"',60,i),$("#"+e.pre+"dl_annotations").append(h);let p=["giseq","cdd","clinvar","snp","site","ptm","ssbond","crosslink","transmem","domain","custom","interaction"];for(let t in p){let i=p[t];$("#"+e.pre+"anno_"+s).append(this.getAnDiv(s,i))}$("#"+e.pre+"anno_"+s).append("


    "),++n}if(t.bNode||e.annoCddSiteCls.setToolTip(),void 0!==e.chainid_seq)await this.processSeqData(e.chainid_seq);else try{let n=[],l=[];for(let e=0,t=i.length;e=6?l.push(i[e]):n.push(i[e]);if(n.length>0){let s=t.htmlCls.baseUrl+"/vastdyn/vastdyn.cgi?chainlist="+n;e.chainid_seq=await t.getAjaxPromise(s,"jsonp")}else e.chainid_seq={};for(let t=0,s=l.length;t40&&(r=r.substr(0,40)+"...");let o="";0==i&&("protein"==s?o="Proteins:

    ":"nucleotide"==s?o="Nucleotides:

    ":"chemical"==s&&(o="Chemicals/Ions/Water:

    ")),$("#"+n.pre+"dl_annotations").append("
    "+o+""+e+": "+r+"
    "),$("#"+n.pre+"anno_"+e).append(this.getAnDiv(e,"giseq")),$("#"+n.pre+"anno_"+e).append(this.getAnDiv(e,"interaction")),$("#"+n.pre+"anno_"+e).append("


    "),n.giSeq[e]=[];for(let t=0;tChemicals/Ions/Water:

    ":"",o=t[0].lastIndexOf("_"),a=t[0].substr(0,o),d=void 0!==l.cfg.mmdbid&&void 0!==n.chainid2sid?n.chainid2sid[a]:void 0;i=void 0!==d?""+e+" ":""+e+"",$("#"+n.pre+"dl_annotations").append("
    "+r+i+"
    "),$("#"+n.pre+"anno_"+e).append("
    "),$("#"+n.pre+"anno_"+e).append("


    ");let c='
    ';c+='",c+='Count: '+t.length+"",c+='';let h=c,p=c;for(let s=0,i=t.length;s3&&(l=i.substr(0,3)),s'+l+""}let m=l.htmlCls.GREY8,u=Math.round(n.seqAnnWidth*t.length/n.maxAnnoLength);u<1&&(u=1),p+='
     
    ',c="",c+="
    ",c+="
    ",h+=c,p+=c,$("#"+n.pre+"dt_giseq_"+e).html(h),$("#"+n.pre+"ov_giseq_"+e).html(p)}async processSeqData(e){let t=this.icn3d,s=t.icn3dui;for(let i in t.protein_chainid){let n=t.protein_chainid[i];if(e.hasOwnProperty(n)){let s=e[n];t.giSeq[i]=s;let l="";for(let e=0;e<10&&e14?"Query: "+o.substr(0,6)+"...":isNaN(s.cfg.query_id)?"Query: "+o:"Query: gi "+o;let a="cannot be aligned";t.queryStart="",t.queryEnd="",t.bRender&&alert("The sequence can NOT be aligned to the structure"),t.showSeqCls.showSeq(i,n,void 0,e,l,a,r)}else if(s.cfg.blast_rep_id==i&&(void 0!==t.seqStructAlignData||void 0!==t.seqStructAlignDataSmithwm)){let e,l,r,o,a,d=s.cfg.oriQuery_id?s.cfg.oriQuery_id:s.cfg.query_id;if(e=d.length>14?"Query: "+d.substr(0,6)+"...":isNaN(s.cfg.query_id)?"Query: "+d:"Query: gi "+d,void 0!==t.seqStructAlignData){let e,s,i=t.seqStructAlignData;if(void 0!==i.data){e=i.data[0].query;let t=Object.keys(i.data[0].targets);s=i.data[0].targets[t[0]],s=void 0!==s&&s.hsps.length>0?s.hsps[0]:void 0}if(void 0!==e&&void 0!==s){l=s.scores.e_value.toPrecision(2),l>1e-200&&(l=parseFloat(l).toExponential()),s.scores.bit_score;let t=Object.keys(i.targets);r=i.targets[t[0]].seqdata,o=e.seqdata,a=s.segs}}else{let e=t.seqStructAlignDataSmithwm;l=e.score,r=e.target.replace(/-/g,""),o=e.query.replace(/-/g,""),a=[];let s=-1,i=-1,n=!1,d={};for(let t=0,l=e.target.length;t0)if(i.orifrom-ni.from-l)for(let t=n+1;t
    "+i+"
    "}addButton(e,t,s,i,n,l){return this.icn3d.icn3dui,"
    "}addSnpButton(e,t,s,i,n,l){let r=this.icn3d;return r.icn3dui,"
    "}conservativeReplacement(e,t){let s=this.icn3d.icn3dui,i=-1!==s.parasCls.b62ResArray.indexOf(e)?s.parasCls.b62ResArray.indexOf(e):s.parasCls.b62ResArray.length-1,n=-1!==s.parasCls.b62ResArray.indexOf(t)?s.parasCls.b62ResArray.indexOf(t):s.parasCls.b62ResArray.length-1;return s.parasCls.b62Matrix[i][n]>0}getColorhexFromBlosum62(e,t){let s=this.icn3d.icn3dui;e=e.toUpperCase(),t=t.toUpperCase();let i=-1!==s.parasCls.b62ResArray.indexOf(e)?s.parasCls.b62ResArray.indexOf(e):s.parasCls.b62ResArray.length-1,n=-1!==s.parasCls.b62ResArray.indexOf(t)?s.parasCls.b62ResArray.indexOf(t):s.parasCls.b62ResArray.length-1,l=s.parasCls.b62Matrix[i][n];if(void 0===l)return"333333";let r="333333";if(l>0){let e=221-parseInt(l/11*221),t=e<10?"0"+e.toString(16):e.toString(16);r="DD"+t+t}else{let e=221-parseInt(-1*l/4*221),t=e<10?"0"+e.toString(16):e.toString(16);r=t+t+"DD"}return r}}class Tt{constructor(e){this.icn3d=e}showSeq(e,t,s,i,n,l,r){let o,a=this.icn3d,d=a.icn3dui,c=!1;if(void 0===d.cfg.mmdbid&&void 0===d.cfg.gi&&void 0===d.cfg.blast_rep_id&&void 0===d.cfg.align&&void 0===d.cfg.chainalign&&void 0===d.cfg.mmdbafid){c=!0,o=[];for(let t=0;t10){u='
    ';let t=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]);void 0===d.cfg.mmdbid&&void 0===d.cfg.gi&&void 0===d.cfg.blast_rep_id&&void 0===d.cfg.align&&void 0===d.cfg.chainalign&&void 0===d.cfg.mmdbafid||void 0===t.resi_ori||t.resi_ori==t.resi||-1!=e.indexOf("Misc")?u+='
    ':u+='
    NCBI Residue Numbers
    ',u+='',b+=u+"
    ",g+=u+'';let s=0,i=0,n="";for(let t=0,l=o.length;t",l%10==0&&(g+=l);let r=e+"_"+l,o=l%10!=0&&l%10!=1&&l%10!=9;if(a.residues.hasOwnProperty(r)){let e=a.firstAtomObjCls.getFirstCalphaAtomObj(a.residues[r]);"H"==a.secondaries[r]&&e.ssbegin?(++s,n='H'+s+"",o&&(g+=n,n="")):"E"==a.secondaries[r]&&e.ssbegin?(++i,"green"==a.sheetcolor?n='S'+i+"":"yellow"==a.sheetcolor&&(n='S'+i+""),o&&(g+=n,n="")):e.ssend&&(n=""),""!=n&&o&&(g+=n,n="")}g+=""}g+='',g+="",g+="
    ",g+="
    ",b+=""}u='
    ',u+='
    ',u+='',b+=u+"
    ",g+=u+'';for(let t=0,s=o.length;t':'',g+=" ";else if("E"==a.secondaries[s]){a.firstAtomObjCls.getFirstCalphaAtomObj(a.residues[s]).ssend?"green"==a.sheetcolor?g+='':"yellow"==a.sheetcolor&&(g+=''):"green"==a.sheetcolor?g+='':"yellow"==a.sheetcolor&&(g+=''),g+=" "}else"c"==a.secondaries[s]?g+=' ':"o"==a.secondaries[s]&&(g+=' ');else g+="-"}g+='',g+="",g+="
    ",g+="
    ",g+="",b+="",u=d.cfg.blast_rep_id===e?'
    ':'
    ';let C="Protein",y="Protein";void 0!==s&&("nucleotide"==s?(C="Nucl.",y="Nucleotide"):"chemical"==s&&(C="Chem.",y="Chemical")),u+='",u+=''+(a.baseResi[e]+1).toString()+"",b+=u+"
    ";let v='';g+=u+v,f+=u+v;let w,_=0;for(let t=0,s=o.length;t1&&(i=s[0]+".."),w=a.ParserUtilsCls.getResi(e,t),a.residues.hasOwnProperty(e+"_"+w)){let n="333333";if(d.cfg.blast_rep_id==e&&void 0!==a.fullpos2ConsTargetpos&&void 0!==a.fullpos2ConsTargetpos[t+_])n=a.fullpos2ConsTargetpos[t+_].color;else{let t=a.firstAtomObjCls.getFirstCalphaAtomObj(a.residues[e+"_"+w]),s=void 0===t.color||"FFFFFF"===t.color.getHexString()?"DDDDDD":t.color.getHexString();n=void 0!==t.color?s:"CCCCCC"}g+=''+i+""}else i=i.toLowerCase(),g+=''+i+""}d.cfg.blast_rep_id==e&&(a.opts.color=a.blastAcxn?"confidence":"conservation",a.setColorCls.setColorByOptions(a.opts,a.atoms));let S=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]),A=S.color?S.color.getHexString():"CCCCCC",x=Math.round(a.seqAnnWidth*o.length/a.maxAnnoLength);if(x<1&&(x=1),d.cfg.blast_rep_id!=e)f+='";else{let t=[],s=[];t.push(0);for(let e=0,i=o.length;e';for(let i=0,n=t.length;i'+e+"
    ";f+="
    "}if(u=''+w+"",u+="",u+="
    ",g+=u,f+=u,d.cfg.blast_rep_id==e){if(void 0!==r&&""!==r){u='",u+='',b+=u+"
    ";let t='';g+=u+t,f+=u+t;let s=0,i=0,l=1;a.queryStart;for(let t=0,n=r.length;t-";else if(" "==n)g+=" ";else{let r=a.fullpos2ConsTargetpos[t].pos;if(a.residues.hasOwnProperty(e+"_"+r)){let s=a.fullpos2ConsTargetpos[t].color;g+=''+n+""}else n=n.toLowerCase(),g+=''+n+"";f+=this.insertGapOverview(e,t);let o=Math.round(a.seqAnnWidth*t/(a.maxAnnoLength+a.nTotalGap)-s-i);o>=0&&(f+='
     
    ',f+='
     
    ',s+=o,i+=l)}}u='',u+="",u+="
    ",g+=u,f+=u}u='
    '+i+"
    ",u+=''+a.queryStart+"",b+=u+"
    ";let t='';g+=u+t,f+=u+t;let s=a.queryStart;for(let t=0,i=l.length;t-":(void 0===a.fullpos2ConsTargetpos||void 0===a.fullpos2ConsTargetpos[t]||a.residues.hasOwnProperty(e+"_"+a.fullpos2ConsTargetpos[t].pos)||(i=i.toLowerCase()),g+=''+i+"",++s)}let o=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]),d=void 0===o.color||"FFFFFF"===o.color.getHexString()?"DDDDDD":o.color.getHexString(),c=void 0!==o.color?d:"CCCCCC",h=[],p=[],m="-";for(let e=0,t=l.length;e ',f+='
    '+i+"
    "}u=''+a.queryEnd+"",u+="",u+="
    ",g+=u,f+=u}if(g+="",f+="",b+="",a.giSeq[e].length>10){let t=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]);if(void 0===d.cfg.mmdbid&&void 0===d.cfg.gi&&void 0===d.cfg.blast_rep_id&&void 0===d.cfg.align&&void 0===d.cfg.chainalign&&void 0===d.cfg.mmdbafid||void 0===t.resi_ori||t.resi_ori==t.resi||-1!=e.indexOf("Misc")){if(a.bShowRefnum&&a.chainid2index.hasOwnProperty(e)){let t=this.showRefNum(o,e);g+=t.html,b+=t.html3;let s=1;t=this.showRefNum(o,e,s),g+=t.html,b+=t.html3,s=2,t=this.showRefNum(o,e,s),g+=t.html,b+=t.html3}else if(a.bShowCustomRefnum&&a.chainsMapping.hasOwnProperty(e)){let t=!0,s=this.showRefNum(o,e,void 0,t);g+=s.html,b+=s.html3}}else{u='
    ',u+='
    ',u+='
    PDB Residue Numbers
    ',u+='',b+=u+"
    ",g+=u+'';for(let t=0,s=o.length;t",e%10==0&&(g+=e+" "),g+=""}else g+=""}g+='',g+="",g+="
    ",g+="
    ",g+="
    ",b+=""}}a.bShowRefnum&&(a.hAtoms=a.hAtomsRefnum,a.hlUpdateCls.updateHlAll()),$("#"+a.pre+"dt_giseq_"+e).html(g),$("#"+a.pre+"ov_giseq_"+e).html(f),$("#"+a.pre+"tt_giseq_"+e).html(b)}showRefNum(e,t,s,i){let n=this.icn3d;n.icn3dui;let l="",r="",o="";for(let e=0,s=n.chainid2index[t].length;eCustom Ref. No.':1==s?'
    Kabat Ref. No.
    ':2==s?'
    IMGT Ref. No.
    ':'
    IgStRAnD Ref. No.
    ',d+='',r+=d+"
    ",l+=d+'';let c=!1;for(let s=0,l=e.length;s0){c=!0;break}}if(1==s&&!c)return{html:"",html3:""};let h=!1;for(let s=0,l=e.length;s0){h=!0;break}}if(2==s&&!h)return{html:"",html3:""};let p,m,u,g,f,b,C,y,v,w=!1,_="",S="",A="",x=1,k={},O=1,R="",E=!1;for(let l=0,r=e.length;l1e3&&"9"!=u.substr(1,1)&&(x=1,E&&R&&(delete k[R],R="")),S&&" "!=_&&f>1e3&&"9"==u.substr(1,1)&&(1==x&&(k.hasOwnProperty(_+g)&&++O,g=u.replace(f.toString(),"")+"_"+O,k[_+g]={},k[_+g].start=b,k[_+g].chainid=t),u=(1e3*parseInt(A)+900+x).toString(),p=_+u,++x))):!S||" "==_||i||s||(1==x&&(k.hasOwnProperty(_+g)?(++O,g=u.replace(f.toString(),"")+"_"+O,k[_+g]={}):k[_+g]={},k[_+g].start=b,k[_+g].chainid=t,R=_+g,E=!0),u=(1e3*parseInt(A)+900+x).toString(),p=_+u,++x),b=u,y=f,C=g,S=_}k[S+C]&&(k[S+C].len=x-1,k[S+C].end=b),O=1,R="",E=!1;let I,T={},M=!0;for(let r=0,o=e.length;r1e3&&"9"!=u.substr(1,1)&&(x=1,E&&R&&(--O,R="")),S&&f>1e3&&"9"==u.substr(1,1)){w=!0,1==x&&(T.hasOwnProperty(I+g)&&(++O,g=u.replace(f.toString(),"")+"_"+O),T[I+g]=1);let e=this.getAdjustedRefnum(k,I,x,A,g,y);f=e.refnum,M=e.bShowRefnum,u=e.refnumStr,p=e.refnumLabel,v=e.refnumLabelNoPostfix,a=e.bHidelabel,_=p.replace(new RegExp(u,"g"),""),++x}y=f}if(i)if(u){l+=parseInt(u)%2==0?''+u+"":' '}else l+="";else if(1==s||2==s)if(u){let e=parseInt(u).toString(),t='style="color:'+this.getRefnumColor(_)+'"';l+=parseInt(e.substr(e.length-2,2))%2==0?"'+u+"":" '}else l+="";else M&&" "!=_?(l+=this.getRefnumHtml(e,u,m,p,_,w,a),w&&(n.residIgLoop[e]=1)):l+=""}else{let t=n.firstAtomObjCls.getFirstAtomObj(n.residues[e]);if(t&&!n.proteins.hasOwnProperty(t.serial)||!S||i||s||I&&"G"==I.substr(0,1))l+="";else{w=!0,1==x&&(T.hasOwnProperty(I+g)&&++O,g=u.replace(f.toString(),"")+"_"+O,T[I+g]=1,E=!0,R=I+g);let t=this.getAdjustedRefnum(k,I,x,A,g,y);f=t.refnum,M=t.bShowRefnum,u=t.refnumStr,p=t.refnumLabel,v=t.refnumLabelNoPostfix,y=f,a=t.bHidelabel,_=p.replace(new RegExp(u,"g"),""),++x,M&&" "!=_?(l+=this.getRefnumHtml(e,u,m,p,_,w,a),w&&(n.residIgLoop[e]=1)):l+=""}}n.resid2refnum[e]=p,n.refnum2residArray.hasOwnProperty(u)?n.refnum2residArray[u].push(e):n.refnum2residArray[u]=[e],n.chainsMapping.hasOwnProperty(t)||(n.chainsMapping[t]={}),n.chainsMapping[t][e]=v,S=I}return l+='',l+="",l+="
    ",l+="",l+="",r+="",{html:l,html3:r}}getAdjustedRefnum(e,t,s,i,n,l){let r,o,a,d;this.icn3d.icn3dui;let c=!1,h=!0;if(e[t+n]){let i=parseInt(e[t+n].start),p=parseInt(e[t+n].end),m=e[t+n].start.replace(i.toString(),""),u=e[t+n].end.replace(p.toString(),""),g=e[t+n].len;s<=(e[t+n].nextStrand?parseInt(g/2+.5):g)?(r=i+s,o=r+m,a=t+o):(r=p-(g+1-s),o=r+u,a=void 0!==e[t+n].nextStrand?e[t+n].nextStrand+o:" "+o),d=t+r,1!=s&&s!=p-1||(c=!0),1==s&&i!=l&&(h=!1,r=0,o="",a="",d="")}else r=0,o="",a="",d="",c=!0;return{refnum:r,refnumStr:o,refnumLabel:a,refnumLabelNoPostfix:d,bHidelabel:c,bShowRefnum:h}}getRefnumHtml(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui,d=parseInt(t).toString(),c=this.getRefnumColor(n),h=l?'style="color:'+c+'"':'style="color:'+c+'; text-decoration: underline overline;"',p=parseInt(d.substr(d.length-2,2));parseInt(d.substr(d.length-3,3));let m="";if(50!=p||l)if(p%2!=0||52==p||r)m+=" ';else{m+="'+(isNaN(t)?p+t.substr(t.length-1,1):p)+""}else o.hAtomsRefnum=a.hashUtilsCls.unionHash(o.hAtomsRefnum,o.residues[e]),m+="'+i.substr(0,1)+""+i.substr(1)+"";return m}getRefnumColor(e){let t=this.icn3d.icn3dui;return"A^"==e?"#FF00FF":"A"==e?"#663399":"A*"==e?"#FFC0CB":"A'"==e?"#9370db":"B"==e?"#ba55d3":"C"==e?"#0000FF":"C'"==e?"#6495ED":"C''"==e?"#006400":"D"==e?"#00FF00":"E"==e?"#FFFF00":"F"==e?"#FFA500":"G"==e?"#FF0000":"G*"==e?"#8B0000":t.htmlCls.GREYB}insertGap(e,t,s,i){let n=this.icn3d;n.icn3dui;let l="";if(void 0!==n.targetGapHash&&n.targetGapHash.hasOwnProperty(t))for(let e=0;e"+s+"";return l}insertGapOverview(e,t){let s=this.icn3d,i="";if(s.icn3dui.cfg.blast_rep_id==e&&void 0!==s.targetGapHash&&s.targetGapHash.hasOwnProperty(t)){i+='
     
    '}return i}setAlternativeSeq(e,t){let s=this.icn3d;s.icn3dui;let i=s.chainsSeq[e];s.giSeq[e]=[];for(let t=0,n=i.length;t1&&s.htmlCls.clickMenuCls.setLogCmd("select sets "+e,!0)}else{let o={};if(void 0!==$(e).attr("domain")||void 0!==$(e).attr("feat")||void 0!==$(e).attr("3ddomain")||void 0!==$(e).attr("custom")){t.hlUpdateCls.hlSummaryDomain3ddomain(e);let a,d,c,h=$(e).attr("from").split(","),p=$(e).attr("to").split(",");r.substr(0,r.indexOf("_"));for(let s=0,i=h.length;s1&&s.htmlCls.clickMenuCls.setLogCmd("select sets "+c,!0)}}else{t.bCtrl||t.bShift?(t.currSelectedSets.push(i),t.selectionCls.selectAChain(r,i,!0,!0)):(t.currSelectedSets=[i],t.selectionCls.selectAChain(r,i,t.bAlignSeq)),t.bAlignSeq?s.htmlCls.clickMenuCls.setLogCmd("select alignChain "+r,!0):s.htmlCls.clickMenuCls.setLogCmd("select chain "+r,!0);let e=t.currSelectedSets.join(" or ");t.currSelectedSets.length>1&&s.htmlCls.clickMenuCls.setLogCmd("select sets "+e,!0)}else t.hlObjectsCls.removeHlObjects(),t.hlUpdateCls.removeHl2D(),$("#"+t.pre+"atomsCustom").val("")}}selectResidues(e,t){let s=this.icn3d,i=s.icn3dui;if(!i.bNode&&(!1!==s.bSelectResidue||s.bShift||s.bCtrl||s.selectionCls.removeSelection(),void 0!==e&&""!==e)){e=e.substr(e.indexOf("_")+1),s.bSelectResidue=!0,$(t).toggleClass("icn3d-highlightSeq");let n=e.substr(e.indexOf("_")+1);if(s.residues.hasOwnProperty(n))if($(t).hasClass("icn3d-highlightSeq")){for(let e in s.residues[n])s.hAtoms[e]=1;if(s.selectedResidues[n]=1,s.bAnnotations&&void 0!==$(t).attr("disease")){let e=$(t).attr("disease"),l=s.applyCenterCls.centerAtoms(i.hashUtilsCls.hash2Atoms(s.residues[n],s.atoms)),r=15;e.length>r&&(e=e.substr(0,r)+"...");let o=s.LABELSIZE,a=i.htmlCls.GREYD;s.analysisCls.addLabel(e,l.center.x,l.center.y,l.center.z,o,a,void 0,"custom")}}else{for(let e in s.residues[n])delete s.hAtoms[e];delete s.selectedResidues[n],s.hlObjectsCls.removeHlObjects()}}}}class Pt{constructor(e){this.icn3d=e}update2DdgmContent(){let e=this.icn3d,t=e.icn3dui,s="";void 0!==t.cfg.mmdbid||void 0!==t.cfg.gi?(s+=e.diagram2dCls.draw2Ddgm(e.interactionData,e.inputid,void 0,!0),s+=e.diagram2dCls.set2DdgmNote(),$("#"+e.pre+"dl_2ddgm").html(s)):e.mmdbidArray&&(void 0!==t.cfg.align||void 0!==t.cfg.chainalign||e.bRealign)&&(s+=e.diagram2dCls.draw2Ddgm(e.interactionData1,e.mmdbidArray[0].toUpperCase(),0,!0),void 0!==e.mmdbid_q&&e.mmdbid_q===e.mmdbid_t?s+=e.diagram2dCls.draw2Ddgm(e.interactionData2,e.mmdbidArray[0].toUpperCase(),1,!0):s+=e.diagram2dCls.draw2Ddgm(e.interactionData2,e.mmdbidArray[1].toUpperCase(),1,!0),s+=e.diagram2dCls.set2DdgmNote(!0),$("#"+e.pre+"dl_2ddgm").html(s))}changeSeqColor(e){let t=this.icn3d,s=t.icn3dui;for(let i=0,n=e.length;i0&&($("#"+e.pre+"dl_2ddgm svg line").attr("stroke","#000000"),$("#"+e.pre+"dl_2ddgm line").attr("stroke-width",1))}removeHlMenus(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"atomsCustom").val(""),$("#"+e.pre+"atomsCustom")[0].blur()}updateHlAll(e,t,s,i){let n=this.icn3d,l=n.icn3dui;n.prevHighlightAtoms=l.hashUtilsCls.cloneHash(n.hAtoms),this.updateHlObjects(i),void 0!==e?this.updateHlSeqInChain(e,s):this.updateHlSeq(void 0,void 0,s),this.updateHl2D(),(void 0===t||t)&&this.updateHlMenus(e)}updateHlObjects(e){let t=this.icn3d;t.icn3dui,t.hlObjectsCls.removeHlObjects(),(t.hAtoms&&t.atoms&&Object.keys(t.hAtoms).length0&&(e=s.defNames2Residues[i]);let t={};if(void 0!==s.defNames2Atoms[i]&&s.defNames2Atoms[i].length>0){for(let e=0,n=s.defNames2Atoms[i].length;e0&&(r=t.firstAtomObjCls.getFirstCalphaAtomObj(l))}let o=void 0!==r&&void 0!==r.color?"#"+r.color.getHexString():"#FFFFFF",a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] rect[class='icn3d-hlnode']"),d=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] rect[class='icn3d-basenode']");void 0!==a&&(t.diagram2dCls.highlightNode("rect",a,d,l),$(a).attr("fill",o)),a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] circle[class='icn3d-hlnode']"),d=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] circle[class='icn3d-basenode']"),void 0!==a&&(t.diagram2dCls.highlightNode("circle",a,d,l),$(a).attr("fill",o)),a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] ellipse[class='icn3d-hlnode']"),void 0!==a&&t.diagram2dCls.highlightNode("ellipse",a,void 0,l),a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] polygon[class='icn3d-hlnode']"),d=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] polygon[class='icn3d-basenode']"),void 0!==a&&(t.diagram2dCls.highlightNode("polygon",a,d,l),$(a).attr("fill",o))}if(void 0!==t.lineArray2d)for(let e=0,i=t.lineArray2d.length;e1){let e={},l=[],o=[],a=[],c=[],h=[],m=[],u=[],g=[],f=[],b=[],C=[],y=[],v={};for(let t=0,s=p.length;t0&&(E=1,t=i.getGraphCls.getNodeTopBottom(c[e],d,void 0,E,g[e]),h[e]=t.nodeArray1,m[e]=t.nodeArray2,d=n.hashUtilsCls.unionHash(d,t.name2node),E=2,t=i.getGraphCls.getNodeTopBottom(c[e],d,void 0,E,y[e]),f[e]=t.nodeArray1,b[e]=t.nodeArray2,d=n.hashUtilsCls.unionHash(d,t.name2node)),x[e]=l[e].length,k[e]=o[e].length,O=Math.max(O,k[e]),R.push(p[e])}let I,T,M,P,D,H=1,F=3*H,L=7*H,N=10,U=10,q=30,$=20;t?(M=(n.utilsCls.sumArray(x)+2*R.length)*(F+L)+4*U+2*q+$*R.length,T=(O+2)*(F+L)+2*N+q):(I=110+$,M=I*R.length,T=(O+2)*(F+L)+2*N),Object.keys(i.chainsMapping).length>0&&(M*=3),t?(i.scatterplotWidth=2*T,D=i.scatterplotWidth,P=n.scatterplotid):(i.linegraphWidth=2*T,D=i.linegraphWidth,P=n.linegraphid),s=0==R.length?"No interactions found for each structure

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

    ",s+="";let j,B=0;E=0,j=this.drawGraphPerType(E,p,t,l,o,a,d,B,I,$,x,F,L,U),B=j.heightFinal,s+=j.html,Object.keys(i.chainsMapping).length>0&&(E=1,j=this.drawGraphPerType(E,p,t,h,m,u,d,B,I,$,x,F,L,U),B=j.heightFinal,s+=j.html,E=2,j=this.drawGraphPerType(E,p,t,f,b,C,d,B,I,$,x,F,L,U),B=j.heightFinal,s+=j.html),s+=""}else if(t){let e,t,l,c,h=p[0],m=o.length,u=a.length,g=1,f=3*g,b=7*g,C=30;t=(m+2)*(f+b)+2*10+C,e=(u+2)*(f+b)+2*10+C,i.scatterplotWidth=2*e,c=i.scatterplotWidth,l=n.scatterplotid,s=r.length>0?"":"No interactions found for these two sets

    ",s+="",s+=this.drawScatterplot_base(o,a,r,d,0),i.lineGraphStr+=i.getGraphCls.updateGraphJson(h,1,o,a,r),s+=""}else{let e=p[0],t=o.length,l=a.length,c=1,h=3*c,m=7*c,u=110,g=10,f=t>l?t*(h+m)+2*g:l*(h+m)+2*g;i.linegraphWidth=2*f,s=r.length>0?"":"No interactions found for these two sets

    ",s+="",s+=this.drawLineGraph_base(o,a,r,d,0),i.lineGraphStr+=i.getGraphCls.updateGraphJson(e,1,o,a,r),s+=""}return i.lineGraphStr+="}\n",i.scatterplotStr=i.lineGraphStr,t?$("#"+i.pre+"scatterplotDiv").html(s):$("#"+i.pre+"linegraphDiv").html(s),s}drawGraphPerType(e,t,s,i,n,l,r,o,a,d,c,h,p,m){let u=this.icn3d;u.icn3dui;let g,f,b="",C=2==t.length&&"2"==t[1].replace(t[0],"");0==e?(g="Interactions in ",f=""):1==e?(g="Common interactions in ",f="_common"):2==e&&(g="Different interactions in ",f="_diff");for(let y=0,v=t.length;y0&&(u.lineGraphStr+=", \n"):u.lineGraphStr+=", \n",u.lineGraphStr+=u.getGraphCls.updateGraphJson(t[y],y+f,i[y],n[y],l[y])}return{heightFinal:o,html:b}}getIdArrayFromNode(e){let t=this.icn3d.icn3dui,s=[];s.push(""),s.push("");let i=e.r.substr(4);return s=s.concat(t.utilsCls.getIdArray(i)),s}drawLineGraph_base(e,t,s,i,n,l,r){let o,a,d=this.icn3d,c=d.icn3dui,h="",p=e.length,m=t.length;p>m?(o=10,a=10*Math.abs(p-m)*.5+10):(a=10,o=10*Math.abs(p-m)*.5+10),l&&(h+=""+l+"");let u=30+n,g=80+n,f="",b={},C={};for(let t=0;t",h+="Interaction of residue "+n.id+" with residue "+l.id+"",h+="
    ")}return h+=f,h}drawScatterplot_base(e,t,s,i,n,l,r,o,a){let d=this.icn3d;d.icn3dui;let c="",h=e.length,p=t.length,m=l?3:7,u=(h+1)*(3+m)+30+40;r&&(c+=""+r+"");let g=n+u-(50+(3+m)),f=40+(3+m),b="",C={},y={};for(let t=0;t"):(h+="",h+="Interaction of residue "+t.id+" with residue "+s.id+"",h+=l?"":"",h+=""))),h}copyStylesInline(e,t){this.icn3d.icn3dui;let s=["svg","g"];for(let i=0;i";return b+=""+e.id+"",o?(b+="",b+=""+g+""):(b+="",b+=""+g+""),b+="",b}getNodeTopBottom(e,t,s,i,n){let l=this.icn3d.icn3dui,r=this,o=[],a=[],d={};for(let s in e){let e=t[s];if(e){if(1==i||2==i){if(e=l.hashUtilsCls.cloneHash(e),1==i){let t=n[s]?n[s]:"-";e.id+="=>"+t}else{let t=n[s]?n[s]:"--";e.id+="==>"+t}d[e.id]=e}"a"==e.s?o.push(e):"b"==e.s?a.push(e):"ab"==e.s&&(o.push(e),a.push(e))}}return o.sort((function(e,t){return r.compNode(e,t)})),a.sort((function(e,t){return r.compNode(e,t,s)})),{nodeArray1:o,nodeArray2:a,name2node:d}}updateGraphJson(e,t,s,i,n){let l=this.icn3d.icn3dui,r="";return r+='"structure'+t+'": {"id": "'+e+'", "nodes1":[',r+=l.utilsCls.getJSONFromArray(s),r+='], \n"nodes2":[',r+=l.utilsCls.getJSONFromArray(i),r+='], \n"links":[',r+=l.utilsCls.getJSONFromArray(n),r+="]}",r}updateGraphColor(){let e=this.icn3d,t=e.icn3dui;if(void 0!==e.graphStr){let s=JSON.parse(e.graphStr),i={};for(let t in e.residues){let s=e.firstAtomObjCls.getFirstAtomObj(e.residues[t]);i[t]=s.color.getHexString().toUpperCase()}let n={};for(let e=0,l=s.nodes.length;e0&&c==e.chain&&(n.resid2ncbi[e.resi]==n.resid2ncbi[p]+1||n.resid2ncbi[e.resi]==n.resid2ncbi[p])&&(o.push('{"source": "'+h+'", "target": "'+u+'", "v": '+d+', "c": "'+f+'"}'),e.ssbegin&&(d=l.htmlCls.ssValue),e.ssend&&(d=l.htmlCls.coilValue)),c=e.chain,h=u,p=e.resi,++a}}return{node:r,link:o}}getHbondLinksForSet(e,t){let s=this.icn3d,i=s.icn3dui,n={},l=parseFloat($("#"+s.pre+"hbondthreshold").val()),r=e,o=r;if(Object.keys(o).length>0&&Object.keys(r).length>0){let e=!1;s.hBondCls.calculateChemicalHbonds(i.hashUtilsCls.intHash2Atoms(s.dAtoms,o,s.atoms),i.hashUtilsCls.intHash2Atoms(s.dAtoms,r,s.atoms),parseFloat(l),e,"graph",!0),n=i.hashUtilsCls.cloneHash(s.resid2Residhash)}return this.getGraphLinks(n,n,i.htmlCls.hbondInsideColor,t,i.htmlCls.hbondValuehbondInsideValue)}getIonicLinksForSet(e,t){let s=this.icn3d,i=s.icn3dui,n={},l=parseFloat($("#"+s.pre+"saltbridgethreshold").val()),r=e,o=r;if(Object.keys(o).length>0&&Object.keys(r).length>0){let e=!1;s.saltbridgeCls.calculateIonicInteractions(i.hashUtilsCls.intHash2Atoms(s.dAtoms,o,s.atoms),i.hashUtilsCls.intHash2Atoms(s.dAtoms,r,s.atoms),parseFloat(l),e,"graph",!0),n=i.hashUtilsCls.cloneHash(s.resid2Residhash)}return this.getGraphLinks(n,n,i.htmlCls.ionicInsideColor,t,i.htmlCls.ionicInsideValue)}getHalogenPiLinksForSet(e,t){let s,i=this.icn3d,n=i.icn3dui,l={},r=e,o=r,a="";return s=parseFloat($("#"+i.pre+"halogenthreshold").val()),Object.keys(o).length>0&&Object.keys(r).length>0&&(i.piHalogenCls.calculateHalogenPiInteractions(n.hashUtilsCls.intHash2Atoms(i.dAtoms,r,i.atoms),n.hashUtilsCls.intHash2Atoms(i.dAtoms,o,i.atoms),parseFloat(s),"graph","halogen",!0),l=n.hashUtilsCls.cloneHash(i.resid2Residhash)),a+=this.getGraphLinks(l,l,n.htmlCls.halogenInsideColor,t,n.htmlCls.halogenInsideValue),s=parseFloat($("#"+i.pre+"picationthreshold").val()),Object.keys(o).length>0&&Object.keys(r).length>0&&(i.piHalogenCls.calculateHalogenPiInteractions(n.hashUtilsCls.intHash2Atoms(i.dAtoms,r,i.atoms),n.hashUtilsCls.intHash2Atoms(i.dAtoms,o,i.atoms),parseFloat(s),"graph","pi-cation",!0),l=n.hashUtilsCls.cloneHash(i.resid2Residhash)),a+=this.getGraphLinks(l,l,n.htmlCls.picationInsideColor,t,n.htmlCls.picationInsideValue),s=parseFloat($("#"+i.pre+"pistackingthreshold").val()),Object.keys(o).length>0&&Object.keys(r).length>0&&(i.piHalogenCls.calculateHalogenPiInteractions(n.hashUtilsCls.intHash2Atoms(i.dAtoms,r,i.atoms),n.hashUtilsCls.intHash2Atoms(i.dAtoms,o,i.atoms),parseFloat(s),"graph","pi-stacking",!0),l=n.hashUtilsCls.cloneHash(i.resid2Residhash)),a+=this.getGraphLinks(l,l,n.htmlCls.pistackingInsideColor,t,n.htmlCls.pistackingInsideValue),a}getContactLinksForSet(e,t,s){let i=this.icn3d;i.icn3dui;let n=[],l="",r="",o={};for(let t in e){let e=i.atoms[t];e.ss==l&&e.chain==r||(Object.keys(o).length>0&&n.push(o),o={}),o[e.serial]=1,l=e.ss,r=e.chain}Object.keys(o).length>0&&n.push(o);let a=n.length,d="";for(let e=0;ed?s?-1:1:ah?1:c0&&Object.keys(a).length>0)){let t,s=c.hBondCls.calculateChemicalHbonds(h.hashUtilsCls.intHash2Atoms(c.dAtoms,d,c.atoms),h.hashUtilsCls.intHash2Atoms(c.dAtoms,a,c.atoms),parseFloat(e),n);n?(c.resid2ResidhashSaltbridge=h.hashUtilsCls.cloneHash(c.resid2Residhash),t="all atoms that have salt bridges with the selected atoms"):(c.resid2ResidhashHbond=h.hashUtilsCls.cloneHash(c.resid2Residhash),t="all atoms that are hydrogen-bonded with the selected atoms");let i={};for(let e in s){i[c.atoms[e].structure+"_"+c.atoms[e].chain+"_"+c.atoms[e].resi]=1}c.hAtoms={};for(let e in i)for(let t in c.residues[e])c.hAtoms[t]=1,c.atoms[t].style2="stick";let l=r+"_auto";c.selectionCls.addCustomSelection(Object.keys(i),l,t,o,!0),c.selectionCls.saveSelectionIfSelected(),c.drawCls.draw()}}showHydrogens(){let e=this.icn3d;if(void 0!==e.icn3dui.cfg.cid)for(let t in e.hAtoms){let s=e.atoms[t];if("H"!==s.elem.substr(0,1)){e.atoms[s.serial].bonds=e.atoms[s.serial].bonds2.concat(),e.atoms[s.serial].bondOrder=e.atoms[s.serial].bondOrder2.concat();for(let t=0,i=e.atoms[s.serial].bonds.length;t0){let i=e.atoms[t].bonds[0];e.atoms[i].bonds.push(s.serial),e.atoms[i].bondOrder&&e.atoms[i].bondOrder.push(1)}e.dAtoms[t]=1}}e.bShowHighlight=!1}hideHydrogens(){let e=this.icn3d;e.icn3dui;for(let t in e.hAtoms){let s=e.atoms[t];if("H"===s.elem.substr(0,1)){if(e.atoms[s.serial].bonds.length>0){let t=e.atoms[s.serial].bonds[0],i=e.atoms[t].bonds?e.atoms[t].bonds.indexOf(s.serial):-1;-1!==i&&(e.atoms[t].bonds.splice(i,1),e.atoms[t].bondOrder&&e.atoms[t].bondOrder.splice(i,1))}delete e.dAtoms[s.serial],delete e.hAtoms[s.serial]}}}hideHbondsContacts(){let e=this.icn3d,t=e.icn3dui,s="set hbonds off";t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.hBondCls.hideHbonds(),s="set salt bridge off",t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.saltbridgeCls.hideSaltbridge(),s="set contact off",t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.contactCls.hideContact(),s="set halogen pi off",t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.piHalogenCls.hideHalogenPi()}showIonicInteractions(e,t,s,i,n,l){let r,o,a,d,c=this.icn3d,h=c.icn3dui;if(!i&&(r="saltbridge",o="salt bridge "+e+" | sets "+t+" "+s+" | "+i,c.opts.saltbridge="yes",a=c.definedSetsCls.getAtomsFromNameArray(t),d=c.definedSetsCls.getAtomsFromNameArray(s),c.firstAtomObjCls.getFirstAtomObj(a),Object.keys(d).length>0&&Object.keys(a).length>0)){let t,s=c.saltbridgeCls.calculateIonicInteractions(h.hashUtilsCls.intHash2Atoms(c.dAtoms,d,c.atoms),h.hashUtilsCls.intHash2Atoms(c.dAtoms,a,c.atoms),parseFloat(e),n);c.resid2ResidhashSaltbridge=h.hashUtilsCls.cloneHash(c.resid2Residhash),t="all atoms that have ionic interactions with the selected atoms";let i={};for(let e in s){i[c.atoms[e].structure+"_"+c.atoms[e].chain+"_"+c.atoms[e].resi]=1}c.hAtoms={};for(let e in i)for(let t in c.residues[e])c.hAtoms[t]=1,c.atoms[t].style2="stick",c.ions.hasOwnProperty(t)&&(c.atoms[t].style2="sphere");let l="saltbridge_auto";c.selectionCls.addCustomSelection(Object.keys(i),l,t,o,!0),c.selectionCls.saveSelectionIfSelected(),c.drawCls.draw()}}showHalogenPi(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(i)return;let a,d,c=l+" "+e+" | sets "+t+" "+s+" | "+i;if(r.opts[l]="yes",a=r.definedSetsCls.getAtomsFromNameArray(t),d=r.definedSetsCls.getAtomsFromNameArray(s),r.firstAtomObjCls.getFirstAtomObj(a),Object.keys(d).length>0&&Object.keys(a).length>0){let t,s=r.piHalogenCls.calculateHalogenPiInteractions(o.hashUtilsCls.intHash2Atoms(r.dAtoms,a,r.atoms),o.hashUtilsCls.intHash2Atoms(r.dAtoms,d,r.atoms),parseFloat(e),n,l);"halogen"==l?(r.resid2ResidhashHalogen=o.hashUtilsCls.cloneHash(r.resid2Residhash),t="all atoms that have halogen bonds with the selected atoms"):"pi-cation"==l?(r.resid2ResidhashPication=o.hashUtilsCls.cloneHash(r.resid2Residhash),t="all atoms that have pi-cation interactions with the selected atoms"):"pi-stacking"==l&&(r.resid2ResidhashPistacking=o.hashUtilsCls.cloneHash(r.resid2Residhash),t="all atoms that have pi-stacking with the selected atoms");let i={};for(let e in s){i[r.atoms[e].structure+"_"+r.atoms[e].chain+"_"+r.atoms[e].resi]=1}r.hAtoms={};for(let e in i)for(let t in r.residues[e])r.hAtoms[t]=1,r.atoms[t].style2="stick",r.ions.hasOwnProperty(t)&&(r.atoms[t].style2="sphere");let h=l+"_auto";r.selectionCls.addCustomSelection(Object.keys(i),h,t,c,!0),r.selectionCls.saveSelectionIfSelected(),r.drawCls.draw()}}showClbonds(){let e=this.icn3d,t=e.icn3dui;e.opts.clbonds="yes";let s=e.applyClbondsCls.applyClbondsOptions();for(let i in s)e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.residues[i]);if(Object.keys(s).length>0){let t="clbonds",i="all atoms that have cross-linkages";e.selectionCls.addCustomSelection(Object.keys(s),t,i,"cross linkage",!0),e.selectionCls.saveSelectionIfSelected(),e.drawCls.draw()}}showSsbonds(){let e=this.icn3d,t=e.icn3dui;e.opts.ssbonds="yes";let s={},i=Object.keys(e.structures);for(let n=0,l=i.length;n0){let t="ssbonds",i="all atoms that have disulfide bonds";e.selectionCls.addCustomSelection(Object.keys(s),t,i,"disulfide bonds",!0),e.selectionCls.saveSelectionIfSelected(),e.drawCls.draw()}}pickCustomSphere(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(i)return;let a,d,c="select zone cutoff "+e+" | sets "+t+" "+s+" | "+i;n&&(c="interactions "+e+" | sets "+t+" "+s+" | "+i,r.opts.contact="yes"),a=r.definedSetsCls.getAtomsFromNameArray(t),d=r.definedSetsCls.getAtomsFromNameArray(s);let h,p,m=this.pickCustomSphere_base(e,a,d,i,n,l,c,!0),u=Object.keys(m.residues);r.hAtoms={};for(let e=0,t=u.length;e1?"structure":v>1?"chain":"residue";let _=[];if(n&&_.push("hbonds"),l&&_.push("salt bridge"),r&&_.push("interactions"),o&&_.push("halogen"),a&&_.push("pi-cation"),d&&_.push("pi-stacking"),s||(p.resids2inter={},p.resids2interAll={}),l){let n=parseFloat($("#"+p.pre+"saltbridgethreshold").val());n&&!isNaN(n)||(n=p.tsIonic),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showIonicInteractions(n,e,t,s,!0,i)),g=m.hashUtilsCls.unionHash(g,p.hAtoms)}if(n){let n=parseFloat($("#"+p.pre+"hbondthreshold").val());n&&!isNaN(n)||(n=p.tsHbond),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHbonds(n,e,t,s,void 0,i)),g=m.hashUtilsCls.unionHash(g,p.hAtoms)}let S,A,x,k,O="";if(n&&(O+=this.exportHbondPairs(i,u)),l&&(O+=this.exportSaltbridgePairs(i,u)),o){let n=parseFloat($("#"+p.pre+"halogenthreshold").val());n&&!isNaN(n)||(n=p.tsHalogen),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHalogenPi(n,e,t,s,i,"halogen")),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportHalogenPiPairs(i,u,"halogen")}if(a){let n=parseFloat($("#"+p.pre+"picationthreshold").val());n&&!isNaN(n)||(n=p.tsPication),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHalogenPi(n,e,t,s,i,"pi-cation")),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportHalogenPiPairs(i,u,"pi-cation")}if(d){let n=parseFloat($("#"+p.pre+"pistackingthreshold").val());n&&!isNaN(n)||(n=p.tsPistacking),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHalogenPi(n,e,t,s,i,"pi-stacking")),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportHalogenPiPairs(i,u,"pi-stacking")}if(r){let n=b?c:parseFloat($("#"+p.pre+"contactthreshold").val());if(n&&!isNaN(n)||(n=p.tsContact),1!=e.length||1!=t.length||e[0]!=t[0])s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.pickCustomSphere(n,e,t,s,!0,i)),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportSpherePairs(!0,i,u);else{if(!s){let l={},o={};if(b){let e=!0,t=p.showInterCls.pickCustomSphere_base(n,C,y,s,!0,void 0,void 0,!0,e);l=m.hashUtilsCls.unionHash(l,t.residues);for(let e in t.resid2Residhash)o[e]=m.hashUtilsCls.unionHash(o[e],t.resid2Residhash[e])}else{let r=[],a="",d="",c={};for(let e in C){let t=p.atoms[e];t.ss==a&&t.chain==d||(Object.keys(c).length>0&&r.push(c),c={}),c[t.serial]=1,a=t.ss,d=t.chain}Object.keys(c).length>0&&r.push(c);let h=r.length;A="interactions "+n+" | sets "+e+" "+t+" | true",p.opts.contact="yes";for(let e=0;e
    ",T=p.resid2specCls.atoms2residues(Object.keys(C)),M=p.resid2specCls.atoms2residues(Object.keys(y)),P="select "+p.resid2specCls.residueids2spec(T),D="select "+p.resid2specCls.residueids2spec(M);I+="Set 1: "+e+'
    ',I+="Set 2: "+t+'

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

    ',I+='
    Note: Each checkbox below selects the corresponding residue. You can click "Save Selection" in the "Select" menu to save the selection and click on "Highlight" button to clear the checkboxes.

    ';let U=I;if(("graph"==i||"linegraph"==i||"scatterplot"==i||b)&&(I=""),I+=O,"save1"==i||"save2"==i){I=U;let e="";"save1"==i?e="Set 1":"save2"==i&&(e="Set 2"),I+='

    Interactions Sorted on '+e+':
    ';let t=this.getAllInteractionTable(i);I+=t.html,h=t.bondCnt,$("#"+p.pre+"dl_interactionsorted").html(I),m.htmlCls.dialogCls.openDlg("dl_interactionsorted","Show sorted interactions")}else if("view"==i)$("#"+p.pre+"dl_allinteraction").html(I),m.htmlCls.dialogCls.openDlg("dl_allinteraction","Show interactions");else if("linegraph"==i){m.htmlCls.dialogCls.openDlg("dl_linegraph","Show interactions between two lines of residue nodes"),p.graphStr=p.getGraphCls.getGraphData(C,y,e,t,I,u),p.bLinegraph=!0;let s=p.lineGraphCls.drawLineGraph(p.graphStr);$("#"+p.pre+"linegraphDiv").html(s)}else if("scatterplot"==i){m.htmlCls.dialogCls.openDlg("dl_scatterplot","Show interactions as scatterplot"),p.graphStr=p.getGraphCls.getGraphData(C,y,e,t,I,u),p.bScatterplot=!0;let s=p.lineGraphCls.drawLineGraph(p.graphStr,!0);$("#"+p.pre+"scatterplotDiv").html(s)}else if(b){m.htmlCls.dialogCls.openDlg("dl_contactmap","Show contact map");let s=!0,i=p.getGraphCls.getGraphData(C,y,e,t,I,u,s);p.bContactMap=!0;let n=p.contactMapCls.drawContactMap(i);$("#"+p.pre+"contactmapDiv").html(n)}else if("graph"==i)if(p.graphStr=p.getGraphCls.getGraphData(C,y,e,t,I,u),p.bGraph=!0,Object.keys(y).length+Object.keys(C).length>Object.keys(p.dAtoms).length&&(p.graphStr=p.selectionCls.getGraphDataForDisplayed()),void 0===p.bD3){await m.getAjaxPromise("https://www.ncbi.nlm.nih.gov/Structure/icn3d/script/d3v4-force-all.min.js","script"),p.bD3=!0,$("#"+m.svgid).empty(),m.htmlCls.dialogCls.openDlg("dl_graph","Force-directed graph"),p.drawGraphCls.drawGraph(p.graphStr,p.pre+"dl_graph")}else $("#"+m.svgid).empty(),m.htmlCls.dialogCls.openDlg("dl_graph","Force-directed graph"),p.drawGraphCls.drawGraph(p.graphStr,p.pre+"dl_graph");return{interactionTypes:_.toString(),bondCnt:h}}clearInteractions(){let e=this.icn3d;e.icn3dui,e.lines.hbond=[],e.hbondpnts=[],e.lines.saltbridge=[],e.saltbridgepnts=[],e.lines.contact=[],e.contactpnts=[],e.lines.halogen=[],e.lines["pi-cation"]=[],e.lines["pi-stacking"]=[],e.halogenpnts=[],e.picationpnts=[],e.pistackingpnts=[]}resetInteractionPairs(){let e=this.icn3d;e.icn3dui,e.bHbondCalc=!1,e.showInterCls.hideHbondsContacts(),e.hlUpdateCls.clearHighlight(),e.resids2inter={},e.resids2interAll={}}async retrieveInteractionData(){let e=this.icn3d,t=e.icn3dui;if(!e.b2DShown)if(void 0!==t.cfg.align){let s=Object.keys(e.structures);if(2==t.cfg.atype){let t=!0;await e.alignParserCls.downloadAlignment(s[0]+","+s[1],t)}await e.ParserUtilsCls.set2DDiagramsForAlign(s[0].toUpperCase(),s[1].toUpperCase())}else void 0!==t.cfg.chainalign?(Object.keys(e.structures),await e.ParserUtilsCls.set2DDiagramsForChainalign(e.chainidArray)):e.ParserUtilsCls.download2Ddgm(e.inputid.toUpperCase())}getAllInteractionTable(e){let t=this.icn3d,s=t.icn3dui,i=[],n=Object.keys(t.resids2inter);("save1"==e||"save2"==e)&&n.sort((function(t,i){return s.utilsCls.compResid(t,i,e)}));let l,r,o="",a="",d="",c="",h="",p="",m="",u="",g="",f=0,b=0,C=0,y=0,v=0,w=0,_="";for(let s=0,S=n.length;s0&&l!=a&&(i.push({res1:a,res2:_,cntHbond:f,cntIonic:b,cntContact:C,cntHalegen:y,cntPication:v,cntPistacking:w}),o+=this.getInteractionPerResidue(d,c,h,p,m,u,g,f,b,C,y,v,w),c="",h="",p="",m="",u="",g="",f=0,b=0,C=0,y=0,v=0,w=0,_=""),x=t.resids2inter[S].hbond,k=this.getInteractionPairDetails(x,e,"hbond"),c+=k.html,f+=k.cnt,k.cnt>0&&(_+=r+":hbond_"+k.cnt+" "),x=t.resids2inter[S].ionic,k=this.getInteractionPairDetails(x,e,"ionic"),h+=k.html,b+=k.cnt,k.cnt>0&&(_+=r+":ionic_"+k.cnt+" "),x=t.resids2inter[S].contact,k=this.getContactPairDetails(x,e,"contact"),p+=k.html,C+=k.cnt,k.cnt>0&&(_+=r+":contact_"+k.cnt+" "),x=t.resids2inter[S].halogen,k=this.getInteractionPairDetails(x,e,"halogen"),m+=k.html,y+=k.cnt,k.cnt>0&&(_+=r+":halogen_"+k.cnt+" "),x=t.resids2inter[S]["pi-cation"],k=this.getInteractionPairDetails(x,e,"pi-cation"),u+=k.html,v+=k.cnt,k.cnt>0&&(_+=r+":pi-cation_"+k.cnt+" "),x=t.resids2inter[S]["pi-stacking"],k=this.getInteractionPairDetails(x,e,"pi-stacking"),g+=k.html,w+=k.cnt,k.cnt>0&&(_+=r+":pi-stacking_"+k.cnt+" "),a=l,d=O}i.push({res1:a,res2:_,cntHbond:f,cntIonic:b,cntContact:C,cntHalegen:y,cntPication:v,cntPistacking:w}),o+=this.getInteractionPerResidue(d,c,h,p,m,u,g,f,b,C,y,v,w);let S="";if(n.length>0){S+='
    ',S+="",S+="",S+="",S+="",S+="";let e='';S+=e,S+=e,S+='',S+=e,S+=e,S+=e,S+="",S+="",S+=o,S+="
    Residue# Hydrogen
    Bond
    # Salt Bridge
    /Ionic Interaction
    # Contact# Halogen
    Bond
    # π-Cation# π-StackingHydrogen Bond (backbone atoms: @CA, @N, @C, @O)Salt Bridge/Ionic InteractionContactHalogen Bondπ-Cationπ-Stacking
    Atom1Atom2Distance(Å)Highlight in 3D
    Atom1Atom2# ContactsMin Distance(Å)C-alpha Distance(Å)Highlight in 3D

    "}return{html:S,bondCnt:i}}getInteractionPerResidue(e,t,s,i,n,l,r,o,a,d,c,h,p){this.icn3d.icn3dui;let m="";m+=''+e[3]+e[2]+""+o+""+a+""+d+""+c+""+h+""+p+"";let u=[t,s,i,n,l,r];for(let e in u){m+=''+u[e]+"
    "}return m+="",m}getInteractionPairDetails(e,t,s){let i=this.icn3d;i.icn3dui;let n="",l=0,r='    ';if(void 0!==e)for(let a in e){let d=a.split(","),c="save1"==t?d[0]:d[1],h="save1"==t?d[1]:d[0],p=i.getGraphCls.convertLabel2Resid(c),m=i.firstAtomObjCls.getFirstAtomObj(i.residues[p]),u=m.color?m.color.getHexString():"",g=i.getGraphCls.convertLabel2Resid(h),f=i.firstAtomObjCls.getFirstAtomObj(i.residues[g]),b=f.color?f.color.getHexString():"",C=Math.sqrt(e[a]).toFixed(1);n+=' '+c+r+u+o+' '+h+r+b+o+''+C+"",n+='',n+="",++l}return{html:n,cnt:l}}getContactPairDetails(e,t){let s=this.icn3d;s.icn3dui;let i="",n=0,l='    ';if(void 0!==e)for(let o in e){let a=o.split(","),d="save1"==t?a[0]:a[1],c="save1"==t?a[1]:a[0],h=s.getGraphCls.convertLabel2Resid(d),p=s.firstAtomObjCls.getFirstAtomObj(s.residues[h]),m=p.color?p.color.getHexString():"",u=s.getGraphCls.convertLabel2Resid(c),g=s.firstAtomObjCls.getFirstAtomObj(s.residues[u]),f=g.color?g.color.getHexString():"",b=e[o].split("_"),C=b[0],y=b[1],v=b[2],w=b[3],_=b[4];i+=' '+d+"@"+v+l+m+r+' '+c+"@"+w+l+f+r+''+_+''+C+''+y+"",i+='',i+="",n+=parseInt(_)}return{html:i,cnt:n}}exportInteractions(){var e=this.icn3d;e.icn3dui;let t='

    Interacting residues:
    ';for(let s in e.chainname2residues)for(let i in e.chainname2residues[s]){let n=s.substr(0,s.indexOf("_"))+"_"+i.substr(0,i.indexOf(" "));t+=""}t+="
    Base Chain: ResiduesInteracting Chain
    "+s+": ",t+=e.resid2specCls.residueids2spec(e.chainname2residues[s][i]),t+=""+n+"

    ";let s=e.inputid?e.inputid:"custom";e.saveFileCls.saveFile(s+"_interactions.html","html",t)}exportSsbondPairs(){var e=this.icn3d;e.icn3dui;let t="",s=0;for(let i in e.structures){let n=e.ssbondpnts[i];if(void 0===n)break;for(let e=0,i=n.length;e"+n[e]+" Cys"+n[e+1]+" Cys",++s}}let i='

    '+s+" disulfide pairs:

    ";i+=t,i+="
    Residue ID 1Residue ID 2

    ";let n=e.inputid?e.inputid:"custom";e.saveFileCls.saveFile(n+"_disulfide_pairs.html","html",i)}exportClbondPairs(){var e=this.icn3d;e.icn3dui;let t="",s=0,i={};for(let n in e.structures){let l=e.clbondpnts[n];if(void 0===l)break;for(let n=0,r=l.length;n"+r+" "+i.resn+""+o+" "+n.resn+"",++s}i[r+"_"+o]=1,i[o+"_"+r]=1}}let n='

    '+s+" cross-linkage pairs:

    ";n+=t,n+="
    Residue ID 1Residue ID 2

    ";let l=e.inputid?e.inputid:"custom";e.saveFileCls.saveFile(l+"_crosslinkage_pairs.html","html",n)}exportHbondPairs(e,t){var s=this.icn3d,i=s.icn3dui;let n="",l=0,r='    ';for(let t in s.resid2ResidhashHbond){let i=s.getGraphCls.convertLabel2Resid(t),a=s.firstAtomObjCls.getFirstAtomObj(s.residues[i]),d=a.color?a.color.getHexString():"";for(let i in s.resid2ResidhashHbond[t]){let a=s.getGraphCls.convertLabel2Resid(i),c=s.firstAtomObjCls.getFirstAtomObj(s.residues[a]),h=c.color?c.color.getHexString():"",p=Math.sqrt(s.resid2ResidhashHbond[t][i]).toFixed(1);n+=' '+t+r+d+o+' '+i+r+h+o+''+p+"","view"==e&&(n+=''),n+="",++l}}let a='

    '+l+" hydrogen bond pairs (backbone atoms: @CA, @N, @C, @O):

    ";if(l>0&&(a+="
    ","view"==e&&(a+=''),a+="",a+=n,a+="
    Atom 1Atom 2Distance(Å)Highlight in 3D

    "),"graph"==e||"linegraph"==e||"scatterplot"==e){return s.getGraphCls.getGraphLinks(s.resid2ResidhashHbond,s.resid2ResidhashHbond,i.htmlCls.hbondColor,t,i.htmlCls.hbondValue)}return a}exportSaltbridgePairs(e,t){var s=this.icn3d,i=s.icn3dui;let n="",l=0,r='    ';for(let t in s.resid2ResidhashSaltbridge){let i=s.getGraphCls.convertLabel2Resid(t),a=s.firstAtomObjCls.getFirstAtomObj(s.residues[i]),d=a.color?a.color.getHexString():"";for(let i in s.resid2ResidhashSaltbridge[t]){let a=s.getGraphCls.convertLabel2Resid(i),c=s.firstAtomObjCls.getFirstAtomObj(s.residues[a]),h=c.color?c.color.getHexString():"",p=Math.sqrt(s.resid2ResidhashSaltbridge[t][i]).toFixed(1);n+=' '+t+r+d+o+' '+i+r+h+o+''+p+"","view"==e&&(n+=''),n+="",++l}}let a='

    '+l+" salt bridge/ionic interaction pairs:

    ";if(l>0&&(a+="
    ","view"==e&&(a+=''),a+="",a+=n,a+="
    Atom 1Atom 2Distance(Å)Highlight in 3D

    "),"graph"==e||"linegraph"==e||"scatterplot"==e){return s.getGraphCls.getGraphLinks(s.resid2ResidhashSaltbridge,s.resid2ResidhashSaltbridge,i.htmlCls.ionicColor,t,i.htmlCls.ionicValue)}return a}exportHalogenPiPairs(e,t,s){var i=this.icn3d,n=i.icn3dui;let l,r,o,a="",d=0,c='    ';"halogen"==s?(l=i.resid2ResidhashHalogen,r=n.htmlCls.halogenColor,o=n.htmlCls.halogenValue):"pi-cation"==s?(l=i.resid2ResidhashPication,r=n.htmlCls.picationColor,o=n.htmlCls.picationValue):"pi-stacking"==s&&(l=i.resid2ResidhashPistacking,r=n.htmlCls.pistackingColor,o=n.htmlCls.pistackingValue);for(let t in l){let n=i.getGraphCls.convertLabel2Resid(t),r=i.firstAtomObjCls.getFirstAtomObj(i.residues[n]),o=r.color?r.color.getHexString():"";for(let n in l[t]){let r=i.getGraphCls.convertLabel2Resid(n),p=i.firstAtomObjCls.getFirstAtomObj(i.residues[r]),m=p.color?p.color.getHexString():"",u=Math.sqrt(l[t][n]).toFixed(1);a+=' '+t+c+o+h+' '+n+c+m+h+''+u+"","view"==e&&(a+=''),a+="",++d}}let p='

    '+d+" "+s+" pairs:

    ";if(d>0&&(p+="
    ","view"==e&&(p+=''),p+="",p+=a,p+="
    Atom 1Atom 2Distance(Å)Highlight in 3D

    "),"graph"==e||"linegraph"==e||"scatterplot"==e){return i.getGraphCls.getGraphLinks(l,l,r,t,o)}return p}exportSpherePairs(e,t,s){var i=this.icn3d,n=i.icn3dui;let l="",r=0,o=e?i.resid2ResidhashInteractions:i.resid2ResidhashSphere,a='    ';for(let s in o){let n=i.getGraphCls.convertLabel2Resid(s),c=i.firstAtomObjCls.getFirstAtomObj(i.residues[n]),h=c.color?c.color.getHexString():"";for(let n in o[s]){let p=i.getGraphCls.convertLabel2Resid(n),m=i.firstAtomObjCls.getFirstAtomObj(i.residues[p]),u=m.color?m.color.getHexString():"",g=o[s][n].split("_"),f=g[0],b=g[1];c=g[2],m=g[3];let C=g[4];e?(l+=' '+s+"@"+c+a+h+d+' '+n+"@"+m+a+u+d+''+C+''+f+''+b+"","view"==t&&(l+=''),l+=""):l+=""+s+""+n+''+C+''+f+''+b+"",++r}}let c='

    '+r+" residue pairs in "+(e?"the contacts":"sphere")+":

    ";if(r>0&&(e?(c+='
    ',"view"==t&&(c+=''),c+=""):c+='
    Residue 1Residue 2Num ContactsMin Distance(Å)C-alpha Distance(Å)Highlight in 3D
    ',c+=l,c+="
    Residue 1Residue 2Num ContactsMin Distance(Å)C-alpha Distance(Å)

    "),"graph"==t||"linegraph"==t||"scatterplot"==t||"calpha"==t||"cbeta"==t||"heavyatoms"==t){return i.getGraphCls.getGraphLinks(o,o,n.htmlCls.contactColor,s,n.htmlCls.contactValue)}return c}}class Ut{constructor(e){this.icn3d=e}drawGraph(e,t){var s=this.icn3d,i=s.icn3dui;if(void 0===n)var n=d3;var l=JSON.parse(e),r=$("#"+t).width(),o=$("#"+t).height(),a=isNaN(r)?300:1*r,d=isNaN(o)?300:1*o,c=r,h=o,p=d3.select("#"+i.svgid).attr("width",r).attr("height",o).attr("viewBox","0,0,"+a+","+d);p.selectAll(".g-main").remove();var m=p.append("g").classed("g-main",!0),u=m.append("rect").attr("width",c).attr("height",h).style("fill","#FFF"),g=m.append("g"),f=n.zoom().on("zoom",(function(){g.attr("transform",n.event.transform)}));if(m.call(f),l.links){for(var b=[],C={},y=0,v=l.nodes.length;y0?n.structures[0]:n.defaultPdbId;p=10*(a.length+2)+20+30,h=10*(d.length+2)+20+30,t?(n.alignerrormapWidth=2*h,u=n.alignerrormapWidth,m=l.alignerrormapid):(n.contactmapWidth=2*h,u=n.contactmapWidth,m=l.contactmapid),i=o.length>0?"":"No interactions found for these two sets

    ",i+="";if(t){n.hex2id={};let e=29/s;n.hex2skip={};let t=1e3;for(let s=0;se&&(n.hex2skip[d]=c)}}if(i+=n.lineGraphCls.drawScatterplot_base(a,d,o,c,0,!0,void 0,void 0,t),g+=n.getGraphCls.updateGraphJson(f,1,a,d,o),i+="",g+="}\n",t){n.alignerrormapStr=g,$("#"+n.pre+"alignerrormapDiv").html(i);let e=$("#"+l.alignerrormapid+"_scale").val();$("#"+l.alignerrormapid).attr("width",(n.alignerrormapWidth*parseFloat(e)).toString()+"px")}else n.contactmapStr=g,$("#"+n.pre+"contactmapDiv").html(i);return i}}class $t{constructor(e){this.icn3d=e}async downloadAlignment(e,t){let s=this.icn3d,i=s.icn3dui,n=this;s.opts.proteins="c alpha trace";let l=e.split(","),r="ids="+e,o=i.htmlCls.baseUrl+"vastplus/vastplus.cgi?v=3&cmd=c&b=1&s=1&w3d&"+r;void 0!==i.cfg.inpara&&(o+=i.cfg.inpara),s.pdbid_chain2title={},void 0===s.chainids2resids&&(s.chainids2resids={});let a={},d="These two MMDB IDs "+l+' do not have 3D alignment data in the VAST+ database. You can try the VAST alignment by visiting the VAST+ page https://www.ncbi.nlm.nih.gov/Structure/vastplus/vastplus.cgi?uid=[PDB ID] (e.g., uid=1KQ2), and clicking "Original VAST"',c=await i.getAjaxPromise(o,"jsonp",!0,d);if(a=c.seqalign,void 0===a)return alert(d),!1;s.pdbid_molid2chain={},s.chainsColor={};for(let e=0,t=2;e5){let t=!1,s=!0;d=await r.pdbParserCls.loadPdbData(e,n,!1,t,"target",h,s)}else{let t=!0;d=await r.mmdbParserCls.parseMmdbData(e,"target",i[0],0,h,t)}for(let e=0,s=t.length;e5){let s=!0,i=!0;c=await r.pdbParserCls.loadPdbData(t[e],l,!1,s,"query",h,i)}else{let s=!0;c=await r.mmdbParserCls.parseMmdbData(t[e],"query",i[e+1],e,h,s)}d=o.hashUtilsCls.unionHash(d,c)}if(o.cfg.resnum)await r.realignParserCls.realignChainOnSeqAlign(s,i);else if(o.cfg.resdef)await r.realignParserCls.realignChainOnSeqAlign(s,i,void 0,!0);else{await r.pdbParserCls.applyCommandDssp(!0);for(let e in r.pdbChainIndexHash){let t=r.pdbChainIndexHash[e].split("_");l=t[0],t[1],n=t[2],t[3],a.transformStructure(l,e-1,"query")}let e=[],t=[],c=[],h=o.htmlCls.baseUrl+"vastdyn/vastdyn.cgi",p=o.htmlCls.baseUrl+"tmalign/tmalign.cgi";for(let s in r.afChainIndexHash){let i=r.afChainIndexHash[s].split("_");l=i[0];let a=i[1];n=i[2];let d,m=i[3];if("tmalign"!=o.cfg.aligntool){let e={domains1:r.domain3dCls.getDomainJsonForAlign(r.chains[l+"_"+a]),domains2:r.domain3dCls.getDomainJsonForAlign(r.chains[n+"_"+m])};d=o.getAjaxPostPromise(h,e)}else{let e={pdb_query:r.saveFileCls.getAtomPDB(r.chains[l+"_"+a]),pdb_target:r.saveFileCls.getAtomPDB(r.chains[n+"_"+m])};d=o.getAjaxPostPromise(p,e)}e.push(d),t.push(s-1),c.push(l)}let m=Promise.allSettled(e);try{let e=await m;await a.downloadChainalignmentPart2b(s,i,d,e,t,n,c)}catch(e){r.bRender&&alert("These structures can NOT be aligned to each other...")}}}async downloadChainalignmentPart2b(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui;for(let e=0,t=i.length;ed&&(d=n[t[0]],o=t[0]),n[t[1]]>d&&(d=n[t[1]],o=t[1])}let c={},h={},p={},m={};for(let e in l){let t,s,i=e.split("_"),n=l[e].split(","),r=n[2];o==i[0]?(t=i[0],s=i[1]):o==i[1]?(t=i[1],s=i[0]):(t=i[0],s=i[1]),p[t]=1,p.hasOwnProperty(s)||(p[s]=1,m[e]=l[e],a="target",this.transformStructure(t,r,a),a="query",this.transformStructure(s,r,a),c[n[0]]=1,c[n[1]]=1)}for(let e in m)if(void 0!==s.q_rotation){let t=m[e].split(","),n=[t[1],t[0],t[2]],l=s.setSeqAlignCls.setSeqAlignChain(void 0,void 0,n);h=i.hashUtilsCls.unionHash(h,l);let r=!1,o=i.htmlCls.alignSeqCls.getAlignSequencesAnnotations(Object.keys(s.alnChains),void 0,void 0,!1,void 0,r),a=$("#"+s.pre+"dl_sequence2").html();$("#"+s.pre+"dl_sequence2").html(a+o.sequencesHtml),$("#"+s.pre+"dl_sequence2").width(i.htmlCls.RESIDUE_WIDTH*o.maxSeqCnt+200)}s.dAtoms=i.hashUtilsCls.cloneHash(h),s.hAtoms=i.hashUtilsCls.cloneHash(h);let u="protein_aligned";s.selectionCls.saveSelection(u,u),s.opts.color="identity",s.setColorCls.setColorByOptions(s.opts,s.hAtoms),i.htmlCls.dialogCls.openDlg("dl_alignment","Select residues in aligned sequences"),s.drawCls.draw(),s.transformCls.zoominSelection(),s.hlUpdateCls.updateHlAll()}transformStructure(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=n.structures[e];for(let e=0,o=r.length;e2){let e=i.firstAtomObjCls.getResiduesFromAtoms(s),t="protein_aligned",n="protein aligned",l="select "+i.resid2specCls.residueids2spec(Object.keys(e));i.selectionCls.addCustomSelection(Object.keys(e),t,n,l,!0)}i.hlUpdateCls.updateHlAll(),void 0!==n.cfg.rotate&&i.resizeCanvasCls.rotStruc(n.cfg.rotate,!0),i.html2ddgm="",n.cfg.show2d&&i.bFullUi&&(n.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions"),i.bFullUi&&(i.bChainAlign?await i.ParserUtilsCls.set2DDiagramsForChainalign(t):i.ParserUtilsCls.download2Ddgm(i.inputid.toUpperCase())))}addPostfixForChainids(e){let t=this.icn3d;t.icn3dui;let s={};for(let i=0,n=e.length;i5?(c="https://alphafold.ebi.ac.uk/files/AF-"+i.mmdbid_t+"-F1-model_"+i.AFUniprotVersion+".pdb",d=n.getAjaxPromise(c,"text")):(c=n.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+n.cfg.bu+"&uid="+i.mmdbid_t,void 0!==n.cfg.inpara&&(c+=n.cfg.inpara),d=n.getAjaxPromise(c,"jsonp")),h.push(d),i.ParserUtilsCls.setYourNote(e.toUpperCase()+" in iCn3D"),i.pdbid_chain2title={},void 0===i.chainids2resids&&(i.chainids2resids={}),i.afChainIndexHash={},i.pdbChainIndexHash={};for(let e=1,t=r.length;e5?(t="https://alphafold.ebi.ac.uk/files/AF-"+i.mmdbid_q+"-F1-model_"+i.AFUniprotVersion+".pdb",s=n.getAjaxPromise(t,"text")):(t=n.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+n.cfg.bu+"&uid="+i.mmdbid_q,void 0!==n.cfg.inpara&&(t+=n.cfg.inpara),s=n.getAjaxPromise(t,"jsonp")),h.push(s)}for(let e=1,t=r.length;e0?o[e]+","+o[0]:void 0;if("tmalign"!=n.cfg.aligntool&&4==i.mmdbid_t.length&&4==i.mmdbid_q.length){let r;r=o.length>0?n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?domainpairs="+l:n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainpairs="+t;let a=n.getAjaxPromise(r,"jsonp");h.push(a),i.pdbChainIndexHash[e]=s+"_"+i.chain_q+"_"+i.mmdbid_t+"_"+i.chain_t}else i.afChainIndexHash[e]=i.mmdbid_q+"_"+i.chain_q+"_"+i.mmdbid_t+"_"+i.chain_t}}let p=Promise.allSettled(h);try{let e=await p;await l.parseChainAlignData(e,r,i.mmdbid_t,i.chain_t)}catch(e){let t="tmalign"==n.cfg.aligntool?"TM-align":"VAST";i.bRender&&alert("These chains can not be aligned by "+t+". You can specify the residue range and try it again...")}}async parseChainAlignData(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=e[0].value,o="HEADER "+s+"\n";isNaN(s)&&s.length>5&&(r=o+r),n.t_trans_add=[],n.q_trans_sub=[],"tmalign"==l.cfg.aligntool&&(n.q_trans_add=[]),n.q_rotation=[],n.qt_start_end=[],n.mmdbidArray=[],n.mmdbidArray.push(s);let a=[];for(let s=1,i=t.length;s5&&(i=o+i),void 0===i||-1!==JSON.stringify(i).indexOf("Oops there was a problem"))return void alert("The coordinate data can NOT be retrieved for the structure "+r+"...");n.mmdbidArray.push(r),a.push(i)}let d=0;for(let r=1,o=t.length;r";"tmalign"==o.cfg.aligntool&&(n+="TM-score: "+e[0].score.toPrecision(4)+"

    "),$("#"+r.pre+"dl_rmsd").html(n),o.cfg.bSidebyside||o.htmlCls.dialogCls.openDlg("dl_rmsd","RMSD of alignment"),a=!0}return a}async loadOpmDataForChainalign(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=this;if(l.cfg.resnum||l.cfg.resdef)n.bCommandLoad||n.init(),await this.downloadChainalignmentPart2(e,t,void 0,s);else{let o=l.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?mmdbids2opm="+i.join("','");try{let i=(await l.getAjaxPromise(o,"jsonp")).mmdbid;if(n.selectedPdbid=i,i){let o="https://opm-assets.storage.googleapis.com/pdb/"+i.toLowerCase()+".pdb";try{let a=await l.getAjaxPromise(o,"text");n.bOpm=!0;let d=!0,c=n.loadPDBCls.loadPDB(a,i,n.bOpm,d);$("#"+n.pre+"selectplane_z1").val(n.halfBilayerSize),$("#"+n.pre+"selectplane_z2").val(-n.halfBilayerSize),$("#"+n.pre+"extra_mem_z").val(n.halfBilayerSize),$("#"+n.pre+"intra_mem_z").val(-n.halfBilayerSize),n.bCommandLoad||n.init(),await r.downloadChainalignmentPart2(e,t,c,s)}catch(i){return n.bCommandLoad||n.init(),void await r.downloadChainalignmentPart2(e,t,void 0,s)}}else n.bCommandLoad||n.init(),await r.downloadChainalignmentPart2(e,t,void 0,s)}catch(i){return n.bCommandLoad||n.init(),void await r.downloadChainalignmentPart2(e,t,void 0,s)}}}async downloadMmdbAf(e,t,s){let i=this.icn3d,n=i.icn3dui,l=this;i.structArray=i.structures?Object.keys(i.structures):[],0==i.structArray.length?i.init():(i.resetConfig(),i.bResetAnno=!0,i.bResetSets=!0);let r=e.split(","),o=[];for(let e=0,t=r.length;e5?(t="https://alphafold.ebi.ac.uk/files/AF-"+l+"-F1-model_"+i.AFUniprotVersion+".pdb",s=n.getAjaxPromise(t,"text")):(t=n.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+n.cfg.bu+"&uid="+l,void 0!==n.cfg.inpara&&(t+=n.cfg.inpara),s=n.getAjaxPromise(t,"jsonp")),a.push(s)}i.ParserUtilsCls.setYourNote(i.structArray+" in iCn3D"),i.ParserUtilsCls.showLoading();let d=Promise.allSettled(a);try{let e=await d;await l.parseMMdbAfData(e,o,t,s),void 0===s&&i.ParserUtilsCls.hideLoading()}catch(e){alert("There are some problems in retrieving the coordinates...")}}async parseMMdbAfData(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=[];for(let s=0,i=t.length;s5&&(i=n+i),void 0===i||-1!==JSON.stringify(i).indexOf("Oops there was a problem"))return void alert("The coordinate data can NOT be retrieved for the structure "+t[s]+"...");r.push(i)}let o={},a={},d=!1;n.opts.color=n.structArray.length>1?"structure":t[0].length>5?"confidence":"chain";for(let e=0,i=t.length;e5){let s=!1;a=await n.pdbParserCls.loadPdbData(r[e],t[e],!1,c,i,d,s)}else{let t=!0;a=await n.mmdbParserCls.parseMmdbData(r[e],i,void 0,void 0,d,t)}o=l.hashUtilsCls.unionHash(o,a)}if(n.structArray.length>1&&(n.opts.color="structure"),n.setColorCls.setColorByOptions(n.opts,n.atoms),await n.ParserUtilsCls.renderStructure(),void 0!==l.cfg.rotate&&n.resizeCanvasCls.rotStruc(l.cfg.rotate,!0),s&&l.cfg.matchedchains){let e=!0,t=!0;await n.realignParserCls.realignChainOnSeqAlign(void 0,n.chainidArray,e,t),$("#"+n.pre+"dl_annotations").html(""),n.bAnnoShown=!1,$("#"+n.pre+"dl_selectannotations").dialog("isOpen")&&$("#"+n.pre+"dl_selectannotations").dialog("close")}else if(void 0!==i){let e=Object.keys(n.structures);await n.vastplusCls.vastplusAlign(e,i)}}}class Bt{constructor(e){this.icn3d=e}dsn6Parser(e,t,s){this.icn3d.icn3dui;let i="https://edmaps.rcsb.org/maps/"+e.toLowerCase()+"_"+t+".dsn6";this.dsn6ParserBase(i,t,s)}dsn6ParserBase(e,t,s){let i=this.icn3d;i.icn3dui;let n=this;if("2fofc"==t&&i.bAjax2fofc)i.mapData.sigma2=s,i.setOptionCls.setOption("map",t);else if("fofc"==t&&i.bAjaxfofc)i.mapData.sigma=s,i.setOptionCls.setOption("map",t);else{let l=new XMLHttpRequest;l.open("GET",e,!0),l.responseType="arraybuffer",l.onreadystatechange=function(){if(4==this.readyState)if(200==this.status){let e=l.response;n.loadDsn6Data(e,t,s),"2fofc"==t?i.bAjax2fofc=!0:"fofc"==t&&(i.bAjaxfofc=!0),i.setOptionCls.setOption("map",t)}else alert("RCSB server has no corresponding eletron density map for this structure.");else i.ParserUtilsCls.showLoading()},l.send()}}loadDsn6Data(e,t,s){let i=this.icn3d;i.icn3dui;let n,l,r={},o=e.buffer&&e.buffer instanceof ArrayBuffer?e.buffer:e,a=new Int16Array(o),d=new Uint8Array(o),c=String.fromCharCode.apply(null,d.subarray(0,512));if(0==c.indexOf(":-)"))r.xStart=parseInt(c.substr(10,5)),r.yStart=parseInt(c.substr(15,5)),r.zStart=parseInt(c.substr(20,5)),r.xExtent=parseInt(c.substr(32,5)),r.yExtent=parseInt(c.substr(38,5)),r.zExtent=parseInt(c.substr(42,5)),r.xRate=parseInt(c.substr(52,5)),r.yRate=parseInt(c.substr(58,5)),r.zRate=parseInt(c.substr(62,5)),r.xlen=1*parseFloat(c.substr(73,10)),r.ylen=1*parseFloat(c.substr(83,10)),r.zlen=1*parseFloat(c.substr(93,10)),r.alpha=parseFloat(c.substr(103,10)),r.beta=parseFloat(c.substr(113,10)),r.gamma=parseFloat(c.substr(123,10)),n=parseFloat(c.substr(138,12))/100,l=parseInt(c.substr(155,8)),r.sigma=100*parseFloat(c.substr(170,12));else{if(100!==a[18])for(let e=0,t=a.length;e>8&255}r.zStart=a[2],r.xStart=a[0],r.yStart=a[1],r.xExtent=a[3],r.yExtent=a[4],r.zExtent=a[5],r.xRate=a[6],r.yRate=a[7],r.zRate=a[8];let e=1/a[17],t=1*e;r.xlen=a[9]*t,r.ylen=a[10]*t,r.zlen=a[11]*t,r.alpha=a[12]*e,r.beta=a[13]*e,r.gamma=a[14]*e,n=a[15]/a[18],l=a[16]}let h=new Float32Array(r.xExtent*r.yExtent*r.zExtent),p=512,m=Math.ceil(r.xExtent/8),u=Math.ceil(r.yExtent/8),g=Math.ceil(r.zExtent/8);for(let e=0;es.maxatomcnt&&(s.bAssembly=!0)}if("mmtfid"===t&&void 0!==o.missingseq){let t=0,n="";for(let l=0,r=o.missingseq.length;lt)&&(s.chainMissingResidueArray[c].push(h),t=d,n=a)}s.loadPDBCls.adjustSeq(s.chainMissingResidueArray)}}async loadMmcifData(e,t){let s=this.icn3d;if(s.icn3dui,t||(t=e.mmcif),t||(t=s.defaultPdbId),void 0===e.atoms)return!1;s.init(),void 0!==e.emd&&(s.emd=e.emd),void 0!==e.organism&&(s.organism=e.organism),void 0!==s.emd?($("#"+s.pre+"mapWrapper1").hide(),$("#"+s.pre+"mapWrapper2").hide(),$("#"+s.pre+"mapWrapper3").hide()):($("#"+s.pre+"emmapWrapper1").hide(),$("#"+s.pre+"emmapWrapper2").hide(),$("#"+s.pre+"emmapWrapper3").hide()),await s.opmParserCls.loadOpmData(e,t,void 0,"mmcif")}}class Gt{constructor(e){this.icn3d=e}async downloadMmdb(e,t){let s,i=this.icn3d,n=i.icn3dui;try{if(s=await this.loadMmdbPrms(e,t),!s||s.error)return void this.getNoData(e,t)}catch(s){return void this.getNoData(e,t)}if(0!=Object.keys(s.atoms).length)if(n.utilsCls.isCalphaPhosOnly(s.atoms)||s.atomCount<=i.maxatomcnt)await this.parseMmdbData(s);else{let s;try{s=await this.loadMmdbPrms(e,t,!0)}catch(s){return void this.getNoData(e,t)}await this.parseMmdbData(s)}else{let e=s.pdbId;i.mmtfParserCls.downloadMmtf(e)}}async downloadGi(e){let t=this.icn3d;t.icn3dui,t.bCid=void 0;await this.downloadMmdb(e,!0)}async downloadBlast_rep_id(e){let t=this.icn3d,s=t.icn3dui,i=e.split(",");s.cfg.query_id=i[0],s.cfg.blast_rep_id=i[1];let n=s.cfg.blast_rep_id.split("_")[0];4==n.length?await this.downloadMmdb(n):(t.blastAcxn=s.cfg.blast_rep_id.split(".")[0],await this.downloadRefseq(t.blastAcxn,!0))}async downloadRefseq(e,t){let s=this.icn3d,i=s.icn3dui,n=i.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?refseq2uniprot="+e;i.cfg.refseqid=e;let l=await i.getAjaxPromise(n,"jsonp",!1,"The protein accession "+e+" can not be mapped to AlphaFold UniProt ID...");if(!l||!l.uniprot)return void alert("The accession "+e+" can not be mapped to AlphaFold UniProt ID. It will be treated as a UniProt ID instead.");i.cfg.afid=l.uniprot,t&&(i.cfg.blast_rep_id=i.cfg.afid+"_A");await s.pdbParserCls.downloadPdb(i.cfg.afid,!0)}getNoData(e,t){let s=this.icn3d.icn3dui;t?alert("This gi "+e+" has no corresponding 3D structure..."):alert("This mmdbid "+e+" with the parameters "+s.cfg.inpara+" may not have 3D structure data. Please visit the summary page for details: "+s.htmlCls.baseUrl+"pdb/"+e)}async parseMmdbData(e,t,s,i,n,l){let r,o=this.icn3d,a=o.icn3dui,d=void 0!==e.pdbId?e.pdbId:e.mmdbId;this.parseMmdbDataPart1(e,t),void 0===t?(void 0!==e.opm&&void 0!==e.opm.rot&&(o.bOpm=!0,o.opmParserCls.setOpmData(e)),r=o.loadAtomDataCls.loadAtomDataIn(e,d,"mmdbid",void 0,t)):(s&&(d=s.substr(0,s.indexOf("_"))),r=o.loadAtomDataCls.loadAtomDataIn(e,d,"mmdbid",void 0,t,s,i,n,l));let c=e.pdbId;void 0===t&&o.ParserUtilsCls.setYourNote(c.toUpperCase()+"(MMDB) in iCn3D");for(let t in e.domains){let s=e.domains[t].chain,i=c+"_"+s,n=e.domains[t].domains;for(let e=0,t=n.length;et.maxatomcnt){let i=!1;if(0==Object.keys(s).length)return void alert("This PDB structure is not found at RCSB...");await t.opmParserCls.loadOpmData(s,e,i,"mmtf")}else s=null,MMTF.fetch(e,(async function(s){0!=Object.keys(s).length?await t.opmParserCls.loadOpmData(s,e,!0,"mmtf"):alert("This PDB structure is not found at RCSB...")}),(function(e){}))}),(function(e){}))}async parseMmtfData(e,t,s){let i=this.icn3d,n=i.icn3dui;e.numAtoms,i.init();let l=new THREE.Vector3(9999,9999,9999),r=new THREE.Vector3(-9999,-9999,-9999),o=new THREE.Vector3,a=e.structureId;if(i.molTitle=e.title,void 0!==e.bioAssemblyList&&void 0!==e.bioAssemblyList[0]&&e.bioAssemblyList[0].transformList.length>1){i.biomtMatrices=[];for(let t=0,s=e.bioAssemblyList[0].transformList.length;t1&&($("#"+i.pre+"assemblyWrapper").show(),i.asuCnt=i.biomtMatrices.length);let d,c,h,p,m,u,g,f,b,C,y,v,w,_,S,A,x,k,O,R={},E=[],I="coil",T="",M=0,P=0,D={onModel:function(e){d=0===e.modelIndex?a:a+(e.modelIndex+1).toString()},onChain:function(e){c=e.chainName;let t=d+"_"+c;void 0===i.structures[d]&&(i.structures[d]=[]),i.structures[d].push(t)},onGroup:function(e){h=e.groupName,p=e.groupId;let t=d+"_"+c+"_"+p;m=0===e.secStruct||2===e.secStruct||4===e.secStruct?"helix":3===e.secStruct?"sheet":-1===e.secStruct?"other":"coil";let s=!1;if(c!==T){if(x=void 0,O=void 0,"coil"!==m&&"other"!==m?(u=!0,g=!1):(u=!1,g=!1),"coil"!==I&&"other"!==I){let e=d+"_"+T+"_"+M.toString();for(let t in i.residues[e])i.atoms[t].ssbegin=!1,i.atoms[t].ssend=!0}}else x=A,O=k,m!==I?"coil"===I||"other"===I?(u=!0,g=!1):"coil"===m||"other"===m?(s=!0,u=!1,g=!1):("sheet"===I&&"helix"===m||"helix"===I&&"sheet"===m)&&(s=!0,u=!0,g=!1):(u=!1,g=!1);if(s&&!isNaN(p)){let e=d+"_"+c+"_"+(p-1).toString();for(let t in i.residues[e])i.atoms[t].ssbegin=!1,i.atoms[t].ssend=!0}I=m,T=c,M=p,f=!1,b=!1,C=!1,"non-polymer"===e.chemCompType.toLowerCase()||"other"===e.chemCompType.toLowerCase()||-1!==e.chemCompType.toLowerCase().indexOf("saccharide")?f=!0:-1!==e.chemCompType.toLowerCase().indexOf("peptide")?b=!0:-1!==e.chemCompType.toLowerCase().indexOf("dna")||-1!==e.chemCompType.toLowerCase().indexOf("rna")?C=!0:b=!0;let l=d+"_"+c,r={};r.resi=p,r.name=n.utilsCls.residueName2Abbr(h),i.residueId2Name[t]=r.name,r.resi%10==0&&r.resi.toString();let o="-";"helix"===m?o="H":"sheet"===m?o="E":"coil"===m?o="c":"other"===m&&(o="o"),void 0===i.chainsSeq[l]&&(i.chainsSeq[l]=[]),i.bFullUi&&i.chainsSeq[l].push(r),i.secondaries[t]=o},onAtom:function(e){if(y=e.element,v=e.atomName,w=new THREE.Vector3(e.xCoord,e.yCoord,e.zCoord),_=e.bFactor,S=e.altLoc,"\0"===e.altLoc&&(S=""),""===S||"A"===S){++P,"SG"===v&&E.push(P),R[e.atomIndex]=P;let t={het:f,serial:P,name:v,alt:S,resn:h,structure:d,chain:c,resi:p,coord:w,b:_,elem:y,bonds:[],bondOrder:[],ss:m,ssbegin:u,ssend:g};if(t.het||"C"!==t.name||(A=P),t.het||"O"!==t.name||(k=P),!t.het&&"N"===t.name&&void 0!==x&&void 0!==O){let e=i.atoms[x].coord.distanceTo(i.atoms[O].coord),s=t.coord.x+(i.atoms[x].coord.x-i.atoms[O].coord.x)/e,n=t.coord.y+(i.atoms[x].coord.y-i.atoms[O].coord.y)/e,l=t.coord.z+(i.atoms[x].coord.z-i.atoms[O].coord.z)/e;t.hcoord=new THREE.Vector3(s,n,l)}i.atoms[P]=t,l.min(w),r.max(w),o.add(w);let a=d+"_"+c,I=a+"_"+p;void 0===i.chains[a]&&(i.chains[a]={}),i.chains[a][P]=1,void 0===i.residues[I]&&(i.residues[I]={}),i.residues[I][P]=1,b?(i.proteins[P]=1,"CA"===v&&(i.calphas[P]=1),"N"!==v&&"H"!==v&&"CA"!==v&&"HA"!==v&&"C"!==v&&"O"!==v&&(i.sidec[P]=1)):C?(i.nucleotides[P]=1,(!s||"O3'"!=v&&"O3*"!=v)&&(s||"P"!=v)||(i.nucleotidesO3[P]=1),-1===n.parasCls.nuclMainArray.indexOf(v)&&(i.ntbase[P]=1)):y.toLowerCase()===h.toLowerCase()?i.ions[P]=1:"HOH"===h||"WAT"===h||"SQL"===h||"H2O"===h||"W"===h||"DOD"===h||"D3O"===h?i.water[P]=1:i.chemicals[P]=1,i.dAtoms[P]=1,i.hAtoms[P]=1}},onBond:function(e){let t=R[e.atomIndex1],s=R[e.atomIndex2];if(R.hasOwnProperty(e.atomIndex1)&&R.hasOwnProperty(e.atomIndex2)&&(i.atoms[t].bonds.push(s),i.atoms[s].bonds.push(t),f)){let n=e.bondOrder;i.atoms[t].bondOrder.push(n),i.atoms[s].bondOrder.push(n),2===n?(i.doublebonds[t+"_"+s]=1,i.doublebonds[s+"_"+t]=1):3===n&&(i.triplebonds[t+"_"+s]=1,i.triplebonds[s+"_"+t]=1)}}};MMTF.traverse(e,D),i.loadPDBCls.setResidMapping();for(let e=0,t=E.length;ei.maxatomcnt||void 0!==i.biomtMatrices&&i.biomtMatrices.length*i.cnt>10*i.maxatomcnt)&&(i.opts.proteins="c alpha trace",i.opts.nucleotides="o3 trace"),i.pmin=l,i.pmax=r,i.center=i.ParserUtilsCls.getGeoCenter(i.pmin,i.pmax),i.maxD=i.ParserUtilsCls.getStructureSize(i.atoms,i.pmin,i.pmax,i.center),i.maxD<5&&(i.maxD=5),i.oriMaxD=i.maxD,i.oriCenter=i.center.clone(),i.ParserUtilsCls.transformToOpmOri(t),void 0===n.cfg.align&&1==Object.keys(i.structures).length&&$("#"+i.pre+"alternateWrapper").hide(),i.setStyleCls.setAtomStyleByOptions(i.opts),i.setColorCls.setColorByOptions(i.opts,i.atoms),await i.ParserUtilsCls.renderStructure(),i.saveFileCls.showTitle(),void 0!==n.cfg.rotate&&i.resizeCanvasCls.rotStruc(n.cfg.rotate,!0)}}class Wt{constructor(e){this.icn3d=e}async loadMol2Data(e){let t=this.icn3d,s=t.icn3dui,i=this.loadMol2AtomData(e);void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),i?(t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.atoms),await t.ParserUtilsCls.renderStructure(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0)):alert("The Mol2 file has the wrong format...")}loadMol2AtomData(e){let t=this.icn3d;t.icn3dui;let s=e.split(/\r?\n|\r/);if(s.length<4)return!1;t.init();let i,n,l="LIG",r={},o="1_A",a=0,d=0,c=1,h=!1,p=!1,m={},u={};for(let e=0,o=s.length;eMOLECULE"==o){t.molTitle=s[e+1].trim();let l=s[e+2].trim().replace(/\s+/g," ").split(" ");i=l[0],n=l[1],e+=4}else"@ATOM"==o?(c=1,h=!0,++e):"@BOND"==o?(p=!0,h=!1,++e):"@SUBSTRUCTURE"==o&&(p=!1,++e);if(o=s[e].trim(),""!==o&&"#"!==o.substr(0,1)){if(h&&a1&&($("#"+l.pre+"assemblyWrapper").show(),l.asuCnt=l.biomtMatrices.length),l.setStyleCls.setAtomStyleByOptions(l.opts),l.setColorCls.setColorByOptions(l.opts,l.atoms),await l.ParserUtilsCls.renderStructure(),void 0!==r.cfg.rotate&&l.resizeCanvasCls.rotStruc(r.cfg.rotate,!0)}else"pdb"===i?await l.pdbParserCls.loadPdbData(e,t):"align"===i&&(l.bOpm?await l.alignParserCls.downloadAlignmentPart2(t):void 0!==n?await this.loadOpmData(e,n,s,i):await l.alignParserCls.downloadAlignmentPart2(t))}}class Xt{constructor(e){this.icn3d=e}async downloadPdb(e,t){let s,i=this.icn3d,n=i.icn3dui;t?(s="https://alphafold.ebi.ac.uk/files/AF-"+e+"-F1-model_"+i.AFUniprotVersion+".pdb",n.cfg.refseqid?i.ParserUtilsCls.setYourNote(n.cfg.refseqid.toUpperCase()+"(NCBI Protein Acc.) in iCn3D"):i.ParserUtilsCls.setYourNote(e.toUpperCase()+"(AlphaFold) in iCn3D")):(s="https://files.rcsb.org/view/"+e+".pdb",i.ParserUtilsCls.setYourNote(e.toUpperCase()+"(PDB) in iCn3D"));let l=await n.getAjaxPromise(s,"text",!0,"The ID "+e+" can not be found in the server "+s+"...");if(t){l="HEADER "+e+"\n"+l,await i.opmParserCls.parseAtomData(l,e,void 0,"pdb",void 0)}else await i.opmParserCls.loadOpmData(l,e,void 0,"pdb")}async downloadUrl(e,t,s){let i=this.icn3d,n=i.icn3dui,l=e.lastIndexOf("/");if(-1!=l){let t=e.lastIndexOf(".");i.filename=e.substr(l+1,t-l-1)}else{let t=e.lastIndexOf(".");i.filename=e.substr(0,t)}let r=await n.getAjaxPromise(e,"text",!0);if(i.InputfileData=i.InputfileData?i.InputfileData+"\nENDMDL\n"+r:r,i.InputfileType=t,"pdb"===t)await this.loadPdbData(r);else if("mmcif"===t){let e=n.htmlCls.baseUrl+"mmcifparser/mmcifparser.cgi",t={mmciffile:r},s=await n.getAjaxPostPromise(e,t,!0);await i.mmcifParserCls.loadMmcifData(s,void 0)}else if("mol2"===t)await i.mol2ParserCls.loadMol2Data(r);else if("sdf"===t)await i.sdfParserCls.loadSdfData(r);else if("xyz"===t)await i.xyzParserCls.loadXyzData(r);else if("mmcif"===t)await i.mmcifParserCls.loadMmcifData(r);else if("icn3dpng"===t)await n.htmlCls.setHtmlCls.loadPng(r,s);else if("pae"===t){n.htmlCls.dialogCls.openDlg("dl_alignerrormap","Show Predicted Aligned Error (PAE) map");let e=!0;i.contactMapCls.processAfErrorMap(JSON.parse(r),e)}}async loadPdbData(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui;if(!i&&(void 0===n||"target"===n)){let e=!!o.bCommandLoad;o.bStatefile||o.init(e)}let d=o.loadPDBCls.loadPDB(e,t,s,void 0,void 0,i,n,l);void 0===a.cfg.opmid&&o.ParserUtilsCls.transformToOpmOri(t),void 0!==o.biomtMatrices&&o.biomtMatrices.length>1&&(a.bNode||$("#"+o.pre+"assemblyWrapper").show(),o.asuCnt=o.biomtMatrices.length),a.bNode||(void 0!==o.emd?($("#"+o.pre+"mapWrapper1").hide(),$("#"+o.pre+"mapWrapper2").hide(),$("#"+o.pre+"mapWrapper3").hide()):($("#"+o.pre+"emmapWrapper1").hide(),$("#"+o.pre+"emmapWrapper2").hide(),$("#"+o.pre+"emmapWrapper3").hide()));let c=!1;return o.bSecondaryStructure&&1==Object.keys(o.structures).length?c=!1:a.cfg.mmtfid||a.cfg.pdbid||a.cfg.opmid||a.cfg.mmdbid||a.cfg.gi||a.cfg.uniprotid||a.cfg.blast_rep_id||a.cfg.cid||a.cfg.mmcifid||a.cfg.align||a.cfg.chainalign||(c=!0),(!o.bSecondaryStructure||c)&&Object.keys(o.proteins).length>0&&!r?await this.applyCommandDssp(i):(await this.loadPdbDataRender(i),a.bNode||await o.ParserUtilsCls.checkMemProteinAndRotate()),d}async applyCommandDssp(e){let t=this.icn3d,s=t.icn3dui,i=s.utilsCls.isCalphaPhosOnly(s.hashUtilsCls.hash2Atoms(t.proteins,t.atoms));await t.dsspCls.applyDssp(i,e)}async loadPdbDataRender(e){let t=this.icn3d,s=t.icn3dui;void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),s.cfg.afid&&!t.bAfMem&&(t.opts.color="confidence"),t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.hAtoms),await t.ParserUtilsCls.renderStructure(),t.saveFileCls.showTitle(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0),e&&t.definedSetsCls.setModeAndDisplay("all")}}class Kt{constructor(e){this.icn3d=e}async downloadCid(e){let t=this.icn3d,s=t.icn3dui;t.ParserUtilsCls.setYourNote("PubChem CID "+e+" in iCn3D"),t.bCid=!0;let i="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/"+t.inputid+"/cids/JSONP?cids_type=parent",n="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/"+(await s.getAjaxPromise(i,"jsonp",!0,"Can not retrieve the parant CID...")).IdentifierList.CID[0]+"/record/SDF/?record_type=3d&response_type=display",l=await s.getAjaxPromise(n,"text",!0,"This CID may not have 3D structure..."),r=this.loadSdfAtomData(l,e);void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),r?(t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.atoms),await t.ParserUtilsCls.renderStructure(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0)):alert("The SDF of CID "+e+" has the wrong format...")}async loadSdfData(e){let t=this.icn3d,s=t.icn3dui,i=this.loadSdfAtomData(e);void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),i?(t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.atoms),await t.ParserUtilsCls.renderStructure(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0)):alert("The SDF file has the wrong format...")}loadSdfAtomData(e,t){let s=this.icn3d;s.icn3dui;let i=e.split(/\r?\n|\r/);if(i.length<4)return!1;s.init();let n=t||1,l="LIG",r=n,o=n+"_A",a=o+"_1",d=parseInt(i[3].substr(0,3));if(isNaN(d)||d<=0)return!1;let c=parseInt(i[3].substr(3,3)),h=4;if(i.lengthr||(Math.abs(t.coord.y-i.coord.y)>r||Math.abs(t.coord.z-i.coord.z)>r||l.utilsCls.hasCovalentBond(t,i)&&(n.atoms[o[e]].bonds.push(o[s]),n.atoms[o[s]].bonds.push(o[e])))}}}loadXyzAtomData(e){let t=this.icn3d;t.icn3dui;let s=e.split(/\r?\n|\r/);if(s.length<3)return!1;t.init();let i,n,l,r={},o=0,a=1;t.molTitle="";for(let e=0,d=s.length;e1&&(t.molTitle+="; "),t.molTitle+=s[e+1].trim(),e+=2),d=s[e].trim(),""===d)continue;let c=d.replace(/,/," ").replace(/\s+/g," ").split(" "),h=c[0],p=parseFloat(c[1]),m=parseFloat(c[2]),u=parseFloat(c[3]),g={het:!0,serial:a,name:h,resn:"LIG",structure:l,chain:"A",resi:1,coord:new THREE.Vector3(p,m,u),b:0,elem:h,bonds:[],ss:"coil",ssbegin:!1,ssend:!1,bondOrder:[]};t.atoms[a]=g,r[a]=1,++a}return this.setXyzAtomSeq(r,o,i,n),t.ParserUtilsCls.setMaxD(),t.saveFileCls.showTitle(),!0}}class Jt{constructor(e){this.icn3d=e}realign(){let e=this.icn3d,t=e.icn3dui;e.selectionCls.saveSelectionPrep();let s="alseq_"+Object.keys(e.defNames2Atoms).length;e.selectionCls.saveSelection(s,s),t.htmlCls.clickMenuCls.setLogCmd("realign",!0);let i={},n={};e.realignResid={};let l="";for(let s in e.hAtoms){let r=e.atoms[s],o=r.structure+"_"+r.chain;if(e.proteins.hasOwnProperty(s)&&"CA"==r.name||e.nucleotides.hasOwnProperty(s)&&("O3'"==r.name||"O3*"==r.name)){if(r.structure+"_"+r.resi==l)continue;i.hasOwnProperty(r.structure)||(i[r.structure]=[]),i[r.structure].push(r.coord.clone()),e.realignResid.hasOwnProperty(o)||(e.realignResid[o]=[]),e.realignResid[o].push({resid:o+"_"+r.resi,resn:t.utilsCls.residueName2Abbr(r.resn.substr(0,3)).substr(0,1)}),n[r.structure]=r.structure+"_"+r.chain,l=r.structure+"_"+r.resi}}let r=Object.keys(i),o=r[0],a=[];e.qt_start_end=[],a.push(n[o]);for(let t=1,s=r.length;t5){let e=r.cfg.chainalign.split(",");e.length>0&&(l.hAtoms=l.definedSetsCls.getAtomsFromNameArray(e)),r.cfg.aligntool="tmalign",await l.realignParserCls.realignOnStructAlign()}else l.hAtoms=l.chainalignParserCls.setMsa(e),l.transformCls.zoominSelection(),await l.chainalignParserCls.downloadChainalignmentPart3(void 0,e,l.hAtoms)}async parseChainRealignData(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui,d=s[0].substr(0,s[0].indexOf("_"));r||(d=d.toUpperCase());let c={};o.realignResid={},o.opts.color="grey",o.setColorCls.setColorByOptions(o.opts,o.dAtoms),o.qt_start_end=[];for(let t=0,h=e.length;t=6&&C.length>=6&&!a.cfg.command&&o.bRender&&alert("These sequences can not be aligned to each other")):o.bRender&&alert("Please do not align residues in the same structure")}if(r){o.hAtoms=o.chainalignParserCls.setMsa(s);let e="protein_aligned";if(o.selectionCls.saveSelection(e,e),o.bAfMem?(o.selectionCls.selectAll_base(),o.opts.chemicals="stick",o.opts.color="confidence",o.setColorCls.setColorByOptions(o.opts,o.atoms)):(o.transformCls.zoominSelection(),o.dAtoms=a.hashUtilsCls.cloneHash(o.hAtoms),o.opts.color="identity",o.setColorCls.setColorByOptions(o.opts,o.hAtoms)),o.drawCls.draw(),o.hlUpdateCls.updateHlAll(),o.bAfMem){let e=new THREE.Vector3(1,0,0),t=-.5*Math.PI;o.transformCls.setRotation(e,t)}}else o.hAtoms=o.chainalignParserCls.setMsa(s),o.transformCls.zoominSelection(),await o.chainalignParserCls.downloadChainalignmentPart3(t,s,o.hAtoms)}async realignOnSeqAlign(e){let t=this.icn3d;t.icn3dui;let s=t.firstAtomObjCls.getChainsFromAtoms(t.hAtoms),i=Object.keys(s),n=[],l="";for(let e=0,t=i.length;ef&&(f=s)}}}return{data:n,min:g,max:f}}(e.getCategory("_volume_data_3d").getColumn("values"),o,n.sampleCount,l);return{name:n.name,spacegroup:function(e,t,s){let i=Math.PI/180*s[0],n=Math.PI/180*s[1],l=Math.PI/180*s[2],r=t[0],o=t[1],a=t[2],d=Math.cos(n),c=(Math.cos(i)-Math.cos(n)*Math.cos(l))/Math.sin(l),h=Math.sqrt(1-d*d-c*c);return{number:e,size:t,angles:s,basis:{x:[r,0,0],y:[Math.cos(l)*o,Math.sin(l)*o,0],z:[d*a,c*a,h*a]}}}(n.spacegroupNumber,n.cellSize,n.cellAngles),box:{origin:r(n.origin),dimensions:r(n.dimensions),sampleCount:o},data:a.data,valuesInfo:{min:a.min,max:a.max,mean:n.mean,sigma:n.sigma}}}BinaryParse(e){this.icn3d.icn3dui;let t=new Uint8Array(e),s=this.MessagePackParse({buffer:t,offset:0,dataView:new DataView(t.buffer)}),i=function(){function e(e){this.additionalData={},this.header=e.header,this.categoryList=e.categories.map((function(e){return new n(e)})),this.categoryMap=new Map;for(let e=0,t=this.categoryList;e=0;s--)t=c(t,e.encoding[s]);return t}function p(e){if(!e.data.data)return _UndefinedColumn;let t,s=h(e.data);return e.mask&&(t=h(e.mask)),s.buffer&&s.byteLength&&s.BYTES_PER_ELEMENT?t?new f(s,t):new g(s):t?new C(s,t):new b(s)}function m(e,t,s){let i=0,n=1;for(45===e.charCodeAt(t)&&(n=-1,t++);t9||s<0)return n*i|0;i=10*i+s|0}return n*i}function u(e,t,s){let i=1,n=0,l=0,r=1;for(45===e.charCodeAt(t)&&(i=-1,++t);t=0&&o<10)){if(-2===o){for(++t;t=0&&o<10))return 53===o||21===o?parseScientific(i*(n+l/r),e,t+1,s):i*(n+l/r);l=10*l+o,r*=10,++t}return i*(n+l/r)}if(53===o||21===o)return parseScientific(i*n,e,t+1,s);break}n=10*n+o,++t}return i*n}let g=function(){function e(e){this.data=e,this.isDefined=!0}return e.prototype.getString=function(e){return""+this.data[e]},e.prototype.getInteger=function(e){return 0|this.data[e]},e.prototype.getFloat=function(e){return 1*this.data[e]},e.prototype.stringEquals=function(e,t){return this.data[e]===u(t,0,t.length)},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return 0},e}(),f=function(){function e(e,t){this.data=e,this.mask=t,this.isDefined=!0}return e.prototype.getString=function(e){return 0===this.mask[e]?""+this.data[e]:null},e.prototype.getInteger=function(e){return 0===this.mask[e]?this.data[e]:0},e.prototype.getFloat=function(e){return 0===this.mask[e]?this.data[e]:0},e.prototype.stringEquals=function(e,t){return 0===this.mask[e]?this.data[e]===u(t,0,t.length):null==t},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return this.mask[e]},e}(),b=function(){function e(e){this.data=e,this.isDefined=!0}return e.prototype.getString=function(e){return this.data[e]},e.prototype.getInteger=function(e){let t=this.data[e];return m(t,0,t.length)},e.prototype.getFloat=function(e){let t=this.data[e];return u(t,0,t.length)},e.prototype.stringEquals=function(e,t){return this.data[e]===t},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return 0},e}(),C=function(){function e(e,t){this.data=e,this.mask=t,this.isDefined=!0}return e.prototype.getString=function(e){return 0===this.mask[e]?this.data[e]:null},e.prototype.getInteger=function(e){if(0!==this.mask[e])return 0;let t=this.data[e];return m(t||"",0,(t||"").length)},e.prototype.getFloat=function(e){if(0!==this.mask[e])return 0;let t=this.data[e];return u(t||"",0,(t||"").length)},e.prototype.stringEquals=function(e,t){return this.data[e]===t},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return this.mask[e]},e}(),y=function(){function e(e){this.dataBlocks=e.dataBlocks.map((function(e){return new i(e)}))}return e.prototype.toJSON=function(){return this.dataBlocks.map((function(e){return e.toJSON()}))},e}();return new y(s)}MessagePackParse(e){this.icn3d.icn3dui;let t=this;function s(e,s){let i={};for(let n=0;n0&&(i[i.length]=l.slice(0,a).join(""));return i.join("")}(e.buffer,e.offset,t);return e.offset+=t,s}let r=function(){let e=[];for(let t=0;t<1024;t++)e[t]=String.fromCharCode(t);return e}();let o,a,d=e.buffer[e.offset];if(0==(128&d))return e.offset++,d;if(128==(240&d))return a=15&d,e.offset++,s(e,a);if(144==(240&d))return a=15&d,e.offset++,n(e,a);if(160==(224&d))return a=31&d,e.offset++,l(e,a);if(224==(224&d))return o=e.dataView.getInt8(e.offset),e.offset++,o;switch(d){case 192:return e.offset++,null;case 194:return e.offset++,!1;case 195:return e.offset++,!0;case 196:return a=e.dataView.getUint8(e.offset+1),e.offset+=2,i(e,a);case 197:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,i(e,a);case 198:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,i(e,a);case 202:return o=e.dataView.getFloat32(e.offset+1),e.offset+=5,o;case 203:return o=e.dataView.getFloat64(e.offset+1),e.offset+=9,o;case 204:return o=e.buffer[e.offset+1],e.offset+=2,o;case 205:return o=e.dataView.getUint16(e.offset+1),e.offset+=3,o;case 206:return o=e.dataView.getUint32(e.offset+1),e.offset+=5,o;case 208:return o=e.dataView.getInt8(e.offset+1),e.offset+=2,o;case 209:return o=e.dataView.getInt16(e.offset+1),e.offset+=3,o;case 210:return o=e.dataView.getInt32(e.offset+1),e.offset+=5,o;case 217:return a=e.dataView.getUint8(e.offset+1),e.offset+=2,l(e,a);case 218:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,l(e,a);case 219:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,l(e,a);case 220:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,n(e,a);case 221:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,n(e,a);case 222:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,s(e,a);case 223:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,s(e,a)}}}class es{constructor(e){this.icn3d=e}alignCoords(e,t,s,i,n,l,r,o){let a,d=this.icn3d,c=d.icn3dui,h=e.length=4&&(d.rmsd_suprTmp=c.rmsdSuprCls.getRmsdSuprCls(e,t,h),void 0!==d.rmsd_suprTmp.rot)){let e=d.rmsd_suprTmp.rot;null===e[0]&&alert("Please select more residues in each structure...");let t=d.rmsd_suprTmp.trans1,i=d.rmsd_suprTmp.trans2;if(a=d.rmsd_suprTmp.rmsd,a){c.htmlCls.clickMenuCls.setLogCmd("realignment RMSD: "+a.toPrecision(4),!1);let e="
    Realignment RMSD: "+a.toPrecision(4)+" Å

    ";d.bAfMem&&(e+=c.utilsCls.getMemDesc()),$("#"+d.pre+"dl_rmsd").html(e),c.cfg.bSidebyside||c.htmlCls.dialogCls.openDlg("dl_rmsd","Realignment RMSD")}let r={};for(let n=0,l=d.structures[s].length;n"+s.diagram2dCls.set2DdgmNote(!0),$("#"+s.pre+"dl_2ddgm").html(s.html2ddgm),s.b2DShown=!0}async set2DDiagramsForChainalign(e){let t=this.icn3d.icn3dui,s=this;t.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions");let i=[];for(let s=0,n=e.length;s"+s.diagram2dCls.set2DdgmNote(!0),s.b2DShown=!0,$("#"+s.pre+"dl_2ddgm").html(s.html2ddgm),i.cfg.show2d&&i.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions")}download2Ddgm(e,t){this.set2DDiagrams(e)}set2DDiagrams(e){let t=this.icn3d;t.icn3dui.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions"),void 0!==t.b2DShown&&t.b2DShown||(t.html2ddgm="",t.diagram2dCls.draw2Ddgm(t.interactionData,e),t.html2ddgm+="
    "+t.diagram2dCls.set2DdgmNote(),$("#"+t.pre+"dl_2ddgm").html(t.html2ddgm)),t.b2DShown=!0}showLoading(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"wait")&&$("#"+e.pre+"wait").show(),$("#"+e.pre+"canvas")&&$("#"+e.pre+"canvas").hide(),$("#"+e.pre+"cmdlog")&&$("#"+e.pre+"cmdlog").hide()}hideLoading(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"wait")&&$("#"+e.pre+"wait").hide(),$("#"+e.pre+"canvas")&&$("#"+e.pre+"canvas").show(),$("#"+e.pre+"cmdlog")&&$("#"+e.pre+"cmdlog").show()}setYourNote(e){let t=this.icn3d,s=t.icn3dui;t.yournote=e,$("#"+t.pre+"yournote").val(t.yournote),s.cfg.shownote&&(document.title=t.yournote)}transformToOpmOri(e){let t=this.icn3d;if(t.icn3dui,void 0!==t.rmsd_supr&&void 0!==t.rmsd_supr.rot){let s=t.rmsd_supr.rot,i=t.rmsd_supr.trans1,n=t.rmsd_supr.trans2;t.rmsd_supr.rmsd;let l=0;for(let e in t.atoms){let r=t.atoms[e];r.coord=t.surfaceCls.transformMemPro(r.coord,s,i,n);let o=r.coord.x*r.coord.x+r.coord.y*r.coord.y;Math.abs(r.coord.z)<=25&&o>l&&(l=o)}this.addMemAtoms(t.halfBilayerSize,e,Math.sqrt(l)),t.bStopRotate=!0,t.bOpm=!0,$("#"+t.pre+"togglememli").show(),$("#"+t.pre+"adjustmemli").show(),$("#"+t.pre+"selectplaneli").show()}else t.bOpm=!1}transformToOpmOriForAlign(e,t,s){let i=this.icn3d,n=i.icn3dui;if(void 0!==t){let l=i.loadPDBCls.getChainCalpha(i.chains,i.atoms,s,e),r=1==Object.keys(l.chainresiCalphaHash).length||1==Object.keys(t.chainresiCalphaHash).length,o=[],a=[];for(let e in l.chainresiCalphaHash)if(t.chainresiCalphaHash.hasOwnProperty(e)){let s=l.chainresiCalphaHash[e],i=t.chainresiCalphaHash[e];if((s.length==i.length||r)&&(o=o.concat(s),a=a.concat(i)),o.length>500)break}let d=o.length=4)if(i.rmsd_supr=n.rmsdSuprCls.getRmsdSuprCls(o,a,d),void 0!==i.rmsd_supr.rot&&i.rmsd_supr.rmsd<.1){let s=i.rmsd_supr.rot,l=i.rmsd_supr.trans1,r=i.rmsd_supr.trans2,o=i.rmsd_supr.rmsd;n.htmlCls.clickMenuCls.setLogCmd("RMSD of alignment to OPM: "+o.toPrecision(4),!1);let a=0;for(let e in i.atoms){let t=i.atoms[e];t.coord=i.surfaceCls.transformMemPro(t.coord,s,l,r);let n=t.coord.x*t.coord.x+t.coord.y*t.coord.y;Math.abs(t.coord.z)<=25&&n>a&&(a=n)}i.center=t.center,i.oriCenter=i.center.clone(),this.addMemAtoms(i.halfBilayerSize,e,Math.sqrt(a)),i.bStopRotate=!0,i.bOpm=!0,$("#"+i.pre+"togglememli").show(),$("#"+i.pre+"adjustmemli").show(),$("#"+i.pre+"selectplaneli").show()}else i.bOpm=!1;else i.bOpm=!1}}addOneDumAtom(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui,a={het:!0,serial:++l,name:t,alt:void 0,resn:"DUM",structure:e,chain:"MEM",resi:1,coord:new THREE.Vector3(s,i,n),b:void 0,elem:t,bonds:[],ss:"",ssbegin:!1,ssend:!1,color:o.parasCls.atomColors[t]};return r.atoms[l]=a,r.chains[e+"_MEM"][l]=1,r.residues[e+"_MEM_1"][l]=1,r.chemicals[l]=1,r.dAtoms[l]=1,r.hAtoms[l]=1,l}addMemAtoms(e,t,s){let i=this.icn3d;if(i.icn3dui,!t)return;t=t?t.toUpperCase():i.defaultPdbId,i.structures[t].push(t+"_MEM"),i.chains[t+"_MEM"]={},i.residues[t+"_MEM_1"]={},i.chainsSeq[t+"_MEM"]=[{name:"DUM",resi:1}];let n=Object.keys(i.atoms).length;for(let e=0;e<1e3;++e)if(!i.atoms.hasOwnProperty(n+e)){n=n+e-1;break}for(let i=0;i<81;++i)for(let l=0;l<81;++l){let r=2*i-80,o=2*l-80;if(Math.sqrt(r*r+o*o)=2?$("#"+e.pre+"mn2_alternateWrap").show():$("#"+e.pre+"mn2_alternateWrap").hide(),setTimeout((async function(){if(e.bInitial){if(void 0!==t.cfg.align||void 0!==t.cfg.chainalign){let s=e.pre+"selection";if($("#"+s).show(),$("#"+s+"_expand").hide(),$("#"+s+"_shrink").show(),void 0!==t.cfg.align&&2!=t.cfg.atype){let s=!1,i=t.htmlCls.alignSeqCls.getAlignSequencesAnnotations(Object.keys(e.alnChains),void 0,void 0,s);$("#"+e.pre+"dl_sequence2").html(i.sequencesHtml),$("#"+e.pre+"dl_sequence2").width(t.htmlCls.RESIDUE_WIDTH*i.maxSeqCnt+200)}}if(t.cfg.showanno){let s="view annotations";t.htmlCls.clickMenuCls.setLogCmd(s,!0),await e.showAnnoCls.showAnnotations()}t.cfg.closepopup&&e.resizeCanvasCls.closeDialogs()}else e.hlUpdateCls.updateHlAll();$("#"+e.pre+"atomsCustom").length>0&&$("#"+e.pre+"atomsCustom")[0].blur(),e.bInitial=!1}),0)}processCommand(){let e=this.icn3d,t=e.icn3dui;if(1==Object.keys(e.structures).length){let s=Object.keys(e.structures)[0];t.cfg.command=t.cfg.command.replace(new RegExp("!","g"),s+"_")}}getMassCenter(e,t){return this.icn3d.icn3dui,e.multiplyScalar(1/t)}getGeoCenter(e,t){return this.icn3d.icn3dui,e.clone().add(t).multiplyScalar(.5)}getStructureSize(e,t,s,i){let n=this.icn3d;n.icn3dui;let l=0;for(let r in e){let e=n.atoms[r].coord;if(Math.round(t.x)==Math.round(e.x)||Math.round(t.y)==Math.round(e.y)||Math.round(t.z)==Math.round(e.z)||Math.round(s.x)==Math.round(e.x)||Math.round(s.y)==Math.round(e.y)||Math.round(s.z)==Math.round(e.z)){let t=2*e.distanceTo(i);t>l&&(l=t)}}return l}async checkMemProteinAndRotate(){let e=this.icn3d,t=e.icn3dui;if(!e.bCheckMemProtein){e.bCheckMemProtein=!0;let s=t.cfg.afid?t.cfg.afid:t.cfg.mmdbafid;if(await e.ParserUtilsCls.checkMemProtein(s),t.cfg.url&&-1!=t.cfg.url.indexOf("membranome")){let t=new THREE.Vector3(1,0,0),s=-.5*Math.PI;e.transformCls.setRotation(t,s)}}}async checkMemProtein(e){let t=this.icn3d,s=t.icn3dui;try{let i=s.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?afid2mem="+e,n=await s.getAjaxPromise(i,"jsonp");if(n&&n.pdbid){let e='This is a single-spanning (bitopic) transmembrane protein according to the Membranome database. Do you want to align the protein with the model from Membranome? If you click "OK", you can press the letter "a" to alternate the structures.';if("off"==s.cfg.afmem);else if("on"==s.cfg.afmem||confirm(e))try{let e="https://storage.googleapis.com/membranome-assets/pdb_files/proteins/"+n.pdbid+".pdb",i=await s.getAjaxPromise(e,"text");t.bAfMem=!0,s.bNode||$("#"+s.pre+"togglememli").show();let l=n.pdbid.substr(0,n.pdbid.indexOf("_")),r=!0,o=!0;await t.pdbParserCls.loadPdbData(i,l,r,o),o&&(t.bSetChainsAdvancedMenu&&t.definedSetsCls.showSets(),t.bAnnoShown&&await t.showAnnoCls.showAnnotations());let a=n.segment.replace(/ /gi,"").split("(")[0];t.afmem_start_end=a.split("-"),t.hAtoms={},t.dAtoms={};for(let e in t.atoms)t.atoms[e].structure!=l&&(t.hAtoms[e]=1),t.dAtoms[e]=1;for(let e=parseInt(t.afmem_start_end[0]);e<=parseInt(t.afmem_start_end[1]);++e)t.hAtoms=s.hashUtilsCls.unionHash(t.hAtoms,t.residues[l+"_A_"+e]);await t.realignParserCls.realignOnSeqAlign(l)}catch(e){return void console.log("Error in retrieving matched PDB from Membranome...")}}}catch(e){return void console.log("Error in finding matched PDB in Membranome...")}}getResi(e,t){let s=this.icn3d;s.icn3dui;let i=s.ncbi2resid[e+"_"+(t+1).toString()];return i?i.substr(i.lastIndexOf("_")+1):""}getResiNCBI(e,t){let s=this.icn3d;s.icn3dui;let i=s.resid2ncbi[e+"_"+t];return i?parseInt(i.substr(i.lastIndexOf("_")+1)):0}}class ts{constructor(e){this.icn3d=e}loadAtomDataIn(e,t,s,i,n,l,r,o,a){let d=this.icn3d,c=d.icn3dui;d.pmin=new THREE.Vector3(9999,9999,9999),d.pmax=new THREE.Vector3(-9999,-9999,-9999),d.psum=new THREE.Vector3;let h=e.atoms,p=d.atoms?Object.keys(d.atoms).length:0,m={},u={};d.pmid=e.pubmedId,void 0===d.chainid2title&&(d.chainid2title={}),void 0===d.chainid2sid&&(d.chainid2sid={});let g={},f={};if("align"===s){d.pmid="",d.molTitle="",c.cfg.inpara&&-1!==c.cfg.inpara.indexOf("atype=1")?d.molTitle="Invariant Core Structure Alignment (VAST) of ":c.cfg.inpara&&-1!==c.cfg.inpara.indexOf("atype=2")?d.molTitle="Structure Alignment (TM-align) of ":d.molTitle="Structure Alignment (VAST) of ";let t=!1;for(let s=0,i=e.alignedStructures[0].length;s'+i.pdbId.toUpperCase()+"",void 0!==i.descr&&(d.pmid+=i.descr.pubmedid),0===s&&(d.molTitle+=" and ",void 0!==i.descr&&(d.pmid+="_")),t=!0}d.molTitle+=" from VAST+",t||(d.molTitle="")}else if(void 0!==e.descr&&(d.molTitle+=e.descr.name),"mmdbid"===s){let s=isNaN(t)?t:e.pdbId,i={};void 0===d.alignmolid2color&&(d.alignmolid2color=[]);let n=1;for(let t in e.moleculeInfor){if(0===Object.keys(e.moleculeInfor[t]).length)continue;let l=e.moleculeInfor[t].chain.trim(),r=s+"_"+l;i.hasOwnProperty(l)?(++i[l],r+=i[l]):i[l]=1,void 0!==d.mmdbid_q&&(d.mmdbid_q,d.mmdbid_t);let o=e.moleculeInfor[t].kind,a=e.moleculeInfor[t].color,c=e.moleculeInfor[t].sid;if(g[r]=o,f[r]=a,"protein"==o&&(d.organism=e.moleculeInfor[t].taxonomyName.toLowerCase()),void 0!==c&&(d.chainid2sid[r]=c),void 0===d.pdbid_chain2title&&(d.pdbid_chain2title={}),d.pdbid_chain2title[r]=e.moleculeInfor[t].name,l==r.substr(r.lastIndexOf("_"))){let e={};e[t]=n.toString(),d.alignmolid2color.push(e)}++n}}let b,C,y,v,w,_={},S="",A="",x="",k="",O="",R="",E=0,I=0,T="",M=!0,P=!1,D="",H=c.utilsCls.isCalphaPhosOnly(h),F=0,L={};for(let e in h){++p,_[e]=p;let i,n=h[e];n.serial=p,"mmdbid"===s||"mmcifid"===s?i=t:"align"===s&&(i=m[p]);let l=!1;if(void 0!==n.chain||"mmdbid"!==s&&"align"!==s)n.chain=""===n.chain?"Misc":n.chain;else if("mmdbid"===s)if(b=n.ids.m,void 0!==d.molid2chain[b]){let e=d.molid2chain[b].indexOf("_");n.chain=d.molid2chain[b].substr(e+1)}else{let e="Misc";("protein"===g[O]&&"nucleotide"===g[O]&&n.resi!=I||"protein"!==g[O]&&"nucleotide"!==g[O]&&(n.resn.substr(0,3)!=T.substr(0,3)||n.resi!=I||"solvent"===g[O]||"HOH"===n.resn))&&++F,n.resi_ori=n.resi,n.resi=F,l=!0,n.chain=e}else if("align"===s)if(b=n.ids.m,void 0!==d.pdbid_molid2chain[i+"_"+b])n.chain=d.pdbid_molid2chain[i+"_"+b];else{let e="Misc";("protein"===g[O]&&"nucleotide"===g[O]&&n.resi!=I||"protein"!==g[O]&&"nucleotide"!==g[O]&&(n.resn.substr(0,3)!=T.substr(0,3)||n.resi!=I||"solvent"===g[O]||"HOH"===n.resn))&&(++F,n.resi_ori=n.resi,n.resi=F,l=!0),n.chain=e}if(n.chain=n.chain.trim(),"mmdbid"!==s&&"align"!==s||(n.structure=i,"mmdbid"===s&&void 0!==d.mmdbid_q&&(d.mmdbid_q,d.mmdbid_t)),k=n.structure,O=k+"_"+n.chain,"mmdbid"===s||"align"===s){l||(n.resi_ori=n.resi,d.bUsePdbNum?n.resi=n.resi_ori:n.resi=n.ids.r);let e=n.resn.indexOf(" ");-1!==e&&0!=e&&(n.resn=n.resn.substr(0,e))}O!==A&&(E=0),n.resi!==E&&(O!==A?(y=void 0,w=void 0):(y=C,w=v)),n.coord="mmdbid"===s?new THREE.Vector3(n.coord[0],n.coord[1],n.coord[2]):new THREE.Vector3(n.coord.x,n.coord.y,n.coord.z);let r=c.utilsCls.residueName2Abbr(n.resn.substr(0,3));"mmdbid"!==s&&"align"!==s||!d.bFullUi||(void 0===d.mmdbMolidResid2mmdbChainResi&&(d.mmdbMolidResid2mmdbChainResi={}),d.mmdbMolidResid2mmdbChainResi[i+"_"+n.ids.m+"_"+n.ids.r]=i+"_"+n.chain+"_"+n.resi),d.pmin.min(n.coord),d.pmax.max(n.coord),d.psum.add(n.coord);let o=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"protein"===g[O]:"p"===n.mt,a=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"nucleotide"===g[O]:"n"===n.mt,u=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"solvent"===g[O]:"s"===n.mt,N=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"ligand"===g[O]||void 0!==g[O]&&-1!==g[O].indexOf("other")||void 0===g[O]:"l"===n.mt;if("Misc"!==n.chain&&"other"!==g[O]||"protein"===L[O]||"nucleotide"===L[O]||("CA"===n.name&&"C"===n.elem?L[O]="protein":"P"===n.name&&"P"===n.elem?L[O]="nucleotide":L[O]="chemical"),o||a?(o?(d.proteins[p]=1,"CA"===n.name&&(d.calphas[p]=1),"N"!==n.name&&"H"!==n.name&&"CA"!==n.name&&"HA"!==n.name&&"C"!==n.name&&"O"!==n.name&&(d.sidec[p]=1)):a&&(d.nucleotides[p]=1,("O3'"==n.name||"O3*"==n.name||H&&"P"==n.name)&&(d.nucleotidesO3[p]=1),-1===c.parasCls.nuclMainArray.indexOf(n.name)&&(d.ntbase[p]=1)),n.het=!1):u?(d.water[p]=1,n.het=!0):N&&("HOH"===n.resn||"O"===n.resn?d.water[p]=1:n.elem===n.resn?d.ions[p]=1:d.chemicals[p]=1,n.het=!0),"mmdbid"===s?n.het?n.color=c.parasCls.atomColors[n.elem]||c.parasCls.defaultAtomColor:n.color=void 0!==f[O]?c.parasCls.thr(f[O]):c.parasCls.chargeColors[n.resn]:void 0!==n.color&&(n.color=c.parasCls.thr(n.color))," "!==n.resn.charAt(0)&&" "===n.resn.charAt(1)&&(n.resn=n.resn.charAt(0)),n.het||"C"!==n.name||(C=p),n.het||"O"!==n.name||(v=p),!n.het&&"N"===n.name&&void 0!==y&&void 0!==w){let e=d.atoms[y].coord.distanceTo(d.atoms[w].coord),t=n.coord.x+(d.atoms[y].coord.x-d.atoms[w].coord.x)/e,s=n.coord.y+(d.atoms[y].coord.y-d.atoms[w].coord.y)/e,i=n.coord.z+(d.atoms[y].coord.z-d.atoms[w].coord.z)/e;n.hcoord=new THREE.Vector3(t,s,i)}"HOH"==n.resn&&(d.water[p]=1),d.atoms[p]=n,d.dAtoms[p]=1,d.hAtoms[p]=1;let U=n.structure+"_"+n.chain;void 0===d.chains[U]&&(d.chains[U]={}),d.chains[U][p]=1;let q=U+"_"+n.resi;void 0===d.residues[q]&&(d.residues[q]={}),d.residues[q][p]=1,R=O+"_"+n.resi,R!==x&&O!==A&&(M=!0,""!==S&&(void 0===d.structures[S]&&(d.structures[S]=[]),d.structures[S].push(A))),d.residueId2Name[q]=r;let $="-";if("helix"===n.ss?$="H":"sheet"===n.ss?$="E":n.het||a?$="o":(!n.het&&c.parasCls.residueColors.hasOwnProperty(n.resn.toUpperCase())||"coil"===n.ss)&&($="c"),d.secondaries[n.structure+"_"+n.chain+"_"+n.resi]=$,(n.resi!=E||b!=D)&&d.bFullUi&&(void 0===d.chainsSeq[U]&&(d.chainsSeq[U]=[],M=!1),!isNaN(n.resi)))if(M&&!P&&void 0!==d.chainsSeq[U][n.resi-1])d.chainsSeq[U][n.resi-1].name=r;else if(!M||!d.chainsSeq[U].hasOwnProperty(n.resi-1)){let e={};e.resi=n.resi,e.name=r,n.resi%10==0&&n.resi.toString(),d.chainsSeq[U].push(e),P=!0}E=n.resi,I=n.resi_ori,T=n.resn,S=k,A=O,x=R,D=b}for(let e in d.chemicals){let t=d.atoms[e];if("P"==t.elem&&t.bonds.length>=4)for(let e=t.bonds.length-1;e>=0;--e){"P"==d.atoms[t.bonds[e]].elem&&t.bonds.splice(e,1)}}for(let e in L)if(!(Object.keys(d.chains[e]).length<10)&&"chemical"!==L[e])for(let t in d.chains[e]){let s=d.atoms[t];delete d.chemicals[t],s.het=!1,"protein"===L[e]?(d.proteins[t]=1,"CA"===s.name&&(d.calphas[t]=1),"N"!==s.name&&"H"!==s.name&&"CA"!==s.name&&"HA"!==s.name&&"C"!==s.name&&"O"!==s.name&&(d.sidec[t]=1)):"nucleotide"===L[e]&&(d.nucleotides[t]=1,("O3'"==s.name||"O3*"==s.name||H&&"P"==s.name)&&(d.nucleotidesO3[t]=1),-1===c.parasCls.nuclMainArray.indexOf(s.name)&&(d.ntbase[t]=1))}if(void 0===d.structures[k]&&(d.structures[k]=[]),d.structures[k].push(O),d.bFullUi)if("mmdbid"===s||"mmcifid"===s)for(let i in e.sequences){let n=e.sequences[i],l=t+"_"+i;void 0!==d.mmdbid_q&&(d.mmdbid_q,d.mmdbid_t),d.ParserUtilsCls.getMissingResidues(n,s,l)}else if("align"===s)for(let e in d.chainid2seq){let t=d.chainid2seq[e];d.ParserUtilsCls.getMissingResidues(t,s,e)}if(d.loadPDBCls.setResidMapping(),"mmcifid"!==s)for(let e in h){let t=_[e],s=void 0===d.atoms[t].bonds?0:d.atoms[t].bonds.length;for(let e=0;ed.maxatomcnt||void 0!==d.biomtMatrices&&d.biomtMatrices.length*d.cnt>10*d.maxatomcnt)&&(d.opts.proteins="c alpha trace",d.opts.nucleotides="o3 trace"),d.center=d.ParserUtilsCls.getGeoCenter(d.pmin,d.pmax),d.maxD=d.ParserUtilsCls.getStructureSize(d.atoms,d.pmin,d.pmax,d.center),d.maxD<5&&(d.maxD=5),d.oriMaxD=d.maxD,("align"===s||o)&&(d.ssbondpnts={},d.loadPDBCls.setSsbond()),"mmdbid"===s&&1==Object.keys(d.structures).length){let t=e.disulfides;if(void 0!==t)for(let e=0,s=t.length;ep&&(p=e)),c[e]={resi:t,resn:i,aligned:n}}r=e[t][1];let u=r.moleculeId,g=s.pdbid_molid2chain[l+"_"+u],f=l+"_"+g;void 0===s.alnChainsAnTtl[d]&&(s.alnChainsAnTtl[d]=[]),void 0===s.alnChainsAnTtl[d][0]&&(s.alnChainsAnTtl[d][0]=[]),void 0===s.alnChainsAnTtl[d][1]&&(s.alnChainsAnTtl[d][1]=[]),void 0===s.alnChainsAnTtl[d][2]&&(s.alnChainsAnTtl[d][2]=[]),void 0===s.alnChainsAnTtl[d][3]&&(s.alnChainsAnTtl[d][3]=[]),void 0===s.alnChainsAnTtl[d][4]&&(s.alnChainsAnTtl[d][4]=[]),void 0===s.alnChainsAnTtl[d][5]&&(s.alnChainsAnTtl[d][5]=[]),void 0===s.alnChainsAnTtl[d][6]&&(s.alnChainsAnTtl[d][6]=[]),s.alnChainsAnTtl[d][0].push(f),s.alnChainsAnTtl[d][1].push(d),s.alnChainsAnTtl[d][2].push(""),s.alnChainsAnTtl[d][3].push(""),s.alnChainsAnTtl[d][4].push(f),s.alnChainsAnTtl[d][5].push(d),s.alnChainsAnTtl[d][6].push("");let b=1;s.chainsMapping[d]||(s.chainsMapping[d]={}),s.chainsMapping[f]||(s.chainsMapping[f]={});for(let e=h;e<=p;++e){let t,o,p,m=s.bUsePdbNum?s.ParserUtilsCls.getResi(f,r.sequence[e][0]-1):r.sequence[e][0],u="~"===r.sequence[e][2]?"-":r.sequence[e][2],C=r.sequence[e][3]?1:0,y=c[e].aligned+C;2===y?(c[e].resn===u?(t="#FF0000",p="icn3d-cons",s.consHash1[d+"_"+c[e].resi]=1,s.consHash2[f+"_"+m]=1):(t="#0000FF",p="icn3d-ncons",s.nconsHash1[d+"_"+c[e].resi]=1,s.nconsHash2[f+"_"+m]=1),s.chainsMapping[d][d+"_"+c[e].resi]=c[e].resn+c[e].resi,s.chainsMapping[f][f+"_"+m]=c[e].resn+c[e].resi,o="#"+s.showAnnoCls.getColorhexFromBlosum62(c[e].resn,u)):(t=i.htmlCls.GREY8,p="icn3d-nalign",s.nalignHash1[d+"_"+c[e].resi]=1,s.nalignHash2[f+"_"+m]=1),void 0===s.alnChainsSeq[d]&&(s.alnChainsSeq[d]=[]);let v={};v.mmdbid=n,v.chain=a,v.resi=c[e].resi,v.resn=""===v.resi||"icn3d-nalign"===p?c[e].resn.toLowerCase():c[e].resn,v.aligned=y,v.color=""===v.resi?i.htmlCls.GREYC:t,v.color2=""===v.resi?i.htmlCls.GREYC:o,v.class=p,s.alnChainsSeq[d].push(v),""!==c[e].resi&&(void 0===s.alnChains[d]&&(s.alnChains[d]={}),$.extend(s.alnChains[d],s.residues[d+"_"+c[e].resi])),void 0===s.alnChainsSeq[f]&&(s.alnChainsSeq[f]=[]),v={},v.mmdbid=l,v.chain=g,v.resi=m,v.resn=""===v.resi||"icn3d-nalign"===p?u.toLowerCase():u,v.aligned=y,v.color=""===v.resi?i.htmlCls.GREYC:t,v.color2=""===v.resi?i.htmlCls.GREYC:o,v.class=p,s.alnChainsSeq[f].push(v),""!==v.resi&&(void 0===s.alnChains[f]&&(s.alnChains[f]={}),$.extend(s.alnChains[f],s.residues[f+"_"+m])),void 0===s.alnChainsAnno[d]&&(s.alnChainsAnno[d]=[]),void 0===s.alnChainsAnno[d][0]&&(s.alnChainsAnno[d][0]=[]),void 0===s.alnChainsAnno[d][1]&&(s.alnChainsAnno[d][1]=[]),void 0===s.alnChainsAnno[d][2]&&(s.alnChainsAnno[d][2]=[]),void 0===s.alnChainsAnno[d][3]&&(s.alnChainsAnno[d][3]=[]),e===h&&(void 0===s.alnChainsAnno[d][4]&&(s.alnChainsAnno[d][4]=[]),void 0===s.alnChainsAnno[d][5]&&(s.alnChainsAnno[d][5]=[]),void 0===s.alnChainsAnno[d][6]&&(s.alnChainsAnno[d][6]=[]),s.alnChainsAnno[d][4].push(s.pdbid_chain2title[f]),s.alnChainsAnno[d][5].push(s.pdbid_chain2title[d]),s.alnChainsAnno[d][6].push(""));let w=d+"_"+c[e].resi,_=f+"_"+m,S=s.secondaries[w],A=s.secondaries[_];A?s.alnChainsAnno[d][0].push(A):s.alnChainsAnno[d][0].push("-"),S?s.alnChainsAnno[d][1].push(S):s.alnChainsAnno[d][1].push("-");let x=".";b%5==0&&(x="*"),b%10==0&&(x="|"),s.alnChainsAnno[d][2].push(x);let k="";b%10==0&&(k=b.toString()),s.alnChainsAnno[d][3].push(k),++b}}e={}}getPosFromResi(e,t){let s=this.icn3d;s.icn3dui;let i,n=s.resid2ncbi[e+"_"+t];if(n){i=n.substr(n.lastIndexOf("_")+1)-1}return i}getResnFromResi(e,t){let s=this.icn3d,i=s.icn3dui,n=this.getPosFromResi(e,t);if(!n)return"?";let l=e+"_"+t,r="";return r=void 0===s.residues[l]?s.chainsSeq[e][n]?s.chainsSeq[e][n].name:"?":i.utilsCls.residueName2Abbr(s.firstAtomObjCls.getFirstAtomObj(s.residues[l]).resn.substr(0,3)),r}setSeqAlignChain(e,t,s){let i,n,l,r,o,a,d,c,h,p,m,u=this.icn3d,g=u.icn3dui,f={},b=!!s;if(b){if(o=s[1],a=s[0],t=s[2],d=o.indexOf("_"),c=a.indexOf("_"),i=o.substr(0,d).toUpperCase(),n=a.substr(0,c).toUpperCase(),l=o.substr(d+1),r=a.substr(d+1),i==n&&l==r){let e=u.chainsSeq[n+"_"+r].length;u.qt_start_end[t]={q_start:1,q_end:e,t_start:1,t_end:e}}}else{let d=s[0].indexOf("_"),c=e.indexOf("_");if(i=u.mmdbid_t,n=e.substr(0,c).toUpperCase(),l=s[0].substr(d+1),r=e.substr(c+1),i==n&&l==r){let e=u.chainsSeq[u.mmdbid_q+"_"+u.chain_q].length;u.qt_start_end[t]={q_start:1,q_end:e,t_start:1,t_end:e}}o=i+"_"+l,a=n+"_"+r,void 0!==n&&u.mmdbid_t}u.conservedName1=o+"_cons",u.nonConservedName1=o+"_ncons",u.notAlignedName1=o+"_nalign",u.conservedName2=a+"_cons",u.nonConservedName2=a+"_ncons",u.notAlignedName2=a+"_nalign",u.consHash1={},u.nconsHash1={},u.nalignHash1={},u.consHash2={},u.nconsHash2={},u.nalignHash2={},u.alnChains={},u.alnChainsSeq[o]=[],u.alnChains[o]={},u.alnChainsSeq[a]=[],u.alnChains[a]={},u.alnChainsAnno[o]=[],u.alnChainsAnTtl[o]=[],void 0===u.alnChainsAnTtl[o]&&(u.alnChainsAnTtl[o]=[]);for(let e=0;e<7;++e)void 0===u.alnChainsAnTtl[o][e]&&(u.alnChainsAnTtl[o][e]=[]);u.alnChainsAnTtl[o][0].push(a),u.alnChainsAnTtl[o][1].push(o),u.alnChainsAnTtl[o][2].push(""),u.alnChainsAnTtl[o][3].push(""),u.alnChainsAnTtl[o][4].push(a),u.alnChainsAnTtl[o][5].push(o),u.alnChainsAnTtl[o][6].push("");let C=0,y=0;if(void 0===u.qt_start_end[t])return;let v=1;u.chainsMapping[o]||(u.chainsMapping[o]={}),u.chainsMapping[a]||(u.chainsMapping[a]={});let w={},_={};for(let e=0,s=u.qt_start_end[t].length;e0){let e=v;for(let t=C+1,i=s;tc&&(c=t)}}}"tmalign"==n.cfg.aligntool&&(s=!0);let p=Object.keys(a);p.sort((function(e,t){return parseInt(e)-parseInt(t)}));let m=-999,u=0,g=0,f=[],b=0;for(let e=0,t=p.length;e0&&i.resid2ncbi[t]!=i.resid2ncbi[m]+1&&i.resid2ncbi[t]!=i.resid2ncbi[m]){g=m;for(let e=0,t=f.length;ec)continue;let o={},p=r.indexOf("_");o.mmdbid=r.substr(0,p),o.chain=r.substr(p+1),o.resi=t,o.resn=a[t]?i.chainsSeq[r][e].name.toUpperCase():i.chainsSeq[r][e].name.toLowerCase(),o.aligned=!!a[t],o.color=a[t]?"#FF0000":n.htmlCls.GREYC,o.color2=a[t]?"#FF0000":n.htmlCls.GREYC,o.class=a[t]?"icn3d-align":"icn3d-nalign",i.alnChainsSeq[r].push(o),a[t]&&($.extend(i.alnChains[r],i.residues[r+"_"+o.resi]),l=n.hashUtilsCls.unionHash(l,i.residues[r+"_"+o.resi]))}let C=[0];for(let i=0,r=t.length;in)for(let e=0,t=u-m;e=n)for(let e=0,s=t-n;e0?void 0!==n?p.alnChainsAnno[t][0].push(n):p.alnChainsAnno[t][0].push("-"):console.log("Error: ic.alnChainsAnno[chainid1] is undefined")}}}class is{constructor(e){this.icn3d=e}getStructureId(e,t,s){let i=this.icn3d;i.icn3dui;let n=e;return(e==i.defaultPdbId||s)&&(n=1===t?e:e+t.toString()),n}loadPDB(e,t,s,i,n,l,r,o){let a,d,c=this.icn3d,h=c.icn3dui,p={},m=!1,u=e.split("\n"),g={},f={};c.atoms||(l=!1),n||l?(c.oriNStru=c.structures?Object.keys(c.structures).length:0,d=c.oriNStru+1,a=c.atoms?Object.keys(c.atoms).length:0):(c.init(),d=1,a=0);let b,C,y,v,w,_,S,A=[],x=[],k=[],O=[],R=[],E=[],I="",T="",M="",P={},D=t||c.defaultPdbId,H=D,F="",L=!1;for(let e in u){let r=u[e],o=r.substr(0,6);if("HEADER"!==o||L||t)if("TITLE "===o){let e=r.substr(10).replace(/ALPHAFOLD MONOMER V2.0 PREDICTION FOR /gi,"");c.molTitle+=e.trim()+" "}else if("HELIX "===o){c.bSecondaryStructure=!0;let e=""==r.substr(18,2).trim()?"A":r.substr(18,2).trim(),t=parseInt(r.substr(21,4)),s=parseInt(r.substr(33,4));for(let i=t;i<=s;++i){let n=H+"_"+e+"_"+i;O.push(n),i===t&&R.push(n),i===s&&E.push(n)}}else if("SHEET "===o){void 0!==s&&s||(c.bSecondaryStructure=!0);let e=""==r.substr(20,2).trim()?"A":r.substr(20,2).trim(),t=parseInt(r.substr(22,4)),i=parseInt(r.substr(33,4));for(let s=t;s<=i;++s){let n=H+"_"+e+"_"+s;A.push(n),s===t&&x.push(n),s===i&&k.push(n)}}else if("HBOND "===o)void 0!==s&&s||(c.bSecondaryStructure=!0);else if("SSBOND"===o){c.bSsbondProvided=!0;let e=D+"_"+(" "==r.substr(15,1)?"A":r.substr(15,1))+"_"+r.substr(17,4).trim(),t=D+"_"+(" "==r.substr(29,1)?"A":r.substr(29,1))+"_"+r.substr(31,4).trim();void 0===c.ssbondpnts[D]&&(c.ssbondpnts[D]=[]),c.ssbondpnts[D].push(e),c.ssbondpnts[D].push(t)}else if("REMARK"===o){let e=parseInt(r.substr(7,3));if(-1!==r.indexOf("1/2 of bilayer thickness:"))c.halfBilayerSize=parseFloat(r.substr(r.indexOf(":")+1).trim());else if(210==e)"EXPERIMENT TYPE"==r.substr(11,32).trim()&&"NMR"==r.substr(45).trim()&&(m=!0);else if(350==e&&"BIOMT"==r.substr(13,5)){let e=parseInt(r[18])-1,t=parseInt(r.substr(21,2))-1;null==c.biomtMatrices[t]&&(c.biomtMatrices[t]=(new THREE.Matrix4).identity()),c.biomtMatrices[t].elements[e]=parseFloat(r.substr(24,9)),c.biomtMatrices[t].elements[e+4]=parseFloat(r.substr(34,9)),c.biomtMatrices[t].elements[e+8]=parseFloat(r.substr(44,9)),c.biomtMatrices[t].elements[e+12]=parseFloat(r.substr(54,14))}else if(465==e&&" "==r.substr(18,1)&&" "==r.substr(20,1)&&"S"!=r.substr(21,1)){let e=r.substr(15,3),t=r.substr(18,2).trim(),s=r.substr(21,5).trim(),i=D+"_"+t;void 0===c.chainMissingResidueArray[i]&&(c.chainMissingResidueArray[i]=[]);let n={};n.resi=s,n.name=h.utilsCls.residueName2Abbr(e).toLowerCase(),""!=F&&t==F&&t!=F||(c.chainMissingResidueArray[i].push(n),F=t)}else 900==e&&void 0===c.emd&&"RELATED DB: EMDB"==r.substr(34).trim()&&(c.emd=r.substr(23,11).trim())}else if("SOURCE"===o&&void 0===c.organism&&"ORGANISM_COMMON"==r.substr(11,15).trim())c.organism=r.substr(28).toLowerCase().trim(),c.organism=c.organism.substr(0,c.organism.length-1);else if("ENDMDL"===o)++d,D=c.defaultPdbId,H=this.getStructureId(D,d,n),m||(A=[],x=[],k=[],O=[],R=[],E=[]),L=!1;else if("JRNL "===o)"PMID"===r.substr(12,4)&&(c.pmid=r.substr(19).trim());else if("ATOM "===o||"HETATM"===o){H=this.getStructureId(D,d,n);let e=r.substr(16,1);++a,P[parseInt(r.substr(6,5))]=a;let t=r.substr(76,2).trim();""===t&&(t=r.substr(12,2).trim());let l=r.substr(12,4).trim(),u=r.substr(17,3),F=r.substr(20,2).trim();""===F&&(F="A");let L=r.substr(22,5).trim(),N=L;if(s&&"DUM"===u&&(t=l,F="MEM",N=1,L=1),i&&"DUM"===u)break;b=H+"_"+F,y=b+"_"+L,C=b+"_"+N;let U=parseFloat(r.substr(30,8)),q=parseFloat(r.substr(38,8)),$=parseFloat(r.substr(46,8)),j=new THREE.Vector3(U,q,$),B={het:"H"===o[0],serial:a,name:l,alt:e,resn:u,structure:H,chain:F,resi:N,coord:j,b:parseFloat(r.substr(60,8)),elem:t,bonds:[],ss:"coil",ssbegin:!1,ssend:!1};if(B.het||"C"!==B.name||(v=a),B.het||"O"!==B.name||(_=a),!B.het&&"N"===B.name&&void 0!==w&&void 0!==S){let e=c.atoms[w].coord.distanceTo(c.atoms[S].coord),t=B.coord.x+(c.atoms[w].coord.x-c.atoms[S].coord.x)/e,s=B.coord.y+(c.atoms[w].coord.y-c.atoms[S].coord.y)/e,i=B.coord.z+(c.atoms[w].coord.z-c.atoms[S].coord.z)/e;B.hcoord=new THREE.Vector3(t,s,i)}c.atoms[a]=B,c.dAtoms[a]=1,c.hAtoms[a]=1,p[a]=1,this.isSecondary(C,A,m)?(c.atoms[a].ss="sheet",this.isSecondary(C,x,m)&&(c.atoms[a].ssbegin=!0),this.isSecondary(C,k,m)&&(c.atoms[a].ssend=!0)):this.isSecondary(C,O,m)&&(c.atoms[a].ss="helix",this.isSecondary(C,R,m)&&(c.atoms[a].ssbegin=!0),this.isSecondary(C,E,m)&&(c.atoms[a].ssend=!0));let z="-";if(z="helix"===c.atoms[a].ss?"H":"sheet"===c.atoms[a].ss?"E":!c.atoms[a].het&&h.parasCls.residueColors.hasOwnProperty(c.atoms[a].resn.toUpperCase())?"c":"o",c.secondaries[C]=z,y!==M){let e=h.utilsCls.residueName2Abbr(u);if(c.residueId2Name[C]=e,1!==a&&""!==T&&(c.residues[T]=f),C!==T&&(f={}),b!==I){w=void 0,S=void 0,1!==a&&""!==I&&(void 0===c.chains[I]&&(c.chains[I]={}),c.chains[I]=h.hashUtilsCls.unionHash(c.chains[I],g)),g={},void 0===c.structures[H.toString()]&&(c.structures[H.toString()]=[]),c.structures[H.toString()].includes(b)||c.structures[H.toString()].push(b),void 0===c.chainsSeq[b]&&(c.chainsSeq[b]=[]);let t={};t.resi=N,t.name=e,c.chainsSeq[b].push(t)}else{w=v,S=_;let t={};t.resi=N,t.name=e,c.chainsSeq[b].push(t)}}g[a]=1,f[a]=1,I=b,T=C,M=y}else if("CONECT"===o){let e=parseInt(r.substr(6,5));for(let t=0;t<4;++t){let s=parseInt(r.substr([11,16,21,26][t],5));isNaN(s)||void 0!==c.atoms[P[e]]&&c.atoms[P[e]].bonds.push(P[s])}}else"TER"===o.substr(0,3)&&++a;else D=r.substr(62).trim(),""==D&&(D=l?c.defaultPdbId:c.inputid&&-1==c.inputid.indexOf("/")?c.inputid.substr(0,10):c.defaultPdbId),H=this.getStructureId(D,d,n),c.molTitle="",L=!0}c.residues[C]=f,void 0===c.chains[b]&&(c.chains[b]={}),c.chains[b]=h.hashUtilsCls.unionHash2Atoms(c.chains[b],g,c.atoms),n||this.adjustSeq(c.chainMissingResidueArray);let N=Object.keys(c.structures);for(let e=0,t=N.length;e=l?n:l,o=new Array(s+i),a=0,d=0,c=0,h=!1;for(;ar&&i>r&&(h=!0),s<=r&&i>r?s>i||h?(o[c]=t[d],d++):(o[c]=e[a],a++):s>r&&i<=r?s<=i||h?(o[c]=e[a],a++):(o[c]=t[d],d++):s<=i?(o[c]=e[a],a++):(o[c]=t[d],d++),c++}if(a4||Math.abs(l.y-r.y)>4||Math.abs(l.z-r.z)>4||(l.x-r.x)*(l.x-r.x)+(l.y-r.y)*(l.y-r.y)+(l.z-r.z)*(l.z-r.z)<16&&(void 0===e.ssbondpnts[s]&&(e.ssbondpnts[s]=[]),e.ssbondpnts[s].push(o),e.ssbondpnts[s].push(a)))}}}getChainCalpha(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r={};for(let o in e){if(void 0!==i){if(o.split("_")[0]!==i)continue}let a=Object.keys(e[o]),d=[],c=0,h=0;for(let e=0,i=a.length;e3?i.resn.trim().substr(0,3):i.resn.trim();if(!l.parasCls.chargeColors.hasOwnProperty(e))continue;s?i.resi_ori:i.resi,d.push(i.coord.clone()),++c,h=i.resi}}if(c>0){r[t[a[0]].chain]=d}}return{chainresiCalphaHash:r,center:n.center.clone()}}isSecondary(e,t,s){if(this.icn3d.icn3dui,s){let s=e.substr(e.indexOf("_")+1),i=!1;for(let e=0,n=t.length;e0&&(d=!0);for(let n=0,l=t.length;na&&(a=l),s.push(l)}o.push(s)}if(!d)return void(n.bRender&&alert("These structures can not be aligned..."));a<1e-6&&(a=1);for(let e=0,s=t.length;ep[e]=4&&(n.rmsd_suprTmp=l.rmsdSuprCls.getRmsdSuprCls(c,a,p),void 0!==n.rmsd_suprTmp.rot))){let e=n.rmsd_suprTmp.rot;if(null===e[0])continue;let i=n.rmsd_suprTmp.trans1,r=n.rmsd_suprTmp.trans2,a=n.rmsd_suprTmp.rmsd;if(aRealignment RMSD: "+a.toPrecision(4)+" Å

    "),l.cfg.bSidebyside||l.htmlCls.dialogCls.openDlg("dl_rmsd","Realignment RMSD"),n.q_rotation=[],n.q_trans_sub=[],n.t_trans_add=[],n.q_rotation.push({x1:e[0],y1:e[1],z1:e[2],x2:e[3],y2:e[4],z2:e[5],x3:e[6],y3:e[7],z3:e[8]}),n.q_trans_sub.push(i),n.t_trans_add.push({x:-r.x,y:-r.y,z:-r.z}),l.cfg.aligntool="vast";//!= 'tmalign'; +var icn3d=function(e){"use strict";class t{constructor(e){this.icn3dui=e}cloneHash(e){this.icn3dui;let t={};void 0===e&&(e={});for(let s in e)t[s]=e[s];return t}intHash(e,t){this.icn3dui;let s={};if(void 0===e&&(e={}),void 0===t&&(t={}),Object.keys(e).length0||window.navigator.userAgent.match(/Trident.*rv\:11\./))}isMobile(){return this.icn3dui,/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)}isMac(){return this.icn3dui,/Mac/i.test(window.navigator.userAgent)}isAndroid(){return this.icn3dui,/android/i.test(window.navigator.userAgent.toLowerCase())}isChrome(){return this.icn3dui,navigator.userAgent.includes("Chrome")&&navigator.vendor.includes("Google Inc")}isSessionStorageSupported(){return this.icn3dui,window.sessionStorage}isLocalStorageSupported(){return this.icn3dui,window.localStorage}hexToRgb(e,t){this.icn3dui;let s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return s?{r:parseInt(s[1],16),g:parseInt(s[2],16),b:parseInt(s[3],16),a:t}:null}isCalphaPhosOnly(e){this.icn3dui;let t=!1,s=0,i=0;for(let t in e){if(!(s<100))break;{let s=e[t].name.trim();"CA"!==s&&"P"!==s&&"O3'"!==s&&"O3*"!==s&&++i}++s}return i<.5*s&&(t=!0),t}hasCovalentBond(e,t){let s=this.icn3dui,i=s.parasCls.covalentRadii[e.elem.toUpperCase()]+s.parasCls.covalentRadii[t.elem.toUpperCase()],n=e.coord.x-t.coord.x,l=e.coord.y-t.coord.y,r=e.coord.z-t.coord.z;return n*n+l*l+r*r<("N"==e.elem&&"H"==t.elem.substr(0,1)||"N"==t.elem&&"H"==e.elem.substr(0,1)?2.2:1.3)*i*i}residueName2Abbr(e){this.icn3dui;let t=e.indexOf(" ");switch(t>0&&(e=e.substr(0,t)),e){case" A":case" DA":case"DA":case"ALA":return"A";case" C":case" DC":case"DC":case"CYS":return"C";case" G":case" DG":case"DG":case"GLY":return"G";case" T":case" DT":case"DT":case"THR":return"T";case" U":case" DU":case"DU":case"SEC":return"U";case" I":case" DI":case"DI":case"ILE":return"I";case"ARG":return"R";case"ASN":return"N";case"ASP":return"D";case"GLU":return"E";case"GLN":return"Q";case"HIS":return"H";case"LEU":return"L";case"LYS":return"K";case"MET":return"M";case"PHE":return"F";case"PRO":return"P";case"SER":return"S";case"TRP":return"W";case"TYR":return"Y";case"VAL":return"V";case"HOH":case"WAT":return"O";default:return e.trim()}}residueAbbr2Name(e){if(this.icn3dui,(e=e.toUpperCase()).length>1)return e;switch(e){case"A":return"ALA";case"R":return"ARG";case"N":return"ASN";case"D":return"ASP";case"C":return"CYS";case"E":return"GLU";case"Q":return"GLN";case"G":return"GLY";case"H":return"HIS";case"I":return"ILE";case"L":return"LEU";case"K":return"LYS";case"M":return"MET";case"F":return"PHE";case"P":return"PRO";case"S":return"SER";case"T":return"THR";case"W":return"TRP";case"Y":return"TYR";case"V":return"VAL";case"O":return"HOH";default:return e.trim()}}getJSONFromArray(e){this.icn3dui;let t="";for(let s=0,i=e.length;sd?1:ah?1:cs&&(e.htmlCls.WIDTH=s),i&&e.htmlCls.HEIGHT>i&&(e.htmlCls.HEIGHT=i)}sumArray(e){let t=0;for(let s=0,i=e.length;sRed and blue membranes indicate extracellular and intracellular membranes, respectively.

    "}}class i{constructor(e){this.icn3dui=e,this.glycanHash={GLC:{c:"1E90FF",s:"sphere"},BGC:{c:"1E90FF",s:"sphere"},NAG:{c:"1E90FF",s:"cube"},NDG:{c:"1E90FF",s:"cube"},GCS:{c:"1E90FF",s:"cube"},PA1:{c:"1E90FF",s:"cube"},GCU:{c:"1E90FF",s:"cone"},BDP:{c:"1E90FF",s:"cone"},G6D:{c:"1E90FF",s:"cone"},DDA:{c:"1E90FF",s:"cylinder"},B6D:{c:"1E90FF",s:"cylinder"},XXM:{c:"1E90FF",s:"cylinder"},MAN:{c:"00FF00",s:"sphere"},BMA:{c:"00FF00",s:"sphere"},BM3:{c:"00FF00",s:"cube"},"95Z":{c:"00FF00",s:"cube"},MAV:{c:"00FF00",s:"cone"},BEM:{c:"00FF00",s:"cone"},RAM:{c:"00FF00",s:"cone"},RM4:{c:"00FF00",s:"cone"},TYV:{c:"00FF00",s:"cylinder"},ARA:{c:"00FF00",s:"cylinder"},ARB:{c:"00FF00",s:"cylinder"},KDN:{c:"00FF00",s:"cylinder"},KDM:{c:"00FF00",s:"cylinder"},"6PZ":{c:"00FF00",s:"cylinder"},GMH:{c:"00FF00",s:"cylinder"},BDF:{c:"00FF00",s:"cylinder"},GAL:{c:"FFFF00",s:"sphere"},GLA:{c:"FFFF00",s:"sphere"},NGA:{c:"FFFF00",s:"cube"},A2G:{c:"FFFF00",s:"cube"},X6X:{c:"FFFF00",s:"cube"},"1GN":{c:"FFFF00",s:"cube"},ADA:{c:"FFFF00",s:"cone"},GTR:{c:"FFFF00",s:"cone"},LDY:{c:"FFFF00",s:"cylinder"},KDO:{c:"FFFF00",s:"cylinder"},T6T:{c:"FFFF00",s:"cylinder"},GUP:{c:"A52A2A",s:"sphere"},GL0:{c:"A52A2A",s:"sphere"},LGU:{c:"A52A2A",s:"cone"},ABE:{c:"A52A2A",s:"cylinder"},XYS:{c:"A52A2A",s:"cylinder"},XYP:{c:"A52A2A",s:"cylinder"},SOE:{c:"A52A2A",s:"cylinder"},PZU:{c:"FF69B4",s:"cylinder"},RIP:{c:"FF69B4",s:"cylinder"},"0MK":{c:"FF69B4",s:"cylinder"},ALL:{c:"8A2BE2",s:"sphere"},AFD:{c:"8A2BE2",s:"sphere"},NAA:{c:"8A2BE2",s:"cube"},SIA:{c:"8A2BE2",s:"cylinder"},SIB:{c:"8A2BE2",s:"cylinder"},AMU:{c:"8A2BE2",s:"cylinder"},X0X:{c:"1E90FF",s:"cone"},X1X:{c:"1E90FF",s:"cone"},NGC:{c:"1E90FF",s:"cylinder"},NGE:{c:"1E90FF",s:"cylinder"},"4N2":{c:"A0522D",s:"sphere"},HSQ:{c:"A0522D",s:"cube"},IDR:{c:"A0522D",s:"cone"},MUR:{c:"A0522D",s:"cylinder"},FUC:{c:"FF0000",s:"cone"},FUL:{c:"FF0000",s:"cone"}},this.nucleotidesArray=[" G"," A"," T"," C"," U"," DG"," DA"," DT"," DC"," DU","G","A","T","C","U","DG","DA","DT","DC","DU"],this.ionsArray=[" K"," NA"," MG"," AL"," CA"," TI"," MN"," FE"," NI"," CU"," ZN"," AG"," BA"," F"," CL"," BR"," I","K","NA","MG","AL","CA","TI","MN","FE","NI","CU","ZN","AG","BA","F","CL","BR","I"],this.cationsTrimArray=["K","NA","MG","AL","CA","TI","MN","FE","NI","CU","ZN","AG","BA"],this.anionsTrimArray=["F","CL","BR","I"],this.ionCharges={K:1,NA:1,MG:2,AL:3,CA:2,TI:3,MN:2,FE:3,NI:2,CU:2,ZN:2,AG:1,BA:2},this.vdwRadii={H:1.08,HE:1.34,LI:1.75,BE:2.05,B:1.47,C:1.49,N:1.41,O:1.4,F:1.39,NE:1.68,NA:1.84,MG:2.05,AL:2.11,SI:2.07,P:1.92,S:1.82,CL:1.83,AR:1.93,K:2.05,CA:2.21,SC:2.16,TI:1.87,V:1.79,CR:1.89,MN:1.97,FE:1.94,CO:1.92,NI:1.84,CU:1.86,ZN:2.1,GA:2.08,GE:2.15,AS:2.06,SE:1.93,BR:1.98,KR:2.12,RB:2.16,SR:2.24,Y:2.19,ZR:1.86,NB:2.07,MO:2.09,TC:2.09,RU:2.07,RH:1.95,PD:2.02,AG:2.03,CD:2.3,IN:2.36,SN:2.33,SB:2.25,TE:2.23,I:2.23,XE:2.21,CS:2.22,BA:2.51,LA:2.4,CE:2.35,PR:2.39,ND:2.29,PM:2.36,SM:2.29,EU:2.33,GD:2.37,TB:2.21,DY:2.29,HO:2.16,ER:2.35,TM:2.27,YB:2.42,LU:2.21,HF:2.12,TA:2.17,W:2.1,RE:2.17,OS:2.16,IR:2.02,PT:2.09,AU:2.17,HG:2.09,TL:2.35,PB:2.32,BI:2.43,PO:2.29,AT:2.36,RN:2.43,FR:2.56,RA:2.43,AC:2.6,TH:2.37,PA:2.43,U:2.4,NP:2.21,PU:2.56,AM:2.56,CM:2.56,BK:2.56,CF:2.56,ES:2.56,FM:2.56},this.covalentRadii={H:.31,HE:.28,LI:1.28,BE:.96,B:.84,C:.76,N:.71,O:.66,F:.57,NE:.58,NA:1.66,MG:1.41,AL:1.21,SI:1.11,P:1.07,S:1.05,CL:1.02,AR:1.06,K:2.03,CA:1.76,SC:1.7,TI:1.6,V:1.53,CR:1.39,MN:1.39,FE:1.32,CO:1.26,NI:1.24,CU:1.32,ZN:1.22,GA:1.22,GE:1.2,AS:1.19,SE:1.2,BR:1.2,KR:1.16,RB:2.2,SR:1.95,Y:1.9,ZR:1.75,NB:1.64,MO:1.54,TC:1.47,RU:1.46,RH:1.42,PD:1.39,AG:1.45,CD:1.44,IN:1.42,SN:1.39,SB:1.39,TE:1.38,I:1.39,XE:1.4,CS:2.44,BA:2.15,LA:2.07,CE:2.04,PR:2.03,ND:2.01,PM:1.99,SM:1.98,EU:1.98,GD:1.96,TB:1.94,DY:1.92,HO:1.92,ER:1.89,TM:1.9,YB:1.87,LU:1.87,HF:1.75,TA:1.7,W:1.62,RE:1.51,OS:1.44,IR:1.41,PT:1.36,AU:1.36,HG:1.32,TL:1.45,PB:1.46,BI:1.48,PO:1.4,AT:1.5,RN:1.5,FR:2.6,RA:2.21,AC:2.15,TH:2.06,PA:2,U:1.96,NP:1.9,PU:1.87,AM:1.8,CM:1.69},this.atomColors={H:this.thr(16777215),He:this.thr(16761035),HE:this.thr(16761035),Li:this.thr(11674146),LI:this.thr(11674146),B:this.thr(65280),C:this.thr(11184810),N:this.thr(255),O:this.thr(15728640),F:this.thr(14329120),Na:this.thr(255),NA:this.thr(255),Mg:this.thr(2263842),MG:this.thr(2263842),Al:this.thr(8421520),AL:this.thr(8421520),Si:this.thr(14329120),SI:this.thr(14329120),P:this.thr(16753920),S:this.thr(16762930),Cl:this.thr(65280),CL:this.thr(65280),Ca:this.thr(8421520),CA:this.thr(8421520),Ti:this.thr(8421520),TI:this.thr(8421520),Cr:this.thr(8421520),CR:this.thr(8421520),Mn:this.thr(8421520),MN:this.thr(8421520),Fe:this.thr(16753920),FE:this.thr(16753920),Ni:this.thr(10824234),NI:this.thr(10824234),Cu:this.thr(10824234),CU:this.thr(10824234),Zn:this.thr(10824234),ZN:this.thr(10824234),Br:this.thr(10824234),BR:this.thr(10824234),Ag:this.thr(8421520),AG:this.thr(8421520),I:this.thr(10494192),Ba:this.thr(16753920),BA:this.thr(16753920),Au:this.thr(14329120),AU:this.thr(14329120)},this.atomnames={H:"Hydrogen",HE:"Helium",LI:"Lithium",B:"Boron",C:"Carbon",N:"Nitrogen",O:"Oxygen",F:"Fluorine",NA:"Sodium",MG:"Magnesium",AL:"Aluminum",SI:"Silicon",P:"Phosphorus",S:"Sulfur",CL:"Chlorine",CA:"Calcium",TI:"Titanium",CR:"Chromium",MN:"Manganese",FE:"Iron",NI:"Nickel",CU:"Copper",ZN:"Zinc",BR:"Bromine",AG:"Silver",I:"Iodine",BA:"Barium",AU:"Gold"},this.defaultAtomColor=this.thr(13421772),this.stdChainColors=[this.thr(16711935),this.thr(255),this.thr(10053171),this.thr(65433),this.thr(16750848),this.thr(16737894),this.thr(3329330),this.thr(2003199),this.thr(16416882),this.thr(16753920),this.thr(52945),this.thr(16738740),this.thr(65280),this.thr(255),this.thr(16711680),this.thr(16776960),this.thr(65535),this.thr(16711935),this.thr(3978097),this.thr(4620980),this.thr(13458524),this.thr(16770229),this.thr(11529966),this.thr(15631086),this.thr(25600),this.thr(139),this.thr(9109504),this.thr(13468991),this.thr(35723),this.thr(9699539)],this.backgroundColors={black:this.thr(0),grey:this.thr(13421772),white:this.thr(16777215),transparent:this.thr(16777215)},this.residueColors={ALA:this.thr(13158600),ARG:this.thr(1334015),ASN:this.thr(56540),ASP:this.thr(15075850),CYS:this.thr(15132160),GLN:this.thr(56540),GLU:this.thr(15075850),GLY:this.thr(15461355),HIS:this.thr(8553170),ILE:this.thr(1016335),LEU:this.thr(1016335),LYS:this.thr(1334015),MET:this.thr(15132160),PHE:this.thr(3289770),PRO:this.thr(14456450),SER:this.thr(16422400),THR:this.thr(16422400),TRP:this.thr(11819700),TYR:this.thr(3289770),VAL:this.thr(1016335),ASX:this.thr(16738740),GLX:this.thr(16738740),G:this.thr(32768),A:this.thr(6324479),T:this.thr(16744448),C:this.thr(16711680),U:this.thr(16744448),DG:this.thr(32768),DA:this.thr(6324479),DT:this.thr(16744448),DC:this.thr(16711680),DU:this.thr(16744448)},this.residueArea={ALA:247,ARG:366,ASN:290,ASP:285,CYS:271,GLN:336,GLU:325,GLY:217,HIS:340,ILE:324,LEU:328,LYS:373,MET:346,PHE:366,PRO:285,SER:265,THR:288,TRP:414,TYR:387,VAL:293,ASX:290,GLX:336,G:520,A:507,T:515,C:467,U:482,DG:520,DA:507,DT:515,DC:467,DU:482},this.defaultResidueColor=this.thr(12492910),this.chargeColors={" G":this.thr(16711680)," A":this.thr(16711680)," T":this.thr(16711680)," C":this.thr(16711680)," U":this.thr(16711680)," DG":this.thr(16711680)," DA":this.thr(16711680)," DT":this.thr(16711680)," DC":this.thr(16711680)," DU":this.thr(16711680),G:this.thr(16711680),A:this.thr(16711680),T:this.thr(16711680),C:this.thr(16711680),U:this.thr(16711680),DG:this.thr(16711680),DA:this.thr(16711680),DT:this.thr(16711680),DC:this.thr(16711680),DU:this.thr(16711680),ARG:this.thr(255),LYS:this.thr(255),ASP:this.thr(16711680),GLU:this.thr(16711680),HIS:this.thr(8421631),GLY:this.thr(8947848),PRO:this.thr(8947848),ALA:this.thr(8947848),VAL:this.thr(8947848),LEU:this.thr(8947848),ILE:this.thr(8947848),PHE:this.thr(8947848),SER:this.thr(8947848),THR:this.thr(8947848),ASN:this.thr(8947848),GLN:this.thr(8947848),TYR:this.thr(8947848),MET:this.thr(8947848),CYS:this.thr(8947848),TRP:this.thr(8947848)},this.hydrophobicColors={" G":this.thr(16711680)," A":this.thr(16711680)," T":this.thr(16711680)," C":this.thr(16711680)," U":this.thr(16711680)," DG":this.thr(16711680)," DA":this.thr(16711680)," DT":this.thr(16711680)," DC":this.thr(16711680)," DU":this.thr(16711680),G:this.thr(16711680),A:this.thr(16711680),T:this.thr(16711680),C:this.thr(16711680),U:this.thr(16711680),DG:this.thr(16711680),DA:this.thr(16711680),DT:this.thr(16711680),DC:this.thr(16711680),DU:this.thr(16711680),ARG:this.thr(255),LYS:this.thr(255),ASP:this.thr(16711680),GLU:this.thr(16711680),HIS:this.thr(8421631),TRP:this.thr().setHSL(1/3,1,.5),PHE:this.thr().setHSL(1/3,1,.6945945945945946),TYR:this.thr().setHSL(1/3,1,.745945945945946),LEU:this.thr().setHSL(1/3,1,.5+.645/1.85),ILE:this.thr().setHSL(1/3,1,.5+.77/1.85),CYS:this.thr().setHSL(1/3,1,.5+.805/1.85),MET:this.thr().setHSL(1/3,1,.5+.81/1.85),GLY:this.thr().setHSL(1/6,1,.5+.285/.58),VAL:this.thr().setHSL(1/6,1,.5+.255/.58),SER:this.thr().setHSL(1/6,1,.8879310344827587),THR:this.thr().setHSL(1/6,1,.8793103448275862),ALA:this.thr().setHSL(1/6,1,.853448275862069),ASN:this.thr().setHSL(1/6,1,.6379310344827587),PRO:this.thr().setHSL(1/6,1,.6120689655172413),GLN:this.thr().setHSL(1/6,1,.5)},this.normalizedHPColors={" G":this.thr(16777215)," A":this.thr(16777215)," T":this.thr(16777215)," C":this.thr(16777215)," U":this.thr(16777215)," DG":this.thr(16777215)," DA":this.thr(16777215)," DT":this.thr(16777215)," DC":this.thr(16777215)," DU":this.thr(16777215),G:this.thr(16777215),A:this.thr(16777215),T:this.thr(16777215),C:this.thr(16777215),U:this.thr(16777215),DG:this.thr(16777215),DA:this.thr(16777215),DT:this.thr(16777215),DC:this.thr(16777215),DU:this.thr(16777215),ARG:this.thr(16777215),LYS:this.thr(16777215),ASP:this.thr(16777215),GLU:this.thr(16777215),HIS:this.thr(16777215),TRP:this.thr().setHSL(1/3,1,.5),PHE:this.thr().setHSL(1/3,1,.644),TYR:this.thr().setHSL(1/3,1,.682),LEU:this.thr().setHSL(1/3,1,.758),ILE:this.thr().setHSL(1/3,1,.808),CYS:this.thr().setHSL(1/3,1,.5+.322),MET:this.thr().setHSL(1/3,1,.5+.324),GLY:this.thr().setHSL(1/3,1,.872),VAL:this.thr().setHSL(1/3,1,.884),SER:this.thr().setHSL(1/3,1,.896),THR:this.thr().setHSL(1/3,1,.898),ALA:this.thr().setHSL(1/3,1,.904),ASN:this.thr().setHSL(1/3,1,.954),PRO:this.thr().setHSL(1/3,1,.9600000000000001),GLN:this.thr().setHSL(1/3,1,.986)},this.hydrophobicValues={" G":3," A":3," T":3," C":3," U":3," DG":3," DA":3," DT":3," DC":3," DU":3,G:3,A:3,T:3,C:3,U:3,DG:3,DA:3,DT:3,DC:3,DU:3,ARG:1,LYS:1,ASP:3,GLU:3,HIS:2,TRP:-1.85,PHE:-1.13,TYR:-.94,LEU:-.56,ILE:-.31,CYS:-.24,MET:-.23,GLY:.01,VAL:.07,SER:.13,THR:.14,ALA:.17,ASN:.42,PRO:.45,GLN:.58},this.residueAbbrev={ALA:"A (Ala)",ARG:"R (Arg)",ASN:"N (Asn)",ASP:"D (Asp)",CYS:"C (Cys)",GLN:"Q (Gln)",GLU:"E (Glu)",GLY:"G (Gly)",HIS:"H (His)",ILE:"I (Ile)",LEU:"L (Leu)",LYS:"K (Lys)",MET:"M (Met)",PHE:"F (Phe)",PRO:"P (Pro)",SER:"S (Ser)",THR:"T (Thr)",TRP:"W (Trp)",TYR:"Y (Tyr)",VAL:"V (Val)",ASX:"X (Asx)",GLX:"X (Glx)",G:"Guanine",A:"Adenine",T:"Thymine",C:"Cytosine",U:"Uracil",DG:"deoxy-Guanine",DA:"deoxy-Adenine",DT:"deoxy-Thymine",DC:"deoxy-Cytosine",DU:"deoxy-Uracil"},this.ssColors={helix:this.thr(16711680),sheet:this.thr(32768),coil:this.thr(6324479)},this.ssColors2={helix:this.thr(16711680),sheet:this.thr(16762880),coil:this.thr(6324479)},this.resn2restype={ALA:1,ARG:4,ASN:7,ASP:10,CYS:13,GLN:16,GLU:19,GLY:22,HIS:25,ILE:28,LEU:31,LYS:34,MET:37,PHE:40,PRO:43,SER:46,THR:49,TRP:52,TYR:55,VAL:58},this.nuclMainArray=["C1'","C1*","C2'","C2*","C3'","C3*","C4'","C4*","C5'","C5*","O3'","O3*","O4'","O4*","O5'","O5*","P","OP1","O1P","OP2","O2P"],this.b62ResArray=["A","R","N","D","C","Q","E","G","H","I","L","K","M","F","P","S","T","W","Y","V","B","Z","X","*"],this.b62Matrix=[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0,-4],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1,-4],[-2,0,6,1,-3,0,0,0,1,-3,-3,0,-2,-3,-2,1,0,-4,-2,-3,3,0,-1,-4],[-2,-2,1,6,-3,0,2,-1,-1,-3,-4,-1,-3,-3,-1,0,-1,-4,-3,-3,4,1,-1,-4],[0,-3,-3,-3,9,-3,-4,-3,-3,-1,-1,-3,-1,-2,-3,-1,-1,-2,-2,-1,-3,-3,-2,-4],[-1,1,0,0,-3,5,2,-2,0,-3,-2,1,0,-3,-1,0,-1,-2,-1,-2,0,3,-1,-4],[-1,0,0,2,-4,2,5,-2,0,-3,-3,1,-2,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-2,0,-1,-3,-2,-2,6,-2,-4,-4,-2,-3,-3,-2,0,-2,-2,-3,-3,-1,-2,-1,-4],[-2,0,1,-1,-3,0,0,-2,8,-3,-3,-1,-2,-1,-2,-1,-2,-2,2,-3,0,0,-1,-4],[-1,-3,-3,-3,-1,-3,-3,-4,-3,4,2,-3,1,0,-3,-2,-1,-3,-1,3,-3,-3,-1,-4],[-1,-2,-3,-4,-1,-2,-3,-4,-3,2,4,-2,2,0,-3,-2,-1,-2,-1,1,-4,-3,-1,-4],[-1,2,0,-1,-3,1,1,-2,-1,-3,-2,5,-1,-3,-1,0,-1,-3,-2,-2,0,1,-1,-4],[-1,-1,-2,-3,-1,0,-2,-3,-2,1,2,-1,5,0,-2,-1,-1,-1,-1,1,-3,-1,-1,-4],[-2,-3,-3,-3,-2,-3,-3,-3,-1,0,0,-3,0,6,-4,-2,-2,1,3,-1,-3,-3,-1,-4],[-1,-2,-2,-1,-3,-1,-1,-2,-2,-3,-3,-1,-2,-4,7,-1,-1,-4,-3,-2,-2,-1,-2,-4],[1,-1,1,0,-1,0,0,0,-1,-2,-2,0,-1,-2,-1,4,1,-3,-2,-2,0,0,0,-4],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,1,5,-2,-2,0,-1,-1,0,-4],[-3,-3,-4,-4,-2,-2,-3,-2,-2,-3,-2,-3,-1,1,-4,-3,-2,11,2,-3,-4,-3,-2,-4],[-2,-2,-2,-3,-2,-1,-2,-3,2,-1,-1,-2,-1,3,-3,-2,-2,2,7,-1,-3,-2,-1,-4],[0,-3,-3,-3,-1,-2,-2,-3,-3,3,1,-2,1,-1,-2,-2,0,-3,-1,4,-3,-2,-1,-4],[-2,-1,3,4,-3,0,1,-1,0,-3,-4,0,-3,-3,-2,0,-1,-4,-3,-3,4,1,-1,-4],[-1,0,0,1,-3,3,4,-2,0,-3,-3,1,-1,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,0,0,-2,-1,-1,-1,-1,-1,-4],[-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,1]]}thr(e){return this.icn3dui,"#0"==e&&(e="#000"),new THREE.Color(e)}}class n{constructor(e){this.icn3dui=e}onId(e,t,s){if(this.icn3dui,!(Object.keys(window).length<2)&&("#"==e.substr(0,1)&&(e=e.substr(1)),document.getElementById(e))){t.split(" ").forEach((t=>{document.getElementById(e).addEventListener(t,s)}))}}onIds(e,t,s){let i=this.icn3dui;Array.isArray(e)?e.forEach((e=>{i.myEventCls.onId(e,t,s)})):i.myEventCls.onId(e,t,s)}}class l{constructor(e){this.icn3dui=e}getRmsdSuprCls(e,t,s){let i,n,l,r,o,a,d,c,h,p,m,u,g,f=this.icn3dui,b=new Array(9),C=new THREE.Vector3,y=new THREE.Vector3,v=[],w=[],_=new Array(3),S=new Array(3),A=new Array(3),x=new Array(3),k=new Array(3),O=new Array(3);if(i=0,s<=1)return{rot:void 0,trans1:void 0,trans2:void 0,rmsd:999};let R=s;for(n=0;n0?(b[0]=x[0]*_[0]+k[0]*S[0]+O[0]*A[0],b[1]=x[0]*_[1]+k[0]*S[1]+O[0]*A[1],b[2]=x[0]*_[2]+k[0]*S[2]+O[0]*A[2],b[3]=x[1]*_[0]+k[1]*S[0]+O[1]*A[0],b[4]=x[1]*_[1]+k[1]*S[1]+O[1]*A[1],b[5]=x[1]*_[2]+k[1]*S[2]+O[1]*A[2],b[6]=x[2]*_[0]+k[2]*S[0]+O[2]*A[0],b[7]=x[2]*_[1]+k[2]*S[1]+O[2]*A[1],b[8]=x[2]*_[2]+k[2]*S[2]+O[2]*A[2]):(b[0]=x[0]*_[0]+k[0]*S[0]-O[0]*A[0],b[1]=x[0]*_[1]+k[0]*S[1]-O[0]*A[1],b[2]=x[0]*_[2]+k[0]*S[2]-O[0]*A[2],b[3]=x[1]*_[0]+k[1]*S[0]-O[1]*A[0],b[4]=x[1]*_[1]+k[1]*S[1]-O[1]*A[1],b[5]=x[1]*_[2]+k[1]*S[2]-O[1]*A[2],b[6]=x[2]*_[0]+k[2]*S[0]-O[2]*A[0],b[7]=x[2]*_[1]+k[2]*S[1]-O[2]*A[1],b[8]=x[2]*_[2]+k[2]*S[2]-O[2]*A[2]),c=Math.sqrt(c),h=Math.sqrt(h),p=Math.sqrt(p),g=c+h+u*p,m=a+d-2*g,i=m>0?Math.sqrt(m):void 0,{rot:b,trans1:E,trans2:I,rmsd:i})}eigen_values(e){let t,s,i,n,l,r,o,a,d,c,h,p,m,u,g,f,b,C,y,v;if(this.icn3dui,t=e[0],s=e[1],i=e[2],n=e[3],l=e[4],r=e[5],o=e[6],a=e[7],d=e[8],c=-(t+l+d),h=t*l+(t+l)*d-r*a-s*n-i*o,p=-t*l*d+t*r*a+s*n*d-s*r*o-i*n*a+i*l*o,m=-c*c/3+h,u=c*c*c/13.5-c*h/3+p,g=.25*u*u+m*m*m/27,g<0){let e,t;e=Math.sqrt(.25*u*u-g),t=Math.acos(-.5*u/e),C=2*Math.cbrt(e)*Math.cos(t/3)}else f=Math.cbrt(-.5*u+Math.sqrt(g)),b=Math.cbrt(-.5*u-Math.sqrt(g)),C=f+b;return C-=c/3,c+=C,p/=-C,y=.5*(-c+Math.sqrt(c*c-4*p)),v=.5*(-c-Math.sqrt(c*c-4*p)),y_&&(_=Math.abs(d)),Math.abs(c)>_&&(_=Math.abs(c)),Math.abs(h)>_&&(_=Math.abs(h)),Math.abs(p)>_&&(_=Math.abs(p)),Math.abs(m)>_&&(_=Math.abs(m)),Math.abs(u)>_&&(_=Math.abs(u)),Math.abs(g)>_&&(_=Math.abs(g)),Math.abs(f)>_&&(_=Math.abs(f)),_<1e-10)return r=3,{k:r,v1:t,v2:s,v3:i};if(o=0,a/=_,d/=_,c/=_,h/=_,p/=_,m/=_,u/=_,g/=_,f/=_,Math.abs(a)_&&(w=a,a=h,h=w,w=d,d=p,p=w,w=c,c=m,m=w,_=Math.abs(d)),Math.abs(g)>_&&(w=a,a=u,u=w,w=d,d=g,g=w,w=c,c=f,f=w),y=m-p*c/d,v=f-g*c/d,Math.abs(y)_&&(w=a,a=h,h=w,w=d,d=p,p=w,w=c,c=m,m=w,_=Math.abs(a)),Math.abs(c)>_&&(w=a,a=u,u=w,w=d,d=g,g=w,w=c,c=f,f=w),b=p-h*d/a,C=m-h*c/a,y=g-u*d/a,v=f-u*c/a,Math.abs(b)0&&(1==o?(a=s[0],d=s[1],c=s[2],w=Math.sqrt(a*a+d*d+c*c),s[0]=a/w,s[1]=d/w,s[2]=c/w):2==o?(a=t[0],d=t[1],c=t[2],h=s[0],p=s[1],m=s[2],w=a*h+d*p+c*m,Math.abs(w)>=n&&(s[0]=a+w*h,s[1]=d+w*p,s[2]=c+w*m,h=s[0],p=s[1],m=s[2]),w=Math.sqrt(a*a+d*d+c*c),t[0]=a/w,t[1]=d/w,t[2]=c/w,w=Math.sqrt(h*h+p*p+m*m),s[0]=h/w,s[1]=p/w,s[2]=m/w):(a=t[0],d=t[1],c=t[2],w=Math.sqrt(a*a+d*d+c*c),t[0]=a/w,t[1]=d/w,t[2]=c/w)),{k:r,v1:t,v2:s,v3:i}}getEigenForSelection(e,t){let s,i=this.icn3dui,n=new THREE.Vector3,l=[];for(s=0;s0&&Math.abs(l[0].x-e[0].x)<=6&&Math.abs(l[0].y-e[0].y)<=6&&Math.abs(l[0].z-e[0].z)<=6?(p.push(l[0]),m=1):m=0,p.push(e[0]);for(let t=1,s=e.length-1;t0&&Math.abs(r[0].x-e[e.length-1].x)<=6&&Math.abs(r[0].y-e[e.length-1].y)<=6&&Math.abs(r[0].z-e[e.length-1].z)<=6&&(p.push(r[0]),++g),u>1&&Math.abs(r[0].x-r[1].x)<=6&&Math.abs(r[0].y-r[1].y)<=6&&Math.abs(r[0].z-r[1].z)<=6&&(p.push(r[1]),++g);let f=[],b=[],C=[];o&&(g=u>0?u-1:0);let y;for(let e=-1,n=p.length,l=1/s;e<=n-3;++e){y=e-m;let r=p[-1===e?0:e],o=p[e+1],u=p[e+2],v=p[e===n-3?n-1:e+3],w=0,_=a.subdivideCls.getKnot(1,w,r,o),S=a.subdivideCls.getKnot(1,_,o,u),A=a.subdivideCls.getKnot(1,S,u,v);_-w<1e-4&&(_=w+1),S-_<1e-4&&(S=_+1),A-S<1e-4&&(A=S+1),e>-1&&(void 0===i||i[y+1])&&e>=-1+m&&e<=n-3-g+1&&(d=d.concat(f),c=c.concat(b),h=h.concat(C)),f=[],b=[],C=[];let x=(S-_)*l;for(let l=0;l=-1+m&&e<=n-3-g&&i[y+1]&&l<=parseInt(s/2)&&(d.push(new THREE.Vector3(k,O,R)),c.push(i[y+1]),h.push(t[y+1])),e>=-1+m&&e<=n-3-g+1&&i[y+2]&&l>parseInt(s/2)&&(f.push(new THREE.Vector3(k,O,R)),b.push(i[y+2]),C.push(t[y+2]))):e>=-1+m&&e<=n-3-g&&(d.push(new THREE.Vector3(k,O,R)),c.push(y+1),h.push(t[y+1]))}}i&&!i[y+1]||(d=d.concat(f),c=c.concat(b),h=h.concat(C),d.push(p[p.length-1-g]),c.push(p.length-1-g),h.push(t[p.length-1-g])),f=[],b=[],C=[],p=[];let v=[];return v.push(d),v.push(c),v.push(h),v}getKnot(e,t,s,i){return this.icn3dui,s.distanceTo(i)+t}getValueFromKnot(e,t,s,i,n,l,r,o,a){this.icn3dui;let d,c,h=(r-l)/(s-t),p=(o-r)/(i-s),m=(a-o)/(n-i),u=(s+i)*(s+i)-4*(t*s+i*n-t*n);return 0==u?(d=9999,c=9999):(d=6*(3*p*s+2*h*n+m*s-2*h*s-2*p*n-p*i-m*s)/u,c=6*(3*p*i+2*m*t+h*s-2*p*t-2*m*i-h*i-p*s)/u),p*(e-s)+r+((2*d+c)/6/(s-i)*(e-s)*(e-i)*(e-i)+(2*c+d)/6/(i-s)*(e-s)*(e-s)*(e-i))}}class o{constructor(e){this.icn3dui=e}passFloat32(e,t){let s=this.icn3dui,i=e.length;t||(t=new Uint8Array(4*i));let n=s.convertTypeCls.getDataView(t);for(let t=0;t  Very high (pLDDT > 90)
      Confident (90 > pLDDT > 70)
      Low (70 > pLDDT > 50)
      Very low (pLDDT < 50)
    '}setLegendHtml(e){let t=this.icn3dui.icn3d,s="
    ";if(e)s+=this.setAlphaFoldLegend();else{s+="
    "+t.startValue+""+t.midValue+""+t.endValue+"
    "}return s}SetChainsAdvancedMenu(){let e=this.icn3dui,t=e.icn3d;if(void 0===t.bSetChainsAdvancedMenu||!t.bSetChainsAdvancedMenu){let s=e.hashUtilsCls.cloneHash(t.hAtoms);t.definedSetsCls.setPredefinedInMenu(),t.bSetChainsAdvancedMenu=!0,t.hAtoms=e.hashUtilsCls.cloneHash(s)}}setSetsMenus(e,t){let s=this.icn3dui,i=s.icn3d;this.SetChainsAdvancedMenu();let n=e,l=e+"2",r=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+s.pre+n).length&&$("#"+s.pre+n).html(" "+r),!t&&$("#"+s.pre+l).length&&$("#"+s.pre+l).html(" "+r),$("#"+s.pre+n).resizable(),t||$("#"+s.pre+l).resizable()}applyShownMenus(){let e=this.icn3dui;e.icn3d;let t=[];for(let s in e.htmlCls.allMenus)e.htmlCls.shownMenus.hasOwnProperty(s)?$("#"+e.pre+s).parent().show():($("#"+e.pre+s).parent().hide(),t.push(s));Object.keys(e.htmlCls.shownMenus).length==Object.keys(e.htmlCls.allMenus).length?$(".icn3d-menusep").show():$(".icn3d-menusep").hide(),localStorage&&localStorage.setItem("hiddenmenus",JSON.stringify(t))}getHiddenMenusFromCache(){let e=this.icn3dui;e.icn3d,e.htmlCls.shownMenus={};let t=localStorage?localStorage.getItem("hiddenmenus"):"";if(t&&"[]"!=t){let s=JSON.parse(t);for(let t in e.htmlCls.allMenus)-1==s.indexOf(t)&&(e.htmlCls.shownMenus[t]=1)}else e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.allMenus)}displayShownMenus(){let e=this.icn3dui;e.icn3d;let t="
    ";t+="",t+="";for(let s in e.htmlCls.allMenusSel){if("uniclr"==s.substr(0,6)||"mn5_opacity"==s.substr(0,11)||"mn6_labelscale"==s.substr(0,14)||"faq_"==s.substr(0,4)||"dev_"==s.substr(0,4))continue;"mn1_searchstru"==s?t+="
    FileSelectViewStyleColorAnalysisHelp
    ":("mn2_definedsets"==s||"mn2_show_selected"==s||"mn3_proteinwrap"==s||e.cfg.cid&&"mn3_ligwrap"==s||"mn4_clrwrap"==s||"mn6_selectannotations"==s||"abouticn3d"==s)&&(t+="");let i=e.htmlCls.shownMenus.hasOwnProperty(s)?"checked":"",n=e.htmlCls.allMenusSel[s];t+=""+e.htmlCls.allMenus[s]+"
    "}t+="
    ",$("#"+e.pre+"menulist").html(t)}clickMenu1(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds("#"+e.pre+"mn1_vastplus","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_vastplus","Please input PDB ID for VAST+")})),e.myEventCls.onIds("#"+e.pre+"mn1_vast","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_vast","Please input chain or PDB file for VAST")})),e.myEventCls.onIds("#"+e.pre+"mn1_foldseek","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_foldseek","Submit your selection to Foldseek")})),e.myEventCls.onIds("#"+e.pre+"mn1_mmtfid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmtfid","Please input MMTF ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_pdbid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pdbid","Please input PDB ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_afid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_afid","Please input AlphaFold UniProt ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_refseqid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_refseqid","Please input NCBI Protein Accession")})),e.myEventCls.onIds("#"+e.pre+"mn1_opmid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_opmid","Please input OPM PDB ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_align","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_align","Align two PDB structures")})),e.myEventCls.onIds("#"+e.pre+"mn1_alignaf","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_alignaf","Align two AlphaFold structures")})),e.myEventCls.onIds("#"+e.pre+"mn1_chainalign","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_chainalign","Align multiple chains by structure alignment")})),e.myEventCls.onIds("#"+e.pre+"mn1_chainalign2","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_chainalign2","Align multiple chains by sequence alignment")})),e.myEventCls.onIds("#"+e.pre+"mn1_chainalign3","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_chainalign3","Align multiple chains residue by residue")})),e.myEventCls.onIds("#"+e.pre+"mn1_mutation","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mutation","Show the mutations in 3D")})),e.myEventCls.onIds("#"+e.pre+"mn1_pdbfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pdbfile","Please input PDB File")})),e.myEventCls.onIds(["#"+e.pre+"mn1_pdbfile_app","#"+e.pre+"tool_pdbfile"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pdbfile_app","Please append PDB Files")})),e.myEventCls.onIds("#"+e.pre+"mn1_mol2file","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mol2file","Please input Mol2 File")})),e.myEventCls.onIds("#"+e.pre+"mn1_sdffile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_sdffile","Please input SDF File")})),e.myEventCls.onIds("#"+e.pre+"mn1_xyzfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_xyzfile","Please input XYZ File")})),e.myEventCls.onIds("#"+e.pre+"mn1_afmapfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_afmapfile","Please input AlphaFold PAE File")})),e.myEventCls.onIds("#"+e.pre+"mn1_urlfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_urlfile","Load data by URL")})),e.myEventCls.onIds("#"+e.pre+"mn1_fixedversion","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_fixedversion","Open Share Link URL in the archived version of iCn3D")})),e.myEventCls.onIds("#"+e.pre+"reload_fixedversion","click",(function(s){let i=e.icn3d,n=$("#"+e.pre+"sharelinkurl").val();t.setLogCmd("open "+n,!1),localStorage.setItem("fixedversion","1");let l=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(n,l)})),e.myEventCls.onIds("#"+e.pre+"mn1_mmciffile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmciffile","Please input mmCIF File")})),e.myEventCls.onIds("#"+e.pre+"mn1_mmcifid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmcifid","Please input mmCIF ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_mmdbid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmdbid","Please input MMDB or PDB ID")})),e.myEventCls.onIds(["#"+e.pre+"mn1_mmdbafid",,"#"+e.pre+"tool_mmdbafid"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmdbafid","Please input PDB/MMDB/AlphaFold UniProt IDs")})),e.myEventCls.onIds("#"+e.pre+"mn1_blast_rep_id","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_blast_rep_id","Align sequence to structure")})),e.myEventCls.onIds("#"+e.pre+"mn1_gi","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_gi","Please input protein gi")})),e.myEventCls.onIds("#"+e.pre+"mn1_cid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_cid","Please input PubChem CID")})),e.myEventCls.onIds("#"+e.pre+"mn1_pngimage","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pngimage","Please input the PNG image")})),e.myEventCls.onIds("#"+e.pre+"mn1_state","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_state","Please input the state file")})),e.myEventCls.onIds("#"+e.pre+"mn1_selection","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_selection","Please input the selection file")})),e.myEventCls.onIds("#"+e.pre+"mn1_dsn6","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_dsn6","Please input the DSN6 file to display electron density map")})),e.myEventCls.onIds(["#"+e.pre+"mn1_delphi","#"+e.pre+"mn1_delphi2","#"+e.pre+"tool_delphi"],"click",(function(t){e.icn3d.loadPhiFrom="delphi",$("#"+e.pre+"dl_delphi_tabs").tabs(),e.htmlCls.dialogCls.openDlg("dl_delphi","Please set parameters to display DelPhi potential map")})),e.myEventCls.onIds("#"+e.pre+"mn1_phi","click",(function(t){e.icn3d.loadPhiFrom="phi",$("#"+e.pre+"dl_phi_tabs").tabs(),$("#"+e.pre+"phitab1_tabs").tabs(),$("#"+e.pre+"phitab2_tabs").tabs(),e.htmlCls.dialogCls.openDlg("dl_phi","Please input local phi or cube file to display DelPhi potential map")})),e.myEventCls.onIds("#"+e.pre+"mn1_phiurl","click",(function(t){e.icn3d.loadPhiFrom="phiurl",$("#"+e.pre+"dl_phiurl_tabs").tabs(),$("#"+e.pre+"phiurltab1_tabs").tabs(),$("#"+e.pre+"phiurltab2_tabs").tabs(),e.htmlCls.dialogCls.openDlg("dl_phiurl","Please input URL phi or cube file to display DelPhi potential map")})),e.myEventCls.onIds("#"+e.pre+"mn1_dsn6url","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_dsn6url","Please input the DSN6 file to display electron density map")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportState","click",(function(s){let i=e.icn3d;t.setLogCmd("export state file",!1);let n=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(n+"_statefile.txt","command")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportPdbRes","click",(function(s){e.icn3d,e.htmlCls.setHtmlCls.exportPdb(),t.setLogCmd("export pdb",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportSecondary","click",(function(s){e.icn3d,e.htmlCls.setHtmlCls.exportSecondary(),t.setLogCmd("export secondary structure",!0)})),e.myEventCls.onIds(["#"+e.pre+"delphipdb","#"+e.pre+"phipdb"],"click",(function(s){let i=e.icn3d,n=i.saveFileCls.getSelectedResiduePDB();t.setLogCmd("export PDB of selected residues",!1);let l=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(l+"_icn3d_residues.pdb","text",[n])})),e.myEventCls.onIds(["#"+e.pre+"delphipqr","#"+e.pre+"phipqr","#"+e.pre+"phiurlpqr"],"click",(async function(s){e.icn3d,await e.htmlCls.setHtmlCls.exportPqr(),t.setLogCmd("export pqr",!0)})),e.myEventCls.onIds("#"+e.pre+"profixpdb","click",(async function(s){let i=e.icn3d;await i.scapCls.exportPdbProfix(!1),t.setLogCmd("export pdb missing atoms",!0)})),e.myEventCls.onIds("#"+e.pre+"profixpdbh","click",(async function(s){let i=e.icn3d;await i.scapCls.exportPdbProfix(!0),t.setLogCmd("export pdb hydrogen",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportStl","click",(function(s){let i=e.icn3d;t.setLogCmd("export stl file",!1),i.export3DCls.exportStlFile("")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportVrml","click",(function(s){let i=e.icn3d;t.setLogCmd("export vrml file",!1),i.export3DCls.exportVrmlFile("")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportStlStab","click",(function(s){let i=e.icn3d;t.setLogCmd("export stl stabilizer file",!1),i.threeDPrintCls.hideStabilizer(),i.threeDPrintCls.resetAfter3Dprint(),i.threeDPrintCls.addStabilizer(),i.export3DCls.exportStlFile("_stab")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportVrmlStab","click",(function(s){let i=e.icn3d;t.setLogCmd("export vrml stabilizer file",!1),i.threeDPrintCls.hideStabilizer(),i.threeDPrintCls.resetAfter3Dprint(),i.threeDPrintCls.addStabilizer(),i.export3DCls.exportVrmlFile("_stab")})),e.myEventCls.onIds("#"+e.pre+"mn6_exportInteraction","click",(async function(s){let i=e.icn3d;t.setLogCmd("export interactions",!1),void 0!==e.cfg.mmdbid&&await i.viewInterPairsCls.retrieveInteractionData(),i.viewInterPairsCls.exportInteractions()})),e.myEventCls.onIds(["#"+e.pre+"mn1_exportCanvas","#"+e.pre+"saveimage"],"click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas",!1);await i.shareLinkCls.shareLink(!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas1","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 1",!0),i.scaleFactor=1,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas2","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 2",!0),i.scaleFactor=2,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas4","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 4",!0),i.scaleFactor=4,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas8","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 8",!0),i.scaleFactor=8,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCounts","click",(function(s){let i=e.icn3d;t.setLogCmd("export counts",!1);let n='

    Total Count for atoms with coordinates:
    ';n+="",n+="
    Structure CountChain CountResidue CountAtom Count
    "+Object.keys(i.structures).length+""+Object.keys(i.chains).length+""+Object.keys(i.residues).length+""+Object.keys(i.atoms).length+"

    ",n+="Counts by Chain for atoms with coordinates:
    ";let l=Object.keys(i.chains);for(let e=0,t=l.length;e"}n+="
    StructureChainResidue CountAtom Count
    "+r+""+o+""+Object.keys(a).length+""+Object.keys(i.chains[t]).length+"

    ";let r=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(r+"_counts.html","html",n)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportSelections","click",(function(s){let i=e.icn3d;t.setLogCmd("export all selections",!1),t.SetChainsAdvancedMenu();let n=i.saveFileCls.exportCustomAtoms(),l=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(l+"_selections.txt","text",[n])})),e.myEventCls.onIds("#"+e.pre+"mn1_exportSelDetails","click",(function(s){let i=e.icn3d;t.setLogCmd("export all selections with details",!1),t.SetChainsAdvancedMenu();let n=i.saveFileCls.exportCustomAtoms(!0),l=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(l+"_sel_details.txt","text",[n])})),e.myEventCls.onIds(["#"+e.pre+"mn1_sharelink","#"+e.pre+"tool_sharelink"],"click",(async function(t){let s=e.icn3d;await s.shareLinkCls.shareLink()})),e.myEventCls.onIds("#"+e.pre+"mn1_replayon","click",(async function(s){let i=e.icn3d;await i.resizeCanvasCls.replayon(),t.setLogCmd("replay on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_replayoff","click",(async function(s){let i=e.icn3d;await i.resizeCanvasCls.replayoff(),t.setLogCmd("replay off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_menuall","click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.allMenus),t.applyShownMenus()})),e.myEventCls.onIds("#"+e.pre+"mn1_menusimple","click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.simpleMenus),t.applyShownMenus()})),e.myEventCls.onIds("#"+e.pre+"mn1_menupref","click",(function(s){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_menupref","Select Menus"),t.getHiddenMenusFromCache(),t.displayShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"apply_menupref","#"+e.pre+"apply_menupref2"],"click",(function(s){e.icn3d;var i=document.querySelectorAll('form[name="'+e.pre+'selmenu"] input:checked');for(var n of(e.htmlCls.shownMenus={},i))e.htmlCls.shownMenus[n.value]=1;t.applyShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"reset_menupref","#"+e.pre+"reset_menupref2"],"click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.simpleMenus),t.applyShownMenus(),t.displayShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"reset_menupref_all","#"+e.pre+"reset_menupref_all2"],"click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.allMenus),t.applyShownMenus(),t.displayShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"savepref","#"+e.pre+"savepref2"],"click",(function(t){let s=e.icn3d,i="[";var n=document.querySelectorAll('form[name="'+e.pre+'selmenu"] input:not(:checked)');let l=0;for(var r of n)l>0&&(i+=", "),i+='"'+r.value+'"',++l;i+="]",s.saveFileCls.saveFile("icn3d_menus_pref.txt","text",[i])})),e.myEventCls.onIds("#"+e.pre+"reload_menupreffile","click",(function(s){e.icn3d,e.cfg.notebook||dialog.dialog("close");let i=$("#"+e.pre+"menupreffile")[0].files[0];if(i){e.htmlCls.setHtmlCls.fileSupport();let s=new FileReader;s.onload=function(s){let i=s.target.result,n=JSON.parse(i);e.htmlCls.shownMenus={};for(let t in e.htmlCls.allMenus)-1==n.indexOf(t)&&(e.htmlCls.shownMenus[t]=1);t.applyShownMenus(),t.displayShownMenus()},s.readAsText(i)}else alert("Please select a file before clicking 'Load'")})),e.myEventCls.onIds("#"+e.pre+"mn1_menuloadpref","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_menuloadpref","Please input the menu preference file")})),e.myEventCls.onIds("#"+e.pre+"mn1_link_structure","click",(function(t){let s=e.icn3d,i=s.saveFileCls.getLinkToStructureSummary(!0),n=s.structures&&Object.keys(s.structures).length>0?"_blank":"_self";window.open(i,n)})),e.myEventCls.onIds("#"+e.pre+"mn1_link_bind","click",(function(s){let i=e.icn3d;url="https://www.ncbi.nlm.nih.gov/pccompound?LinkName=pccompound_structure&from_uid="+i.inputid,t.setLogCmd("link to 3D protein structures bound to CID "+i.inputid+": "+url,!1);let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(url,n)})),e.myEventCls.onIds("#"+e.pre+"mn1_link_vast","click",(function(s){let i=e.icn3d;if(void 0===i.inputid)url="https://www.ncbi.nlm.nih.gov/pccompound?term="+i.molTitle,t.setLogCmd("link to compounds "+i.molTitle+": "+url,!1);else{let s;if(void 0!==e.cfg.cid)s="https://www.ncbi.nlm.nih.gov/pccompound?LinkName=pccompound_pccompound_3d&from_uid="+i.inputid,t.setLogCmd("link to compounds with structure similar to CID "+i.inputid+": "+s,!1);else{let n=i.inputid.split("_");1===n.length?(s=e.htmlCls.baseUrl+"vastplus/vastplus.cgi?uid="+i.inputid,t.setLogCmd("link to structures similar to "+i.inputid+": "+s,!1)):2===n.length&&(s=e.htmlCls.baseUrl+"vastplus/vastplus.cgi?uid="+n[0],t.setLogCmd("link to structures similar to "+n[0]+": "+s,!1))}}let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(url,n)})),e.myEventCls.onIds("#"+e.pre+"mn1_link_pubmed","click",(function(s){let i=e.icn3d;if(void 0===i.inputid){let e;e="https://www.ncbi.nlm.nih.gov/pubmed/?term="+i.molTitle,t.setLogCmd("link to literature about "+i.molTitle+": "+e,!1);let s=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(e,s)}else if(i.pmid){let e,s=i.pmid.toString().split("_");1===s.length?(e="https://www.ncbi.nlm.nih.gov/pubmed/"+i.pmid,t.setLogCmd("link to PubMed ID "+i.pmid+": "+e,!1)):2===s.length&&(e="https://www.ncbi.nlm.nih.gov/pubmed/?term="+s[0]+" OR "+s[1],t.setLogCmd("link to PubMed IDs "+s[0]+", "+s[1]+": "+e,!1));let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(e,n)}else if(isNaN(i.inputid)){let e,s=i.inputid.toString().split("_");1===s.length?(e="https://www.ncbi.nlm.nih.gov/pubmed/?term="+i.inputid,t.setLogCmd("link to literature about PDB "+i.inputid+": "+e,!1)):2===s.length&&(e="https://www.ncbi.nlm.nih.gov/pubmed/?term="+s[0]+" OR "+s[1],t.setLogCmd("link to literature about PDB "+s[0]+" OR "+s[1]+": "+e,!1));let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(e,n)}else void 0!==e.cfg.cid?alert("No literature information is available for this compound in the SDF file."):alert("No literature information is available for this structure.")})),e.myEventCls.onIds("#"+e.pre+"mn1_link_protein","click",(function(s){let i=e.icn3d,n=Object.keys(i.structures),l=Object.keys(i.chains),r="";for(let e=0,t=l.length;e0&&(r=r.substr(0,r.length-4));let o="https://www.ncbi.nlm.nih.gov/protein/?term="+r;t.setLogCmd("link to Entrez protein about PDB "+n+": "+o,!1);let a=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(o,a)}))}clickMenu2(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds(["#"+e.pre+"mn6_selectannotations","#"+e.pre+"tool_selectannotations"],"click",(async function(s){let i=e.icn3d;await i.showAnnoCls.showAnnotations(),t.setLogCmd("view annotations",!0)})),e.myEventCls.onIds("#"+e.pre+"mn2_selectall","click",(function(s){let i=e.icn3d;t.setLogCmd("select all",!0),i.selectionCls.selectAll(),i.hlUpdateCls.removeHlAll(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"clearall","click",(function(s){let i=e.icn3d;t.setLogCmd("clear all",!0),i.bSelectResidue=!1,i.selectionCls.selectAll(),i.hlUpdateCls.removeHlAll(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn2_selectdisplayed","click",(function(s){let i=e.icn3d;t.setLogCmd("select displayed set",!0),i.hAtoms=e.hashUtilsCls.cloneHash(i.viewSelectionAtoms),i.hlUpdateCls.updateHlAll()})),e.myEventCls.onIds("#"+e.pre+"mn2_fullstru","click",(function(s){let i=e.icn3d;t.setLogCmd("show all",!0),i.selectionCls.showAll()})),e.myEventCls.onIds("#"+e.pre+"mn2_selectcomplement","click",(function(s){let i=e.icn3d;Object.keys(i.hAtoms).lengthnon-selected"+n),$("#"+e.pre+"atomsCustomSphere2").length&&$("#"+e.pre+"atomsCustomSphere2").html(" "+n),e.htmlCls.dialogCls.openDlg("dl_aroundsphere","Select a sphere around a set of residues"),i.bSphereCalc=!1,$("#"+e.pre+"atomsCustomSphere").resizable(),$("#"+e.pre+"atomsCustomSphere2").resizable()})),e.myEventCls.onIds(["#"+e.pre+"mn2_select_chain","#"+e.pre+"definedSets"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_select_chain","Select Structure/Chain/Custom Selection")}))}clickMenu3(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds(["#"+e.pre+"mn3_proteinsRibbon","#"+e.pre+"tool_proteinsRibbon"],"click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","ribbon"),t.setLogCmd("style proteins ribbon",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsStrand","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","strand"),t.setLogCmd("style proteins strand",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsCylinder","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","cylinder and plate"),t.setLogCmd("style proteins cylinder and plate",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsSchematic","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","schematic"),t.setLogCmd("style proteins schematic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsCalpha","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","c alpha trace"),t.setLogCmd("style proteins c alpha trace",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsBackbone","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","backbone"),t.setLogCmd("style proteins backbone",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsBfactor","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","b factor tube"),t.setLogCmd("style proteins b factor tube",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsLines","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","lines"),t.setLogCmd("style proteins lines",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsStick","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","stick"),t.setLogCmd("style proteins stick",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn3_proteinsBallstick","#"+e.pre+"tool_proteinsBallstick"],"click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","ball and stick"),t.setLogCmd("style proteins ball and stick",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn3_proteinsSphere","#"+e.pre+"tool_proteinsSphere"],"click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","sphere"),t.setLogCmd("style proteins sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsNo","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","nothing"),t.setLogCmd("style proteins nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecLines","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","lines2"),t.setLogCmd("style sidec lines2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecStick","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","stick2"),t.setLogCmd("style sidec stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","ball and stick2"),t.setLogCmd("style sidec ball and stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","sphere2"),t.setLogCmd("style sidec sphere2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecNo","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","nothing"),t.setLogCmd("style sidec nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseLines","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","lines2"),t.setLogCmd("style ntbase lines2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseStick","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","stick2"),t.setLogCmd("style ntbase stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","ball and stick2"),t.setLogCmd("style ntbase ball and stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","sphere2"),t.setLogCmd("style ntbase sphere2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseNo","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","nothing"),t.setLogCmd("style ntbase nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclCartoon","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","nucleotide cartoon"),t.setLogCmd("style nucleotides nucleotide cartoon",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclBackbone","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","backbone"),t.setLogCmd("style nucleotides backbone",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclSchematic","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","schematic"),t.setLogCmd("style nucleotides schematic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclPhos","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","o3 trace"),t.setLogCmd("style nucleotides o3 trace",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclLines","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","lines"),t.setLogCmd("style nucleotides lines",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclStick","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","stick"),t.setLogCmd("style nucleotides stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","ball and stick"),t.setLogCmd("style nucleotides ball and stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","sphere"),t.setLogCmd("style nucleotides sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclNo","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","nothing"),t.setLogCmd("style nucleotides nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligLines","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","lines"),t.setLogCmd("style chemicals lines",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligStick","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","stick"),t.setLogCmd("style chemicals stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","ball and stick"),t.setLogCmd("style chemicals ball and stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligSchematic","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","schematic"),t.setLogCmd("style chemicals schematic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","sphere"),t.setLogCmd("style chemicals sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligNo","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","nothing"),t.setLogCmd("style chemicals nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_glycansCartYes","click",(function(s){let i=e.icn3d;i.bGlycansCartoon=!0,i.drawCls.draw(),t.setLogCmd("glycans cartoon yes",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_glycansCartNo","click",(function(s){let i=e.icn3d;i.bGlycansCartoon=!1,i.drawCls.draw(),t.setLogCmd("glycans cartoon no",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_hydrogensYes","click",(function(s){let i=e.icn3d;i.showInterCls.showHydrogens(),i.drawCls.draw(),t.setLogCmd("hydrogens",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_hydrogensNo","click",(function(s){let i=e.icn3d;i.showInterCls.hideHydrogens(),i.drawCls.draw(),t.setLogCmd("set hydrogens off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ionsSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("ions","sphere"),t.setLogCmd("style ions sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ionsDot","click",(function(s){e.icn3d.setOptionCls.setStyle("ions","dot"),t.setLogCmd("style ions dot",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ionsNo","click",(function(s){e.icn3d.setOptionCls.setStyle("ions","nothing"),t.setLogCmd("style ions nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_waterSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("water","sphere"),t.setLogCmd("style water sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_waterDot","click",(function(s){e.icn3d.setOptionCls.setStyle("water","dot"),t.setLogCmd("style water dot",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_waterNo","click",(function(s){e.icn3d.setOptionCls.setStyle("water","nothing"),t.setLogCmd("style water nothing",!0)}))}clickMenu4(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrum","click",(function(s){e.icn3d.setOptionCls.setOption("color","spectrum"),t.setLogCmd("color spectrum",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrumChain","click",(function(s){e.icn3d.setOptionCls.setOption("color","spectrum for chains"),t.setLogCmd("color spectrum for chains",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrumAcrossSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorSpectrumAcross").length&&$("#"+e.pre+"atomsCustomColorSpectrumAcross").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorspectrumacrosssets","Please select sets to apply spectrum color for sets"),$("#"+e.pre+"atomsCustomColorSpectrumAcross").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrumSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorSpectrum").length&&$("#"+e.pre+"atomsCustomColorSpectrum").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorspectrumbysets","Please select sets to apply spectrum color for residues"),$("#"+e.pre+"atomsCustomColorSpectrum").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrRainbowAcrossSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorRainbowAcross").length&&$("#"+e.pre+"atomsCustomColorRainbowAcross").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorrainbowacrosssets","Please select sets to apply rainbow color for sets"),$("#"+e.pre+"atomsCustomColorRainbowAcross").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrRainbowSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorRainbow").length&&$("#"+e.pre+"atomsCustomColorRainbow").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorrainbowbysets","Please select sets to apply rainbow color for residues"),$("#"+e.pre+"atomsCustomColorRainbow").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrRainbow","click",(function(s){e.icn3d.setOptionCls.setOption("color","rainbow"),t.setLogCmd("color rainbow",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrRainbowChain","#"+e.pre+"tool_clrRainbowChain"],"click",(function(s){e.icn3d.setOptionCls.setOption("color","rainbow for chains"),t.setLogCmd("color rainbow for chains",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrChain","#"+e.pre+"tool_clrChain"],"click",(function(s){e.icn3d.setOptionCls.setOption("color","chain"),t.setLogCmd("color chain",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrStructure","click",(function(s){e.icn3d.setOptionCls.setOption("color","structure"),t.setLogCmd("color structure",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrdomain","click",(function(s){e.icn3d.setOptionCls.setOption("color","domain"),t.setLogCmd("color domain",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrsets","click",(function(s){e.icn3d.setOptionCls.setOption("color","defined sets"),t.setLogCmd("color defined sets",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrSSGreen","#"+e.pre+"tool_clrSSGreen"],"click",(function(s){let i=e.icn3d;i.sheetcolor="green",i.setOptionCls.setOption("color","secondary structure green"),t.setLogCmd("color secondary structure green",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSSYellow","click",(function(s){let i=e.icn3d;i.sheetcolor="yellow",i.setOptionCls.setOption("color","secondary structure yellow"),t.setLogCmd("color secondary structure yellow",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSSSpectrum","click",(function(s){e.icn3d.setOptionCls.setOption("color","secondary structure spectrum"),t.setLogCmd("color secondary structure spectrum",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrResidue","click",(function(s){e.icn3d.setOptionCls.setOption("color","residue"),t.setLogCmd("color residue",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrResidueCustom","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_rescolorfile","Please input the file on residue colors")})),e.myEventCls.onIds("#"+e.pre+"reload_rescolorfile","click",(function(s){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close");let n=$("#"+e.pre+"rescolorfile")[0].files[0];if(n){e.htmlCls.setHtmlCls.fileSupport();let s=new FileReader;s.onload=function(s){let n=s.target.result.replace(/#/g,"");i.customResidueColors=JSON.parse(n);for(let t in i.customResidueColors)i.customResidueColors[t.toUpperCase()]=e.parasCls.thr("#"+i.customResidueColors[t]);i.setOptionCls.setOption("color","residue custom"),t.setLogCmd("color residue custom | "+n,!0)},s.readAsText(n)}else alert("Please select a file before clicking 'Load'")})),e.myEventCls.onIds("#"+e.pre+"reload_customcolorfile","click",(function(s){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close"),i.startColor=$("#"+e.pre+"startColor").val(),i.midColor=$("#"+e.pre+"midColor").val(),i.endColor=$("#"+e.pre+"endColor").val();let n=t.setLegendHtml();$("#"+e.pre+"dl_legend").html(n),e.htmlCls.dialogCls.openDlg("dl_legend","Color range"),i.addTrackCls.setCustomFile("color",i.startColor,i.midColor,i.endColor)})),e.myEventCls.onIds("#"+e.pre+"mn6_customref","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_customref","Set custom reference numbers")})),e.myEventCls.onIds("#"+e.pre+"reload_customreffile","click",(function(s){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close");let n=$("#"+i.pre+"cstreffile")[0].files[0];if(n){e.utilsCls.checkFileAPI();let s=new FileReader;s.onload=async function(e){let s=e.target.result;await i.refnumCls.parseCustomRefFile(s),s=s.replace(/\r/g,"").replace(/\n/g,"\\n"),t.setLogCmd("custom refnum | "+s,!0)},s.readAsText(n)}else alert("Please select a file before clicking 'Apply'")})),e.myEventCls.onIds("#"+e.pre+"remove_legend","click",(function(s){e.icn3d,$("#"+e.pre+"legend").hide(),t.setLogCmd("remove legend",!0)})),e.myEventCls.onIds("#"+e.pre+"reload_customtubefile","click",(function(t){let s=e.icn3d;e.cfg.notebook||dialog.dialog("close"),s.addTrackCls.setCustomFile("tube")})),e.myEventCls.onIds("#"+e.pre+"mn4_clrCharge","click",(function(s){e.icn3d.setOptionCls.setOption("color","charge"),t.setLogCmd("color charge",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrHydrophobic","click",(function(s){e.icn3d.setOptionCls.setOption("color","hydrophobic"),t.setLogCmd("color hydrophobic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrNormalizedHP","click",(function(s){e.icn3d.setOptionCls.setOption("color","normalized hydrophobic"),t.setLogCmd("color normalized hydrophobic",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrAtom","#"+e.pre+"tool_clrAtom"],"click",(function(s){e.icn3d.setOptionCls.setOption("color","atom"),t.setLogCmd("color atom",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrBfactor","click",(function(s){e.icn3d.setOptionCls.setOption("color","b factor"),t.setLogCmd("color b factor",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrConfidence","click",(function(s){e.icn3d.setOptionCls.setOption("color","confidence"),t.setLogCmd("color confidence",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrIgstrand","click",(function(s){e.icn3d.setOptionCls.setOption("color","ig strand"),t.setLogCmd("color ig strand",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrArea","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_colorbyarea","Color based on residue's solvent accessibility")})),e.myEventCls.onIds("#"+e.pre+"applycolorbyarea","click",(function(s){let i=e.icn3d;i.midpercent=$("#"+e.pre+"midpercent").val(),i.setOptionCls.setOption("color","area"),t.setLogCmd("color area | "+i.midpercent,!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrBfactorNorm","click",(function(s){e.icn3d.setOptionCls.setOption("color","b factor percentile"),t.setLogCmd("color b factor percentile",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrIdentity","click",(function(s){e.icn3d.setOptionCls.setOption("color","identity"),t.setLogCmd("color identity",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrConserved","click",(function(s){e.icn3d.setOptionCls.setOption("color","conservation"),t.setLogCmd("color conservation",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrCustom","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_clr","Color picker")})),$(document).on("click",".icn3d-color-rad-text",(function(s){let i=e.icn3d;s.stopImmediatePropagation(),s.preventDefault();let n=$(this).attr("color");i.setOptionCls.setOption("color",n),t.setLogCmd("color "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSave","click",(function(s){e.icn3d.setOptionCls.saveColor(),t.setLogCmd("save color",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrApplySave","click",(function(s){e.icn3d.setOptionCls.applySavedColor(),t.setLogCmd("apply saved color",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_styleSave","click",(function(s){e.icn3d.setOptionCls.saveStyle(),t.setLogCmd("save style",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_styleApplySave","click",(function(s){e.icn3d.setOptionCls.applySavedStyle(),t.setLogCmd("apply saved style",!0)}))}clickMenu5(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds("#"+e.pre+"mn5_neighborsYes","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.applyMapCls.removeLastSurface(),i.applyMapCls.applySurfaceOptions(),i.bRender&&i.drawCls.render(),t.setLogCmd("set surface neighbors on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_neighborsNo","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.applyMapCls.removeLastSurface(),i.applyMapCls.applySurfaceOptions(),i.bRender&&i.drawCls.render(),t.setLogCmd("set surface neighbors off",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn5_surfaceVDW","#"+e.pre+"tool_surfaceVDW"],"click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.setOptionCls.setOption("surface","Van der Waals surface"),t.setLogCmd("set surface Van der Waals surface",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceSAS","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.setOptionCls.setOption("surface","solvent accessible surface"),t.setLogCmd("set surface solvent accessible surface",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceMolecular","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.setOptionCls.setOption("surface","molecular surface"),t.setLogCmd("set surface molecular surface",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceVDWContext","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.setOptionCls.setOption("surface","Van der Waals surface with context"),t.setLogCmd("set surface Van der Waals surface with context",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceSASContext","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.setOptionCls.setOption("surface","solvent accessible surface with context"),t.setLogCmd("set surface solvent accessible surface with context",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceMolecularContext","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.setOptionCls.setOption("surface","molecular surface with context"),t.setLogCmd("set surface molecular surface with context",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceNo","click",(function(s){e.icn3d.setOptionCls.setOption("surface","nothing"),t.setLogCmd("set surface nothing",!0)})),$(document).on("click","."+e.pre+"mn5_opacity",(function(s){let i=e.icn3d;i.transparentRenderOrder=!1;let n=$(this).attr("v");i.setOptionCls.setOption("opacity",n),t.setLogCmd("set surface opacity "+n,!0)})),$(document).on("click","."+e.pre+"mn5_opacityslow",(function(s){let i=e.icn3d;i.transparentRenderOrder=!0;let n=$(this).attr("v");i.setOptionCls.setOption("opacity",n),t.setLogCmd("set surface2 opacity "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_wireframeYes","click",(function(s){e.icn3d.setOptionCls.setOption("wireframe","yes"),t.setLogCmd("set surface wireframe on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_wireframeNo","click",(function(s){e.icn3d.setOptionCls.setOption("wireframe","no"),t.setLogCmd("set surface wireframe off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_elecmap2fofc","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_elecmap2fofc","2Fo-Fc Electron Density Map")})),e.myEventCls.onIds("#"+e.pre+"mn5_elecmapfofc","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_elecmapfofc","Fo-Fc Electron Density Map")})),e.myEventCls.onIds(["#"+e.pre+"mn5_elecmapNo","#"+e.pre+"elecmapNo2","#"+e.pre+"elecmapNo3","#"+e.pre+"elecmapNo4","#"+e.pre+"elecmapNo5"],"click",(function(s){e.icn3d.setOptionCls.setOption("map","nothing"),t.setLogCmd("setoption map nothing",!0)})),e.myEventCls.onIds(["#"+e.pre+"delphimapNo","#"+e.pre+"phimapNo","#"+e.pre+"phiurlmapNo","#"+e.pre+"mn1_phimapNo"],"click",(function(s){e.icn3d.setOptionCls.setOption("phimap","nothing"),t.setLogCmd("setoption phimap nothing",!0)})),e.myEventCls.onIds(["#"+e.pre+"delphimapNo2","#"+e.pre+"phimapNo2","#"+e.pre+"phiurlmapNo2"],"click",(function(s){e.icn3d.setOptionCls.setOption("phisurface","nothing"),t.setLogCmd("setoption phisurface nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"applymap2fofc","click",(function(s){let i=e.icn3d,n=parseFloat($("#"+e.pre+"sigma2fofc").val());i.dsn6ParserCls.dsn6Parser(i.inputid,"2fofc",n),t.setLogCmd("set map 2fofc sigma "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"applymapfofc","click",(function(s){let i=e.icn3d,n=parseFloat($("#"+e.pre+"sigmafofc").val());i.dsn6ParserCls.dsn6Parser(i.inputid,"fofc",n),t.setLogCmd("set map fofc sigma "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_mapwireframeYes","click",(function(s){e.icn3d.setOptionCls.setOption("mapwireframe","yes"),t.setLogCmd("set map wireframe on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_mapwireframeNo","click",(function(s){e.icn3d.setOptionCls.setOption("mapwireframe","no"),t.setLogCmd("set map wireframe off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_emmap","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_emmap","EM Density Map")})),e.myEventCls.onIds(["#"+e.pre+"mn5_emmapNo","#"+e.pre+"emmapNo2"],"click",(function(s){e.icn3d.setOptionCls.setOption("emmap","nothing"),t.setLogCmd("setoption emmap nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"applyemmap","click",(function(s){let i=e.icn3d,n=parseFloat($("#"+e.pre+"empercentage").val());i.densityCifParserCls.densityCifParser(i.inputid,"em",n,i.emd),t.setLogCmd("set emmap percentage "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_emmapwireframeYes","click",(function(s){e.icn3d.setOptionCls.setOption("emmapwireframe","yes"),t.setLogCmd("set emmap wireframe on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_emmapwireframeNo","click",(function(s){e.icn3d.setOptionCls.setOption("emmapwireframe","no"),t.setLogCmd("set emmap wireframe off",!0)}))}clickMenu6(){let e=this.icn3dui,t=e.icn3d;if(e.bNode)return;let s=this;e.myEventCls.onIds("#"+e.pre+"mn6_assemblyYes","click",(function(t){let i=e.icn3d;i.bAssembly=!0,s.setLogCmd("set assembly on",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_assemblyNo","click",(function(t){let i=e.icn3d;i.bAssembly=!1,s.setLogCmd("set assembly off",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_igrefYes","click",(async function(t){let i=e.icn3d;s.setLogCmd("ig refnum on",!0),await i.refnumCls.showIgRefNum()})),e.myEventCls.onIds("#"+e.pre+"mn6_igrefNo","click",(async function(t){let i=e.icn3d;s.setLogCmd("ig refnum off",!0),await i.refnumCls.hideIgRefNum()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelAtoms","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addAtomLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add atom labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelElements","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addAtomLabels(i.hAtoms,!0),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add element labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelResidues","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addResidueLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add residue labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelResnum","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addResidueLabels(i.hAtoms,void 0,void 0,!0),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add residue number labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelChains","click",(function(t){let i=e.icn3d;i.analysisCls.addChainLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add chain labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelTermini","click",(function(t){let i=e.icn3d;i.analysisCls.addTerminiLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add terminal labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelYes","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_addlabel","Add custom labels by selection"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelSelection","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_addlabelselection","Add custom labels by the selected")})),e.myEventCls.onIds("#"+e.pre+"mn6_labelColor","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_labelColor","Change color for all labels")})),e.myEventCls.onIds(["#"+e.pre+"mn2_saveselection","#"+e.pre+"tool_saveselection"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_saveselection","Save the selected")})),e.myEventCls.onIds(["#"+e.pre+"mn6_addlabelNo","#"+e.pre+"removeLabels"],"click",(function(t){let i=e.icn3d;i.labelcolor=void 0,i.pickpair=!1;s.setLogCmd("set labels off",!0);for(let e in i.labels)i.labels[e]=[];i.drawCls.draw()})),$(document).on("click","."+e.pre+"mn6_labelscale",(function(t){let i=e.icn3d,n=$(this).attr("v");i.labelScale=n,i.drawCls.draw(),s.setLogCmd("set label scale "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_distanceYes","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_distance","Measure the distance of atoms"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0,s.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_distTwoSets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_disttwosets","Measure the distance between two sets"),s.setSetsMenus("atomsCustomDist"),i.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_distManySets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_distmanysets","Measure the pairwise distance among many sets"),s.setSetsMenus("atomsCustomDistTable"),i.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_distanceNo","click",(function(t){let i=e.icn3d;i.pickpair=!1;s.setLogCmd("set lines off",!0),i.labels.distance=[],i.lines.distance=[],i.distPnts=[],i.pk=2,i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn5_cartoonshape","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_cartoonshape","Draw cartoon for a set");s.setSetsMenus("cartoonshape",!0),i.bCartoonshape=!0})),e.myEventCls.onIds("#"+e.pre+"mn5_linebtwsets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_linebtwsets","Draw a line between two sets"),s.setSetsMenus("linebtwsets"),i.bLinebtwsets=!0})),e.myEventCls.onIds(["#"+e.pre+"mn2_selectedcenter","#"+e.pre+"zoomin_selection","#"+e.pre+"tool_selectedcenter"],"click",(function(t){let i=e.icn3d;i.transformCls.zoominSelection(),i.drawCls.draw(),s.setLogCmd("zoom selection",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_center","click",(function(t){let i=e.icn3d;i.applyCenterCls.centerSelection(),i.drawCls.draw(),s.setLogCmd("center selection",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_resetOrientation","#"+e.pre+"resetOrientation","#"+e.pre+"tool_resetOrientation"],"click",(function(t){let i=e.icn3d;i.transformCls.resetOrientation(),i.drawCls.draw(),s.setLogCmd("reset orientation",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_chemicalbindingshow","#"+e.pre+"chemicalbindingshow"],"click",(function(t){e.icn3d.setOptionCls.setOption("chemicalbinding","show"),s.setLogCmd("set chemicalbinding show",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_chemicalbindinghide","#"+e.pre+"chemicalbindinghide"],"click",(function(t){e.icn3d.setOptionCls.setOption("chemicalbinding","hide"),s.setLogCmd("set chemicalbinding hide",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_sidebyside","click",(function(t){let i=e.icn3d;if(i.bInputfile)return void alert("Side-by-Side does NOT work when the input is from a local file.");let n=i.shareLinkCls.shareLinkUrl(void 0);n=n.replace("full.html","full2.html"),n+="&closepopup=1";let l=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(n,l),s.setLogCmd("side by side | "+n,!0)})),$(document).on("click","."+e.pre+"mn6_rotate",(function(t){let i=e.icn3d,n=$(this).attr("v").toLowerCase(),l=n.split(" ")[1];s.setLogCmd(n,!0),i.bStopRotate=!1,i.transformCls.rotateCount=0,i.transformCls.rotateCountMax=6e3,i.ROT_DIR=l,i.resizeCanvasCls.rotStruc(l)})),$(document).on("click","."+e.pre+"mn6_rotate90",(function(t){let i,n=e.icn3d,l=$(this).attr("v").toLowerCase(),r=l.split("-")[0];s.setLogCmd(l,!0),"x"==r?i=new THREE.Vector3(1,0,0):"y"==r?i=new THREE.Vector3(0,1,0):"z"==r&&(i=new THREE.Vector3(0,0,1));let o=.5*Math.PI;n.transformCls.setRotation(i,o)})),e.myEventCls.onIds("#"+e.pre+"mn6_cameraPers","click",(function(t){e.icn3d.setOptionCls.setOption("camera","perspective"),s.setLogCmd("set camera perspective",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_cameraOrth","click",(function(t){e.icn3d.setOptionCls.setOption("camera","orthographic"),s.setLogCmd("set camera orthographic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_bkgdBlack","click",(function(t){e.icn3d.setStyleCls.setBackground("black")})),e.myEventCls.onIds("#"+e.pre+"tool_bkgd","click",(function(t){let s=e.icn3d;"black"==s.opts.background?s.setStyleCls.setBackground("white"):s.setStyleCls.setBackground("black")})),e.myEventCls.onIds("#"+e.pre+"mn6_bkgdGrey","click",(function(t){e.icn3d.setStyleCls.setBackground("grey")})),e.myEventCls.onIds(["#"+e.pre+"mn6_bkgdWhite","#"+e.pre+"tool_bkgdWhite"],"click",(function(t){e.icn3d.setStyleCls.setBackground("white")})),e.myEventCls.onIds("#"+e.pre+"mn6_bkgdTransparent","click",(function(t){e.icn3d.setStyleCls.setBackground("transparent")})),e.myEventCls.onIds("#"+e.pre+"mn6_showfogYes","click",(function(t){let i=e.icn3d;i.opts.fog="yes",i.fogCls.setFog(!0),i.drawCls.draw(),s.setLogCmd("set fog on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showfogNo","click",(function(t){let i=e.icn3d;i.opts.fog="no",i.fogCls.setFog(!0),i.drawCls.draw(),s.setLogCmd("set fog off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showslabYes","click",(function(t){e.icn3d.setOptionCls.setOption("slab","yes"),s.setLogCmd("set slab on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showslabNo","click",(function(t){e.icn3d.setOptionCls.setOption("slab","no"),s.setLogCmd("set slab off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showaxisYes","click",(function(t){e.icn3d.setOptionCls.setOption("axis","yes"),s.setLogCmd("set axis on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showaxisSel","click",(function(t){let i=e.icn3d;i.pc1=!0,i.axesCls.setPc1Axes(),s.setLogCmd("set pc1 axis",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showaxisNo","click",(function(t){let i=e.icn3d;i.pc1=!1,i.axes=[],i.setOptionCls.setOption("axis","no"),s.setLogCmd("set axis off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_symmetry","click",(async function(t){let s=e.icn3d;s.bAxisOnly=!1,await s.symdCls.retrieveSymmetry(Object.keys(s.structures)[0])})),e.myEventCls.onIds("#"+e.pre+"mn6_symd","click",(async function(t){let i=e.icn3d;i.bAxisOnly=!1,await i.symdCls.retrieveSymd(),i.bSymd=!0,s.setLogCmd("symd symmetry",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_clear_sym","click",(function(t){let i=e.icn3d;i.symdArray=[],i.drawCls.draw(),s.setLogCmd("clear symd symmetry",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_axes_only","click",(function(t){let i=e.icn3d;i.bAxisOnly=!0,i.drawCls.draw(),s.setLogCmd("show axis",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_area","click",(function(t){e.icn3d.analysisCls.calculateArea(),s.setLogCmd("area",!0)})),e.myEventCls.onIds("#"+e.pre+"applysymmetry","click",(function(t){let i=e.icn3d;i.bAxisOnly=!1;let n=$("#"+e.pre+"selectSymmetry").val();i.symmetrytitle="none"===n?void 0:n,i.drawCls.draw(),s.setLogCmd("symmetry "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"clearsymmetry","click",(function(t){let i=e.icn3d;i.symmetrytitle=void 0,i.drawCls.draw(),s.setLogCmd("symmetry none",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_hbondsYes","#"+e.pre+"hbondsYes"],"click",(function(t){let i=e.icn3d;s.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomHbond").length&&$("#"+e.pre+"atomsCustomHbond").html(" "+n),$("#"+e.pre+"atomsCustomHbond2").length&&$("#"+e.pre+"atomsCustomHbond2").html(" "+n),e.htmlCls.dialogCls.openDlg("dl_hbonds","Hydrogen bonds/interactions between two sets of atoms"),i.bHbondCalc=!1,$("#"+e.pre+"atomsCustomHbond").resizable(),$("#"+e.pre+"atomsCustomHbond2").resizable()})),e.myEventCls.onIds(["#"+e.pre+"mn6_contactmap"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_contact","Set contact map")})),e.myEventCls.onIds("#"+e.pre+"mn6_hbondsNo","click",(function(t){let s=e.icn3d;s.showInterCls.hideHbondsContacts(),s.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerYes","click",(function(t){let i=e.icn3d;i.threeDPrintCls.addStabilizer(),i.threeDPrintCls.prepareFor3Dprint(),s.setLogCmd("stabilizer",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerNo","click",(function(t){let i=e.icn3d;s.setLogCmd("set stabilizer off",!0),i.threeDPrintCls.hideStabilizer(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerOne","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_stabilizer","Add One Stabilizer"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerRmOne","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_stabilizer_rm","Remove One Stabilizer"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0})),e.myEventCls.onIds("#"+e.pre+"mn1_thicknessSet","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_thickness","Set Thickness for 3D Printing")})),e.myEventCls.onIds("#"+e.pre+"mn3_setThickness","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_thickness2","Style Preferences")})),e.myEventCls.onIds("#"+e.pre+"mn6_ssbondsYes","click",(function(t){let i=e.icn3d;s.setLogCmd("disulfide bonds",!0),i.showInterCls.showSsbonds()})),e.myEventCls.onIds("#"+e.pre+"mn6_ssbondsExport","click",(function(t){e.icn3d.viewInterPairsCls.exportSsbondPairs(),s.setLogCmd("export disulfide bond pairs",!1)})),e.myEventCls.onIds("#"+e.pre+"mn6_ssbondsNo","click",(function(t){let i=e.icn3d;i.opts.ssbonds="no";s.setLogCmd("set disulfide bonds off",!0),i.lines.ssbond=[],i.setOptionCls.setStyle("sidec","nothing")})),e.myEventCls.onIds("#"+e.pre+"mn6_clbondsYes","click",(function(t){let i=e.icn3d;s.setLogCmd("cross linkage",!0),i.showInterCls.showClbonds()})),e.myEventCls.onIds("#"+e.pre+"mn6_clbondsExport","click",(function(t){e.icn3d.viewInterPairsCls.exportClbondPairs(),s.setLogCmd("export cross linkage pairs",!1)})),e.myEventCls.onIds("#"+e.pre+"mn6_clbondsNo","click",(function(t){let i=e.icn3d;i.opts.clbonds="no";s.setLogCmd("set cross linkage off",!0),i.lines.clbond=[],i.setOptionCls.setStyle("sidec","nothing")})),$("#"+e.pre+"newvs2").on("submit",(function(){let s=t.saveFileCls.getAtomPDB(t.hAtoms);return $("#"+e.pre+"pdbstr").val(s),!0})),$("#"+e.pre+"fssubmit").on("click",(function(){let e=t.saveFileCls.getAtomPDB(t.hAtoms),s=window.open("","_blank");s.document.body.innerHTML="\n\nLoading Foldseek\n\n\n\n
    Foldseek is loading...
    \n",$.ajax({url:"https://search.foldseek.com/api/ticket",type:"POST",data:{q:e,database:["afdb50","afdb-swissprot","gmgcl_id","pdb100","afdb-proteome","mgnify_esm30"],mode:"3diaa"},dataType:"text",success:function(e){s.location="https://search.foldseek.com/queue/"+JSON.parse(e).id},error:function(e,t,s){console.log("Error in submitting data to Foldseek...")}})}))}setLogCmd(e,t,s){var i=this.icn3dui,n=i.icn3d;if(""===e.trim())return!1;let l=e.indexOf("|||");-1!==l&&(e=e.substr(0,l));let r={};if(r.factor=n._zoomFactor,r.mouseChange=n.mouseChange,r.quaternion={},r.quaternion._x=parseFloat(n.quaternion._x).toPrecision(5),r.quaternion._y=parseFloat(n.quaternion._y).toPrecision(5),r.quaternion._z=parseFloat(n.quaternion._z).toPrecision(5),r.quaternion._w=parseFloat(n.quaternion._w).toPrecision(5),t&&n.bAddCommands)if(n.STATENUMBER "+n.logs.join("\n> ")+"\n> "),$("#"+i.pre+"logtext")[0]&&$("#"+i.pre+"logtext").scrollTop($("#"+i.pre+"logtext")[0].scrollHeight)}n.setStyleCls.adjustIcon()}}class d{constructor(e){this.icn3dui=e}getLink(e,t,s,i){return this.icn3dui.htmlCls.setHtmlCls.getLink(e,t,s,i)}getMenuText(e,t,s,i,n){return this.icn3dui.htmlCls.setHtmlCls.getMenuText(e,t,s,i,n)}getMenuUrl(e,t,s,i,n){return this.icn3dui.htmlCls.setHtmlCls.getMenuUrl(e,t,s,i,n)}getMenuSep(){return this.icn3dui.htmlCls.setHtmlCls.getMenuSep()}getLinkWrapper(e,t,s,i,n,l){let r=this.icn3dui;return r.icn3d,r.htmlCls.setHtmlCls.getLinkWrapper(e,t,s,i,n,l)}getLinkWrapper2(e,t,s,i,n){let l=this.icn3dui;return l.icn3d,l.htmlCls.setHtmlCls.getLinkWrapper2(e,t,s,i,n)}getRadio(e,t,s,i,n,l){return this.icn3dui.htmlCls.setHtmlCls.getRadio(e,t,s,i,n,l)}getRadClr(e,t,s,i,n,l,r){return this.icn3dui.htmlCls.setHtmlCls.getRadioColor(e,t,s,i,n,l,r)}setTopMenusHtml(e,t,s){let i=this.icn3dui;if(i.bNode)return"";let n="black"==i.htmlCls.opts.background?i.htmlCls.GREYD:"black",l="";l+="
    ",l+=i.htmlCls.divStr+"popup' class='icn3d-text icn3d-popup'>
    ",l+=this.setReplayHtml(),l+="\x3c!--https://forum.jquery.com/topic/looking-for-a-jquery-horizontal-menu-bar--\x3e",l+=i.htmlCls.divStr+"mnlist' style='position:absolute; z-index:999; float:left; display:table-row; margin-top: -2px;'>",l+="";let r='",l+=r+this.setMenu2()+"",l+=r+this.setMenu2b()+"",l+=r+this.setMenu3()+"",l+=r+this.setMenu4()+"",l+=r+this.setMenu5()+"",l+=r+this.setMenu6()+"",i.htmlCls.shownMenus=i.hashUtilsCls.cloneHash(i.htmlCls.simpleMenus),l+=r+"
    "+t,l+="
    "+s,l+=r+'
    '+i.htmlCls.space2+'Toolbar '+i.htmlCls.space2+'
    ",l+=r+'
    '+i.htmlCls.space2+' ?
    ',l+="
    ",l+="
    ';if(l+=r+this.setMenu1()+"
    ",l+="",l+=this.setTools(),l+=i.htmlCls.divStr+"title' class='icn3d-commandTitle' style='font-size:1.2em; font-weight:normal; position:absolute; z-index:1; float:left; display:table-row; margin: 85px 0px 0px 5px; color:"+n+"; width:"+i.htmlCls.WIDTH+"px'>",l+=i.htmlCls.divStr+"viewer' style='position:relative; width:100%; height:100%; background-color: "+i.htmlCls.GREYD+";'>",l+=i.htmlCls.divStr+"mnLogSection'>",l+="
    ",l+=" ",void 0===i.cfg.mmtfid){let e="top:180px; font-size: 1.8em;";l+=i.htmlCls.divStr+"wait' style='position:absolute; left:50px; "+e+" color: #444444;'>Loading data..."}l+="Your browser does not support WebGL.",(void 0===i.cfg.showcommand||i.cfg.showcommand)&&(l+=this.setLogWindow()),l+="",l+="",l+=i.htmlCls.setDialogCls.setDialogs(),l+=i.htmlCls.setDialogCls.setCustomDialogs(),$("#"+e).html(l),$("accordion").accordion({collapsible:!0,active:!1,heightStyle:"content"}),$("accordion div").removeClass("ui-accordion-content ui-corner-all ui-corner-bottom ui-widget-content"),$(".icn3d-mn-item").menu({position:{my:"left top",at:"right top"}}),$(".icn3d-mn-item").hover((function(){}),(function(){$("accordion").accordion("option","active","none")})),$("#"+i.pre+"accordion1").hover((function(){$("#"+i.pre+"accordion1 div").css("display","block")}),(function(){$("#"+i.pre+"accordion1 div").css("display","none")})),$("#"+i.pre+"accordion2").hover((function(){$("#"+i.pre+"accordion2 div").css("display","block")}),(function(){$("#"+i.pre+"accordion2 div").css("display","none")})),$("#"+i.pre+"accordion2b").hover((function(){$("#"+i.pre+"accordion2b div").css("display","block")}),(function(){$("#"+i.pre+"accordion2b div").css("display","none")})),$("#"+i.pre+"accordion3").hover((function(){$("#"+i.pre+"accordion3 div").css("display","block")}),(function(){$("#"+i.pre+"accordion3 div").css("display","none")})),$("#"+i.pre+"accordion4").hover((function(){$("#"+i.pre+"accordion4 div").css("display","block")}),(function(){$("#"+i.pre+"accordion4 div").css("display","none")})),$("#"+i.pre+"accordion5").hover((function(){$("#"+i.pre+"accordion5 div").css("display","block")}),(function(){$("#"+i.pre+"accordion5 div").css("display","none")})),$("#"+i.pre+"accordion6").hover((function(){$("#"+i.pre+"accordion6 div").css("display","block")}),(function(){$("#"+i.pre+"accordion6 div").css("display","none")}))}setTopMenusHtmlMobile(e,t,s){let i=this.icn3dui;if(i.bNode)return"";let n="black"==i.htmlCls.opts.background?i.htmlCls.GREYD:"black",l="";if(l+="
    ",l+=i.htmlCls.divStr+"popup' class='icn3d-text icn3d-popup'>
    ",l+=this.setReplayHtml(),!i.utilsCls.isMobile()){let e=i.htmlCls.WIDTH-40+5;l+=i.htmlCls.buttonStr+"fullscreen' style='position:absolute; z-index:1999; display:block; padding:0px; margin: 12px 0px 0px "+e+"px; width:30px; height:34px; border-radius:4px; border:none; background-color:#f6f6f6;' title='Full screen'>",l+="",l+="",l+="",l+="",l+=""}l+="\x3c!--https://forum.jquery.com/topic/looking-for-a-jquery-horizontal-menu-bar--\x3e",l+=i.htmlCls.divStr+"mnlist' style='position:absolute; z-index:999; float:left; display:block; margin: 5px 0px 0px 5px;'>",l+="
    ",l+="",i.cfg.notebook?l+="

    ":l+="

    ",l+="
    ";let r="
  • File",l+=this.setMenu1_base(),l+=r+">Select",l+=this.setMenu2_base(),l+=r+">View",l+=this.setMenu2b_base(),l+=r+" id='"+i.pre+"style'>Style",l+=this.setMenu3_base(),l+=r+" id='"+i.pre+"color'>Color",l+=this.setMenu4_base(),l+=r+">Analysis",l+=this.setMenu5_base(),l+=r+">Help",l+=this.setMenu6_base(),i.htmlCls.shownMenus=i.hashUtilsCls.cloneHash(i.htmlCls.simpleMenus),l+="
  • "+t,l+="
    "+s,l+="
  • Alternate",l+="",l+="
  • ",l+="
    ",l+="
    ",l+="",l+=i.htmlCls.divStr+"title' class='icn3d-commandTitle' style='font-size:1.2em; font-weight:normal; position:absolute; z-index:1; float:left; display:block; margin: 12px 0px 0px 40px; color:"+n+"; width:"+(i.htmlCls.WIDTH-40).toString()+"px'>",l+=i.htmlCls.divStr+"viewer' style='position:relative; width:100%; height:100%; background-color: "+i.htmlCls.GREYD+";'>",l+=i.htmlCls.divStr+"mnLogSection'>",l+="
    ",l+="",void 0===i.cfg.mmtfid){let e="top:180px; font-size: 1.8em;";l+=i.htmlCls.divStr+"wait' style='position:absolute; left:50px; "+e+" color: #444444;'>Loading data..."}l+="Your browser does not support WebGL.",(void 0===i.cfg.showcommand||i.cfg.showcommand)&&(l+=this.setLogWindow()),l+="",l+="",l+=i.htmlCls.setDialogCls.setDialogs(),l+=i.htmlCls.setDialogCls.setCustomDialogs(),$("#"+e).html(l),$("accordion").accordion({collapsible:!0,active:!1,heightStyle:"content"}),$("accordion div").removeClass("ui-accordion-content ui-corner-all ui-corner-bottom ui-widget-content"),$(".icn3d-mn-item").menu({position:{my:"left top",at:"right top"}}),$(".icn3d-mn-item").hover((function(){}),(function(){$("accordion").accordion("option","active","none")})),$("#"+i.pre+"accordion0").hover((function(){$("#"+i.pre+"accordion0 div").css("display","block")}),(function(){$("#"+i.pre+"accordion0 div").css("display","none")}))}setReplayHtml(e){let t=this.icn3dui;if(t.bNode)return"";let s="";return s+=t.htmlCls.divStr+"replay' style='display:none; position:absolute; z-index:9999; top:"+parseInt(t.htmlCls.HEIGHT-100).toString()+"px; left:20px;'>",s+="
    ",s+='',s+="",s+='',s+='',s+="",s+="
    ",s+=t.htmlCls.divStr+"replay_menu' style='background-color:#DDDDDD; padding:3px; font-weight:bold;'>",s+=t.htmlCls.divStr+"replay_cmd' style='background-color:#DDDDDD; padding:3px; max-width:250px'>",s+="",s}setTools(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+=e.htmlCls.divStr+"selection' style='display:none;'>
    ",t+="",t+=this.setTools_base(),t+="
    ",t+="
    ",t}setButton(e,t,s,i,n){let l=this.icn3dui;return l.bNode?"":(n=void 0!==n?"color:"+n:"","
    ")}setIcon(e,t,s,i,n,l,r){let o=this.icn3dui;if(o.bNode)return"";let a,d=r?"color:#f8b84e; ":"color:#1c94c4; ",c=" background-color:#EEE; ",h="text"==e?"":"cursor:pointer;";return a=l?'
    '+i+"
    ":'',"link"==e?''+a+"":a}setTools_base(){if(this.icn3dui.bNode)return"";let e="",t="regular",s="",i="";return e+=s+this.setIcon(t,"tool_mmdbafid","Input PDB/MMDB/AlphaFold IDs","id",void 0,!0)+"",e+=s+this.setIcon(t,"tool_pdbfile","Input PDB Files (appendable)","file-alt")+"",e+=s+this.setIcon(t,"tool_sharelink","Get Share Link","link")+"",e+=s+this.setIcon(t,"saveimage","Save iCn3D PNG Image","camera")+"",e+=i+this.setIcon(t,"tool_definedsets","Defined Sets","object-group")+"",e+=s+this.setIcon(t,"tool_aroundsphere","Select by Distance","dot-circle")+"",e+=s+this.setIcon(t,"tool_saveselection","Save Selection as a Set","save")+"",e+=s+this.setIcon(t,"toggleHighlight","Toggle Highlight","highlighter")+"",e+=i+this.setIcon(t,"show_selected","View Selection","eye")+"",e+=s+this.setIcon(t,"tool_selectedcenter","Zoom in Selection","search-plus")+"",e+=s+this.setIcon(t,"alternate","Alternate the Structures by keying the letter 'a'","a",void 0,!0,!0)+"",e+=s+this.setIcon(t,"tool_resetOrientation","Reset Orientation","undo-alt")+"",e+=i+this.setIcon(t,"tool_proteinsRibbon","Style Ribbon for proteins","dna")+"",e+=s+this.setIcon(t,"tool_proteinsSphere","Style Sphere for proteins","volleyball-ball")+"",e+=s+this.setIcon(t,"tool_surfaceVDW","Show Van der Waals Surface","cloud")+"",e+=s+this.setIcon(t,"tool_bkgd","Toggle Background Color","adjust")+"",e+=i+this.setIcon(t,"tool_clrRainbowChain","Color Rainbow for Chains","rainbow")+"",e+=s+this.setIcon(t,"tool_clrSSGreen","Color by Secondary Structures","ring")+"",e+=s+this.setIcon(t,"tool_clrChain","Color by Chains","layer-group")+"",e+=s+this.setIcon(t,"tool_clrAtom","Color by Atoms","atom")+"",e+=i+this.setIcon(t,"tool_selectannotations","Sequences & Annotations","grip-lines")+"",e+=s+this.setIcon(t,"hbondsYes","Interactions","users")+"",e+=s+this.setIcon(t,"tool_delphi","Delphi Potentials","cloud-meatball")+"",e+=s+this.setIcon(t,"removeLabels","Remove Labels","remove-format")+"",e+=i+this.setIcon("link","tool-gallery","Gallery","image","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#gallery")+"",e+=s+this.setIcon("link","tool-video","Videos","file-video","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#videos")+"",e+=s+this.setIcon("link","tool-github","iCn3D GitHub","code","https://github.com/ncbi/icn3d")+"",e+=s+this.setIcon("link","tool-hints","Transform Hints","info-circle","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#useicn3d")+"",e+="",e}setTheme(e){let t,s,i,n,l,r=this.icn3dui;if(r.bNode)return"";r.htmlCls.themecolor=e,"orange"==e?(t="#e78f08",s="#f6a828",i="ui-bg_gloss-wave_35_f6a828_500x100.png",n="ui-icons_ef8c08_256x240.png",l="#eb8f00"):"black"==e?(t="#333333",s="#333333",i="ui-bg_gloss-wave_25_333333_500x100.png",n="ui-icons_222222_256x240.png",l="#222222"):"blue"==e&&(t="#4297d7",s="#5c9ccc",i="ui-bg_gloss-wave_55_5c9ccc_500x100.png",n="ui-icons_228ef1_256x240.png",l="#444"),$(".ui-widget-header").css({border:"1px solid "+t,background:s+' url("https://www.ncbi.nlm.nih.gov/Structure/icn3d/lib/images/'+i+'") 50% 50% repeat-x',color:"#fff","font-weight":"bold"}),$(".ui-button .ui-icon").css({"background-image":"url(https://www.ncbi.nlm.nih.gov/Structure/icn3d/lib/images/"+n+")"}),$(".ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited").css({color:l,"text-decoration":"none"})}setLogWindow(e,t){let s=this.icn3dui;if(s.bNode)return"";let i,n="",l=s.htmlCls.setHtmlCls.getCookie("cmdwindow");return""!=l?(i=void 0!==t?t:parseInt(l),1==i?(s.htmlCls.LOG_HEIGHT=180,s.htmlCls.CMD_HEIGHT=.8*s.htmlCls.LOG_HEIGHT,e||(n+=s.htmlCls.divStr+"cmdlog' style='float:left; margin-top: 5px; width: 100%;'>"),n+=""):(s.htmlCls.LOG_HEIGHT=65,s.htmlCls.CMD_HEIGHT=.8*s.htmlCls.LOG_HEIGHT,e||(n+=s.htmlCls.divStr+"cmdlog' style='float:left; margin-top: 5px; width: 100%;'>"),n+="")):(i=0,s.htmlCls.LOG_HEIGHT=65,s.htmlCls.CMD_HEIGHT=.8*s.htmlCls.LOG_HEIGHT,e||(n+=s.htmlCls.divStr+"cmdlog' style='float:left; margin-top: 5px; width: 100%;'>"),n+=""),e||(n+=""),e&&(s.htmlCls.clickMenuCls.setLogCmd("set cmdwindow "+i,!0),$("#"+s.pre+"cmdlog").html(n)),n}setMenu1(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
    ",t+="",t+="

    File

    ",t+="
    ",t+=this.setMenu1_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu1_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getMenuUrl("mn1_searchstru","https://www.ncbi.nlm.nih.gov/structure","Search Structure "+e.htmlCls.wifiStr,1,1),t+=this.getMenuText("mn1_searchsimilar","Search Similar",void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_vastplus","NCBI VAST+ (PDB Complex)"+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_vast","NCBI VAST (PDB Chain)"+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_foldseek","Foldseek (PDB & AlphaFold)"+e.htmlCls.wifiStr,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn1_retrievebyid","Retrieve by ID",void 0,1,1),t+="
        ",t+=this.getLink("mn1_mmdbafid","PDB/MMDB/AlphaFold IDs"+e.htmlCls.wifiStr,1,2),t+=this.getLink("mn1_mmdbid","NCBI MMDB ID (annotation) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_mmtfid","RCSB MMTF ID (fast) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_pdbid","RCSB PDB ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getMenuText("mn1_afwrap","AlphaFold Structures",void 0,void 0,2),t+="
          ",t+=this.getLink("mn1_afid","UniProt ID "+e.htmlCls.wifiStr,void 0,3),t+=this.getLink("mn1_refseqid","NCBI Protein Accession "+e.htmlCls.wifiStr,void 0,3),t+="
        ",t+=this.getLink("mn1_opmid","OPM PDB ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_mmcifid","RCSB mmCIF ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_cid","PubChem CID "+e.htmlCls.wifiStr,1,2),t+="
      ",t+="",t+=this.getMenuText("mn1_openfile","Open File",void 0,1,1),t+="
        ",t+=this.getLink("mn1_pdbfile_app","PDB Files (appendable)",1,2),t+=this.getLink("mn1_mmciffile","mmCIF File",void 0,2),t+=this.getLink("mn1_mol2file","Mol2 File",void 0,2),t+=this.getLink("mn1_sdffile","SDF File",void 0,2),t+=this.getLink("mn1_xyzfile","XYZ File",void 0,2),t+=this.getLink("mn1_afmapfile","AlphaFold PAE File",void 0,2),t+=this.getLink("mn1_urlfile","URL(CORS) "+e.htmlCls.wifiStr,void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_pngimage","iCn3D PNG Image",1,2),t+=this.getLink("mn1_state","State/Script File",void 0,2),t+=this.getLink("mn1_fixedversion","Share Link in Archived Ver. "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_selection","Selection File",void 0,2),t+=this.getMenuSep(),t+=this.getMenuText("mn1_dsn6wrap","Electron Density(DSN6)",void 0,void 0,2),t+="
          ",t+=this.getLink("mn1_dsn6","Local File",void 0,3),t+=this.getLink("mn1_dsn6url","URL(CORS) "+e.htmlCls.wifiStr,void 0,3),t+="
        ",t+="
      ",t+="",t+=this.getMenuText("mn1_alignwrap","Align",void 0,1,1),t+="
        ",t+=this.getMenuText("mn1_chainalignwrap","Multiple Chains",void 0,1,2),t+="
          ",t+=this.getRadio("mn1_chainalignRad","mn1_chainalign","by Structure Alignment "+e.htmlCls.wifiStr,void 0,1,3),t+=this.getRadio("mn1_chainalignRad","mn1_chainalign2","by Sequence Alignment "+e.htmlCls.wifiStr,void 0,1,3),t+=this.getRadio("mn1_chainalignRad","mn1_chainalign3","Residue by Residue",void 0,void 0,3),t+="
        ",t+="",t+=this.getMenuText("mn1_aligntwostru","Protein Complexes",void 0,void 0,2),t+="
          ",t+=this.getLink("mn1_align","Two PDB Structures "+e.htmlCls.wifiStr,void 0,3),t+=this.getLink("mn1_alignaf","Two AlphaFold Structures "+e.htmlCls.wifiStr,void 0,3),t+="
        ",t+=this.getLink("mn1_blast_rep_id","Sequence to Structure",void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_realignWrap","Realign Selection",void 0,void 0,1),t+="
        ",t+=this.getMenuText("mn2_chainrealignwrap","Multiple Chains",void 0,void 0,2),t+="
          ",t+=this.getRadio("mn2_realign","mn2_realignonstruct","by Structure Alignment "+e.htmlCls.wifiStr,void 0,void 0,3),t+=this.getRadio("mn2_realign","mn2_realignonseqalign","by Sequence Alignment "+e.htmlCls.wifiStr,void 0,void 0,3),t+=this.getRadio("mn2_realign","mn2_realignresbyres","Residue by Residue",void 0,void 0,3),t+="
        ",t+=this.getLink("mn2_realigntwostru","Protein Complexes",void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn1_3dpprint","3D Printing",void 0,1,1),t+="
        ",void 0===e.cfg.cid?(t+=this.getLink("mn1_exportVrmlStab","WRL/VRML(Color, W/ Stab.)",1,2),t+=this.getLink("mn1_exportStlStab","STL(W/ Stabilizers)",1,2),t+=this.getMenuSep(),t+=this.getLink("mn1_exportVrml","WRL/VRML(Color)",void 0,2),t+=this.getLink("mn1_exportStl","STL",void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_stabilizerYes","Add All Stabilizers",void 0,2),t+=this.getLink("mn1_stabilizerNo","Remove All Stabilizers",void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_stabilizerOne","Add One Stabilizer",void 0,2),t+=this.getLink("mn1_stabilizerRmOne","Remove One Stabilizer",void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_thicknessSet","Set Thickness",void 0,2)):(t+=this.getLink("mn1_exportVrml","VRML(Color)",1,2),t+=this.getLink("mn1_exportStl","STL",1,2)),t+="
      ",t+="",t+=this.getMenuText("mn1_savefile","Save File",void 0,1,1),t+="
        ",t+=this.getMenuText("mn1_savepngimage","iCn3D PNG Image",void 0,1,2),t+="
          ",t+=this.getLink("mn1_exportCanvas","Original Size & HTML",1,3),t+=this.getLink("mn1_exportCanvas1","Original Size",void 0,3),t+=this.getLink("mn1_exportCanvas2","2X Large",void 0,3),t+=this.getLink("mn1_exportCanvas4","4X Large",void 0,3),t+=this.getLink("mn1_exportCanvas8","8X Large",void 0,3),t+="
        ",t+="",t+=this.getLink("mn1_exportState","State File",void 0,2),t+=this.getLink("mn1_exportSelections","Selection File",void 0,2),t+=this.getLink("mn1_exportSelDetails","Selection Details",void 0,2),t+=this.getLink("mn1_exportCounts","Residue Counts",void 0,2),t+=this.getLink("mn1_exportPdbRes","PDB",1,2),t+=this.getLink("profixpdb","PDB with Missing Atoms",void 0,2),t+=this.getLink("profixpdbh","PDB with Hydrogens",void 0,2),void 0===e.cfg.cid&&(t+=this.getLink("mn1_exportSecondary","Secondary Structure",void 0,2)),t+="

      • ",t+="
      ",t+="",t+=this.getLink("mn1_sharelink","Share Link "+e.htmlCls.wifiStr,1,1),t+=this.getLink("mn1_replayon","Replay Each Step",void 0,1),t+=this.getMenuSep(),t+=this.getMenuText("mn1_menuwrap","Customize Menus",void 0,1,1),t+="
        ",t+=this.getLink("mn1_menuall","All Menus",1,2),t+=this.getLink("mn1_menusimple","Simple Menus",1,2),t+=this.getMenuSep(),t+=this.getLink("mn1_menupref","Preferences",1,2),t+=this.getLink("mn1_menuloadpref","Load Preferences",1,2),t+="
      ",t+="",t+="

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

    Select

    ",t+="
    ",t+=this.setMenu2_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu2_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getLink("mn2_definedsets","Defined Sets",1,1),t+=this.getLink("mn2_selectall","All",void 0,1),t+=this.getLink("mn2_selectdisplayed","Displayed Set",void 0,1),t+=this.getLink("mn2_aroundsphere","by Distance",1,1),t+=this.getMenuText("mn2_selbyprop","by Property",void 0,void 0,1),t+="
        ",t+=this.getLink("mn2_propPos","Positive",void 0,2),t+=this.getLink("mn2_propNeg","Negative",void 0,2),t+=this.getLink("mn2_propHydro","Hydrophobic",void 0,2),t+=this.getLink("mn2_propPolar","Polar",void 0,2),t+=this.getLink("mn2_propBfactor","B-factor/pLDDT",void 0,2),t+=this.getLink("mn2_propSolAcc","Solvent Accessibility",void 0,2),t+="
      ",t+="",t+=this.getLink("mn2_selectcomplement","Inverse",void 0,1),t+=this.getLink("mn2_selectmainchains","Main Chains",void 0,1),t+=this.getLink("mn2_selectsidechains","Side Chains",void 0,1),t+=this.getLink("mn2_selectmainsidechains","Main & Side Chains",void 0,1),t+=this.getLink("mn2_command","Advanced",void 0,1),void 0===e.cfg.cid?(t+=this.getMenuText("mn2_selon3d","Select on 3D",void 0,1,1),t+="
        ",t+='
      • "Alt"+Click: start selection
      • ',t+='
      • "Ctrl"+Click: union selection
      • ',t+='
      • "Shift"+Click: range Selection
      • ',t+=this.getMenuSep(),t+=this.getRadio("mn2_pk","mn2_pkChain","Chain",void 0,1,2),void 0===e.cfg.mmdbid&&void 0===e.cfg.gi||(t+=this.getRadio("mn2_pk","mn2_pkDomain","3D Domain",void 0,void 0,2)),t+=this.getRadio("mn2_pk","mn2_pkStrand","Strand/Helix",void 0,void 0,2),t+=this.getRadio("mn2_pk","mn2_pkResidue","Residue",!0,1,2),t+=this.getRadio("mn2_pk","mn2_pkYes","Atom",void 0,1,2),t+=this.getRadio("mn2_pk","mn2_pkNo","None",void 0,void 0,2),t+="
      ",t+=""):e.utilsCls.isMobile()?t+="
    • Touch to pick
    • ":t+='
    • Picking with
      "Alt" + Click
    • ',t+=this.getMenuSep(),t+=this.getLink("mn2_saveselection","Save Selection",1,1),t+=this.getLink("clearall","Clear Selection",void 0,1),t+=this.getLink("mn2_saveresidue","Save Res. in Sel.",1,1),t+=this.getMenuSep(),t+=this.getMenuText("mn2_hlcolor","Highlight Color",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn2_hl_clr","mn2_hl_clrYellow","Yellow",!0,void 0,2),t+=this.getRadio("mn2_hl_clr","mn2_hl_clrGreen","Green",void 0,void 0,2),t+=this.getRadio("mn2_hl_clr","mn2_hl_clrRed","Red",void 0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_hlstyle","Highlight Style",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn2_hl_style","mn2_hl_styleOutline","Outline",!0,void 0,2),t+=this.getRadio("mn2_hl_style","mn2_hl_styleObject","3D Objects",void 0,void 0,2),t+="
      ",t+="",t+=this.getLink("toggleHighlight2","Toggle Highlight",1,1),t+="

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

    View

    ",t+="
    ",t+=this.setMenu2b_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu2b_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getLink("mn2_show_selected","View Selection",1,1),t+=this.getLink("mn2_hide_selected","Hide Selection",1,1),t+=this.getLink("mn2_selectedcenter","Zoom in Selection",1,1),t+=this.getLink("mn6_center","Center Selection",1,1),t+=this.getLink("mn2_fullstru","View Full Structure"),t+=this.getLinkWrapper("mn2_alternate",'Alternate(Key "a")',"mn2_alternateWrap",void 0,1),void 0!==e.cfg.opmid?t+=this.getLinkWrapper("togglemem","Toggle Membrane","togglememli",void 0,1):void 0===e.cfg.cid&&(t+=this.getLinkWrapper("togglemem","Toggle Membrane","togglememli",void 0,1,!0)),void 0!==e.cfg.opmid&&(t+=this.getLinkWrapper("adjustmem","Adjust Membrane","adjustmemli",void 0,1),t+=this.getLinkWrapper("selectplane","Select between
      Two X-Y Planes","selectplaneli",void 0,1)),t+=this.getMenuSep(),t+=this.getMenuText("mn2_vrarhints","VR & AR Hints",void 0,1,1),t+="
        ",t+=this.getMenuUrl("vrhint",e.htmlCls.baseUrl+"icn3d/icn3d.html#vr","VR: VR Headsets",1,2),t+=this.getMenuUrl("arhint",e.htmlCls.baseUrl+"icn3d/icn3d.html#ar","AR: Chrome in Android",1,2),t+="
      ",t+="",t+=this.getLink("mn6_sidebyside","Side by Side",1,1),t+=this.getMenuText("mn2_rotate","Rotate",void 0,1,1),t+="
        ",t+=this.getMenuText("mn2_rotate90","Rotate 90°",void 0,void 0,2),t+="
          ",t+=this.getRadio("mn6_rotate90","mn6_rotatex","X-axis(Shift + Key M)",void 0,void 0,2),t+=this.getRadio("mn6_rotate90","mn6_rotatey","Y-axis(Shift + Key J)",void 0,void 0,2),t+=this.getRadio("mn6_rotate90","mn6_rotatez","Z-axis",void 0,void 0,2),t+="
        ",t+="",t+=this.getMenuText("mn2_rotateauto","Auto Rotation",void 0,1,2),t+="
          ",t+=this.getRadio("mn6_rotate","mn6_rotateleft","Rotate Left",void 0,1,3),t+=this.getRadio("mn6_rotate","mn6_rotateright","Rotate Right",void 0,1,3),t+=this.getRadio("mn6_rotate","mn6_rotateup","Rotate Up",void 0,1,3),t+=this.getRadio("mn6_rotate","mn6_rotatedown","Rotate Down",void 0,1,3),t+="
        ",t+="",t+="
      ",t+="",t+=this.getMenuText("mn2_camera","Camera",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_camera","mn6_cameraPers","Perspective",!0,void 0,2),t+=this.getRadio("mn6_camera","mn6_cameraOrth","Orthographic",void 0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_fog","Fog for Selection",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_showfog","mn6_showfogYes","On",void 0,void 0,2),t+=this.getRadio("mn6_showfog","mn6_showfogNo","Off",!0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_slab","Slab for Selection",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_showslab","mn6_showslabYes","On",void 0,void 0,2),t+=this.getRadio("mn6_showslab","mn6_showslabNo","Off",!0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_axes","XYZ-axes",void 0,1),t+="
        ",t+=this.getRadio("mn6_showaxis","mn6_showaxisYes","Original",void 0,void 0,2),t+=this.getRadio("mn6_showaxis","mn6_showaxisSel","Prin. Axes on Sel.",void 0,void 0,2),t+=this.getRadio("mn6_showaxis","mn6_showaxisNo","Hide",!0,void 0,2),t+="
      ",t+="",t+=this.getMenuSep(),t+=this.getMenuText("mn2_resetwrap","Reset",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_reset","reset","All",void 0,1,2),t+=this.getRadio("mn6_reset","mn6_resetOrientation","Orientation",void 0,1,2),t+="
      ",t+="",t+=this.getLink("mn6_back","Undo",void 0,1),t+=this.getLink("mn6_forward","Redo",void 0,1),t+=this.getLink("mn6_fullscreen","Full Screen",void 0,1),t+="

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

    Style

    ",t+="
    ",t+=this.setMenu3_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu3_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";t+="
      ",void 0===e.cfg.cid&&(t+=this.getMenuText("mn3_proteinwrap","Proteins",void 0,1,1),t+="
        ",void 0!==e.cfg.align||void 0!==e.cfg.chainalign?t+=this.getRadio("mn3_proteins","mn3_proteinsRibbon","Ribbon",void 0,1,2):t+=this.getRadio("mn3_proteins","mn3_proteinsRibbon","Ribbon",!0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsStrand","Strand",void 0,void 0,2),t+=this.getRadio("mn3_proteins","mn3_proteinsCylinder","Cylinder and Plate",void 0,void 0,2),t+=this.getRadio("mn3_proteins","mn3_proteinsSchematic","Schematic",void 0,1,2),void 0!==e.cfg.align||void 0!==e.cfg.chainalign?t+=this.getRadio("mn3_proteins","mn3_proteinsCalpha","C Alpha Trace",!0,1,2):t+=this.getRadio("mn3_proteins","mn3_proteinsCalpha","C Alpha Trace",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsBackbone","Backbone",void 0,void 0,2),t+=this.getRadio("mn3_proteins","mn3_proteinsBfactor","B-factor Tube",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsLines","Lines",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsStick","Stick",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsBallstick","Ball and Stick",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_sidecwrap","Side Chains",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_sidec","mn3_sidecLines","Lines",void 0,1,2),t+=this.getRadio("mn3_sidec","mn3_sidecStick","Stick",void 0,1,2),t+=this.getRadio("mn3_sidec","mn3_sidecBallstick","Ball and Stick",void 0,1,2),t+=this.getRadio("mn3_sidec","mn3_sidecSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_sidec","mn3_sidecNo","Hide",!0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_nuclwrap","Nucleotides",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_nucl","mn3_nuclCartoon","Cartoon",!0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclPhos","O3' Trace",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclBackbone","Backbone",void 0,void 0,2),t+=this.getRadio("mn3_nucl","mn3_nuclSchematic","Schematic",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclLines","Lines",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclStick","Stick",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclBallstick","Ball and Stick",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_ntbasewrap","Nucl. Bases",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_ntbase","mn3_ntbaseLines","Lines",void 0,1,2),t+=this.getRadio("mn3_ntbase","mn3_ntbaseStick","Stick",void 0,1,2),t+=this.getRadio("mn3_ntbase","mn3_ntbaseBallstick","Ball and Stick",void 0,1,2),t+=this.getRadio("mn3_ntbase","mn3_ntbaseSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_ntbase","mn3_ntbaseNo","Hide",!0,1,2),t+="
      ",t+=""),t+=this.getMenuText("mn3_ligwrap","Chemicals",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_lig","mn3_ligLines","Lines",void 0,1,2),void 0===e.cfg.cid?(t+=this.getRadio("mn3_lig","mn3_ligStick","Stick",!0,1,2),t+=this.getRadio("mn3_lig","mn3_ligBallstick","Ball and Stick",void 0,1,2)):(t+=this.getRadio("mn3_lig","mn3_ligStick","Stick",void 0,1,2),t+=this.getRadio("mn3_lig","mn3_ligBallstick","BalHydrogensl and Stick",!0,1,2)),t+=this.getRadio("mn3_lig","mn3_ligSchematic","Schematic",void 0,1,2),t+=this.getRadio("mn3_lig","mn3_ligSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_lig","mn3_ligNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_hydrogenswrap","Hydrogens",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_hydrogens","mn3_hydrogensYes","Show",!0,1,2),t+=this.getRadio("mn3_hydrogens","mn3_hydrogensNo","Hide",void 0,1,2),t+="
      ",t+="",void 0===e.cfg.cid&&(t+=this.getMenuText("mn3_glycanwrap","Glycans",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn3_glycansCart","mn3_glycansCartYes","Show Cartoon",void 0,void 0,2),t+=this.getRadio("mn3_glycansCart","mn3_glycansCartNo","Hide Cartoon",!0,void 0,2),t+="
      ",t+=""),t+=this.getMenuText("mn3_ionswrap","Ions",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_ions","mn3_ionsSphere","Sphere",!0,1,2),t+=this.getRadio("mn3_ions","mn3_ionsDot","Dot",void 0,1,2),t+=this.getRadio("mn3_ions","mn3_ionsNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_waterwrap","Water",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_water","mn3_waterSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_water","mn3_waterDot","Dot",void 0,1,2),t+=this.getRadio("mn3_water","mn3_waterNo","Hide",!0,1,2),t+="
      ",t+="",t+=this.getLink("mn3_setThickness","Preferences",void 0,1),t+=this.getMenuSep(),t+=this.getLink("mn3_styleSave","Save Style",void 0,2),t+=this.getLink("mn3_styleApplySave","Apply Saved Style",void 0,2),t+=this.getMenuSep(),t+=this.getMenuText("mn5_surfacewrap","Surface Type",void 0,1,1),t+="
        ",t+=this.getRadio("mn5_surface","mn5_surfaceVDW","Van der Waals",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceVDWContext","VDW with Context",void 0,void 0,2),t+=this.getRadio("mn5_surface","mn5_surfaceMolecular","Molecular Surface",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceMolecularContext","MS with Context",void 0,void 0,2),t+=this.getRadio("mn5_surface","mn5_surfaceSAS","Solvent Accessible",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceSASContext","SA with Context",void 0,void 0,2),t+="
      ",t+="",t+=this.getLink("mn5_surfaceNo","Remove Surface",1,1),t+=this.getMenuText("mn5_surfaceop","Surface Opacity",void 0,1,1),t+="
        ",t+=this.getMenuText("mn5_surfaceopfast","Fast Transparency",void 0,1,2),t+="
          ",t+=this.getRadio("mn5_opacity","mn5_opacity10","1.0",!0,1,3);for(let e=9;e>0;--e)t+=this.getRadio("mn5_opacity","mn5_opacity0"+e,"0."+e,1,3);t+="
        ",t+="",t+=this.getMenuText("mn5_surfaceopslow","Slow Transparency",void 0,void 0,2),t+="
          ",t+=this.getRadio("mn5_opacityslow","mn5_opacityslow10","1.0",!0,void 0,3);for(let e=9;e>0;--e)t+=this.getRadio("mn5_opacityslow","mn5_opacityslow0"+e,"0."+e,void 0,void 0,3);return t+="
        ",t+="",t+="
      ",t+=this.getMenuText("mn5_wireframewrap","Surface Wireframe",void 0,1,1),t+="
        ",t+=this.getRadio("mn5_wireframe","mn5_wireframeYes","Yes",void 0,1,2),t+=this.getRadio("mn5_wireframe","mn5_wireframeNo","No",!0,1,2),t+="
      ",t+="",t+=this.getMenuSep(),t+=this.getLink("mn5_cartoonshape","Cartoon for a Set",void 0,1),t+=this.getLink("mn5_linebtwsets","Line btw. Two Sets",void 0,1),void 0===e.cfg.cid&&void 0===e.cfg.align&&void 0===e.cfg.chainalign&&void 0===e.cfg.mmdbaf&&(t+=this.getMenuSep(),t+=this.getLinkWrapper2("mn5_map","Electron Density","mapWrapper1",void 0,1),t+="
        ",t+=this.getLink("mn5_elecmap2fofc","2Fo-Fc Map",void 0,2),t+=this.getLink("mn5_elecmapfofc","Fo-Fc Map",void 0,2),t+=this.getLinkWrapper("mn5_elecmapNo","Remove Map","mapWrapper2",void 0,2),t+="
      ",t+="",t+=this.getLinkWrapper2("mn5_map3","Map Wireframe","mapWrapper3",void 0,1),t+="
        ",t+=this.getRadio("mn5_mapwireframe","mn5_mapwireframeYes","Yes",!0,void 0,2),t+=this.getRadio("mn5_mapwireframe","mn5_mapwireframeNo","No",void 0,void 0,2),t+="
      ",t+="",void 0===e.cfg.mmtfid&&(t+=this.getLinkWrapper("mn5_emmap","EM Density Map","emmapWrapper1",void 0,1),t+=this.getLinkWrapper("mn5_emmapNo","Remove EM Map","emmapWrapper2",void 0,1),t+=this.getLinkWrapper2("mn5_emmap3","EM Map Wireframe","emmapWrapper3",void 0,1),t+="
        ",t+=this.getRadio("mn5_emmapwireframe","mn5_emmapwireframeYes","Yes",!0,void 0,2),t+=this.getRadio("mn5_emmapwireframe","mn5_emmapwireframeNo","No",void 0,void 0,2),t+="
      ",t+="")),t+=this.getMenuSep(),t+=this.getMenuText("mn6_bkgdwrap","Background",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_bkgd","mn6_bkgdTransparent","Transparent",void 0,1,2),t+=this.getRadio("mn6_bkgd","mn6_bkgdBlack","Black",!0,1,2),t+=this.getRadio("mn6_bkgd","mn6_bkgdGrey","Gray",void 0,1,2),t+=this.getRadio("mn6_bkgd","mn6_bkgdWhite","White",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn6_themewrap","Dialog Color",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_theme","mn6_themeBlue","Blue",!0,void 0,2),t+=this.getRadio("mn6_theme","mn6_themeOrange","Orange",void 0,void 0,2),t+=this.getRadio("mn6_theme","mn6_themeBlack","Black",void 0,void 0,2),t+="
      ",t+="",t+="

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

    Color

    ",t+="
    ",t+=this.setMenu4_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu4_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getMenuText("mn4_clrwrap","Unicolor","icn3d-menupd",1,1),t+="
        ",t+=this.getMenuText("uniclrRedwrap","Red",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrRed1","Red","F00",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed2","Indian Red","CD5C5C",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed3","Light Coral","F08080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed4","Salmon","FA8072",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed5","Dark Salmon","E9967A",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed6","Light Salmon","FFA07A",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed7","Crimson","DC143C",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed8","Fire Brick","B22222",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed9","Dark Red","8B0000",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrPinkwrap","Pink",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrPink1","Pink","FFC0CB",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink2","Light Pink","FFB6C1",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink3","Hot Pink","FF69B4",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink4","Deep Pink","FF1493",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink5","Medium Violet Red","C71585",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink6","Pale Violet Red","DB7093",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrOrangewrap","Orange",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrOran1","Orange","FFA500",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran2","Dark Orange","FF8C00",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran3","Orange Red","FF4500",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran4","Tomato","FF6347",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran5","Coral","FF7F50",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran6","Light Salmon","FFA07A",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrYellowwrap","Yellow",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrYllw1","Yellow","FF0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw2","Gold","FFD700",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw3","Light Yellow","FFFFE0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw4","Lemon Chiffon","FFFACD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw5","Light Golden Rod","FAFAD2",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw6","Papaya Whip","FFEFD5",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw7","Moccasin","FFE4B5",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw8","Peach Puff","FFDAB9",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw9","Pale Golden Rod","EEE8AA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw10","Khaki","F0E68C",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw11","Dark Khaki","BDB76B",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrMagentawrap","Magenta",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrMgnt1","Magenta","F0F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt2","Orchid","DA70D6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt3","Violet","EE82EE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt4","Plum","DDA0DD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt5","Thistle","D8BFD8",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt6","Lavender","E6E6FA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt7","Medium Orchid","BA55D3",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt8","Medium Purple","9370DB",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt9","Rebecca Purple","663399",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt10","Blue Violet","8A2BE2",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt11","Dark Violet","9400D3",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt12","Dark Orchid","9932CC",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt13","Dark Magenta","8B008B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt14","Purple","800080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt15","Indigo","4B0082",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt16","Slat Blue","6A5ACD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt17","Dark Slate Blue","483D8B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt18","Medium Slat Blue","6A5ACD",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrGreenwrap","Green",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrGrn1","Green","0F0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn2","Dark Green","006400",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn3","Yellow Green","9ACD32",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn4","Olive Drab","6B8E23",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn5","Olive","808000",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn6","Dark Olive Green","556B2F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn7","Medium Aquamarine","66CDAA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn8","Dark Sea Green","8FBC8B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn9","Lignt Sea Green","20B2AA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn10","Dark Cyan","008B8B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn11","Teal","008080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn12","Forest Green","228B22",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn13","Sea Green","2E8B57",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn14","Medium Sea Green","3CB371",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn15","Spring Green","00FF7F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn16","Medium Spring","00FA9A",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn17","Light Green","90EE90",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn18","Pale Green","98FB98",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn19","Lime Green","32CD32",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn20","Lawn Green","7CFC00",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn21","Chartreuse","7FFF00",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn22","Green Yellow","ADFF2F",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrCyanwrap","Cyan",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrCyan1","Cyan","0FF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan2","Light Cyan","E0FFFF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan3","Pale Turquoise","AFEEEE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan4","Aquamarine","7FFFD4",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan5","Turquoise","40E0D0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan6","Medium Turquoise","48D1CC",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan7","Dark Turquoise","00CED1",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrBluewrap","Blue",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrBlue1","Blue","00F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue2","Medium Blue","0000CD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue3","Dark Blue","00008B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue4","Navy","000080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue5","Midnight Blue","191970",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue6","Royal Blue","4169E1",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue7","Medium Slate Blue","7B68EE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue8","Corn Flower Blue","6495ED",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue9","Dodger Blue","1E90FF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue10","Deep Sky Blue","00BFFF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue11","Light Sky Blue","87CEFA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue12","Sky Blue","87CEEB",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue13","Light Blue","ADD8E6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue14","Powder Blue","B0E0E6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue15","Light Steel Blue","B0C4DE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue16","Steel Blue","4682B4",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue17","Cadet Blue","5F9EA0",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrBrownwrap","Brown",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrBrown1","Brown","A52A2A",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown2","Maroon","800000",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown3","Sienna","A0522D",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown4","Saddle Brown","8B4513",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown5","Chocolate","D2691E",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown6","Peru","CD853F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown7","Dark Golden Rod","B8860B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown8","Golden Rod","DAA520",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown9","Sandy Brown","F4A460",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown10","Rosy Brown","BC8F8F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown11","Tan","D2B48C",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown12","Burlywood","DEB887",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown13","Wheat","F5DEB3",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown14","Navajo White","FFDEAD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown15","Bisque","FFE4C4",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown16","Blanched Almond","FFEBCD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown17","Corn Silk","FFF8DC",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrWhitewrap","White",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrWhite1","White","FFF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite2","Snow","FFFAFA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite3","Honey Dew","F0FFF0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite4","Mint Cream","F5FFFA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite5","Azure","F0FFFF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite6","Alice Blue","F0F8FF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite7","Ghost White","F8F8FF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite8","White Smoke","F5F5F5",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite9","Sea Shell","FFF5EE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite10","Beige","F5F5DC",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite11","Old Lace","FDF5E6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite12","Floral White","FFFAF0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite13","Ivory","FFFFF0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite14","Antique White","FAEBD7",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite15","Linen","FAF0E6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite16","Lavenderblush","FFF0F5",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite17","Misty Rose","FFE4E1",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrGraywrap","Gray",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrGray1","Gray","808080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray2","Dim Gray","696969",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray3","Light Slate Gray","778899",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray4","Slate Gray","708090",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray5","Dark Slate Gray","2F4F4F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray6","Black","000000",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray7","Dark Gray","A9A9A9",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray8","Silver","C0C0C0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray9","Light Gray","D3D3D3",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray10","Gainsboro","DCDCDC",void 0,1,3),t+="
        ",t+="
      ",t+=this.getRadio("mn4_clr","mn4_clrCustom","Color Picker",void 0,void 0,1),t+=this.getMenuSep(),void 0===e.cfg.cid?(t+=this.getMenuText("mn4_clrRainbowwrap","Rainbow (R-V)","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrRainbow","for Selection",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrRainbowChain","for Chains",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrRainbowSets","for Sets",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrRainbowAcrossSets","across Sets",void 0,void 0,2),t+="
      ",t+=this.getMenuText("mn4_clrSpectrumwrap","Spectrum (V-R)","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrSpectrum","for Selection",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSpectrumChain","for Chains",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSpectrumSets","for Sets",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrSpectrumAcrossSets","across Sets",void 0,void 0,2),t+="
      ",t+=this.getMenuText("mn4_clrSSwrap","Secondary","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrSSGreen","Sheet in Green",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSSYellow","Sheet in Yellow",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSSSpectrum","Spectrum",void 0,void 0,2),t+="
      ",t+=this.getRadio("mn4_clr","mn4_clrCharge","Charge",void 0,1,1),t+=this.getMenuText("mn4_hydrophobicwrap","Hydrophobicity","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrNormalizedHP","Normalized",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrHydrophobic","Wimley-White",void 0,void 0,2),t+="
      ",t+=this.getMenuText("mn4_clrBfactorwrap","B-factor","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrBfactor","Original",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrBfactorNorm","Percentile",void 0,1,2),t+="
      ",t+=this.getRadio("mn4_clr","mn4_clrArea",'Solvent
      Accessibility',void 0,void 0,1),t+=this.getRadio("mn4_clr","mn4_clrStructure","Structure",void 0,1,1),void 0!==e.cfg.align||void 0!==e.cfg.chainalign||void 0!==e.cfg.blast_rep_id?t+=this.getRadio("mn4_clr","mn4_clrChain","Chain",void 0,1,1):t+=this.getRadio("mn4_clr","mn4_clrChain","Chain",!0,1,1),t+=this.getRadio("mn4_clr","mn4_clrdomain","3D Domain",void 0,void 0,1),void 0===e.cfg.cid&&(t+=this.getMenuText("mn4_clrsetswrap","Defined Sets","icn3d-menupd",void 0,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrsets",'Rainbow for Selected Sets
        in "Analysis > Defined Sets"',void 0,void 0,2),t+="
      ",t+=""),t+=this.getMenuText("mn4_clrResiduewrap","Residue","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrResidue","Default",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrResidueCustom","Custom",void 0,void 0,2),t+="
      ",t+=this.getRadio("mn4_clr","mn4_clrAtom","Atom",void 0,1,1),void 0!==e.cfg.align||void 0!==e.cfg.chainalign?(t+=this.getRadio("mn4_clr","mn4_clrIdentity","Identity",!0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrConserved","Conservation",void 0,void 0,2)):void 0!==e.cfg.blast_rep_id?(t+=this.getRadio("mn4_clr","mn4_clrIdentity","Identity",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrConserved","Conservation",!0,void 0,2)):(t+=this.getRadio("mn4_clr","mn4_clrIdentity","Identity",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrConserved","Conservation",void 0,void 0,2)),t+=this.getRadio("mn4_clr","mn4_clrConfidence",'AlphaFold
      Confidence',void 0,1,1)):t+=this.getRadio("mn4_clr","mn4_clrAtom","Atom",!0,1,1),t+=this.getMenuSep(),t+=this.getLink("mn4_clrSave","Save Color",void 0,1),t+=this.getLink("mn4_clrApplySave","Apply Saved Color",void 0,1),t+="

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

     Analysis

    ",t+="
    ",t+=this.setMenu5_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu5_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";t+="
      ",void 0===e.cfg.cid&&(t+=this.getLink("mn6_selectannotations","Seq. & Annotations "+e.htmlCls.wifiStr,1,1),t+=this.getLink("mn2_alignment","Aligned Seq. "+e.htmlCls.wifiStr,void 0,1),void 0===e.cfg.mmdbid&&void 0===e.cfg.gi&&void 0===e.cfg.blast_rep_id&&void 0===e.cfg.align&&void 0===e.cfg.chainalign||(t+=this.getLink("mn2_2ddgm","2D Diagram "+e.htmlCls.wifiStr,1,1)),t+=this.getMenuText("2dctnwrap","2D Cartoon",void 0,void 0,1),t+="
        ",t+=this.getLink("2dctn_chain","Chain Level",void 0,2),t+=this.getLink("2dctn_domain","Domain Level",void 0,2),t+=this.getLink("2dctn_secondary","Helix/Sheet Level",void 0,2),t+="
      ",t+="",t+=this.getLink("definedsets2","Defined Sets",1,1),t+=this.getMenuSep(),t+=this.getLink("mn6_hbondsYes","Interactions",1,1),t+=this.getMenuText("mn1_window","Bring to Front",void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_window_table","Interaction Table",void 0,2),t+=this.getLink("mn1_window_linegraph","2D Interaction Network",void 0,2),t+=this.getLink("mn1_window_scatterplot","2D Interaction Map",void 0,2),t+=this.getLink("mn1_window_graph","2D Graph(Force-Directed)",void 0,2),t+="
      ",t+="",t+=this.getLink("mn6_contactmap","Contact Map",void 0,1),e.cfg.notebook||(t+=this.getLink("mn1_mutation","Mutation "+e.htmlCls.wifiStr,1,1))),e.cfg.notebook||e.cfg.hidelicense||(t+=this.getMenuText("mn1_delphiwrap","DelPhi Potential",void 0,1,1),t+="
        ",t+=this.getLink("mn1_delphi","DelPhi Potential "+e.htmlCls.licenseStr,1,2),t+=this.getMenuText("mn1_phiwrap","Load PQR/Phi",void 0,void 0,2),t+="
          ",t+=this.getLink("mn1_phi","Local PQR/Phi/Cube File",void 0,3),t+=this.getLink("mn1_phiurl","URL PQR/Phi/Cube File",void 0,3),t+="
        ",t+="",t+=this.getLink("delphipqr","Download PQR",void 0,2),t+="
      ",t+=""),t+=this.getMenuSep(),t+=this.getMenuText("mn6_distancewrap","Distance",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_distance","mn6_distanceYes","between Two Atoms",void 0,1,2),t+=this.getRadio("mn6_distance","mn6_distTwoSets","between Two Sets",void 0,void 0,2),t+=this.getRadio("mn6_distance","mn6_distManySets","Among Many Sets",void 0,void 0,2),t+=this.getRadio("mn6_distance","mn6_distanceNo","Hide",!0,1,2),t+="
      ",t+="",t+=this.getLink("mn6_area","Surface Area",1,1),t+=this.getMenuText("mn6_addlabelwrap","Label",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_addlabel","mn6_addlabelYes","by Picking Atoms",void 0,void 0,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelSelection","per Selection",void 0,void 0,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelAtoms","per Atom",void 0,void 0,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelElements","per Atom Element",void 0,1,2),void 0===e.cfg.cid&&(t+=this.getRadio("mn6_addlabel","mn6_addlabelResidues","per Residue",void 0,1,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelResnum","per Residue & Number",void 0,1,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelChains","per Chain",void 0,void 0,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelTermini","N- & C-Termini",void 0,1,2)),t+=this.getMenuSep(),t+=this.getRadio("mn6_addlabel","mn6_labelColor","Change Label Color",void 0,1,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelNo","Remove",!0,1,2),t+="
      ",t+="",t+=this.getMenuText("labelscalewrap","Label Scale",void 0,1,1),t+="
        ";for(let e=1;e<=4;++e){let s=2*e;t+=this.getRadio("mn6_labelscale","mn6_labelscale0"+s,"0."+s,void 0,1,2)}for(let e=1;e<=5;++e)t+=1==e?this.getRadio("mn6_labelscale","mn6_labelscale"+e+"0",e+".0",!0,1,2):this.getRadio("mn6_labelscale","mn6_labelscale"+e+"0",e+".0",void 0,1,2);if(t+="
      ",t+="",t+=this.getMenuSep(),void 0===e.cfg.cid){t+=this.getMenuText("mn6_chemicalbindingwrap","Chem. Binding",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_chemicalbinding","mn6_chemicalbindingshow","Show",void 0,void 0,2),t+=this.getRadio("mn6_chemicalbinding","mn6_chemicalbindinghide","Hide",!0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn6_ssbondswrap","Disulfide Bonds",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_ssbonds","mn6_ssbondsYes","Show",!0,1,2),t+=this.getRadio("mn6_ssbonds","mn6_ssbondsExport","Export Pairs",void 0,void 0,2),t+=this.getRadio("mn6_ssbonds","mn6_ssbondsNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn6_clbondswrap","Cross-Linkages",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_clbonds","mn6_clbondsYes","Show",!0,void 0,2),t+=this.getRadio("mn6_clbonds","mn6_clbondsExport","Export Pairs",void 0,void 0,2),t+=this.getRadio("mn6_clbonds","mn6_clbondsNo","Hide",void 0,void 0,2),t+="
      ",t+="";let s=void 0!==e.cfg.mmtfid||void 0!==e.cfg.pdbid||void 0!==e.cfg.opmid||void 0!==e.cfg.mmcifid||void 0!==e.cfg.mmdbid||void 0!==e.cfg.mmdbafid||void 0!==e.cfg.gi||void 0!==e.cfg.blast_rep_id;s&&(t+=this.getMenuText("assemblyWrapper","Assembly",void 0,1,1),t+="
        ",e.cfg.bu?(t+=this.getRadio("mn6_assembly","mn6_assemblyYes","Biological Assembly",!0,1,2),t+=this.getRadio("mn6_assembly","mn6_assemblyNo","Asymmetric Unit",void 0,1,2)):(t+=this.getRadio("mn6_assembly","mn6_assemblyYes","Biological Assembly",void 0,1,2),t+=this.getRadio("mn6_assembly","mn6_assemblyNo","Asymmetric Unit",!0,1,2)),t+="
      ",t+=""),t+=this.getMenuText("mn6_symmetrywrap","Symmetry",void 0,void 0,1),t+="
        ",s&&(t+=this.getLink("mn6_symmetry","from PDB(precalculated) "+e.htmlCls.wifiStr,void 0,2)),t+=this.getLink("mn6_symd","from SymD(Dynamic) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn6_clear_sym","Clear SymD Symmetry",void 0,2),t+=this.getLink("mn6_axes_only","Show Axes Only",void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn6_igrefwrap","Ref. Number",void 0,void 0,1),t+="
        ",t+=this.getLink("mn6_customref","Custom Ref. Number",void 0,2),t+="
      ",t+="",t+=this.getMenuSep()}return t+=this.getLink("mn6_yournote","Window Title",void 0,1),void 0!==e.cfg.cid?(t+=this.getMenuText("mn1_linkwrap","Links",void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_link_structure","Compound Summary "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_vast","Similar Compounds "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_bind","Structures Bound "+e.htmlCls.wifiStr,void 0,2),t+="
      ",t+=""):(t+=this.getMenuText("mn1_linkwrap","Links",void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_link_structure","Structure Summary "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_vast","Similar Structures "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_pubmed","Literature "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_protein","Protein "+e.htmlCls.wifiStr,void 0,2),t+="
      ",t+=""),t+="

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

    Help

    ",t+="
    ",t+=this.setMenu6_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu6_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getMenuUrl("abouticn3d",e.htmlCls.baseUrl+"icn3d/icn3d.html#about","About iCn3D "+e.REVISION+"",1,1),t+=this.getMenuUrl("gallery",e.htmlCls.baseUrl+"icn3d/icn3d.html#gallery","Live Gallery "+e.htmlCls.wifiStr,1,1),t+=this.getMenuUrl("video",e.htmlCls.baseUrl+"icn3d/icn3d.html#videos","iCn3D Videos",1,1),t+=this.getMenuText("mn6_faq","FAQ",void 0,1,1),t+="
        ",t+=this.getMenuUrl("faq_viewstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#viewstru","View structure",1,2),t+=this.getMenuUrl("faq_tfstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#tfstru","Transform Structure",1,2),t+=this.getMenuUrl("faq_selsubset",e.htmlCls.baseUrl+"icn3d/icn3d.html#selsubset","Select Subsets",1,2),t+=this.getMenuUrl("faq_stylecolor",e.htmlCls.baseUrl+"icn3d/icn3d.html#changestylecolor","Change Style/Color",1,2),t+=this.getMenuUrl("faq_savework",e.htmlCls.baseUrl+"icn3d/icn3d.html#saveview","Save Work",1,2),t+=this.getMenuUrl("faq_showanno",e.htmlCls.baseUrl+"icn3d/icn3d.html#showanno","Show Annotations",1,2),t+=this.getMenuUrl("faq_exportanno",e.htmlCls.baseUrl+"icn3d/icn3d.html#exportanno","Export Annotations",1,2),t+=this.getMenuUrl("faq_interanal",e.htmlCls.baseUrl+"icn3d/icn3d.html#interanalysis","Interaction Analysis",1,2),t+=this.getMenuUrl("faq_mutanal",e.htmlCls.baseUrl+"icn3d/icn3d.html#mutationanalysis","Mutation Analysis",1,2),t+=this.getMenuUrl("faq_elecpot",e.htmlCls.baseUrl+"icn3d/icn3d.html#elecpot","Electrostatic Pot.",1,2),t+=this.getMenuUrl("faq_simipdb",e.htmlCls.baseUrl+"icn3d/icn3d.html#simivast","Similar PDB",1,2),t+=this.getMenuUrl("faq_simialphapdb",e.htmlCls.baseUrl+"icn3d/icn3d.html#simifoldseek","Similar AlphaFold/PDB",1,2),t+=this.getMenuUrl("faq_alnstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#alignmul","Align Multiple Structures",1,2),t+=this.getMenuUrl("faq_batchanal",e.htmlCls.baseUrl+"icn3d/icn3d.html#batchanalysis","Batch Analysis",1,2),t+=this.getMenuUrl("faq_embedicn3d",e.htmlCls.baseUrl+"icn3d/icn3d.html#embedicn3d","Embed iCn3D",1,2),t+="
      ",t+="",t+=this.getMenuUrl("citing",e.htmlCls.baseUrl+"icn3d/icn3d.html#citing","Citing iCn3D",void 0,1),t+=this.getMenuText("mn6_source","Source Code",void 0,1,1),t+="
        ",t+=this.getMenuUrl("github","https://github.com/ncbi/icn3d","GitHub (browser) "+e.htmlCls.wifiStr,1,2),t+=this.getMenuUrl("npm","https://www.npmjs.com/package/icn3d","npm (Node.js) "+e.htmlCls.wifiStr,1,2),t+=this.getMenuUrl("notebook","https://pypi.org/project/icn3dpy","Jupyter Notebook "+e.htmlCls.wifiStr,1,2),t+="
      ",t+="",t+=this.getMenuText("mn6_develop","Develop",void 0,void 0,1),t+="
        ",t+=this.getMenuUrl("dev_embedicn3d2",e.htmlCls.baseUrl+"icn3d/icn3d.html#HowToUse","Embed iCn3D",void 0,2),t+=this.getMenuUrl("dev_urlpara",e.htmlCls.baseUrl+"icn3d/icn3d.html#parameters","URL Parameters",void 0,2),t+=this.getMenuUrl("dev_command",e.htmlCls.baseUrl+"icn3d/icn3d.html#commands","Commands",void 0,2),t+=this.getMenuUrl("dev_datastru",e.htmlCls.baseUrl+"icn3d/icn3d.html#datastructure","Data Structure",void 0,2),t+=this.getMenuUrl("dev_classstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#classstructure","Class Structure",void 0,2),t+=this.getMenuUrl("dev_addclass",e.htmlCls.baseUrl+"icn3d/icn3d.html#addclass","Add New Classes",void 0,2),t+=this.getMenuUrl("dev_modfunc",e.htmlCls.baseUrl+"icn3d/icn3d.html#modifyfunction","Modify Functions",void 0,2),t+=this.getMenuUrl("dev_restful",e.htmlCls.baseUrl+"icn3d/icn3d.html#restfulapi","RESTful APIs",void 0,2),t+=this.getMenuUrl("dev_contributor",e.htmlCls.baseUrl+"icn3d/icn3d.html#contributors","iCn3D Contributors",void 0,2),t+="
      ",t+="",t+=this.getMenuUrl("helpdoc",e.htmlCls.baseUrl+"icn3d/docs/icn3d_help.html","Help Doc "+e.htmlCls.wifiStr,1,1),t+=this.getMenuSep(),t+=this.getMenuText("mn6_tfhint","Transform Hints",void 0,1,1),t+="
        ",t+=this.getMenuText("mn6_rotate","Rotate",void 0,1,2),t+="
          ",t+="
        • Left Mouse (Click & Drag)
        • ",t+="
        • Key l: Left
        • ",t+="
        • Key j: Right
        • ",t+="
        • Key i: Up
        • ",t+="
        • Key m: Down
        • ",t+="
        • Shift + Key l: Left 90°
        • ",t+="
        • Shift + Key j: Right 90°
        • ",t+="
        • Shift + Key i: Up 90°
        • ",t+="
        • Shift + Key m: Down 90°
        • ",t+="
        ",t+="",t+=this.getMenuText("mn6_zoom","Zoom",void 0,1,2),t+="
          ",t+="
        • Middle Mouse
          (Pinch & Spread)
        • ",t+="
        • Key z: Zoom in
        • ",t+="
        • Key x: Zoom out
        • ",t+="
        ",t+="",t+=this.getMenuText("mn6_translate","Translate",void 0,1,2),t+="
          ",t+="
        • Right Mouse
          (Two Finger Click & Drag)
        • ",t+="
        ",t+="",t+="
      ",t+="",t+=this.getMenuUrl("selhints",e.htmlCls.baseUrl+"icn3d/icn3d.html#selsubset","Selection Hints",void 0,1),t+=this.getMenuUrl("helpdesk","https://support.nlm.nih.gov/support/create-case/","Write to Help Desk",1,1),t+="

    • ",t+="
    ",t}hideMenu(){let e=this.icn3dui;e.bNode||(void 0!==$("#"+e.pre+"mnlist")[0]&&($("#"+e.pre+"mnlist")[0].style.display="none"),void 0!==$("#"+e.pre+"mnLogSection")[0]&&($("#"+e.pre+"mnLogSection")[0].style.display="none"),void 0!==$("#"+e.pre+"cmdlog")[0]&&($("#"+e.pre+"cmdlog")[0].style.display="none"),$("#"+e.pre+"title")[0].style.margin="10px 0 0 10px")}showMenu(){let e=this.icn3dui;e.bNode||(void 0!==$("#"+e.pre+"mnlist")[0]&&($("#"+e.pre+"mnlist")[0].style.display="block"),void 0!==$("#"+e.pre+"mnLogSection")[0]&&($("#"+e.pre+"mnLogSection")[0].style.display="block"),void 0!==$("#"+e.pre+"cmdlog")[0]&&($("#"+e.pre+"cmdlog")[0].style.display="block"))}}class c{constructor(e){this.icn3dui=e}openDlg(e,t){let s=this.icn3dui;s.icn3d,s.bNode||(e=s.pre+e,s.cfg.notebook?this.openDlgNotebook(e,t):this.openDlgRegular(e,t),s.htmlCls.themecolor||(s.htmlCls.themecolor="blue"),s.htmlCls.setMenuCls.setTheme(s.htmlCls.themecolor))}addSaveButton(e){let t=this.icn3dui;t.icn3d,t.bNode||void 0!==this.dialogHashSave&&this.dialogHashSave.hasOwnProperty(e)||($("#"+e).parent().children(".ui-dialog-titlebar").append("
    "),void 0===this.dialogHashSave&&(this.dialogHashSave={}),this.dialogHashSave[e]=1)}addHideButton(e){let t=this.icn3dui;t.icn3d,t.bNode||void 0!==this.dialogHashHide&&this.dialogHashHide.hasOwnProperty(e)||($("#"+e).parent().children(".ui-dialog-titlebar").append("
    "),void 0===this.dialogHashHide&&(this.dialogHashHide={}),this.dialogHashHide[e]=1)}getDialogStatus(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t={},s={},i=$("#"+e.pre+"dl_selectannotations").hasClass("ui-dialog-content"),n=$("#"+e.pre+"dl_graph").hasClass("ui-dialog-content"),l=$("#"+e.pre+"dl_linegraph").hasClass("ui-dialog-content"),r=$("#"+e.pre+"dl_scatterplot").hasClass("ui-dialog-content"),o=$("#"+e.pre+"dl_contactmap").hasClass("ui-dialog-content"),a=$("#"+e.pre+"dl_alignerrormap").hasClass("ui-dialog-content"),d=$("#"+e.pre+"dl_interactionsorted").hasClass("ui-dialog-content"),c=$("#"+e.pre+"dl_alignment").hasClass("ui-dialog-content"),h=$("#"+e.pre+"dl_2ddgm").hasClass("ui-dialog-content"),p=$("#"+e.pre+"dl_2dctn").hasClass("ui-dialog-content"),m=$("#"+e.pre+"dl_definedsets").hasClass("ui-dialog-content");return t.bSelectannotationsInit2=!1,t.bGraph2=!1,t.bLineGraph2=!1,t.bScatterplot2=!1,t.bTable2=!1,t.bAlignmentInit2=!1,t.bTwoddgmInit2=!1,t.bTwodctnInit2=!1,t.bSetsInit2=!1,s.dl_selectannotations="bSelectannotationsInit2",s.dl_graph="bGraph2",s.dl_linegraph="bLineGraph2",s.dl_scatterplot="bScatterplot2",s.dl_contactmap="bContactmap2",s.dl_alignerrormap="bAlignerrormap2",s.dl_interactionsorted="bTable2",s.dl_alignment="bAlignmentInit2",s.dl_2ddgm="bTwoddgmInit2",s.dl_2dctn="bTwodctnInit2",s.dl_definedsets="bSetsInit2",i&&(t.bSelectannotationsInit2=$("#"+e.pre+"dl_selectannotations").dialog("isOpen")),n&&(t.bGraph2=$("#"+e.pre+"dl_graph").dialog("isOpen")),l&&(t.bLineGraph2=$("#"+e.pre+"dl_linegraph").dialog("isOpen")),r&&(t.bScatterplot2=$("#"+e.pre+"dl_scatterplot").dialog("isOpen")),o&&(t.bContactmap2=$("#"+e.pre+"dl_contactmap").dialog("isOpen")),a&&(t.bAlignerror2=$("#"+e.pre+"dl_alignerrormap").dialog("isOpen")),d&&(t.bTable2=$("#"+e.pre+"dl_interactionsorted").dialog("isOpen")),c&&(t.bAlignmentInit2=$("#"+e.pre+"dl_alignment").dialog("isOpen")),h&&(t.bTwoddgmInit2=$("#"+e.pre+"dl_2ddgm").dialog("isOpen")),p&&(t.bTwodctnInit2=$("#"+e.pre+"dl_2dctn").dialog("isOpen")),m&&(t.bSetsInit2=$("#"+e.pre+"dl_definedsets").dialog("isOpen")),{status:t,id2flag:s}}openDlgHalfWindow(e,t,s,i){let n=this.icn3dui,l=n.icn3d;if(n.bNode)return;let r=this,o=n.htmlCls.width2d+20;l.resizeCanvasCls.resizeCanvas(n.htmlCls.WIDTH-s,n.htmlCls.HEIGHT,i);let a,d=n.htmlCls.HEIGHT,c=s;a=!n.cfg.showmenu||n.utilsCls.isMobile()||n.cfg.mobilemenu?{my:"left top",at:"right top",of:"#"+n.pre+"viewer",collision:"none"}:{my:"left top",at:"right top+40",of:"#"+n.pre+"viewer",collision:"none"},n.cfg.resize=!1,window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:d,width:c,modal:!1,position:a,close:function(t){let s=r.getDialogStatus(),i=s.status,a=s.id2flag,d=!1;for(let t in a){let s=e===n.pre+t;for(let e in i)i.hasOwnProperty(e)||(s=s&&!i[e]);d=d||s}if(d)if(i.bTwoddgmInit2||i.bTwodctnInit2||i.bSetsInit2){let e=n.utilsCls.isMobile()?n.htmlCls.WIDTH:n.htmlCls.WIDTH-o;l.resizeCanvasCls.resizeCanvas(e,n.htmlCls.HEIGHT,!0),i.bTwoddgmInit2&&r.openDlg2Ddgm(n.pre+"dl_2ddgm",void 0,i.bSetsInit2),i.bTwodctnInit2&&r.openDlg2Ddgm(n.pre+"dl_2dctn",void 0,i.bSetsInit2),i.bSetsInit2&&r.openDlg2Ddgm(n.pre+"dl_definedsets")}else l.resizeCanvasCls.resizeCanvas(n.htmlCls.WIDTH,n.htmlCls.HEIGHT,!0)},resize:function(t){if(e==n.pre+"dl_selectannotations")l.annotationCls.hideFixedTitle();else if(e==n.pre+"dl_graph"){let t=$("#"+e).width(),s=$("#"+e).height();d3.select("#"+n.svgid).attr("width",t).attr("height",s)}else if(e==n.pre+"dl_linegraph"||e==n.pre+"dl_scatterplot"||e==n.pre+"dl_contactmap"||e==n.pre+"dl_alignerrormap"){let t=status.bTwoddgmInit2||status.bSetsInit2?(n.htmlCls.WIDTH-o)/2:n.htmlCls.WIDTH/2,s=$("#"+e).width()/t;if(e==n.pre+"dl_linegraph"){let e=l.linegraphWidth*s;$("#"+n.linegraphid).attr("width",e)}else if(e==n.pre+"dl_scatterplot"){let e=l.scatterplotWidth*s;$("#"+n.scatterplotid).attr("width",e)}else if(e==n.pre+"dl_contactmap"){let e=l.contactmapWidth*s;$("#"+n.contactmapid).attr("width",e)}else if(e==n.pre+"dl_alignerrormap"){let e=l.alignerrormapWidth*s;$("#"+n.alignerrormapid).attr("width",e)}}}}),this.addSaveButton(e),this.addHideButton(e)}openDlg2Ddgm(e,t,s){let i=this.icn3dui,n=i.icn3d;if(i.bNode)return;let l,r,o=this,a=i.htmlCls.width2d+20;e===i.pre+"dl_definedsets"?(l="right top",r="Select sets"):e!==i.pre+"dl_2ddgm"&&e!==i.pre+"dl_2dctn"||(l=s?"right top+240":"right top",r=e===i.pre+"dl_2ddgm"?"2D Diagram":"2D Cartoon");let d={my:"left top+"+i.htmlCls.MENU_HEIGHT,at:l,of:"#"+i.pre+"viewer",collision:"none"};window.dialog=$("#"+e).dialog({autoOpen:!0,title:r,height:"auto",width:a,modal:!1,position:d,close:function(e){let t=o.getDialogStatus().status;t.bSelectannotationsInit2||t.bGraph2||t.bLineGraph2||t.bScatterplot2||t.bTable2||t.bAlignmentInit2||n.resizeCanvasCls.resizeCanvas(i.htmlCls.WIDTH,i.htmlCls.HEIGHT,!0)},resize:function(t,s){e==i.pre+"dl_2dctn"&&(n.resizeRatioX=s.size.width/i.htmlCls.width2d,n.resizeRatioY=s.size.height/(i.htmlCls.width2d+70))},resizeStop:function(e,t){n.resizeRatioX=t.size.width/i.htmlCls.width2d,n.resizeRatioY=t.size.height/(i.htmlCls.width2d+70)}}),this.addSaveButton(e),this.addHideButton(e)}openDlgRegular(e,t){let s=this.icn3dui,i=s.icn3d;if(s.bNode)return;let n=400,l=150,r=s.htmlCls.width2d+20,o=this.getDialogStatus().status;if(e===s.pre+"dl_selectannotations"||e===s.pre+"dl_graph"||e===s.pre+"dl_linegraph"||e===s.pre+"dl_scatterplot"||e===s.pre+"dl_contactmap"||e===s.pre+"dl_alignerrormap"||e===s.pre+"dl_interactionsorted"||e===s.pre+"dl_alignment"){let a=.5*s.htmlCls.WIDTH-.5*r;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)this.openDlgHalfWindow(e,t,a,!0),(o.bTwoddgmInit2||o.bTwodctnInit2||o.bSetsInit2)&&(i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-a-r,s.htmlCls.HEIGHT,!0),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,o.bSetsInit2),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,o.bSetsInit2),o.bSetsInit2&&this.openDlg2Ddgm(s.pre+"dl_definedsets"));else{i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH,.5*s.htmlCls.HEIGHT,!0),l=.5*s.htmlCls.HEIGHT,n=s.htmlCls.WIDTH;let a={my:"left top",at:"left bottom+32",of:"#"+s.pre+"canvas",collision:"none"};window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:l,width:n,modal:!1,position:a,close:function(t){if(!((e!==s.pre+"dl_selectannotations"||o.bAlignmentInit2||o.bGraph2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_graph"||o.bSelectannotationsInit2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_alignment"||o.bSelectannotationsInit2||o.bGraph2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_interactionsorted"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_linegraph"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_scatterplot"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_contactmap"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bAlignerrormap2)&&(e!==s.pre+"dl_alignerrormap"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2)))if(o.bTwoddgmInit2||o.bTwodctnInit2||o.bSetsInit2){let e=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(e,s.htmlCls.HEIGHT,!0),o.bTwoddgmInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,o.bSetsInit2),o.bTwodctnInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,o.bSetsInit2),o.bSetsInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_definedsets")}else i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH,s.htmlCls.HEIGHT,!0)},resize:function(t){if(e==s.pre+"dl_selectannotations")i.annotationCls.hideFixedTitle();else if(e==s.pre+"dl_graph"){let t=$("#"+e).width(),i=$("#"+e).height();d3.select("#"+s.svgid).attr("width",t).attr("height",i)}else if(e==s.pre+"dl_linegraph"||e==s.pre+"dl_scatterplot"||e==s.pre+"dl_contactmap"||e==s.pre+"dl_alignerrormap"){let t=o.bTwoddgmInit2||o.bSetsInit2?(s.htmlCls.WIDTH-r)/2:s.htmlCls.WIDTH/2,n=$("#"+e).width()/t;if(e==s.pre+"dl_linegraph"){let e=i.linegraphWidth*n;$("#"+s.linegraphid).attr("width",e)}else if(e==s.pre+"dl_scatterplot"){let e=i.scatterplotWidth*n;$("#"+s.scatterplotid).attr("width",e)}else if(e==s.pre+"dl_contactmap"){let e=i.contactmapWidth*n;$("#"+s.contactmapid).attr("width",e)}else if(e==s.pre+"dl_alignerrormap"){let e=i.alignerrormapWidth*n;$("#"+s.alignerrormapid).attr("width",e)}}}}),this.addSaveButton(e),this.addHideButton(e)}}else if(e===s.pre+"dl_2ddgm"||e===s.pre+"dl_2dctn"){let t=0;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)(o.bSelectannotationsInit2||o.bGraph2||o.bLineGraph2||o.bScatterplot2||o.bTable2||o.bAlignmentInit2)&&(t=.5*s.htmlCls.WIDTH-.5*r),i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-t-r,s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,void 0,o.bSetsInit2);else{let t=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(t,.5*s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT,o.bSetsInit2)}}else{let a;if(l="auto",n="auto",e===s.pre+"dl_addtrack"?n="50%":e===s.pre+"dl_menupref"&&(n=600,l=500),e===s.pre+"dl_definedsets"){let t=0;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)(o.bSelectannotationsInit2||o.bGraph2||o.bLineGraph2||o.bScatterplot2||o.bTable2||o.bAlignmentInit2)&&(t=.5*s.htmlCls.WIDTH-.5*r),i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-t-r,s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,!0),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,!0);else{let t=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(t,.5*s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",.5*s.htmlCls.HEIGHT,!0),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",.5*s.htmlCls.HEIGHT,!0)}}else s.utilsCls.isMobile()?a={my:"left top",at:"left bottom-50",of:"#"+s.pre+"canvas",collision:"none"}:e===s.pre+"dl_allinteraction"||e===s.pre+"dl_buriedarea"?(a={my:"right top",at:"right top+50",of:"#"+i.divid,collision:"none"},n=700,l=500):a=e===s.pre+"dl_rmsd"||e===s.pre+"dl_legend"?{my:"left bottom",at:"left+20 bottom-20",of:"#"+s.pre+"canvas",collision:"none"}:e===s.pre+"dl_symd"?{my:"left top",at:"right-200 bottom-200",of:"#"+s.pre+"canvas",collision:"none"}:s.cfg.align?{my:"left top",at:"left top+90",of:"#"+s.pre+"canvas",collision:"none"}:{my:"left top",at:"left top+50",of:"#"+s.pre+"canvas",collision:"none"},window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:l,width:n,modal:!1,position:a}),this.addSaveButton(e),this.addHideButton(e)}$(".ui-dialog .ui-button span").removeClass("ui-icon-closethick").addClass("ui-icon-close")}openDlgNotebook(e,t){let s=this.icn3dui,i=s.icn3d;if(s.bNode)return;let n=400,l=150,r=s.htmlCls.width2d+20;e===s.pre+"dl_selectannotations"||e===s.pre+"dl_graph"||e===s.pre+"dl_linegraph"||e===s.pre+"dl_scatterplot"||e===s.pre+"dl_contactmap"||e===s.pre+"dl_alignerrormap"||e===s.pre+"dl_interactionsorted"||e===s.pre+"dl_alignment"?($("#"+e).show(),l=.5*s.htmlCls.HEIGHT,n=s.htmlCls.WIDTH,$("#"+e).width(n),$("#"+e).height(l),$("#"+e).resize((function(t){let n=s.htmlCls.WIDTH/2,l=$("#"+e).width()/n;if(e==s.pre+"dl_selectannotations")i.annotationCls.hideFixedTitle();else if(e==s.pre+"dl_graph"){let t=$("#"+e).width(),i=$("#"+e).height();d3.select("#"+s.svgid).attr("width",t).attr("height",i)}else if(e==s.pre+"dl_linegraph"){let e=i.linegraphWidth*l;$("#"+s.linegraphid).attr("width",e)}else if(e==s.pre+"dl_scatterplot"){let e=i.scatterplotWidth*l;$("#"+s.scatterplotid).attr("width",e)}else if(e==s.pre+"dl_contactmap"){let e=i.contactmapWidth*l;$("#"+s.contactmapid).attr("width",e)}else if(e==s.pre+"dl_alignerrormap"){let e=i.alignerrormapWidth*l;$("#"+s.alignerrormapid).attr("width",e)}}))):(i.bRender&&$("#"+e).show(),l="auto",n="auto",e===s.pre+"dl_addtrack"?n="50%":e===s.pre+"dl_2ddgm"||e===s.pre+"dl_2dctn"||e===s.pre+"dl_definedsets"?n=r:e!==s.pre+"dl_allinteraction"&&e!==s.pre+"dl_buriedarea"||(n=700,l=500),$("#"+e).width(n),$("#"+e).height(l))}}class h{constructor(e){this.icn3dui=e}setCustomDialogs(){let e=this.icn3dui;if(e.icn3d,e.bNode)return"";return""}getHtmlAlignResidueByResidue(e,t,s){let i=this.icn3dui;i.icn3d;let n="";return n+="All chains will be aligned to the first chain in the comma-separated chain IDs. Each chain ID has the form of PDBID_chain (e.g., 1HHO_A, case sensitive) or UniprotID (e.g., P69905 for AlphaFold structures).

    ",n+="Chain IDs: "+i.htmlCls.inputTextStr+"id='"+i.pre+e+"' value='P69905,P01942,1HHO_A' size=50>

    ",n+='Each alignment is defined as " | "-separated residue lists in one line. "10-50" means a range of residues from 10 to 50.

    ",n+=i.htmlCls.buttonStr+s+"'>Align Residue by Residue
    ",n}setDialogs(){let e=this.icn3dui,t=e.icn3d;if(e.bNode)return"";let s="";e.htmlCls.optionStr="":s.htmlCls.optionStr+"'"+l+"'>"+l+""}return i}setColorHints(){let e=this.icn3dui;e.icn3d;let t="";return t+=e.htmlCls.divNowrapStr+'Green: H-Bonds; ',t+='Cyan: Salt Bridge/Ionic; ',t+='Grey: contacts',t+=e.htmlCls.divNowrapStr+'Magenta: Halogen Bonds; ',t+='Red: π-Cation; ',t+='Blue: π-Stacking',t}setThicknessHtml(e){let t=this.icn3dui,s=t.icn3d,i="",n="3dprint"==e?"1":"0.1",l="3dprint"==e?"1.2":"0.3",r="3dprint"==e?"0.8":"0.4",o="3dprint"==e?"0.8":"0.4",a="3dprint"==e?"1":"0.4",d="3dprint"==e?"0.6":"0.3",c="3dprint"==e?"1":"0.2",h="3dprint"==e?"2":"1.3",p="3dprint"==e?"1.4":"0.8",m=40,u=.6,g=.4,f=.2,b=0,C=1,y=0;if("style"==e){if(""!=this.getCookie("shininess")&&(m=parseFloat(this.getCookie("shininess"))),""!=this.getCookie("light1")&&(u=parseFloat(this.getCookie("light1")),g=parseFloat(this.getCookie("light2")),f=parseFloat(this.getCookie("light3"))),""!=this.getCookie("lineRadius")){n=parseFloat(this.getCookie("lineRadius")),l=parseFloat(this.getCookie("coilWidth")),r=parseFloat(this.getCookie("cylinderRadius"));let e=this.getCookie("crosslinkRadius");o=isNaN(e)?s.crosslinkRadius:parseFloat(e),a=parseFloat(this.getCookie("traceRadius")),d=parseFloat(this.getCookie("dotSphereScale")),c=parseFloat(this.getCookie("ribbonthickness")),h=parseFloat(this.getCookie("helixSheetWidth")),p=parseFloat(this.getCookie("nucleicAcidWidth"))}""!=this.getCookie("glycan")&&(b=parseFloat(this.getCookie("glycan"))),""!=this.getCookie("membrane")&&(C=parseFloat(this.getCookie("membrane"))),""!=this.getCookie("cmdwindow")&&(y=parseFloat(this.getCookie("cmdwindow"))),i+="Note: The following parameters will be saved in cache. You just need to set them once.

    ",i+="1. Shininess: "+t.htmlCls.inputTextStr+"id='"+t.pre+"shininess' value='"+m+"' size=4>"+t.htmlCls.space3+"(for the shininess of the 3D objects, default 40)

    ",i+="2. Three directional lights:
    ",i+="Key Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light1' value='"+u+"' size=4>"+t.htmlCls.space3+"(for the light strength of the key light, default 0.6)
    ",i+="Fill Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light2' value='"+g+"' size=4>"+t.htmlCls.space3+"(for the light strength of the fill light, default 0.4)
    ",i+="Back Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light3' value='"+f+"' size=4>"+t.htmlCls.space3+"(for the light strength of the back light, default 0.2)

    ",i+="3. Thickness:
    "}return i+="Line Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"linerad_"+e+"' value='"+n+"' size=4>"+t.htmlCls.space3+"(for stabilizers, hydrogen bonds, distance lines, default 0.1)
    ",i+="Coil Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"coilrad_"+e+"' value='"+l+"' size=4>"+t.htmlCls.space3+"(for coils, default 0.3)
    ",i+="Stick Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"stickrad_"+e+"' value='"+r+"' size=4>"+t.htmlCls.space3+"(for sticks, default 0.4)
    ",i+="Cross-Linkage Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"crosslinkrad_"+e+"' value='"+o+"' size=4>"+t.htmlCls.space3+"(for cross-linkages, default 0.4)
    ",i+="Trace Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"tracerad_"+e+"' value='"+a+"' size=4>"+t.htmlCls.space3+"(for C alpha trace, O3' trace, default 0.4)
    ",i+="Ribbon Thickness: "+t.htmlCls.inputTextStr+"id='"+t.pre+"ribbonthick_"+e+"' value='"+c+"' size=4>"+t.htmlCls.space3+"(for helix and sheet ribbons, nucleotide ribbons, default 0.2)
    ",i+="Protein Ribbon Width: "+t.htmlCls.inputTextStr+"id='"+t.pre+"prtribbonwidth_"+e+"' value='"+h+"' size=4>"+t.htmlCls.space3+"(for helix and sheet ribbons, default 1.3)
    ",i+="Nucleotide Ribbon Width: "+t.htmlCls.inputTextStr+"id='"+t.pre+"nucleotideribbonwidth_"+e+"' value='"+p+"' size=4>"+t.htmlCls.space3+"(for nucleotide ribbons, default 0.8)
    ",i+="Ball Scale: "+t.htmlCls.inputTextStr+"id='"+t.pre+"ballscale_"+e+"' value='"+d+"' size=4>"+t.htmlCls.space3+"(for styles 'Ball and Stick' and 'Dot', default 0.3)
    ","style"==e&&(i+="
    4. Show Glycan Cartoon: "+t.htmlCls.inputTextStr+"id='"+t.pre+"glycan' value='"+b+"' size=4>"+t.htmlCls.space3+"(0: hide, 1: show, default 0)
    ",i+="
    5. Show Membrane: "+t.htmlCls.inputTextStr+"id='"+t.pre+"membrane' value='"+C+"' size=4>"+t.htmlCls.space3+"(0: hide, 1: show, default 1)
    ",i+="
    6. Enlarge Command Window: "+t.htmlCls.inputTextStr+"id='"+t.pre+"cmdwindow' value='"+y+"' size=4>"+t.htmlCls.space3+"(0: Regular, 1: Large, default 0)

    "),i+=t.htmlCls.spanNowrapStr+""+t.htmlCls.buttonStr+"apply_thickness_"+e+"'>Apply   ",i+=t.htmlCls.spanNowrapStr+""+t.htmlCls.buttonStr+"reset_thickness_"+e+"'>Reset",i}getCookie(e){let t=e+"=",s=decodeURIComponent(document.cookie).split(";");for(let e=0;e":(n+='
    ',n+="
    Selection: Name: "+s.htmlCls.inputTextStr+"id='"+s.pre+"seq_command_name"+e+"' value='seq_"+l+"' size='5'> "+s.htmlCls.space2+"

    ",n+=s.htmlCls.divStr+"seqguide"+e+"' style='display:none; white-space:normal;' class='icn3d-box'>"),n+=this.getSelectionHints();return n+="Residue labeling: standard residue with coordinates: UPPER case letter; nonstandard residue with coordinates: the first UPPER case letter plus a period except that water residue uses the letter 'O'; residue missing coordinates: lower case letter."+(s.utilsCls.isMac()&&!s.utilsCls.isMobile()?"

    Turn on scroll bar: System preferences -> General -> show scroll bars -> check Always":"")+"
    ",n}setAlignSequenceGuide(e,t){let s=this.icn3dui,i=s.icn3d,n="";let l=i&&i.defNames2Atoms?Object.keys(i.defNames2Atoms).length:1;n+='
    ',n+="
    Selection: Name: "+s.htmlCls.inputTextStr+"id='"+s.pre+"alignseq_command_name' value='alseq_"+l+"' size='10'> "+s.htmlCls.space2+"

    ",n+=s.htmlCls.divStr+"alignseqguide' style='display:none; white-space:normal;' class='icn3d-box'>",n+=this.getSelectionHints();return n+="Residue labeling: aligned residue with coordinates: UPPER case letter; non-aligned residue with coordinates: lower case letter which can be highlighted; residue missing coordinates: lower case letter which can NOT be highlighted."+(s.utilsCls.isMac()&&!s.utilsCls.isMobile()?"

    Turn on scroll bar: System preferences -> General -> show scroll bars -> check Always":"")+"
    ",n}getSelectionHints(){let e=this.icn3dui;e.icn3d;let t="";if(e.utilsCls.isMobile())t+='Select Aligned Sequences: touch to select, touch again to deselect, multiple selection is allowed without Ctrl key, click "Save Selection" to save the current selection.
    ';else{t+='Select on 1D sequences: drag to select, drag again to deselect, multiple selection is allowed without Ctrl key, click "Save Selection" to save the current selection.

    ',t+="Select on 2D interaction diagram: click on the nodes or lines. The nodes are chains and can be united with the Ctrl key. The lines are interactions and can NOT be united. Each click on the lines selects half of the lines, i.e., select the interacting residues in one of the two chains.

    ",t+="Select on 3D structures: "+(e.utilsCls.isMobile()?"use finger to pick":'hold "Alt" and use mouse to pick')+', click the second time to deselect, hold "Ctrl" to union selection, hold "Shift" to select a range, press the up/down arrow to switch among atom/residue/strand/chain/structure, click "Save Selection" to save the current selection.

    ',t+='Save the current selection(either on 3D structure, 2D interactions, or 1D sequence): open the menu "Select -> Save Selection", specify the name and description for the selection, and click "Save".

    '}return t}addGsizeSalt(e){let t=this.icn3dui;t.icn3d;let s="";s+="Grid Size: ",s+="Salt Concentration: M
    ",s}getFootHtml(e,t){let s=this.icn3dui;s.icn3d;let i="
    ";return"delphi"==e?s.cfg.cid?i+="Note: Partial charges(MMFF94) are from PubChem Compound SDF files.

    ":(i+="Note: Only the selected residues are used for DelPhi potential calculation by solving linear Poisson-Boltzmann equation.",i+='

    ',i+=s.htmlCls.divStr+t+"' style='display:none;'>",i+="
    The hydrogens and partial charges of proteins and nucleotides are added using DelPhiPKa with the Amber charge and size files. The hydrogens of ligands are added using Open Babel. The partial charges of ligands are calculated using Antechamber with the Gasteiger charge method. All partial charges are calculated at pH 7.

    ",i+='Lipids are treated as ligands. Please use "HETATM" instead of "ATOM " for each lipid atom in your PDB file. Each phosphate in lipids is assigned with a charge of -1. You can download PQR and modify it, or prepare your PQR file using other tools. Then load the PQR file at the menu "Analysis > Load PQR/Potential".

    ',i+="
    "):(i+="Note: Always load a PDB file before loading a PQR or DelPhi potential file.",i+='

    ',i+=s.htmlCls.divStr+t+"' style='display:none;'>",i+='The PDB file can be loaded in the URL with "pdbid=" or at "File > Open File". The PQR file can be prepared at the menu "Analysis > Download PQR" with your modification or using other tools. The DelPhi potential file can be calculated at DelPhi Web Server and be exported as a Cube file. ',"url"==e&&(i+="The PQR or potential file can be accessed in a URL if it is located in the same host as iCn3D."),i+="

    ",i+=""),i+="",i}getPotentialHtml(e,t){let s=this.icn3dui;s.icn3d;let i,n,l,r,o,a="";r="Equipotential Map",o="Surface with Potential","delphi"==e?n="delphi":"local"==e?(i="pqr",n="phi",l="cube"):"url"==e&&(i="pqrurl",n="phiurl",l="cubeurl"),a+=s.htmlCls.divStr+"dl_"+n+"' class='"+t+"'>",a+=s.htmlCls.divStr+"dl_"+n+"_tabs' style='border:0px;'>",a+="",a+=s.htmlCls.divStr+n+"tab1'>","delphi"==e&&(a+=this.addGsizeSalt(n)+"
    "),a+="Potential contour at: kT/e(25.6mV at 298K)

    ","delphi"==e?(a+=s.htmlCls.buttonStr+"reload_"+n+"file' style='margin-top: 6px;'>Equipotential Map",a+=s.htmlCls.buttonStr+n+"mapNo' style='margin-left:30px;'>Remove Map
    "):"local"==e?(a+=s.htmlCls.divStr+n+"tab1_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo'>Remove Map",a+=s.htmlCls.divStr+n+"tab1_"+i+"'>",a+=this.addGsizeSalt(i)+"
    ",a+="PQR File: "+s.htmlCls.inputFileStr+"id='"+s.pre+i+"file'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+n+"'>",a+="Phi File: "+s.htmlCls.inputFileStr+"id='"+s.pre+n+"file'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+l+"'>",a+="Cube File: "+s.htmlCls.inputFileStr+"id='"+s.pre+l+"file'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=""):"url"==e&&(a+=s.htmlCls.divStr+n+"tab1_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo'>Remove Map",a+=s.htmlCls.divStr+n+"tab1_"+i+"2'>",a+=this.addGsizeSalt(i)+"
    ",a+="PQR URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+i+"file'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+n+"2'>",a+="Phi URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+n+"file'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+l+"2'>",a+="Cube URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+l+"file'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=""),a+="
    "+this.getFootHtml(e,n+"tab1_foot"),a+="",a+=s.htmlCls.divStr+n+"tab2'>","delphi"==e&&(a+=this.addGsizeSalt(n)+"
    "),a+="Surface with max potential at: kT/e(25.6mV at 298K)

    ",a+="Surface: ",a+="Opacity: ",a+="Wireframe:
    ",a+="
    ","delphi"==e?(a+=s.htmlCls.buttonStr+"reload_"+n+"file2' style='margin-top: 6px;'>Surface with Potential",a+=s.htmlCls.buttonStr+n+"mapNo2' style='margin-left:30px;'>Remove Surface
    "):"local"==e?(a+=s.htmlCls.divStr+n+"tab2_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo2'>Remove Surface",a+=s.htmlCls.divStr+n+"tab2_"+i+"'>",a+=this.addGsizeSalt(i+"2")+"
    ",a+="PQR File: "+s.htmlCls.inputFileStr+"id='"+s.pre+i+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+n+"'>",a+="Phi File: "+s.htmlCls.inputFileStr+"id='"+s.pre+n+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+l+"'>",a+="Cube File: "+s.htmlCls.inputFileStr+"id='"+s.pre+l+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=""):"url"==e&&(a+=s.htmlCls.divStr+n+"tab2_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo2'>Remove Surface",a+=s.htmlCls.divStr+n+"tab2_"+i+"2'>",a+=this.addGsizeSalt(i+"2")+"
    ",a+="PQR URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+i+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+n+"2'>",a+="Phi URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+n+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+l+"2'>",a+="Cube URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+l+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=""),a+="
    "+this.getFootHtml(e,n+"tab2_foot"),a+="",a+="",a+="",a}async exportPqr(e){let t=this.icn3dui,s=t.icn3d,i={},n={},l=t.hashUtilsCls.intHash(s.dAtoms,s.hAtoms);for(let e in l)s.atoms[e],s.ions.hasOwnProperty(e)?i[e]=1:n[e]=1;let r=e?"pdb":"pqr";if(t.cfg.cid){let t="",l=!e;t+=s.saveFileCls.getAtomPDB(n,l)+s.saveFileCls.getAtomPDB(i,l);let o=s.inputid?s.inputid:"custom";s.saveFileCls.saveFile(o+"_icn3d."+r,"text",[t])}else{if(t.utilsCls.isCalphaPhosOnly(t.hashUtilsCls.hash2Atoms(n,s.atoms)))return void alert("The potential will not be shown because the side chains are missing in the structure...");let l="";l+=s.saveFileCls.getAtomPDB(n),l+=s.saveFileCls.getAtomPDB(i,!0,void 0,!0);let o="https://www.ncbi.nlm.nih.gov/Structure/delphi/delphi.fcgi",a={pdb2pqr:l,pdbid:t.cfg.cid?t.cfg.cid:Object.keys(s.structures).toString()},d=await t.getAjaxPostPromise(o,a,!0,void 0,void 0,!0,"text");if(e){let e=d.split("\n"),s="";for(let i=0,n=e.length;i PNG Image" in the Data menu...');else if(-1!=l){let t=e.substr(l+n.length);s.htmlCls.clickMenuCls.setLogCmd("load iCn3D PNG image "+$("#"+s.pre+"pngimage").val(),!1),window.open(t,"_self")}else if(-1!=o){let n="Start of data file======\n",l=e.indexOf(n);i.bInputfile=-1!=l;let a,d=t?t.replace(/;/g,"\n"):"";if(i.bInputfile){let t=e.indexOf("End of data file======\n"),s=e.substr(l+n.length,t-l-n.length);i.InputfileData=i.InputfileData?i.InputfileData+"\nENDMDL\n"+s:s;let c="Start of type file======\n",h=e.indexOf(c),p=e.indexOf("End of type file======\n"),m=e.substr(h+c.length,p-h-c.length-1);i.InputfileType=m;let u=e.indexOf("End of state file======\n");a=e.substr(o+r.length,u-o-r.length),a=decodeURIComponent(a+"\n"+d),"pdb"===m?(await i.pdbParserCls.loadPdbData(s),i.commands=[],i.optsHistory=[]):("mol2"===m?await i.mol2ParserCls.loadMol2Data(s):"sdf"===m?await i.sdfParserCls.loadSdfData(s):"xyz"===m?await i.xyzParserCls.loadXyzData(s):"mmcif"===m&&await i.mmcifParserCls.loadMmcifData(s),i.commands=[],i.optsHistory=[])}else{let t=e.indexOf("End of state file======\n");a=e.substr(o+r.length,t-o-r.length),a=decodeURIComponent(a+"\n"+d),i.commands=[],i.optsHistory=[]}await i.loadScriptCls.loadScript(a,!0),s.htmlCls.clickMenuCls.setLogCmd("load iCn3D PNG image "+$("#"+s.pre+"pngimage").val(),!1)}}fileSupport(){window.File&&window.FileReader&&window.FileList&&window.Blob||alert("The File APIs are not fully supported in this browser.")}getLinkColor(){let e="";return e+=", linkmap: {\n",e+='3: {"type": "peptidebond", "c":""},\n',e+='4: {"type": "ssbond", "c":"FFA500"},\n',e+='5: {"type": "ionic", "c":"0FF"},\n',e+='6: {"type": "ionicInside", "c":"FFF"},\n',e+='11: {"type": "contact", "c":"888"},\n',e+='12: {"type": "contactInside", "c":"FFF"},\n',e+='13: {"type": "hbond", "c":"0F0"},\n',e+='14: {"type": "hbondInside", "c":"FFF"},\n',e+='15: {"type": "clbond", "c":"006400"},\n',e+='17: {"type": "halogen", "c":"F0F"},\n',e+='18: {"type": "halogenInside", "c":"FFF"},\n',e+='19: {"type": "pication", "c":"F00"},\n',e+='20: {"type": "picationInside", "c":"FFF"},\n',e+='21: {"type": "pistacking", "c":"00F"},\n',e+='22: {"type": "pistackingInside", "c":"FFF"}\n',e+="}}\n",', linkmap: {\n3: {"type": "peptidebond", "c":""},\n4: {"type": "ssbond", "c":"FFA500"},\n5: {"type": "ionic", "c":"0FF"},\n6: {"type": "ionicInside", "c":"FFF"},\n11: {"type": "contact", "c":"888"},\n12: {"type": "contactInside", "c":"FFF"},\n13: {"type": "hbond", "c":"0F0"},\n14: {"type": "hbondInside", "c":"FFF"},\n15: {"type": "clbond", "c":"006400"},\n17: {"type": "halogen", "c":"F0F"},\n18: {"type": "halogenInside", "c":"FFF"},\n19: {"type": "pication", "c":"F00"},\n20: {"type": "picationInside", "c":"FFF"},\n21: {"type": "pistacking", "c":"00F"},\n22: {"type": "pistackingInside", "c":"FFF"}\n}}\n'}setCookieForThickness(){let e=this.icn3dui,t=e.icn3d;if(!e.bNode){let e=3650;this.setCookie("lineRadius",t.lineRadius,e),this.setCookie("coilWidth",t.coilWidth,e),this.setCookie("cylinderRadius",t.cylinderRadius,e),this.setCookie("crosslinkRadius",t.crosslinkRadius,e),this.setCookie("traceRadius",t.traceRadius,e),this.setCookie("dotSphereScale",t.dotSphereScale,e),this.setCookie("ribbonthickness",t.ribbonthickness,e),this.setCookie("helixSheetWidth",t.helixSheetWidth,e),this.setCookie("nucleicAcidWidth",t.nucleicAcidWidth,e)}}setLineThickness(e,t){let s=this.icn3dui,i=s.icn3d;if(i.bSetThickness=!0,"style"==e&&(t&&($("#"+s.pre+"shininess").val("40"),$("#"+s.pre+"light1").val("0.6"),$("#"+s.pre+"light2").val("0.4"),$("#"+s.pre+"light3").val("0.2"),$("#"+s.pre+"glycan").val("0"),$("#"+s.pre+"membrane").val("1"),$("#"+s.pre+"cmdwindow").val("0")),i.shininess=parseFloat($("#"+s.pre+"shininess").val()),i.light1=parseFloat($("#"+s.pre+"light1").val()),i.light2=parseFloat($("#"+s.pre+"light2").val()),i.light3=parseFloat($("#"+s.pre+"light3").val()),i.bGlycansCartoon=parseInt($("#"+s.pre+"glycan").val()),i.bMembrane=parseInt($("#"+s.pre+"membrane").val()),i.bCmdWindow=parseInt($("#"+s.pre+"cmdwindow").val())),t&&($("#"+s.pre+"linerad_"+e).val(.1),$("#"+s.pre+"coilrad_"+e).val(.3),$("#"+s.pre+"stickrad_"+e).val(.4),$("#"+s.pre+"crosslinkrad_"+e).val(.4),$("#"+s.pre+"tracerad_"+e).val(.4),$("#"+s.pre+"ballscale_"+e).val(.3),$("#"+s.pre+"ribbonthick_"+e).val(.2),$("#"+s.pre+"prtribbonwidth_"+e).val(1.3),$("#"+s.pre+"nucleotideribbonwidth_"+e).val(.8)),i.lineRadius=parseFloat($("#"+s.pre+"linerad_"+e).val()),i.coilWidth=parseFloat($("#"+s.pre+"coilrad_"+e).val()),i.cylinderRadius=parseFloat($("#"+s.pre+"stickrad_"+e).val()),i.crosslinkRadius=parseFloat($("#"+s.pre+"crosslinkrad_"+e).val()),i.traceRadius=parseFloat($("#"+s.pre+"tracerad_"+e).val()),i.dotSphereScale=parseFloat($("#"+s.pre+"ballscale_"+e).val()),i.ribbonthickness=parseFloat($("#"+s.pre+"ribbonthick_"+e).val()),i.helixSheetWidth=parseFloat($("#"+s.pre+"prtribbonwidth_"+e).val()),i.nucleicAcidWidth=parseFloat($("#"+s.pre+"nucleotideribbonwidth_"+e).val()),!s.bNode){let e=3650;this.setCookie("shininess",i.shininess,e),this.setCookie("light1",i.light1,e),this.setCookie("light2",i.light2,e),this.setCookie("light3",i.light3,e),this.setCookie("glycan",i.bGlycansCartoon,e),this.setCookie("membrane",i.bMembrane,e),this.setCookie("cmdwindow",i.bCmdWindow,e)}if(this.setCookieForThickness(),e=t){let e="reset thickness";s.htmlCls.clickMenuCls.setLogCmd(e,!0),i.bSetThickness=!1,i.threeDPrintCls.resetAfter3Dprint()}else s.htmlCls.clickMenuCls.setLogCmd("set thickness | linerad "+i.lineRadius+" | coilrad "+i.coilWidth+" | stickrad "+i.cylinderRadius+" | crosslinkrad "+i.crosslinkRadius+" | tracerad "+i.traceRadius+" | ribbonthick "+i.ribbonthickness+" | proteinwidth "+i.helixSheetWidth+" | nucleotidewidth "+i.nucleicAcidWidth+" | ballscale "+i.dotSphereScale,!0),s.htmlCls.clickMenuCls.setLogCmd("set glycan "+i.bGlycansCartoon,!0),s.htmlCls.clickMenuCls.setLogCmd("set membrane "+i.bMembrane,!0),s.htmlCls.clickMenuCls.setLogCmd("set cmdwindow "+i.bCmdWindow,!0);i.drawCls.draw()}setCookie(e,t,s){let i=new Date;i.setTime(i.getTime()+24*s*60*60*1e3);let n="expires="+i.toUTCString();document.cookie=e+"="+t+";"+n+";path=/"}updateSurfPara(e){let t=this.icn3dui,s=t.icn3d;s.phisurftype=$("#"+t.pre+e+"surftype").val(),s.phisurfop=$("#"+t.pre+e+"surfop").val(),s.phisurfwf=$("#"+t.pre+e+"surfwf").val()}exportPdb(){let e=this.icn3dui,t=e.icn3d,s="",i=e.hashUtilsCls.intHash(t.dAtoms,t.hAtoms);if(s+=t.saveFileCls.getAtomPDB(i),!e.bNode){let e=t.inputid?t.inputid:"custom";t.saveFileCls.saveFile(e+"_icn3d.pdb","text",[s])}return s}exportSecondary(){let e=this.icn3dui,t=e.icn3d,s="",i=e.hashUtilsCls.intHash(t.dAtoms,t.hAtoms);if(s+=t.saveFileCls.getSecondary(i),!e.bNode){let e=t.inputid?t.inputid:"custom";t.saveFileCls.saveFile(e+"_icn3d_ss.txt","text",[s])}return s}}class g{constructor(e){let t=e;this.icn3dui=e,this.cfg=this.icn3dui.cfg,this.opts={},this.opts.background="black",this.allMenus={},this.allMenusSel={},this.simpleMenus={},this.shownMenus={},this.WIDTH=400,this.HEIGHT=400,this.RESIDUE_WIDTH=10,t.utilsCls.isMobile()||this.cfg.mobilemenu?this.MENU_HEIGHT=0:this.MENU_HEIGHT=40,this.LOG_HEIGHT=65,this.MENU_WIDTH=750,this.LESSWIDTH=20,this.LESSWIDTH_RESIZE=20,this.LESSHEIGHT=20,this.width2d=200,this.CMD_HEIGHT=.8*this.LOG_HEIGHT,this.EXTRAHEIGHT=this.MENU_HEIGHT+this.CMD_HEIGHT,null!=this.cfg.showmenu&&0==this.cfg.showmenu&&(this.EXTRAHEIGHT-=this.MENU_HEIGHT),null!=this.cfg.showcommand&&0==this.cfg.showcommand&&(this.EXTRAHEIGHT-=this.CMD_HEIGHT),this.GREY8="#AAAAAA",this.GREYB="#CCCCCC",this.GREYC="#DDDDDD",this.GREYD="#EEEEEE",this.ORANGE="#FFA500",this.themecolor="blue",this.defaultValue=1,this.ssValue=3,this.coilValue=3,this.contactValue=11,this.contactInsideValue=12,this.hbondValue=13,this.hbondInsideValue=14,this.ssbondValue=4,this.ionicValue=5,this.ionicInsideValue=6,this.clbondValue=15,this.halogenValue=17,this.halogenInsideValue=18,this.picationValue=19,this.picationInsideValue=20,this.pistackingValue=21,this.pistackingInsideValue=22,this.contactColor="888",this.contactInsideColor="FFF",this.hbondColor="0F0",this.hbondInsideColor="FFF",this.ssbondColor="FFA500",this.ionicColor="0FF",this.ionicInsideColor="FFF",this.clbondColor="006400",this.halogenColor="F0F",this.halogenInsideColor="FFF",this.picationColor="F00",this.picationInsideColor="FFF",this.pistackingColor="00F",this.pistackingInsideColor="FFF",this.hideedges=1,this.force=4,this.simulation=void 0,this.baseUrl=window&&window.location&&"structure.ncbi.nlm.nih.gov"==window.location.hostname?"https://structure.ncbi.nlm.nih.gov/Structure/":"https://www.ncbi.nlm.nih.gov/Structure/",this.divStr="
    ",this.spanNowrapStr="",this.inputTextStr="=2.0 are supported.")));const a=new pe(o,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});a.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===r[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}a.setExtensions(l),a.setPlugins(r),a.parse(s,i)}parseAsync(e,t){const s=this;return new Promise((function(i,n){s.parse(e,t,i,n)}))}}function b(){let e={};return{get:function(t){return e[t]},add:function(t,s){e[t]=s},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const C={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class y{constructor(e){this.parser=e,this.name=C.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,i=t.length;s=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,n.source,l)}}class R{constructor(e){this.parser=e,this.name=C.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,i=s.json,n=i.textures[e];if(!n.extensions||!n.extensions[t])return null;const l=n.extensions[t],r=i.images[l.source];let o=s.textureLoader;if(r.uri){const e=s.options.manager.getHandler(r.uri);null!==e&&(o=e)}return this.detectSupport().then((function(n){if(n)return s.loadTextureImage(e,l.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class E{constructor(e){this.name=C.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const e=s.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),n=this.parser.options.meshoptDecoder;if(!n||!n.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([i,n.ready]).then((function(t){const s=e.byteOffset||0,i=e.byteLength||0,l=e.count,r=e.byteStride,o=new ArrayBuffer(l*r),a=new Uint8Array(t[0],s,i);return n.decodeGltfBuffer(new Uint8Array(o),l,r,a,e.mode,e.filter),o}))}return null}}const I="glTF",T=1313821514,M=5130562;class P{constructor(e){this.name=C.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:THREE.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==I)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-12,i=new DataView(e,12);let n=0;for(;n",t).replace("#include ",s).replace("#include ",i).replace("#include ",n).replace("#include ",l)},Object.defineProperties(this,{specular:{get:function(){return r.specular.value},set:function(e){r.specular.value=e}},specularMap:{get:function(){return r.specularMap.value},set:function(e){r.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return r.glossiness.value},set:function(e){r.glossiness.value=e}},glossinessMap:{get:function(){return r.glossinessMap.value},set:function(e){r.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class L{constructor(){this.name=C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity"]}getMaterialType(){return F}extendParams(e,t,s){const i=t.extensions[this.name];e.color=new Color(1,1,1),e.opacity=1;const n=[];if(Array.isArray(i.diffuseFactor)){const t=i.diffuseFactor;e.color.fromArray(t),e.opacity=t[3]}if(void 0!==i.diffuseTexture&&n.push(s.assignTexture(e,"map",i.diffuseTexture,sRGBEncoding)),e.emissive=new Color(0,0,0),e.glossiness=void 0!==i.glossinessFactor?i.glossinessFactor:1,e.specular=new Color(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),void 0!==i.specularGlossinessTexture){const t=i.specularGlossinessTexture;n.push(s.assignTexture(e,"glossinessMap",t)),n.push(s.assignTexture(e,"specularMap",t,sRGBEncoding))}return Promise.all(n)}createMaterial(e){const t=new F(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=TangentSpaceNormalMap,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t}}class N{constructor(){this.name=C.KHR_MESH_QUANTIZATION}}class U extends THREE.Interpolant{constructor(e,t,s,i){super(e,t,s,i)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,i=this.valueSize,n=e*i*3+i;for(let e=0;e!==i;e++)t[e]=s[n+e];return t}}U.prototype.beforeStart_=U.prototype.copySampleValue_,U.prototype.afterEnd_=U.prototype.copySampleValue_,U.prototype.interpolate_=function(e,t,s,i){const n=this.resultBuffer,l=this.sampleValues,r=this.valueSize,o=2*r,a=3*r,d=i-t,c=(s-t)/d,h=c*c,p=h*c,m=e*a,u=m-a,g=-2*p+3*h,f=p-h,b=1-g,C=f-h+c;for(let e=0;e!==r;e++){const t=l[u+e+r],s=l[u+e+o]*d,i=l[m+e+r],a=l[m+e]*d;n[e]=b*t+C*s+g*i+f*a}return n};const q=new THREE.Quaternion;class j extends U{interpolate_(e,t,s,i){const n=super.interpolate_(e,t,s,i);return q.fromArray(n).normalize().toArray(n),n}}const B=0,z=1,G=2,V=3,W=4,Y=5,X=6,K={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Q={9728:THREE.NearestFilter,9729:THREE.LinearFilter,9984:THREE.NearestMipmapNearestFilter,9985:THREE.LinearMipmapNearestFilter,9986:THREE.NearestMipmapLinearFilter,9987:THREE.LinearMipmapLinearFilter},J={33071:THREE.ClampToEdgeWrapping,33648:THREE.MirroredRepeatWrapping,10497:THREE.RepeatWrapping},Z={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ee={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},te={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},se={CUBICSPLINE:void 0,LINEAR:THREE.InterpolateLinear,STEP:THREE.InterpolateDiscrete},ie="OPAQUE",ne="MASK",le="BLEND";function re(e,t,s){for(const i in s.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=s.extensions[i])}function oe(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function ae(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let s=0,i=t.weights.length;s{const s=this.associations.get(e);null!=s&&this.associations.set(t,s);for(const[s,i]of e.children.entries())n(i,t.children[s])};return n(s,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s=2&&m.setY(t,c[e*l+1]),l>=3&&m.setZ(t,c[e*l+2]),l>=4&&m.setW(t,c[e*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m}))}loadTexture(e){const t=this.json,s=this.options,i=t.textures[e].source,n=t.images[i];let l=this.textureLoader;if(n.uri){const e=s.manager.getHandler(n.uri);null!==e&&(l=e)}return this.loadTextureImage(e,i,l)}loadTextureImage(e,t,s){const i=this,n=this.json,l=n.textures[e],r=n.images[t],o=(r.uri||r.bufferView)+":"+l.sampler;if(this.textureCache[o])return this.textureCache[o];const a=this.loadImageSource(t,s).then((function(t){t.flipY=!1,l.name&&(t.name=l.name);const s=(n.samplers||{})[l.sampler]||{};return t.magFilter=Q[s.magFilter]||LinearFilter,t.minFilter=Q[s.minFilter]||LinearMipmapLinearFilter,t.wrapS=J[s.wrapS]||RepeatWrapping,t.wrapT=J[s.wrapT]||RepeatWrapping,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=a,a}loadImageSource(e,t){const s=this,i=this.json,n=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const l=i.images[e],r=self.URL||self.webkitURL;let o=l.uri||"",a=!1;if(void 0!==l.bufferView)o=s.getDependency("bufferView",l.bufferView).then((function(e){a=!0;const t=new Blob([e],{type:l.mimeType});return o=r.createObjectURL(t),o}));else if(void 0===l.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(o).then((function(e){return new Promise((function(s,i){let l=s;!0===t.isImageBitmapLoader&&(l=function(e){const t=new Texture(e);t.needsUpdate=!0,s(t)}),t.load(THREE.LoaderUtils.resolveURL(e,n.path),l,void 0,i)}))})).then((function(e){var t;return!0===a&&r.revokeObjectURL(o),e.userData.mimeType=l.mimeType||((t=l.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),e}));return this.sourceCache[e]=d,d}assignTexture(e,t,s,i){const n=this;return this.getDependency("texture",s.index).then((function(l){if(void 0===s.texCoord||0==s.texCoord||"aoMap"===t&&1==s.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+s.texCoord+" for texture "+t+" not yet supported."),n.extensions[C.KHR_TEXTURE_TRANSFORM]){const e=void 0!==s.extensions?s.extensions[C.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=n.associations.get(l);l=n.extensions[C.KHR_TEXTURE_TRANSFORM].extendTexture(l,e),n.associations.set(l,t)}}return void 0!==i&&(l.encoding=i),e[t]=l,l}))}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const i=void 0===t.attributes.tangent,n=void 0!==t.attributes.color,l=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new PointsMaterial,Material.prototype.copy.call(t,s),t.color.copy(s.color),t.map=s.map,t.sizeAttenuation=!1,this.cache.add(e,t)),s=t}else if(e.isLine){const e="LineBasicMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new LineBasicMaterial,Material.prototype.copy.call(t,s),t.color.copy(s.color),this.cache.add(e,t)),s=t}if(i||n||l){let e="ClonedMaterial:"+s.uuid+":";s.isGLTFSpecularGlossinessMaterial&&(e+="specular-glossiness:"),i&&(e+="derivative-tangents:"),n&&(e+="vertex-colors:"),l&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=s.clone(),n&&(t.vertexColors=!0),l&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(s))),s=t}s.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),e.material=s}getMaterialType(){return MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,i=this.extensions,n=s.materials[e];let l;const r={},o=n.extensions||{},a=[];if(o[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=i[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];l=e.getMaterialType(),a.push(e.extendParams(r,n,t))}else if(o[C.KHR_MATERIALS_UNLIT]){const e=i[C.KHR_MATERIALS_UNLIT];l=e.getMaterialType(),a.push(e.extendParams(r,n,t))}else{const s=n.pbrMetallicRoughness||{};if(r.color=new Color(1,1,1),r.opacity=1,Array.isArray(s.baseColorFactor)){const e=s.baseColorFactor;r.color.fromArray(e),r.opacity=e[3]}void 0!==s.baseColorTexture&&a.push(t.assignTexture(r,"map",s.baseColorTexture,sRGBEncoding)),r.metalness=void 0!==s.metallicFactor?s.metallicFactor:1,r.roughness=void 0!==s.roughnessFactor?s.roughnessFactor:1,void 0!==s.metallicRoughnessTexture&&(a.push(t.assignTexture(r,"metalnessMap",s.metallicRoughnessTexture)),a.push(t.assignTexture(r,"roughnessMap",s.metallicRoughnessTexture))),l=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),a.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,r)}))))}!0===n.doubleSided&&(r.side=DoubleSide);const d=n.alphaMode||ie;if(d===le?(r.transparent=!0,r.depthWrite=!1):(r.transparent=!1,d===ne&&(r.alphaTest=void 0!==n.alphaCutoff?n.alphaCutoff:.5)),void 0!==n.normalTexture&&l!==MeshBasicMaterial&&(a.push(t.assignTexture(r,"normalMap",n.normalTexture)),r.normalScale=new Vector2(1,1),void 0!==n.normalTexture.scale)){const e=n.normalTexture.scale;r.normalScale.set(e,e)}return void 0!==n.occlusionTexture&&l!==MeshBasicMaterial&&(a.push(t.assignTexture(r,"aoMap",n.occlusionTexture)),void 0!==n.occlusionTexture.strength&&(r.aoMapIntensity=n.occlusionTexture.strength)),void 0!==n.emissiveFactor&&l!==MeshBasicMaterial&&(r.emissive=(new Color).fromArray(n.emissiveFactor)),void 0!==n.emissiveTexture&&l!==MeshBasicMaterial&&a.push(t.assignTexture(r,"emissiveMap",n.emissiveTexture,sRGBEncoding)),Promise.all(a).then((function(){let s;return s=l===F?i[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(r):new l(r),n.name&&(s.name=n.name),oe(s,n),t.associations.set(s,{materials:e}),n.extensions&&re(i,s,n),s}))}createUniqueName(e){const t=PropertyBinding.sanitizeNodeName(e||"");let s=t;for(let e=1;this.nodeNamesUsed[s];++e)s=t+"_"+e;return this.nodeNamesUsed[s]=!0,s}loadGeometries(e){const t=this,s=this.extensions,i=this.primitiveCache;function n(e){return s[C.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(s){return ue(s,e,t)}))}const l=[];for(let s=0,r=e.length;s0&&ae(h,n),h.name=t.createUniqueName(n.name||"mesh_"+e),oe(h,n),c.extensions&&re(i,h,c),t.assignFinalMaterial(h),a.push(h)}for(let s=0,i=a.length;s1?new Group:1===t.length?t[0]:new Object3D,r!==t[0])for(let e=0,s=t.length;e{const t=new Map;for(const[e,s]of n.associations)(e instanceof Material||e instanceof Texture)&&t.set(e,s);return e.traverse((e=>{const s=n.associations.get(e);null!=s&&t.set(e,s)})),t})(l),l}))}}function me(e,t,s,i){const n=s.nodes[e];return i.getDependency("node",e).then((function(e){if(void 0===n.skin)return e;let t;return i.getDependency("skin",n.skin).then((function(e){t=e;const s=[];for(let e=0,n=t.joints.length;e{const s=n[e];return s&&(l={profileId:e,profilePath:`${t}/${s.path}`,deprecated:!!s.deprecated}),!!l})),!l){if(!s)throw new Error("No matching profile name found");const e=n[s];if(!e)throw new Error(`No matching profile name found and default profile "${s}" missing.`);l={profileId:s,profilePath:`${t}/${e.path}`,deprecated:!!e.deprecated}}const r=await be(l.profilePath);let o;if(i){let t;if(t="any"===e.handedness?r.layouts[Object.keys(r.layouts)[0]]:r.layouts[e.handedness],!t)throw new Error(`No matching handedness, ${e.handedness}, in profile ${l.profileId}`);t.assetPath&&(o=l.profilePath.replace("profile.json",t.assetPath))}return{profile:r,assetPath:o}}const ye={xAxis:0,yAxis:0,button:0,state:fe.ComponentState.DEFAULT};class ve{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===fe.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(ye)}updateFromComponent({xAxis:e,yAxis:t,button:s,state:i}){const{normalizedXAxis:n,normalizedYAxis:l}=function(e=0,t=0){let s=e,i=t;if(Math.sqrt(e*e+t*t)>1){const n=Math.atan2(t,e);s=Math.cos(n),i=Math.sin(n)}return{normalizedXAxis:.5*s+.5,normalizedYAxis:.5*i+.5}}(e,t);switch(this.componentProperty){case fe.ComponentProperty.X_AXIS:this.value=this.states.includes(i)?n:.5;break;case fe.ComponentProperty.Y_AXIS:this.value=this.states.includes(i)?l:.5;break;case fe.ComponentProperty.BUTTON:this.value=this.states.includes(i)?s:0;break;case fe.ComponentProperty.STATE:this.valueNodeProperty===fe.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(i):this.value=this.states.includes(i)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}}class we{constructor(e,t){if(!(e&&t&&t.visualResponses&&t.gamepadIndices&&0!==Object.keys(t.gamepadIndices).length))throw new Error("Invalid arguments supplied");this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach((e=>{const s=new ve(t.visualResponses[e]);this.visualResponses[e]=s})),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:fe.ComponentState.DEFAULT,button:void 0!==this.gamepadIndices.button?0:void 0,xAxis:void 0!==this.gamepadIndices.xAxis?0:void 0,yAxis:void 0!==this.gamepadIndices.yAxis?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(e){if(this.values.state=fe.ComponentState.DEFAULT,void 0!==this.gamepadIndices.button&&e.buttons.length>this.gamepadIndices.button){const t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||1===this.values.button?this.values.state=fe.ComponentState.PRESSED:(t.touched||this.values.button>fe.ButtonTouchThreshold)&&(this.values.state=fe.ComponentState.TOUCHED)}void 0!==this.gamepadIndices.xAxis&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===fe.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>fe.AxisTouchThreshold&&(this.values.state=fe.ComponentState.TOUCHED)),void 0!==this.gamepadIndices.yAxis&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===fe.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>fe.AxisTouchThreshold&&(this.values.state=fe.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach((e=>{e.updateFromComponent(this.values)}))}}class _e{constructor(e,t,s){if(!e)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No profile supplied");this.xrInputSource=e,this.assetUrl=s,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach((e=>{const t=this.layoutDescription.components[e];this.components[e]=new we(e,t)})),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const e=[];return Object.values(this.components).forEach((t=>{e.push(t.data)})),e}updateFromGamepad(){Object.values(this.components).forEach((e=>{e.updateFromGamepad(this.xrInputSource.gamepad)}))}}class Se extends THREE.Object3D{constructor(){super(),this.motionController=null,this.envMap=null}setEnvironmentMap(e){return this.envMap==e||(this.envMap=e,this.traverse((e=>{e.isMesh&&(e.material.envMap=this.envMap,e.material.needsUpdate=!0)}))),this}updateMatrixWorld(e){super.updateMatrixWorld(e),this.motionController&&(this.motionController.updateFromGamepad(),Object.values(this.motionController.components).forEach((e=>{Object.values(e.visualResponses).forEach((e=>{const{valueNode:t,minNode:s,maxNode:i,value:n,valueNodeProperty:l}=e;t&&(l===fe.VisualResponseProperty.VISIBILITY?t.visible=n:l===fe.VisualResponseProperty.TRANSFORM&&(t.quaternion.slerpQuaternions(s.quaternion,i.quaternion,n),t.position.lerpVectors(s.position,i.position,n)))}))})))}}function Ae(e,t){!function(e,t){Object.values(e.components).forEach((e=>{const{type:s,touchPointNodeName:i,visualResponses:n}=e;if(s===fe.ComponentType.TOUCHPAD)if(e.touchPointNode=t.getObjectByName(i),e.touchPointNode){const t=new SphereGeometry(.001),s=new MeshBasicMaterial({color:255}),i=new Mesh(t,s);e.touchPointNode.add(i)}else console.warn(`Could not find touch dot, ${e.touchPointNodeName}, in touchpad component ${e.id}`);Object.values(n).forEach((e=>{const{valueNodeName:s,minNodeName:i,maxNodeName:n,valueNodeProperty:l}=e;if(l===fe.VisualResponseProperty.TRANSFORM){if(e.minNode=t.getObjectByName(i),e.maxNode=t.getObjectByName(n),!e.minNode)return void console.warn(`Could not find ${i} in the model`);if(!e.maxNode)return void console.warn(`Could not find ${n} in the model`)}e.valueNode=t.getObjectByName(s),e.valueNode||console.warn(`Could not find ${s} in the model`)}))}))}(e.motionController,t),e.envMap&&t.traverse((t=>{t.isMesh&&(t.material.envMap=e.envMap,t.material.needsUpdate=!0)})),e.add(t)}class xe{constructor(e=null){this.gltfLoader=e,this.path="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",this._assetCache={},this.gltfLoader||(this.gltfLoader=new f)}createControllerModel(e){const t=new Se;let s=null;return e.addEventListener("connected",(e=>{const i=e.data;"tracked-pointer"===i.targetRayMode&&i.gamepad&&Ce(i,this.path,"generic-trigger").then((({profile:e,assetPath:n})=>{t.motionController=new _e(i,e,n);const l=this._assetCache[t.motionController.assetUrl];if(l)s=l.scene.clone(),Ae(t,s);else{if(!this.gltfLoader)throw new Error("GLTFLoader not set.");this.gltfLoader.setPath(""),this.gltfLoader.load(t.motionController.assetUrl,(e=>{this._assetCache[t.motionController.assetUrl]=e,s=e.scene.clone(),Ae(t,s)}),null,(()=>{throw new Error(`Asset ${t.motionController.assetUrl} missing or malformed.`)}))}})).catch((e=>{console.warn(e)}))})),e.addEventListener("disconnected",(()=>{t.motionController=null,t.remove(s),s=null})),t}}class ke extends THREE.EventDispatcher{constructor(e){if(super(),void 0===e)return void console.error("ControllerGestures must be passed a renderer");const t=new THREE.Clock;this.controller1=e.xr.getController(0),this.controller1.userData.gestures={index:0},this.controller1.userData.selectPressed=!1,this.controller1.addEventListener("selectstart",i),this.controller1.addEventListener("selectend",n),this.controller2=e.xr.getController(1),this.controller2.userData.gestures={index:1},this.controller2.userData.selectPressed=!1,this.controller2.addEventListener("selectstart",i),this.controller2.addEventListener("selectend",n),this.doubleClickLimit=.2,this.pressMinimum=.4,this.right=new THREE.Vector3(1,0,0),this.up=new THREE.Vector3(0,1,0),this.type="unknown",this.prevTap="none",this.clock=t;const s=this;function i(){const e=this.userData.gestures;e.startPosition=void 0,e.startTime=t.getElapsedTime(),-1==s.type.indexOf("tap")&&(e.taps=0),s.type="unknown",this.userData.selectPressed=!0}function n(){const e=this.userData.gestures;e.endTime=t.getElapsedTime();e.endTime-e.startTime.05&&(e.startPosition=this.controller1.position.clone())),this.controller2.userData.selectPressed&&void 0===t.startPosition&&(i=s-t.startTime,i>.05&&(t.startPosition=this.controller2.position.clone())),!this.controller1.userData.selectPressed&&"tap"===this.type&&(i=this.clock.getElapsedTime()-e.endTime,i>this.doubleClickLimit)){switch(e.taps){case 1:self.prevTap="tap";break;case 2:this.dispatchEvent({type:"doubletap",position:this.controller1.position,matrixWorld:this.controller1.matrixWorld}),self.prevTap="doubletap"}this.type="unknown",e.taps=0}if("unknown"===this.type&&this.touch)"doubletap"==self.prevTap?(this.type="pinch",this.startDistance=this.controller1.position.distanceTo(this.controller2.position),this.dispatchEvent({type:"pinch",delta:new THREE.Vector3(0,0,0),scale:1,initialise:!0})):(this.type="pan",this.startPosition=this.controller1.position.clone(),this.dispatchEvent({type:"pan",delta:new THREE.Vector3(0,0,0),initialise:!0}));else if(("pinch"===this.type||"pan"===this.type)&&"doubletap"==self.prevTap&&this.controller2.position){const e=this.controller1.position.distanceTo(this.controller2.position)/this.startDistance,t=this.controller1.position.clone().sub(this.startPosition);this.dispatchEvent({type:"pinch",delta:t,scale:e})}}}class Oe{constructor(e,t){this.config=void 0===t?{panelSize:{width:1,height:1},width:512,height:512,opacity:.7,body:{fontFamily:"Arial",fontSize:30,padding:20,backgroundColor:"#000",fontColor:"#fff",borderRadius:6}}:t,void 0===this.config.width&&(this.config.width=512),void 0===this.config.height&&(this.config.height=512),void 0===this.config.body&&(this.config.body={fontFamily:"Arial",size:30,padding:20,backgroundColor:"#000",fontColor:"#fff",borderRadius:6});const s=this.config.body;void 0===s.borderRadius&&(s.borderRadius=6),void 0===s.fontFamily&&(s.fontFamily="Arial"),void 0===s.padding&&(s.padding=20),void 0===s.fontSize&&(s.fontSize=30),void 0===s.backgroundColor&&(s.backgroundColor="#000"),void 0===s.fontColor&&(s.fontColor="#fff"),Object.entries(this.config).forEach((([e,t])=>{if(!("object"!=typeof t||"panelSize"===e||t instanceof THREE.WebGLRenderer||t instanceof THREE.Scene)){const e=void 0!==t.position?t.position:{x:0,y:0};void 0!==e.left&&void 0===e.x&&(e.x=e.left),void 0!==e.top&&void 0===e.y&&(e.y=e.top);const s=void 0!==t.width?t.width:this.config.width,i=void 0!==t.height?t.height:this.config.height;void 0!==e.right&&void 0===e.x&&(e.x=this.config.width-e.right-s),void 0!==e.bottom&&void 0===e.y&&(e.y=this.config.height-e.bottom-i),void 0===e.x&&(e.x=0),void 0===e.y&&(e.y=0),t.position=e,void 0===t.type&&(t.type="text")}}));const i=this.createOffscreenCanvas(this.config.width,this.config.height);this.context=i.getContext("2d"),this.context.save();const n=void 0!==this.config.opacity?this.config.opacity:.7,l=new THREE.MeshBasicMaterial({transparent:!0,opacity:n});this.panelSize=void 0!==this.config.panelSize?this.config.panelSize:{width:1,height:1};const r=new THREE.PlaneGeometry(this.panelSize.width,this.panelSize.height);this.mesh=new THREE.Mesh(r,l),this.texture=new THREE.CanvasTexture(i),this.mesh.material.map=this.texture,this.scene=this.config.scene;if(Object.values(this.config).filter((e=>"input-text"===e.type)).length>0){this.keyboard=new Re(this.panelSize.width,this.config.renderer);this.keyboard.mesh.position.set(0,-.3,.2),this.mesh.add(this.keyboard.mesh)}if(void 0===e)this.content={body:""},this.config.body.type="text";else{this.content=e;Object.values(t).filter((e=>"button"===e.type||"scroll"===e.overflow||"input-text"===e.type)).length>0&&(void 0===t||void 0===t.renderer?console.warn("CanvasUI: button, scroll or input-text in the config but no renderer"):(this.renderer=t.renderer,this.initControllers()))}this.selectedElements=[void 0,void 0],this.selectPressed=[!1,!1],this.scrollData=[void 0,void 0],this.intersects=[void 0,void 0],this.needsUpdate=!0,this.update()}getIntersectY(e){const t=this.config.height||512,s=this.intersects[e];return void 0===s||void 0===s.uv?0:(1-s.uv.y)*t}initControllers(){this.vec3=new THREE.Vector3,this.mat4=new THREE.Matrix4,this.raycaster=new THREE.Raycaster;const e=this;function t(t){const s=t.target===e.controller?0:1,i=e.selectedElements[s];if(void 0!==i)if("button"==i.type)e.select(s);else if("input-text"==i.type&&e.keyboard)if(e.keyboard.visible)e.keyboard.linkedUI=void 0,e.keyboard.linkedText=void 0,e.keyboard.linkedElement=void 0,e.keyboard.visible=!1;else{let t;e.keyboard.linkedUI=e,Object.entries(e.config).forEach((([e,s])=>{s==i&&(t=e)}));const s=(.5-(i.position.y+i.height+e.config.body.padding)/e.config.height)*e.panelSize.height,n=Math.max(e.panelSize.width,e.panelSize.height)/2;e.keyboard.position.set(0,-n/1.5-s,.1),e.keyboard.linkedText=e.content[t],e.keyboard.linkedName=t,e.keyboard.linkedElement=i,e.keyboard.visible=!0}}function s(t){const s=t.target===e.controller?0:1;if(e.selectPressed[s]=!0,void 0!==e.selectedElements[s]&&"scroll"==e.selectedElements[s].overflow){const t=e.selectedElements[s];e.scrollData[s]={scrollY:t.scrollY,rayY:e.getIntersectY(s)}}}function i(t){const s=t.target===e.controller?0:1;e.selectPressed[s]=!1,void 0!==e.selectedElements[s]&&"scroll"==e.selectedElements[s].overflow&&(e.scrollData[s]=void 0)}if(this.controller=this.renderer.xr.getController(0),this.controller.addEventListener("select",t),this.controller.addEventListener("selectstart",s),this.controller.addEventListener("selectend",i),this.controller1=this.renderer.xr.getController(1),this.controller1.addEventListener("select",t),this.controller1.addEventListener("selectstart",s),this.controller1.addEventListener("selectend",i),this.scene){const e=.015,t=new THREE.IcosahedronBufferGeometry(e),s=new THREE.MeshBasicMaterial({color:170}),i=new THREE.Mesh(t,s);i.visible=!1,this.scene.add(i);const n=new THREE.Mesh(t,s);n.visible=!1,this.scene.add(n),this.intersectMesh=[i,n]}}setClip(e){const t=this.context;if(t.restore(),t.save(),void 0!==e.clipPath){const s=new Path2D(e.clipPath);t.clip(s)}else{const s=void 0!==e.position?e.position:{x:0,y:0},i=e.borderRadius||0,n=e.width||this.config.width,l=e.height||this.config.height;if(t.beginPath(),0!==i){const e=Math.PI/2;t.moveTo(s.x+i,s.y),t.arc(s.x+i,s.y+i,i,e,2*e,!0),t.lineTo(s.x,s.y+l-i),t.arc(s.x+i,s.y+l-i,i,0,e,!0),t.lineTo(s.x+n-i,s.y+l),t.arc(s.x+n-i,s.y+l-i,i,3*e,4*e,!0),t.lineTo(s.x+n,s.y+i),t.arc(s.x+n-i,s.y+i,i,2*e,3*e,!0),t.closePath(),t.clip()}else t.rect(s.x,s.y,n,l),t.clip()}}setPosition(e,t,s){void 0!==this.mesh&&this.mesh.position.set(e,t,s)}setRotation(e,t,s){void 0!==this.mesh&&this.mesh.rotation.set(e,t,s)}updateElement(e,t){let s=this.content[e];void 0!==s?("object"==typeof s?s.content=t:s=t,this.content[e]=s,this.needsUpdate=!0):console.warn(`CanvasGUI.updateElement: No ${e} found`)}get panel(){return this.mesh}getElementAtLocation(e,t){const s=this,i=Object.entries(this.config).filter((([i,n])=>{if(!("object"!=typeof n||"panelSize"===i||"body"===i||n instanceof THREE.WebGLRenderer||n instanceof THREE.Scene)){const i=n.position,l=void 0!==n.width?n.width:s.config.width,r=void 0!==n.height?n.height:s.config.height;return e>=i.x&&e=i.y&&t0?(this.hover(t,s[0].uv),this.intersects[t]=s[0],this.scroll(t)):(this.hover(t),this.intersects[t]=void 0,this.scroll(t))}update(){if(void 0===this.mesh)return;if(this.controller&&this.handleController(this.controller,0),this.controller1&&this.handleController(this.controller1,1),this.keyboard&&this.keyboard.visible&&this.keyboard.update(),!this.needsUpdate)return;let e=this.context;e.clearRect(0,0,this.config.width,this.config.height);const t=this.config.body.backgroundColor?this.config.body.backgroundColor:"#000";!this.config.body.fontFamily||this.config.body.fontFamily;const s=this.config.body.fontColor?this.config.body.fontColor:"#fff";!this.config.body.fontSize||this.config.body.fontSize,this.setClip(this.config.body),e.fillStyle=t,e.fillRect(0,0,this.config.width,this.config.height);const i=this;Object.entries(this.content).forEach((([t,n])=>{const l=void 0!==i.config[t]?i.config[t]:i.config.body;if("none"!==(void 0!==l.display?l.display:"block")){const r=void 0!==l.position?l.position:{x:0,y:0},o=void 0!==l.width?l.width:i.config.width,a=void 0!==l.height?l.height:i.config.height;"button"!=l.type||n.toLowerCase().startsWith("")||(void 0===l.borderRadius&&(l.borderRadius=6),void 0===l.textAlign&&(l.textAlign="center")),i.setClip(l);const d=n.toLowerCase().startsWith(""),c=void 0!==i.selectedElements[0]&&this.selectedElements[0]===l||void 0!==i.selectedElements[1]&&this.selectedElements[1]===l;if(void 0!==l.backgroundColor&&(c&&"button"==l.type&&void 0!==l.hover?e.fillStyle=l.hover:e.fillStyle=l.backgroundColor,e.fillRect(r.x,r.y,o,a)),"text"==l.type||"button"==l.type||"input-text"==l.type){let h=!1;if(c?(d||"button"!=l.type?e.fillStyle=void 0!==l.hover?l.hover:void 0!==l.fontColor?l.fontColor:s:e.fillStyle=void 0!==l.fontColor?l.fontColor:s,h=void 0===l.hover):e.fillStyle=void 0!==l.fontColor?l.fontColor:s,d){const t=n.toUpperCase().substring(6,n.length-7);e.save(),e.translate(r.x,r.y);const s=new Path2D(t);e.fill(s),e.restore()}else i.wrapText(t,n);h&&(e.beginPath(),e.strokeStyle="#fff",e.lineWidth=2,e.rect(r.x,r.y,o,a),e.stroke())}else if("img"==l.type)if(void 0===l.img)this.loadImage(n).then((e=>{console.log(`w: ${e.width} | h: ${e.height}`),l.img=e,i.needsUpdate=!0,i.update()})).catch((e=>console.error(e)));else{const t=o/(l.img.width/l.img.height);e.drawImage(l.img,r.x,r.y,o,t)}}})),this.needsUpdate=!1,this.texture.needsUpdate=!0}loadImage(e){return new Promise(((t,s)=>{const i=new THREE.Image;i.addEventListener("load",(()=>t(i))),i.addEventListener("error",(e=>s(e))),i.src=e}))}createOffscreenCanvas(e,t){const s=document.createElement("canvas");return s.width=e,s.height=t,s}fillRoundedRect(e,t,s,i,n){const l=this.context;l.beginPath(),l.moveTo(e+n,t),l.lineTo(e+s-n,t),l.quadraticCurveTo(e+s,t,e+s,t+n),l.lineTo(e+s,t+i-n),l.quadraticCurveTo(e+s,t+i,e+s-n,t+i),l.lineTo(e+n,t+i),l.quadraticCurveTo(e,t+i,e,t+i-n),l.lineTo(e,t+n),l.quadraticCurveTo(e,t,e+n,t),l.closePath(),l.fill()}lookAt(e){void 0!==this.mesh&&(e instanceof Vector3?this.mesh.lookAt(e):console.error("CanvasUI lookAt called parameter not a THREE.Vector3"))}get visible(){return void 0!==this.mesh&&this.mesh.visible}set visible(e){this.mesh&&(this.mesh.visible=e)}get position(){if(void 0!==this.mesh)return this.mesh.position}set position(e){void 0!==this.mesh&&(e instanceof Vector3?this.mesh.position.copy(e):console.error("CanvasUI trying to set the mesh position using a parameter that is not a THREE.Vector3"))}get quaternion(){if(void 0!==this.mesh)return this.mesh.quaternion}set quaternion(e){void 0!==this.mesh&&(e instanceof QUaternion?this.mesh.quaternion.copy(e):console.error("CanvasUI trying to set the mesh quaternion using a parameter that is not a THREE.Quaternion"))}wrapText(e,t){const s=t.split(" ");let i="";const n=[],l=void 0!==this.config[e]?this.config[e]:this.config.body,r=void 0!==l.width?l.width:this.config.width,o=void 0!==l.height?l.height:this.config.height,a=void 0!==l.position?l.position:{x:0,y:0},d=void 0!==l.padding?l.padding:void 0!==this.config.body.padding?this.config.body.padding:10,c=void 0!==l.paddingTop?l.paddingTop:d,h=void 0!==l.paddingLeft?l.paddingLeft:d,p=void 0!==l.paddingBottom?l.paddingBottom:d,m=void 0!==l.paddingRight?l.paddingRight:d,u={x:a.x+h,y:a.y+c,width:r-h-m,height:o-c-p},g=void 0!==l.textAlign?l.textAlign:void 0!==this.config.body.textAlign?this.config.body.textAlign:"left",f=void 0!==l.fontSize?l.fontSize:void 0!==this.config.body.fontSize?this.config.body.fontSize:30,b=void 0!==l.fontFamily?l.fontFamily:void 0!==this.config.body.fontFamily?this.config.body.fontFamily:"Arial",C=f+(void 0!==l.leading?l.leading:void 0!==this.config.body.leading?this.config.body.leading:8),y=this.context;y.textAlign=g,y.font=`${f}px '${b}'`,s.forEach((function(e){let t=s.length>1?`${i}${e} `:e,l=y.measureText(t);if(l.width>u.width&&e.length>1)if(0==i.length&&l.width>u.width){for(;l.width>u.width;){let s=0;do{s++,t=e.substr(0,s),l=y.measureText(t)}while(l.widthu.height&&"scroll"===l.overflow){void 0===l.scrollY&&(l.scrollY=0);const e=void 0!==l.fontColor?l.fontColor:this.config.body.fontColor;y.fillStyle="#aaa",this.fillRoundedRect(a.x+r-12,a.y,12,o,6),y.fillStyle="#666";const t=u.height/v,s=t*o,i=-l.scrollY*t;this.fillRoundedRect(a.x+r-12,a.y+i,12,s,6),y.fillStyle=e,w=l.scrollY,l.minScrollY=u.height-v}let _,S=w+u.y+f/2;switch(g){case"center":_=u.x+u.width/2;break;case"right":_=u.x+u.width;break;default:_=u.x}n.forEach((e=>{S+C>0&&y.fillText(e,_,S),S+=C}))}}class Re{constructor(e,t,s="EN"){const i=this.getConfig(s);i.panelSize={width:e,height:.5*e},i.height=256,i.body={backgroundColor:"#555"},i.renderer=t;const n=this.getContent(s);this.keyboard=new Oe(n,i),this.keyboard.mesh.visible=!1,this.shift=!1}get mesh(){return this.keyboard.mesh}getConfig(e){const t={};let s=10;const i=39.2,n=49,l="#333",r="#000";let o=s,a=s;for(let e=0;e<10;e++){const d={type:"button",position:{x:a,y:o},width:i,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e)};t[`btn${e}`]=d,a+=49.2}o+=59,a=s;for(let e=0;e<10;e++){const d={type:"button",position:{x:a,y:o},width:i,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+10)};t[`btn${e+10}`]=d,a+=49.2}o+=59,a=s;for(let e=0;e<9;e++){const d=0==e||8==e?1.5*i+5:i,c={type:"button",position:{x:a,y:o},width:d,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+20)};t[`btn${e+20}`]=c,a+=d+s}o+=59,a=s;for(let e=0;e<5;e++){const d=0==e||4==e?88.4:2==e?186.8:i,c={type:"button",position:{x:a,y:o},width:d,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+30)};0==e&&(c.fontSize=20),t[`btn${e+30}`]=c,a+=d+s}return t}getContent(e,t=0){let s,i={};switch(this.language=e,this.keyboardIndex=t,t){case 0:s=["q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","@","⇧","z","x","c","v","b","n","m","⇦","","?123",","," ",".","↲"];for(let e=0;e","_","`","~",":",";","⇦","","abc",","," ",".","↲"];for(let e=0;e=0;e--){let s=t.scene.children[e];t.scene.remove(s)}else t.scene=new THREE.Scene;if(void 0!==t.scene_ghost)for(let e=t.scene_ghost.children.length-1;e>=0;e--){let s=t.scene_ghost.children[e];t.scene_ghost.remove(s)}else t.scene_ghost=new THREE.Scene;if(""!=s.htmlCls.setHtmlCls.getCookie("shininess")){let e=parseFloat(s.htmlCls.setHtmlCls.getCookie("shininess"));t.shininess!=e&&s.htmlCls.clickMenuCls.setLogCmd("set shininess "+e,!0),t.shininess=e}if(!s.bNode&&""!=s.htmlCls.setHtmlCls.getCookie("light1")){let e=parseFloat(s.htmlCls.setHtmlCls.getCookie("light1")),i=parseFloat(s.htmlCls.setHtmlCls.getCookie("light2")),n=parseFloat(s.htmlCls.setHtmlCls.getCookie("light3"));t.light1==e&&t.light2==i&&t.light3==n||s.htmlCls.clickMenuCls.setLogCmd("set light | light1 "+e+" | light2 "+i+" | light3 "+n,!0),t.light1=e,t.light2=i,t.light3=n}t.directionalLight=new THREE.DirectionalLight(16777215,t.light1),t.directionalLight2=new THREE.DirectionalLight(16777215,t.light2),t.directionalLight3=new THREE.DirectionalLight(16777215,t.light3),t.cam_z>0?(t.directionalLight.position.set(-1,1,1),t.directionalLight2.position.set(1,1,1),t.directionalLight3.position.set(1,1,-1),t.lightPos=new THREE.Vector3(-1,1,1),t.lightPos2=new THREE.Vector3(1,1,1),t.lightPos3=new THREE.Vector3(1,1,-1)):(t.directionalLight.position.set(-1,1,-1),t.directionalLight2.position.set(1,1,-1),t.directionalLight3.position.set(1,1,1),t.lightPos=new THREE.Vector3(-1,1,-1),t.lightPos2=new THREE.Vector3(1,1,-1),t.lightPos3=new THREE.Vector3(1,1,1));let i=new THREE.AmbientLight(8947848);if(t.scene.add(t.directionalLight),t.scene.add(i),void 0!==t.mdl)for(let e=t.mdl.children.length-1;e>=0;e--){let s=t.mdl.children[e];s.geometry&&s.geometry.dispose(),s.material&&s.material.dispose(),t.mdl.remove(s)}if(void 0!==t.mdlImpostor){for(let e=t.mdlImpostor.children.length-1;e>=0;e--){let s=t.mdlImpostor.children[e];s.geometry&&s.geometry.dispose(),s.material&&s.material.dispose(),t.mdlImpostor.remove(s)}t.mdlImpostor.children.length=0}s.bNode||t.renderer.renderLists.dispose(),t.mdl=new THREE.Object3D,t.mdlImpostor=new THREE.Object3D,t.scene.add(t.mdl),t.scene.add(t.mdlImpostor),t.mdl_ghost=new THREE.Object3D,t.scene_ghost.add(t.mdl_ghost),t.objects=[],t.objects_ghost=[],t.raycaster=new THREE.Raycaster,t.projector=new THREE.Projector,t.mouse=new THREE.Vector2;let n=s.parasCls.backgroundColors[t.opts.background.toLowerCase()];s.bNode||("transparent"===t.opts.background.toLowerCase()?t.renderer.setClearColor(n,0):t.renderer.setClearColor(n,1)),t.perspectiveCamera=new THREE.PerspectiveCamera(20,t.container.whratio,.1,1e4),t.perspectiveCamera.position.set(0,0,t.cam_z),t.perspectiveCamera.lookAt(new THREE.Vector3(0,0,0)),t.orthographicCamera=new THREE.OrthographicCamera,t.orthographicCamera.position.set(0,0,t.cam_z),t.orthographicCamera.lookAt(new THREE.Vector3(0,0,0)),t.cams={perspective:t.perspectiveCamera,orthographic:t.orthographicCamera}}setVrAr(){let e=this.icn3d;e.icn3dui;let t=this;e.bSetVrAr=!0,e.bVr?(e.canvasUI=this.createUI(),e.raycasterVR=new THREE.Raycaster,e.workingMatrix=new THREE.Matrix4,e.workingVector=new THREE.Vector3,e.origin=new THREE.Vector3,e.dolly=new THREE.Object3D,e.dolly.position.z=5,e.dolly.add(e.cam),e.scene.add(e.dolly),e.dollyId=e.dolly.id,e.dummyCam=new THREE.Object3D,e.cam.add(e.dummyCam),e.clock=new THREE.Clock,e.controllers=this.getControllers(),e.controllers.forEach((s=>{s.addEventListener("connected",(function(e){try{const s={},i="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",n="generic-trigger";Ce(e.data,i,n).then((({profile:i,assetPath:n})=>{s.name=i.profileId,s.targetRayMode=e.data.targetRayMode,Object.entries(i.layouts).forEach((([e,t])=>{const i={};Object.values(t.components).forEach((e=>{i[e.rootNodeName]=e.gamepadIndices})),s[e]=i})),t.updateControllers(s)}))}catch(e){}})),s.addEventListener("disconnected",(function(){this.remove(this.children[0]),e.controllers.forEach((e=>{}))}))}))):e.bAr&&(e.gestures=new ke(e.renderer),e.scene.add(e.gestures.controller1),e.scene.add(e.gestures.controller2),e.gestures.addEventListener("doubletap",(e=>{t.positionCenter()})),e.gestures.addEventListener("pinch",(s=>{if(void 0!==s.initialise)t.startPosition=e.mdl.position.clone(),t.startScale=e.mdl.scale.clone();else{let i=1;const n=t.startScale.clone().multiplyScalar(s.scale*i);e.mdl.scale.copy(n)}})))}positionCenter(){let e=this.icn3d;e.icn3dui;const t=e.gestures.controller1;e.mdl.position.set(-.06,0,-.6).applyMatrix4(t.matrixWorld),e.mdl.scale.copy(new THREE.Vector3(.005,.005,.005))}setVrArButtons(){let e=this.icn3d,t=e.icn3dui;e.bSetVrArButtons=!0,t.bNode||($("#"+t.pre+"VRButton").remove(),$("#"+t.pre+"viewer").get(0).appendChild(e.VRButtonCls.createButton(e.renderer)),$("#"+t.pre+"ARButton").remove(),$("#"+t.pre+"viewer").get(0).appendChild(e.ARButtonCls.createButton(e.renderer)))}updateControllers(e){this.icn3d.icn3dui,this.addEventForController(e,"right"),this.addEventForController(e,"left")}addEventForController(e,t){let s=this.icn3d;s.icn3dui;const i="right"==t?s.renderer.xr.getController(0):s.renderer.xr.getController(1),n="right"==t?e.right:e.left;if(void 0!==n){let e=!1,t=!1;Object.keys(n).forEach((i=>{-1!=i.indexOf("trigger")&&(e=!0),-1!=i.indexOf("squeeze")&&(t=!0),-1==i.indexOf("thumbstick")&&-1==i.indexOf("touchpad")||(s.xAxisIndex=n[i].xAxis,s.yAxisIndex=n[i].yAxis)})),e&&(i.addEventListener("selectstart",(function(){this.userData.selectPressed=!0})),i.addEventListener("selectend",(function(){this.userData.selectPressed=!1,this.userData.selected=void 0}))),t&&(i.addEventListener("squeezestart",(function(){this.userData.squeezePressed=!0,s.cam.add(s.canvasUI.mesh)})),i.addEventListener("squeezeend",(function(){this.userData.squeezePressed=!1,s.cam.remove(s.canvasUI.mesh)})))}}createUI(){let e=this.icn3d;e.icn3dui;let t=94,s=50,i=44,n=12,l="#1c94c4",r="#ccc",o="#fbcb09";const a={panelSize:{width:2,height:1.2},height:300,select:{type:"button",position:{top:6,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},residue:{type:"button",position:{top:6,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.pk=2,e.cam.remove(e.canvasUI.mesh)}},secondarySelect:{type:"button",position:{top:6,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.pk=3,e.cam.remove(e.canvasUI.mesh)}},chainSelect:{type:"button",position:{top:6,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.pk=5,e.cam.remove(e.canvasUI.mesh)}},style:{type:"button",position:{top:62,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},ribbon:{type:"button",position:{top:62,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","ribbon"),e.setOptionCls.setStyle("nucleotides","nucleotide cartoon"),e.cam.remove(e.canvasUI.mesh)}},schematic:{type:"button",position:{top:62,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","schematic"),e.setOptionCls.setStyle("nucleotides","schematic"),e.cam.remove(e.canvasUI.mesh)}},stick:{type:"button",position:{top:62,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","stick"),e.setOptionCls.setStyle("nucleotides","stick"),e.cam.remove(e.canvasUI.mesh)}},sphere:{type:"button",position:{top:62,left:406},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","sphere"),e.setOptionCls.setStyle("nucleotides","sphere"),e.cam.remove(e.canvasUI.mesh)}},color:{type:"button",position:{top:118,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},rainbow:{type:"button",position:{top:118,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","rainbow for chains"),e.cam.remove(e.canvasUI.mesh)}},atomColor:{type:"button",position:{top:118,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","atom"),e.cam.remove(e.canvasUI.mesh)}},secondaryColor:{type:"button",position:{top:118,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","secondary structure green"),e.cam.remove(e.canvasUI.mesh)}},AlphaFold:{type:"button",position:{top:118,left:406},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","confidence"),e.cam.remove(e.canvasUI.mesh)}},unicolor:{type:"button",position:{top:174,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},red:{type:"button",position:{top:168,left:100},width:i,height:s,fontColor:"red",hover:o,onSelect:function(){e.setOptionCls.setOption("color","red"),e.cam.remove(e.canvasUI.mesh)}},green:{type:"button",position:{top:168,left:150},width:i,height:s,fontColor:"green",hover:o,onSelect:function(){e.setOptionCls.setOption("color","green"),e.cam.remove(e.canvasUI.mesh)}},blue:{type:"button",position:{top:168,left:200},width:i,height:s,fontColor:"blue",hover:o,onSelect:function(){e.setOptionCls.setOption("color","blue"),e.cam.remove(e.canvasUI.mesh)}},magenta:{type:"button",position:{top:168,left:250},width:i,height:s,fontColor:"magenta",hover:o,onSelect:function(){e.setOptionCls.setOption("color","magenta"),e.cam.remove(e.canvasUI.mesh)}},orange:{type:"button",position:{top:168,left:300},width:i,height:s,fontColor:"orange",hover:o,onSelect:function(){e.setOptionCls.setOption("color","FFA500"),e.cam.remove(e.canvasUI.mesh)}},cyan:{type:"button",position:{top:168,left:350},width:i,height:s,fontColor:"cyan",hover:o,onSelect:function(){e.setOptionCls.setOption("color","cyan"),e.cam.remove(e.canvasUI.mesh)}},gray:{type:"button",position:{top:168,left:400},width:i,height:s,fontColor:"gray",hover:o,onSelect:function(){e.setOptionCls.setOption("color","888888"),e.cam.remove(e.canvasUI.mesh)}},white:{type:"button",position:{top:168,left:450},width:i,height:s,fontColor:"white",hover:o,onSelect:function(){e.setOptionCls.setOption("color","white"),e.cam.remove(e.canvasUI.mesh)}},analysis:{type:"button",position:{top:230,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},interaction:{type:"button",position:{top:230,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){try{e.viewInterPairsCls.viewInteractionPairs(["selected"],["non-selected"],!1,"3d",1,1,1,1,1,1),e.cam.remove(e.canvasUI.mesh)}catch(e){}}},removeLabel:{type:"button",position:{top:230,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){for(let t in e.labels)e.labels[t]=[];e.drawCls.draw(),e.cam.remove(e.canvasUI.mesh)}},reset:{type:"button",position:{top:230,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.selectionCls.resetAll(),e.cam.remove(e.canvasUI.mesh)}},renderer:e.renderer},d=new Oe({select:"Select",residue:"Residue",secondarySelect:"SSE",chainSelect:"Chain",style:"Style",ribbon:"Ribbon",schematic:"Schem.",stick:"Stick",sphere:"Sphere",color:"Color",rainbow:"Rainbow",atomColor:"Atom",secondaryColor:"SSE",AlphaFold:"AlphaFold",unicolor:"UniColor",red:"M 50 15 L 15 15 L 15 50 L 50 50 Z",green:"M 50 15 L 15 15 L 15 50 L 50 50 Z",blue:"M 50 15 L 15 15 L 15 50 L 50 50 Z",magenta:"M 50 15 L 15 15 L 15 50 L 50 50 Z",orange:"M 50 15 L 15 15 L 15 50 L 50 50 Z",cyan:"M 50 15 L 15 15 L 15 50 L 50 50 Z",gray:"M 50 15 L 15 15 L 15 50 L 50 50 Z",white:"M 50 15 L 15 15 L 15 50 L 50 50 Z",analysis:"Analysis",interaction:"Interact",removeLabel:"No Label",reset:"Reset"},a);return d.mesh.position.set(0,0,-3),d}createUILog(){let e=this.icn3d;e.icn3dui;const t={panelSize:{width:2,height:2},height:512,info:{type:"text",overflow:"scroll",position:{top:6,left:6},width:506,height:506,backgroundColor:"#aaa",fontColor:"#000"},renderer:e.renderer},s=new Oe({info:"Debug info"},t);return s.mesh.position.set(0,-1,-2),s}getControllers(){let e=this.icn3d;e.icn3dui;const t=new xe,s=(new THREE.BufferGeometry).setFromPoints([new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,-1)]),i=new THREE.Line(s);i.name="line",i.scale.z=50;const n=[];for(let s=0;s<=1;s++){const l=e.renderer.xr.getController(s);e.dolly.add(l),l.add(i.clone()),l.userData.selectPressed=!1,e.cam.add(l),n.push(l);const r=e.renderer.xr.getControllerGrip(s);r.add(t.createControllerModel(r)),e.scene.add(r)}return n}}class Ie{constructor(e){this.icn3d=e}setCamera(){let e=this.icn3d,t=e.icn3dui;if(e.bControlGl&&!t.bNode){window.cam=e.cams[e.opts.camera.toLowerCase()];let s=e.maxD;if(window.cam===e.perspectiveCamera){let i=void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>e.maxatomcnt;i?window.camMaxDFactor=1:void 0!==window.camMaxDFactorFog?window.camMaxDFactor=window.camMaxDFactorFog:window.camMaxDFactor=3,window.cam_z>0?window.cam.position.z=s*window.camMaxDFactor:window.cam.position.z=-s*window.camMaxDFactor,"yes"===e.opts.slab?i?window.cam.near=.1:void 0!==window.camMaxDFactorFog?window.cam.near=s*window.camMaxDFactorFog-10:window.cam.near=s*window.camMaxDFactor:window.cam.near=.1,window.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.TrackballControls(window.cam,void 0,e):t.bNode?e.controls=new THREE.TrackballControls(e.cam,document,e):e.controls=new THREE.TrackballControls(e.cam,document.getElementById(e.id),e)}else window.cam===e.orthographicCamera&&(void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>10*e.maxatomcnt?window.cam.right=e.maxD/2*1.5:window.cam.right=e.maxD/2*2.5,window.cam.left=-window.cam.right,window.cam.top=window.cam.right/e.container.whratio,window.cam.bottom=-window.cam.right/e.container.whratio,"yes"===e.opts.slab?window.cam.near=2*e.maxD:window.cam.near=0,window.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.OrthographicTrackballControls(window.cam,void 0,e):t.bNode?e.controls=new THREE.OrthographicTrackballControls(e.cam,document,e):e.controls=new THREE.OrthographicTrackballControls(e.cam,document.getElementById(e.id),e));window.cam.updateProjectionMatrix()}e.cam=e.cams[e.opts.camera.toLowerCase()];let s=e.maxD;if(e.cam===e.perspectiveCamera){let i=void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>e.maxatomcnt;i?e.camMaxDFactor=1:void 0!==e.camMaxDFactorFog?e.camMaxDFactor=e.camMaxDFactorFog:e.camMaxDFactor=3,e.cam_z>0?e.cam.position.z=s*e.camMaxDFactor:e.cam.position.z=-s*e.camMaxDFactor,"yes"===e.opts.slab?i?e.cam.near=.1:void 0!==e.camMaxDFactorFog?e.cam.near=s*e.camMaxDFactorFog-10:e.cam.near=s*e.camMaxDFactor:e.cam.near=.1,e.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.TrackballControls(e.cam,void 0,e):t.bNode?e.controls=new THREE.TrackballControls(e.cam,document,e):e.controls=new THREE.TrackballControls(e.cam,document.getElementById(e.id),e)}else e.cam===e.orthographicCamera&&(void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>10*e.maxatomcnt?e.cam.right=e.maxD/2*1.5:e.cam.right=e.maxD/2*2.5,e.cam.left=-e.cam.right,e.cam.top=e.cam.right/e.container.whratio,e.cam.bottom=-e.cam.right/e.container.whratio,"yes"===e.opts.slab?e.cam.near=2*e.maxD:e.cam.near=0,e.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.OrthographicTrackballControls(e.cam,void 0,e):t.bNode?e.controls=new THREE.OrthographicTrackballControls(e.cam,document,e):e.controls=new THREE.OrthographicTrackballControls(e.cam,document.getElementById(e.id),e));e.cam.updateProjectionMatrix()}}class Te{constructor(e){this.icn3d=e}setFog(e){let t=this.icn3d,s=t.icn3dui.parasCls.backgroundColors[t.opts.background.toLowerCase()];if(e){let e=t.applyCenterCls.centerAtoms(t.hAtoms);t.maxD=e.maxD,t.maxD<25&&(t.maxD=25)}let i=void 0!==t.biomtMatrices&&t.biomtMatrices.length*t.cnt>t.maxatomcnt;if("yes"===t.opts.fog)if("perspective"===t.opts.camera)if(i)t.scene.fog=void 0,t.bSetFog=!1;else{let e=t._zoomFactor>1?1*t._zoomFactor:t._zoomFactor;t.scene.fog=new THREE.Fog(s,2.5*t.maxD*e,4*t.maxD*e),t.bSetFog=!0,t.camMaxDFactorFog=3}else"orthographic"===t.opts.camera&&(t.scene.fog=void 0,t.bSetFog=!1);else t.scene.fog=void 0,t.bSetFog=!1}}class Me{constructor(e){this.icn3d=e}createBox(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(o.bNode)return;void 0===t&&(t=.8),void 0===s&&(s=!1),void 0===i&&(i=.8),l?void 0===n&&(n=r.hColor):void 0===n&&(n=e.color);let a=s?t:(o.parasCls.vdwRadii[e.elem.toUpperCase()]||t)*(i||1);this.createBox_base(e.coord,a,n,l)}createBox_base(e,t,s,i,n,l,r){let o,a=this.icn3d;a.icn3dui.bNode||(void 0===r&&(r=l?.5:1),new THREE.BoxGeometry(1,1,1),o=new THREE.Mesh(a.boxGeometry,new THREE.MeshPhongMaterial({transparent:!0,opacity:r,specular:a.frac,shininess:a.shininess,emissive:a.emissive,color:s})),o.scale.x=o.scale.y=o.scale.z=t,o.position.copy(e),a.mdl.add(o),i?a.prevHighlightObjects.push(o):n?a.prevOtherMesh.push(o):a.objects.push(o))}createBoxRepresentation_P_CA(e,t,s){let i=this.icn3d;if(i.icn3dui.bNode)return;let n=this;i.reprSubCls.createRepresentationSub(e,(function(e){"CA"!==e.name&&"O3'"!==e.name&&"O3*"!==e.name||n.createBox(e,void 0,void 0,t,void 0,s)}))}}class Pe{constructor(e){this.icn3d=e}createBrick(e,t,s,i){let n=this.icn3d;if(n.icn3dui.bNode)return;let l=new THREE.CylinderGeometry(1,1,1,4,1),r=new THREE.Mesh(l,new THREE.MeshPhongMaterial({specular:n.frac,shininess:n.shininess,emissive:n.emissive,color:i}));r.position.copy(e).add(t).multiplyScalar(.5),r.matrixAutoUpdate=!1,r.lookAt(t.clone().sub(e)),r.updateMatrix(),r.matrix.multiply((new THREE.Matrix4).makeScale(s,s,e.distanceTo(t))).multiply((new THREE.Matrix4).makeRotationX(.5*Math.PI)),n.mdl.add(r)}}class De{constructor(e){this.icn3d=e}createCurveSubArrow(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u){if(this.icn3d.icn3dui.bNode)return;let g=[],f=[];g.push(e),f.push(o),this.prepareStrand(g,f,t,s,i,void 0,n,l,r,a,d,!1,c,h,p,m,u),g=[],f=[]}createStripArrow(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g){if(this.icn3d.icn3dui.bNode)return;let f=[],b=[];f.push(e),f.push(t),b.push(o),b.push(a),this.prepareStrand(f,b,void 0,s,i,n,l,void 0,r,d,c,!0,h,p,m,u,g),f=[],b=[]}prepareStrand(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g,f){let b=this.icn3d,C=b.icn3dui;if(1===d.length)return;let y=i,v=!u,w=[];w.push(i[i.length-2]),w.push(i[i.length-1]),n=n||b.axisDIV;let _,S,A,x,k=2/(a-1),O={};for(let e=0,s=t.length;e1)if(void 0!==d){let i,n,l=[];for(let r=0,o=p.length;r0&&i.tubeCls.createTube(a,"CA",i.coilWidth,s),Object.keys(d).length>0&&i.strandCls.createStrand(d,void 0,void 0,!0,0,i.helixSheetWidth,!1,2*i.ribbonthickness,s)):(Object.keys(a).length>0&&i.tubeCls.createTube(a,"CA",i.coilWidth),Object.keys(d).length>0&&i.strandCls.createStrand(d,void 0,void 0,!0,0,i.helixSheetWidth,!1,2*i.ribbonthickness))}createCylinderCurve(e,t,s,i,n){let l=this.icn3d;if(l.icn3dui.bNode)return;let r,o,a,d,c,h,p=null;for(a in e)if(d=e[a],!d.het&&(c=d.structure+"_"+d.chain,h=d.structure+"_"+r,-1!=t.indexOf(d.name))){if(null!==p&&r===d.chain&&l.ParserUtilsCls.getResiNCBI(h,o)+1===l.ParserUtilsCls.getResiNCBI(c,d.resi)&&Math.abs(p.coord.x-d.coord.x)<8&&Math.abs(p.coord.y-d.coord.y)<8&&Math.abs(p.coord.z-d.coord.z)<8){let e=p.coord.clone().add(d.coord).multiplyScalar(.5);if(n)1===n&&(this.createCylinder(p.coord,e,s,p.color,n),this.createCylinder(e,d.coord,s,d.color,n),l.sphereCls.createSphere(d,s,!0,1,n));else if(i){let t=l.lineCls.createSingleLine(p.coord,e,p.color,!1);l.mdl.add(t),l.objects.push(t),t=l.lineCls.createSingleLine(e,d.coord,d.color,!1),l.mdl.add(t),l.objects.push(t)}else this.createCylinder(p.coord,e,s,p.color),this.createCylinder(e,d.coord,s,d.color),l.sphereCls.createSphere(d,s,!0,1,n)}p=d,r=d.chain,o=d.resi,l.sphereCls.createSphere(d,s,!0,1,n),2===n&&l.boxCls.createBox(d,void 0,void 0,void 0,void 0,n)}if(null!==p&&r===d.chain&&l.ParserUtilsCls.getResiNCBI(h,o)+1===l.ParserUtilsCls.getResiNCBI(c,d.resi)&&Math.abs(p.coord.x-d.coord.x)<8&&Math.abs(p.coord.y-d.coord.y)<8&&Math.abs(p.coord.z-d.coord.z)<8){let e=p.coord.add(d.coord).multiplyScalar(.5);if(n)1===n&&(this.createCylinder(p.coord,e,s,p.color,n),this.createCylinder(e,d.coord,s,d.color,n),l.sphereCls.createSphere(d,s,!0,1,n));else if(i){let t=l.lineCls.createSingleLine(p.coord,e,p.color,!1);l.mdl.add(t),l.objects.push(t),t=l.lineCls.createSingleLine(e,d.coord,d.color,!1),l.mdl.add(t),l.objects.push(t)}else this.createCylinder(p.coord,e,s,p.color),this.createCylinder(e,d.coord,s,d.color)}}}class Le{constructor(e){this.icn3d=e}createLineRepresentation(e,t){let s=this.icn3d;if(s.icn3dui.bNode)return;let i=new THREE.BufferGeometry,n=[],l=[],r=0,o=0;s.reprSubCls.createRepresentationSub(e,void 0,(function(e,t){if(e.color===t.color)n[r++]=e.coord.x,n[r++]=e.coord.y,n[r++]=e.coord.z,n[r++]=t.coord.x,n[r++]=t.coord.y,n[r++]=t.coord.z,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b;else{let s=e.coord.clone().add(t.coord).multiplyScalar(.5);n[r++]=e.coord.x,n[r++]=e.coord.y,n[r++]=e.coord.z,n[r++]=s.x,n[r++]=s.y,n[r++]=s.z,n[r++]=t.coord.x,n[r++]=t.coord.y,n[r++]=t.coord.z,n[r++]=s.x,n[r++]=s.y,n[r++]=s.z,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b}}));if(i.setAttribute("position",new THREE.BufferAttribute(new Float32Array(n),3)),i.setAttribute("color",new THREE.BufferAttribute(new Float32Array(l),3)),2!==t){let e;1===t||(e=new THREE.LineSegments(i,new THREE.LineBasicMaterial({linewidth:s.linewidth,vertexColors:!0})),s.mdl.add(e)),1===t?s.prevHighlightObjects.push(e):s.objects.push(e)}else 2===t&&s.boxCls.createBoxRepresentation_P_CA(e,.8,t)}createConnCalphSidechain(e,t){let s=this.icn3d;if(s.icn3dui.bNode)return;let i={};for(let s in e){let n=e[s];if(!n.het&&n.style2===t){i[n.structure+"_"+n.chain+"_"+n.resi]=1}}let n=[],l=[];for(let e in i){let t=s.firstAtomObjCls.getFirstAtomObjByName(s.residues[e],"CA");if(void 0!==t)for(let e=0,i=t.bonds.length;e=t.bonds.length&&e.bonds.length>1)s=e.serial,l=e.bonds[0],d=e.bonds[1];else{if(!(t.bonds.length>=e.bonds.length&&t.bonds.length>1))return void console.log("Double bond was not drawn due to the undefined cross plane");s=t.serial,l=t.bonds[0],d=t.bonds[1]}let i=r.atoms[s].coord.clone();i.sub(r.atoms[l].coord);let n=r.atoms[s].coord.clone();n.sub(r.atoms[d].coord),i.cross(n),0==parseInt(1e4*i.length())&&(i=new THREE.Vector3(.2,.3,.5)),c=t.coord.clone(),c.sub(e.coord),c.cross(i).normalize().multiplyScalar(.2*o),0==parseInt(1e4*c.length())&&(i=new THREE.Vector3(.5,.3,.2),c.cross(i).normalize().multiplyScalar(.2*o))}e.color===t.color?r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),t.coord.clone().add(c),a,e.color,n),r.cylinderCls.createCylinder(e.coord.clone().sub(c),t.coord.clone().sub(c),a,e.color,n)):r.bImpo?r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),t.coord.clone().add(c),a,e.color,n,t.color),r.cylinderCls.createCylinder(e.coord.clone().sub(c),t.coord.clone().sub(c),a,e.color,n,t.color)):r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),i.clone().add(c),a,e.color,n),r.cylinderCls.createCylinder(t.coord.clone().add(c),i.clone().add(c),a,t.color,n),r.cylinderCls.createCylinder(e.coord.clone().sub(c),i.clone().sub(c),a,e.color,n),r.cylinderCls.createCylinder(t.coord.clone().sub(c),i.clone().sub(c),a,t.color,n))}else if(r.aromaticbonds.hasOwnProperty(l)){let s,l,d;if(e.bonds.length>t.bonds.length&&e.bonds.length>1)s=e.serial,l=e.bonds[0],d=e.bonds[1];else{if(!(t.bonds.length>1))return;s=t.serial,l=t.bonds[0],d=t.bonds[1]}let c=r.atoms[s].coord.clone();c.sub(r.atoms[l].coord);let h=r.atoms[s].coord.clone();h.sub(r.atoms[d].coord),c.cross(h);let p=t.coord.clone();p.sub(e.coord),p.cross(c).normalize().multiplyScalar(.2*o);let m=0;for(let s=0,i=e.bondOrder.length;so+1?(s=k.clone(),i=d.atoms[G[G.length-1-o-1]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random()))):d.bCalphaOnly&&"CA"===b.name&&(G.length>o+1?(s=k.clone(),i=d.atoms[G[G.length-1-o-1]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random())),s.normalize(),s.multiplyScalar(f),null!==E&&s.dot(E)<0&&s.negate(),E=s;for(let e=0,s=2/(t-1);e6||c&&Math.abs(S.y-c.y)>6||c&&Math.abs(S.z-c.z)>6;if((u!==b.chain||b.ssbegin||b.ssend||B===j-1||p)&&m[0].length>0){let c="CA",u=[],g=[];if(isNaN(d.atoms[P].resi))u=[];else{let e=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)-1).toString(),t=d.firstAtomObjCls.getAtomCoordFromResi(e,c);u=void 0!==t?[t]:[]}if(!isNaN(d.atoms[P].resi)){let e=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)+1).toString(),t=d.firstAtomObjCls.getAtomCoordFromResi(e,c);void 0!==t&&g.push(t);let s=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)+2).toString(),i=d.firstAtomObjCls.getAtomCoordFromResi(s,c);void 0!==i&&g.push(i)}if(!p){1===a||2===a?_.push(d.hColor):_.push(R),f=b.ssend&&"sheet"===b.ss?0:"coil"===I&&b.ssbegin||T&&b.ssbegin||"coil"===b.ss?n:l;let s,i,o=4;"O"===b.name?(s=A.clone(),s.sub(S)):d.bCalphaOnly&&"CA"===b.name&&(G.length>o?(s=S.clone(),i=d.atoms[G[G.length-1-o]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random())),s.normalize(),s.multiplyScalar(f),null!==E&&s.dot(E)<0&&s.negate(),E=s;for(let e=0,s=2/(t-1);e0){let e="CA",n=[],l=[];if(isNaN(d.atoms[P].resi))n=[];else{let t=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)-1).toString();d.firstAtomObjCls.getAtomCoordFromResi(t,e)}for(let e=0;!i&&e0;--e){let t=a.structure+"_"+a.chain+"_"+e;if(!c.residues.hasOwnProperty(t))break;let s=c.firstAtomObjCls.getFirstCalphaAtomObj(c.residues[t]);if(s.ss===a.ss&&s.ssbegin){g=s.resi;break}}for(let e=g;e0&&(o!==c.chain||Math.abs(c.coord.x-h.coord.x)>6||Math.abs(c.coord.y-h.coord.y)>6||Math.abs(c.coord.z-h.coord.z)>6||r.ParserUtilsCls.getResiNCBI(c.structure+"_"+o,a)+13||Math.abs(c.coord.y-h.coord.y)>3||Math.abs(c.coord.z-h.coord.z)>3))){if(2!==i){if(!isNaN(d.resi)&&!isNaN(h.resi)){let e=d.structure+"_"+d.chain+"_"+(parseInt(d.resi)-1).toString(),i=r.firstAtomObjCls.getAtomCoordFromResi(e,t);g=void 0!==i?[i]:[];let l=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+1).toString(),o=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+2).toString(),a=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+3).toString();if(r.residues.hasOwnProperty(l)){let e=r.firstAtomObjCls.getAtomFromResi(l,t);void 0!==e&&e.ssbegin&&(l=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+2).toString(),o=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+3).toString(),p.push(e.coord),n?u.push(this.getCustomtubesize(l)):u.push(this.getRadius(s,e)),m.push(e.color))}if(1==p.length&&r.residues.hasOwnProperty(l)){let e=r.firstAtomObjCls.getAtomFromResi(l,t);if(e){p.push(e.coord),m.push(e.color);let t=this.getRadius(s,c);u.push(t),l=o,o=a}}let b=r.firstAtomObjCls.getAtomCoordFromResi(l,t);void 0!==b&&f.push(b);let C=r.firstAtomObjCls.getAtomCoordFromResi(o,t);void 0!==C&&f.push(C)}C.push({pnts:p,colors:m,radii:u,prevone:g,nexttwo:f})}p=[],m=[],u=[],g=[],f=[],d=c,b=0}if(0==p.length&&!isNaN(c.resi)){let e=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)-1).toString();r.residues.hasOwnProperty(e)&&(h=r.firstAtomObjCls.getAtomFromResi(e,t),void 0!==h&&h.ssend&&(p.push(h.coord),n?u.push(this.getCustomtubesize(e)):u.push(this.getRadius(s,h)),m.push(h.color)))}let e;p.push(c.coord),e=n?this.getCustomtubesize(c.structure+"_"+c.chain+"_"+c.resi):this.getRadius(s,c),u.push(e),m.push(c.color),1===b&&(m[m.length-2]=c.color),o=c.chain,a=c.resi;let l=1.2;2!==i||c.ssbegin||r.boxCls.createBox(c,void 0,void 0,l,void 0,i),++b,h=c}if(2!==i){if(g=[],void 0!==d&&!isNaN(d.resi)){let e=d.structure+"_"+d.chain+"_"+(parseInt(d.resi)-1).toString(),s=r.firstAtomObjCls.getAtomCoordFromResi(e,t);g=void 0!==s?[s]:[]}if(f=[],void 0!==c&&!isNaN(c.resi)){let e=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+1).toString(),i=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+2).toString(),n=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+3).toString();if(1==p.length&&r.residues.hasOwnProperty(e)){let l=r.firstAtomObjCls.getAtomFromResi(e,t);if(l){p.push(l.coord),m.push(l.color);let t=this.getRadius(s,c);u.push(t),e=i,i=n}}let l=r.firstAtomObjCls.getAtomCoordFromResi(e,t);void 0!==l&&f.push(l);let o=r.firstAtomObjCls.getAtomCoordFromResi(i,t);void 0!==o&&f.push(o)}C.push({pnts:p,colors:m,radii:u,prevone:g,nexttwo:f})}for(let e=0,t=C.length;e1?a.parasCls.thr(t[t.length-2]):a.parasCls.thr(t[e]),f[y++]=d.r,f[y++]=d.g,f[y++]=d.b}}let x,k=0;for(let e=0,t=_.length-1;er&&(l=r,e=1);for(let t=0;t0&&t.b<=100?.01*t.b:t.b>100?1:s.coilWidth),i}}class ze{constructor(e){this.icn3d=e}drawCartoonNucleicAcid(e,t,s,i){this.drawStrandNucleicAcid(e,2,t,!0,void 0,s,i)}drawStrandNucleicAcid(e,t,s,i,n,l,r){let o,a,d,c=this.icn3d;if(c.icn3dui.bNode)return;2===r&&(t=void 0,l=void 0),n=n||c.nucleicAcidWidth,s=s||c.axisDIV,t=t||c.nucleicAcidStrandDIV;let h=[];for(d=0;dy?y=C:C=y);let v=.8*b/y;if(g.width=C,g.height=y,f.clearRect(0,0,C,y),h)if(f.fillStyle="rgba("+n.r+","+n.g+","+n.b+","+n.a+")",f.strokeStyle="rgba("+l.r+","+l.g+","+l.b+","+l.a+")",f.lineWidth=r,p){let e=.4*C;this.circle(f,0,0,C,y,e)}else{let e=0;this.roundRect(f,0,0,C,y,e)}f.font="Bold "+a+"px "+o,f.textAlign="center",f.textBaseline="middle",f.fillStyle="rgba("+u.r+", "+u.g+", "+u.b+", 1.0)",f.strokeStyle="rgba("+u.r+", "+u.g+", "+u.b+", 1.0)",f.fillText(e,.5*C,.5*y);let w=new THREE.Texture(g);w.needsUpdate=!0;let _=new THREE.SpriteMaterial({map:w,depthTest:!1,depthWrite:!1});_.map.minFilter=THREE.LinearFilter;let S=new THREE.Sprite(_);return p?S.scale.set(.3*d,.3*d,1):S.scale.set(v*d,d,1),S}roundRect(e,t,s,i,n,l){e.beginPath(),e.moveTo(t+l,s),e.lineTo(t+i-l,s),e.quadraticCurveTo(t+i,s,t+i,s+l),e.lineTo(t+i,s+n-l),e.quadraticCurveTo(t+i,s+n,t+i-l,s+n),e.lineTo(t+l,s+n),e.quadraticCurveTo(t,s+n,t,s+n-l),e.lineTo(t,s+l),e.quadraticCurveTo(t,s,t+l,s),e.closePath(),e.fill(),e.stroke()}circle(e,t,s,i,n,l){e.beginPath(),e.arc(t+i/2,.9*(s+n/2),l,0,2*Math.PI,!0),e.closePath(),e.fill(),e.stroke()}}class Ve{constructor(e){this.icn3d=e,this.textSpriteCls=new Ge(e)}createLabelRepresentation(e){let t=this.icn3d;t.icn3dui;let s=t.oriMaxD/100;s<.4&&(s=.4);let i=3*s*t.labelScale;for(let s in e){let n=void 0!==e[s]?e[s]:[],l="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd;for(let e=0,r=n.length;e.99999)h.set(0,0,0,1);else if(e.y<-.99999)h.set(1,0,0,0);else{let t=new THREE.Vector3;t.set(e.z,0,-e.x).normalize();let s=Math.acos(e.y);h.setFromAxisAngle(t,s)}return c.applyQuaternion(h),c.scale.set(l,n,l),c.position.copy(t),c}setPc1Axes(){let e=this.icn3d,t=e.icn3dui;if(t.bNode)return;let s=t.hashUtilsCls.intHash(e.hAtoms,e.dAtoms),i=[],n=Object.keys(s).length<100;for(let t in s){let s=e.atoms[t],l=s.structure+"_"+s.chain+"_"+s.resi;(n||""!=l)&&i.push(s.coord.clone())}let l=t.rmsdSuprCls.getEigenForSelection(i,i.length),r=new THREE.Vector3(l.h1[0],l.h1[1],l.h1[2]);if(0==l.k&&e.bRender)return void alert("Can't determine the first principal component. Please select a subset and try it again.");let o=e.applyCenterCls.centerAtoms(s),a=o.maxD,d=o.center,c=d.clone().add(r.normalize().multiplyScalar(.4*a)),h=new THREE.Vector3(l.h2[0],l.h2[1],l.h2[2]),p=d.clone().add(h.normalize().multiplyScalar(.3*a)),m=new THREE.Vector3(l.h3[0],l.h3[1],l.h3[2]),u=d.clone().add(m.normalize().multiplyScalar(.3*a));this.buildAxes(void 0,d,c,p,u,!0);let g=[d,c,p,u];return e.axes.push(g),e.drawCls.draw(),g}}class Ye{constructor(e){this.icn3d=e}showGlycans(){let e=this.icn3d,t=e.icn3dui;if(t.bNode)return;let s={},i=e.dAtoms;for(let n in i){let i=e.atoms[n];i.het&&-1!=t.parasCls.glycanHash.hasOwnProperty(i.resn)&&(void 0===s[i.resn]&&(s[i.resn]={}),"Misc"!=i.chain&&(s[i.resn][i.structure+"_"+i.chain+"_"+i.resi]=1))}let n=Object.keys(s);for(let i=0,l=n.length;i>2))+i+((2&t)>>1))*c+n+(1&t)]&this.ISDONE)<=3&&(t.push(t[i]),i=t.length-1,t.push(t[n]),n=t.length-1,t.push(t[l]),l=t.length-1),s.push(i),s.push(n),s.push(l)}}},Xe.prototype.laplacianSmooth=function(e,t,s){let i,n,l,r,o,a=new Array(t.length);for(i=0,n=t.length;ithis.origextent[1][0])&&(!(tthis.origextent[1][1])&&!(sthis.origextent[1][2]))},Ke.prototype.getFacesAndVertices=function(){let e,t,s=this.verts;for(e=0,t=s.length;eh&&(h=this.pmaxy-this.pminy),this.pmaxz-this.pminz>h&&(h=this.pmaxz-this.pminz),this.scaleFactor=(c-1)/h,this.scaleFactor=this.defaultScaleFactor,(this.bCalcArea||this.defaultScaleFactor*h>this.threshbox)&&(c=Math.floor(this.threshbox),this.scaleFactor=(this.threshbox-1)/h),this.pLength=Math.ceil(this.scaleFactor*(this.pmaxx-this.pminx))+1,this.pWidth=Math.ceil(this.scaleFactor*(this.pmaxy-this.pminy))+1,this.pHeight=Math.ceil(this.scaleFactor*(this.pmaxz-this.pminz))+1,this.finalScaleFactor.x=(this.pLength-1)/(this.pmaxx-this.pminx),this.finalScaleFactor.y=(this.pWidth-1)/(this.pmaxy-this.pminy),this.finalScaleFactor.z=(this.pHeight-1)/(this.pmaxz-this.pminz),this.boundingatom(t),this.cutRadius=this.probeRadius*this.scaleFactor,this.vpBits=new Uint8Array(this.pLength*this.pWidth*this.pHeight),this.vpDistance=new Float64Array(this.pLength*this.pWidth*this.pHeight),this.vpAtomID=new Int32Array(this.pLength*this.pWidth*this.pHeight),this.vpColor=[],this.vpPot=[]},Ke.prototype.boundingatom=function(e){let t,s,i,n,l=[];for(let r in this.vdwRadii){if(!this.vdwRadii.hasOwnProperty(r))continue;let o=this.vdwRadii[r];l[r]=e?(o+this.probeRadius)*this.scaleFactor+.5:o*this.scaleFactor+.5,i=l[r]*l[r],this.widxz[r]=Math.floor(l[r])+1,this.depty[r]=new Int32Array(this.widxz[r]*this.widxz[r]),n=0;for(let e=0;ei?this.depty[r][n]=-1:(s=Math.sqrt(i-t),this.depty[r][n]=Math.floor(s)),n++}},Ke.prototype.fillvoxels=function(e,t){let s,i,n,l;for(s=0,l=this.vpBits.length;sc&&(a=c),C>h&&(C=h),v>p&&(v=p);let w,_=g[o*m+d*u+y],S=g[a*m+d*u+y],A=g[o*m+C*u+y],x=g[o*m+d*u+v],k=g[a*m+C*u+y],O=g[o*m+C*u+v],R=g[a*m+d*u+v],E=g[a*m+C*u+v],I=r.x-o,T=r.y-d,M=r.z-y,P=((_*(1-I)+S*I)*(1-T)+(A*(1-I)+k*I)*T)*(1-M)+((x*(1-I)+R*I)*(1-T)+(O*(1-I)+E*I)*T)*M,D=s*f+i*b+n;this.vpPot[D]=P,P>this.isovalue&&(P=this.isovalue),P<-this.isovalue&&(P=-this.isovalue),P>0?(P/=1*this.isovalue,w=new THREE.Color(1-P,1-P,1)):(P/=-1*this.isovalue,w=new THREE.Color(1,1-P,1-P)),this.vpColor[D]=w}}for(s=0,l=this.vpBits.length;s=this.pLength||g>=this.pWidth||f>=this.pHeight)continue;let h=u*S+g*this.pHeight+f;if(this.vpBits[h]&this.INOUT){let p=t[this.vpAtomID[h]];p.serial!=e.serial&&(l=s+a-Math.floor(.5+this.scaleFactor*(p.x+this.ptranx)),r=i+d-Math.floor(.5+this.scaleFactor*(p.y+this.ptrany)),o=n+c-Math.floor(.5+this.scaleFactor*(p.z+this.ptranz)),a*a+d*d+c*c=this.pLength||p>=this.pWidth||m>=this.pHeight)continue;let u=h*S+p*this.pHeight+m;if(this.vpBits[u]&this.ISDONE){let h=t[this.vpAtomID[u]];h.serial!=e.serial&&(l=s+a-Math.floor(.5+this.scaleFactor*(h.x+this.ptranx)),r=i+d-Math.floor(.5+this.scaleFactor*(h.y+this.ptrany)),o=n+c-Math.floor(.5+this.scaleFactor*(h.z+this.ptranz)),a*a+d*d+c*c-1&&r-1&&a-1&&o=h)||(this.vpBits[n]|=this.ISBOUND))},Ke.prototype.fastoneshell=function(e,t){let s,i,n,l,r,o,a,d,c,h,p,m,u=[];if(0===e.length)return u;let g={ix:-1,iy:-1,iz:-1},f=this.pWidth*this.pHeight;for(a=0,c=e.length;a-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,h-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,h-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,hm&&(m=this.pmaxy-this.pminy),this.pmaxz-this.pminz>m&&(m=this.pmaxz-this.pminz),this.scaleFactor=1,this.pLength=Math.floor(.5+this.scaleFactor*(this.pmaxx-this.pminx))+1,this.pWidth=Math.floor(.5+this.scaleFactor*(this.pmaxy-this.pminy))+1,this.pHeight=Math.floor(.5+this.scaleFactor*(this.pmaxz-this.pminz))+1,this.cutRadius=this.probeRadius*this.scaleFactor,this.vpBits=new Uint8Array(this.pLength*this.pWidth*this.pHeight),this.vpAtomID=new Uint8Array(this.pLength*this.pWidth*this.pHeight)},Qe.prototype.transformMemPro=function(e,t,s,i){let n=e.clone();n.sub(s);let l=n.x*t[0]+n.y*t[1]+n.z*t[2]+i.x,r=n.x*t[3]+n.y*t[4]+n.z*t[5]+i.y,o=n.x*t[6]+n.y*t[7]+n.z*t[8]+i.z;return n.x=l,n.y=r,n.z=o,n},Qe.prototype.fillvoxels=function(e,t){let s,i,n,l,r,o;for(s=0,l=this.vpBits.length;sthis.pLength&&(o=this.pLength),p>this.pWidth&&(p=this.pWidth),b>this.pHeight&&(b=this.pHeight);let C,y=l[r*a+h*d+f],v=l[o*a+h*d+f],w=l[r*a+p*d+f],_=l[r*a+h*d+b],S=l[o*a+p*d+f],A=l[r*a+p*d+b],x=l[o*a+h*d+b],k=l[o*a+p*d+b],O=n.x-r,R=n.y-h,E=n.z-f,I=((y*(1-O)+v*O)*(1-R)+(w*(1-O)+S*O)*R)*(1-E)+((_*(1-O)+x*O)*(1-R)+(A*(1-O)+k*O)*R)*E;I>this.isovalue&&(I=this.isovalue),I<-this.isovalue&&(I=-this.isovalue),I>0?(I/=1*this.isovalue,C=new THREE.Color(1-I,1-I,1)):(I/=-1*this.isovalue,C=new THREE.Color(1,1-I,1-I)),this.icn3d.atoms[t[s]].color=C,this.icn3d.atomPrevColors[t[s]]=C}}else{for(let p in t){let f,b=e[t[p]];if("DUM"!==b.resn){if(void 0!==this.rmsd_supr&&void 0!==this.rmsd_supr.rot){f=this.transformMemPro(b.coord,g,u,m).applyMatrix4(c)}else f=b.coord.clone().applyMatrix4(c);for(s=Math.floor(f.x)-this.maxdist,l=Math.ceil(f.x)+this.maxdist;s<=l;++s)if(!(s<0||s>this.header.xExtent*this.scaleFactor-1))for(i=Math.floor(f.y)-this.maxdist,r=Math.ceil(f.y)+this.maxdist;i<=r;++i)if(!(i<0||i>this.header.yExtent*this.scaleFactor-1))for(n=Math.floor(f.z)-this.maxdist,o=Math.ceil(f.z)+this.maxdist;n<=o;++n){if(n<0||n>this.header.zExtent*this.scaleFactor-1)continue;let e=s*a+i*d+n;h.push(e)}}}for(s=0,l=h.length;s=this.isovalue?1:0:"fofc"==this.type?(this.vpBits[e]=this.dataArray[e]>=this.isovalue||this.dataArray[e]<=-this.isovalue?1:0,this.vpAtomID[e]=this.dataArray[e]>=0?1:0):"em"==this.type&&(this.vpBits[e]=this.dataArray[e]>=this.isovalue?1:0)}}}else for(s=0;s=this.isovalue||this.dataArray[e]<=-this.isovalue?1:0,this.vpAtomID[t]=this.dataArray[e]>=0?1:0)}for(s=0,l=this.vpBits.length;s-1&&r-1&&a-1&&o1?"Structure":"",a=Object.keys(i).length>1?"Chain":"";n+=""+o+a+"ResidueNumberSASA (Å2)Percent OutIn/Out";for(let e in l.resid2area){let d=e.lastIndexOf("_"),c=e.substr(d+1),h=r.utilsCls.getIdArray(e.substr(0,d));o=Object.keys(s).length>1?""+h[0]+"":"",a=Object.keys(i).length>1?""+h[1]+"":"";let p="",m="";l.resid2area[e]=(l.resid2area[e]/t).toFixed(2),r.parasCls.residueArea.hasOwnProperty(c)&&(m=parseInt(l.resid2area[e]/r.parasCls.residueArea[c]*100),m>100&&(m=100),m>=50&&(p="out"),m<20&&(p="in")),n+=''+o+a+""+c+''+h[2]+''+l.resid2area[e]+''+m+"%"+p+""}return n+="",void(l.areahtml=n)}let p,m,u,g=c.vertices,f=c.faces,b=r.parasCls.thr("#00FFFF"),C=r.parasCls.thr("#00FF00"),y=r.parasCls.thr("#ff0000"),v=r.parasCls.thr("#00FFFF"),w=r.parasCls.thr("#0000FF"),_=r.parasCls.thr("#FF0000");11!=t&&12!=t&&13!=t&&14!=t||void 0===l.rmsd_supr||void 0===l.rmsd_supr.rot||(p=l.rmsd_supr.rot,m=l.rmsd_supr.trans1,u=l.rmsd_supr.trans2);let S=(11==t||12==t||13==t||14==t&&"delphi"!=l.loadPhiFrom)&&void 0!==l.rmsd_supr&&void 0!==l.rmsd_supr.rot;n=new THREE.BufferGeometry;let A,x=[],k=[],O=[],R=0;for(let e=0,s=g.length;e0?-parseInt(C.z):parseInt(C.z),y.onBeforeRender=function(e,t,s,i,n,o){let a,d=new THREE.Vector3(0,0,0),c=i.getAttribute("position").array;for(let e=0,t=c.length;e0?-parseInt(a.z):parseInt(a.z)},l.mdl.add(y),11==t||12==t?l.prevMaps.push(y):13==t?l.prevEmmaps.push(y):14==t?l.prevPhimaps.push(y):l.prevSurfaces.push(y)}}else{let e=new THREE.Mesh(n,new THREE.MeshPhongMaterial({specular:l.frac,shininess:20,emissive:l.emissive,vertexColors:THREE.VertexColors,wireframe:s,opacity:i,transparent:!0,depthWrite:10==parseInt(10*i),side:THREE.DoubleSide}));e.renderOrder=-2,l.mdl.add(e),11==t||12==t?l.prevMaps.push(e):13==t?l.prevEmmaps.push(e):14==t?l.prevPhimaps.push(e):l.prevSurfaces.push(e)}c=null,g=null,f=null,n=null}transformMemPro(e,t,s,i,n){this.icn3d.icn3dui;let l=e.clone();l.sub(s),n&&console.log("sub coord: "+JSON.stringify(l));let r=l.x*t[0]+l.y*t[1]+l.z*t[2]+i.x,o=l.x*t[3]+l.y*t[4]+l.z*t[5]+i.y,a=l.x*t[6]+l.y*t[7]+l.z*t[8]+i.z;return l.x=r,l.y=o,l.z=a,n&&console.log("out coord: "+JSON.stringify(l)),l}SetupSurface(e){let t=this.icn3d;t.icn3dui;let s=e.threshbox,i=new Ke(t,s);i.initparm(e.extent,1!==e.type,e.bCalcArea,e.atomsToShow,e.header,e.data,e.matrix,e.isovalue,e.loadPhiFrom),i.fillvoxels(e.allatoms,e.extendedAtoms),i.buildboundary(),2===e.type&&(i.fastdistancemap(),i.boundingatom(!1),i.fillvoxelswaals(e.allatoms,e.extendedAtoms));let n=i.marchingcube();i.vpBits=null,i.vpDistance=null,i.vpAtomID=null;let l=i.getFacesAndVertices(e.atomsToShow);return l.area=n.area,l.serial2area=n.serial2area,l.scaleFactor=n.scaleFactor,i.faces=null,i.verts=null,l}SetupMap(e){let t=this.icn3d;t.icn3dui;let s,i=new Qe(t);return i.initparm(e.header,e.data,e.matrix,e.isovalue,e.center,e.maxdist,e.pmin,e.pmax,e.water,e.type,e.rmsd_supr,e.loadPhiFrom,e.icn3d),i.fillvoxels(e.allatoms,e.extendedAtoms),e.header.bSurface||i.buildboundary(),e.header.bSurface||i.marchingcube(),i.vpBits=null,i.vpAtomID=null,e.header.bSurface||(s=i.getFacesAndVertices(e.allatoms,e.atomsToShow)),i.faces=null,i.verts=null,s}}class Ze{constructor(e){this.icn3d=e}applyCenterOptions(e){let t,s=this.icn3d;switch(s.icn3dui,void 0===e&&(e=s.opts),e.rotationcenter.toLowerCase()){case"molecule center":void 0!==s.center&&this.setRotationCenter(s.center);break;case"pick center":void 0!==s.pAtom&&this.setRotationCenter(s.pAtom.coord);break;case"display center":t=this.centerAtoms(s.dAtoms).center,this.setRotationCenter(t);break;case"highlight center":t=this.centerAtoms(s.hAtoms).center,this.setRotationCenter(t)}}setRotationCenter(e){this.icn3d.icn3dui,this.setCenter(e)}setCenter(e){let t=this.icn3d;t.icn3dui,t.mdl.position.set(0,0,0),t.mdlImpostor.position.set(0,0,0),t.mdl_ghost.position.set(0,0,0),t.mdl.position.sub(e),t.mdlImpostor.position.sub(e),t.mdl_ghost.position.sub(e)}centerSelection(e,t){let s=this.icn3d,i=s.icn3dui;if(s.opts.rotationcenter="highlight center",void 0===e&&(e=i.hashUtilsCls.hash2Atoms(s.hAtoms,s.atoms)),t||(s._zoomFactor=1,s.mouseChange=new THREE.Vector2(0,0),s.quaternion=new THREE.Quaternion(0,0,0,1)),Object.keys(e).length>1){let t=this.centerAtoms(e);s.center=t.center,this.setCenter(s.center),s.cameraCls.setCamera()}}centerAtoms(e){let t=this.icn3d;t.icn3dui;let s=new THREE.Vector3(9999,9999,9999),i=new THREE.Vector3(-9999,-9999,-9999),n=new THREE.Vector3;for(let l in e){let e=t.atoms[l].coord;n.add(e),s.min(e),i.max(e)}let l=t.ParserUtilsCls.getGeoCenter(s,i);return{center:l,maxD:t.ParserUtilsCls.getStructureSize(e,s,i,l),pmin:s,pmax:i}}setWidthHeight(e,t){let s=this.icn3d;s.icn3dui,void 0===s.scaleFactor&&(s.scaleFactor=1),s.renderer.setSize(e*s.scaleFactor,t*s.scaleFactor),s.renderer.domElement.style.width=e*s.scaleFactor+"px",s.renderer.domElement.style.height=t*s.scaleFactor+"px",s.renderer.domElement.width=e*s.scaleFactor,s.renderer.domElement.height=t*s.scaleFactor,s.container.whratio=e/t}}class et{constructor(e){this.icn3d=e}applyClbondsOptions(e){let t=this.icn3d,s=t.icn3dui;if(void 0===e&&(e=t.opts),t.bCalcCrossLink||(t.clbondpnts={},t.clbondResid2serial={},this.applyClbondsOptions_base("chemical"),this.applyClbondsOptions_base("all"),t.bCalcCrossLink=!0),"yes"===e.clbonds.toLowerCase()&&"nothing"!==e.chemicals){let e="#006400",i=s.parasCls.thr(25600);if(t.lines.clbond=[],t.residuesHashClbonds={},t.structures){let n=Object.keys(t.structures);for(let l=0,r=n.length;l1&&"sphere"!==a[Object.keys(a)[0]].style&&"dot"!==a[Object.keys(a)[0]].style){if(void 0===i.bCid||!i.bCid)for(let e in a){let t=a[e],n=1;i.boxCls.createBox(t,void 0,void 0,n,void 0,s)}}else for(let e in o){let l=i.firstAtomObjCls.getFirstCalphaAtomObj(i.residues[e]),r=l,o=r.structure+"_"+r.chain+"_"+(parseInt(r.resi)-1).toString(),a=r.structure+"_"+r.chain+"_"+(parseInt(r.resi)+1).toString();if("cylinder and plate"===r.style&&"helix"===r.ss)for(let t in i.residues[e]){let e=i.atoms[t],n=1;i.boxCls.createBox(e,void 0,void 0,n,void 0,s)}else if("ribbon"===r.style&&"coil"===r.ss||"strand"===r.style&&"coil"===r.ss||"o3 trace"===r.style||"schematic"===r.style||"c alpha trace"===r.style||"b factor tube"===r.style||"cylinder and plate"===r.style&&"helix"!==r.ss){if(void 0!==l&&void 0!==l.style2&&"nothing"!==l.style2)continue;let e=!1;if(!isNaN(r.resi)&&!e&&i.residues.hasOwnProperty(a)){let s=Object.keys(i.residues[a])[0],l=n.hashUtilsCls.hash2Atoms(i.residues[a],i.atoms)[s];if(r.style===l.style&&!l.ssbegin||l.ssbegin){let s=i.residues[a];if(t=n.hashUtilsCls.unionHash(t,s),e=!0,l.ssbegin)for(let e in s)i.atoms[e].notshow=!0}}if(!isNaN(r.resi)&&!e&&i.residues.hasOwnProperty(o)){let s=Object.keys(i.residues[o])[0],l=n.hashUtilsCls.hash2Atoms(i.residues[o],i.atoms)[s];r.style===l.style&&(t=n.hashUtilsCls.unionHash(t,i.residues[o]),e=!0)}}else if("ribbon"===r.style&&"coil"!==r.ss&&r.ssend||"strand"===r.style&&"coil"!==r.ss&&r.ssend){if(void 0!==l&&void 0!==l.style2&&"nothing"!==l.style2)continue;let e=!1;if(!isNaN(r.resi)&&!e&&i.residues.hasOwnProperty(a)){let s=Object.keys(i.residues[a])[0];n.hashUtilsCls.hash2Atoms(i.residues[a],i.atoms)[s],t=n.hashUtilsCls.unionHash(t,i.residues[a]),e=!0}}}a={}}if(i.bInitial){if(""!=n.htmlCls.setHtmlCls.getCookie("membrane")){let e=parseInt(n.htmlCls.setHtmlCls.getCookie("membrane"));i.bMembrane!=e&&n.htmlCls.clickMenuCls.setLogCmd("set membrane "+e,!0),i.bMembrane=isNaN(e)?0:parseInt(e)}i.bMembrane?i.selectionCls.toggleMembrane(!0):i.selectionCls.toggleMembrane(!1)}i.setStyleCls.setStyle2Atoms(t);let d=.5*i.cylinderRadius;void 0!==i.labels&&delete i.labels.schematic;for(let e in i.style2atoms){let t=i.style2atoms[e],l=n.hashUtilsCls.intHash(t,i.nucleotides),r=n.utilsCls.isCalphaPhosOnly(n.hashUtilsCls.hash2Atoms(l,i.atoms));if("ribbon"===e)i.strandCls.createStrand(n.hashUtilsCls.hash2Atoms(t,i.atoms),2,void 0,!0,void 0,void 0,!1,i.ribbonthickness,s);else if("strand"===e)i.strandCls.createStrand(n.hashUtilsCls.hash2Atoms(t,i.atoms),null,null,null,null,null,!1,void 0,s);else if("cylinder and plate"===e)i.cylinderCls.createCylinderHelix(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderHelixRadius,s);else if("nucleotide cartoon"===e)r?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["P"],i.traceRadius,!1,s):(i.cartoonNuclCls.drawCartoonNucleicAcid(n.hashUtilsCls.hash2Atoms(t,i.atoms),null,i.ribbonthickness,s),2!==s&&i.cartoonNuclCls.drawNucleicAcidStick(n.hashUtilsCls.hash2Atoms(t,i.atoms),s));else if("o3 trace"===e)r?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["P"],i.traceRadius,!1,s):i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["O3'","O3*"],i.traceRadius,!1,s);else if("schematic"===e){let e=i.firstAtomObjCls.getFirstAtomObj(t);if(i.chemicals.hasOwnProperty(e.serial)){i.residueLabelsCls.addNonCarbonAtomLabels(n.hashUtilsCls.hash2Atoms(t,i.atoms));let e=!0;i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),d,d,void 0,s,e)}else i.residueLabelsCls.addResidueLabels(n.hashUtilsCls.hash2Atoms(t,i.atoms),!0),r?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["P"],i.traceRadius,!1,s):i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["O3'","O3*"],i.traceRadius,!1,s),i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["CA"],i.traceRadius,!1,s)}else"c alpha trace"===e?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["CA"],i.traceRadius,!1,s):"b factor tube"===e?i.tubeCls.createTube(n.hashUtilsCls.hash2Atoms(t,i.atoms),"CA",null,s,!1,!0):"custom tube"===e?i.tubeCls.createTube(n.hashUtilsCls.hash2Atoms(t,i.atoms),"CA",null,s,!0,!0):"lines"===e||"lines2"===e?(1===s?i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.hlLineRadius,i.hlLineRadius,void 0,s):i.lineCls.createLineRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),s),i.lineCls.createConnCalphSidechain(n.hashUtilsCls.hash2Atoms(t,i.atoms),e)):"stick"===e||"stick2"===e?(i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderRadius,i.cylinderRadius,void 0,s,void 0),i.lineCls.createConnCalphSidechain(n.hashUtilsCls.hash2Atoms(t,i.atoms),e)):"backbone"===e?(t=this.selectMainChainSubset(t),i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderRadius,i.cylinderRadius,void 0,s,void 0)):"ball and stick"===e||"ball and stick2"===e?(i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderRadius,.5*i.cylinderRadius,i.dotSphereScale,s,void 0),i.lineCls.createConnCalphSidechain(n.hashUtilsCls.hash2Atoms(t,i.atoms),e)):"sphere"===e||"sphere2"===e?i.sphereCls.createSphereRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.sphereRadius,void 0,void 0,s):"dot"===e&&i.sphereCls.createSphereRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.sphereRadius,!1,i.dotSphereScale,s)}if(i.cnt>i.maxmaxatomcnt&&i.init_base(),void 0!==i.labels&&Object.keys(i.labels).length>0){i.labelCls.hideLabels();for(let e in i.labels)"schematic"!=e&&this.changeLabelColor(i.labels[e]);i.labelCls.createLabelRepresentation(i.labels)}}changeLabelColor(e){let t=this.icn3d;if(t.icn3dui,e)for(let s=0,i=e.length;s0){this.updateStabilizer();let e="#FFFFFF",s=t.stabilizerpnts;t.lines.stabilizer=[];for(let i=0,n=Math.floor(s.length/2);i0)for(let e=0,s=t.distPnts.length;e0&&t.applySymdCls.applySymd(),void 0!==t.prevOtherMesh)for(let e=0,s=t.prevOtherMesh.length;e0&&(e=s.hashUtilsCls.hash2Atoms(t.chemicals,t.atoms));let i=4;if(void 0!==e){let n=t.contactCls.getAtomsWithinAtom(t.atoms,e,i),l=3.5;t.opts.hbonds="yes",Object.keys(n).length>0&&t.hBondCls.calculateChemicalHbonds(e,n,parseFloat(l)),t.bSetFog||t.transformCls.zoominSelection(s.hashUtilsCls.unionHash(e,n))}}else"hide"===e.chemicalbinding&&(t.hBondCls.hideHbonds(),t.bSetFog||t.transformCls.zoominSelection(t.atoms))}updateStabilizer(){let e=this.icn3d;if(e.icn3dui,e.stabilizerpnts=[],void 0!==e.pairArray)for(let t=0,s=e.pairArray.length;t=0;i--){let r=t.ssbondpnts[e][2*i],o=t.ssbondpnts[e][2*i+1],a={};a.color=n,a.dashed=!0;let d=[],c=[],h=[],p=[],m=!1,u=!1;for(let e in t.residues[r])"SG"===t.atoms[e].name&&(h.push(t.atoms[e].coord),d.push(t.atoms[e].serial),m=!0);if(!m)for(let e in t.residues[r])if("CA"===t.atoms[e].name){h.push(t.atoms[e].coord),d.push(t.atoms[e].serial),m=!0,u=!0;break}m=!1;for(let e in t.residues[o])"SG"===t.atoms[e].name&&(p.push(t.atoms[e].coord),c.push(t.atoms[e].serial),m=!0);if(!m)for(let e in t.residues[o])if("CA"===t.atoms[e].name){p.push(t.atoms[e].coord),c.push(t.atoms[e].serial),m=!0,u=!0;break}let g=u?7:3,f=!1;for(let e=0,t=h.length;e1&&(l=!0)}if(t)if(l){let t=Object.keys(r)[0];e=i.chains[t]}else{0==Object.keys(i.hAtoms).length&&(i.hAtoms=n.hashUtilsCls.cloneHash(i.dAtoms));let t,s=parseInt(Object.keys(i.hAtoms).length/u),l=0;for(let n in i.hAtoms)if(e[n]=1,t=n,++l,l>s)break;let r=i.atoms[t].structure+"_"+i.atoms[t].chain+"_"+i.atoms[t].resi;e=n.hashUtilsCls.unionHash(e,i.residues[r])}else{let t=Object.keys(i.structures)[0]+"_"+g;if(i.chains.hasOwnProperty(t)||(t=Object.keys(i.structures)[0]+"_"+g.toLowerCase()),!i.chains.hasOwnProperty(t)){t=Object.keys(i.chains)[0];for(let e in i.chains){let s=Object.keys(i.chains[e])[0];if(i.proteins.hasOwnProperty(s)){t=e;break}}}e=i.chains[t]}let a=s.clone().add(h).multiplyScalar(.5),c=new THREE.Vector3,p=0,f=h.clone().sub(s).normalize(),b=new THREE.Vector3(0,0,1),C=new THREE.Quaternion;C.setFromUnitVectors(f,b);let y=-9999;for(let t in e){let e=i.atoms[t].coord.clone();c.add(e),e.sub(a).applyQuaternion(C);let s=e.x*e.x+e.y*e.y;s>y&&(y=s),++p}let v=i.ParserUtilsCls.getMassCenter(c,p),w=new THREE.Line3(s,h),_=new THREE.Vector3;w.closestPointToPoint(v,!0,_);let S,A,x,k,O=Math.sqrt(y),R=v.clone().sub(_).normalize().multiplyScalar(O),E=a.clone().add(s.clone().sub(a).multiplyScalar(.83)).add(R),I=a.clone().add(h.clone().sub(a).multiplyScalar(.83)).add(R),T=2*Math.PI/o;for(let e=0;et&&(i.sphereCls.createSphereBase(r,colorPolygon,d,1,0),i.cylinderCls.createCylinder(e,r,d,colorPolygon,0),i.cylinderCls.createCylinder(s,r,d,colorPolygon,0),void 0!==n&&i.cylinderCls.createCylinder(c[n],r,d,colorPolygon,0),n=l)}}else if("O"==r)for(let e=0,t=c.length;e0&&(e.mdl.remove(e.prevSurfaces[e.prevSurfaces.length-1]),e.prevSurfaces.slice(e.prevSurfaces.length-1,1))}removeMaps(){let e=this.icn3d;e.icn3dui;for(let t=0,s=e.prevMaps.length;t0&&(e.mdl.remove(e.prevMaps[e.prevMaps.length-1]),e.prevMaps.slice(e.prevMaps.length-1,1))}removeLastEmmap(){let e=this.icn3d;e.icn3dui,e.prevEmmaps.length>0&&(e.mdl.remove(e.prevEmmaps[e.prevEmmaps.length-1]),e.prevEmmaps.slice(e.prevEmmaps.length-1,1))}removeLastPhimap(){let e=this.icn3d;e.icn3dui,e.prevPhimaps.length>0&&(e.mdl.remove(e.prevPhimaps[e.prevPhimaps.length-1]),e.prevPhimaps.slice(e.prevPhimaps.length-1,1))}}class rt{constructor(e){this.icn3d=e}addResidueLabels(e,t,s,i){let n=this.icn3d,l=n.icn3dui;if(l.bNode)return;let r=l.hashUtilsCls.intHash(n.hAtoms,e);t?void 0===n.labels.schematic&&(n.labels.schematic=[]):void 0===n.labels.residue&&(n.labels.residue=[]);let o="";for(let e in r){let s=n.atoms[e],r={},a=s.structure+"_"+s.chain+"_"+s.resi;if(!s.het&&("CA"===s.name||"O3'"===s.name||"O3*"===s.name)||n.water.hasOwnProperty(s.serial)||n.ions.hasOwnProperty(s.serial)||n.chemicals.hasOwnProperty(s.serial)&&a!==o){r.position=s.coord,r.bSchematic=0,t&&(r.bSchematic=1),r.text=l.utilsCls.residueName2Abbr(s.resn),i&&(r.text+=s.resi),r.size=18,r.factor=.3;let e=s.color.getHexString().toUpperCase();r.color=i?"black"!=n.opts.background?n.colorWhitebkgd:n.colorBlackbkgd:"CCCCCC"===e||"C8C8C8"===e?"#888888":"#"+e,r.background="#FFFFFF",t?n.labels.schematic.push(r):n.labels.residue.push(r)}o=a}n.hlObjectsCls.removeHlObjects()}addNonCarbonAtomLabels(e){let t=this.icn3d,s=t.icn3dui;if(s.bNode)return;let i=s.hashUtilsCls.intHash(t.hAtoms,e);void 0===t.labels.schematic&&(t.labels.schematic=[]);for(let e in i){let s=t.atoms[e];if(!t.residues.hasOwnProperty(s.structure+"_"+s.chain+"_"+s.resi))continue;if("C"===s.elem)continue;let i={};i.position=s.coord,i.bSchematic=1,i.text=s.elem,i.size=18,i.color="black"!=t.opts.background?t.colorWhitebkgd:s.color.getHexString(),i.background="#FFFFFF",t.labels.schematic.push(i)}t.hlObjectsCls.removeHlObjects()}addAtomLabels(e,t){let s=this.icn3d,i=s.icn3dui;if(i.bNode)return;let n=i.hashUtilsCls.intHash(s.hAtoms,e);n=i.hashUtilsCls.intHash(s.dAtoms,n),void 0===s.labels.residue&&(s.labels.residue=[]);for(let e in n){let i=s.atoms[e],n={};n.position=i.coord,n.bSchematic=0,n.text=t?i.elem:i.name.padEnd(2," "),n.size=18,t&&(n.bSchematic=!0);let l=i.color.getHexString().toUpperCase();n.color="black"!=s.opts.background?s.colorWhitebkgd:s.colorBlackbkgd,t&&(n.color="CCCCCC"===l||"C8C8C8"===l?"#888888":"#"+l),n.background="#FFFFFF",s.labels.residue.push(n)}s.hlObjectsCls.removeHlObjects()}}class ot{constructor(e){this.icn3d=e}onBeforeRender(e,t,s,i,n,l){let r=n.uniforms,o=[];if(r.objectId&&(r.objectId.value=SupportsReadPixelsFloat?this.id:this.id/255,o.push("objectId")),(r.modelViewMatrixInverse||r.modelViewMatrixInverseTranspose||r.modelViewProjectionMatrix||r.modelViewProjectionMatrixInverse)&&this.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,this.matrixWorld),r.modelViewMatrixInverse&&(r.modelViewMatrixInverse.value.copy(this.modelViewMatrix).invert(),o.push("modelViewMatrixInverse")),r.modelViewMatrixInverseTranspose&&(r.modelViewMatrixInverse?r.modelViewMatrixInverseTranspose.value.copy(r.modelViewMatrixInverse.value).transpose():r.modelViewMatrixInverseTranspose.value.copy(this.modelViewMatrix).invert().transpose(),o.push("modelViewMatrixInverseTranspose")),r.modelViewProjectionMatrix&&(s.updateProjectionMatrix(),r.modelViewProjectionMatrix.value.multiplyMatrices(s.projectionMatrix,this.modelViewMatrix),o.push("modelViewProjectionMatrix")),r.modelViewProjectionMatrixInverse){let e=new THREE.Matrix4;r.modelViewProjectionMatrix?(e.copy(r.modelViewProjectionMatrix.value),r.modelViewProjectionMatrixInverse.value.copy(e).invert()):(s.updateProjectionMatrix(),e.multiplyMatrices(s.projectionMatrix,this.modelViewMatrix),r.modelViewProjectionMatrixInverse.value.copy(e).invert()),o.push("modelViewProjectionMatrixInverse")}if(r.projectionMatrix&&(s.updateProjectionMatrix(),r.projectionMatrix.value.copy(s.projectionMatrix),o.push("projectionMatrix")),r.projectionMatrixInverse&&(s.updateProjectionMatrix(),r.projectionMatrixInverse.value.copy(s.projectionMatrix).invert(),o.push("projectionMatrixInverse")),o.length){let t=e.properties.get(n);if(t.program){let s=e.getContext(),i=t.program;s.useProgram(i.program);let n=i.getUniforms();o.forEach((function(e){n.setValue(s,e,r[e].value)}))}}}setParametersForShader(e){let t,s=this.icn3d,i=s.icn3dui.parasCls.backgroundColors[s.opts.background.toLowerCase()],n=2.5*s.maxD,l=4*s.maxD,r=void 0!==s.biomtMatrices&&s.biomtMatrices.length*s.cnt>s.maxatomcnt;"yes"===s.opts.slab?r?t=.1:void 0!==s.camMaxDFactorFog?(t=s.maxD*s.camMaxDFactorFog-10,n=2.5*s.maxD-t<0?0:2.5*s.maxD-t,l=4*s.maxD-t):t=s.maxD*s.camMaxDFactor:t=.1;let o=void 0!==e?e:1,a=s.shininess/100*.5;s.uniforms=THREE.UniformsUtils.merge([THREE.UniformsLib.common,{modelViewMatrix:{value:new THREE.Matrix4},modelViewMatrixInverse:{value:new THREE.Matrix4},modelViewMatrixInverseTranspose:{value:new THREE.Matrix4},modelViewProjectionMatrix:{value:new THREE.Matrix4},modelViewProjectionMatrixInverse:{value:new THREE.Matrix4},projectionMatrix:{value:new THREE.Matrix4},projectionMatrixInverse:{value:new THREE.Matrix4},diffuse:{type:"v3",value:[1,1,1]},emissive:{type:"v3",value:[.06,.06,.06]},roughness:{type:"f",value:.5},metalness:{type:"f",value:a},opacity:{type:"f",value:o},nearClip:{type:"f",value:t},ortho:{type:"f",value:0},shrink:{type:"f",value:.13},fogColor:{type:"v3",value:[i.r,i.g,i.b]},fogNear:{type:"f",value:n},fogFar:{type:"f",value:l},fogDensity:{type:"f",value:2}},THREE.UniformsLib.ambient,THREE.UniformsLib.lights]),s.defines={USE_COLOR:1,NEAR_CLIP:1,CAP:1},"yes"!==s.opts.fog||r||(s.defines.USE_FOG=1,"orthographic"===s.opts.camera&&(s.defines.FOG_EXP2=1)),s.bExtFragDepth&&(s.defines.USE_LOGDEPTHBUF_EXT=1)}drawImpostorShader(){this.icn3d.icn3dui.bNode||(this.setParametersForShader(),this.createImpostorShaderSphere("SphereImpostor"),this.createImpostorShaderCylinder("CylinderImpostor"))}getShader(e){this.icn3d.icn3dui;let t=$NGL_shaderTextHash[e];return t=t.replace(/#include\s+(\S+)/gim,(function(e,t){let s;return THREE.ShaderChunk.hasOwnProperty(t)&&(s=THREE.ShaderChunk[t]),s||""})),t}createImpostorShaderBase(e,t,s,i,n,l,r,o,a){let d=this.icn3d;d.icn3dui;let c=new THREE.ShaderMaterial({defines:d.defines,uniforms:d.uniforms,vertexShader:this.getShader(e+".vert"),fragmentShader:this.getShader(e+".frag"),depthTest:!0,depthWrite:!0,lights:!0});c.extensions.fragDepth=!0,"CylinderImpostor"==e?d.CylinderImpostorMaterial=c:"SphereImpostor"==e&&(d.SphereImpostorMaterial=c);let h,p,m=l*r,u=l*o,g=new(m>65535?Uint32Array:Uint16Array)(u);for(let e=0;e=0;t--){let s=a.children[t];s.onBeforeRender=e.impostorCls.onBeforeRender,s.frustumCulled=!1}l.add(a)}void 0!==e.mdl_ghost&&(a=e.mdl_ghost.clone(),this.applyMat(a,d),r.add(a));let c=e.center.clone();this.applyMat(c,d,!0),s.add(c),++t}e.mdl.add(n),e.mdlImpostor.add(l),e.mdl_ghost.add(r),void 0!==e.bSetInstancing&&e.bSetInstancing?(e.maxD=e.maxDAssembly,e.center=e.centerAssembly.clone(),e.applyCenterCls.setCenter(e.center),e.cameraCls.setCamera()):(e.maxD*=Math.sqrt(t),e.center=e.ParserUtilsCls.getMassCenter(s,t),e.maxDAssembly=e.maxD,e.centerAssembly=e.center.clone(),e.applyCenterCls.setCenter(e.center),e.cameraCls.setCamera()),e.bSetInstancing=!0}createInstancedGeometry(e){let t=this.icn3d,s=t.icn3dui,i=e.geometry,n=new THREE.InstancedBufferGeometry,l=[],r=[],o=[],a=[],d=[],c=[],h=[],p=[];if(t.bImpo&&"Cylinder"==e.type){t.instancedMaterial=this.getInstancedMaterial("CylinderInstancing");let e=s.hashUtilsCls.hashvalue2array(i.attributes.position1.array),r=s.hashUtilsCls.hashvalue2array(i.attributes.color.array),m=s.hashUtilsCls.hashvalue2array(i.attributes.position2.array),u=s.hashUtilsCls.hashvalue2array(i.attributes.color2.array),g=s.hashUtilsCls.hashvalue2array(i.index.array),f=s.hashUtilsCls.hashvalue2array(i.attributes.radius.array),b=s.hashUtilsCls.hashvalue2array(i.attributes.mapping.array);l=l.concat(e),o=o.concat(r),h=h.concat(m),p=p.concat(u),a=a.concat(g),d=d.concat(f),c=c.concat(b),n.setAttribute("position1",new THREE.BufferAttribute(new Float32Array(l),3)),n.setAttribute("color",new THREE.BufferAttribute(new Float32Array(o),3)),n.setAttribute("position2",new THREE.BufferAttribute(new Float32Array(h),3)),n.setAttribute("color2",new THREE.BufferAttribute(new Float32Array(p),3)),n.setAttribute("radius",new THREE.BufferAttribute(new Float32Array(d),1)),n.setAttribute("mapping",new THREE.BufferAttribute(new Float32Array(c),3)),n.setIndex(new THREE.BufferAttribute(new Uint32Array(a),1)),e=null,r=null,m=null,u=null,g=null,f=null,b=null}else if(t.bImpo&&"Sphere"==e.type){t.instancedMaterial=this.getInstancedMaterial("SphereInstancing");let e=s.hashUtilsCls.hashvalue2array(i.attributes.position.array),r=s.hashUtilsCls.hashvalue2array(i.attributes.color.array),h=s.hashUtilsCls.hashvalue2array(i.index.array),p=s.hashUtilsCls.hashvalue2array(i.attributes.radius.array),m=s.hashUtilsCls.hashvalue2array(i.attributes.mapping.array);l=l.concat(e),o=o.concat(r),a=a.concat(h),d=d.concat(p),c=c.concat(m),n.setAttribute("position",new THREE.BufferAttribute(new Float32Array(l),3)),n.setAttribute("color",new THREE.BufferAttribute(new Float32Array(o),3)),n.setAttribute("radius",new THREE.BufferAttribute(new Float32Array(d),1)),n.setAttribute("mapping",new THREE.BufferAttribute(new Float32Array(c),2)),n.setIndex(new THREE.BufferAttribute(new Uint32Array(a),1)),e=null,r=null,h=null,p=null,m=null}else{t.instancedMaterial=this.getInstancedMaterial("Instancing");let e=i.attributes.position?s.hashUtilsCls.hashvalue2array(i.attributes.position.array):[],d=i.attributes.normal?s.hashUtilsCls.hashvalue2array(i.attributes.normal.array):[],c=i.attributes.color?s.hashUtilsCls.hashvalue2array(i.attributes.color.array):[],h=i.index?s.hashUtilsCls.hashvalue2array(i.index.array):[];l=l.concat(e),r=r.concat(d),o=o.concat(c),a=a.concat(h);let p=[],m="CylinderGeometry"==i.type?1:0;for(let e=0,t=l.length/3;e0&&(e.dAtoms=t.hashUtilsCls.cloneHash(s)),e.bShowHighlight=!1}e.applyMapCls.removeSurfaces(),e.applyMapCls.applySurfaceOptions(),e.applyMapCls.removeMaps(),e.applyMapCls.applyMapOptions(),e.applyMapCls.removeEmmaps(),e.applyMapCls.applyEmmapOptions(),e.applyMapCls.removePhimaps(),e.axes=[],e.pc1&&e.axesCls.setPc1Axes(),e.drawCls.draw(),e.bShowHighlight=!0,e.opts.rotationcenter="molecule center"}alternateWrapper(){let e=this.icn3d;e.icn3dui,e.bAlternate=!0,this.alternateStructures(),e.bAlternate=!1}}class ct{constructor(e){this.icn3d=e}draw(e){let t=this.icn3d,s=t.icn3dui;if(!t.bRender||t.hAtoms&&0!=Object.keys(t.hAtoms)||(t.hAtoms=s.hashUtilsCls.cloneHash(t.atoms)),t.sceneCls.rebuildScene(),t.bImpo&&t.impostorCls.drawImpostorShader(),t.setColorCls.applyPrevColor(),void 0!==t.biomtMatrices&&t.biomtMatrices.length>1)if(t.bAssembly&&1==Object.keys(t.structures).length&&(void 0===s.cfg.mmdbid&&1==s.cfg.bu||void 0!==s.cfg.mmdbid&&1==s.cfg.bu&&Object.keys(t.atoms).length*t.biomtMatrices.length>t.maxatomcnt))t.instancingCls.drawSymmetryMates();else{let e=!0;t.applyCenterCls.centerSelection(void 0,e)}let i=void 0!==t.hAtoms?Object.keys(t.hAtoms).length:0;if(i>0&&i0){e.children[0].scale.z=t[0].distance,t[0].point.sub(r.mdl.position);let s=r.rayThreshold,i=r.rayCls.getAtomsFromPosition(t[0].point,s);for(;!i&&s<10;)s+=.5,i=r.rayCls.getAtomsFromPosition(t[0].point,s);i&&(r.pAtom=i,this.showPickingVr(r.pk,i))}}}}catch(e){}}showPickingVr(e,t){let s=this.icn3d;if(s.icn3dui,e||(e=2),1===e)s.hAtoms[t.serial]=1;else if(2===e){let e=t.structure+"_"+t.chain+"_"+t.resi;s.hAtoms=s.residues[e]}else if(3===e)s.hAtoms=s.pickingCls.selectStrandHelixFromAtom(t);else if(4===e)s.hAtoms=s.pickingCls.select3ddomainFromAtom(t);else if(5===e){let e=t.structure+"_"+t.chain;s.hAtoms=s.chains[e]}2===e?s.residueLabelsCls.addResidueLabels(s.hAtoms,void 0,void 0,!0):1===e&&s.residueLabelsCls.addAtomLabels(atoms),s.setOptionCls.setStyle("proteins",t.style)}render_base(){let e=this.icn3d,t=e.icn3dui,s=this;if(t.bNode)return;let i=e.bControlGl&&!t.bNode?window.cam:e.cam;if(e.directionalLight){let t=new THREE.Quaternion;t.setFromUnitVectors(new THREE.Vector3(0,0,e.cam_z).normalize(),i.position.clone().normalize()),e.directionalLight.position.copy(e.lightPos.clone().applyQuaternion(t).normalize()),e.directionalLight2.position.copy(e.lightPos2.clone().applyQuaternion(t).normalize()),e.directionalLight3.position.copy(e.lightPos3.clone().applyQuaternion(t).normalize())}if(e.bVr||e.renderer.setPixelRatio(window.devicePixelRatio),e.bVr){let t=.04;if(e.controllers){let i=this.updateGamepadState();for(let n=0,l=e.controllers.length;n{const i=e.gamepad.axes;let r=parseInt(1e3*i[t]),o=parseInt(-1e3*i[s]);n.push(r),l.push(o)})),{xArray:n,yArray:l}}return{xArray:[0,0],yArray:[0,0]}}}class ht{constructor(e){this.icn3d=e}getAtomsWithinAtom(e,t,s,i,n,l,r){let o=this.icn3d;o.icn3dui;let a=this.getNeighboringAtoms(e,t,s,r);i&&(o.resid2Residhash={});let d={};for(let e in t){let c,h,p=o.atoms[e],m=p.structure+"_"+p.chain+"_"+p.resi;for(let e in o.residues[m])if(o.atoms[e]&&("CA"===o.atoms[e].name&&"C"===o.atoms[e].elem||"O3'"===o.atoms[e].name||"O3*"===o.atoms[e].name)){c=o.atoms[e];break}void 0===c&&(c=p),i&&(h=p.resn+" $"+p.structure+"."+p.chain+":"+p.resi,void 0===o.resid2Residhash[h]&&(o.resid2Residhash[h]={}));let u=p.structure+"_"+p.chain+"_"+p.resi;for(let e in a){let m=a[e];if(!o.crossstrucinter&&p.structure!=m.structure)continue;if(!r&&m.serial in t)continue;if(o.bOpm&&"DUM"===m.resn)continue;let g=m.coord.distanceTo(p.coord);if(go?r:o,d=Math.sqrt(a),c=(d+s)*(d+s),h={};for(let r in e){let e=n.atoms[r];!i&&t.hasOwnProperty(e.serial)||(this.bOpm&&"DUM"===e.resn||e.coord.xl[1][0]+s||e.coord.yl[1][1]+s||e.coord.zl[1][2]+s||(e.coord.x-l[2][0])*(e.coord.x-l[2][0])+(e.coord.y-l[2][1])*(e.coord.y-l[2][1])+(e.coord.z-l[2][2])*(e.coord.z-l[2][2])e.coord.x?n:e.coord.x,l=l>e.coord.y?l:e.coord.y,r=r>e.coord.z?r:e.coord.z}return[[t,s,i],[n,l,r],[o/c,a/c,d/c]]}hideContact(){let e=this.icn3d;e.icn3dui,e.opts.contact="no",void 0===e.lines&&(e.lines={}),e.lines.contact=[],e.contactpnts=[];for(let t in e.atoms)e.atoms[t].style2="nothing";for(let t in e.sidec)e.hAtoms.hasOwnProperty(t)&&(e.atoms[t].style2=e.opts.sidec);for(let t in e.water)e.hAtoms.hasOwnProperty(t)&&(e.atoms[t].style=e.opts.water)}}class pt{constructor(e){this.icn3d=e}isHbondDonorAcceptor(e){let t=this.icn3d;if(t.icn3dui,"N"==e.name&&!e.het||"N"==e.elem&&"Arg"==e.resn||"N"==e.elem&&"Asn"==e.resn||"N"==e.elem&&"Gln"==e.resn||"N"==e.elem&&"Lys"==e.resn||"N"==e.elem&&"Trp"==e.resn)return"donor";if("O"==e.name&&!e.het||"S"==e.elem&&"Met"==e.resn||"O"==e.elem&&"Asn"==e.resn||"O"==e.elem&&"Asp"==e.resn||"O"==e.elem&&"Gln"==e.resn||"O"==e.elem&&"Glu"==e.resn)return"acceptor";if("S"==e.elem&&"Cys"==e.resn||"N"==e.elem&&"His"==e.resn||"O"==e.elem&&"Ser"==e.resn||"O"==e.elem&&"Thr"==e.resn||"O"==e.elem&&"Tyr"==e.resn)return"both";if("Pro"==e.resn)return"none";if("N"==e.elem){if("Asn"==e.resn||"Gln"==e.resn)return"both";let s=0,i=0;for(let i=0,n=e.bonds.length;i1?"ring":"donor":"none"}if("O"==e.elem&&1==e.bonds.length){if("Asn"==e.resn||"Gln"==e.resn)return"both";for(let s=0,i=e.bonds.length;s=2?"acceptor":"both"}if("O"==e.elem&&2==e.bonds.length){for(let s=0,i=e.bonds.length;s1);++t)"H"!=s.atoms[e.bonds[t]].elem&&(i=s.atoms[e.bonds[t]],l[r++].subVectors(s.atoms[e.bonds[t]].coord,e.coord));if(1===r)for(let t=0,n=i.bonds.length;t1);++t)"H"!=s.atoms[i.bonds[t]].elem&&s.atoms[i.bonds[t]].serial!=e.serial&&l[r++].subVectors(s.atoms[i.bonds[t]].coord,e.coord);if(2!==r)return;let o=l[0].cross(l[1]);return Math.abs(Math.PI/2-o.angleTo(n))}isValidHbond(e,t,s){let i=this.icn3d;i.icn3dui;let n,l,r=this.isHbondDonorAcceptor(e),o=this.isHbondDonorAcceptor(t),a=50*Math.PI/180,d=50*Math.PI/180,c=90*Math.PI/180,h=30*Math.PI/180;if("donor"==r&&("acceptor"==o||"both"==o||"ring"==o)||"acceptor"==o&&("donor"==r||"both"==r||"ring"==r))n=e,l=t;else if("acceptor"==r&&("donor"==o||"both"==o||"ring"==o)||"donor"==o&&("acceptor"==r||"both"==r||"ring"==r))l=e,n=t;else{if("both"!=r&&"ring"!=r||"both"!=o&&"ring"!=o)return!1;n=e,l=t,i.nucleotides.hasOwnProperty(e.serial)&&i.nucleotides.hasOwnProperty(t.serial)&&("ring"==r||"ring"==o)||(e.het||t.het)&&"ring"==r&&"ring"==o||(h=90*Math.PI/180)}let p=this.calcAngles(n,l),m=90*Math.PI/180;for(let e=0,t=p.length;ed)return!1;let u=this.calcPlaneAngle(n,l);if(void 0!==u&&u>h)return!1;let g=this.calcAngles(l,n),f=90*Math.PI/180;for(let e=0,t=g.length;ea)return!1;let b=this.calcPlaneAngle(l,n);return!(void 0!==b&&b>c)}calculateChemicalHbonds(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(0===Object.keys(e).length||0===Object.keys(t).length)return;r.resid2Residhash={};let a,d,c={},h=s*s;for(let t in e){let s=e[t],n=i?"LYS"===s.resn&&"N"===s.elem&&"N"!==s.name||"ARG"===s.resn&&("NH1"===s.name||"NH2"===s.name)||("GLU"===s.resn||"ASP"===s.resn)&&"O"===s.elem&&"O"!==s.name||s.het&&("N"===s.elem||"O"===s.elem||"S"===s.elem):"N"===s.elem||"O"===s.elem||"S"===s.elem&&(s.het||"Cys"===s.resn||"Met"===s.resn);n=r.bOpm?n&&"DUM"!==s.resn:n,n&&(a=s.structure+"_"+s.chain+"_"+s.resi,d=a+"_"+s.name,c[d]=s)}let p={},m={},u=.5,g=-27.888,f={};for(let e in t){let b=t[e],C=i?"LYS"===b.resn&&"N"===b.elem&&"N"!==b.name||"ARG"===b.resn&&("NH1"===b.name||"NH2"===b.name)||("GLU"===b.resn||"ASP"===b.resn)&&"O"===b.elem&&"O"!==b.name||b.het&&("N"===b.elem||"O"===b.elem||"S"===b.elem):"N"===b.elem||"O"===b.elem||"S"===b.elem&&(b.het||"Cys"===b.resn||"Met"===b.resn);if(C=r.bOpm?C&&"DUM"!==b.resn:C,C){a=b.structure+"_"+b.chain+"_"+b.resi,d=a+"_"+b.name;let e=b.resn+" $"+b.structure+"."+b.chain+":"+b.resi+"@"+b.name;void 0===r.resid2Residhash[e]&&(r.resid2Residhash[e]={});for(let t in c){if(i&&!(("LYS"!==b.resn&&"ARG"!==b.resn||"LYS"!==c[t].resn&&"ARG"!==c[t].resn)&&("GLU"!==b.resn&&"ASP"!==b.resn||"GLU"!==c[t].resn&&"ASP"!==c[t].resn)))continue;if(!r.crossstrucinter&&b.structure!=c[t].structure)continue;if(a==t.substr(0,t.lastIndexOf("_")))continue;let d=Math.abs(b.coord.x-c[t].coord.x);if(d>s)continue;let C=Math.abs(b.coord.y-c[t].coord.y);if(C>s)continue;let y=Math.abs(b.coord.z-c[t].coord.z);if(y>s)continue;let v=d*d+C*C+y*y;if(v>h)continue;if(!r.proteins.hasOwnProperty(b.serial)||!r.proteins.hasOwnProperty(c[t].serial)||"N"!==b.name&&"O"!==b.name||"O"!==c[t].name&&"N"!==c[t].name){if(!this.isValidHbond(b,c[t],s))continue}else{if(b.name===c[t].name)continue;if(b.structure==c[t].structure&&b.chain==c[t].chain&&Math.abs(b.resi-c[t].resi)<=1)continue;let e,i="N"===b.name?b:c[t],n="O"===b.name?b:c[t];if("Pro"===i.resn)continue;if(void 0===i.hcoord){if(!this.isValidHbond(b,c[t],s))continue}else{let s,l=i.hcoord,o=i.coord,a=n.structure+"_"+n.chain+"_"+n.resi;for(let e in r.residues[a])if("C"===r.atoms[e].name){s=r.atoms[e];break}if(!s)continue;let d=s.coord,h=n.coord,p=l.distanceTo(h),m=l.distanceTo(d),f=o.distanceTo(d),C=o.distanceTo(h);e=p2||f[c[t].serial]>2)continue;void 0===f[b.serial]?f[b.serial]=1:++f[b.serial],void 0===f[c[t].serial]?f[c[t].serial]=1:++f[c[t].serial],"graph"!==n&&(i?(r.saltbridgepnts.push({serial:b.serial,coord:b.coord}),r.saltbridgepnts.push({serial:c[t].serial,coord:c[t].coord})):(r.hbondpnts.push({serial:b.serial,coord:b.coord}),r.hbondpnts.push({serial:c[t].serial,coord:c[t].coord})));let w=c[t].structure+"_"+c[t].chain+"_"+c[t].resi;p=o.hashUtilsCls.unionHash(p,r.residues[a]),p=o.hashUtilsCls.unionHash(p,r.residues[w]),m[a]=1,m[w]=1;let _=c[t].resn+" $"+c[t].structure+"."+c[t].chain+":"+c[t].resi+"@"+c[t].name,S=a+"_"+b.resn+","+w+"_"+c[t].resn;void 0!==r.resids2interAll[S]&&void 0!==r.resids2interAll[S].ionic&&r.resids2interAll[S].ionic.hasOwnProperty(e+","+_)||(r.resid2Residhash[e][_]=v.toFixed(1),l||(void 0===r.resids2inter[S]&&(r.resids2inter[S]={}),void 0===r.resids2inter[S].hbond&&(r.resids2inter[S].hbond={}),r.resids2inter[S].hbond[e+","+_]=v.toFixed(1)),void 0===r.resids2interAll[S]&&(r.resids2interAll[S]={}),void 0===r.resids2interAll[S].hbond&&(r.resids2interAll[S].hbond={}),r.resids2interAll[S].hbond[e+","+_]=v.toFixed(1))}}}let b=Object.keys(m);if("graph"!==n)for(let e=0,t=b.length;en)return!1;let c=Math.abs(e.coord.y-t.coord.y);if(c>n)return!1;let h=Math.abs(e.coord.z-t.coord.z);if(h>n)return!1;let p=d*d+c*c+h*h;if(p>l)return!1;"graph"!==s&&("halogen"==i?(a.halogenpnts.push({serial:e.serial,coord:e.coord}),a.halogenpnts.push({serial:t.serial,coord:t.coord})):"pi-cation"==i?(a.picationpnts.push({serial:e.serial,coord:e.coord}),a.picationpnts.push({serial:t.serial,coord:t.coord})):"pi-stacking"==i&&(a.pistackingpnts.push({serial:e.serial,coord:e.coord}),a.pistackingpnts.push({serial:t.serial,coord:t.coord})));let m=t.resn+" $"+t.structure+"."+t.chain+":"+t.resi+"@"+t.name;a.resid2Residhash[r][m]=p.toFixed(1);let u=e.structure+"_"+e.chain+"_"+e.resi+"_"+e.resn+","+t.structure+"_"+t.chain+"_"+t.resi+"_"+t.resn;return o||(void 0===a.resids2inter[u]&&(a.resids2inter[u]={}),void 0===a.resids2inter[u][i]&&(a.resids2inter[u][i]={}),a.resids2inter[u][i][r+","+m]=p.toFixed(1)),void 0===a.resids2interAll[u]&&(a.resids2interAll[u]={}),void 0===a.resids2interAll[u][i]&&(a.resids2interAll[u][i]={}),a.resids2interAll[u][i][r+","+m]=p.toFixed(1),!0}getRingNormal(e){if(this.icn3d.icn3dui,e.length<3)return;let t=e[0].clone().sub(e[1]),s=e[1].clone().sub(e[2]);return t.cross(s).normalize()}getAromaticRings(e,t,s){let i=this.icn3d;i.icn3dui;let n=[],l=[],r=[],o=[];if("nucleotide"==s){let s=new THREE.Vector3,a=new THREE.Vector3;if("A"==e.trim().toUpperCase()||"DA"==e.trim().toUpperCase()||"G"==e.trim().toUpperCase()||"DG"==e.trim().toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"N1"==t.name||"C2"==t.name||"N3"==t.name||"C6"==t.name?(s.add(t.coord),r.push(t.coord)):"C4"==t.name||"C5"==t.name?(s.add(t.coord),a.add(t.coord),r.push(t.coord),o.push(t.coord)):"N7"!=t.name&&"C8"!=t.name&&"N9"!=t.name||(a.add(t.coord),o.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r))),5==o.length&&(a.multiplyScalar(.2),n.push(a),l.push(this.getRingNormal(o)))}else if("C"==e.trim().toUpperCase()||"DC"==e.trim().toUpperCase()||"T"==e.trim().toUpperCase()||"DT"==e.trim().toUpperCase()||"U"==e.trim().toUpperCase()||"DU"==e.trim().toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"N1"==t.name||"C2"==t.name||"N3"==t.name||"C6"==t.name?(s.add(t.coord),r.push(t.coord)):"C4"!=t.name&&"C5"!=t.name||(s.add(t.coord),r.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r)))}}else if("protein"==s){let s=new THREE.Vector3,a=new THREE.Vector3;if("PHE"==e.toUpperCase()||"TYR"==e.toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"CG"!=t.name&&"CD1"!=t.name&&"CE1"!=t.name&&"CZ"!=t.name&&"CE2"!=t.name&&"CD2"!=t.name||(s.add(t.coord),r.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r)))}else if("HIS"==e.toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"CG"!=t.name&&"ND1"!=t.name&&"CE1"!=t.name&&"NE2"!=t.name&&"CD2"!=t.name||(s.add(t.coord),r.push(t.coord))}5==r.length&&(s.multiplyScalar(.2),n.push(s),l.push(this.getRingNormal(r)))}else if("TRP"==e.toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"CZ2"==t.name||"CH2"==t.name||"CZ3"==t.name||"CE3"==t.name?(s.add(t.coord),r.push(t.coord)):"CD2"==t.name||"CE2"==t.name?(s.add(t.coord),a.add(t.coord),r.push(t.coord),o.push(t.coord)):"CG"!=t.name&&"CD1"!=t.name&&"NE1"!=t.name||(a.add(t.coord),o.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r))),5==o.length&&(a.multiplyScalar(.2),n.push(a),l.push(this.getRingNormal(o)))}}return{piPosArray:n,normalArray:l}}dfs_cycle(e,t,s){let i=this.icn3d;if(i.icn3dui,2==i.ring_color[e])return s;if(1==i.ring_color[e]){s++;let n=t;for(i.ring_mark[n]=s;n!=e;)n=i.ring_par[n],i.ring_mark[n]=s;return s}if(i.ring_par[e]=t,i.ring_color[e]=1,void 0!==i.atoms[e])for(let t=0,n=i.atoms[e].bonds.length;t=3&&o<=6&&a[0]&&a[1]&&a[2]&&a[3]){let i=a[0].clone().sub(a[1]).normalize(),r=a[1].clone().sub(a[2]).normalize(),d=a[2].clone().sub(a[3]).normalize(),c=i.cross(r).normalize(),h=c.dot(d);if(Math.abs(h)<.052){l.multiplyScalar(1/o);let i=t.atoms[n];s[e+"_pi"+n]={resn:i.resn,name:"pi"+n,coord:l,serial:i.serial,structure:i.structure,chain:i.chain,resi:i.resi,normal:c}}}}return s}hideHalogenPi(){let e=this.icn3d;e.icn3dui,e.opts.halogen="no",e.opts["pi-cation"]="no",e.opts["pi-stacking"]="no",void 0===e.lines&&(e.lines={}),e.lines.halogen=[],e.lines["pi-cation"]=[],e.lines["pi-stacking"]=[],e.halogenpnts=[],e.picationpnts=[],e.pistackingpnts=[];for(let t in e.atoms)e.atoms[t].style2="nothing";for(let t in e.sidec)e.hAtoms.hasOwnProperty(t)&&(e.atoms[t].style2=e.opts.sidec);for(let t in e.water)e.hAtoms.hasOwnProperty(t)&&(e.atoms[t].style=e.opts.water)}}class ut{constructor(e){this.icn3d=e}calculateIonicInteractions(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(0===Object.keys(e).length||0===Object.keys(t).length)return;r.resid2Residhash={};let a,d,c={},h={},p=s*s;for(let t in e){let s=e[t];if("ARG"===s.resn&&"NH2"===s.name||"GLU"===s.resn&&"OE2"===s.name||"ASP"===s.resn&&"OD2"===s.name)continue;let i=("LYS"===s.resn||"HIS"===s.resn)&&"N"===s.elem&&"N"!==s.name||"ARG"===s.resn&&("NH1"===s.name||"NH2"===s.name)||s.het&&-1!==o.parasCls.cationsTrimArray.indexOf(s.elem)||s.het&&"N"===s.elem&&1==s.bonds.length,n=this.isAnion(s);i=r.bOpm?i&&"DUM"!==s.resn:i,n=r.bOpm?n&&"DUM"!==s.resn:n,(i||n)&&(a=s.structure+"_"+s.chain+"_"+s.resi,d=a+"_"+s.name,i&&(c[d]=s),n&&(h[d]=s))}let m={},u={};for(let e in t){let i=t[e];if("ARG"===i.resn&&"NH2"===i.name||"GLU"===i.resn&&"OE2"===i.name||"ASP"===i.resn&&"OD2"===i.name)continue;let g=("LYS"===i.resn||"HIS"===i.resn)&&"N"===i.elem&&"N"!==i.name||"ARG"===i.resn&&("NH1"===i.name||"NH2"===i.name)||i.het&&-1!==o.parasCls.cationsTrimArray.indexOf(i.elem),f=this.isAnion(i);if(g=r.bOpm?g&&"DUM"!==i.resn:g,f=r.bOpm?f&&"DUM"!==i.resn:f,g||f){a=i.structure+"_"+i.chain+"_"+i.resi,d=a+"_"+i.name;let e=i.resn+" $"+i.structure+"."+i.chain+":"+i.resi+"@"+i.name;void 0===r.resid2Residhash[e]&&(r.resid2Residhash[e]={});let t={};g?t=h:f&&(t=c);let b,C=i.structure+"_"+i.chain+"_"+i.resi;g&&"ARG"===i.resn&&"NH1"===i.name?b=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[C],"NH2"):f&&"GLU"===i.resn&&"OE1"===i.name?b=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[C],"OE2"):f&&"ASP"===i.resn&&"OD1"===i.name&&(b=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[C],"OD2"));let y=void 0===b?i.coord:i.coord.clone().add(b.coord).multiplyScalar(.5);for(let d in t){if(a==d.substr(0,d.lastIndexOf("_")))continue;if(!r.crossstrucinter&&i.structure!=t[d].structure)continue;let c,h=t[d].structure+"_"+t[d].chain+"_"+t[d].resi;f&&"ARG"===t[d].resn&&"NH1"===t[d].name?c=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[h],"NH2"):g&&"GLU"===t[d].resn&&"OE1"===t[d].name?c=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[h],"OE2"):g&&"ASP"===t[d].resn&&"OD1"===t[d].name&&(c=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[h],"OD2"));let b=void 0===c?t[d].coord:t[d].coord.clone().add(c.coord).multiplyScalar(.5),C=Math.abs(y.x-b.x);if(C>s)continue;let v=Math.abs(y.y-b.y);if(v>s)continue;let w=Math.abs(y.z-b.z);if(w>s)continue;let _=C*C+v*v+w*w;if(_>p)continue;"graph"!==n&&(r.saltbridgepnts.push({serial:i.serial,coord:y}),r.saltbridgepnts.push({serial:t[d].serial,coord:b}));let S=t[d].structure+"_"+t[d].chain+"_"+t[d].resi;m=o.hashUtilsCls.unionHash(m,r.residues[a]),m=o.hashUtilsCls.unionHash(m,r.residues[S]),u[a]=1,u[S]=1;let A=t[d].resn+" $"+t[d].structure+"."+t[d].chain+":"+t[d].resi+"@"+t[d].name;r.resid2Residhash[e][A]=_.toFixed(1);let x=a+"_"+i.resn+","+S+"_"+t[d].resn;l||(void 0===r.resids2inter[x]&&(r.resids2inter[x]={}),void 0===r.resids2inter[x].ionic&&(r.resids2inter[x].ionic={}),r.resids2inter[x].ionic[e+","+A]=_.toFixed(1)),void 0===r.resids2interAll[x]&&(r.resids2interAll[x]={}),void 0===r.resids2interAll[x].ionic&&(r.resids2interAll[x].ionic={}),r.resids2interAll[x].ionic[e+","+A]=_.toFixed(1)}}}let g=Object.keys(u);if("graph"!==n)for(let e=0,t=g.length;e1?1/(n-1):1;for(let n in e){let e=t.atoms[n];e.color=e.het?s.parasCls.atomColors[e.elem]||s.parasCls.defaultAtomColor:s.parasCls.thr().setHSL(3/4*(1-i++*l),1,.45),t.atomPrevColors[n]=e.color}}colorRainbow(e){let t=this.icn3d,s=t.icn3dui,i=0,n=0;e=s.hashUtilsCls.intHash(e,t.hAtoms);for(let s in e){t.atoms[s].het||++n}let l=n>1?1/(n-1):1;for(let n in e){let e=t.atoms[n];e.color=e.het?s.parasCls.atomColors[e.elem]||s.parasCls.defaultAtomColor:s.parasCls.thr().setHSL(3/4*i++*l,1,.45),t.atomPrevColors[n]=e.color}}setColorAcrossSets(e,t){let s=this.icn3d,i=s.icn3dui,n=0,l=e.length,r=l>1?1/(l-1):1;for(let l=0,o=e.length;l0)this.setMmdbChainColor();else{let e=-1,s="",l=n.parasCls.stdChainColors.length;for(let r in t){let t=i.atoms[r];t.chain!=s&&(++e,e%=l),t.het?(t.color=n.parasCls.atomColors[t.elem],i.atomPrevColors[r]=t.color):(t.color=n.parasCls.stdChainColors[e],Object.keys(i.chainsColor).length>0&&this.updateChainsColor(t),i.atomPrevColors[r]=t.color),s=t.chain}}break;case"domain":s=0,l=0;let m=Object.keys(i.tddomains);l=m.length,r=l>1?1/(l-1):1;for(let e=0,t=m.length;e1?1/(l-1):1;for(let e=0;e Defined Sets", and try it again.');break;case"secondary structure green":i.sheetcolor="green";for(let e in t){let t=i.atoms[e];t.color=t.het?n.parasCls.atomColors[t.elem]||n.parasCls.defaultAtomColor:n.parasCls.ssColors[t.ss]||n.parasCls.thr(16711935),i.atomPrevColors[e]=t.color}break;case"secondary structure yellow":case"secondary structure":i.sheetcolor="yellow";for(let e in t){let t=i.atoms[e];t.color=t.het?n.parasCls.atomColors[t.elem]||n.parasCls.defaultAtomColor:n.parasCls.ssColors2[t.ss]||n.parasCls.thr(16711935),i.atomPrevColors[e]=t.color}break;case"secondary structure spectrum":s=0,l=0;let u,g,f=[],b=-9999;for(let e in t){if(!i.proteins.hasOwnProperty(e))continue;let t=i.atoms[e];-9999==b&&(u=parseInt(e)),-9999!=b&&(t.ss!=g.ss||Math.abs(t.resi-g.resi)>1||t.ssbegin&&g.ssend)&&("coil"==g.ss||f.push([u,b]),u=e),b=parseInt(e),g=t}"coil"==g.ss||f.push([u,b]),l=f.length,r=l>1?1/(l-1):1;for(let e=0,t=f.length;e100&&(e=100);let r=(i.middB-e)*i.spanBinv1,o=(e-i.middB)*i.spanBinv2;e=90?t.color=n.parasCls.thr().setRGB(0,.325,.839):e>=70&&e<90?t.color=n.parasCls.thr().setRGB(.396,.572,.953):e>=50&&e<70?t.color=n.parasCls.thr().setRGB(1,.859,.075):e<50&&(t.color=n.parasCls.thr().setRGB(1,.49,.271))}i.atomPrevColors[e]=t.color}break;case"b factor":i.middB=50,i.spanBinv1=.02,i.spanBinv2=.02;for(let e in t){let t=i.atoms[e];if(void 0===t.b||isNaN(t.b)||0==parseInt(1e3*t.b))t.color=n.parasCls.thr().setRGB(0,1,0);else{let e=t.b;e>100&&(e=100),e=t.structure.substr(0,4)!=i.defaultPdbId&&t.structure.length>5?100-e:e;let s=(i.middB-e)*i.spanBinv1,l=(e-i.middB)*i.spanBinv2;t.color=et.b&&(o=t.b),a5?100-t.b:t.b,s=i.bfactorArray.indexOf(e)/C;t.color=s<.5?n.parasCls.thr().setRGB(2*s,2*s,1):n.parasCls.thr().setRGB(1,2*(1-s),2*(1-s))}i.atomPrevColors[e]=t.color}break;case"area":if(void 0===i.resid2area){let e=n.hashUtilsCls.cloneHash(i.hAtoms);i.hAtoms=n.hashUtilsCls.cloneHash(i.atoms),i.bCalcArea=!0,i.opts.surface="solvent accessible surface",i.applyMapCls.applySurfaceOptions(),i.bCalcArea=!1,i.hAtoms=n.hashUtilsCls.cloneHash(e)}let y=void 0!==i.midpercent?i.midpercent:35;i.spanBinv1=.02,i.spanBinv2=.02;for(let e in t){let t=i.atoms[e],s=t.structure+"_"+t.chain+"_"+t.resi+"_"+t.resn,l=n.parasCls.residueArea.hasOwnProperty(t.resn)?i.resid2area[s]/n.parasCls.residueArea[t.resn]*100:y;l>100&&(l=100);let r=(y-l)*i.spanBinv1,o=(l-y)*i.spanBinv2;t.color=l

    ";if("atom"==e){let e=["proteins","nucleotides","chemicals","ions","water"];for(let i=0,n=e.length;i[e,s.parasCls.hydrophobicValues[e]]));r.sort(((e,t)=>parseFloat(e[1])-parseFloat(t[1])));var o=r.map((e=>[e[0],Object.keys(n[e[0]])[0]]));l+="
    ","normalized hydrophobic"==e?(l+="Dark green (W, F, Y, L, I, C, M): Hydrophobic
    ",l+="Light green (G, V, S, T, A, N, P, Q): Polar
    ",l+="Grey: Charged, not hydrophobic

    "):(l+="Green (W, F, Y, L, I, C, M): Hydrophobic
    ",l+="Yellow (G, V, S, T, A, N, P, Q): Polar
    ",l+="Red: Negatively Charged
    ",l+="Blue: Positively Charged

    ");let a=0;for(let e of o)s.parasCls.residueAbbrev[e[0]]&&(l+="
    ",l+="
    ",l+=s.parasCls.residueAbbrev[e[0]]+"
    ",a%4==3&&(l+="
    "),++a);l+="
    "}else"b factor"==e?(l+="
    B factor quantitates the uncertainty for each atom. A high B factor reflects that the position is less certain.

    ",l+=s.htmlCls.clickMenuCls.setLegendHtml()):"confidence"==e?l+=s.htmlCls.clickMenuCls.setLegendHtml(!0):(l="",i=!0);$("#"+s.pre+"dl_legend").html(l),s.htmlCls.dialogCls.openDlg("dl_legend","Color Legend"),i&&window.dialog&&window.dialog.dialog("close")}getColorLegendForElem(e,t){let s=this.icn3d,i=s.icn3dui,n="",l={};for(let e in t){let t=s.atoms[e],i=void 0===t||void 0===t.color||"FFFFFF"===t.color.getHexString().toUpperCase()?"DDDDDD":t.color.getHexString();void 0===l[t.elem]&&(l[t.elem]={}),l[t.elem][i]=1}if(Object.keys(l).length>0){n+=""+e+"
    ";let t=Object.keys(l).sort();for(let e=0,s=t.length;e";for(let e in l[s])n+="
    ";n+=i.parasCls.atomnames[s.toUpperCase()]+"

    "}n+="
    "}return n}getRes2color(e,t){let s=this.icn3d,i=s.icn3dui,n={},l=s.firstAtomObjCls.getResiduesFromAtoms(e);for(let e in l){let l=s.residues[e],r=s.firstAtomObjCls.getFirstAtomObj(l),o=t?r.resn:i.parasCls.residueAbbrev[r.resn],a=void 0===r||void 0===r.color||"FFFFFF"===r.color.getHexString().toUpperCase()?"DDDDDD":r.color.getHexString();null!=o&&(void 0===n[o]&&(n[o]={}),n[o][a]=1)}return n}getColorLegendForResidue(e){this.icn3d.icn3dui;let t="",s=this.getRes2color(e);if(Object.keys(s).length>0){t+="
    ";let e=Object.keys(s).sort(),i="",n=0;for(let l=0,r=e.length;l";for(let e in s[o])r+="
    ";r+=o+"
    ",n%4==3&&(r+="
    "),-1!=o.indexOf("(")?(t+=r,++n):i+=r}i&&(t+="
    "+i),t+="
    "}return t}getColorLegendForCharge(e){let t=this.icn3d;t.icn3dui;let s="",i=t.firstAtomObjCls.getResiduesFromAtoms(e),n={};for(let e in i){let s=t.residues[e],i=t.firstAtomObjCls.getFirstAtomObj(s);"ARG"==i.resn||"LYS"==i.resn?n.Positive=1:"HIS"==i.resn?n["Partial-Positive"]=1:"ASP"==i.resn||"GLU"==i.resn||t.nucleotides[i.serial]?n.Negative=1:n.Neutral=1}const l={Positive:"0000ff","Partial-Positive":"8080ff",Negative:"ff0000",Neutral:"888888"};let r=["Positive","Partial-Positive","Negative","Neutral"];s+="
    ";for(let e=0,t=r.length;e",s+="
    ",s+=t,s+="
    ")}return s+="
    (Charges are at pH 7)",s+="
    ",s}getColorLegendForIgstrand(e){this.icn3d.icn3dui;let t="";const s={"A^ Strand":"FF00FF","A Strand":"663399","A* Strand":"FFC0CB","A Strand":"9370db","B Strand":"ba55d3","C Strand":"0000FF","C' Strand":"6495ED","C'' Strand":"006400","D Strand":"00FF00","E Strand":"FFFF00","F Strand":"FFA500","G Strand":"FF0000","G* Strand":"8B0000",Loop:"CCCCCC"};t+="
    ";for(let e in s){t+="",t+="
    ",t+=e,t+="

    "}return t+="
    ",t}}class yt{constructor(e){this.icn3d=e}async showCddSiteAll(){let e=this.icn3d,t=e.icn3dui,s=this;e.chainid2pssmid={};let i=$.map(e.protein_chainid,(function(e){return e})),n=Object.keys(e.protein_chainid),l="https://www.ncbi.nlm.nih.gov/Structure/cdannots/cdannots.fcgi?fmt&frclive&live=lcl&queries="+i;if(1==Object.keys(e.structures).length&&(t.cfg.mmtfid||t.cfg.pdbid||t.cfg.opmid||t.cfg.mmdbid||t.cfg.gi||t.cfg.uniprotid||t.cfg.blast_rep_id||t.cfg.cid||t.cfg.mmcifid)||2==Object.keys(e.structures).length&&t.cfg.align){let e={};try{e.value=await t.getAjaxPromise(l,"jsonp"),s.parseCddData([e],n)}catch(e){return void s.getNoCdd(i)}}else{let i=[];for(let s=0,r=n.length;s',p=h,m=h,u=d.doms;n.bNode&&!i.resid2cdd[c]&&(i.resid2cdd[c]=[]);let g=l.setDomainFeature(u,c,!0,h,p,m);i.chainid2pssmid[c]={pssmid2name:g.pssmid2name,pssmid2fromArray:g.pssmid2fromArray,pssmid2toArray:g.pssmid2toArray};let f=g.acc2domain;h=g.html+"",p=g.html2+"",m=g.html3+"",$("#"+i.pre+"dt_cdd_"+c).html(h),$("#"+i.pre+"ov_cdd_"+c).html(p),$("#"+i.pre+"tt_cdd_"+c).html(m),h='
    ',p=h,m=h;let b=d.motifs;n.bNode&&!i.resid2site[c]&&(i.resid2site[c]=[]),g=l.setDomainFeature(b,c,!1,h,p,m,f),h=g.html,p=g.html2,m=g.html3;let C=a.data[e].sites,y=void 0!==C?C.length:0;for(let e=0;e17&&(s=s.substr(0,17)+"...");let l,r=C[e].title,o=[];for(let t=0,s=C[e].locs.length;t'+s+"
    ",u=''+t.toString()+" Res",g='';m+=d+u+"
    ",h+=d+u+g,p+=d+u+g;let f="site"+e.toString(),b=0,y=0,v=1;for(let t=0,s=i.giSeq[c].length;t1&&(l=s[0]+"..");let r=i.ParserUtilsCls.getResi(c,t);if(h+=''+s+"",n.bNode){let t={};t[c+"_"+r]="site: "+C[e].title,i.resid2site[c].push(t)}p+=i.showSeqCls.insertGapOverview(c,t);let o=n.cfg.blast_rep_id==c?Math.round(i.seqAnnWidth*t/(i.maxAnnoLength+i.nTotalGap)-b-y):Math.round(i.seqAnnWidth*t/i.maxAnnoLength-b-y);o>=0&&(p+='
     
    ',p+='
     
    ',b+=o,y+=v)}else h+="-";g=' '+t.toString()+" Residues",g+="
    ",g+="
    ",h+=g,p+=g}h+="",p+="",m+="",$("#"+i.pre+"dt_site_"+c).html(h),$("#"+i.pre+"ov_site_"+c).html(p),$("#"+i.pre+"tt_site_"+c).html(m)}}for(let e in i.protein_chainid)r.hasOwnProperty(e)||($("#"+i.pre+"dt_cdd_"+e).html(""),$("#"+i.pre+"ov_cdd_"+e).html(""),$("#"+i.pre+"tt_cdd_"+e).html(""),$("#"+i.pre+"dt_site_"+e).html(""),$("#"+i.pre+"ov_site_"+e).html(""),$("#"+i.pre+"tt_site_"+e).html(""));i.showAnnoCls.enableHlSeq(),i.bAjaxCddSite=!0}getNoCdd(e){let t=this.icn3d;t.icn3dui,console.log("No CDD data were found for the protein "+e+"...");for(let e in t.protein_chainid)$("#"+t.pre+"dt_cdd_"+e).html(""),$("#"+t.pre+"ov_cdd_"+e).html(""),$("#"+t.pre+"tt_cdd_"+e).html(""),$("#"+t.pre+"dt_site_"+e).html(""),$("#"+t.pre+"ov_site_"+e).html(""),$("#"+t.pre+"tt_site_"+e).html("");t.showAnnoCls.enableHlSeq(),t.bAjaxCddSite=!0}setDomainFeature(e,t,s,i,n,l,r){let o,a,d,c=this.icn3d,h=c.icn3dui;s&&(r={},o={},a={},d={});let p=void 0!==e?e.length:0,m=s?14:19,u=s?100:120;for(let g=0;gm&&(v=v.substr(0,m)+"...");let w=b+": "+C;s&&(o[p]=C);let _=e[g].locs;if(_)for(let e=0,r=_.length;e'+v+" ",E=''+S.toString()+" Res";l+=R+E+"
    ";let I='';i+=R+E+I,s&&(n+='
    '),n+='
    '+v+"
    ",n+=E+I;let T=b+g.toString();for(let e=0,n=c.giSeq[t].length;e1&&(l=n[0]+"..");let r=c.ParserUtilsCls.getResi(t,e);if(i+=''+n+"",h.bNode){let e={};e[t+"_"+r]=w,s?c.resid2cdd[t].push(e):c.resid2site[t].push(e)}}else i+="-";let M=c.firstAtomObjCls.getFirstCalphaAtomObj(c.chains[t]),P=void 0===M.color||"FFFFFF"===M.color.getHexString()?"DDDDDD":M.color.getHexString(),D=void 0!==M.color?P:"CCCCCC";if(h.cfg.blast_rep_id!=t)for(let s=0,i=r.length;s ',n+='
    '+C+"
    "}else{let s=[],i=[];for(let e=0,t=r.length;e ',n+='
    '+C+"
    "}}I=' '+S.toString()+" Residues",I+="
    ",I+="
    ",i+=I,n+=I,s&&(n+='')}}return{html:i,html2:n,html3:l,acc2domain:r,pssmid2name:o,pssmid2fromArray:a,pssmid2toArray:d}}showAnnoType(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui,a='
    ',d=a,c=a;if(0==n.length)return $("#"+r.pre+"dt_"+s+"_"+e).html(""),$("#"+r.pre+"ov_"+s+"_"+e).html(""),void $("#"+r.pre+"tt_"+s+"_"+e).html("");let h=i;i.length>17&&(i=i.substr(0,17)+"...");let p=[];for(let e=0,t=n.length;e'+i+"
    ",f=''+m.toString()+" Res";c+=g+f+"
    ";let b='';a+=g+f+b,d+=g+f+b;let C=s,y=0,v=0;for(let t=0,i=r.giSeq[e].length;t1&&(c=n[0]+"..");let h=i,p=e+"_"+i,m=n+i;if("ssbond"==s){m="Residue "+p+" has disulfide bond with";let t="";if(void 0!==l[p])for(let e=0,s=l[p].length;e'+c+"",d+=r.showSeqCls.insertGapOverview(e,t);let u=o.cfg.blast_rep_id==e?Math.round(r.seqAnnWidth*t/(r.maxAnnoLength+r.nTotalGap)-y-v):Math.round(r.seqAnnWidth*t/r.maxAnnoLength-y-v);u>=0&&(d+='
     
    ',d+='
     
    ',y+=u,v+=1)}else a+="-"}b=' '+m.toString()+" Residues",b+="",b+="
    ",a+=b,d+=b,a+="",d+="",c+="",$("#"+r.pre+"dt_"+s+"_"+e).html(a),$("#"+r.pre+"ov_"+s+"_"+e).html(d),$("#"+r.pre+"tt_"+s+"_"+e).html(c)}setToolTip(){let e=this.icn3d;e.icn3dui,$("[id^="+e.pre+"snp]").add("[id^="+e.pre+"clinvar]").add("[id^="+e.pre+"ssbond]").add("[id^="+e.pre+"crosslink]").tooltip({content:function(){return $(this).prop("title")},show:null,close:function(e,t){t.tooltip.hover((function(){$(this).stop(!0).fadeTo(400,1)}),(function(){$(this).fadeOut("400",(function(){$(this).remove()}))}))}})}}class vt{constructor(e){this.icn3d=e}showInteraction(e,t){this.icn3d.icn3dui,this.showInteraction_base(e,t)}showInteraction_base(e,t){let s=this.icn3d,i=s.icn3dui;i.bNode&&(s.resid2contact||(s.resid2contact={}),s.resid2contact[e]||(s.resid2contact[e]=[])),void 0===s.chainname2residues&&(s.chainname2residues={});let n=Object.keys(s.chains),l=e,r=Math.round(l.indexOf("_"));if(s.firstAtomObjCls.getFirstCalphaAtomObj(s.chains[l]),void 0===s.chainname2residues[l]){s.chainname2residues[l]={};let t=n.length;if(t>100&&void 0===i.cfg.mmdbid&&void 0===i.cfg.gi&&void 0===i.cfg.blast_rep_id&&void 0===i.cfg.align&&void 0===i.cfg.chainalign)return $("#"+s.pre+"dt_interaction_"+e).html(""),void $("#"+s.pre+"ov_interaction_"+e).html("");for(let e=0;e4)continue;let o,a=s.firstAtomObjCls.getFirstCalphaAtomObj(s.chains[t]);s.chemicals.hasOwnProperty(a.serial)?o="chemical":s.nucleotides.hasOwnProperty(a.serial)?o="nucleotide":s.ions.hasOwnProperty(a.serial)?o="ion":s.proteins.hasOwnProperty(a.serial)?o="protein":s.water.hasOwnProperty(a.serial)&&(o="water");let d=s.contactCls.getAtomsWithinAtom(i.hashUtilsCls.hash2Atoms(s.chains[l],s.atoms),i.hashUtilsCls.hash2Atoms(s.chains[t],s.atoms),4);if(0==Object.keys(d).length)continue;let c={};for(let e in d){let t=s.atoms[e];c[t.structure+"_"+t.chain+"_"+t.resi]=1}let h=t.substr(t.indexOf("_")+1)+"("+o+")";s.chainname2residues[l][h]=Object.keys(c)}}let o='
    ',a=o,d=o,c=0;for(let t in s.chainname2residues[e]){let n=s.chainname2residues[e][t];if(!n)continue;let l="Interact ."+t;l.length>17&&(l=l.substr(0,17)+"...");let r="Interact ."+t,h=[];for(let e=0,t=n.length;e'+l+"
    ",g=''+p.toString()+" Res";d+=u+g+"
    ";let f='';o+=u+g+f,a+=u+g+f;let b="inter"+c.toString(),C=0,y=0,v=1;for(let t=0,n=s.giSeq[e].length;t1&&(d=l[0]+"..");let c=n;if(o+=''+d+"",i.bNode){let t={};t[e+"_"+c]=r,s.resid2contact[e].push(t)}a+=s.showSeqCls.insertGapOverview(e,t);let h=i.cfg.blast_rep_id==e?Math.round(s.seqAnnWidth*t/(s.maxAnnoLength+s.nTotalGap)-C-y):Math.round(s.seqAnnWidth*t/s.maxAnnoLength-C-y);h>=0&&(a+='
     
    ',a+='
     
    ',C+=h,y+=v)}else o+="-"}f=' '+p.toString()+" Residues",f+="
    ",f+="
    ",o+=f,a+=f,++c}o+="",a+="",d+="",$("#"+s.pre+"dt_interaction_"+e).html(o),$("#"+s.pre+"ov_interaction_"+e).html(a),$("#"+s.pre+"tt_interaction_"+e).html(d),i.utilsCls.isMobile()?(s.hlSeqCls.selectSequenceMobile(),s.hlSeqCls.selectChainMobile()):s.hlSeqCls.selectSequenceNonMobile()}}class wt{constructor(e){this.icn3d=e}async showPTM(e,t,s,i,n){let l=this.icn3d,r=l.icn3dui,o=this,a=e.substr(0,e.indexOf("_")),d=e.substr(e.indexOf("_")+1);if("afmem"==s){let t={Transmembrane:[{begin:i,end:n}]};this.setAnnoPtmTransmem("transmem",t,e)}else if(a.length>5){let t,i="https://www.ebi.ac.uk/proteins/api/features/"+a;try{t=await r.getAjaxPromise(i,"json"),o.parsePTM(t,e,s)}catch{return void o.getNoPTM(e,s)}}else{let t,i=a.substr(0,4).toLowerCase(),n="https://www.ebi.ac.uk/pdbe/api/mappings/uniprot/"+i;try{t=await r.getAjaxPromise(n,"json");let a="";l.UPResi2ResiPosPerChain||(l.UPResi2ResiPosPerChain={}),l.UPResi2ResiPosPerChain[e]={};let c=t[i].UniProt,h=!1;for(let t in c){let s=c[t].mappings;for(let i=0,n=s.length;i',o+=r,a+=r;let d=s.substr(0,s.indexOf("_"));for(let c in t){let h=t[c],p=[],m=!1;for(let e=0,t=h.length;e5?p.push(e-1):i.UPResi2ResiPosPerChain&&i.UPResi2ResiPosPerChain[s][e]&&p.push(i.UPResi2ResiPosPerChain[s][e]),!m&&i.residues.hasOwnProperty(s+"_"+e)&&(m=!0)}if(0==p.length)continue;let u=p.length,g="ptm"==e?"PTM: "+c:"Transmembrane";g.length>17&&(g=g.substr(0,17)+"...");let f=c,b='
    '+g+"
    ",C=''+u.toString()+" Res",y='';a+=b+C+"
    ",r+=b+C+y,o+=b+C+y;let v=e+l.toString(),w=0,_=0,S=1;for(let e=0,t=i.giSeq[s].length;e1&&(l=t[0]+"..");let a=i.ParserUtilsCls.getResi(s,e);if(r+=''+t+"",n.bNode){let e={};e[s+"_"+a]=g,i.resid2ptm[s].push(e)}o+=i.showSeqCls.insertGapOverview(s,e);let d=n.cfg.blast_rep_id==s?Math.round(i.seqAnnWidth*e/(i.maxAnnoLength+i.nTotalGap)-w-_):Math.round(i.seqAnnWidth*e/i.maxAnnoLength-w-_);d>=0&&(o+='
     
    ',o+='
     
    ',w+=d,_+=S)}else r+="-";y=' '+u.toString()+" Residues",y+="
    ",y+="
    ",r+=y,o+=y,++l}r+="",o+="",a+="",$("#"+i.pre+"dt_"+e+"_"+s).html(r),$("#"+i.pre+"ov_"+e+"_"+s).html(o),$("#"+i.pre+"tt_"+e+"_"+s).html(a)}getNoPTM(e,t){let s=this.icn3d;s.icn3dui,console.log("No PTM data were found for the chain "+e+"...");let i="ptm"==t?"ptm":"transmem";$("#"+s.pre+"dt_"+i+"_"+e).html(""),$("#"+s.pre+"ov_"+i+"_"+e).html(""),$("#"+s.pre+"tt_"+i+"_"+e).html(""),s.showAnnoCls.enableHlSeq(),s.bAjaxPTM=!0}}class _t{constructor(e){this.icn3d=e}showCrosslink(e,t){let s=this.icn3d;s.icn3dui;let i=this;void 0===s.clbondpnts?setTimeout((function(){i.showCrosslink_base(e,t)}),1e3):this.showCrosslink_base(e,t)}showCrosslink_base(e,t){let s=this.icn3d;s.icn3dui.bNode&&(s.resid2crosslink||(s.resid2crosslink={}),s.resid2crosslink[e]||(s.resid2crosslink[e]=[]));let i=t,n={},l=i.substr(0,i.indexOf("_")),r=s.clbondpnts[l];if(void 0===r)return $("#"+s.pre+"dt_crosslink_"+e).html(""),$("#"+s.pre+"ov_crosslink_"+e).html(""),void $("#"+s.pre+"tt_crosslink_"+e).html("");for(let e=0,t=r.length;e',a=o,d=o,c=e.indexOf("_"),h=e.substr(c+1);if(s)n=e,i=t.domains[e]?t.domains[e].domains:[];else{let e,s=t.moleculeInfor;for(let t in s)if(s[t].chain===h){e=t,n=s[t].name;break}void 0!==e&&void 0!==t.domains[e]&&(i=t.domains[e].domains),void 0===i&&(i=[])}for(let t=0,s=i.length;t17?s.substr(0,17)+"...":s,h=i[t].intervals,p={},m={},u=[],g=[],f={},b=0;for(let e=0,t=h.length;e'+c+" ",y=''+b.toString()+" Res";d+=C+y+"
    ";let v='';o+=C+y+v,a+=C+y+v;let w="domain3d"+t.toString();for(let t=0,s=l.giSeq[e].length;t1&&(n=i[0]+"..");let r=s;o+=''+i+""}else o+="-"}let _=l.firstAtomObjCls.getFirstCalphaAtomObj(l.chains[e]),S=void 0===_.color||"FFFFFF"===_.color.getHexString()?"DDDDDD":_.color.getHexString(),A=void 0!==_.color?S:"CCCCCC";if(r.cfg.blast_rep_id!=e)for(let i=0,n=u.length;i ',a+='"}else{let i=[],n=[];for(let e=0,t=u.length;e ',a+='"}}v=' '+b.toString()+" Residues",v+="",v+="
    ",o+=v,a+=v}o+="",a+="",d+="",$("#"+l.pre+"dt_domain_"+e).html(o),$("#"+l.pre+"ov_domain_"+e).html(a),$("#"+l.pre+"tt_domain_"+e).html(d)}}class At{constructor(e){this.icn3d=e}async showSnp(e,t){this.icn3d.icn3dui,await this.showSnpClinvar(e,t,!0)}async showClinvar(e,t){this.icn3d.icn3dui,await this.showSnpClinvar(e,t,!1)}async showSnpClinvar(e,t,s){let i=this.icn3d.icn3dui,n=this,l=i.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainid="+t;try{let r=await i.getAjaxPromise(l,"jsonp"),o=r.snpgi,a=r.gi;if(s)await n.showSnpPart2(e,t,o);else{let s=o;[6137708,1942289,224510717,2624886,253723219,2554905,75765331,3660278,312207882,319443632,342350956,1827805,109157826,1065265,40889086,6730307,163931185,494469,163931091,60594093,55669745,18655489,17942684,6980537,166235465,6435586,4139398,4389047,364506122,78101667,262118402,20664221,2624640,158430173,494395,28948777,34810587,13399647,3660342,261278854,342350965,384482350,378792570,15988303,213424334,4558333,2098365,10835631,3318817,374074330,332639529,122919696,4389286,319443573,2781341,67464020,194709238,210061039,364506106,28949044,40889076,161172338,17943181,4557976,62738484,365813173,6137343,350610552,17942703,576308,223674070,15826518,1310997,93279697,4139395,255311799,157837067,361132363,357380836,146387678,383280379,1127268,299856826,13786789,1311054,46015217,3402130,381353319,30750059,218766885,340707375,27065817,355333104,2624634,62738384,241913553,304446010].includes(a)&&(s=a),await n.showClinvarPart2(e,t,s)}}catch(t){return void(s?n.processNoSnp(e):n.processNoClinvar(e))}}navClinVar(e){let t=this.icn3d;t.icn3dui;let s=this;t.currClin[e]=-1,$(document).on("click","#"+t.pre+e+"_prevclin",(function(t){let i=s.icn3d;t.stopImmediatePropagation();let n=void 0!==i.resi2disease_nonempty[e]?Object.keys(i.resi2disease_nonempty[e]).length:0;--i.currClin[e],i.currClin[e]<0&&(i.currClin[e]=n-1),s.showClinVarLabelOn3D(e)})),$(document).on("click","#"+t.pre+e+"_nextclin",(function(t){let i=s.icn3d;t.stopImmediatePropagation();let n=void 0!==i.resi2disease_nonempty[e]?Object.keys(i.resi2disease_nonempty[e]).length:0;++i.currClin[e],i.currClin[e]>n-1&&(i.currClin[e]=0),s.showClinVarLabelOn3D(e)}))}showClinVarLabelOn3D(e){let t,s,i=this.icn3d,n=i.icn3dui,l=Object.keys(i.resi2disease_nonempty[e]);t=e,s=t+"_"+(parseInt(l[i.currClin[e]])+i.baseResi[e]).toString();let r="",o=i.resi2disease_nonempty[e][l[i.currClin[e]]];for(let e=0,t=o.length;e0?o[0]:"N/A");let a=i.applyCenterCls.centerAtoms(n.hashUtilsCls.hash2Atoms(i.residues[s],i.atoms));r.length>30&&(r=r.substr(0,30)+"..."),i.selectionCls.removeSelection(),null==i.labels&&(i.labels={}),i.labels.clinvar=[];let d=i.LABELSIZE,c="black"!=i.opts.background?i.colorWhitebkgd:i.colorBlackbkgd;i.analysisCls.addLabel(r,a.center.x+1,a.center.y+1,a.center.z+1,d,c,void 0,"clinvar"),i.hAtoms={};for(let e in i.residues[s])i.hAtoms[e]=1;$("#clinvar_"+i.pre+s).addClass("icn3d-highlightSeq"),void 0===$("#"+i.pre+"modeswitch")[0]||$("#"+i.pre+"modeswitch")[0].checked||i.definedSetsCls.setMode("selection"),i.drawCls.draw()}getSnpLine(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g){let f=this.icn3d,b=f.icn3dui,C="",y=m?"clinvar":"snp",v=!1;for(let e in i){for(let t=0,s=i[e].length;t(from human)",i=" (based on human sequences and mapped to this structure by sequence similarity)"),C+=m?'":'"}else if(2==e&&m){let e=b.utilsCls.isMobile()?"none":"button";C+='
    ',C+='
    '}else C+='
    ';let w=y,_=0,S=0,A={},x={};for(let t=1,i=f.giSeq[h].length;t<=i;++t)if(void 0!==r[t]){++_;let i="";for(let n=0,r=s[t].length;n'+k+" Res":'',u)return C+"
    ";C+='';let O="",R=0,E=0;for(let t=1,a=f.giSeq[h].length;t<=a;++t)if(p){if(void 0!==r[t]){let e=f.giSeq[h][t-1],i=e;e.length>1&&(i=e[0]+"..");let n=f.ParserUtilsCls.getResi(h,t-1)+i+">";for(let e=0,i=s[t].length;e=0&&(C+='
     
    ',C+='
     
    ',R+=r,E+=1):r>0&&(C+='
     
    ',C+='
     
    ',R+=r,E+=1)}}else if(C+=f.showSeqCls.insertGap(h,t-1,"-"),void 0!==r[t])if(m||1!=e){let r=f.giSeq[h][t-1],a=r;r.length>1&&(a=r[0]+"..");let d,c=f.ParserUtilsCls.getResi(h,t-1),p="",u="
    ",y=s[t].length,v=0,_=0;if(2==e&&(v=0,_=y),m){d=1;let r=0;for(let e=v;e0?_+="; ":0!==e&&1!==e||(O='disease="'+v[t]+'"'),_+=v[t]+"("+w[t]+")",++S;""!=_&&(r"+s[t][e],u+=": "+_,C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(m,"snpin3d","3D with scap","SNP in 3D with scap",70,g)+"  ",u+=f.showAnnoCls.addSnpButton(m,"snpinter","Interactions","SNP Interactions in 3D",70,g)+"  ",u+=f.showAnnoCls.addSnpButton(m,"snppdb","PDB","Download SNP PDB",35,g)),u+="
    Links: ClinVar, dbSNP(rs"+i[t][e]+")",e
    "),++r)}r>d&&2==e&&(p+="..")}else{d=1;for(let e=v;e"+s[t][e],g)C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),0!=i[t][e]&&(u+="
    Link: dbSNP(rs"+i[t][e]+")"),e
    ");else{let s=l[t][e].split("; "),a=o[t][e].split("; "),d="",c=0;for(let t=0,i=s.length;t0?d+="; ":0!==e&&1!==e||(O='disease="'+s[t]+'"'),d+=s[t]+"("+a[t]+")",++c;""!=d?(u+=": "+d,C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),u+="
    Links: ClinVar, dbSNP(rs"+i[t][e]+")"):(C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),u+="
    Link: dbSNP(rs"+i[t][e]+")"),e
    ")}}y>d&&2==e&&(p+="..")}u+="
    ",m?"icn3d-clinvar"==A[t]||"icn3d-clinvar-path"==A[t]?C+=1==e?"":""==p||" "==p?"-":''+p+"":C+="-":C+=""==p||" "==p?"-":g?''+p+"":''+p+""}else C+="";else C+="-";return C+=1==e?' '+k+" Residues":'',C+="
    ",C+="
    ",C}processSnpClinvar(e,t,s,i,n){let l=this.icn3d,r=l.icn3dui,o='
    ',a=o,d=o,c='
    ',h=c,p=c,m=!i||n?e.data:e.split("\n"),u={},g={},f={};void 0===l.resi2disease_nonempty[t]&&(l.resi2disease_nonempty[t]={});let b={},C={},y={},v={},w={},_="";r.bNode&&(i?(l.resid2snp||(l.resid2snp={}),l.resid2snp[t]||(l.resid2snp[t]=[])):(l.resid2clinvar||(l.resid2clinvar={}),l.resid2clinvar[t]||(l.resid2clinvar[t]=[])));for(let e=0,s=m.length;e")+1),h=s[4],p=i?"":s[5],S=i?"":s[6],A=i?"":s[7],x=l.ParserUtilsCls.getResi(t,d-1);v[x]=1,""!=S&&(w[x]=1),g[d]=e+1,void 0===u[d]&&(u[d]=[]),u[d].push(c),void 0===C[d]&&(C[d]=[]),C[d].push(h),void 0===y[d]&&(y[d]=[]),y[d].push(p),void 0===f[d]&&(f[d]=[]),f[d].push(S),""!=S&&(void 0===l.resi2disease_nonempty[t][d]&&(l.resi2disease_nonempty[t][d]=[]),l.resi2disease_nonempty[t][d].push(S)),void 0===b[d]&&(b[d]=[]),b[d].push(A)}let S=Object.keys(v),A=Object.keys(w);if(i){let e=!1;o+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,void 0,i),o+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,void 0,i),d+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,!0,i),d+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,!0,i),a+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!0,e,void 0,i),o+="
    ",a+="
    ",d+="",$("#"+l.pre+"dt_snp_"+t).html(o),$("#"+l.pre+"ov_snp_"+t).html(a),$("#"+l.pre+"tt_snp_"+t).html(d)}else{let e=!0;c+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,void 0,i),c+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,void 0,i),p+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,!0,i),p+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,!0,i),h+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!0,e,void 0,i),c+="",h+="",p+="",$("#"+l.pre+"dt_clinvar_"+t).html(c),$("#"+l.pre+"ov_clinvar_"+t).html(h),$("#"+l.pre+"tt_clinvar_"+t).html(p),this.navClinVar(t,s)}l.showAnnoCls.enableHlSeq(),i?l.bAjaxSnp=!0:l.bAjaxClinvar=!0}async showClinvarPart2(e,t,s){let i=this.icn3d,n=i.icn3dui,l=this,r=n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainid_clinvar="+t;i.chainsGene[e]&&i.chainsGene[e].geneSymbol&&(r+="&gene="+i.chainsGene[e].geneSymbol);try{let s=await n.getAjaxPromise(r,"jsonp");if(s&&s.data&&s.data.length>0){let i=!1,n=s;l.processSnpClinvar(n,e,t,i)}else l.processNoClinvar(e)}catch(t){return void l.processNoClinvar(e)}}async showSnpPart2(e,t,s){let i=this.icn3d,n=i.icn3dui,l=this;if(void 0!==s){let s=n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainid_snp="+t;i.chainsGene[e]&&i.chainsGene[e].geneSymbol&&(s+="&gene="+i.chainsGene[e].geneSymbol);try{let i=await n.getAjaxPromise(s,"jsonp");if(i&&i.data&&i.data.length>0){let s=!0,n=!0;l.processSnpClinvar(i,e,t,s,n)}else l.processNoSnp(e)}catch(t){return void l.processNoSnp(e)}}else this.processNoSnp(e),console.log("No gi was found for the chain "+t+"...")}processNoClinvar(e){let t=this.icn3d;t.icn3dui,console.log("No ClinVar data were found for the protein "+e+"..."),$("#"+t.pre+"dt_clinvar_"+e).html(""),$("#"+t.pre+"ov_clinvar_"+e).html(""),t.showAnnoCls.enableHlSeq(),t.bAjaxClinvar=!0}processNoSnp(e){let t=this.icn3d;t.icn3dui,console.log("No SNP data were found for the protein "+e+"..."),$("#"+t.pre+"dt_snp_"+e).html(""),$("#"+t.pre+"ov_snp_"+e).html(""),t.showAnnoCls.enableHlSeq(),t.bAjaxSnp=!0}}class xt{constructor(e){this.icn3d=e}showSsbond(e,t){let s=this.icn3d;s.icn3dui;let i=this;void 0===s.ssbondpnts?setTimeout((function(){i.showSsbond_base(e,t)}),1e3):this.showSsbond_base(e,t)}showSsbond_base(e,t){let s=this.icn3d;s.icn3dui.bNode&&(s.resid2ssbond||(s.resid2ssbond={}),s.resid2ssbond[e]||(s.resid2ssbond[e]=[]));let i=t,n={},l=i.substr(0,i.indexOf("_")),r=s.ssbondpnts[l];if(void 0===r)return $("#"+s.pre+"dt_ssbond_"+e).html(""),$("#"+s.pre+"ov_ssbond_"+e).html(""),void $("#"+s.pre+"tt_ssbond_"+e).html("");for(let e=0,t=r.length;e-s.halfBilayerSize){i[t.structure+"_"+t.chain+"_"+t.resi]=1}}let n=Object.keys(i);s.annoCddSiteCls.showAnnoType(e,t,"transmem","Transmembrane",n)}}class Ot{constructor(e){this.icn3d=e,this.dcut=7,this.MAX_SSE=512,this.ctc_cnt=[];for(let e=0;e=this.curr_ratio+.01||f>this.split_ratio)return e;if(f>this.curr_ratio-.01&&Math.min(m,u)=0&&l[i]==t-e+i;i--);if(i<0)break;for(l[i]++,s=i+1;s-1;i++);for(l=Math.min(i-1,this.max_csz),this.curr_ne0=this.curr_ne1=0,this.curr_ratio=100,s=1;s<=l;s++)this.cut_size(s,i);if(this.top--,0==this.curr_ne0){for(n=this.stack[this.top],e=n;e-1;e++)this.parts[this.np++]=this.elements[e];this.parts[this.np++]=-1,this.n_doms++}else{if(this.save_ratios[this.saved++]=this.curr_ratio,this.curr_ne0>this.min_sse){for(n=this.stack[this.top],e=0;ethis.min_sse){for(n=this.stack[this.top],e=0;e0;)this.process_set()}output(e){let t,s;this.icn3d.icn3dui;let i=[];for(t=0;t<2*e;t++)i.push(0);for(t=s=0;st+n)break;let p=(t-a)*(t-a);p+=(s-c)*(s-c),p+=(i-h)*(i-h);let m=Math.sqrt(p);if(m>n)continue;let u={},g={};parseInt(e.rnum)this.MAX_SSE)return{subdomains:a,substruct:o};let g=h.length,f=r[g-1],b=this.c2b_AlphaContacts(g,i,n,l,t,r),C=[];for(let e=0;e0&&this.elt_size[s.sse-1]>=6&&0!=s.adj_strand2&&e++}for(let e=0;e0)for(let e=0;e0){let e=0;for(let t=0;t<=E;t++){let t=[];for(;e<2*u;){let s=this.parts[e++];if(0==s){I.push(t);break}t.push(s)}}}I.sort((function(e,t){return e[0]-t[0]}));for(let e=0,t=I.length;e=o.length)return{subdomains:a,substruct:o};let n=o[i],l=n.From,r=n.To;for(let e=l;e<=r;e++)s[e]=1;if(0==i&&l>1)for(let e=1;e0){let e=o[i-1].To,t=parseInt(.5*(l-e-1));if(t>0)for(let e=l-t;e<=l-1;e++)s[e]=1}if(i0)for(let e=r+1;e<=r+t;e++)s[e]=1}}let i,n=!1,l=[];for(let e=0;e0&&(d+=", "),d+='{"ss": [';let i=0;for(let s=0,r=n[e].length;s=r&&c<=o&&(i>0&&(d+=", "),d+="["+s+","+n+","+c+","+l[e].x1.toFixed(2)+","+l[e].y1.toFixed(2)+","+l[e].z1.toFixed(2)+","+l[e].x2.toFixed(2)+","+l[e].y2.toFixed(2)+","+l[e].z2.toFixed(2)+"]",++i))}}d+="]",d+=', "domain": [';let r=0;for(let i=0,l=n[e].length;i=l&&n<=a&&(r>0&&(d+=", "),d+="["+n+","+h+","+c.coord.x.toFixed(2)+","+c.coord.y.toFixed(2)+","+c.coord.z.toFixed(2)+"]",++r)}}d+="]}"}return d+="]}",d}}class Rt{constructor(e){this.icn3d=e}clickAddTrackButton(){let e=this.icn3d,t=e.icn3dui,s=this;t.myEventCls.onIds("#"+e.pre+"addtrack_button1","click",(async function(e){let i=s.icn3d;e.stopImmediatePropagation(),dialog.dialog("close");let n=$("#"+i.pre+"track_chainid").val(),l=$("#"+i.pre+"track_gi").val(),r=isNaN(l)?"Acc "+l:"gi "+l,o=t.htmlCls.baseUrl+"pwaln/pwaln.fcgi?from=track",a={targets:n,queries:l},d=await t.getAjaxPostPromise(o,a);s.alignSequenceToStructure(n,d,r)})),t.myEventCls.onIds("#"+e.pre+"addtrack_button2","click",(async function(e){let i=s.icn3d;e.stopImmediatePropagation(),dialog.dialog("close");let n=$("#"+i.pre+"track_chainid").val(),l=$("#"+i.pre+"track_fasta").val(),r=$("#"+i.pre+"fasta_title").val(),o=n.substr(0,n.indexOf("_")),a=n;if(5==o.length)a=a.substr(0,4);else if(o.length>5){a="";for(let e=0,t=i.chainsSeq[n].length;e"),a=o[1].indexOf("\n");o[1].substr(0,a);let d,c=o[1].substr(a+1).replace(/\n/g,""),h=[],p=[];for(let e=2,t=o.length;e0&&(u=f,i.targetGapHash[m+d]={from:m+d,to:u+C-1+d}),g=c[e],f=b,"-"!=c[e]?(++b,w=e,y||(v=e,y=!0)):++C;await i.annotationCls.resetAnnoAll();let _="",S=0;for(let e in i.targetGapHash)S>0&&(_+=" "),_+=e+"_"+i.targetGapHash[e].from+"_"+i.targetGapHash[e].to,++S;t.htmlCls.clickMenuCls.setLogCmd("msa | "+_,!0);let A={};for(let e=0,o=p.length;e0){void 0===i.queryresi2score&&(i.queryresi2score={}),void 0===i.queryresi2score[n]&&(i.queryresi2score[n]={});let e=p.length;for(let t in A){let s=parseInt(A[t]/e*100);i.queryresi2score[n][t]=s}let s=Object.keys(A),l=Math.min.apply(null,s),r=Math.max.apply(null,s),o="";for(let t=l;t<=r;++t)A.hasOwnProperty(t)?o+=Math.round(A[t]/e*9):o+="_";i.opts.color="align custom",i.setColorCls.setColorByOptions(i.opts,i.hAtoms),i.hlUpdateCls.updateHlAll(),i.drawCls.draw(),t.htmlCls.clickMenuCls.setLogCmd("color align custom | "+n+" | range "+l+"_"+r+" | "+o,!0)}})),t.myEventCls.onIds("#"+e.pre+"addtrack_button3","click",(function(e){let i=s.icn3d;e.stopImmediatePropagation(),dialog.dialog("close");let n=$("#"+i.pre+"track_chainid").val(),l=$("#"+i.pre+"track_bed")[0].files[0];if(l){window.File&&window.FileReader&&window.FileList&&window.Blob||alert("The File APIs are not fully supported in this browser.");let e=new FileReader;e.onload=function(e){let l,r=e.target.result.split("\n"),o=!1,a=!1;for(let e=0,d=r.length;e8||d.length<6)&&(a=!1),d.length<9&&(o=!1),d[0];let c,h,p=d[1],m=d[2],u=d[3];d.length,d.length>5&&(c=d[5]),d.length,d.length,d.length>8&&(h=d[8]),d.length,d.length,d.length;let g=u,f="51,51,51";o?f=h:a&&("+"==c&&l.length>0?f=l[0]:"-"==c&&l.length>1?f=l[1]:"."==c&&l.length>2&&(f=l[2]));let b="",C=[];for(let e=0,t=m;e1&&(s=t[0]);let l=i.ParserUtilsCls.getResi(n,e);if(a.hasOwnProperty(n+"_"+l)){let e=i.firstAtomObjCls.getFirstCalphaAtomObj(i.residues[n+"_"+l]),t=void 0===e.color||"FFFFFF"===e.color.getHexString().toUpperCase()?"DDDDDD":e.color.getHexString(),o=void 0!==e.color?t:"CCCCCC";r+=s,d.push("#"+o)}else r+="-",d.push("")}s.showNewTrack(n,l,r,d,void 0,"selection",void 0),t.htmlCls.clickMenuCls.setLogCmd("add track | chainid "+n+" | title "+l+" | text "+s.simplifyText(r)+" | type selection",!0)}))}showNewTrack(e,t,s,i,n,l,r,o,a,d){let c=this.icn3d,h=c.icn3dui,p=!1;"cannot be aligned"==s&&(p=!0);let m=s.replace(/-/g,"").length;if(!o)if(s.length>c.giSeq[e].length)s=s.substr(0,c.giSeq[e].length);else if(s.length20&&(u=u.substr(0,20));let g=h.htmlCls.RESIDUE_WIDTH*s.length+200;$("#"+c.pre+"dt_custom_"+e).append("
    "),$("#"+c.pre+"dt_custom_"+e+"_"+u).width(g),$("#"+c.pre+"ov_custom_"+e).append("
    "),$("#"+c.pre+"ov_custom_"+e+"_"+u).width(g),$("#"+c.pre+"tt_custom_"+e).append("
    "),$("#"+c.pre+"tt_custom_"+e+"_"+u).width(g);let f='
    ',b=f,C=f,y=parseInt(10*Math.random()),v='",w=''+m.toString()+" Pos";C+=v+w+"
    ";let _='';f+=v+w+_,b+=v+w+_;let S=e.indexOf("_"),A="cst"+e.substr(S+1),x=0,k=0,O=(void 0===l||"seq"===l||"custom"===l)&&-1==s.indexOf("cannot-be-aligned")&&-1==s.indexOf("cannot be aligned"),R="identity"===l&&-1==s.indexOf("cannot-be-aligned")&&-1==s.indexOf("cannot be aligned"),E={},I=0,T=1;v="";for(let t=0,a=s.length;t"+d+"",v+=c.showSeqCls.insertGapOverview(e,t);let g=h.cfg.blast_rep_id==e?Math.round(c.seqAnnWidth*t/(c.maxAnnoLength+c.nTotalGap)-x-k):Math.round(c.seqAnnWidth*t/c.maxAnnoLength-x-k);g<0&&(g=0),v+='
     
    ',s=void 0!==i&&""!=i[t]?i[t]:r?"rgb("+r+")":O?"#"+p:"#333",v+='
     
    ',x+=g,k+=1,++T}else f+=p?""+d+"":"-"}if(void 0!==a){v="";let s=[],i=[];for(let e=0,t=a.length;e 
    ',v+='"}}_=''+m.toString()+" Pos",_+="",_+="
    ",_+="",f+=_,b+=v+_,C+="",$("#"+c.pre+"dt_custom_"+e+"_"+u).html(f),$("#"+c.pre+"ov_custom_"+e+"_"+u).html(b),$("#"+c.pre+"tt_custom_"+e+"_"+u).html(C)}alignSequenceToStructure(e,t,s){let i,n,l,r=this.icn3d,o=r.icn3dui;void 0!==t.data&&(i=t.data[0].query,l=Object.keys(t.data[0].targets)[0],n=t.data[0].targets[l],n=n.hsps[0]);let a="",d=[],c={};if(void 0!==i&&void 0!==n){let h=n.scores.e_value.toPrecision(2);h>1e-200&&(h=parseFloat(h).toExponential()),n.scores.bit_score;let p=t.targets[l].seqdata,m=i.seqdata,u=n.segs;for(let e=0,t=u.length;e0&&(l=n+"H"+d+")","coil"==t&&(s.selectionCls.selectResidueList(r,l,l,o,a),o||(o=!0)),r={})),n=e+"_H"+d,r[p]=1,i.ssend&&(h=e+"_C(H"+d,"helix"==t&&(s.selectionCls.selectResidueList(r,n,n,o,a),o||(o=!0)),r={})):"E"==m?(i.ssbegin&&(++c,Object.keys(r).length>0&&(l=n+"S"+c+")","coil"==t&&(s.selectionCls.selectResidueList(r,l,l,o,a),o||(o=!0)),r={})),n=e+"_S"+c,r[p]=1,i.ssend&&(h=e+"_C(S"+c,"sheet"==t&&(s.selectionCls.selectResidueList(r,n,n,o,a),o||(o=!0)),r={})):(n=h+"-",r[p]=1)}}Object.keys(r).length>0&&(l=n+"Cterm)","coil"==t&&s.selectionCls.selectResidueList(r,l,l,o,a))}simplifyText(e){this.icn3d.icn3dui;let t,s,i="",n=!1,l=-1;for(t=0,s=(e=e.replace(/undefined/g," ")).length;t20)return!1;if(void 0!==o.giSeq&&void 0!==o.giSeq[e]){let r=this.getFullText(s);return s=r.text,this.showNewTrack(e,t,s,void 0,void 0,i,n,l),!1}setTimeout((function(){a.checkGiSeq(e,t,s,i,n,l,r+1)}),100)}getFullText(e){this.icn3d.icn3dui;let t="",s=[],i=[],n=e.split(","),l=-1;for(let e=0,r=n.length;ep?t+=c.substr(0,p):t+=c;for(let e=0;e0&&($("#"+e.pre+"anno_cdd")[0].checked?(this.setAnnoTabCdd(),t.htmlCls.clickMenuCls.setLogCmd("set annotation cdd",!0)):(this.hideAnnoTabCdd(),t.htmlCls.clickMenuCls.setLogCmd("hide annotation cdd",!0)))}showAnnoSelectedChains(){let e=this.icn3d,t=e.icn3dui,s={};for(let t in e.hAtoms){let i=e.atoms[t];s[i.structure+"_"+i.chain]=1}$("#"+e.pre+"dl_annotations > .icn3d-annotation").hide();for(let i in s){$("#"+e.pre+"anno_"+i).length&&$("#"+e.pre+"anno_"+i).show();let s=e.firstAtomObjCls.getFirstCalphaAtomObj(e.chains[i]);if(void 0!==s.resn){let i=t.utilsCls.residueName2Abbr(s.resn.substr(0,3));$("#"+e.pre+"anno_"+i).show()}}}showAnnoAllChains(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"dl_annotations > .icn3d-annotation").show()}setAnnoView(e){let t=this.icn3d;t.icn3dui.bNode||("detailed view"===e?(t.view="detailed view",$("#"+t.pre+"dl_anno_view_tabs").tabs("option","active",1)):(t.view="overview",$("#"+t.pre+"dl_anno_view_tabs").tabs("option","active",0)))}setAnnoDisplay(e,t){let s=this.icn3d;s.icn3dui;let i=["giseq","custom","site","ptm","snp","clinvar","cdd","domain","interaction","ssbond","crosslink","transmem"];for(let n in i){let l=i[n];$("[id^="+s.pre+t+"_"+l+"]").attr("style",e)}}showFixedTitle(){this.icn3d.icn3dui;this.setAnnoDisplay("display:block;","tt")}hideFixedTitle(){this.icn3d.icn3dui;this.setAnnoDisplay("display:none!important;","tt")}setAnnoViewAndDisplay(e){let t=this.icn3d;if(t.icn3dui,"detailed view"===e){this.setAnnoView("detailed view");let e="display:block;";this.setAnnoDisplay(e,"dt"),$("#"+t.pre+"seqguide_wrapper").attr("style",e),e="display:none;",this.setAnnoDisplay(e,"ov")}else{this.setAnnoView("overview"),this.hideFixedTitle();let e="display:none;";this.setAnnoDisplay(e,"dt"),$("#"+t.pre+"seqguide_wrapper").attr("style",e),e="display:block;",this.setAnnoDisplay(e,"ov")}}async updateClinvar(){let e=this.icn3d;if(e.icn3dui,void 0===e.bClinvarShown||!e.bClinvarShown)for(let t in e.protein_chainid){let s=e.protein_chainid[t];await e.annoSnpClinVarCls.showClinvar(t,s)}e.bClinvarShown=!0}async updateSnp(){let e=this.icn3d;if(e.icn3dui,void 0===e.bSnpShown||!e.bSnpShown)for(let t in e.protein_chainid){let s=e.protein_chainid[t];await e.annoSnpClinVarCls.showSnp(t,s)}e.bSnpShown=!0}updateDomain(){let e=this.icn3d;e.icn3dui,void 0!==e.bDomainShown&&e.bDomainShown||e.annoDomainCls.showDomainAll(),e.bDomainShown=!0}updateInteraction(){let e=this.icn3d;if(e.icn3dui,void 0===e.bInteractionShown||!e.bInteractionShown)for(let t in e.interactChainbase){let s=e.interactChainbase[t];e.annoContactCls.showInteraction(t,s)}e.bInteractionShown=!0}async updatePTM(){let e=this.icn3d;if(e.icn3dui,void 0===e.bPTMShown||!e.bPTMShown)for(let t in e.PTMChainbase){let s=e.PTMChainbase[t];await e.annoPTMCls.showPTM(t,s,"ptm")}e.bPTMShown=!0}updateSsbond(){let e=this.icn3d;if(e.icn3dui,void 0===e.bSSbondShown||!e.bSSbondShown)for(let t in e.ssbondChainbase){let s=e.ssbondChainbase[t];e.annoSsbondCls.showSsbond(t,s)}e.bSSbondShown=!0}updateCrosslink(){let e=this.icn3d;if(e.icn3dui,void 0===e.bCrosslinkShown||!e.bCrosslinkShown)for(let t in e.crosslinkChainbase){let s=e.crosslinkChainbase[t];e.annoCrossLinkCls.showCrosslink(t,s)}e.bCrosslinkShown=!0}async updateTransmem(){let e=this.icn3d,t=e.icn3dui;if(void 0===e.bTranememShown||!e.bTranememShown)for(let s in e.protein_chainid){let i=e.protein_chainid[s];if(void 0!==t.cfg.opmid)e.annoTransMemCls.showTransmem(s,i);else if(e.bAfMem&&e.afmem_start_end){let t=e.afmem_start_end[0],n=e.afmem_start_end[1];await e.annoPTMCls.showPTM(s,i,"afmem",t,n)}else await e.annoPTMCls.showPTM(s,i,"transmem")}e.bTranememShown=!0}}class It{constructor(e){this.icn3d=e}showAnnotations_part1(){let e=this.icn3d,t=e.icn3dui;if(t.htmlCls.dialogCls.openDlg("dl_selectannotations","Sequences and Annotations"),(void 0===e.bAssemblyNote||!e.bAssemblyNote)&&void 0!==e.asuCnt){let t="
    Assembly Tips: Only the asymmetric unit is shown in the sequence window.
    Click \"Assembly\" in the menu \"View\" to switch between asymmetric unit and biological assembly("+e.asuCnt+" asymmetric unit).
    ";$("#"+e.pre+"dl_annotations_tabs").append(t),e.bAssemblyNote=!0}e.bResetAnno&&(e.giSeq={},e.currClin={},e.resi2disease_nonempty={},e.baseResi={},e.matchedPos={},$("#"+t.pre+"dl_annotations").empty(),e.annotationCls.setAnnoView("overview"));let s={},i={},n={};if(void 0===e.bAnnoShown||!e.bAnnoShown||e.bResetAnno){e.protein_chainid={};let l,r=Object.keys(e.chains);void 0===e.giSeq&&(e.giSeq={}),void 0===e.currClin&&(e.currClin={}),void 0===e.resi2disease_nonempty&&(e.resi2disease_nonempty={}),void 0===e.baseResi&&(e.baseResi={}),void 0===e.matchedPos&&(e.matchedPos={}),l=t.bNode?500:t.cfg.notebook?t.htmlCls.WIDTH/2:$("#"+e.pre+"dl_selectannotations").dialog("option","width"),e.seqAnnWidth=l-120-60-50;for(let l=0,o=r.length;l1)e.protein_chainid[r[l]]=a;else if(e.nucleotides.hasOwnProperty(o.serial)&&e.chainsSeq[r[l]].length>1)s[r[l]]=a;else if(e.chainsSeq[r[l]].length>1)i[r[l]]=a;else{let t=e.chainsSeq[r[l]][0].name,s=r[l]+"_"+e.chainsSeq[r[l]][0].resi;void 0===n[t]&&(n[t]=[]),n[t].push(s)}if((void 0!==t.cfg.pdbid||void 0!==t.cfg.opmid||void 0!==t.cfg.mmcifid||void 0!==t.cfg.mmtfid)&&(e.proteins.hasOwnProperty(o.serial)||e.nucleotides.hasOwnProperty(o.serial)))for(let t=0,s=e.chainsSeq[r[l]].length;te.maxAnnoLength&&(e.protein_chainid.hasOwnProperty(t)||s.hasOwnProperty(t))&&(e.maxAnnoLength=e.chainsSeq[t].length)}return{nucleotide_chainid:s,chemical_chainid:i,chemical_set:n}}async showAnnotations(){let e=this.icn3d,t=e.icn3dui,s=this,i=this.showAnnotations_part1(),n=i.nucleotide_chainid,l=i.chemical_chainid,r=i.chemical_set;if(void 0===e.bAnnoShown||!e.bAnnoShown||e.bResetAnno)if(void 0===t.cfg.blast_rep_id){if(e.bFullUi){if(void 0!==t.cfg.mmtfid){let t=Object.keys(e.structures)[0];await e.mmcifParserCls.downloadMmcifSymmetry(t,"mmtfid")}await this.showAnnoSeqData(n,l,r)}}else if(void 0===t.cfg.blast_rep_id||e.bSmithwm||e.bLocalSmithwm){if(void 0!==t.cfg.blast_rep_id&&(e.bSmithwm||e.bLocalSmithwm)){let i,o,a=[t.cfg.blast_rep_id];if(-1!=t.cfg.query_id.indexOf(">")?o=t.cfg.query_id.substr(t.cfg.query_id.indexOf("\n")+1):!/\d/.test(t.cfg.query_id)||t.cfg.query_id.length>50?o=t.cfg.query_id:a.push(t.cfg.query_id),e.blastAcxn){let s=t.cfg.afid+"_A",n="";for(let t=0,i=e.chainsSeq[s].length;tProteins:

    ":"",a=e.chainsGene[s]&&e.chainsGene[s].geneId?"(Gene: "+e.chainsGene[s].geneSymbol+")":"",d=s.substr(0,s.indexOf("_")),c=d.length>5?''+s+"":s,h="
    "+o+"Annotations of "+c+": "+r+""+a+"   "+this.addButton(s,"icn3d-addtrack","Add Track","Add a custom track",60,i)+"   ";h+=this.addButton(s,"icn3d-customcolor","Custom Color/Tube","Use a custom file to define the colors or tubes in 3D structure",110,i)+"   ",h+=this.addButton(s,"icn3d-helixsets","Helix Sets",'Define sets for each helix in this chain and add them to the menu of "Defined Sets"',60,i)+" "+this.addButton(s,"icn3d-sheetsets","Sheet Sets",'Define sets for each sheet in this chain and add them to the menu of "Defined Sets"',60,i)+" "+this.addButton(s,"icn3d-coilsets","Coil Sets",'Define sets for each coil in this chain and add them to the menu of "Defined Sets"',60,i),$("#"+e.pre+"dl_annotations").append(h);let p=["giseq","cdd","clinvar","snp","site","ptm","ssbond","crosslink","transmem","domain","custom","interaction"];for(let t in p){let i=p[t];$("#"+e.pre+"anno_"+s).append(this.getAnDiv(s,i))}$("#"+e.pre+"anno_"+s).append("


    "),++n}if(t.bNode||e.annoCddSiteCls.setToolTip(),void 0!==e.chainid_seq)await this.processSeqData(e.chainid_seq);else try{let n=[],l=[];for(let e=0,t=i.length;e=6?l.push(i[e]):n.push(i[e]);if(n.length>0){let s=t.htmlCls.baseUrl+"/vastdyn/vastdyn.cgi?chainlist="+n;e.chainid_seq=await t.getAjaxPromise(s,"jsonp")}else e.chainid_seq={};for(let t=0,s=l.length;t40&&(r=r.substr(0,40)+"...");let o="";0==i&&("protein"==s?o="Proteins:

    ":"nucleotide"==s?o="Nucleotides:

    ":"chemical"==s&&(o="Chemicals/Ions/Water:

    ")),$("#"+n.pre+"dl_annotations").append("
    "+o+""+e+": "+r+"
    "),$("#"+n.pre+"anno_"+e).append(this.getAnDiv(e,"giseq")),$("#"+n.pre+"anno_"+e).append(this.getAnDiv(e,"interaction")),$("#"+n.pre+"anno_"+e).append("


    "),n.giSeq[e]=[];for(let t=0;tChemicals/Ions/Water:

    ":"",o=t[0].lastIndexOf("_"),a=t[0].substr(0,o),d=void 0!==l.cfg.mmdbid&&void 0!==n.chainid2sid?n.chainid2sid[a]:void 0;i=void 0!==d?""+e+" ":""+e+"",$("#"+n.pre+"dl_annotations").append("
    "+r+i+"
    "),$("#"+n.pre+"anno_"+e).append("
    "),$("#"+n.pre+"anno_"+e).append("


    ");let c='
    ';c+='",c+='Count: '+t.length+"",c+='';let h=c,p=c;for(let s=0,i=t.length;s3&&(l=i.substr(0,3)),s'+l+""}let m=l.htmlCls.GREY8,u=Math.round(n.seqAnnWidth*t.length/n.maxAnnoLength);u<1&&(u=1),p+='
     
    ',c="",c+="
    ",c+="
    ",h+=c,p+=c,$("#"+n.pre+"dt_giseq_"+e).html(h),$("#"+n.pre+"ov_giseq_"+e).html(p)}async processSeqData(e){let t=this.icn3d,s=t.icn3dui;for(let i in t.protein_chainid){let n=t.protein_chainid[i];if(e.hasOwnProperty(n)){let s=e[n];t.giSeq[i]=s;let l="";for(let e=0;e<10&&e14?"Query: "+o.substr(0,6)+"...":isNaN(s.cfg.query_id)?"Query: "+o:"Query: gi "+o;let a="cannot be aligned";t.queryStart="",t.queryEnd="",t.bRender&&alert("The sequence can NOT be aligned to the structure"),t.showSeqCls.showSeq(i,n,void 0,e,l,a,r)}else if(s.cfg.blast_rep_id==i&&(void 0!==t.seqStructAlignData||void 0!==t.seqStructAlignDataSmithwm)){let e,l,r,o,a,d=s.cfg.oriQuery_id?s.cfg.oriQuery_id:s.cfg.query_id;if(e=d.length>14?"Query: "+d.substr(0,6)+"...":isNaN(s.cfg.query_id)?"Query: "+d:"Query: gi "+d,void 0!==t.seqStructAlignData){let e,s,i=t.seqStructAlignData;if(void 0!==i.data){e=i.data[0].query;let t=Object.keys(i.data[0].targets);s=i.data[0].targets[t[0]],s=void 0!==s&&s.hsps.length>0?s.hsps[0]:void 0}if(void 0!==e&&void 0!==s){l=s.scores.e_value.toPrecision(2),l>1e-200&&(l=parseFloat(l).toExponential()),s.scores.bit_score;let t=Object.keys(i.targets);r=i.targets[t[0]].seqdata,o=e.seqdata,a=s.segs}}else{let e=t.seqStructAlignDataSmithwm;l=e.score,r=e.target.replace(/-/g,""),o=e.query.replace(/-/g,""),a=[];let s=-1,i=-1,n=!1,d={};for(let t=0,l=e.target.length;t0)if(i.orifrom-ni.from-l)for(let t=n+1;t
    "+i+"
    "}addButton(e,t,s,i,n,l){return this.icn3d.icn3dui,"
    "}addSnpButton(e,t,s,i,n,l){let r=this.icn3d;return r.icn3dui,"
    "}conservativeReplacement(e,t){let s=this.icn3d.icn3dui,i=-1!==s.parasCls.b62ResArray.indexOf(e)?s.parasCls.b62ResArray.indexOf(e):s.parasCls.b62ResArray.length-1,n=-1!==s.parasCls.b62ResArray.indexOf(t)?s.parasCls.b62ResArray.indexOf(t):s.parasCls.b62ResArray.length-1;return s.parasCls.b62Matrix[i][n]>0}getColorhexFromBlosum62(e,t){let s=this.icn3d.icn3dui;e=e.toUpperCase(),t=t.toUpperCase();let i=-1!==s.parasCls.b62ResArray.indexOf(e)?s.parasCls.b62ResArray.indexOf(e):s.parasCls.b62ResArray.length-1,n=-1!==s.parasCls.b62ResArray.indexOf(t)?s.parasCls.b62ResArray.indexOf(t):s.parasCls.b62ResArray.length-1,l=s.parasCls.b62Matrix[i][n];if(void 0===l)return"333333";let r="333333";if(l>0){let e=221-parseInt(l/11*221),t=e<10?"0"+e.toString(16):e.toString(16);r="DD"+t+t}else{let e=221-parseInt(-1*l/4*221),t=e<10?"0"+e.toString(16):e.toString(16);r=t+t+"DD"}return r}}class Tt{constructor(e){this.icn3d=e}showSeq(e,t,s,i,n,l,r){let o,a=this.icn3d,d=a.icn3dui,c=!1;if(void 0===d.cfg.mmdbid&&void 0===d.cfg.gi&&void 0===d.cfg.blast_rep_id&&void 0===d.cfg.align&&void 0===d.cfg.chainalign&&void 0===d.cfg.mmdbafid){c=!0,o=[];for(let t=0;t10){u='
    ';let t=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]);void 0===d.cfg.mmdbid&&void 0===d.cfg.gi&&void 0===d.cfg.blast_rep_id&&void 0===d.cfg.align&&void 0===d.cfg.chainalign&&void 0===d.cfg.mmdbafid||void 0===t.resi_ori||t.resi_ori==t.resi||-1!=e.indexOf("Misc")?u+='
    ':u+='
    NCBI Residue Numbers
    ',u+='',b+=u+"
    ",g+=u+'';let s=0,i=0,n="";for(let t=0,l=o.length;t",l%10==0&&(g+=l);let r=e+"_"+l,o=l%10!=0&&l%10!=1&&l%10!=9;if(a.residues.hasOwnProperty(r)){let e=a.firstAtomObjCls.getFirstCalphaAtomObj(a.residues[r]);"H"==a.secondaries[r]&&e.ssbegin?(++s,n='H'+s+"",o&&(g+=n,n="")):"E"==a.secondaries[r]&&e.ssbegin?(++i,"green"==a.sheetcolor?n='S'+i+"":"yellow"==a.sheetcolor&&(n='S'+i+""),o&&(g+=n,n="")):e.ssend&&(n=""),""!=n&&o&&(g+=n,n="")}g+=""}g+='',g+="",g+="
    ",g+="
    ",b+=""}u='
    ',u+='
    ',u+='',b+=u+"
    ",g+=u+'';for(let t=0,s=o.length;t':'',g+=" ";else if("E"==a.secondaries[s]){a.firstAtomObjCls.getFirstCalphaAtomObj(a.residues[s]).ssend?"green"==a.sheetcolor?g+='':"yellow"==a.sheetcolor&&(g+=''):"green"==a.sheetcolor?g+='':"yellow"==a.sheetcolor&&(g+=''),g+=" "}else"c"==a.secondaries[s]?g+=' ':"o"==a.secondaries[s]&&(g+=' ');else g+="-"}g+='',g+="",g+="
    ",g+="
    ",g+="",b+="",u=d.cfg.blast_rep_id===e?'
    ':'
    ';let C="Protein",y="Protein";void 0!==s&&("nucleotide"==s?(C="Nucl.",y="Nucleotide"):"chemical"==s&&(C="Chem.",y="Chemical")),u+='",u+=''+(a.baseResi[e]+1).toString()+"",b+=u+"
    ";let v='';g+=u+v,f+=u+v;let w,_=0;for(let t=0,s=o.length;t1&&(i=s[0]+".."),w=a.ParserUtilsCls.getResi(e,t),a.residues.hasOwnProperty(e+"_"+w)){let n="333333";if(d.cfg.blast_rep_id==e&&void 0!==a.fullpos2ConsTargetpos&&void 0!==a.fullpos2ConsTargetpos[t+_])n=a.fullpos2ConsTargetpos[t+_].color;else{let t=a.firstAtomObjCls.getFirstCalphaAtomObj(a.residues[e+"_"+w]),s=void 0===t.color||"FFFFFF"===t.color.getHexString()?"DDDDDD":t.color.getHexString();n=void 0!==t.color?s:"CCCCCC"}g+=''+i+""}else i=i.toLowerCase(),g+=''+i+""}d.cfg.blast_rep_id==e&&(a.opts.color=a.blastAcxn?"confidence":"conservation",a.setColorCls.setColorByOptions(a.opts,a.atoms));let S=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]),A=S.color?S.color.getHexString():"CCCCCC",x=Math.round(a.seqAnnWidth*o.length/a.maxAnnoLength);if(x<1&&(x=1),d.cfg.blast_rep_id!=e)f+='";else{let t=[],s=[];t.push(0);for(let e=0,i=o.length;e';for(let i=0,n=t.length;i'+e+"
    ";f+="
    "}if(u=''+w+"",u+="",u+="
    ",g+=u,f+=u,d.cfg.blast_rep_id==e){if(void 0!==r&&""!==r){u='",u+='',b+=u+"
    ";let t='';g+=u+t,f+=u+t;let s=0,i=0,l=1;a.queryStart;for(let t=0,n=r.length;t-";else if(" "==n)g+=" ";else{let r=a.fullpos2ConsTargetpos[t].pos;if(a.residues.hasOwnProperty(e+"_"+r)){let s=a.fullpos2ConsTargetpos[t].color;g+=''+n+""}else n=n.toLowerCase(),g+=''+n+"";f+=this.insertGapOverview(e,t);let o=Math.round(a.seqAnnWidth*t/(a.maxAnnoLength+a.nTotalGap)-s-i);o>=0&&(f+='
     
    ',f+='
     
    ',s+=o,i+=l)}}u='',u+="",u+="
    ",g+=u,f+=u}u='
    '+i+"
    ",u+=''+a.queryStart+"",b+=u+"
    ";let t='';g+=u+t,f+=u+t;let s=a.queryStart;for(let t=0,i=l.length;t-":(void 0===a.fullpos2ConsTargetpos||void 0===a.fullpos2ConsTargetpos[t]||a.residues.hasOwnProperty(e+"_"+a.fullpos2ConsTargetpos[t].pos)||(i=i.toLowerCase()),g+=''+i+"",++s)}let o=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]),d=void 0===o.color||"FFFFFF"===o.color.getHexString()?"DDDDDD":o.color.getHexString(),c=void 0!==o.color?d:"CCCCCC",h=[],p=[],m="-";for(let e=0,t=l.length;e ',f+='
    '+i+"
    "}u=''+a.queryEnd+"",u+="",u+="
    ",g+=u,f+=u}if(g+="",f+="",b+="",a.giSeq[e].length>10){let t=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]);if(void 0===d.cfg.mmdbid&&void 0===d.cfg.gi&&void 0===d.cfg.blast_rep_id&&void 0===d.cfg.align&&void 0===d.cfg.chainalign&&void 0===d.cfg.mmdbafid||void 0===t.resi_ori||t.resi_ori==t.resi||-1!=e.indexOf("Misc")){if(a.bShowRefnum&&a.chainid2index.hasOwnProperty(e)){let t=this.showRefNum(o,e);g+=t.html,b+=t.html3;let s=1;t=this.showRefNum(o,e,s),g+=t.html,b+=t.html3,s=2,t=this.showRefNum(o,e,s),g+=t.html,b+=t.html3}else if(a.bShowCustomRefnum&&a.chainsMapping.hasOwnProperty(e)){let t=!0,s=this.showRefNum(o,e,void 0,t);g+=s.html,b+=s.html3}}else{u='
    ',u+='
    ',u+='
    PDB Residue Numbers
    ',u+='',b+=u+"
    ",g+=u+'';for(let t=0,s=o.length;t",e%10==0&&(g+=e+" "),g+=""}else g+=""}g+='',g+="",g+="
    ",g+="
    ",g+="
    ",b+=""}}a.bShowRefnum&&(a.hAtoms=a.hAtomsRefnum,a.hlUpdateCls.updateHlAll()),$("#"+a.pre+"dt_giseq_"+e).html(g),$("#"+a.pre+"ov_giseq_"+e).html(f),$("#"+a.pre+"tt_giseq_"+e).html(b)}showRefNum(e,t,s,i){let n=this.icn3d;n.icn3dui;let l="",r="",o="";for(let e=0,s=n.chainid2index[t].length;eCustom Ref. No.':1==s?'
    Kabat Ref. No.
    ':2==s?'
    IMGT Ref. No.
    ':'
    IgStRAnD Ref. No.
    ',d+='',r+=d+"
    ",l+=d+'';let c=!1;for(let s=0,l=e.length;s0){c=!0;break}}if(1==s&&!c)return{html:"",html3:""};let h=!1;for(let s=0,l=e.length;s0){h=!0;break}}if(2==s&&!h)return{html:"",html3:""};let p,m,u,g,f,b,C,y,v,w=!1,_="",S="",A="",x=1,k={},O=1,R="",E=!1;for(let l=0,r=e.length;l1e3&&"9"!=u.substr(1,1)&&(x=1,E&&R&&(delete k[R],R="")),S&&" "!=_&&f>1e3&&"9"==u.substr(1,1)&&(1==x&&(k.hasOwnProperty(_+g)&&++O,g=u.replace(f.toString(),"")+"_"+O,k[_+g]={},k[_+g].start=b,k[_+g].chainid=t),u=(1e3*parseInt(A)+900+x).toString(),p=_+u,++x))):!S||" "==_||i||s||(1==x&&(k.hasOwnProperty(_+g)?(++O,g=u.replace(f.toString(),"")+"_"+O,k[_+g]={}):k[_+g]={},k[_+g].start=b,k[_+g].chainid=t,R=_+g,E=!0),u=(1e3*parseInt(A)+900+x).toString(),p=_+u,++x),b=u,y=f,C=g,S=_}k[S+C]&&(k[S+C].len=x-1,k[S+C].end=b),O=1,R="",E=!1;let I,T={},M=!0;for(let r=0,o=e.length;r1e3&&"9"!=u.substr(1,1)&&(x=1,E&&R&&(--O,R="")),S&&f>1e3&&"9"==u.substr(1,1)){w=!0,1==x&&(T.hasOwnProperty(I+g)&&(++O,g=u.replace(f.toString(),"")+"_"+O),T[I+g]=1);let e=this.getAdjustedRefnum(k,I,x,A,g,y);f=e.refnum,M=e.bShowRefnum,u=e.refnumStr,p=e.refnumLabel,v=e.refnumLabelNoPostfix,a=e.bHidelabel,_=p.replace(new RegExp(u,"g"),""),++x}y=f}if(i)if(u){l+=parseInt(u)%2==0?''+u+"":' '}else l+="";else if(1==s||2==s)if(u){let e=parseInt(u).toString(),t='style="color:'+this.getRefnumColor(_)+'"';l+=parseInt(e.substr(e.length-2,2))%2==0?"'+u+"":" '}else l+="";else M&&" "!=_?(l+=this.getRefnumHtml(e,u,m,p,_,w,a),w&&(n.residIgLoop[e]=1)):l+=""}else{let t=n.firstAtomObjCls.getFirstAtomObj(n.residues[e]);if(t&&!n.proteins.hasOwnProperty(t.serial)||!S||i||s||I&&"G"==I.substr(0,1))l+="";else{w=!0,1==x&&(T.hasOwnProperty(I+g)&&++O,g=u.replace(f.toString(),"")+"_"+O,T[I+g]=1,E=!0,R=I+g);let t=this.getAdjustedRefnum(k,I,x,A,g,y);f=t.refnum,M=t.bShowRefnum,u=t.refnumStr,p=t.refnumLabel,v=t.refnumLabelNoPostfix,y=f,a=t.bHidelabel,_=p.replace(new RegExp(u,"g"),""),++x,M&&" "!=_?(l+=this.getRefnumHtml(e,u,m,p,_,w,a),w&&(n.residIgLoop[e]=1)):l+=""}}n.resid2refnum[e]=p,n.refnum2residArray.hasOwnProperty(u)?n.refnum2residArray[u].push(e):n.refnum2residArray[u]=[e],n.chainsMapping.hasOwnProperty(t)||(n.chainsMapping[t]={}),n.chainsMapping[t][e]=v,S=I}return l+='',l+="",l+="
    ",l+="",l+="",r+="",{html:l,html3:r}}getAdjustedRefnum(e,t,s,i,n,l){let r,o,a,d;this.icn3d.icn3dui;let c=!1,h=!0;if(e[t+n]){let i=parseInt(e[t+n].start),p=parseInt(e[t+n].end),m=e[t+n].start.replace(i.toString(),""),u=e[t+n].end.replace(p.toString(),""),g=e[t+n].len;s<=(e[t+n].nextStrand?parseInt(g/2+.5):g)?(r=i+s,o=r+m,a=t+o):(r=p-(g+1-s),o=r+u,a=void 0!==e[t+n].nextStrand?e[t+n].nextStrand+o:" "+o),d=t+r,1!=s&&s!=p-1||(c=!0),1==s&&i!=l&&(h=!1,r=0,o="",a="",d="")}else r=0,o="",a="",d="",c=!0;return{refnum:r,refnumStr:o,refnumLabel:a,refnumLabelNoPostfix:d,bHidelabel:c,bShowRefnum:h}}getRefnumHtml(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui,d=parseInt(t).toString(),c=this.getRefnumColor(n),h=l?'style="color:'+c+'"':'style="color:'+c+'; text-decoration: underline overline;"',p=parseInt(d.substr(d.length-2,2));parseInt(d.substr(d.length-3,3));let m="";if(50!=p||l)if(p%2!=0||52==p||r)m+=" ';else{m+="'+(isNaN(t)?p+t.substr(t.length-1,1):p)+""}else o.hAtomsRefnum=a.hashUtilsCls.unionHash(o.hAtomsRefnum,o.residues[e]),m+="'+i.substr(0,1)+""+i.substr(1)+"";return m}getRefnumColor(e){let t=this.icn3d.icn3dui;return"A^"==e?"#FF00FF":"A"==e?"#663399":"A*"==e?"#FFC0CB":"A'"==e?"#9370db":"B"==e?"#ba55d3":"C"==e?"#0000FF":"C'"==e?"#6495ED":"C''"==e?"#006400":"D"==e?"#00FF00":"E"==e?"#FFFF00":"F"==e?"#FFA500":"G"==e?"#FF0000":"G*"==e?"#8B0000":t.htmlCls.GREYB}insertGap(e,t,s,i){let n=this.icn3d;n.icn3dui;let l="";if(void 0!==n.targetGapHash&&n.targetGapHash.hasOwnProperty(t))for(let e=0;e"+s+"";return l}insertGapOverview(e,t){let s=this.icn3d,i="";if(s.icn3dui.cfg.blast_rep_id==e&&void 0!==s.targetGapHash&&s.targetGapHash.hasOwnProperty(t)){i+='
     
    '}return i}setAlternativeSeq(e,t){let s=this.icn3d;s.icn3dui;let i=s.chainsSeq[e];s.giSeq[e]=[];for(let t=0,n=i.length;t1&&s.htmlCls.clickMenuCls.setLogCmd("select sets "+e,!0)}else{let o={};if(void 0!==$(e).attr("domain")||void 0!==$(e).attr("feat")||void 0!==$(e).attr("3ddomain")||void 0!==$(e).attr("custom")){t.hlUpdateCls.hlSummaryDomain3ddomain(e);let a,d,c,h=$(e).attr("from").split(","),p=$(e).attr("to").split(",");r.substr(0,r.indexOf("_"));for(let s=0,i=h.length;s1&&s.htmlCls.clickMenuCls.setLogCmd("select sets "+c,!0)}}else{t.bCtrl||t.bShift?(t.currSelectedSets.push(i),t.selectionCls.selectAChain(r,i,!0,!0)):(t.currSelectedSets=[i],t.selectionCls.selectAChain(r,i,t.bAlignSeq)),t.bAlignSeq?s.htmlCls.clickMenuCls.setLogCmd("select alignChain "+r,!0):s.htmlCls.clickMenuCls.setLogCmd("select chain "+r,!0);let e=t.currSelectedSets.join(" or ");t.currSelectedSets.length>1&&s.htmlCls.clickMenuCls.setLogCmd("select sets "+e,!0)}else t.hlObjectsCls.removeHlObjects(),t.hlUpdateCls.removeHl2D(),$("#"+t.pre+"atomsCustom").val("")}}selectResidues(e,t){let s=this.icn3d,i=s.icn3dui;if(!i.bNode&&(!1!==s.bSelectResidue||s.bShift||s.bCtrl||s.selectionCls.removeSelection(),void 0!==e&&""!==e)){e=e.substr(e.indexOf("_")+1),s.bSelectResidue=!0,$(t).toggleClass("icn3d-highlightSeq");let n=e.substr(e.indexOf("_")+1);if(s.residues.hasOwnProperty(n))if($(t).hasClass("icn3d-highlightSeq")){for(let e in s.residues[n])s.hAtoms[e]=1;if(s.selectedResidues[n]=1,s.bAnnotations&&void 0!==$(t).attr("disease")){let e=$(t).attr("disease"),l=s.applyCenterCls.centerAtoms(i.hashUtilsCls.hash2Atoms(s.residues[n],s.atoms)),r=15;e.length>r&&(e=e.substr(0,r)+"...");let o=s.LABELSIZE,a=i.htmlCls.GREYD;s.analysisCls.addLabel(e,l.center.x,l.center.y,l.center.z,o,a,void 0,"custom")}}else{for(let e in s.residues[n])delete s.hAtoms[e];delete s.selectedResidues[n],s.hlObjectsCls.removeHlObjects()}}}}class Pt{constructor(e){this.icn3d=e}update2DdgmContent(){let e=this.icn3d,t=e.icn3dui,s="";void 0!==t.cfg.mmdbid||void 0!==t.cfg.gi?(s+=e.diagram2dCls.draw2Ddgm(e.interactionData,e.inputid,void 0,!0),s+=e.diagram2dCls.set2DdgmNote(),$("#"+e.pre+"dl_2ddgm").html(s)):e.mmdbidArray&&(void 0!==t.cfg.align||void 0!==t.cfg.chainalign||e.bRealign)&&(s+=e.diagram2dCls.draw2Ddgm(e.interactionData1,e.mmdbidArray[0].toUpperCase(),0,!0),void 0!==e.mmdbid_q&&e.mmdbid_q===e.mmdbid_t?s+=e.diagram2dCls.draw2Ddgm(e.interactionData2,e.mmdbidArray[0].toUpperCase(),1,!0):s+=e.diagram2dCls.draw2Ddgm(e.interactionData2,e.mmdbidArray[1].toUpperCase(),1,!0),s+=e.diagram2dCls.set2DdgmNote(!0),$("#"+e.pre+"dl_2ddgm").html(s))}changeSeqColor(e){let t=this.icn3d,s=t.icn3dui;for(let i=0,n=e.length;i0&&($("#"+e.pre+"dl_2ddgm svg line").attr("stroke","#000000"),$("#"+e.pre+"dl_2ddgm line").attr("stroke-width",1))}removeHlMenus(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"atomsCustom").val(""),$("#"+e.pre+"atomsCustom")[0].blur()}updateHlAll(e,t,s,i){let n=this.icn3d,l=n.icn3dui;n.prevHighlightAtoms=l.hashUtilsCls.cloneHash(n.hAtoms),this.updateHlObjects(i),void 0!==e?this.updateHlSeqInChain(e,s):this.updateHlSeq(void 0,void 0,s),this.updateHl2D(),(void 0===t||t)&&this.updateHlMenus(e)}updateHlObjects(e){let t=this.icn3d;t.icn3dui,t.hlObjectsCls.removeHlObjects(),(t.hAtoms&&t.atoms&&Object.keys(t.hAtoms).length0&&(e=s.defNames2Residues[i]);let t={};if(void 0!==s.defNames2Atoms[i]&&s.defNames2Atoms[i].length>0){for(let e=0,n=s.defNames2Atoms[i].length;e0&&(r=t.firstAtomObjCls.getFirstCalphaAtomObj(l))}let o=void 0!==r&&void 0!==r.color?"#"+r.color.getHexString():"#FFFFFF",a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] rect[class='icn3d-hlnode']"),d=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] rect[class='icn3d-basenode']");void 0!==a&&(t.diagram2dCls.highlightNode("rect",a,d,l),$(a).attr("fill",o)),a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] circle[class='icn3d-hlnode']"),d=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] circle[class='icn3d-basenode']"),void 0!==a&&(t.diagram2dCls.highlightNode("circle",a,d,l),$(a).attr("fill",o)),a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] ellipse[class='icn3d-hlnode']"),void 0!==a&&t.diagram2dCls.highlightNode("ellipse",a,void 0,l),a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] polygon[class='icn3d-hlnode']"),d=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] polygon[class='icn3d-basenode']"),void 0!==a&&(t.diagram2dCls.highlightNode("polygon",a,d,l),$(a).attr("fill",o))}if(void 0!==t.lineArray2d)for(let e=0,i=t.lineArray2d.length;e1){let e={},l=[],o=[],a=[],c=[],h=[],m=[],u=[],g=[],f=[],b=[],C=[],y=[],v={};for(let t=0,s=p.length;t0&&(E=1,t=i.getGraphCls.getNodeTopBottom(c[e],d,void 0,E,g[e]),h[e]=t.nodeArray1,m[e]=t.nodeArray2,d=n.hashUtilsCls.unionHash(d,t.name2node),E=2,t=i.getGraphCls.getNodeTopBottom(c[e],d,void 0,E,y[e]),f[e]=t.nodeArray1,b[e]=t.nodeArray2,d=n.hashUtilsCls.unionHash(d,t.name2node)),x[e]=l[e].length,k[e]=o[e].length,O=Math.max(O,k[e]),R.push(p[e])}let I,T,M,P,D,H=1,F=3*H,L=7*H,N=10,U=10,q=30,$=20;t?(M=(n.utilsCls.sumArray(x)+2*R.length)*(F+L)+4*U+2*q+$*R.length,T=(O+2)*(F+L)+2*N+q):(I=110+$,M=I*R.length,T=(O+2)*(F+L)+2*N),Object.keys(i.chainsMapping).length>0&&(M*=3),t?(i.scatterplotWidth=2*T,D=i.scatterplotWidth,P=n.scatterplotid):(i.linegraphWidth=2*T,D=i.linegraphWidth,P=n.linegraphid),s=0==R.length?"No interactions found for each structure

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

    ",s+="";let j,B=0;E=0,j=this.drawGraphPerType(E,p,t,l,o,a,d,B,I,$,x,F,L,U),B=j.heightFinal,s+=j.html,Object.keys(i.chainsMapping).length>0&&(E=1,j=this.drawGraphPerType(E,p,t,h,m,u,d,B,I,$,x,F,L,U),B=j.heightFinal,s+=j.html,E=2,j=this.drawGraphPerType(E,p,t,f,b,C,d,B,I,$,x,F,L,U),B=j.heightFinal,s+=j.html),s+=""}else if(t){let e,t,l,c,h=p[0],m=o.length,u=a.length,g=1,f=3*g,b=7*g,C=30;t=(m+2)*(f+b)+2*10+C,e=(u+2)*(f+b)+2*10+C,i.scatterplotWidth=2*e,c=i.scatterplotWidth,l=n.scatterplotid,s=r.length>0?"":"No interactions found for these two sets

    ",s+="",s+=this.drawScatterplot_base(o,a,r,d,0),i.lineGraphStr+=i.getGraphCls.updateGraphJson(h,1,o,a,r),s+=""}else{let e=p[0],t=o.length,l=a.length,c=1,h=3*c,m=7*c,u=110,g=10,f=t>l?t*(h+m)+2*g:l*(h+m)+2*g;i.linegraphWidth=2*f,s=r.length>0?"":"No interactions found for these two sets

    ",s+="",s+=this.drawLineGraph_base(o,a,r,d,0),i.lineGraphStr+=i.getGraphCls.updateGraphJson(e,1,o,a,r),s+=""}return i.lineGraphStr+="}\n",i.scatterplotStr=i.lineGraphStr,t?$("#"+i.pre+"scatterplotDiv").html(s):$("#"+i.pre+"linegraphDiv").html(s),s}drawGraphPerType(e,t,s,i,n,l,r,o,a,d,c,h,p,m){let u=this.icn3d;u.icn3dui;let g,f,b="",C=2==t.length&&"2"==t[1].replace(t[0],"");0==e?(g="Interactions in ",f=""):1==e?(g="Common interactions in ",f="_common"):2==e&&(g="Different interactions in ",f="_diff");for(let y=0,v=t.length;y0&&(u.lineGraphStr+=", \n"):u.lineGraphStr+=", \n",u.lineGraphStr+=u.getGraphCls.updateGraphJson(t[y],y+f,i[y],n[y],l[y])}return{heightFinal:o,html:b}}getIdArrayFromNode(e){let t=this.icn3d.icn3dui,s=[];s.push(""),s.push("");let i=e.r.substr(4);return s=s.concat(t.utilsCls.getIdArray(i)),s}drawLineGraph_base(e,t,s,i,n,l,r){let o,a,d=this.icn3d,c=d.icn3dui,h="",p=e.length,m=t.length;p>m?(o=10,a=10*Math.abs(p-m)*.5+10):(a=10,o=10*Math.abs(p-m)*.5+10),l&&(h+=""+l+"");let u=30+n,g=80+n,f="",b={},C={};for(let t=0;t",h+="Interaction of residue "+n.id+" with residue "+l.id+"",h+="")}return h+=f,h}drawScatterplot_base(e,t,s,i,n,l,r,o,a){let d=this.icn3d;d.icn3dui;let c="",h=e.length,p=t.length,m=l?3:7,u=(h+1)*(3+m)+30+40;r&&(c+=""+r+"");let g=n+u-(50+(3+m)),f=40+(3+m),b="",C={},y={};for(let t=0;t"):(h+="",h+="Interaction of residue "+t.id+" with residue "+s.id+"",h+=l?"":"",h+=""))),h}copyStylesInline(e,t){this.icn3d.icn3dui;let s=["svg","g"];for(let i=0;i";return b+=""+e.id+"",o?(b+="",b+=""+g+""):(b+="",b+=""+g+""),b+="",b}getNodeTopBottom(e,t,s,i,n){let l=this.icn3d.icn3dui,r=this,o=[],a=[],d={};for(let s in e){let e=t[s];if(e){if(1==i||2==i){if(e=l.hashUtilsCls.cloneHash(e),1==i){let t=n[s]?n[s]:"-";e.id+="=>"+t}else{let t=n[s]?n[s]:"--";e.id+="==>"+t}d[e.id]=e}"a"==e.s?o.push(e):"b"==e.s?a.push(e):"ab"==e.s&&(o.push(e),a.push(e))}}return o.sort((function(e,t){return r.compNode(e,t)})),a.sort((function(e,t){return r.compNode(e,t,s)})),{nodeArray1:o,nodeArray2:a,name2node:d}}updateGraphJson(e,t,s,i,n){let l=this.icn3d.icn3dui,r="";return r+='"structure'+t+'": {"id": "'+e+'", "nodes1":[',r+=l.utilsCls.getJSONFromArray(s),r+='], \n"nodes2":[',r+=l.utilsCls.getJSONFromArray(i),r+='], \n"links":[',r+=l.utilsCls.getJSONFromArray(n),r+="]}",r}updateGraphColor(){let e=this.icn3d,t=e.icn3dui;if(void 0!==e.graphStr){let s=JSON.parse(e.graphStr),i={};for(let t in e.residues){let s=e.firstAtomObjCls.getFirstAtomObj(e.residues[t]);i[t]=s.color.getHexString().toUpperCase()}let n={};for(let e=0,l=s.nodes.length;e0&&c==e.chain&&(n.resid2ncbi[e.resi]==n.resid2ncbi[p]+1||n.resid2ncbi[e.resi]==n.resid2ncbi[p])&&(o.push('{"source": "'+h+'", "target": "'+u+'", "v": '+d+', "c": "'+f+'"}'),e.ssbegin&&(d=l.htmlCls.ssValue),e.ssend&&(d=l.htmlCls.coilValue)),c=e.chain,h=u,p=e.resi,++a}}return{node:r,link:o}}getHbondLinksForSet(e,t){let s=this.icn3d,i=s.icn3dui,n={},l=parseFloat($("#"+s.pre+"hbondthreshold").val()),r=e,o=r;if(Object.keys(o).length>0&&Object.keys(r).length>0){let e=!1;s.hBondCls.calculateChemicalHbonds(i.hashUtilsCls.intHash2Atoms(s.dAtoms,o,s.atoms),i.hashUtilsCls.intHash2Atoms(s.dAtoms,r,s.atoms),parseFloat(l),e,"graph",!0),n=i.hashUtilsCls.cloneHash(s.resid2Residhash)}return this.getGraphLinks(n,n,i.htmlCls.hbondInsideColor,t,i.htmlCls.hbondValuehbondInsideValue)}getIonicLinksForSet(e,t){let s=this.icn3d,i=s.icn3dui,n={},l=parseFloat($("#"+s.pre+"saltbridgethreshold").val()),r=e,o=r;if(Object.keys(o).length>0&&Object.keys(r).length>0){let e=!1;s.saltbridgeCls.calculateIonicInteractions(i.hashUtilsCls.intHash2Atoms(s.dAtoms,o,s.atoms),i.hashUtilsCls.intHash2Atoms(s.dAtoms,r,s.atoms),parseFloat(l),e,"graph",!0),n=i.hashUtilsCls.cloneHash(s.resid2Residhash)}return this.getGraphLinks(n,n,i.htmlCls.ionicInsideColor,t,i.htmlCls.ionicInsideValue)}getHalogenPiLinksForSet(e,t){let s,i=this.icn3d,n=i.icn3dui,l={},r=e,o=r,a="";return s=parseFloat($("#"+i.pre+"halogenthreshold").val()),Object.keys(o).length>0&&Object.keys(r).length>0&&(i.piHalogenCls.calculateHalogenPiInteractions(n.hashUtilsCls.intHash2Atoms(i.dAtoms,r,i.atoms),n.hashUtilsCls.intHash2Atoms(i.dAtoms,o,i.atoms),parseFloat(s),"graph","halogen",!0),l=n.hashUtilsCls.cloneHash(i.resid2Residhash)),a+=this.getGraphLinks(l,l,n.htmlCls.halogenInsideColor,t,n.htmlCls.halogenInsideValue),s=parseFloat($("#"+i.pre+"picationthreshold").val()),Object.keys(o).length>0&&Object.keys(r).length>0&&(i.piHalogenCls.calculateHalogenPiInteractions(n.hashUtilsCls.intHash2Atoms(i.dAtoms,r,i.atoms),n.hashUtilsCls.intHash2Atoms(i.dAtoms,o,i.atoms),parseFloat(s),"graph","pi-cation",!0),l=n.hashUtilsCls.cloneHash(i.resid2Residhash)),a+=this.getGraphLinks(l,l,n.htmlCls.picationInsideColor,t,n.htmlCls.picationInsideValue),s=parseFloat($("#"+i.pre+"pistackingthreshold").val()),Object.keys(o).length>0&&Object.keys(r).length>0&&(i.piHalogenCls.calculateHalogenPiInteractions(n.hashUtilsCls.intHash2Atoms(i.dAtoms,r,i.atoms),n.hashUtilsCls.intHash2Atoms(i.dAtoms,o,i.atoms),parseFloat(s),"graph","pi-stacking",!0),l=n.hashUtilsCls.cloneHash(i.resid2Residhash)),a+=this.getGraphLinks(l,l,n.htmlCls.pistackingInsideColor,t,n.htmlCls.pistackingInsideValue),a}getContactLinksForSet(e,t,s){let i=this.icn3d;i.icn3dui;let n=[],l="",r="",o={};for(let t in e){let e=i.atoms[t];e.ss==l&&e.chain==r||(Object.keys(o).length>0&&n.push(o),o={}),o[e.serial]=1,l=e.ss,r=e.chain}Object.keys(o).length>0&&n.push(o);let a=n.length,d="";for(let e=0;ed?s?-1:1:ah?1:c0&&Object.keys(a).length>0)){let t,s=c.hBondCls.calculateChemicalHbonds(h.hashUtilsCls.intHash2Atoms(c.dAtoms,d,c.atoms),h.hashUtilsCls.intHash2Atoms(c.dAtoms,a,c.atoms),parseFloat(e),n);n?(c.resid2ResidhashSaltbridge=h.hashUtilsCls.cloneHash(c.resid2Residhash),t="all atoms that have salt bridges with the selected atoms"):(c.resid2ResidhashHbond=h.hashUtilsCls.cloneHash(c.resid2Residhash),t="all atoms that are hydrogen-bonded with the selected atoms");let i={};for(let e in s){i[c.atoms[e].structure+"_"+c.atoms[e].chain+"_"+c.atoms[e].resi]=1}c.hAtoms={};for(let e in i)for(let t in c.residues[e])c.hAtoms[t]=1,c.atoms[t].style2="stick";let l=r+"_auto";c.selectionCls.addCustomSelection(Object.keys(i),l,t,o,!0),c.selectionCls.saveSelectionIfSelected(),c.drawCls.draw()}}showHydrogens(){let e=this.icn3d;if(void 0!==e.icn3dui.cfg.cid)for(let t in e.hAtoms){let s=e.atoms[t];if("H"!==s.elem.substr(0,1)){e.atoms[s.serial].bonds=e.atoms[s.serial].bonds2.concat(),e.atoms[s.serial].bondOrder=e.atoms[s.serial].bondOrder2.concat();for(let t=0,i=e.atoms[s.serial].bonds.length;t0){let i=e.atoms[t].bonds[0];e.atoms[i].bonds.push(s.serial),e.atoms[i].bondOrder&&e.atoms[i].bondOrder.push(1)}e.dAtoms[t]=1}}e.bShowHighlight=!1}hideHydrogens(){let e=this.icn3d;e.icn3dui;for(let t in e.hAtoms){let s=e.atoms[t];if("H"===s.elem.substr(0,1)){if(e.atoms[s.serial].bonds.length>0){let t=e.atoms[s.serial].bonds[0],i=e.atoms[t].bonds?e.atoms[t].bonds.indexOf(s.serial):-1;-1!==i&&(e.atoms[t].bonds.splice(i,1),e.atoms[t].bondOrder&&e.atoms[t].bondOrder.splice(i,1))}delete e.dAtoms[s.serial],delete e.hAtoms[s.serial]}}}hideHbondsContacts(){let e=this.icn3d,t=e.icn3dui,s="set hbonds off";t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.hBondCls.hideHbonds(),s="set salt bridge off",t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.saltbridgeCls.hideSaltbridge(),s="set contact off",t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.contactCls.hideContact(),s="set halogen pi off",t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.piHalogenCls.hideHalogenPi()}showIonicInteractions(e,t,s,i,n,l){let r,o,a,d,c=this.icn3d,h=c.icn3dui;if(!i&&(r="saltbridge",o="salt bridge "+e+" | sets "+t+" "+s+" | "+i,c.opts.saltbridge="yes",a=c.definedSetsCls.getAtomsFromNameArray(t),d=c.definedSetsCls.getAtomsFromNameArray(s),c.firstAtomObjCls.getFirstAtomObj(a),Object.keys(d).length>0&&Object.keys(a).length>0)){let t,s=c.saltbridgeCls.calculateIonicInteractions(h.hashUtilsCls.intHash2Atoms(c.dAtoms,d,c.atoms),h.hashUtilsCls.intHash2Atoms(c.dAtoms,a,c.atoms),parseFloat(e),n);c.resid2ResidhashSaltbridge=h.hashUtilsCls.cloneHash(c.resid2Residhash),t="all atoms that have ionic interactions with the selected atoms";let i={};for(let e in s){i[c.atoms[e].structure+"_"+c.atoms[e].chain+"_"+c.atoms[e].resi]=1}c.hAtoms={};for(let e in i)for(let t in c.residues[e])c.hAtoms[t]=1,c.atoms[t].style2="stick",c.ions.hasOwnProperty(t)&&(c.atoms[t].style2="sphere");let l="saltbridge_auto";c.selectionCls.addCustomSelection(Object.keys(i),l,t,o,!0),c.selectionCls.saveSelectionIfSelected(),c.drawCls.draw()}}showHalogenPi(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(i)return;let a,d,c=l+" "+e+" | sets "+t+" "+s+" | "+i;if(r.opts[l]="yes",a=r.definedSetsCls.getAtomsFromNameArray(t),d=r.definedSetsCls.getAtomsFromNameArray(s),r.firstAtomObjCls.getFirstAtomObj(a),Object.keys(d).length>0&&Object.keys(a).length>0){let t,s=r.piHalogenCls.calculateHalogenPiInteractions(o.hashUtilsCls.intHash2Atoms(r.dAtoms,a,r.atoms),o.hashUtilsCls.intHash2Atoms(r.dAtoms,d,r.atoms),parseFloat(e),n,l);"halogen"==l?(r.resid2ResidhashHalogen=o.hashUtilsCls.cloneHash(r.resid2Residhash),t="all atoms that have halogen bonds with the selected atoms"):"pi-cation"==l?(r.resid2ResidhashPication=o.hashUtilsCls.cloneHash(r.resid2Residhash),t="all atoms that have pi-cation interactions with the selected atoms"):"pi-stacking"==l&&(r.resid2ResidhashPistacking=o.hashUtilsCls.cloneHash(r.resid2Residhash),t="all atoms that have pi-stacking with the selected atoms");let i={};for(let e in s){i[r.atoms[e].structure+"_"+r.atoms[e].chain+"_"+r.atoms[e].resi]=1}r.hAtoms={};for(let e in i)for(let t in r.residues[e])r.hAtoms[t]=1,r.atoms[t].style2="stick",r.ions.hasOwnProperty(t)&&(r.atoms[t].style2="sphere");let h=l+"_auto";r.selectionCls.addCustomSelection(Object.keys(i),h,t,c,!0),r.selectionCls.saveSelectionIfSelected(),r.drawCls.draw()}}showClbonds(){let e=this.icn3d,t=e.icn3dui;e.opts.clbonds="yes";let s=e.applyClbondsCls.applyClbondsOptions();for(let i in s)e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.residues[i]);if(Object.keys(s).length>0){let t="clbonds",i="all atoms that have cross-linkages";e.selectionCls.addCustomSelection(Object.keys(s),t,i,"cross linkage",!0),e.selectionCls.saveSelectionIfSelected(),e.drawCls.draw()}}showSsbonds(){let e=this.icn3d,t=e.icn3dui;e.opts.ssbonds="yes";let s={},i=Object.keys(e.structures);for(let n=0,l=i.length;n0){let t="ssbonds",i="all atoms that have disulfide bonds";e.selectionCls.addCustomSelection(Object.keys(s),t,i,"disulfide bonds",!0),e.selectionCls.saveSelectionIfSelected(),e.drawCls.draw()}}pickCustomSphere(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(i)return;let a,d,c="select zone cutoff "+e+" | sets "+t+" "+s+" | "+i;n&&(c="interactions "+e+" | sets "+t+" "+s+" | "+i,r.opts.contact="yes"),a=r.definedSetsCls.getAtomsFromNameArray(t),d=r.definedSetsCls.getAtomsFromNameArray(s);let h,p,m=this.pickCustomSphere_base(e,a,d,i,n,l,c,!0),u=Object.keys(m.residues);r.hAtoms={};for(let e=0,t=u.length;e1?"structure":v>1?"chain":"residue";let _=[];if(n&&_.push("hbonds"),l&&_.push("salt bridge"),r&&_.push("interactions"),o&&_.push("halogen"),a&&_.push("pi-cation"),d&&_.push("pi-stacking"),s||(p.resids2inter={},p.resids2interAll={}),l){let n=parseFloat($("#"+p.pre+"saltbridgethreshold").val());n&&!isNaN(n)||(n=p.tsIonic),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showIonicInteractions(n,e,t,s,!0,i)),g=m.hashUtilsCls.unionHash(g,p.hAtoms)}if(n){let n=parseFloat($("#"+p.pre+"hbondthreshold").val());n&&!isNaN(n)||(n=p.tsHbond),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHbonds(n,e,t,s,void 0,i)),g=m.hashUtilsCls.unionHash(g,p.hAtoms)}let S,A,x,k,O="";if(n&&(O+=this.exportHbondPairs(i,u)),l&&(O+=this.exportSaltbridgePairs(i,u)),o){let n=parseFloat($("#"+p.pre+"halogenthreshold").val());n&&!isNaN(n)||(n=p.tsHalogen),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHalogenPi(n,e,t,s,i,"halogen")),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportHalogenPiPairs(i,u,"halogen")}if(a){let n=parseFloat($("#"+p.pre+"picationthreshold").val());n&&!isNaN(n)||(n=p.tsPication),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHalogenPi(n,e,t,s,i,"pi-cation")),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportHalogenPiPairs(i,u,"pi-cation")}if(d){let n=parseFloat($("#"+p.pre+"pistackingthreshold").val());n&&!isNaN(n)||(n=p.tsPistacking),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHalogenPi(n,e,t,s,i,"pi-stacking")),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportHalogenPiPairs(i,u,"pi-stacking")}if(r){let n=b?c:parseFloat($("#"+p.pre+"contactthreshold").val());if(n&&!isNaN(n)||(n=p.tsContact),1!=e.length||1!=t.length||e[0]!=t[0])s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.pickCustomSphere(n,e,t,s,!0,i)),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportSpherePairs(!0,i,u);else{if(!s){let l={},o={};if(b){let e=!0,t=p.showInterCls.pickCustomSphere_base(n,C,y,s,!0,void 0,void 0,!0,e);l=m.hashUtilsCls.unionHash(l,t.residues);for(let e in t.resid2Residhash)o[e]=m.hashUtilsCls.unionHash(o[e],t.resid2Residhash[e])}else{let r=[],a="",d="",c={};for(let e in C){let t=p.atoms[e];t.ss==a&&t.chain==d||(Object.keys(c).length>0&&r.push(c),c={}),c[t.serial]=1,a=t.ss,d=t.chain}Object.keys(c).length>0&&r.push(c);let h=r.length;A="interactions "+n+" | sets "+e+" "+t+" | true",p.opts.contact="yes";for(let e=0;e
    ",T=p.resid2specCls.atoms2residues(Object.keys(C)),M=p.resid2specCls.atoms2residues(Object.keys(y)),P="select "+p.resid2specCls.residueids2spec(T),D="select "+p.resid2specCls.residueids2spec(M);I+="Set 1: "+e+'
    ',I+="Set 2: "+t+'

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

    ',I+='
    Note: Each checkbox below selects the corresponding residue. You can click "Save Selection" in the "Select" menu to save the selection and click on "Highlight" button to clear the checkboxes.

    ';let U=I;if(("graph"==i||"linegraph"==i||"scatterplot"==i||b)&&(I=""),I+=O,"save1"==i||"save2"==i){I=U;let e="";"save1"==i?e="Set 1":"save2"==i&&(e="Set 2"),I+='

    Interactions Sorted on '+e+':
    ';let t=this.getAllInteractionTable(i);I+=t.html,h=t.bondCnt,$("#"+p.pre+"dl_interactionsorted").html(I),m.htmlCls.dialogCls.openDlg("dl_interactionsorted","Show sorted interactions")}else if("view"==i)$("#"+p.pre+"dl_allinteraction").html(I),m.htmlCls.dialogCls.openDlg("dl_allinteraction","Show interactions");else if("linegraph"==i){m.htmlCls.dialogCls.openDlg("dl_linegraph","Show interactions between two lines of residue nodes"),p.graphStr=p.getGraphCls.getGraphData(C,y,e,t,I,u),p.bLinegraph=!0;let s=p.lineGraphCls.drawLineGraph(p.graphStr);$("#"+p.pre+"linegraphDiv").html(s)}else if("scatterplot"==i){m.htmlCls.dialogCls.openDlg("dl_scatterplot","Show interactions as scatterplot"),p.graphStr=p.getGraphCls.getGraphData(C,y,e,t,I,u),p.bScatterplot=!0;let s=p.lineGraphCls.drawLineGraph(p.graphStr,!0);$("#"+p.pre+"scatterplotDiv").html(s)}else if(b){m.htmlCls.dialogCls.openDlg("dl_contactmap","Show contact map");let s=!0,i=p.getGraphCls.getGraphData(C,y,e,t,I,u,s);p.bContactMap=!0;let n=p.contactMapCls.drawContactMap(i);$("#"+p.pre+"contactmapDiv").html(n)}else if("graph"==i)if(p.graphStr=p.getGraphCls.getGraphData(C,y,e,t,I,u),p.bGraph=!0,Object.keys(y).length+Object.keys(C).length>Object.keys(p.dAtoms).length&&(p.graphStr=p.selectionCls.getGraphDataForDisplayed()),void 0===p.bD3){await m.getAjaxPromise("https://www.ncbi.nlm.nih.gov/Structure/icn3d/script/d3v4-force-all.min.js","script"),p.bD3=!0,$("#"+m.svgid).empty(),m.htmlCls.dialogCls.openDlg("dl_graph","Force-directed graph"),p.drawGraphCls.drawGraph(p.graphStr,p.pre+"dl_graph")}else $("#"+m.svgid).empty(),m.htmlCls.dialogCls.openDlg("dl_graph","Force-directed graph"),p.drawGraphCls.drawGraph(p.graphStr,p.pre+"dl_graph");return{interactionTypes:_.toString(),bondCnt:h}}clearInteractions(){let e=this.icn3d;e.icn3dui,e.lines.hbond=[],e.hbondpnts=[],e.lines.saltbridge=[],e.saltbridgepnts=[],e.lines.contact=[],e.contactpnts=[],e.lines.halogen=[],e.lines["pi-cation"]=[],e.lines["pi-stacking"]=[],e.halogenpnts=[],e.picationpnts=[],e.pistackingpnts=[]}resetInteractionPairs(){let e=this.icn3d;e.icn3dui,e.bHbondCalc=!1,e.showInterCls.hideHbondsContacts(),e.hlUpdateCls.clearHighlight(),e.resids2inter={},e.resids2interAll={}}async retrieveInteractionData(){let e=this.icn3d,t=e.icn3dui;if(!e.b2DShown)if(void 0!==t.cfg.align){let s=Object.keys(e.structures);if(2==t.cfg.atype){let t=!0;await e.alignParserCls.downloadAlignment(s[0]+","+s[1],t)}await e.ParserUtilsCls.set2DDiagramsForAlign(s[0].toUpperCase(),s[1].toUpperCase())}else void 0!==t.cfg.chainalign?(Object.keys(e.structures),await e.ParserUtilsCls.set2DDiagramsForChainalign(e.chainidArray)):e.ParserUtilsCls.download2Ddgm(e.inputid.toUpperCase())}getAllInteractionTable(e){let t=this.icn3d,s=t.icn3dui,i=[],n=Object.keys(t.resids2inter);("save1"==e||"save2"==e)&&n.sort((function(t,i){return s.utilsCls.compResid(t,i,e)}));let l,r,o="",a="",d="",c="",h="",p="",m="",u="",g="",f=0,b=0,C=0,y=0,v=0,w=0,_="";for(let s=0,S=n.length;s0&&l!=a&&(i.push({res1:a,res2:_,cntHbond:f,cntIonic:b,cntContact:C,cntHalegen:y,cntPication:v,cntPistacking:w}),o+=this.getInteractionPerResidue(d,c,h,p,m,u,g,f,b,C,y,v,w),c="",h="",p="",m="",u="",g="",f=0,b=0,C=0,y=0,v=0,w=0,_=""),x=t.resids2inter[S].hbond,k=this.getInteractionPairDetails(x,e,"hbond"),c+=k.html,f+=k.cnt,k.cnt>0&&(_+=r+":hbond_"+k.cnt+" "),x=t.resids2inter[S].ionic,k=this.getInteractionPairDetails(x,e,"ionic"),h+=k.html,b+=k.cnt,k.cnt>0&&(_+=r+":ionic_"+k.cnt+" "),x=t.resids2inter[S].contact,k=this.getContactPairDetails(x,e,"contact"),p+=k.html,C+=k.cnt,k.cnt>0&&(_+=r+":contact_"+k.cnt+" "),x=t.resids2inter[S].halogen,k=this.getInteractionPairDetails(x,e,"halogen"),m+=k.html,y+=k.cnt,k.cnt>0&&(_+=r+":halogen_"+k.cnt+" "),x=t.resids2inter[S]["pi-cation"],k=this.getInteractionPairDetails(x,e,"pi-cation"),u+=k.html,v+=k.cnt,k.cnt>0&&(_+=r+":pi-cation_"+k.cnt+" "),x=t.resids2inter[S]["pi-stacking"],k=this.getInteractionPairDetails(x,e,"pi-stacking"),g+=k.html,w+=k.cnt,k.cnt>0&&(_+=r+":pi-stacking_"+k.cnt+" "),a=l,d=O}i.push({res1:a,res2:_,cntHbond:f,cntIonic:b,cntContact:C,cntHalegen:y,cntPication:v,cntPistacking:w}),o+=this.getInteractionPerResidue(d,c,h,p,m,u,g,f,b,C,y,v,w);let S="";if(n.length>0){S+='
    ',S+="",S+="",S+="",S+="",S+="";let e='';S+=e,S+=e,S+='',S+=e,S+=e,S+=e,S+="",S+="",S+=o,S+="
    Residue# Hydrogen
    Bond
    # Salt Bridge
    /Ionic Interaction
    # Contact# Halogen
    Bond
    # π-Cation# π-StackingHydrogen Bond (backbone atoms: @CA, @N, @C, @O)Salt Bridge/Ionic InteractionContactHalogen Bondπ-Cationπ-Stacking
    Atom1Atom2Distance(Å)Highlight in 3D
    Atom1Atom2# ContactsMin Distance(Å)C-alpha Distance(Å)Highlight in 3D

    "}return{html:S,bondCnt:i}}getInteractionPerResidue(e,t,s,i,n,l,r,o,a,d,c,h,p){this.icn3d.icn3dui;let m="";m+=''+e[3]+e[2]+""+o+""+a+""+d+""+c+""+h+""+p+"";let u=[t,s,i,n,l,r];for(let e in u){m+=''+u[e]+"
    "}return m+="",m}getInteractionPairDetails(e,t,s){let i=this.icn3d;i.icn3dui;let n="",l=0,r='    ';if(void 0!==e)for(let a in e){let d=a.split(","),c="save1"==t?d[0]:d[1],h="save1"==t?d[1]:d[0],p=i.getGraphCls.convertLabel2Resid(c),m=i.firstAtomObjCls.getFirstAtomObj(i.residues[p]),u=m.color?m.color.getHexString():"",g=i.getGraphCls.convertLabel2Resid(h),f=i.firstAtomObjCls.getFirstAtomObj(i.residues[g]),b=f.color?f.color.getHexString():"",C=Math.sqrt(e[a]).toFixed(1);n+=' '+c+r+u+o+' '+h+r+b+o+''+C+"",n+='',n+="",++l}return{html:n,cnt:l}}getContactPairDetails(e,t){let s=this.icn3d;s.icn3dui;let i="",n=0,l='    ';if(void 0!==e)for(let o in e){let a=o.split(","),d="save1"==t?a[0]:a[1],c="save1"==t?a[1]:a[0],h=s.getGraphCls.convertLabel2Resid(d),p=s.firstAtomObjCls.getFirstAtomObj(s.residues[h]),m=p.color?p.color.getHexString():"",u=s.getGraphCls.convertLabel2Resid(c),g=s.firstAtomObjCls.getFirstAtomObj(s.residues[u]),f=g.color?g.color.getHexString():"",b=e[o].split("_"),C=b[0],y=b[1],v=b[2],w=b[3],_=b[4];i+=' '+d+"@"+v+l+m+r+' '+c+"@"+w+l+f+r+''+_+''+C+''+y+"",i+='',i+="",n+=parseInt(_)}return{html:i,cnt:n}}exportInteractions(){var e=this.icn3d;e.icn3dui;let t='

    Interacting residues:
    ';for(let s in e.chainname2residues)for(let i in e.chainname2residues[s]){let n=s.substr(0,s.indexOf("_"))+"_"+i.substr(0,i.indexOf(" "));t+=""}t+="
    Base Chain: ResiduesInteracting Chain
    "+s+": ",t+=e.resid2specCls.residueids2spec(e.chainname2residues[s][i]),t+=""+n+"

    ";let s=e.inputid?e.inputid:"custom";e.saveFileCls.saveFile(s+"_interactions.html","html",t)}exportSsbondPairs(){var e=this.icn3d;e.icn3dui;let t="",s=0;for(let i in e.structures){let n=e.ssbondpnts[i];if(void 0===n)break;for(let e=0,i=n.length;e"+n[e]+" Cys"+n[e+1]+" Cys",++s}}let i='

    '+s+" disulfide pairs:

    ";i+=t,i+="
    Residue ID 1Residue ID 2

    ";let n=e.inputid?e.inputid:"custom";e.saveFileCls.saveFile(n+"_disulfide_pairs.html","html",i)}exportClbondPairs(){var e=this.icn3d;e.icn3dui;let t="",s=0,i={};for(let n in e.structures){let l=e.clbondpnts[n];if(void 0===l)break;for(let n=0,r=l.length;n"+r+" "+i.resn+""+o+" "+n.resn+"",++s}i[r+"_"+o]=1,i[o+"_"+r]=1}}let n='

    '+s+" cross-linkage pairs:

    ";n+=t,n+="
    Residue ID 1Residue ID 2

    ";let l=e.inputid?e.inputid:"custom";e.saveFileCls.saveFile(l+"_crosslinkage_pairs.html","html",n)}exportHbondPairs(e,t){var s=this.icn3d,i=s.icn3dui;let n="",l=0,r='    ';for(let t in s.resid2ResidhashHbond){let i=s.getGraphCls.convertLabel2Resid(t),a=s.firstAtomObjCls.getFirstAtomObj(s.residues[i]),d=a.color?a.color.getHexString():"";for(let i in s.resid2ResidhashHbond[t]){let a=s.getGraphCls.convertLabel2Resid(i),c=s.firstAtomObjCls.getFirstAtomObj(s.residues[a]),h=c.color?c.color.getHexString():"",p=Math.sqrt(s.resid2ResidhashHbond[t][i]).toFixed(1);n+=' '+t+r+d+o+' '+i+r+h+o+''+p+"","view"==e&&(n+=''),n+="",++l}}let a='

    '+l+" hydrogen bond pairs (backbone atoms: @CA, @N, @C, @O):

    ";if(l>0&&(a+="
    ","view"==e&&(a+=''),a+="",a+=n,a+="
    Atom 1Atom 2Distance(Å)Highlight in 3D

    "),"graph"==e||"linegraph"==e||"scatterplot"==e){return s.getGraphCls.getGraphLinks(s.resid2ResidhashHbond,s.resid2ResidhashHbond,i.htmlCls.hbondColor,t,i.htmlCls.hbondValue)}return a}exportSaltbridgePairs(e,t){var s=this.icn3d,i=s.icn3dui;let n="",l=0,r='    ';for(let t in s.resid2ResidhashSaltbridge){let i=s.getGraphCls.convertLabel2Resid(t),a=s.firstAtomObjCls.getFirstAtomObj(s.residues[i]),d=a.color?a.color.getHexString():"";for(let i in s.resid2ResidhashSaltbridge[t]){let a=s.getGraphCls.convertLabel2Resid(i),c=s.firstAtomObjCls.getFirstAtomObj(s.residues[a]),h=c.color?c.color.getHexString():"",p=Math.sqrt(s.resid2ResidhashSaltbridge[t][i]).toFixed(1);n+=' '+t+r+d+o+' '+i+r+h+o+''+p+"","view"==e&&(n+=''),n+="",++l}}let a='

    '+l+" salt bridge/ionic interaction pairs:

    ";if(l>0&&(a+="
    ","view"==e&&(a+=''),a+="",a+=n,a+="
    Atom 1Atom 2Distance(Å)Highlight in 3D

    "),"graph"==e||"linegraph"==e||"scatterplot"==e){return s.getGraphCls.getGraphLinks(s.resid2ResidhashSaltbridge,s.resid2ResidhashSaltbridge,i.htmlCls.ionicColor,t,i.htmlCls.ionicValue)}return a}exportHalogenPiPairs(e,t,s){var i=this.icn3d,n=i.icn3dui;let l,r,o,a="",d=0,c='    ';"halogen"==s?(l=i.resid2ResidhashHalogen,r=n.htmlCls.halogenColor,o=n.htmlCls.halogenValue):"pi-cation"==s?(l=i.resid2ResidhashPication,r=n.htmlCls.picationColor,o=n.htmlCls.picationValue):"pi-stacking"==s&&(l=i.resid2ResidhashPistacking,r=n.htmlCls.pistackingColor,o=n.htmlCls.pistackingValue);for(let t in l){let n=i.getGraphCls.convertLabel2Resid(t),r=i.firstAtomObjCls.getFirstAtomObj(i.residues[n]),o=r.color?r.color.getHexString():"";for(let n in l[t]){let r=i.getGraphCls.convertLabel2Resid(n),p=i.firstAtomObjCls.getFirstAtomObj(i.residues[r]),m=p.color?p.color.getHexString():"",u=Math.sqrt(l[t][n]).toFixed(1);a+=' '+t+c+o+h+' '+n+c+m+h+''+u+"","view"==e&&(a+=''),a+="",++d}}let p='

    '+d+" "+s+" pairs:

    ";if(d>0&&(p+="
    ","view"==e&&(p+=''),p+="",p+=a,p+="
    Atom 1Atom 2Distance(Å)Highlight in 3D

    "),"graph"==e||"linegraph"==e||"scatterplot"==e){return i.getGraphCls.getGraphLinks(l,l,r,t,o)}return p}exportSpherePairs(e,t,s){var i=this.icn3d,n=i.icn3dui;let l="",r=0,o=e?i.resid2ResidhashInteractions:i.resid2ResidhashSphere,a='    ';for(let s in o){let n=i.getGraphCls.convertLabel2Resid(s),c=i.firstAtomObjCls.getFirstAtomObj(i.residues[n]),h=c.color?c.color.getHexString():"";for(let n in o[s]){let p=i.getGraphCls.convertLabel2Resid(n),m=i.firstAtomObjCls.getFirstAtomObj(i.residues[p]),u=m.color?m.color.getHexString():"",g=o[s][n].split("_"),f=g[0],b=g[1];c=g[2],m=g[3];let C=g[4];e?(l+=' '+s+"@"+c+a+h+d+' '+n+"@"+m+a+u+d+''+C+''+f+''+b+"","view"==t&&(l+=''),l+=""):l+=""+s+""+n+''+C+''+f+''+b+"",++r}}let c='

    '+r+" residue pairs in "+(e?"the contacts":"sphere")+":

    ";if(r>0&&(e?(c+='
    ',"view"==t&&(c+=''),c+=""):c+='
    Residue 1Residue 2Num ContactsMin Distance(Å)C-alpha Distance(Å)Highlight in 3D
    ',c+=l,c+="
    Residue 1Residue 2Num ContactsMin Distance(Å)C-alpha Distance(Å)

    "),"graph"==t||"linegraph"==t||"scatterplot"==t||"calpha"==t||"cbeta"==t||"heavyatoms"==t){return i.getGraphCls.getGraphLinks(o,o,n.htmlCls.contactColor,s,n.htmlCls.contactValue)}return c}}class Ut{constructor(e){this.icn3d=e}drawGraph(e,t){var s=this.icn3d,i=s.icn3dui;if(void 0===n)var n=d3;var l=JSON.parse(e),r=$("#"+t).width(),o=$("#"+t).height(),a=isNaN(r)?300:1*r,d=isNaN(o)?300:1*o,c=r,h=o,p=d3.select("#"+i.svgid).attr("width",r).attr("height",o).attr("viewBox","0,0,"+a+","+d);p.selectAll(".g-main").remove();var m=p.append("g").classed("g-main",!0),u=m.append("rect").attr("width",c).attr("height",h).style("fill","#FFF"),g=m.append("g"),f=n.zoom().on("zoom",(function(){g.attr("transform",n.event.transform)}));if(m.call(f),l.links){for(var b=[],C={},y=0,v=l.nodes.length;y0?n.structures[0]:n.defaultPdbId;p=10*(a.length+2)+20+30,h=10*(d.length+2)+20+30,t?(n.alignerrormapWidth=2*h,u=n.alignerrormapWidth,m=l.alignerrormapid):(n.contactmapWidth=2*h,u=n.contactmapWidth,m=l.contactmapid),i=o.length>0?"":"No interactions found for these two sets

    ",i+="";if(t){n.hex2id={};let e=29/s;n.hex2skip={};let t=1e3;for(let s=0;se&&(n.hex2skip[d]=c)}}if(i+=n.lineGraphCls.drawScatterplot_base(a,d,o,c,0,!0,void 0,void 0,t),g+=n.getGraphCls.updateGraphJson(f,1,a,d,o),i+="",g+="}\n",t){n.alignerrormapStr=g,$("#"+n.pre+"alignerrormapDiv").html(i);let e=$("#"+l.alignerrormapid+"_scale").val();$("#"+l.alignerrormapid).attr("width",(n.alignerrormapWidth*parseFloat(e)).toString()+"px")}else n.contactmapStr=g,$("#"+n.pre+"contactmapDiv").html(i);return i}}class $t{constructor(e){this.icn3d=e}async downloadAlignment(e,t){let s=this.icn3d,i=s.icn3dui,n=this;s.opts.proteins="c alpha trace";let l=e.split(","),r="ids="+e,o=i.htmlCls.baseUrl+"vastplus/vastplus.cgi?v=3&cmd=c&b=1&s=1&w3d&"+r;void 0!==i.cfg.inpara&&(o+=i.cfg.inpara),s.pdbid_chain2title={},void 0===s.chainids2resids&&(s.chainids2resids={});let a={},d="These two MMDB IDs "+l+' do not have 3D alignment data in the VAST+ database. You can try the VAST alignment by visiting the VAST+ page https://www.ncbi.nlm.nih.gov/Structure/vastplus/vastplus.cgi?uid=[PDB ID] (e.g., uid=1KQ2), and clicking "Original VAST"',c=await i.getAjaxPromise(o,"jsonp",!0,d);if(a=c.seqalign,void 0===a)return alert(d),!1;s.pdbid_molid2chain={},s.chainsColor={};for(let e=0,t=2;e5){let t=!1,s=!0;d=await r.pdbParserCls.loadPdbData(e,n,!1,t,"target",h,s)}else{let t=!0;d=await r.mmdbParserCls.parseMmdbData(e,"target",i[0],0,h,t)}for(let e=0,s=t.length;e5){let s=!0,i=!0;c=await r.pdbParserCls.loadPdbData(t[e],l,!1,s,"query",h,i)}else{let s=!0;c=await r.mmdbParserCls.parseMmdbData(t[e],"query",i[e+1],e,h,s)}d=o.hashUtilsCls.unionHash(d,c)}if(o.cfg.resnum)await r.realignParserCls.realignChainOnSeqAlign(s,i);else if(o.cfg.resdef)await r.realignParserCls.realignChainOnSeqAlign(s,i,void 0,!0);else{await r.pdbParserCls.applyCommandDssp(!0);for(let e in r.pdbChainIndexHash){let t=r.pdbChainIndexHash[e].split("_");l=t[0],t[1],n=t[2],t[3],a.transformStructure(l,e-1,"query")}let e=[],t=[],c=[],h=o.htmlCls.baseUrl+"vastdyn/vastdyn.cgi",p=o.htmlCls.baseUrl+"tmalign/tmalign.cgi";for(let s in r.afChainIndexHash){let i=r.afChainIndexHash[s].split("_");l=i[0];let a=i[1];n=i[2];let d,m=i[3];if("tmalign"!=o.cfg.aligntool){let e={domains1:r.domain3dCls.getDomainJsonForAlign(r.chains[l+"_"+a]),domains2:r.domain3dCls.getDomainJsonForAlign(r.chains[n+"_"+m])};d=o.getAjaxPostPromise(h,e)}else{let e={pdb_query:r.saveFileCls.getAtomPDB(r.chains[l+"_"+a]),pdb_target:r.saveFileCls.getAtomPDB(r.chains[n+"_"+m])};d=o.getAjaxPostPromise(p,e)}e.push(d),t.push(s-1),c.push(l)}let m=Promise.allSettled(e);try{let e=await m;await a.downloadChainalignmentPart2b(s,i,d,e,t,n,c)}catch(e){r.bRender&&alert("These structures can NOT be aligned to each other...")}}}async downloadChainalignmentPart2b(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui;for(let e=0,t=i.length;ed&&(d=n[t[0]],o=t[0]),n[t[1]]>d&&(d=n[t[1]],o=t[1])}let c={},h={},p={},m={};for(let e in l){let t,s,i=e.split("_"),n=l[e].split(","),r=n[2];o==i[0]?(t=i[0],s=i[1]):o==i[1]?(t=i[1],s=i[0]):(t=i[0],s=i[1]),p[t]=1,p.hasOwnProperty(s)||(p[s]=1,m[e]=l[e],a="target",this.transformStructure(t,r,a),a="query",this.transformStructure(s,r,a),c[n[0]]=1,c[n[1]]=1)}for(let e in m)if(void 0!==s.q_rotation){let t=m[e].split(","),n=[t[1],t[0],t[2]],l=s.setSeqAlignCls.setSeqAlignChain(void 0,void 0,n);h=i.hashUtilsCls.unionHash(h,l);let r=!1,o=i.htmlCls.alignSeqCls.getAlignSequencesAnnotations(Object.keys(s.alnChains),void 0,void 0,!1,void 0,r),a=$("#"+s.pre+"dl_sequence2").html();$("#"+s.pre+"dl_sequence2").html(a+o.sequencesHtml),$("#"+s.pre+"dl_sequence2").width(i.htmlCls.RESIDUE_WIDTH*o.maxSeqCnt+200)}s.dAtoms=i.hashUtilsCls.cloneHash(h),s.hAtoms=i.hashUtilsCls.cloneHash(h);let u="protein_aligned";s.selectionCls.saveSelection(u,u),s.opts.color="identity",s.setColorCls.setColorByOptions(s.opts,s.hAtoms),i.htmlCls.dialogCls.openDlg("dl_alignment","Select residues in aligned sequences"),s.drawCls.draw(),s.transformCls.zoominSelection(),s.hlUpdateCls.updateHlAll()}transformStructure(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=n.structures[e];for(let e=0,o=r.length;e2){let e=i.firstAtomObjCls.getResiduesFromAtoms(s),t="protein_aligned",n="protein aligned",l="select "+i.resid2specCls.residueids2spec(Object.keys(e));i.selectionCls.addCustomSelection(Object.keys(e),t,n,l,!0)}i.hlUpdateCls.updateHlAll(),void 0!==n.cfg.rotate&&i.resizeCanvasCls.rotStruc(n.cfg.rotate,!0),i.html2ddgm="",n.cfg.show2d&&i.bFullUi&&(n.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions"),i.bFullUi&&(i.bChainAlign?await i.ParserUtilsCls.set2DDiagramsForChainalign(t):i.ParserUtilsCls.download2Ddgm(i.inputid.toUpperCase())))}addPostfixForChainids(e){let t=this.icn3d;t.icn3dui;let s={};for(let i=0,n=e.length;i5?(c="https://alphafold.ebi.ac.uk/files/AF-"+i.mmdbid_t+"-F1-model_"+i.AFUniprotVersion+".pdb",d=n.getAjaxPromise(c,"text")):(c=n.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+n.cfg.bu+"&uid="+i.mmdbid_t,void 0!==n.cfg.inpara&&(c+=n.cfg.inpara),d=n.getAjaxPromise(c,"jsonp")),h.push(d),i.ParserUtilsCls.setYourNote(e.toUpperCase()+" in iCn3D"),i.pdbid_chain2title={},void 0===i.chainids2resids&&(i.chainids2resids={}),i.afChainIndexHash={},i.pdbChainIndexHash={};for(let e=1,t=r.length;e5?(t="https://alphafold.ebi.ac.uk/files/AF-"+i.mmdbid_q+"-F1-model_"+i.AFUniprotVersion+".pdb",s=n.getAjaxPromise(t,"text")):(t=n.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+n.cfg.bu+"&uid="+i.mmdbid_q,void 0!==n.cfg.inpara&&(t+=n.cfg.inpara),s=n.getAjaxPromise(t,"jsonp")),h.push(s)}for(let e=1,t=r.length;e0?o[e]+","+o[0]:void 0;if("tmalign"!=n.cfg.aligntool&&4==i.mmdbid_t.length&&4==i.mmdbid_q.length){let r;r=o.length>0?n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?domainpairs="+l:n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainpairs="+t;let a=n.getAjaxPromise(r,"jsonp");h.push(a),i.pdbChainIndexHash[e]=s+"_"+i.chain_q+"_"+i.mmdbid_t+"_"+i.chain_t}else i.afChainIndexHash[e]=i.mmdbid_q+"_"+i.chain_q+"_"+i.mmdbid_t+"_"+i.chain_t}}let p=Promise.allSettled(h);try{let e=await p;await l.parseChainAlignData(e,r,i.mmdbid_t,i.chain_t)}catch(e){let t="tmalign"==n.cfg.aligntool?"TM-align":"VAST";i.bRender&&alert("These chains can not be aligned by "+t+". You can specify the residue range and try it again...")}}async parseChainAlignData(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=e[0].value,o="HEADER "+s+"\n";isNaN(s)&&s.length>5&&(r=o+r),n.t_trans_add=[],n.q_trans_sub=[],"tmalign"==l.cfg.aligntool&&(n.q_trans_add=[]),n.q_rotation=[],n.qt_start_end=[],n.mmdbidArray=[],n.mmdbidArray.push(s);let a=[];for(let s=1,i=t.length;s5&&(i=o+i),void 0===i||-1!==JSON.stringify(i).indexOf("Oops there was a problem"))return void alert("The coordinate data can NOT be retrieved for the structure "+r+"...");n.mmdbidArray.push(r),a.push(i)}let d=0;for(let r=1,o=t.length;r";"tmalign"==o.cfg.aligntool&&(n+="TM-score: "+e[0].score.toPrecision(4)+"

    "),$("#"+r.pre+"dl_rmsd").html(n),o.cfg.bSidebyside||o.htmlCls.dialogCls.openDlg("dl_rmsd","RMSD of alignment"),a=!0}return a}async loadOpmDataForChainalign(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=this;if(l.cfg.resnum||l.cfg.resdef)n.bCommandLoad||n.init(),await this.downloadChainalignmentPart2(e,t,void 0,s);else{let o=l.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?mmdbids2opm="+i.join("','");try{let i=(await l.getAjaxPromise(o,"jsonp")).mmdbid;if(n.selectedPdbid=i,i){let o="https://opm-assets.storage.googleapis.com/pdb/"+i.toLowerCase()+".pdb";try{let a=await l.getAjaxPromise(o,"text");n.bOpm=!0;let d=!0,c=n.loadPDBCls.loadPDB(a,i,n.bOpm,d);$("#"+n.pre+"selectplane_z1").val(n.halfBilayerSize),$("#"+n.pre+"selectplane_z2").val(-n.halfBilayerSize),$("#"+n.pre+"extra_mem_z").val(n.halfBilayerSize),$("#"+n.pre+"intra_mem_z").val(-n.halfBilayerSize),n.bCommandLoad||n.init(),await r.downloadChainalignmentPart2(e,t,c,s)}catch(i){return n.bCommandLoad||n.init(),void await r.downloadChainalignmentPart2(e,t,void 0,s)}}else n.bCommandLoad||n.init(),await r.downloadChainalignmentPart2(e,t,void 0,s)}catch(i){return n.bCommandLoad||n.init(),void await r.downloadChainalignmentPart2(e,t,void 0,s)}}}async downloadMmdbAf(e,t,s){let i=this.icn3d,n=i.icn3dui,l=this;i.structArray=i.structures?Object.keys(i.structures):[],0==i.structArray.length?i.init():(i.resetConfig(),i.bResetAnno=!0,i.bResetSets=!0);let r=e.split(","),o=[];for(let e=0,t=r.length;e5?(t="https://alphafold.ebi.ac.uk/files/AF-"+l+"-F1-model_"+i.AFUniprotVersion+".pdb",s=n.getAjaxPromise(t,"text")):(t=n.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+n.cfg.bu+"&uid="+l,void 0!==n.cfg.inpara&&(t+=n.cfg.inpara),s=n.getAjaxPromise(t,"jsonp")),a.push(s)}i.ParserUtilsCls.setYourNote(i.structArray+" in iCn3D"),i.ParserUtilsCls.showLoading();let d=Promise.allSettled(a);try{let e=await d;await l.parseMMdbAfData(e,o,t,s),void 0===s&&i.ParserUtilsCls.hideLoading()}catch(e){alert("There are some problems in retrieving the coordinates...")}}async parseMMdbAfData(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=[];for(let s=0,i=t.length;s5&&(i=n+i),void 0===i||-1!==JSON.stringify(i).indexOf("Oops there was a problem"))return void alert("The coordinate data can NOT be retrieved for the structure "+t[s]+"...");r.push(i)}let o={},a={},d=!1;n.opts.color=n.structArray.length>1?"structure":t[0].length>5?"confidence":"chain";for(let e=0,i=t.length;e5){let s=!1;a=await n.pdbParserCls.loadPdbData(r[e],t[e],!1,c,i,d,s)}else{let t=!0;a=await n.mmdbParserCls.parseMmdbData(r[e],i,void 0,void 0,d,t)}o=l.hashUtilsCls.unionHash(o,a)}if(n.structArray.length>1&&(n.opts.color="structure"),n.setColorCls.setColorByOptions(n.opts,n.atoms),await n.ParserUtilsCls.renderStructure(),void 0!==l.cfg.rotate&&n.resizeCanvasCls.rotStruc(l.cfg.rotate,!0),s&&l.cfg.matchedchains){let e=!0,t=!0;await n.realignParserCls.realignChainOnSeqAlign(void 0,n.chainidArray,e,t),$("#"+n.pre+"dl_annotations").html(""),n.bAnnoShown=!1,$("#"+n.pre+"dl_selectannotations").dialog("isOpen")&&$("#"+n.pre+"dl_selectannotations").dialog("close")}else if(void 0!==i){let e=Object.keys(n.structures);await n.vastplusCls.vastplusAlign(e,i)}}}class Bt{constructor(e){this.icn3d=e}dsn6Parser(e,t,s){this.icn3d.icn3dui;let i="https://edmaps.rcsb.org/maps/"+e.toLowerCase()+"_"+t+".dsn6";this.dsn6ParserBase(i,t,s)}dsn6ParserBase(e,t,s){let i=this.icn3d;i.icn3dui;let n=this;if("2fofc"==t&&i.bAjax2fofc)i.mapData.sigma2=s,i.setOptionCls.setOption("map",t);else if("fofc"==t&&i.bAjaxfofc)i.mapData.sigma=s,i.setOptionCls.setOption("map",t);else{let l=new XMLHttpRequest;l.open("GET",e,!0),l.responseType="arraybuffer",l.onreadystatechange=function(){if(4==this.readyState)if(200==this.status){let e=l.response;n.loadDsn6Data(e,t,s),"2fofc"==t?i.bAjax2fofc=!0:"fofc"==t&&(i.bAjaxfofc=!0),i.setOptionCls.setOption("map",t)}else alert("RCSB server has no corresponding eletron density map for this structure.");else i.ParserUtilsCls.showLoading()},l.send()}}loadDsn6Data(e,t,s){let i=this.icn3d;i.icn3dui;let n,l,r={},o=e.buffer&&e.buffer instanceof ArrayBuffer?e.buffer:e,a=new Int16Array(o),d=new Uint8Array(o),c=String.fromCharCode.apply(null,d.subarray(0,512));if(0==c.indexOf(":-)"))r.xStart=parseInt(c.substr(10,5)),r.yStart=parseInt(c.substr(15,5)),r.zStart=parseInt(c.substr(20,5)),r.xExtent=parseInt(c.substr(32,5)),r.yExtent=parseInt(c.substr(38,5)),r.zExtent=parseInt(c.substr(42,5)),r.xRate=parseInt(c.substr(52,5)),r.yRate=parseInt(c.substr(58,5)),r.zRate=parseInt(c.substr(62,5)),r.xlen=1*parseFloat(c.substr(73,10)),r.ylen=1*parseFloat(c.substr(83,10)),r.zlen=1*parseFloat(c.substr(93,10)),r.alpha=parseFloat(c.substr(103,10)),r.beta=parseFloat(c.substr(113,10)),r.gamma=parseFloat(c.substr(123,10)),n=parseFloat(c.substr(138,12))/100,l=parseInt(c.substr(155,8)),r.sigma=100*parseFloat(c.substr(170,12));else{if(100!==a[18])for(let e=0,t=a.length;e>8&255}r.zStart=a[2],r.xStart=a[0],r.yStart=a[1],r.xExtent=a[3],r.yExtent=a[4],r.zExtent=a[5],r.xRate=a[6],r.yRate=a[7],r.zRate=a[8];let e=1/a[17],t=1*e;r.xlen=a[9]*t,r.ylen=a[10]*t,r.zlen=a[11]*t,r.alpha=a[12]*e,r.beta=a[13]*e,r.gamma=a[14]*e,n=a[15]/a[18],l=a[16]}let h=new Float32Array(r.xExtent*r.yExtent*r.zExtent),p=512,m=Math.ceil(r.xExtent/8),u=Math.ceil(r.yExtent/8),g=Math.ceil(r.zExtent/8);for(let e=0;es.maxatomcnt&&(s.bAssembly=!0)}if("mmtfid"===t&&void 0!==o.missingseq){let t=0,n="";for(let l=0,r=o.missingseq.length;lt)&&(s.chainMissingResidueArray[c].push(h),t=d,n=a)}s.loadPDBCls.adjustSeq(s.chainMissingResidueArray)}}async loadMmcifData(e,t){let s=this.icn3d;if(s.icn3dui,t||(t=e.mmcif),t||(t=s.defaultPdbId),void 0===e.atoms)return!1;s.init(),void 0!==e.emd&&(s.emd=e.emd),void 0!==e.organism&&(s.organism=e.organism),void 0!==s.emd?($("#"+s.pre+"mapWrapper1").hide(),$("#"+s.pre+"mapWrapper2").hide(),$("#"+s.pre+"mapWrapper3").hide()):($("#"+s.pre+"emmapWrapper1").hide(),$("#"+s.pre+"emmapWrapper2").hide(),$("#"+s.pre+"emmapWrapper3").hide()),await s.opmParserCls.loadOpmData(e,t,void 0,"mmcif")}}class Gt{constructor(e){this.icn3d=e}async downloadMmdb(e,t){let s,i=this.icn3d,n=i.icn3dui;try{if(s=await this.loadMmdbPrms(e,t),!s||s.error)return void this.getNoData(e,t)}catch(s){return void this.getNoData(e,t)}if(0!=Object.keys(s.atoms).length)if(n.utilsCls.isCalphaPhosOnly(s.atoms)||s.atomCount<=i.maxatomcnt)await this.parseMmdbData(s);else{let s;try{s=await this.loadMmdbPrms(e,t,!0)}catch(s){return void this.getNoData(e,t)}await this.parseMmdbData(s)}else{let e=s.pdbId;i.mmtfParserCls.downloadMmtf(e)}}async downloadGi(e){let t=this.icn3d;t.icn3dui,t.bCid=void 0;await this.downloadMmdb(e,!0)}async downloadBlast_rep_id(e){let t=this.icn3d,s=t.icn3dui,i=e.split(",");s.cfg.query_id=i[0],s.cfg.blast_rep_id=i[1];let n=s.cfg.blast_rep_id.split("_")[0];4==n.length?await this.downloadMmdb(n):(t.blastAcxn=s.cfg.blast_rep_id.split(".")[0],await this.downloadRefseq(t.blastAcxn,!0))}async downloadRefseq(e,t){let s=this.icn3d,i=s.icn3dui,n=i.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?refseq2uniprot="+e;i.cfg.refseqid=e;let l=await i.getAjaxPromise(n,"jsonp",!1,"The protein accession "+e+" can not be mapped to AlphaFold UniProt ID...");if(!l||!l.uniprot)return void alert("The accession "+e+" can not be mapped to AlphaFold UniProt ID. It will be treated as a UniProt ID instead.");i.cfg.afid=l.uniprot,t&&(i.cfg.blast_rep_id=i.cfg.afid+"_A");await s.pdbParserCls.downloadPdb(i.cfg.afid,!0)}getNoData(e,t){let s=this.icn3d.icn3dui;t?alert("This gi "+e+" has no corresponding 3D structure..."):alert("This mmdbid "+e+" with the parameters "+s.cfg.inpara+" may not have 3D structure data. Please visit the summary page for details: "+s.htmlCls.baseUrl+"pdb/"+e)}async parseMmdbData(e,t,s,i,n,l){let r,o=this.icn3d,a=o.icn3dui,d=void 0!==e.pdbId?e.pdbId:e.mmdbId;this.parseMmdbDataPart1(e,t),void 0===t?(void 0!==e.opm&&void 0!==e.opm.rot&&(o.bOpm=!0,o.opmParserCls.setOpmData(e)),r=o.loadAtomDataCls.loadAtomDataIn(e,d,"mmdbid",void 0,t)):(s&&(d=s.substr(0,s.indexOf("_"))),r=o.loadAtomDataCls.loadAtomDataIn(e,d,"mmdbid",void 0,t,s,i,n,l));let c=e.pdbId;void 0===t&&o.ParserUtilsCls.setYourNote(c.toUpperCase()+"(MMDB) in iCn3D");for(let t in e.domains){let s=e.domains[t].chain,i=c+"_"+s,n=e.domains[t].domains;for(let e=0,t=n.length;et.maxatomcnt){let i=!1;if(0==Object.keys(s).length)return void alert("This PDB structure is not found at RCSB...");await t.opmParserCls.loadOpmData(s,e,i,"mmtf")}else s=null,MMTF.fetch(e,(async function(s){0!=Object.keys(s).length?await t.opmParserCls.loadOpmData(s,e,!0,"mmtf"):alert("This PDB structure is not found at RCSB...")}),(function(e){}))}),(function(e){}))}async parseMmtfData(e,t,s){let i=this.icn3d,n=i.icn3dui;e.numAtoms,i.init();let l=new THREE.Vector3(9999,9999,9999),r=new THREE.Vector3(-9999,-9999,-9999),o=new THREE.Vector3,a=e.structureId;if(i.molTitle=e.title,void 0!==e.bioAssemblyList&&void 0!==e.bioAssemblyList[0]&&e.bioAssemblyList[0].transformList.length>1){i.biomtMatrices=[];for(let t=0,s=e.bioAssemblyList[0].transformList.length;t1&&($("#"+i.pre+"assemblyWrapper").show(),i.asuCnt=i.biomtMatrices.length);let d,c,h,p,m,u,g,f,b,C,y,v,w,_,S,A,x,k,O,R={},E=[],I="coil",T="",M=0,P=0,D={onModel:function(e){d=0===e.modelIndex?a:a+(e.modelIndex+1).toString()},onChain:function(e){c=e.chainName;let t=d+"_"+c;void 0===i.structures[d]&&(i.structures[d]=[]),i.structures[d].push(t)},onGroup:function(e){h=e.groupName,p=e.groupId;let t=d+"_"+c+"_"+p;m=0===e.secStruct||2===e.secStruct||4===e.secStruct?"helix":3===e.secStruct?"sheet":-1===e.secStruct?"other":"coil";let s=!1;if(c!==T){if(x=void 0,O=void 0,"coil"!==m&&"other"!==m?(u=!0,g=!1):(u=!1,g=!1),"coil"!==I&&"other"!==I){let e=d+"_"+T+"_"+M.toString();for(let t in i.residues[e])i.atoms[t].ssbegin=!1,i.atoms[t].ssend=!0}}else x=A,O=k,m!==I?"coil"===I||"other"===I?(u=!0,g=!1):"coil"===m||"other"===m?(s=!0,u=!1,g=!1):("sheet"===I&&"helix"===m||"helix"===I&&"sheet"===m)&&(s=!0,u=!0,g=!1):(u=!1,g=!1);if(s&&!isNaN(p)){let e=d+"_"+c+"_"+(p-1).toString();for(let t in i.residues[e])i.atoms[t].ssbegin=!1,i.atoms[t].ssend=!0}I=m,T=c,M=p,f=!1,b=!1,C=!1,"non-polymer"===e.chemCompType.toLowerCase()||"other"===e.chemCompType.toLowerCase()||-1!==e.chemCompType.toLowerCase().indexOf("saccharide")?f=!0:-1!==e.chemCompType.toLowerCase().indexOf("peptide")?b=!0:-1!==e.chemCompType.toLowerCase().indexOf("dna")||-1!==e.chemCompType.toLowerCase().indexOf("rna")?C=!0:b=!0;let l=d+"_"+c,r={};r.resi=p,r.name=n.utilsCls.residueName2Abbr(h),i.residueId2Name[t]=r.name,r.resi%10==0&&r.resi.toString();let o="-";"helix"===m?o="H":"sheet"===m?o="E":"coil"===m?o="c":"other"===m&&(o="o"),void 0===i.chainsSeq[l]&&(i.chainsSeq[l]=[]),i.bFullUi&&i.chainsSeq[l].push(r),i.secondaries[t]=o},onAtom:function(e){if(y=e.element,v=e.atomName,w=new THREE.Vector3(e.xCoord,e.yCoord,e.zCoord),_=e.bFactor,S=e.altLoc,"\0"===e.altLoc&&(S=""),""===S||"A"===S){++P,"SG"===v&&E.push(P),R[e.atomIndex]=P;let t={het:f,serial:P,name:v,alt:S,resn:h,structure:d,chain:c,resi:p,coord:w,b:_,elem:y,bonds:[],bondOrder:[],ss:m,ssbegin:u,ssend:g};if(t.het||"C"!==t.name||(A=P),t.het||"O"!==t.name||(k=P),!t.het&&"N"===t.name&&void 0!==x&&void 0!==O){let e=i.atoms[x].coord.distanceTo(i.atoms[O].coord),s=t.coord.x+(i.atoms[x].coord.x-i.atoms[O].coord.x)/e,n=t.coord.y+(i.atoms[x].coord.y-i.atoms[O].coord.y)/e,l=t.coord.z+(i.atoms[x].coord.z-i.atoms[O].coord.z)/e;t.hcoord=new THREE.Vector3(s,n,l)}i.atoms[P]=t,l.min(w),r.max(w),o.add(w);let a=d+"_"+c,I=a+"_"+p;void 0===i.chains[a]&&(i.chains[a]={}),i.chains[a][P]=1,void 0===i.residues[I]&&(i.residues[I]={}),i.residues[I][P]=1,b?(i.proteins[P]=1,"CA"===v&&(i.calphas[P]=1),"N"!==v&&"H"!==v&&"CA"!==v&&"HA"!==v&&"C"!==v&&"O"!==v&&(i.sidec[P]=1)):C?(i.nucleotides[P]=1,(!s||"O3'"!=v&&"O3*"!=v)&&(s||"P"!=v)||(i.nucleotidesO3[P]=1),-1===n.parasCls.nuclMainArray.indexOf(v)&&(i.ntbase[P]=1)):y.toLowerCase()===h.toLowerCase()?i.ions[P]=1:"HOH"===h||"WAT"===h||"SQL"===h||"H2O"===h||"W"===h||"DOD"===h||"D3O"===h?i.water[P]=1:i.chemicals[P]=1,i.dAtoms[P]=1,i.hAtoms[P]=1}},onBond:function(e){let t=R[e.atomIndex1],s=R[e.atomIndex2];if(R.hasOwnProperty(e.atomIndex1)&&R.hasOwnProperty(e.atomIndex2)&&(i.atoms[t].bonds.push(s),i.atoms[s].bonds.push(t),f)){let n=e.bondOrder;i.atoms[t].bondOrder.push(n),i.atoms[s].bondOrder.push(n),2===n?(i.doublebonds[t+"_"+s]=1,i.doublebonds[s+"_"+t]=1):3===n&&(i.triplebonds[t+"_"+s]=1,i.triplebonds[s+"_"+t]=1)}}};MMTF.traverse(e,D),i.loadPDBCls.setResidMapping();for(let e=0,t=E.length;ei.maxatomcnt||void 0!==i.biomtMatrices&&i.biomtMatrices.length*i.cnt>10*i.maxatomcnt)&&(i.opts.proteins="c alpha trace",i.opts.nucleotides="o3 trace"),i.pmin=l,i.pmax=r,i.center=i.ParserUtilsCls.getGeoCenter(i.pmin,i.pmax),i.maxD=i.ParserUtilsCls.getStructureSize(i.atoms,i.pmin,i.pmax,i.center),i.maxD<5&&(i.maxD=5),i.oriMaxD=i.maxD,i.oriCenter=i.center.clone(),i.ParserUtilsCls.transformToOpmOri(t),void 0===n.cfg.align&&1==Object.keys(i.structures).length&&$("#"+i.pre+"alternateWrapper").hide(),i.setStyleCls.setAtomStyleByOptions(i.opts),i.setColorCls.setColorByOptions(i.opts,i.atoms),await i.ParserUtilsCls.renderStructure(),i.saveFileCls.showTitle(),void 0!==n.cfg.rotate&&i.resizeCanvasCls.rotStruc(n.cfg.rotate,!0)}}class Wt{constructor(e){this.icn3d=e}async loadMol2Data(e){let t=this.icn3d,s=t.icn3dui,i=this.loadMol2AtomData(e);void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),i?(t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.atoms),await t.ParserUtilsCls.renderStructure(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0)):alert("The Mol2 file has the wrong format...")}loadMol2AtomData(e){let t=this.icn3d;t.icn3dui;let s=e.split(/\r?\n|\r/);if(s.length<4)return!1;t.init();let i,n,l="LIG",r={},o="1_A",a=0,d=0,c=1,h=!1,p=!1,m={},u={};for(let e=0,o=s.length;eMOLECULE"==o){t.molTitle=s[e+1].trim();let l=s[e+2].trim().replace(/\s+/g," ").split(" ");i=l[0],n=l[1],e+=4}else"@ATOM"==o?(c=1,h=!0,++e):"@BOND"==o?(p=!0,h=!1,++e):"@SUBSTRUCTURE"==o&&(p=!1,++e);if(o=s[e].trim(),""!==o&&"#"!==o.substr(0,1)){if(h&&a1&&($("#"+l.pre+"assemblyWrapper").show(),l.asuCnt=l.biomtMatrices.length),l.setStyleCls.setAtomStyleByOptions(l.opts),l.setColorCls.setColorByOptions(l.opts,l.atoms),await l.ParserUtilsCls.renderStructure(),void 0!==r.cfg.rotate&&l.resizeCanvasCls.rotStruc(r.cfg.rotate,!0)}else"pdb"===i?await l.pdbParserCls.loadPdbData(e,t):"align"===i&&(l.bOpm?await l.alignParserCls.downloadAlignmentPart2(t):void 0!==n?await this.loadOpmData(e,n,s,i):await l.alignParserCls.downloadAlignmentPart2(t))}}class Xt{constructor(e){this.icn3d=e}async downloadPdb(e,t){let s,i=this.icn3d,n=i.icn3dui;t?(s="https://alphafold.ebi.ac.uk/files/AF-"+e+"-F1-model_"+i.AFUniprotVersion+".pdb",n.cfg.refseqid?i.ParserUtilsCls.setYourNote(n.cfg.refseqid.toUpperCase()+"(NCBI Protein Acc.) in iCn3D"):i.ParserUtilsCls.setYourNote(e.toUpperCase()+"(AlphaFold) in iCn3D")):(s="https://files.rcsb.org/view/"+e+".pdb",i.ParserUtilsCls.setYourNote(e.toUpperCase()+"(PDB) in iCn3D"));let l=await n.getAjaxPromise(s,"text",!0,"The ID "+e+" can not be found in the server "+s+"...");if(t){l="HEADER "+e+"\n"+l,await i.opmParserCls.parseAtomData(l,e,void 0,"pdb",void 0)}else await i.opmParserCls.loadOpmData(l,e,void 0,"pdb")}async downloadUrl(e,t,s){let i=this.icn3d,n=i.icn3dui,l=e.lastIndexOf("/");if(-1!=l){let t=e.lastIndexOf(".");i.filename=e.substr(l+1,t-l-1)}else{let t=e.lastIndexOf(".");i.filename=e.substr(0,t)}let r=await n.getAjaxPromise(e,"text",!0);if(i.InputfileData=i.InputfileData?i.InputfileData+"\nENDMDL\n"+r:r,i.InputfileType=t,"pdb"===t)await this.loadPdbData(r);else if("mmcif"===t){let e=n.htmlCls.baseUrl+"mmcifparser/mmcifparser.cgi",t={mmciffile:r},s=await n.getAjaxPostPromise(e,t,!0);await i.mmcifParserCls.loadMmcifData(s,void 0)}else if("mol2"===t)await i.mol2ParserCls.loadMol2Data(r);else if("sdf"===t)await i.sdfParserCls.loadSdfData(r);else if("xyz"===t)await i.xyzParserCls.loadXyzData(r);else if("mmcif"===t)await i.mmcifParserCls.loadMmcifData(r);else if("icn3dpng"===t)await n.htmlCls.setHtmlCls.loadPng(r,s);else if("pae"===t){n.htmlCls.dialogCls.openDlg("dl_alignerrormap","Show Predicted Aligned Error (PAE) map");let e=!0;i.contactMapCls.processAfErrorMap(JSON.parse(r),e)}}async loadPdbData(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui;if(!i&&(void 0===n||"target"===n)){let e=!!o.bCommandLoad;o.bStatefile||o.init(e)}let d=o.loadPDBCls.loadPDB(e,t,s,void 0,void 0,i,n,l);void 0===a.cfg.opmid&&o.ParserUtilsCls.transformToOpmOri(t),void 0!==o.biomtMatrices&&o.biomtMatrices.length>1&&(a.bNode||$("#"+o.pre+"assemblyWrapper").show(),o.asuCnt=o.biomtMatrices.length),a.bNode||(void 0!==o.emd?($("#"+o.pre+"mapWrapper1").hide(),$("#"+o.pre+"mapWrapper2").hide(),$("#"+o.pre+"mapWrapper3").hide()):($("#"+o.pre+"emmapWrapper1").hide(),$("#"+o.pre+"emmapWrapper2").hide(),$("#"+o.pre+"emmapWrapper3").hide()));let c=!1;return o.bSecondaryStructure&&1==Object.keys(o.structures).length?c=!1:a.cfg.mmtfid||a.cfg.pdbid||a.cfg.opmid||a.cfg.mmdbid||a.cfg.gi||a.cfg.uniprotid||a.cfg.blast_rep_id||a.cfg.cid||a.cfg.mmcifid||a.cfg.align||a.cfg.chainalign||(c=!0),(!o.bSecondaryStructure||c)&&Object.keys(o.proteins).length>0&&!r?await this.applyCommandDssp(i):(await this.loadPdbDataRender(i),a.bNode||await o.ParserUtilsCls.checkMemProteinAndRotate()),d}async applyCommandDssp(e){let t=this.icn3d,s=t.icn3dui,i=s.utilsCls.isCalphaPhosOnly(s.hashUtilsCls.hash2Atoms(t.proteins,t.atoms));await t.dsspCls.applyDssp(i,e)}async loadPdbDataRender(e){let t=this.icn3d,s=t.icn3dui;void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),s.cfg.afid&&!t.bAfMem&&(t.opts.color="confidence"),t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.hAtoms),await t.ParserUtilsCls.renderStructure(),t.saveFileCls.showTitle(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0),e&&t.definedSetsCls.setModeAndDisplay("all")}}class Kt{constructor(e){this.icn3d=e}async downloadCid(e){let t=this.icn3d,s=t.icn3dui;t.ParserUtilsCls.setYourNote("PubChem CID "+e+" in iCn3D"),t.bCid=!0;let i="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/"+t.inputid+"/cids/JSONP?cids_type=parent",n="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/"+(await s.getAjaxPromise(i,"jsonp",!0,"Can not retrieve the parant CID...")).IdentifierList.CID[0]+"/record/SDF/?record_type=3d&response_type=display",l=await s.getAjaxPromise(n,"text",!0,"This CID may not have 3D structure..."),r=this.loadSdfAtomData(l,e);void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),r?(t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.atoms),await t.ParserUtilsCls.renderStructure(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0)):alert("The SDF of CID "+e+" has the wrong format...")}async loadSdfData(e){let t=this.icn3d,s=t.icn3dui,i=this.loadSdfAtomData(e);void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),i?(t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.atoms),await t.ParserUtilsCls.renderStructure(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0)):alert("The SDF file has the wrong format...")}loadSdfAtomData(e,t){let s=this.icn3d;s.icn3dui;let i=e.split(/\r?\n|\r/);if(i.length<4)return!1;s.init();let n=t||1,l="LIG",r=n,o=n+"_A",a=o+"_1",d=parseInt(i[3].substr(0,3));if(isNaN(d)||d<=0)return!1;let c=parseInt(i[3].substr(3,3)),h=4;if(i.lengthr||(Math.abs(t.coord.y-i.coord.y)>r||Math.abs(t.coord.z-i.coord.z)>r||l.utilsCls.hasCovalentBond(t,i)&&(n.atoms[o[e]].bonds.push(o[s]),n.atoms[o[s]].bonds.push(o[e])))}}}loadXyzAtomData(e){let t=this.icn3d;t.icn3dui;let s=e.split(/\r?\n|\r/);if(s.length<3)return!1;t.init();let i,n,l,r={},o=0,a=1;t.molTitle="";for(let e=0,d=s.length;e1&&(t.molTitle+="; "),t.molTitle+=s[e+1].trim(),e+=2),d=s[e].trim(),""===d)continue;let c=d.replace(/,/," ").replace(/\s+/g," ").split(" "),h=c[0],p=parseFloat(c[1]),m=parseFloat(c[2]),u=parseFloat(c[3]),g={het:!0,serial:a,name:h,resn:"LIG",structure:l,chain:"A",resi:1,coord:new THREE.Vector3(p,m,u),b:0,elem:h,bonds:[],ss:"coil",ssbegin:!1,ssend:!1,bondOrder:[]};t.atoms[a]=g,r[a]=1,++a}return this.setXyzAtomSeq(r,o,i,n),t.ParserUtilsCls.setMaxD(),t.saveFileCls.showTitle(),!0}}class Jt{constructor(e){this.icn3d=e}realign(){let e=this.icn3d,t=e.icn3dui;e.selectionCls.saveSelectionPrep();let s="alseq_"+Object.keys(e.defNames2Atoms).length;e.selectionCls.saveSelection(s,s),t.htmlCls.clickMenuCls.setLogCmd("realign",!0);let i={},n={};e.realignResid={};let l="";for(let s in e.hAtoms){let r=e.atoms[s],o=r.structure+"_"+r.chain;if(e.proteins.hasOwnProperty(s)&&"CA"==r.name||e.nucleotides.hasOwnProperty(s)&&("O3'"==r.name||"O3*"==r.name)){if(r.structure+"_"+r.resi==l)continue;i.hasOwnProperty(r.structure)||(i[r.structure]=[]),i[r.structure].push(r.coord.clone()),e.realignResid.hasOwnProperty(o)||(e.realignResid[o]=[]),e.realignResid[o].push({resid:o+"_"+r.resi,resn:t.utilsCls.residueName2Abbr(r.resn.substr(0,3)).substr(0,1)}),n[r.structure]=r.structure+"_"+r.chain,l=r.structure+"_"+r.resi}}let r=Object.keys(i),o=r[0],a=[];e.qt_start_end=[],a.push(n[o]);for(let t=1,s=r.length;t5){let e=r.cfg.chainalign.split(",");e.length>0&&(l.hAtoms=l.definedSetsCls.getAtomsFromNameArray(e)),r.cfg.aligntool="tmalign",await l.realignParserCls.realignOnStructAlign()}else l.hAtoms=l.chainalignParserCls.setMsa(e),l.transformCls.zoominSelection(),await l.chainalignParserCls.downloadChainalignmentPart3(void 0,e,l.hAtoms)}async parseChainRealignData(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui,d=s[0].substr(0,s[0].indexOf("_"));r||(d=d.toUpperCase());let c={};o.realignResid={},o.opts.color="grey",o.setColorCls.setColorByOptions(o.opts,o.dAtoms),o.qt_start_end=[];for(let t=0,h=e.length;t=6&&C.length>=6&&!a.cfg.command&&o.bRender&&alert("These sequences can not be aligned to each other")):o.bRender&&alert("Please do not align residues in the same structure")}if(r){o.hAtoms=o.chainalignParserCls.setMsa(s);let e="protein_aligned";if(o.selectionCls.saveSelection(e,e),o.bAfMem?(o.selectionCls.selectAll_base(),o.opts.chemicals="stick",o.opts.color="confidence",o.setColorCls.setColorByOptions(o.opts,o.atoms)):(o.transformCls.zoominSelection(),o.dAtoms=a.hashUtilsCls.cloneHash(o.hAtoms),o.opts.color="identity",o.setColorCls.setColorByOptions(o.opts,o.hAtoms)),o.drawCls.draw(),o.hlUpdateCls.updateHlAll(),o.bAfMem){let e=new THREE.Vector3(1,0,0),t=-.5*Math.PI;o.transformCls.setRotation(e,t)}}else o.hAtoms=o.chainalignParserCls.setMsa(s),o.transformCls.zoominSelection(),await o.chainalignParserCls.downloadChainalignmentPart3(t,s,o.hAtoms)}async realignOnSeqAlign(e){let t=this.icn3d;t.icn3dui;let s=t.firstAtomObjCls.getChainsFromAtoms(t.hAtoms),i=Object.keys(s),n=[],l="";for(let e=0,t=i.length;ef&&(f=s)}}}return{data:n,min:g,max:f}}(e.getCategory("_volume_data_3d").getColumn("values"),o,n.sampleCount,l);return{name:n.name,spacegroup:function(e,t,s){let i=Math.PI/180*s[0],n=Math.PI/180*s[1],l=Math.PI/180*s[2],r=t[0],o=t[1],a=t[2],d=Math.cos(n),c=(Math.cos(i)-Math.cos(n)*Math.cos(l))/Math.sin(l),h=Math.sqrt(1-d*d-c*c);return{number:e,size:t,angles:s,basis:{x:[r,0,0],y:[Math.cos(l)*o,Math.sin(l)*o,0],z:[d*a,c*a,h*a]}}}(n.spacegroupNumber,n.cellSize,n.cellAngles),box:{origin:r(n.origin),dimensions:r(n.dimensions),sampleCount:o},data:a.data,valuesInfo:{min:a.min,max:a.max,mean:n.mean,sigma:n.sigma}}}BinaryParse(e){this.icn3d.icn3dui;let t=new Uint8Array(e),s=this.MessagePackParse({buffer:t,offset:0,dataView:new DataView(t.buffer)}),i=function(){function e(e){this.additionalData={},this.header=e.header,this.categoryList=e.categories.map((function(e){return new n(e)})),this.categoryMap=new Map;for(let e=0,t=this.categoryList;e=0;s--)t=c(t,e.encoding[s]);return t}function p(e){if(!e.data.data)return _UndefinedColumn;let t,s=h(e.data);return e.mask&&(t=h(e.mask)),s.buffer&&s.byteLength&&s.BYTES_PER_ELEMENT?t?new f(s,t):new g(s):t?new C(s,t):new b(s)}function m(e,t,s){let i=0,n=1;for(45===e.charCodeAt(t)&&(n=-1,t++);t9||s<0)return n*i|0;i=10*i+s|0}return n*i}function u(e,t,s){let i=1,n=0,l=0,r=1;for(45===e.charCodeAt(t)&&(i=-1,++t);t=0&&o<10)){if(-2===o){for(++t;t=0&&o<10))return 53===o||21===o?parseScientific(i*(n+l/r),e,t+1,s):i*(n+l/r);l=10*l+o,r*=10,++t}return i*(n+l/r)}if(53===o||21===o)return parseScientific(i*n,e,t+1,s);break}n=10*n+o,++t}return i*n}let g=function(){function e(e){this.data=e,this.isDefined=!0}return e.prototype.getString=function(e){return""+this.data[e]},e.prototype.getInteger=function(e){return 0|this.data[e]},e.prototype.getFloat=function(e){return 1*this.data[e]},e.prototype.stringEquals=function(e,t){return this.data[e]===u(t,0,t.length)},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return 0},e}(),f=function(){function e(e,t){this.data=e,this.mask=t,this.isDefined=!0}return e.prototype.getString=function(e){return 0===this.mask[e]?""+this.data[e]:null},e.prototype.getInteger=function(e){return 0===this.mask[e]?this.data[e]:0},e.prototype.getFloat=function(e){return 0===this.mask[e]?this.data[e]:0},e.prototype.stringEquals=function(e,t){return 0===this.mask[e]?this.data[e]===u(t,0,t.length):null==t},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return this.mask[e]},e}(),b=function(){function e(e){this.data=e,this.isDefined=!0}return e.prototype.getString=function(e){return this.data[e]},e.prototype.getInteger=function(e){let t=this.data[e];return m(t,0,t.length)},e.prototype.getFloat=function(e){let t=this.data[e];return u(t,0,t.length)},e.prototype.stringEquals=function(e,t){return this.data[e]===t},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return 0},e}(),C=function(){function e(e,t){this.data=e,this.mask=t,this.isDefined=!0}return e.prototype.getString=function(e){return 0===this.mask[e]?this.data[e]:null},e.prototype.getInteger=function(e){if(0!==this.mask[e])return 0;let t=this.data[e];return m(t||"",0,(t||"").length)},e.prototype.getFloat=function(e){if(0!==this.mask[e])return 0;let t=this.data[e];return u(t||"",0,(t||"").length)},e.prototype.stringEquals=function(e,t){return this.data[e]===t},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return this.mask[e]},e}(),y=function(){function e(e){this.dataBlocks=e.dataBlocks.map((function(e){return new i(e)}))}return e.prototype.toJSON=function(){return this.dataBlocks.map((function(e){return e.toJSON()}))},e}();return new y(s)}MessagePackParse(e){this.icn3d.icn3dui;let t=this;function s(e,s){let i={};for(let n=0;n0&&(i[i.length]=l.slice(0,a).join(""));return i.join("")}(e.buffer,e.offset,t);return e.offset+=t,s}let r=function(){let e=[];for(let t=0;t<1024;t++)e[t]=String.fromCharCode(t);return e}();let o,a,d=e.buffer[e.offset];if(0==(128&d))return e.offset++,d;if(128==(240&d))return a=15&d,e.offset++,s(e,a);if(144==(240&d))return a=15&d,e.offset++,n(e,a);if(160==(224&d))return a=31&d,e.offset++,l(e,a);if(224==(224&d))return o=e.dataView.getInt8(e.offset),e.offset++,o;switch(d){case 192:return e.offset++,null;case 194:return e.offset++,!1;case 195:return e.offset++,!0;case 196:return a=e.dataView.getUint8(e.offset+1),e.offset+=2,i(e,a);case 197:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,i(e,a);case 198:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,i(e,a);case 202:return o=e.dataView.getFloat32(e.offset+1),e.offset+=5,o;case 203:return o=e.dataView.getFloat64(e.offset+1),e.offset+=9,o;case 204:return o=e.buffer[e.offset+1],e.offset+=2,o;case 205:return o=e.dataView.getUint16(e.offset+1),e.offset+=3,o;case 206:return o=e.dataView.getUint32(e.offset+1),e.offset+=5,o;case 208:return o=e.dataView.getInt8(e.offset+1),e.offset+=2,o;case 209:return o=e.dataView.getInt16(e.offset+1),e.offset+=3,o;case 210:return o=e.dataView.getInt32(e.offset+1),e.offset+=5,o;case 217:return a=e.dataView.getUint8(e.offset+1),e.offset+=2,l(e,a);case 218:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,l(e,a);case 219:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,l(e,a);case 220:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,n(e,a);case 221:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,n(e,a);case 222:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,s(e,a);case 223:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,s(e,a)}}}class es{constructor(e){this.icn3d=e}alignCoords(e,t,s,i,n,l,r,o){let a,d=this.icn3d,c=d.icn3dui,h=e.length=4&&(d.rmsd_suprTmp=c.rmsdSuprCls.getRmsdSuprCls(e,t,h),void 0!==d.rmsd_suprTmp.rot)){let e=d.rmsd_suprTmp.rot;null===e[0]&&alert("Please select more residues in each structure...");let t=d.rmsd_suprTmp.trans1,i=d.rmsd_suprTmp.trans2;if(a=d.rmsd_suprTmp.rmsd,a){c.htmlCls.clickMenuCls.setLogCmd("realignment RMSD: "+a.toPrecision(4),!1);let e="
    Realignment RMSD: "+a.toPrecision(4)+" Å

    ";d.bAfMem&&(e+=c.utilsCls.getMemDesc()),$("#"+d.pre+"dl_rmsd").html(e),c.cfg.bSidebyside||c.htmlCls.dialogCls.openDlg("dl_rmsd","Realignment RMSD")}let r={};for(let n=0,l=d.structures[s].length;n"+s.diagram2dCls.set2DdgmNote(!0),$("#"+s.pre+"dl_2ddgm").html(s.html2ddgm),s.b2DShown=!0}async set2DDiagramsForChainalign(e){let t=this.icn3d.icn3dui,s=this;t.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions");let i=[];for(let s=0,n=e.length;s"+s.diagram2dCls.set2DdgmNote(!0),s.b2DShown=!0,$("#"+s.pre+"dl_2ddgm").html(s.html2ddgm),i.cfg.show2d&&i.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions")}download2Ddgm(e,t){this.set2DDiagrams(e)}set2DDiagrams(e){let t=this.icn3d;t.icn3dui.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions"),void 0!==t.b2DShown&&t.b2DShown||(t.html2ddgm="",t.diagram2dCls.draw2Ddgm(t.interactionData,e),t.html2ddgm+="
    "+t.diagram2dCls.set2DdgmNote(),$("#"+t.pre+"dl_2ddgm").html(t.html2ddgm)),t.b2DShown=!0}showLoading(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"wait")&&$("#"+e.pre+"wait").show(),$("#"+e.pre+"canvas")&&$("#"+e.pre+"canvas").hide(),$("#"+e.pre+"cmdlog")&&$("#"+e.pre+"cmdlog").hide()}hideLoading(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"wait")&&$("#"+e.pre+"wait").hide(),$("#"+e.pre+"canvas")&&$("#"+e.pre+"canvas").show(),$("#"+e.pre+"cmdlog")&&$("#"+e.pre+"cmdlog").show()}setYourNote(e){let t=this.icn3d,s=t.icn3dui;t.yournote=e,$("#"+t.pre+"yournote").val(t.yournote),s.cfg.shownote&&(document.title=t.yournote)}transformToOpmOri(e){let t=this.icn3d;if(t.icn3dui,void 0!==t.rmsd_supr&&void 0!==t.rmsd_supr.rot){let s=t.rmsd_supr.rot,i=t.rmsd_supr.trans1,n=t.rmsd_supr.trans2;t.rmsd_supr.rmsd;let l=0;for(let e in t.atoms){let r=t.atoms[e];r.coord=t.surfaceCls.transformMemPro(r.coord,s,i,n);let o=r.coord.x*r.coord.x+r.coord.y*r.coord.y;Math.abs(r.coord.z)<=25&&o>l&&(l=o)}this.addMemAtoms(t.halfBilayerSize,e,Math.sqrt(l)),t.bStopRotate=!0,t.bOpm=!0,$("#"+t.pre+"togglememli").show(),$("#"+t.pre+"adjustmemli").show(),$("#"+t.pre+"selectplaneli").show()}else t.bOpm=!1}transformToOpmOriForAlign(e,t,s){let i=this.icn3d,n=i.icn3dui;if(void 0!==t){let l=i.loadPDBCls.getChainCalpha(i.chains,i.atoms,s,e),r=1==Object.keys(l.chainresiCalphaHash).length||1==Object.keys(t.chainresiCalphaHash).length,o=[],a=[];for(let e in l.chainresiCalphaHash)if(t.chainresiCalphaHash.hasOwnProperty(e)){let s=l.chainresiCalphaHash[e],i=t.chainresiCalphaHash[e];if((s.length==i.length||r)&&(o=o.concat(s),a=a.concat(i)),o.length>500)break}let d=o.length=4)if(i.rmsd_supr=n.rmsdSuprCls.getRmsdSuprCls(o,a,d),void 0!==i.rmsd_supr.rot&&i.rmsd_supr.rmsd<.1){let s=i.rmsd_supr.rot,l=i.rmsd_supr.trans1,r=i.rmsd_supr.trans2,o=i.rmsd_supr.rmsd;n.htmlCls.clickMenuCls.setLogCmd("RMSD of alignment to OPM: "+o.toPrecision(4),!1);let a=0;for(let e in i.atoms){let t=i.atoms[e];t.coord=i.surfaceCls.transformMemPro(t.coord,s,l,r);let n=t.coord.x*t.coord.x+t.coord.y*t.coord.y;Math.abs(t.coord.z)<=25&&n>a&&(a=n)}i.center=t.center,i.oriCenter=i.center.clone(),this.addMemAtoms(i.halfBilayerSize,e,Math.sqrt(a)),i.bStopRotate=!0,i.bOpm=!0,$("#"+i.pre+"togglememli").show(),$("#"+i.pre+"adjustmemli").show(),$("#"+i.pre+"selectplaneli").show()}else i.bOpm=!1;else i.bOpm=!1}}addOneDumAtom(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui,a={het:!0,serial:++l,name:t,alt:void 0,resn:"DUM",structure:e,chain:"MEM",resi:1,coord:new THREE.Vector3(s,i,n),b:void 0,elem:t,bonds:[],ss:"",ssbegin:!1,ssend:!1,color:o.parasCls.atomColors[t]};return r.atoms[l]=a,r.chains[e+"_MEM"][l]=1,r.residues[e+"_MEM_1"][l]=1,r.chemicals[l]=1,r.dAtoms[l]=1,r.hAtoms[l]=1,l}addMemAtoms(e,t,s){let i=this.icn3d;if(i.icn3dui,!t)return;t=t?t.toUpperCase():i.defaultPdbId,i.structures[t].push(t+"_MEM"),i.chains[t+"_MEM"]={},i.residues[t+"_MEM_1"]={},i.chainsSeq[t+"_MEM"]=[{name:"DUM",resi:1}];let n=Object.keys(i.atoms).length;for(let e=0;e<1e3;++e)if(!i.atoms.hasOwnProperty(n+e)){n=n+e-1;break}for(let i=0;i<81;++i)for(let l=0;l<81;++l){let r=2*i-80,o=2*l-80;if(Math.sqrt(r*r+o*o)=2?$("#"+e.pre+"mn2_alternateWrap").show():$("#"+e.pre+"mn2_alternateWrap").hide(),setTimeout((async function(){if(e.bInitial){if(void 0!==t.cfg.align||void 0!==t.cfg.chainalign){let s=e.pre+"selection";if($("#"+s).show(),$("#"+s+"_expand").hide(),$("#"+s+"_shrink").show(),void 0!==t.cfg.align&&2!=t.cfg.atype){let s=!1,i=t.htmlCls.alignSeqCls.getAlignSequencesAnnotations(Object.keys(e.alnChains),void 0,void 0,s);$("#"+e.pre+"dl_sequence2").html(i.sequencesHtml),$("#"+e.pre+"dl_sequence2").width(t.htmlCls.RESIDUE_WIDTH*i.maxSeqCnt+200)}}if(t.cfg.showanno){let s="view annotations";t.htmlCls.clickMenuCls.setLogCmd(s,!0),await e.showAnnoCls.showAnnotations()}t.cfg.closepopup&&e.resizeCanvasCls.closeDialogs()}else e.hlUpdateCls.updateHlAll();$("#"+e.pre+"atomsCustom").length>0&&$("#"+e.pre+"atomsCustom")[0].blur(),e.bInitial=!1}),0)}processCommand(){let e=this.icn3d,t=e.icn3dui;if(1==Object.keys(e.structures).length){let s=Object.keys(e.structures)[0];t.cfg.command=t.cfg.command.replace(new RegExp("!","g"),s+"_")}}getMassCenter(e,t){return this.icn3d.icn3dui,e.multiplyScalar(1/t)}getGeoCenter(e,t){return this.icn3d.icn3dui,e.clone().add(t).multiplyScalar(.5)}getStructureSize(e,t,s,i){let n=this.icn3d;n.icn3dui;let l=0;for(let r in e){let e=n.atoms[r].coord;if(Math.round(t.x)==Math.round(e.x)||Math.round(t.y)==Math.round(e.y)||Math.round(t.z)==Math.round(e.z)||Math.round(s.x)==Math.round(e.x)||Math.round(s.y)==Math.round(e.y)||Math.round(s.z)==Math.round(e.z)){let t=2*e.distanceTo(i);t>l&&(l=t)}}return l}async checkMemProteinAndRotate(){let e=this.icn3d,t=e.icn3dui;if(!e.bCheckMemProtein){e.bCheckMemProtein=!0;let s=t.cfg.afid?t.cfg.afid:t.cfg.mmdbafid;if(await e.ParserUtilsCls.checkMemProtein(s),t.cfg.url&&-1!=t.cfg.url.indexOf("membranome")){let t=new THREE.Vector3(1,0,0),s=-.5*Math.PI;e.transformCls.setRotation(t,s)}}}async checkMemProtein(e){let t=this.icn3d,s=t.icn3dui;try{let i=s.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?afid2mem="+e,n=await s.getAjaxPromise(i,"jsonp");if(n&&n.pdbid){let e='This is a single-spanning (bitopic) transmembrane protein according to the Membranome database. Do you want to align the protein with the model from Membranome? If you click "OK", you can press the letter "a" to alternate the structures.';if("off"==s.cfg.afmem);else if("on"==s.cfg.afmem||confirm(e))try{let e="https://storage.googleapis.com/membranome-assets/pdb_files/proteins/"+n.pdbid+".pdb",i=await s.getAjaxPromise(e,"text");t.bAfMem=!0,s.bNode||$("#"+s.pre+"togglememli").show();let l=n.pdbid.substr(0,n.pdbid.indexOf("_")),r=!0,o=!0;await t.pdbParserCls.loadPdbData(i,l,r,o),o&&(t.bSetChainsAdvancedMenu&&t.definedSetsCls.showSets(),t.bAnnoShown&&await t.showAnnoCls.showAnnotations());let a=n.segment.replace(/ /gi,"").split("(")[0];t.afmem_start_end=a.split("-"),t.hAtoms={},t.dAtoms={};for(let e in t.atoms)t.atoms[e].structure!=l&&(t.hAtoms[e]=1),t.dAtoms[e]=1;for(let e=parseInt(t.afmem_start_end[0]);e<=parseInt(t.afmem_start_end[1]);++e)t.hAtoms=s.hashUtilsCls.unionHash(t.hAtoms,t.residues[l+"_A_"+e]);await t.realignParserCls.realignOnSeqAlign(l)}catch(e){return void console.log("Error in retrieving matched PDB from Membranome...")}}}catch(e){return void console.log("Error in finding matched PDB in Membranome...")}}getResi(e,t){let s=this.icn3d;s.icn3dui;let i=s.ncbi2resid[e+"_"+(t+1).toString()];return i?i.substr(i.lastIndexOf("_")+1):""}getResiNCBI(e,t){let s=this.icn3d;s.icn3dui;let i=s.resid2ncbi[e+"_"+t];return i?parseInt(i.substr(i.lastIndexOf("_")+1)):0}}class ts{constructor(e){this.icn3d=e}loadAtomDataIn(e,t,s,i,n,l,r,o,a){let d=this.icn3d,c=d.icn3dui;d.pmin=new THREE.Vector3(9999,9999,9999),d.pmax=new THREE.Vector3(-9999,-9999,-9999),d.psum=new THREE.Vector3;let h=e.atoms,p=d.atoms?Object.keys(d.atoms).length:0,m={},u={};d.pmid=e.pubmedId,void 0===d.chainid2title&&(d.chainid2title={}),void 0===d.chainid2sid&&(d.chainid2sid={});let g={},f={};if("align"===s){d.pmid="",d.molTitle="",c.cfg.inpara&&-1!==c.cfg.inpara.indexOf("atype=1")?d.molTitle="Invariant Core Structure Alignment (VAST) of ":c.cfg.inpara&&-1!==c.cfg.inpara.indexOf("atype=2")?d.molTitle="Structure Alignment (TM-align) of ":d.molTitle="Structure Alignment (VAST) of ";let t=!1;for(let s=0,i=e.alignedStructures[0].length;s'+i.pdbId.toUpperCase()+"",void 0!==i.descr&&(d.pmid+=i.descr.pubmedid),0===s&&(d.molTitle+=" and ",void 0!==i.descr&&(d.pmid+="_")),t=!0}d.molTitle+=" from VAST+",t||(d.molTitle="")}else if(void 0!==e.descr&&(d.molTitle+=e.descr.name),"mmdbid"===s){let s=isNaN(t)?t:e.pdbId,i={};void 0===d.alignmolid2color&&(d.alignmolid2color=[]);let n=1;for(let t in e.moleculeInfor){if(0===Object.keys(e.moleculeInfor[t]).length)continue;let l=e.moleculeInfor[t].chain.trim(),r=s+"_"+l;i.hasOwnProperty(l)?(++i[l],r+=i[l]):i[l]=1,void 0!==d.mmdbid_q&&(d.mmdbid_q,d.mmdbid_t);let o=e.moleculeInfor[t].kind,a=e.moleculeInfor[t].color,c=e.moleculeInfor[t].sid;if(g[r]=o,f[r]=a,"protein"==o&&(d.organism=e.moleculeInfor[t].taxonomyName.toLowerCase()),void 0!==c&&(d.chainid2sid[r]=c),void 0===d.pdbid_chain2title&&(d.pdbid_chain2title={}),d.pdbid_chain2title[r]=e.moleculeInfor[t].name,l==r.substr(r.lastIndexOf("_"))){let e={};e[t]=n.toString(),d.alignmolid2color.push(e)}++n}}let b,C,y,v,w,_={},S="",A="",x="",k="",O="",R="",E=0,I=0,T="",M=!0,P=!1,D="",H=c.utilsCls.isCalphaPhosOnly(h),F=0,L={};for(let e in h){++p,_[e]=p;let i,n=h[e];n.serial=p,"mmdbid"===s||"mmcifid"===s?i=t:"align"===s&&(i=m[p]);let l=!1;if(void 0!==n.chain||"mmdbid"!==s&&"align"!==s)n.chain=""===n.chain?"Misc":n.chain;else if("mmdbid"===s)if(b=n.ids.m,void 0!==d.molid2chain[b]){let e=d.molid2chain[b].indexOf("_");n.chain=d.molid2chain[b].substr(e+1)}else{let e="Misc";("protein"===g[O]&&"nucleotide"===g[O]&&n.resi!=I||"protein"!==g[O]&&"nucleotide"!==g[O]&&(n.resn.substr(0,3)!=T.substr(0,3)||n.resi!=I||"solvent"===g[O]||"HOH"===n.resn))&&++F,n.resi_ori=n.resi,n.resi=F,l=!0,n.chain=e}else if("align"===s)if(b=n.ids.m,void 0!==d.pdbid_molid2chain[i+"_"+b])n.chain=d.pdbid_molid2chain[i+"_"+b];else{let e="Misc";("protein"===g[O]&&"nucleotide"===g[O]&&n.resi!=I||"protein"!==g[O]&&"nucleotide"!==g[O]&&(n.resn.substr(0,3)!=T.substr(0,3)||n.resi!=I||"solvent"===g[O]||"HOH"===n.resn))&&(++F,n.resi_ori=n.resi,n.resi=F,l=!0),n.chain=e}if(n.chain=n.chain.trim(),"mmdbid"!==s&&"align"!==s||(n.structure=i,"mmdbid"===s&&void 0!==d.mmdbid_q&&(d.mmdbid_q,d.mmdbid_t)),k=n.structure,O=k+"_"+n.chain,"mmdbid"===s||"align"===s){l||(n.resi_ori=n.resi,d.bUsePdbNum?n.resi=n.resi_ori:n.resi=n.ids.r);let e=n.resn.indexOf(" ");-1!==e&&0!=e&&(n.resn=n.resn.substr(0,e))}O!==A&&(E=0),n.resi!==E&&(O!==A?(y=void 0,w=void 0):(y=C,w=v)),n.coord="mmdbid"===s?new THREE.Vector3(n.coord[0],n.coord[1],n.coord[2]):new THREE.Vector3(n.coord.x,n.coord.y,n.coord.z);let r=c.utilsCls.residueName2Abbr(n.resn.substr(0,3));"mmdbid"!==s&&"align"!==s||!d.bFullUi||(void 0===d.mmdbMolidResid2mmdbChainResi&&(d.mmdbMolidResid2mmdbChainResi={}),d.mmdbMolidResid2mmdbChainResi[i+"_"+n.ids.m+"_"+n.ids.r]=i+"_"+n.chain+"_"+n.resi),d.pmin.min(n.coord),d.pmax.max(n.coord),d.psum.add(n.coord);let o=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"protein"===g[O]:"p"===n.mt,a=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"nucleotide"===g[O]:"n"===n.mt,u=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"solvent"===g[O]:"s"===n.mt,N=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"ligand"===g[O]||void 0!==g[O]&&-1!==g[O].indexOf("other")||void 0===g[O]:"l"===n.mt;if("Misc"!==n.chain&&"other"!==g[O]||"protein"===L[O]||"nucleotide"===L[O]||("CA"===n.name&&"C"===n.elem?L[O]="protein":"P"===n.name&&"P"===n.elem?L[O]="nucleotide":L[O]="chemical"),o||a?(o?(d.proteins[p]=1,"CA"===n.name&&(d.calphas[p]=1),"N"!==n.name&&"H"!==n.name&&"CA"!==n.name&&"HA"!==n.name&&"C"!==n.name&&"O"!==n.name&&(d.sidec[p]=1)):a&&(d.nucleotides[p]=1,("O3'"==n.name||"O3*"==n.name||H&&"P"==n.name)&&(d.nucleotidesO3[p]=1),-1===c.parasCls.nuclMainArray.indexOf(n.name)&&(d.ntbase[p]=1)),n.het=!1):u?(d.water[p]=1,n.het=!0):N&&("HOH"===n.resn||"O"===n.resn?d.water[p]=1:n.elem===n.resn?d.ions[p]=1:d.chemicals[p]=1,n.het=!0),"mmdbid"===s?n.het?n.color=c.parasCls.atomColors[n.elem]||c.parasCls.defaultAtomColor:n.color=void 0!==f[O]?c.parasCls.thr(f[O]):c.parasCls.chargeColors[n.resn]:void 0!==n.color&&(n.color=c.parasCls.thr(n.color))," "!==n.resn.charAt(0)&&" "===n.resn.charAt(1)&&(n.resn=n.resn.charAt(0)),n.het||"C"!==n.name||(C=p),n.het||"O"!==n.name||(v=p),!n.het&&"N"===n.name&&void 0!==y&&void 0!==w){let e=d.atoms[y].coord.distanceTo(d.atoms[w].coord),t=n.coord.x+(d.atoms[y].coord.x-d.atoms[w].coord.x)/e,s=n.coord.y+(d.atoms[y].coord.y-d.atoms[w].coord.y)/e,i=n.coord.z+(d.atoms[y].coord.z-d.atoms[w].coord.z)/e;n.hcoord=new THREE.Vector3(t,s,i)}"HOH"==n.resn&&(d.water[p]=1),d.atoms[p]=n,d.dAtoms[p]=1,d.hAtoms[p]=1;let U=n.structure+"_"+n.chain;void 0===d.chains[U]&&(d.chains[U]={}),d.chains[U][p]=1;let q=U+"_"+n.resi;void 0===d.residues[q]&&(d.residues[q]={}),d.residues[q][p]=1,R=O+"_"+n.resi,R!==x&&O!==A&&(M=!0,""!==S&&(void 0===d.structures[S]&&(d.structures[S]=[]),d.structures[S].push(A))),d.residueId2Name[q]=r;let $="-";if("helix"===n.ss?$="H":"sheet"===n.ss?$="E":n.het||a?$="o":(!n.het&&c.parasCls.residueColors.hasOwnProperty(n.resn.toUpperCase())||"coil"===n.ss)&&($="c"),d.secondaries[n.structure+"_"+n.chain+"_"+n.resi]=$,(n.resi!=E||b!=D)&&d.bFullUi&&(void 0===d.chainsSeq[U]&&(d.chainsSeq[U]=[],M=!1),!isNaN(n.resi)))if(M&&!P&&void 0!==d.chainsSeq[U][n.resi-1])d.chainsSeq[U][n.resi-1].name=r;else if(!M||!d.chainsSeq[U].hasOwnProperty(n.resi-1)){let e={};e.resi=n.resi,e.name=r,n.resi%10==0&&n.resi.toString(),d.chainsSeq[U].push(e),P=!0}E=n.resi,I=n.resi_ori,T=n.resn,S=k,A=O,x=R,D=b}for(let e in d.chemicals){let t=d.atoms[e];if("P"==t.elem&&t.bonds.length>=4)for(let e=t.bonds.length-1;e>=0;--e){"P"==d.atoms[t.bonds[e]].elem&&t.bonds.splice(e,1)}}for(let e in L)if(!(Object.keys(d.chains[e]).length<10)&&"chemical"!==L[e])for(let t in d.chains[e]){let s=d.atoms[t];delete d.chemicals[t],s.het=!1,"protein"===L[e]?(d.proteins[t]=1,"CA"===s.name&&(d.calphas[t]=1),"N"!==s.name&&"H"!==s.name&&"CA"!==s.name&&"HA"!==s.name&&"C"!==s.name&&"O"!==s.name&&(d.sidec[t]=1)):"nucleotide"===L[e]&&(d.nucleotides[t]=1,("O3'"==s.name||"O3*"==s.name||H&&"P"==s.name)&&(d.nucleotidesO3[t]=1),-1===c.parasCls.nuclMainArray.indexOf(s.name)&&(d.ntbase[t]=1))}if(void 0===d.structures[k]&&(d.structures[k]=[]),d.structures[k].push(O),d.bFullUi)if("mmdbid"===s||"mmcifid"===s)for(let i in e.sequences){let n=e.sequences[i],l=t+"_"+i;void 0!==d.mmdbid_q&&(d.mmdbid_q,d.mmdbid_t),d.ParserUtilsCls.getMissingResidues(n,s,l)}else if("align"===s)for(let e in d.chainid2seq){let t=d.chainid2seq[e];d.ParserUtilsCls.getMissingResidues(t,s,e)}if(d.loadPDBCls.setResidMapping(),"mmcifid"!==s)for(let e in h){let t=_[e],s=void 0===d.atoms[t].bonds?0:d.atoms[t].bonds.length;for(let e=0;ed.maxatomcnt||void 0!==d.biomtMatrices&&d.biomtMatrices.length*d.cnt>10*d.maxatomcnt)&&(d.opts.proteins="c alpha trace",d.opts.nucleotides="o3 trace"),d.center=d.ParserUtilsCls.getGeoCenter(d.pmin,d.pmax),d.maxD=d.ParserUtilsCls.getStructureSize(d.atoms,d.pmin,d.pmax,d.center),d.maxD<5&&(d.maxD=5),d.oriMaxD=d.maxD,("align"===s||o)&&(d.ssbondpnts={},d.loadPDBCls.setSsbond()),"mmdbid"===s&&1==Object.keys(d.structures).length){let t=e.disulfides;if(void 0!==t)for(let e=0,s=t.length;ep&&(p=e)),c[e]={resi:t,resn:i,aligned:n}}r=e[t][1];let u=r.moleculeId,g=s.pdbid_molid2chain[l+"_"+u],f=l+"_"+g;void 0===s.alnChainsAnTtl[d]&&(s.alnChainsAnTtl[d]=[]),void 0===s.alnChainsAnTtl[d][0]&&(s.alnChainsAnTtl[d][0]=[]),void 0===s.alnChainsAnTtl[d][1]&&(s.alnChainsAnTtl[d][1]=[]),void 0===s.alnChainsAnTtl[d][2]&&(s.alnChainsAnTtl[d][2]=[]),void 0===s.alnChainsAnTtl[d][3]&&(s.alnChainsAnTtl[d][3]=[]),void 0===s.alnChainsAnTtl[d][4]&&(s.alnChainsAnTtl[d][4]=[]),void 0===s.alnChainsAnTtl[d][5]&&(s.alnChainsAnTtl[d][5]=[]),void 0===s.alnChainsAnTtl[d][6]&&(s.alnChainsAnTtl[d][6]=[]),s.alnChainsAnTtl[d][0].push(f),s.alnChainsAnTtl[d][1].push(d),s.alnChainsAnTtl[d][2].push(""),s.alnChainsAnTtl[d][3].push(""),s.alnChainsAnTtl[d][4].push(f),s.alnChainsAnTtl[d][5].push(d),s.alnChainsAnTtl[d][6].push("");let b=1;s.chainsMapping[d]||(s.chainsMapping[d]={}),s.chainsMapping[f]||(s.chainsMapping[f]={});for(let e=h;e<=p;++e){let t,o,p,m=s.bUsePdbNum?s.ParserUtilsCls.getResi(f,r.sequence[e][0]-1):r.sequence[e][0],u="~"===r.sequence[e][2]?"-":r.sequence[e][2],C=r.sequence[e][3]?1:0,y=c[e].aligned+C;2===y?(c[e].resn===u?(t="#FF0000",p="icn3d-cons",s.consHash1[d+"_"+c[e].resi]=1,s.consHash2[f+"_"+m]=1):(t="#0000FF",p="icn3d-ncons",s.nconsHash1[d+"_"+c[e].resi]=1,s.nconsHash2[f+"_"+m]=1),s.chainsMapping[d][d+"_"+c[e].resi]=c[e].resn+c[e].resi,s.chainsMapping[f][f+"_"+m]=c[e].resn+c[e].resi,o="#"+s.showAnnoCls.getColorhexFromBlosum62(c[e].resn,u)):(t=i.htmlCls.GREY8,p="icn3d-nalign",s.nalignHash1[d+"_"+c[e].resi]=1,s.nalignHash2[f+"_"+m]=1),void 0===s.alnChainsSeq[d]&&(s.alnChainsSeq[d]=[]);let v={};v.mmdbid=n,v.chain=a,v.resi=c[e].resi,v.resn=""===v.resi||"icn3d-nalign"===p?c[e].resn.toLowerCase():c[e].resn,v.aligned=y,v.color=""===v.resi?i.htmlCls.GREYC:t,v.color2=""===v.resi?i.htmlCls.GREYC:o,v.class=p,s.alnChainsSeq[d].push(v),""!==c[e].resi&&(void 0===s.alnChains[d]&&(s.alnChains[d]={}),$.extend(s.alnChains[d],s.residues[d+"_"+c[e].resi])),void 0===s.alnChainsSeq[f]&&(s.alnChainsSeq[f]=[]),v={},v.mmdbid=l,v.chain=g,v.resi=m,v.resn=""===v.resi||"icn3d-nalign"===p?u.toLowerCase():u,v.aligned=y,v.color=""===v.resi?i.htmlCls.GREYC:t,v.color2=""===v.resi?i.htmlCls.GREYC:o,v.class=p,s.alnChainsSeq[f].push(v),""!==v.resi&&(void 0===s.alnChains[f]&&(s.alnChains[f]={}),$.extend(s.alnChains[f],s.residues[f+"_"+m])),void 0===s.alnChainsAnno[d]&&(s.alnChainsAnno[d]=[]),void 0===s.alnChainsAnno[d][0]&&(s.alnChainsAnno[d][0]=[]),void 0===s.alnChainsAnno[d][1]&&(s.alnChainsAnno[d][1]=[]),void 0===s.alnChainsAnno[d][2]&&(s.alnChainsAnno[d][2]=[]),void 0===s.alnChainsAnno[d][3]&&(s.alnChainsAnno[d][3]=[]),e===h&&(void 0===s.alnChainsAnno[d][4]&&(s.alnChainsAnno[d][4]=[]),void 0===s.alnChainsAnno[d][5]&&(s.alnChainsAnno[d][5]=[]),void 0===s.alnChainsAnno[d][6]&&(s.alnChainsAnno[d][6]=[]),s.alnChainsAnno[d][4].push(s.pdbid_chain2title[f]),s.alnChainsAnno[d][5].push(s.pdbid_chain2title[d]),s.alnChainsAnno[d][6].push(""));let w=d+"_"+c[e].resi,_=f+"_"+m,S=s.secondaries[w],A=s.secondaries[_];A?s.alnChainsAnno[d][0].push(A):s.alnChainsAnno[d][0].push("-"),S?s.alnChainsAnno[d][1].push(S):s.alnChainsAnno[d][1].push("-");let x=".";b%5==0&&(x="*"),b%10==0&&(x="|"),s.alnChainsAnno[d][2].push(x);let k="";b%10==0&&(k=b.toString()),s.alnChainsAnno[d][3].push(k),++b}}e={}}getPosFromResi(e,t){let s=this.icn3d;s.icn3dui;let i,n=s.resid2ncbi[e+"_"+t];if(n){i=n.substr(n.lastIndexOf("_")+1)-1}return i}getResnFromResi(e,t){let s=this.icn3d,i=s.icn3dui,n=this.getPosFromResi(e,t);if(!n)return"?";let l=e+"_"+t,r="";return r=void 0===s.residues[l]?s.chainsSeq[e][n]?s.chainsSeq[e][n].name:"?":i.utilsCls.residueName2Abbr(s.firstAtomObjCls.getFirstAtomObj(s.residues[l]).resn.substr(0,3)),r}setSeqAlignChain(e,t,s){let i,n,l,r,o,a,d,c,h,p,m,u=this.icn3d,g=u.icn3dui,f={},b=!!s;if(b){if(o=s[1],a=s[0],t=s[2],d=o.indexOf("_"),c=a.indexOf("_"),i=o.substr(0,d).toUpperCase(),n=a.substr(0,c).toUpperCase(),l=o.substr(d+1),r=a.substr(d+1),i==n&&l==r){let e=u.chainsSeq[n+"_"+r].length;u.qt_start_end[t]={q_start:1,q_end:e,t_start:1,t_end:e}}}else{let d=s[0].indexOf("_"),c=e.indexOf("_");if(i=u.mmdbid_t,n=e.substr(0,c).toUpperCase(),l=s[0].substr(d+1),r=e.substr(c+1),i==n&&l==r){let e=u.chainsSeq[u.mmdbid_q+"_"+u.chain_q].length;u.qt_start_end[t]={q_start:1,q_end:e,t_start:1,t_end:e}}o=i+"_"+l,a=n+"_"+r,void 0!==n&&u.mmdbid_t}u.conservedName1=o+"_cons",u.nonConservedName1=o+"_ncons",u.notAlignedName1=o+"_nalign",u.conservedName2=a+"_cons",u.nonConservedName2=a+"_ncons",u.notAlignedName2=a+"_nalign",u.consHash1={},u.nconsHash1={},u.nalignHash1={},u.consHash2={},u.nconsHash2={},u.nalignHash2={},u.alnChains={},u.alnChainsSeq[o]=[],u.alnChains[o]={},u.alnChainsSeq[a]=[],u.alnChains[a]={},u.alnChainsAnno[o]=[],u.alnChainsAnTtl[o]=[],void 0===u.alnChainsAnTtl[o]&&(u.alnChainsAnTtl[o]=[]);for(let e=0;e<7;++e)void 0===u.alnChainsAnTtl[o][e]&&(u.alnChainsAnTtl[o][e]=[]);u.alnChainsAnTtl[o][0].push(a),u.alnChainsAnTtl[o][1].push(o),u.alnChainsAnTtl[o][2].push(""),u.alnChainsAnTtl[o][3].push(""),u.alnChainsAnTtl[o][4].push(a),u.alnChainsAnTtl[o][5].push(o),u.alnChainsAnTtl[o][6].push("");let C=0,y=0;if(void 0===u.qt_start_end[t])return;let v=1;u.chainsMapping[o]||(u.chainsMapping[o]={}),u.chainsMapping[a]||(u.chainsMapping[a]={});let w={},_={};for(let e=0,s=u.qt_start_end[t].length;e0){let e=v;for(let t=C+1,i=s;tc&&(c=t)}}}"tmalign"==n.cfg.aligntool&&(s=!0);let p=Object.keys(a);p.sort((function(e,t){return parseInt(e)-parseInt(t)}));let m=-999,u=0,g=0,f=[],b=0;for(let e=0,t=p.length;e0&&i.resid2ncbi[t]!=i.resid2ncbi[m]+1&&i.resid2ncbi[t]!=i.resid2ncbi[m]){g=m;for(let e=0,t=f.length;ec)continue;let o={},p=r.indexOf("_");o.mmdbid=r.substr(0,p),o.chain=r.substr(p+1),o.resi=t,o.resn=a[t]?i.chainsSeq[r][e].name.toUpperCase():i.chainsSeq[r][e].name.toLowerCase(),o.aligned=!!a[t],o.color=a[t]?"#FF0000":n.htmlCls.GREYC,o.color2=a[t]?"#FF0000":n.htmlCls.GREYC,o.class=a[t]?"icn3d-align":"icn3d-nalign",i.alnChainsSeq[r].push(o),a[t]&&($.extend(i.alnChains[r],i.residues[r+"_"+o.resi]),l=n.hashUtilsCls.unionHash(l,i.residues[r+"_"+o.resi]))}let C=[0];for(let i=0,r=t.length;in)for(let e=0,t=u-m;e=n)for(let e=0,s=t-n;e0?void 0!==n?p.alnChainsAnno[t][0].push(n):p.alnChainsAnno[t][0].push("-"):console.log("Error: ic.alnChainsAnno[chainid1] is undefined")}}}class is{constructor(e){this.icn3d=e}getStructureId(e,t,s){let i=this.icn3d;i.icn3dui;let n=e;return(e==i.defaultPdbId||s)&&(n=1===t?e:e+t.toString()),n}loadPDB(e,t,s,i,n,l,r,o){let a,d,c=this.icn3d,h=c.icn3dui,p={},m=!1,u=e.split("\n"),g={},f={};c.atoms||(l=!1),n||l?(c.oriNStru=c.structures?Object.keys(c.structures).length:0,d=c.oriNStru+1,a=c.atoms?Object.keys(c.atoms).length:0):(c.init(),d=1,a=0);let b,C,y,v,w,_,S,A=[],x=[],k=[],O=[],R=[],E=[],I="",T="",M="",P={},D=t||c.defaultPdbId,H=D,F="",L=!1;for(let e in u){let r=u[e],o=r.substr(0,6);if("HEADER"!==o||L||t)if("TITLE "===o){let e=r.substr(10).replace(/ALPHAFOLD MONOMER V2.0 PREDICTION FOR /gi,"");c.molTitle+=e.trim()+" "}else if("HELIX "===o){c.bSecondaryStructure=!0;let e=""==r.substr(18,2).trim()?"A":r.substr(18,2).trim(),t=parseInt(r.substr(21,4)),s=parseInt(r.substr(33,4));for(let i=t;i<=s;++i){let n=H+"_"+e+"_"+i;O.push(n),i===t&&R.push(n),i===s&&E.push(n)}}else if("SHEET "===o){void 0!==s&&s||(c.bSecondaryStructure=!0);let e=""==r.substr(20,2).trim()?"A":r.substr(20,2).trim(),t=parseInt(r.substr(22,4)),i=parseInt(r.substr(33,4));for(let s=t;s<=i;++s){let n=H+"_"+e+"_"+s;A.push(n),s===t&&x.push(n),s===i&&k.push(n)}}else if("HBOND "===o)void 0!==s&&s||(c.bSecondaryStructure=!0);else if("SSBOND"===o){c.bSsbondProvided=!0;let e=D+"_"+(" "==r.substr(15,1)?"A":r.substr(15,1))+"_"+r.substr(17,4).trim(),t=D+"_"+(" "==r.substr(29,1)?"A":r.substr(29,1))+"_"+r.substr(31,4).trim();void 0===c.ssbondpnts[D]&&(c.ssbondpnts[D]=[]),c.ssbondpnts[D].push(e),c.ssbondpnts[D].push(t)}else if("REMARK"===o){let e=parseInt(r.substr(7,3));if(-1!==r.indexOf("1/2 of bilayer thickness:"))c.halfBilayerSize=parseFloat(r.substr(r.indexOf(":")+1).trim());else if(210==e)"EXPERIMENT TYPE"==r.substr(11,32).trim()&&"NMR"==r.substr(45).trim()&&(m=!0);else if(350==e&&"BIOMT"==r.substr(13,5)){let e=parseInt(r[18])-1,t=parseInt(r.substr(21,2))-1;null==c.biomtMatrices[t]&&(c.biomtMatrices[t]=(new THREE.Matrix4).identity()),c.biomtMatrices[t].elements[e]=parseFloat(r.substr(24,9)),c.biomtMatrices[t].elements[e+4]=parseFloat(r.substr(34,9)),c.biomtMatrices[t].elements[e+8]=parseFloat(r.substr(44,9)),c.biomtMatrices[t].elements[e+12]=parseFloat(r.substr(54,14))}else if(465==e&&" "==r.substr(18,1)&&" "==r.substr(20,1)&&"S"!=r.substr(21,1)){let e=r.substr(15,3),t=r.substr(18,2).trim(),s=r.substr(21,5).trim(),i=D+"_"+t;void 0===c.chainMissingResidueArray[i]&&(c.chainMissingResidueArray[i]=[]);let n={};n.resi=s,n.name=h.utilsCls.residueName2Abbr(e).toLowerCase(),""!=F&&t==F&&t!=F||(c.chainMissingResidueArray[i].push(n),F=t)}else 900==e&&void 0===c.emd&&"RELATED DB: EMDB"==r.substr(34).trim()&&(c.emd=r.substr(23,11).trim())}else if("SOURCE"===o&&void 0===c.organism&&"ORGANISM_COMMON"==r.substr(11,15).trim())c.organism=r.substr(28).toLowerCase().trim(),c.organism=c.organism.substr(0,c.organism.length-1);else if("ENDMDL"===o)++d,D=c.defaultPdbId,H=this.getStructureId(D,d,n),m||(A=[],x=[],k=[],O=[],R=[],E=[]),L=!1;else if("JRNL "===o)"PMID"===r.substr(12,4)&&(c.pmid=r.substr(19).trim());else if("ATOM "===o||"HETATM"===o){H=this.getStructureId(D,d,n);let e=r.substr(16,1);++a,P[parseInt(r.substr(6,5))]=a;let t=r.substr(76,2).trim();""===t&&(t=r.substr(12,2).trim());let l=r.substr(12,4).trim(),u=r.substr(17,3),F=r.substr(20,2).trim();""===F&&(F="A");let L=r.substr(22,5).trim(),N=L;if(s&&"DUM"===u&&(t=l,F="MEM",N=1,L=1),i&&"DUM"===u)break;b=H+"_"+F,y=b+"_"+L,C=b+"_"+N;let U=parseFloat(r.substr(30,8)),q=parseFloat(r.substr(38,8)),$=parseFloat(r.substr(46,8)),j=new THREE.Vector3(U,q,$),B={het:"H"===o[0],serial:a,name:l,alt:e,resn:u,structure:H,chain:F,resi:N,coord:j,b:parseFloat(r.substr(60,8)),elem:t,bonds:[],ss:"coil",ssbegin:!1,ssend:!1};if(B.het||"C"!==B.name||(v=a),B.het||"O"!==B.name||(_=a),!B.het&&"N"===B.name&&void 0!==w&&void 0!==S){let e=c.atoms[w].coord.distanceTo(c.atoms[S].coord),t=B.coord.x+(c.atoms[w].coord.x-c.atoms[S].coord.x)/e,s=B.coord.y+(c.atoms[w].coord.y-c.atoms[S].coord.y)/e,i=B.coord.z+(c.atoms[w].coord.z-c.atoms[S].coord.z)/e;B.hcoord=new THREE.Vector3(t,s,i)}c.atoms[a]=B,c.dAtoms[a]=1,c.hAtoms[a]=1,p[a]=1,this.isSecondary(C,A,m)?(c.atoms[a].ss="sheet",this.isSecondary(C,x,m)&&(c.atoms[a].ssbegin=!0),this.isSecondary(C,k,m)&&(c.atoms[a].ssend=!0)):this.isSecondary(C,O,m)&&(c.atoms[a].ss="helix",this.isSecondary(C,R,m)&&(c.atoms[a].ssbegin=!0),this.isSecondary(C,E,m)&&(c.atoms[a].ssend=!0));let z="-";if(z="helix"===c.atoms[a].ss?"H":"sheet"===c.atoms[a].ss?"E":!c.atoms[a].het&&h.parasCls.residueColors.hasOwnProperty(c.atoms[a].resn.toUpperCase())?"c":"o",c.secondaries[C]=z,y!==M){let e=h.utilsCls.residueName2Abbr(u);if(c.residueId2Name[C]=e,1!==a&&""!==T&&(c.residues[T]=f),C!==T&&(f={}),b!==I){w=void 0,S=void 0,1!==a&&""!==I&&(void 0===c.chains[I]&&(c.chains[I]={}),c.chains[I]=h.hashUtilsCls.unionHash(c.chains[I],g)),g={},void 0===c.structures[H.toString()]&&(c.structures[H.toString()]=[]),c.structures[H.toString()].includes(b)||c.structures[H.toString()].push(b),void 0===c.chainsSeq[b]&&(c.chainsSeq[b]=[]);let t={};t.resi=N,t.name=e,c.chainsSeq[b].push(t)}else{w=v,S=_;let t={};t.resi=N,t.name=e,c.chainsSeq[b].push(t)}}g[a]=1,f[a]=1,I=b,T=C,M=y}else if("CONECT"===o){let e=parseInt(r.substr(6,5));for(let t=0;t<4;++t){let s=parseInt(r.substr([11,16,21,26][t],5));isNaN(s)||void 0!==c.atoms[P[e]]&&c.atoms[P[e]].bonds.push(P[s])}}else"TER"===o.substr(0,3)&&++a;else D=r.substr(62).trim(),""==D&&(D=l?c.defaultPdbId:c.inputid&&-1==c.inputid.indexOf("/")?c.inputid.substr(0,10):c.defaultPdbId),H=this.getStructureId(D,d,n),c.molTitle="",L=!0}c.residues[C]=f,void 0===c.chains[b]&&(c.chains[b]={}),c.chains[b]=h.hashUtilsCls.unionHash2Atoms(c.chains[b],g,c.atoms),n||this.adjustSeq(c.chainMissingResidueArray);let N=Object.keys(c.structures);for(let e=0,t=N.length;e=l?n:l,o=new Array(s+i),a=0,d=0,c=0,h=!1;for(;ar&&i>r&&(h=!0),s<=r&&i>r?s>i||h?(o[c]=t[d],d++):(o[c]=e[a],a++):s>r&&i<=r?s<=i||h?(o[c]=e[a],a++):(o[c]=t[d],d++):s<=i?(o[c]=e[a],a++):(o[c]=t[d],d++),c++}if(a4||Math.abs(l.y-r.y)>4||Math.abs(l.z-r.z)>4||(l.x-r.x)*(l.x-r.x)+(l.y-r.y)*(l.y-r.y)+(l.z-r.z)*(l.z-r.z)<16&&(void 0===e.ssbondpnts[s]&&(e.ssbondpnts[s]=[]),e.ssbondpnts[s].push(o),e.ssbondpnts[s].push(a)))}}}getChainCalpha(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r={};for(let o in e){if(void 0!==i){if(o.split("_")[0]!==i)continue}let a=Object.keys(e[o]),d=[],c=0,h=0;for(let e=0,i=a.length;e3?i.resn.trim().substr(0,3):i.resn.trim();if(!l.parasCls.chargeColors.hasOwnProperty(e))continue;s?i.resi_ori:i.resi,d.push(i.coord.clone()),++c,h=i.resi}}if(c>0){r[t[a[0]].chain]=d}}return{chainresiCalphaHash:r,center:n.center.clone()}}isSecondary(e,t,s){if(this.icn3d.icn3dui,s){let s=e.substr(e.indexOf("_")+1),i=!1;for(let e=0,n=t.length;e0&&(d=!0);for(let n=0,l=t.length;na&&(a=l),s.push(l)}o.push(s)}if(!d)return void(n.bRender&&alert("These structures can not be aligned..."));a<1e-6&&(a=1);for(let e=0,s=t.length;ep[e]=4&&(n.rmsd_suprTmp=l.rmsdSuprCls.getRmsdSuprCls(c,a,p),void 0!==n.rmsd_suprTmp.rot))){let e=n.rmsd_suprTmp.rot;if(null===e[0])continue;let i=n.rmsd_suprTmp.trans1,r=n.rmsd_suprTmp.trans2,a=n.rmsd_suprTmp.rmsd;if(aRealignment RMSD: "+a.toPrecision(4)+" Å

    "),l.cfg.bSidebyside||l.htmlCls.dialogCls.openDlg("dl_rmsd","Realignment RMSD"),n.q_rotation=[],n.q_trans_sub=[],n.t_trans_add=[],n.q_rotation.push({x1:e[0],y1:e[1],z1:e[2],x2:e[3],y2:e[4],z2:e[5],x3:e[6],y3:e[7],z3:e[8]}),n.q_trans_sub.push(i),n.t_trans_add.push({x:-r.x,y:-r.y,z:-r.z}),l.cfg.aligntool="vast";//!= 'tmalign'; let c=0,h="query",p=o.substr(0,o.indexOf("_")),m=!0;n.chainalignParserCls.transformStructure(p,c,h,m);let u="";for(let e=0,i=s.length;e8)return s;let g=[];g[0]=n[0]*r[0]+n[1]*r[1]+n[2]*r[2],g[1]=n[3]*r[0]+n[4]*r[1]+n[5]*r[2],g[2]=n[6]*r[0]+n[7]*r[1]+n[8]*r[2],g[0]-=n[0]*a[0]+n[1]*a[1]+n[2]*a[2],g[1]-=n[3]*a[0]+n[4]*a[1]+n[5]*a[2],g[2]-=n[6]*a[0]+n[7]*a[1]+n[8]*a[2];let f=0;return f=c[0]*g[0],f+=c[1]*g[1],f+=c[2]*g[2],f/=p*m,f<.866?s:(g[0]=l[0]*r[0]+l[1]*r[1]+l[2]*r[2],g[1]=l[3]*r[0]+l[4]*r[1]+l[5]*r[2],g[2]=l[6]*r[0]+l[7]*r[1]+l[8]*r[2],g[0]-=l[0]*a[0]+l[1]*a[1]+l[2]*a[2],g[1]-=l[3]*a[0]+l[4]*a[1]+l[5]*a[2],g[2]-=l[6]*a[0]+l[7]*a[1]+l[8]*a[2],f=c[0]*g[0],f+=c[1]*g[1],f+=c[2]*g[2],f/=p*m,f<.866?s:(u=0,u+=Math.pow(e.q_rotation.x1-t.q_rotation.x1,2),u+=Math.pow(e.q_rotation.y1-t.q_rotation.y1,2),u+=Math.pow(e.q_rotation.z1-t.q_rotation.z1,2),u+=Math.pow(e.q_rotation.x2-t.q_rotation.x2,2),u+=Math.pow(e.q_rotation.y2-t.q_rotation.y2,2),u+=Math.pow(e.q_rotation.z2-t.q_rotation.z2,2),u+=Math.pow(e.q_rotation.x3-t.q_rotation.x3,2),u+=Math.pow(e.q_rotation.y3-t.q_rotation.y3,2),u+=Math.pow(e.q_rotation.z3-t.q_rotation.z3,2),Math.sqrt(u)))}GetRotMatrix(e,t,s){this.icn3d.icn3dui;let i=[];return i&&(i[0]=e.q_rotation.x1/t,i[1]=e.q_rotation.y1/t,i[2]=e.q_rotation.z1/t,i[3]=e.q_rotation.x2/t,i[4]=e.q_rotation.y2/t,i[5]=e.q_rotation.z2/t,i[6]=e.q_rotation.x3/t,i[7]=e.q_rotation.y3/t,i[8]=e.q_rotation.z3/t,2!=s?(i[9]=e.t_trans_add.x/t,i[10]=e.t_trans_add.y/t,i[11]=e.t_trans_add.z/t,i[12]=-e.q_trans_sub.x/t,i[13]=-e.q_trans_sub.y/t,i[14]=-e.q_trans_sub.z/t):(i[9]=-e.q_trans_add.x/t,i[10]=-e.q_trans_add.y/t,i[11]=-e.q_trans_add.z/t,i[12]=0,i[13]=0,i[14]=0)),i}cbu_dist(e,t,s){return er&&(s.push(e[n].leaves),i.push(e[n].dist));return{clusters:s,scores:i}}}class ls{constructor(e){this.icn3d=e}async applyCommand(e){let t=this.icn3d,s=t.icn3dui;t.bAddCommands=!1;let i=e.split("|||")[0].split("%7C%7C%7C")[0].replace(/\s+/g," ").trim(),n=i.toLowerCase();if("share link"==n)await t.shareLinkCls.shareLink();else if("export state file"==n);else if(0==n.indexOf("export canvas"))setTimeout((async function(){let e=n.substr(13).trim();t.scaleFactor=""===e?1:parseInt(e);let s=""!==e;await t.shareLinkCls.shareLink(!0,s)}),500);else if("export interactions"==n)t.viewInterPairsCls.exportInteractions();else if("export stl file"==n)setTimeout((function(){t.export3DCls.exportStlFile("")}),500);else if("export vrml file"==n)setTimeout((function(){t.export3DCls.exportVrmlFile("")}),500);else if("export stl stabilizer file"==n)setTimeout((function(){t.threeDPrintCls.hideStabilizer(),t.threeDPrintCls.resetAfter3Dprint(),t.threeDPrintCls.addStabilizer(),t.export3DCls.exportStlFile("_stab")}),500);else if("export vrml stabilizer file"==n)setTimeout((function(){t.threeDPrintCls.hideStabilizer(),t.threeDPrintCls.resetAfter3Dprint(),t.threeDPrintCls.addStabilizer(),t.export3DCls.exportVrmlFile("_stab")}),500);else if("export pdb"==n)s.htmlCls.setHtmlCls.exportPdb();else if("export pdb missing atoms"==n)await t.scapCls.exportPdbProfix(!1);else if("export pdb hydrogen"==n)await t.scapCls.exportPdbProfix(!0);else if("export secondary structure"==n)s.htmlCls.setHtmlCls.exportSecondary();else if("select all"==n)t.selectionCls.selectAll();else if("show all"==n)t.selectionCls.showAll();else if("select complement"==n)t.resid2specCls.selectComplement();else if("set pk atom"==n)t.pk=1,t.opts.pk="atom";else if("set pk off"==n)t.pk=0,t.opts.pk="no",t.drawCls.draw(),t.hlObjectsCls.removeHlObjects();else if("set pk residue"==n)t.pk=2,t.opts.pk="residue";else if("set pk strand"==n)t.pk=3,t.opts.pk="strand";else if("set pk domain"==n)t.pk=4,t.opts.pk="domain";else if("set pk chain"==n)t.pk=5,t.opts.pk="chain";else if("set surface wireframe on"==n)t.opts.wireframe="yes",t.applyMapCls.applySurfaceOptions();else if("set surface wireframe off"==n)t.opts.wireframe="no",t.applyMapCls.applySurfaceOptions();else if("set map wireframe on"==n)t.opts.mapwireframe="yes",t.applyMapCls.applyMapOptions();else if("set map wireframe off"==n)t.opts.mapwireframe="no",t.applyMapCls.applyMapOptions();else if("set emmap wireframe on"==n)t.opts.emmapwireframe="yes",t.applyMapCls.applyEmmapOptions();else if("set emmap wireframe off"==n)t.opts.emmapwireframe="no",t.applyMapCls.applyEmmapOptions();else if("set surface neighbors on"==n)t.bConsiderNeighbors=!0,t.applyMapCls.applySurfaceOptions();else if("set surface neighbors off"==n)t.bConsiderNeighbors=!1,t.applyMapCls.applySurfaceOptions();else if("set axis on"==n)t.opts.axis="yes";else if("set pc1 axis"==n)t.pc1=!0,t.axesCls.setPc1Axes();else if("set axis off"==n)t.opts.axis="no",t.pc1=!1;else if("set fog on"==n)t.opts.fog="yes",t.fogCls.setFog(!0);else if("set fog off"==n)t.opts.fog="no",t.fogCls.setFog(!0);else if("set slab on"==n)t.opts.slab="yes";else if("set slab off"==n)t.opts.slab="no";else if("set assembly on"==n)t.bAssembly=!0;else if("set assembly off"==n)t.bAssembly=!1;else if("set chemicalbinding show"==n)t.setOptionCls.setOption("chemicalbinding","show");else if("set chemicalbinding hide"==n)t.setOptionCls.setOption("chemicalbinding","hide");else if("set hbonds off"==n)t.hBondCls.hideHbonds(),t.drawCls.draw();else if("set salt bridge off"==n)t.saltbridgeCls.hideSaltbridge(),t.drawCls.draw();else if("set contact off"==n)t.contactCls.hideContact(),t.drawCls.draw();else if("set halogen pi off"==n)t.piHalogenCls.hideHalogenPi(),t.drawCls.draw();else if("hydrogens"==n)t.showInterCls.showHydrogens(),t.drawCls.draw();else if("set hydrogens off"==n)t.showInterCls.hideHydrogens(),t.drawCls.draw();else if("close popup"==n)t.resizeCanvasCls.closeDialogs();else if("set stabilizer off"==n)t.threeDPrintCls.hideStabilizer(),t.drawCls.draw();else if("set disulfide bonds off"==n)t.opts.ssbonds="no",t.drawCls.draw();else if("set cross linkage off"==n)t.opts.clbonds="no",t.drawCls.draw();else if("set lines off"==n)t.labels.distance=[],t.lines.distance=[],t.drawCls.draw();else if("set labels off"==n){for(let e in t.labels)t.labels[e]=[];t.drawCls.draw()}else if("set mode all"==n)t.definedSetsCls.setModeAndDisplay("all");else if("set mode selection"==n)t.definedSetsCls.setModeAndDisplay("selection");else if("set view detailed view"==n)t.annotationCls.setAnnoViewAndDisplay("detailed view");else if("set view overview"==n)t.annotationCls.setAnnoViewAndDisplay("overview");else if("set annotation custom"==n)t.annotationCls.setAnnoTabCustom();else if("set annotation interaction"==n)t.annotationCls.setAnnoTabInteraction();else if("set annotation ptm"==n)await t.annotationCls.setAnnoTabPTM();else if("set annotation cdd"==n)t.annotationCls.setAnnoTabCdd();else if("set annotation site"==n)t.annotationCls.setAnnoTabSite();else if("set annotation ssbond"==n)t.annotationCls.setAnnoTabSsbond();else if("set annotation crosslink"==n)t.annotationCls.setAnnoTabCrosslink();else if("set annotation transmembrane"==n)await t.annotationCls.setAnnoTabTransmem();else if("highlight level up"==n)t.resid2specCls.switchHighlightLevelUp();else if("highlight level down"==n)t.resid2specCls.switchHighlightLevelDown();else if(0==n.indexOf("hide annotation")){let e=n.lastIndexOf(" "),s=n.substr(e+1);"all"==s?t.annotationCls.hideAnnoTabAll():"custom"==s?t.annotationCls.hideAnnoTabCustom():"clinvar"==s?t.annotationCls.hideAnnoTabClinvar():"snp"==s?t.annotationCls.hideAnnoTabSnp():"cdd"==s?t.annotationCls.hideAnnoTabCdd():"3ddomain"==s?t.annotationCls.hideAnnoTab3ddomain():"site"==s?t.annotationCls.hideAnnoTabSite():"ptm"==s?t.annotationCls.hideAnnoTabPTM():"interaction"==s?t.annotationCls.hideAnnoTabInteraction():"ssbond"==s?t.annotationCls.hideAnnoTabSsbond():"crosslink"==s?t.annotationCls.hideAnnoTabCrosslink():"transmembrane"==s&&t.annotationCls.hideAnnoTabTransmem()}else if("add residue labels"==n)t.residueLabelsCls.addResidueLabels(t.hAtoms),t.drawCls.draw();else if("add residue number labels"==n)t.residueLabelsCls.addResidueLabels(t.hAtoms,void 0,void 0,!0),t.drawCls.draw();else if("add atom labels"==n)t.residueLabelsCls.addAtomLabels(t.hAtoms),t.drawCls.draw();else if("add element labels"==n)t.residueLabelsCls.addAtomLabels(t.hAtoms,!0),t.drawCls.draw();else if("add chain labels"==n)t.analysisCls.addChainLabels(t.hAtoms),t.drawCls.draw();else if("add terminal labels"==n)t.analysisCls.addTerminiLabels(t.hAtoms),t.drawCls.draw();else if("rotate left"==n)t.bStopRotate=!1,t.ROT_DIR="left",t.resizeCanvasCls.rotStruc("left");else if("rotate right"==n)t.bStopRotate=!1,t.ROT_DIR="right",t.resizeCanvasCls.rotStruc("right");else if("rotate up"==n)t.bStopRotate=!1,t.ROT_DIR="up",t.resizeCanvasCls.rotStruc("up");else if("rotate down"==n)t.bStopRotate=!1,t.ROT_DIR="down",t.resizeCanvasCls.rotStruc("down");else if("rotate x"==n){let e=new THREE.Vector3(1,0,0),s=.5*Math.PI;t.transformCls.setRotation(e,s)}else if("rotate y"==n){let e=new THREE.Vector3(0,1,0),s=.5*Math.PI;t.transformCls.setRotation(e,s)}else if("rotate z"==n){let e=new THREE.Vector3(0,0,1),s=.5*Math.PI;t.transformCls.setRotation(e,s)}else if("reset"===n)t.selectionCls.resetAll();else if("reset orientation"===n)t.transformCls.resetOrientation(),t.drawCls.draw();else if("reset thickness"==n)t.threeDPrintCls.resetAfter3Dprint(),t.drawCls.draw();else if("clear selection"==n)t.hlObjectsCls.removeHlObjects(),t.hlUpdateCls.removeHl2D(),t.bShowHighlight=!1,t.bSelectResidue=!1;else if("zoom selection"==n)t.transformCls.zoominSelection(),t.drawCls.draw();else if("center selection"==n)t.applyCenterCls.centerSelection(),t.drawCls.draw();else if("show selection"==n)t.selectionCls.showSelection();else if("hide selection"==n)t.selectionCls.hideSelection();else if("output selection"==n)t.threeDPrintCls.outputSelection();else if("toggle selection"==n)t.selectionCls.toggleSelection();else if("toggle highlight"==n)t.hlUpdateCls.toggleHighlight();else if("stabilizer"==n)t.threeDPrintCls.addStabilizer(),t.threeDPrintCls.prepareFor3Dprint();else if("disulfide bonds"==n)t.showInterCls.showSsbonds();else if("cross linkage"==n)t.showInterCls.showClbonds();else if("back"==n)await t.resizeCanvasCls.back();else if("forward"==n)await t.resizeCanvasCls.forward();else if("clear all"==n)t.selectionCls.selectAll();else if("defined sets"==n)t.definedSetsCls.showSets();else if("delete selected sets"==n)t.definedSetsCls.deleteSelectedSets();else if("view interactions"==n)void 0===s.cfg.mmdbid&&void 0===s.cfg.gi||t.ParserUtilsCls.set2DDiagrams(t.inputid);else if("show annotations all chains"==n)t.annotationCls.showAnnoAllChains();else if("save color"==n)t.setOptionCls.saveColor();else if("apply saved color"==n)t.setOptionCls.applySavedColor();else if("save style"==n)t.setOptionCls.saveStyle();else if("apply saved style"==n)t.setOptionCls.applySavedStyle();else if("select main chains"==n)t.selectionCls.selectMainChains();else if("select side chains"==n)t.selectionCls.selectSideChains();else if("select main side chains"==n)t.selectionCls.selectMainSideChains();else if("realign"==n)t.realignParserCls.realign();else if(-1!=n.indexOf("realign predefined ")){let e="realign predefined ",n=i.substr(e.length),l=n.indexOf(" "),r=n.substr(0,l).split(",");s.cfg.resdef=n.substr(l+1).replace(/:/gi,";"),await t.realignParserCls.realignChainOnSeqAlign(void 0,r,!0,!0)}else if("area"==n)t.analysisCls.calculateArea();else if("table inter count only"==n)$(".icn3d-border").hide();else if("table inter details"==n)$(".icn3d-border").show();else if("setoption map nothing"==n)t.setOptionCls.setOption("map","nothing");else if("setoption emmap nothing"==n)t.setOptionCls.setOption("emmap","nothing");else if("setoption phimap nothing"==n)t.setOptionCls.setOption("phimap","nothing");else if("setoption phisurface nothing"==n)t.setOptionCls.setOption("phisurface","nothing");else if("clear symd symmetry"==n)t.symdArray=[];else if("show axis"==n)t.bAxisOnly=!0;else if(0==i.indexOf("define helix sets")){let e=i.split(" | ")[1].split(" ")[1];t.addTrackCls.defineSecondary(e,"helix")}else if(0==i.indexOf("define sheet sets")){let e=i.split(" | ")[1].split(" ")[1];t.addTrackCls.defineSecondary(e,"sheet")}else if(0==i.indexOf("define coil sets")){let e=i.split(" | ")[1].split(" ")[1];t.addTrackCls.defineSecondary(e,"coil")}else if(0==i.indexOf("select interaction")){let e=i.substr(i.lastIndexOf(" ")+1).split(",");if(null!==e){let s=e[0].split("_")[0];t.b2DShown||t.ParserUtilsCls.download2Ddgm(s.toUpperCase()),t.diagram2dCls.selectInteraction(e[0],e[1])}}else if(0==i.indexOf("select saved atoms")||0==i.indexOf("select sets")){i=i.replace(/aligned_protein/g,"protein_aligned");let e=i.split(" | "),s=e[0].replace(/,/g," or "),n=19;0==i.indexOf("select sets")&&(n=12);let l=s.substr(n),r=l;2==e.length&&(r=e[1].substr(5)),t.definedSetsCls.selectCombinedSets(l,r)}else if(-1!==i.indexOf("select chain")){let e=i.substr(i.lastIndexOf(" ")+1).split(",");for(let s=0,i=e.length;s6?e[6].substr(e[6].lastIndexOf(" ")+1):0,d=e.length>7?e[7].substr(e[7].lastIndexOf(" ")+1):1;t.analysisCls.addLine(parseFloat(s[1]),parseFloat(s[3]),parseFloat(s[5]),parseFloat(i[1]),parseFloat(i[3]),parseFloat(i[5]),l,r,o,parseFloat(a),parseFloat(d)),t.drawCls.draw()}else if(0==n.indexOf("add sphere"))this.addShape(n,"sphere");else if(0==n.indexOf("add cube"))this.addShape(n,"cube");else if(0==n.indexOf("clear shape"))t.shapeCmdHash={};else if(0==n.indexOf("clear line between sets"))t.lines.cylinder=[];else if(0==i.indexOf("add label")){let e,n,l,r,o,a,d,c=i.split(" | "),h=c[0].substr("add label".length+1),p=!1;for(let t=1,s=c.length;t=5&&(e=l[4].substr(5)),l.length>=6&&(s=l[5].substr(6)),l.length>=7&&(n=l[6].substr(4)),$("#"+t.pre+"anno_custom")[0].checked=!0,$("[id^="+t.pre+"custom]").show(),"0"==s&&(s=void 0),t.addTrackCls.checkGiSeq(r,o,a,e,s,n,0)}else if(0==n.indexOf("remove one stabilizer")){let e=n.split(" | ")[1].split(" "),s=[];s.push(parseInt(e[0])),s.push(parseInt(e[1])),t.threeDPrintCls.removeOneStabilizer(s),t.drawCls.draw()}else if(0==n.indexOf("add one stabilizer")){let e=n.split(" | ")[1].split(" ");void 0===t.pairArray&&(t.pairArray=[]),t.pairArray.push(parseInt(e[0])),t.pairArray.push(parseInt(e[1])),t.drawCls.draw()}else if(0==n.indexOf("select planes z-axis")){let e=n.split(" ");if(5==e.length){let s=parseFloat(e[3]),i=parseFloat(e[4]);t.selectionCls.selectBtwPlanes(s,i)}}else if(0==n.indexOf("adjust membrane z-axis")){let e=n.split(" ");if(5==e.length){let s=parseFloat(e[3]),i=parseFloat(e[4]);t.selectionCls.adjustMembrane(s,i)}}else if(0==n.indexOf("toggle membrane"))t.selectionCls.toggleMembrane();else if(0==i.indexOf("calc buried surface")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(" ");if(2==s.length){let e=s[0].split(","),i=s[1].split(",");t.analysisCls.calcBuriedSurface(e,i)}}}else if(0==i.indexOf("dist ")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(" ");if(2==s.length){let e=s[0].split(","),i=s[1].split(",");t.analysisCls.measureDistTwoSets(e,i)}}}else if(0==i.indexOf("disttable")){let e=i.split(" | ");if(2==e.length){let i=e[1].split(" ");if(2==i.length){let e=i[0].split(","),n=i[1].split(",");t.analysisCls.measureDistManySets(e,n),s.htmlCls.dialogCls.openDlg("dl_disttable","Distance among the sets")}}}else if(0==i.indexOf("display interaction 3d")||0==i.indexOf("view interaction pairs")||0==i.indexOf("save1 interaction pairs")||0==i.indexOf("save2 interaction pairs")||0==i.indexOf("line graph interaction pairs")||0==i.indexOf("scatterplot interaction pairs")){let e=i.split(" | ");if(e.length>=3){let s=e[1].split(" ");if(2==s.length){let n,l,r=s[0].split(","),o=s[1].split(","),a=-1!==e[2].indexOf("hbonds"),d=-1!==e[2].indexOf("salt bridge"),c=-1!==e[2].indexOf("interactions"),h=-1!==e[2].indexOf("halogen"),p=-1!==e[2].indexOf("pi-cation"),m=-1!==e[2].indexOf("pi-stacking");if(e.length>=4&&(n="true"==e[3]),e.length>=5){let s=e[4].split(" ");s.length>=4&&($("#"+t.pre+"hbondthreshold").val(s[1]),$("#"+t.pre+"saltbridgethreshold").val(s[2]),$("#"+t.pre+"contactthreshold").val(s[3]),7==s.length&&($("#"+t.pre+"halogenthreshold").val(s[4]),$("#"+t.pre+"picationthreshold").val(s[5]),$("#"+t.pre+"pistackingthreshold").val(s[6])))}0==i.indexOf("display interaction 3d")?l="3d":0==i.indexOf("view interaction pairs")?l="view":0==i.indexOf("save1 interaction pairs")?l="save1":0==i.indexOf("save2 interaction pairs")?l="save2":0==i.indexOf("line graph interaction pairs")?l="linegraph":0==i.indexOf("scatterplot interaction pairs")&&(l="scatterplot"),await t.viewInterPairsCls.viewInteractionPairs(r,o,n,l,a,d,c,h,p,m)}}}else if(0==i.indexOf("export pairs")){let e=i.split(" | ");if(3==e.length){let s=e[1].split(" ");if(2==s.length){let i=s[0].split(","),n=s[1].split(","),l=e[2].split(" ")[1];t.showInterCls.pickCustomSphere(l,i,n,t.bSphereCalc),t.bSphereCalc=!0;let r=t.viewInterPairsCls.exportSpherePairs(),o=t.inputid?t.inputid:"custom";t.saveFileCls.saveFile(o+"_sphere_pairs.html","html",r)}}}else if(0==n.indexOf("graph label")){let e=n.lastIndexOf(" "),t=n.substr(e+1);$("#"+s.svgid+"_label").val(t),$("#"+s.svgid+" text").removeClass(),$("#"+s.svgid+" text").addClass(t)}else if(0==n.indexOf("cartoon label")){let e=n.lastIndexOf(" "),t=n.substr(e+1);$("#"+s.svgid_ct+"_label").val(t),$("#"+s.svgid_ct+" text").removeClass(),$("#"+s.svgid_ct+" text").addClass(t)}else if(0==n.indexOf("line graph scale")){let e=n.lastIndexOf(" "),i=n.substr(e+1);$("#"+s.linegraphid+"_scale").val(i),$("#"+s.linegraphid).attr("width",(t.linegraphWidth*parseFloat(i)).toString()+"px")}else if(0==n.indexOf("scatterplot scale")){let e=n.lastIndexOf(" "),i=n.substr(e+1);$("#"+s.scatterplotid+"_scale").val(i),$("#"+s.scatterplotid).attr("width",(t.scatterplotWidth*parseFloat(i)).toString()+"px")}else if(0==n.indexOf("contactmap scale")){let e=n.lastIndexOf(" "),i=n.substr(e+1);$("#"+s.contactmapid+"_scale").val(i),$("#"+s.contactmapid).attr("width",(t.contactmapWidth*parseFloat(i)).toString()+"px")}else if(0==n.indexOf("alignerrormap scale")){let e=n.lastIndexOf(" "),i=n.substr(e+1);$("#"+s.alignerrormapid+"_scale").val(i),$("#"+s.alignerrormapid).attr("width",(t.alignerrormapWidth*parseFloat(i)).toString()+"px")}else if(0==n.indexOf("graph force")){let e=n.lastIndexOf(" ");s.htmlCls.force=parseInt(n.substr(e+1)),$("#"+s.svgid+"_force").val(s.htmlCls.force),t.getGraphCls.handleForce()}else if(0==n.indexOf("hide edges")){let e=n.lastIndexOf(" ");s.htmlCls.hideedges=parseInt(n.substr(e+1)),$("#"+s.svgid+"_hideedges").val(s.htmlCls.hideedges),s.htmlCls.hideedges?(s.htmlCls.contactInsideColor="FFF",s.htmlCls.hbondInsideColor="FFF",s.htmlCls.ionicInsideColor="FFF"):(s.htmlCls.contactInsideColor="DDD",s.htmlCls.hbondInsideColor="AFA",s.htmlCls.ionicInsideColor="8FF"),void 0!==t.graphStr&&t.bRender&&s.htmlCls.force&&t.drawGraphCls.drawGraph(t.graphStr,t.pre+"dl_graph")}else if(0==n.indexOf("reset interaction pairs"))t.viewInterPairsCls.resetInteractionPairs();else if(0==n.indexOf("side by side")){let e=n.split(" | ")[1],t="_blank";window.open(e,t)}else if(0==i.indexOf("your note")){let e=i.split(" | ");t.yournote=e[1],$("#"+t.pre+"yournote").val(t.yournote),s.cfg.shownote&&(document.title=t.yournote)}else if(0==n.indexOf("cross structure interaction"))t.crossstrucinter=parseInt(n.substr(n.lastIndexOf(" ")+1)),$("#"+t.pre+"crossstrucinter").val(t.crossstrucinter);else if("replay on"==n)await t.resizeCanvasCls.replayon();else if("replay off"==n)await t.resizeCanvasCls.replayoff();else if(0==n.indexOf("contact map")){let e=n.split(" | ");if(3===e.length){let s=parseFloat(e[1].split(" ")[1]),i=e[2].split(" ")[1];await t.contactMapCls.contactMap(s,i)}}else if(0==n.indexOf("pickatom")){let e=parseInt(n.substr(n.lastIndexOf(" ")+1));t.pAtom=t.atoms[e],t.pickingCls.showPicking(t.pAtom)}else if(0==i.indexOf("set color spectrum")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(","),i=!0;t.setColorCls.setColorAcrossSets(s,i)}}else if(0==i.indexOf("set residues color spectrum")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(","),i=!0;t.setColorCls.setColorBySets(s,i)}}else if(0==i.indexOf("set color rainbow")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(","),i=!1;t.setColorCls.setColorAcrossSets(s,i)}}else if(0==i.indexOf("set residues color rainbow")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(","),i=!1;t.setColorCls.setColorBySets(s,i)}}else if(0==i.indexOf("color")){let e=i.split(" | "),n=e[0].substr(e[0].indexOf(" ")+1);if(t.opts.color=n,"residue custom"==n&&2==e.length){t.customResidueColors=JSON.parse(e[1]);for(let e in t.customResidueColors)t.customResidueColors[e.toUpperCase()]=s.parasCls.thr("#"+t.customResidueColors[e])}else if("align custom"==n&&3==e.length){let s=e[1],i=e[2].split(", ");t.queryresi2score={},t.queryresi2score[s]={};for(let e=0,n=i.length;e=4?this.setQueryresi2score(e):"area"==n&&2==e.length&&(t.midpercent=e[1],$("#"+t.pre+"midpercent").val(t.midpercent));t.setColorCls.setColorByOptions(t.opts,t.hAtoms),t.hlUpdateCls.updateHlAll(),t.getGraphCls.updateGraphColor()}else if(0==i.indexOf("remove legend"))$("#"+s.pre+"legend").hide();else if(0==i.indexOf("custom tube")){let e=i.split(" | ");this.setQueryresi2score(e),t.setOptionCls.setStyle("proteins","custom tube")}else if(0==n.indexOf("style")){let e=n.substr(n.indexOf(" ")+1),s=e.substr(0,e.indexOf(" ")),i=e.substr(e.indexOf(" ")+1);t.setOptionCls.setStyle(s,i)}else if(0==n.indexOf("window")){let e=n.substr(n.indexOf(" ")+1);setTimeout((function(){"aligned sequences"==e?s.htmlCls.dialogCls.openDlg("dl_alignment","Select residues in aligned sequences"):"interaction table"==e?s.htmlCls.dialogCls.openDlg("dl_allinteraction","Show interactions"):"interaction graph"==e?s.htmlCls.dialogCls.openDlg("dl_linegraph","Show interactions between two lines of residue nodes"):"interaction scatterplot"==e?s.htmlCls.dialogCls.openDlg("dl_scatterplot","Show interactions as scatterplot"):"force-directed graph"==e&&s.htmlCls.dialogCls.openDlg("dl_graph","Force-directed graph")}),1e3)}else if(0==n.indexOf("set theme")){let e=n.substr(n.lastIndexOf(" ")+1);s.htmlCls.setMenuCls.setTheme(e)}else if(0==n.indexOf("set double color")){let e=n.substr(n.lastIndexOf(" ")+1);"on"==e?(t.bDoublecolor=!0,t.setOptionCls.setStyle("proteins","ribbon")):"off"==e&&(t.bDoublecolor=!1)}else if(0==n.indexOf("adjust dialog")){let e=n.substr(n.lastIndexOf(" ")+1);t.scapCls.adjust2DWidth(e)}else if(0==n.indexOf("glycans cartoon")){let e=n.substr(n.lastIndexOf(" ")+1);t.bGlycansCartoon="yes"==e}else if(0==n.indexOf("save html")){let e=n.substr(n.lastIndexOf(" ")+1);s.htmlCls.eventsCls.saveHtml(e)}else if(0==n.indexOf("resdef"))s.cfg.resdef=n.substr(n.indexOf(" ")+1);else if(0==n.indexOf("vast_search_chainid")){t.chainidArray=i.substr(i.indexOf(" ")+1).split(",");let e=!0,s=!0;await t.realignParserCls.realignChainOnSeqAlign(void 0,t.chainidArray,e,s)}else if(0==n.indexOf("ig refnum off"))await t.refnumCls.hideIgRefNum();else if(0==n.indexOf("custom refnum")){let e=i.split(" | ")[1].replace(/\\n/g,"\n");await t.refnumCls.parseCustomRefFile(e)}else if(-1!==n.indexOf("select displayed set"))t.hAtoms=s.hashUtilsCls.cloneHash(t.viewSelectionAtoms),t.hlUpdateCls.updateHlAll();else if(-1!==n.indexOf("select prop")){let e,s,n=i.split(" | "),l=n[0].substr("select prop".length+1);if(2==n.length){let t=n[1].split("_");e=t[0],s=t[1]}t.resid2specCls.selectProperty(l,e,s)}else if(-1!==n.indexOf("select each residue"))t.selectionCls.saveEachResiInSel();else if(0==n.indexOf("select")&&-1!==n.indexOf("name")){let e=i.split(" | "),s="",n="",l="";for(let t=0,i=e.length;t1&&(n=e[1].substr(e[1].indexOf(" ")+1)),e.length>2&&(l=e[2].substr(e[2].indexOf(" ")+1)),-1!==s.indexOf(" or ")?await t.selByCommCls.selectByCommand(s,n,l):await t.selByCommCls.selectBySpec(s,n,l)}s.htmlCls.clickMenuCls.setLogCmd(i,!1),t.bAddCommands=!0}setStrengthPara(e){let t=this.icn3d;if(t.icn3dui,e.length>=5){let s=e[4].split(" ");s.length>=4&&($("#"+t.pre+"hbondthreshold").val(s[1]),$("#"+t.pre+"saltbridgethreshold").val(s[2]),$("#"+t.pre+"contactthreshold").val(s[3]),s.length>=7&&($("#"+t.pre+"halogenthreshold").val(s[4]),$("#"+t.pre+"picationthreshold").val(s[5]),$("#"+t.pre+"pistackingthreshold").val(s[6])))}if(6==e.length){let s=e[5].split(" ");s.length>=6&&($("#"+t.pre+"dist_ss").val(s[0]),$("#"+t.pre+"dist_coil").val(s[1]),$("#"+t.pre+"dist_hbond").val(s[2]),$("#"+t.pre+"dist_inter").val(s[3]),$("#"+t.pre+"dist_ssbond").val(s[4]),$("#"+t.pre+"dist_ionic").val(s[5]),9==s.length&&($("#"+t.pre+"dist_halogen").val(s[6]),$("#"+t.pre+"dist_pication").val(s[7]),$("#"+t.pre+"dist_pistacking").val(s[8])))}}getThresholdNameArrays(e){this.icn3d.icn3dui.htmlCls.clickMenuCls.SetChainsAdvancedMenu();let t,s=e.split(" | "),i=parseFloat(s[0].substr(s[0].lastIndexOf(" ")+1)),n=[],l=[];if(s.length>=2&&s[1].length>4){let e=s[1].split(" ");e.length>1&&(l=e[1].split(",")),e.length>2&&(n=e[2].split(","))}else l=["selected"],n=["non-selected"];return 3==s.length&&(t="true"==s[2]),{threshold:i,nameArray2:l,nameArray:n,bHbondCalc:t}}setQueryresi2score(e){let t=this.icn3d,s=t.icn3dui,i=e[1],n=e[2].split(" ")[1].split("_"),l=e[3];void 0===t.queryresi2score&&(t.queryresi2score={}),t.queryresi2score[i]={};for(let e=parseInt(n[0]),s=0;e<=parseInt(n[1]);++e,++s)"_"!=l[s]&&(t.queryresi2score[i][e]=11.11111111111111*parseInt(l[s]));if(e.length>4){let i=e[4].split(" ");t.startColor=i[1],t.midColor=i[2],t.endColor=i[3];let n=s.htmlCls.clickMenuCls.setLegendHtml();$("#"+s.pre+"dl_legend").html(n),s.htmlCls.dialogCls.openDlg("dl_legend","Color Range")}}addShape(e,t){let s=this.icn3d,i=s.icn3dui;s.shapeCmdHash[e]=1;let n=e.split(" | "),l=n[1].split(" "),r=n[2].substr(n[2].lastIndexOf(" ")+1),o=n[3].substr(n[3].lastIndexOf(" ")+1),a=n[4].substr(n[4].lastIndexOf(" ")+1);r="#"+r.replace(/\#/g,"");let d=i.parasCls.thr(r),c=new THREE.Vector3(parseFloat(l[1]),parseFloat(l[3]),parseFloat(l[5]));"sphere"==t?s.sphereCls.createSphereBase(c,d,parseFloat(a),void 0,void 0,void 0,parseFloat(o)):s.boxCls.createBox_base(c,parseFloat(a),d,void 0,void 0,void 0,parseFloat(o))}getMenuFromCmd(e){this.icn3d.icn3dui;let t="Windows > View Sequences & Annotations",s="Analysis > H-Bonds & Interactions",i=s+" > 2D Graph(Force-Directed)",n="View > Rotate > Auto Rotation > Rotate ",l="View > Rotate > Rotate 90 deg > ",r="Select > Select on 3D > ",o="Analysis > Label > ",a="File > 3D Printing > ";return 0==(e=e.trim()).indexOf("load")?"File > Retrieve by ID, Align":0==e.indexOf("set map")&&-1==e.indexOf("set map wireframe")?"Style > Electron Density":0==e.indexOf("set emmap")&&-1==e.indexOf("set emmap wireframe")?"Style > EM Density Map":0==e.indexOf("set phi")?"Analysis > Load Potential > URL(CORS) Phi/Cube":0==e.indexOf("set delphi")?"Analysis > DelPhi Potential":0==e.indexOf("setoption map")?"Style > Remove Map":0==e.indexOf("setoption emmap")?"Style > Remove EM Map":0==e.indexOf("view annotations")?t:0==e.indexOf("set annotation all")?t+': "All" checkbox':0==e.indexOf("set annotation clinvar")?t+': "ClinVar" checkbox':0==e.indexOf("set annotation snp")?t+': "SNP" checkbox':0==e.indexOf("set annotation 3ddomain")?t+': "3D Domains" checkbox':0==e.indexOf("view interactions")?"Windows > View 2D Diagram":0==e.indexOf("symmetry")?"Analysis > Symmetry":0==e.indexOf("realign on seq align")?"File > Realign Selection > on Sequence Alignment":0==e.indexOf("realign")?"File > Realign Selection > Residue by Residue":0==e.indexOf("graph interaction pairs")?s+" > 2D Graph(Force-Directed)":0==e.indexOf("export canvas")?"File > Save File > iCn3D PNG Image":"export stl file"==e?a+"STL":"export vrml file"==e?a+"VRML(Color)":"export stl stabilizer file"==e?a+"STL W/ Stabilizers":"export vrml stabilizer file"==e?a+"VRML(Color, W/ Stabilizers)":"select all"==e?'Select > All; or Toggle to "All"(next to "Help")':"show all"==e?"View > View Full Structure":"select complement"==e?"Select > Inverse":"set pk atom"==e?r+"Atom":"set pk residue"==e?r+"Residue":"set pk strand"==e?r+"Strand/Helix":"set pk domain"==e?r+"3D Domain":"set pk chain"==e?r+"Chain":"set surface wireframe on"==e?"Style > Surface Wireframe > Yes":"set surface wireframe off"==e?"Style > Surface Wireframe > No":"set map wireframe on"==e?"Style > Map Wireframe > Yes":"set map wireframe off"==e?"Style > Map Wireframe > No":"set emmap wireframe on"==e?"Style > EM Map Wireframe > Yes":"set emmap wireframe off"==e?"Style > EM Map Wireframe > No":"set surface neighbors on"==e?"Style > Surface Type > ... with Context":"set axis on"==e?"View > XYZ-axes > Show":"set axis off"==e?"View > XYZ-axes > Hide":"set fog on"==e?"View > Fog for Selection > On":"set fog off"==e?"View > Fog for Selection > Off":"set slab on"==e?"View > Slab for Selection > On":"set slab off"==e?"View > Slab for Selection > Off":"set assembly on"==e?"Analysis > Assembly > Biological Assembly":"set assembly off"==e?"Analysis > Assembly > Asymmetric Unit":"set chemicalbinding show"==e?"Analysis > Chem. Binding > Show":"set chemicalbinding hide"==e?"Analysis > Chem. Binding > Hide":"set hbonds off"==e||"set salt bridge off"==e||"set contact off"==e||"set halogen pi off"==e?s+" > Reset":"hydrogens"==e?"Style > Hydrogens > Show":"set hydrogens off"==e?"Style > Hydrogens > Hide":"set stabilizer off"==e?"File > 3D Printing > Remove All Stabilizers":"set disulfide bonds off"==e?"Analysis > Disulfide Bonds > Hide":"set cross linkage off"==e?"Analysis > Cross-Linkages > Hide":"set lines off"==e?"Analysis > Distance > Hide":"set labels off"==e?"Analysis > Label > Remove":"set mode all"==e?'Toggle to "All"(next to "Help")':"set mode selection"==e?'Toggle to "Selection"(next to "Help")':"set view detailed view"==e?t+': "Details" tab':"set view overview"==e?t+': "Summary" tab':"set annotation custom"==e?t+': "Custom" checkbox':"set annotation interaction"==e?t+': "Interactions" checkbox':"set annotation ptm"==e?t+': "PTM" checkbox':"set annotation cdd"==e?t+': "Conserved Domains" checkbox':"set annotation site"==e?t+': "Functional Sites" checkbox':"set annotation ssbond"==e?t+': "Disulfide Bonds" checkbox':"set annotation crosslink"==e?t+': "Cross-Linkages" checkbox':"set annotation transmembrane"==e?t+': "Transmembrane" checkbox':"highlight level up"==e?"Keyboard Arrow Up":"highlight level down"==e?"Keyboard Arrow Down":0==e.indexOf("hide annotation")?t+": checkboxes off":"add residue labels"==e?o+"per Residue":"add residue number labels"==e?o+"per Residue & Number":"add atom labels"==e?o+"per Atom":"add chain labels"==e?o+"per Chain":"add terminal labels"==e?o+"N- & C- Termini":"rotate left"==e?n+"Left; or Key l":"rotate right"==e?n+"Right; or Key j":"rotate up"==e?n+"Up; or Key i":"rotate down"==e?n+"Down; or Key m":"rotate x"==e?l+"X-axis":"rotate y"==e?l+"Y-axis":"rotate z"==e?l+"Z-axis":"reset"==e?"View > Reset > All":"reset orientation"==e?"View > Reset > Orientation":"clear selection"==e?"Select > Clear Selection":"zoom selection"==e?"Select > Zoom in Selection":"center selection"==e?"Select > Center Selection":"show selection"==e?"Select > View Only Selection":"hide selection"==e?"Select > Hide Selection":"output selection"==e?"Select > Clear Selection":"toggle highlight"==e?"Select > Toggle Highlight":"stabilizer"==e?"File > 3D Printing > Add all Stabilizers":"disulfide bonds"==e?"Analysis > Disulfide Bonds > Show":"cross linkage"==e?"Analysis > Cross-Linkages > Show":"back"==e?"View > Undo":"forward"==e?"View > Redo":"clear all"==e?"Select > Clear Selection":"defined sets"==e?"Windows > Defined Sets":"delete selected sets"==e?'Windows > Defined Sets: "Delete Selected Sets" button':"view interactions"==e?"Windows > View Interactions":"show annotations all chains"==e?t+': "Show All Chains" button':"save color"==e?"Color > Save Color":"apply saved color"==e?"Color > Apply Saved Color":"save style"==e?"Style > Save Style":"apply saved style"==e?"Style > Apply Saved Style":"select main chains"==e?"Select > Main Chains":"select side chains"==e?"Select > Side Chains":"select main side chains"==e?"Select > Main & Side Chains":"area"==e?"View > Surface Area":"table inter count only"==e?s+': "Set 1" button: "Show Count Only" button':"table inter details"==e?s+': "Set 1" button: "Show Details" button':0==e.indexOf("define helix sets")?t+': "Helix Sets" button':0==e.indexOf("define sheet sets")?t+': "Sheet Sets" button':0==e.indexOf("define coil sets")?t+': "Coil Sets" button':0==e.indexOf("select interaction")?"Windows > View 2D Diagram: click on edges":0==e.indexOf("select saved atoms")||0==e.indexOf("select sets")?"Windows > Defined Sets: select in menu":-1!==e.indexOf("select chain")?t+": click on chain names":-1!==e.indexOf("select alignChain")?"Windows > View Aligned Sequences: click on chain names":0==e.indexOf("select zone cutoff")?"Select > by Distance":0==e.indexOf("set surface opacity")?"Style > Surface Opacity":0==e.indexOf("set label scale")?"View > Label Scale":0==e.indexOf("set surface")?"Style > Surface Type":0==e.indexOf("set camera")?"View > Camera":0==e.indexOf("set background")?"Style > Background":0==e.indexOf("set thickness")?"File > 3D Printing > Set Thickness":0==e.indexOf("set highlight color")?"Select > Highlight Color":0==e.indexOf("set highlight style")?"Select > Highlight Style":0==e.indexOf("add line")||0==e.indexOf("add label")?"Analysis > Distance > between Two Atoms":0==e.indexOf("dist")?"Analysis > Distance > between Two Sets":0==e.indexOf("msa")?t+': "Add Track" button: "FASTA Alignment" button':0==e.indexOf("add track")?t+': "Add Track" button':0==e.indexOf("remove one stabilizer")?"File > 3D Printing > Remove One Stablizer":0==e.indexOf("add one stabilizer")?"File > 3D Printing > Add One Stablizer":0==e.indexOf("select planes z-axis")?"View > Select between Two X-Y Planes":0==e.indexOf("adjust membrane z-axis")?"View > Adjust Membrane":0==e.indexOf("toggle membrane")?"View > Toggle Membrane":0==e.indexOf("calc buried surface")?s+': "Buried Surface Area" button':0==e.indexOf("display interaction 3d")?s+': "3D Display Interactions" button':0==e.indexOf("view interaction pairs")?s+': "Highlight Interactions in Table" button':0==e.indexOf("save1 interaction pairs")?s+': "Set 1" button':0==e.indexOf("save2 interaction pairs")?s+': "Set 2" button':0==e.indexOf("line graph interaction pairs")?s+': "2D Interaction Network" button':0==e.indexOf("scatterplot interaction pairs")?s+': "2D Interaction Map" button':0==e.indexOf("graph label")?i+': "Label Size" menu':0==e.indexOf("graph force")?i+': "Force on Nodes" menu':0==e.indexOf("hide edges")?i+': "Internal Edges" menu':0==e.indexOf("reset interaction pairs")?s+" > Reset":0==e.indexOf("side by side")?"View > Side by Side":0==e.indexOf("your note")?"Windows > Your Notes / Window Title":0==e.indexOf("pickatom")?"Hold Alt key and click on 3D structure":0==e.indexOf("color")?"Color menu":0==e.indexOf("custom tube")?t+': "Custom Color/Tube" button: "Custom Tube" button':0==e.indexOf("style")?"Style menu":-1!==e.indexOf("select displayed set")?"Select > Displayed Set":-1!==e.indexOf("select prop")?"Select > by Property":0==e.indexOf("select")&&-1!==e.indexOf("name")?t+": drag on residues to select":-1!==e.indexOf("select $")||-1!==e.indexOf("select .")||-1!==e.indexOf("select :")||-1!==e.indexOf("select @")?"Select > Advanced; or other selection":-1!==e.indexOf("replay on")?"File > Replay Each Step > On":-1!==e.indexOf("replay off")?"File > Replay Each Step > Off":-1!==e.indexOf("set theme")?"Style > Theme Color":-1!==e.indexOf("set double color")?"Style > Two-color Helix":""}}class rs{constructor(e){this.icn3d=e}setProtNuclLigInMenu(){let e=this.icn3d;if(e.icn3dui,Object.keys(e.proteins).length>0&&(e.defNames2Residues.proteins=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.proteins)),e.defNames2Descr.proteins="proteins",e.defNames2Command.proteins="select :proteins"),Object.keys(e.nucleotides).length>0&&(e.defNames2Residues.nucleotides=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.nucleotides)),e.defNames2Descr.nucleotides="nucleotides",e.defNames2Command.nucleotides="select :nucleotides"),Object.keys(e.chemicals).length>0)if(e.bOpm){let t={},s={};for(let i in e.chemicals){let n=e.atoms[i],l=n.structure+"_"+n.chain+"_"+n.resi;"DUM"===n.resn?s[l]=1:t[l]=1}Object.keys(t).length>0&&(e.defNames2Residues.chemicals=Object.keys(t),e.defNames2Descr.chemicals="chemicals",e.defNames2Command.chemicals="select :chemicals"),Object.keys(s).length>0&&(e.defNames2Residues.membrane=Object.keys(s),e.defNames2Descr.membrane="membrane",e.defNames2Command.membrane="select :membrane")}else e.defNames2Residues.chemicals=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.chemicals)),e.defNames2Descr.chemicals="chemicals",e.defNames2Command.chemicals="select :chemicals";Object.keys(e.ions).length>0&&(e.defNames2Residues.ions=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.ions)),e.defNames2Descr.ions="ions",e.defNames2Command.ions="select :ions"),Object.keys(e.water).length>0&&(e.defNames2Residues.water=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.water)),e.defNames2Descr.water="water",e.defNames2Command.water="select :water"),this.setTransmemInMenu(e.halfBilayerSize,-e.halfBilayerSize)}setPredefinedInMenu(){let e=this.icn3d,t=e.icn3dui;if(this.setChainsInMenu(),this.setProtNuclLigInMenu(),void 0!==t.cfg.mmdbid||void 0!==t.cfg.gi||void 0!==t.cfg.chainalign||void 0!==t.cfg.mmdbafid)for(let t in e.tddomains)e.selectionCls.selectResidueList(e.tddomains[t],t,t,!1,!1);if((void 0!==t.cfg.align||void 0!==t.cfg.chainalign&&2==e.chainidArray.length)&&e.bFullUi){e.selectionCls.selectResidueList(e.consHash1,e.conservedName1,e.conservedName1,!1,!1),e.selectionCls.selectResidueList(e.consHash2,e.conservedName2,e.conservedName2,!1,!1),e.selectionCls.selectResidueList(e.nconsHash1,e.nonConservedName1,e.nonConservedName1,!1,!1),e.selectionCls.selectResidueList(e.nconsHash2,e.nonConservedName2,e.nonConservedName2,!1,!1),e.selectionCls.selectResidueList(e.nalignHash1,e.notAlignedName1,e.notAlignedName1,!1,!1),e.selectionCls.selectResidueList(e.nalignHash2,e.notAlignedName2,e.notAlignedName2,!1,!1);let s={};for(let i in e.alnChains)s=t.hashUtilsCls.unionHash(s,e.alnChains[i]);let i=e.firstAtomObjCls.getResiduesFromAtoms(s),n="protein_aligned",l="aligned protein and nucleotides",r="select "+e.resid2specCls.residueids2spec(Object.keys(i));e.selectionCls.addCustomSelection(Object.keys(i),n,l,r,!0)}}setAtomMenu(e){let t=this.icn3d;t.icn3dui;let s="",i=void 0!==t.defNames2Residues?Object.keys(t.defNames2Residues):[],n=void 0!==t.defNames2Atoms?Object.keys(t.defNames2Atoms):[],l=i.concat(n).sort(),r=[];l.forEach((e=>{-1===$.inArray(e,r)&&r.push(e)}));for(let i=0,n=r.length;i0&&(n=t.atoms[e[0]])}else if(void 0!==t.defNames2Residues&&t.defNames2Residues.hasOwnProperty(o)){let e=t.defNames2Residues[o];e.length>0&&(l=t.residues[e[0]],l&&(n=t.atoms[Object.keys(l)[0]]))}let a=void 0===n||void 0===n.color||"FFFFFF"===n.color.getHexString().toUpperCase()?"DDDDDD":n.color.getHexString(),d=void 0!==n&&void 0!==n.color?a:"000000";-1!=e.indexOf(o)?s+="":s+=""}return s}setChainsInMenu(){let e=this.icn3d;e.icn3dui;for(let t in e.chains)if(e.chainsSeq[t]&&e.chainsSeq[t].length>1){e.defNames2Residues[t]=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.chains[t])),e.defNames2Descr[t]=t;let s=t.indexOf("_"),i=t.substr(0,s),n=t.substr(s+1);e.defNames2Command[t]="select $"+i+"."+n}if(1==Object.keys(e.structures)){let t=Object.keys(e.structures)[0];e.defNames2Residues[t]=Object.keys(e.residues),e.defNames2Descr[t]=t,e.defNames2Command[t]="select $"+t}else{let t=Object.keys(e.residues),s={};for(let e=0,i=t.length;ee?l[a]=1:o.coord.z0&&(i.defNames2Residues["transmembrane"+o]=Object.keys(n),i.defNames2Descr["transmembrane"+o]="transmembrane"+o,i.defNames2Command["transmembrane"+o]="select :transmembrane"+o),Object.keys(l).length>0&&(i.defNames2Residues["extracellular"+o]=Object.keys(l),i.defNames2Descr["extracellular"+o]="extracellular"+o,i.defNames2Command["extracellular"+o]="select :extracellular"+o),Object.keys(r).length>0&&(i.defNames2Residues["intracellular"+o]=Object.keys(r),i.defNames2Descr["intracellular"+o]="intracellular"+o,i.defNames2Command["intracellular"+o]="select :intracellular"+o)}}showSets(){let e=this.icn3d,t=e.icn3dui;t.bNode||(t.htmlCls.dialogCls.openDlg("dl_definedsets","Select sets"),$("#"+e.pre+"dl_setsmenu").show(),$("#"+e.pre+"dl_setoperations").show(),$("#"+e.pre+"dl_command").hide(),$("#"+e.pre+"atomsCustom").resizable());let s=t.hashUtilsCls.cloneHash(e.hAtoms),i=t.hashUtilsCls.cloneHash(e.dAtoms);void 0!==e.bSetChainsAdvancedMenu&&e.bSetChainsAdvancedMenu&&!e.bResetSets||(this.setPredefinedInMenu(),e.bSetChainsAdvancedMenu=!0),e.hAtoms=t.hashUtilsCls.cloneHash(s),e.dAtoms=t.hashUtilsCls.cloneHash(i),e.hlUpdateCls.updateHlMenus()}clickCustomAtoms(){let e=this.icn3d,t=e.icn3dui,s=this;$("#"+e.pre+"atomsCustom").change((function(e){let i=s.icn3d,n=$(this).val();if(i.nameArray=n,null!==n){let e=!1;s.changeCustomAtoms(n,e),t.htmlCls.clickMenuCls.setLogCmd("select sets "+n.join(" "+i.setOperation+" "),!0),i.bSelectResidue=!1}})),t.myEventCls.onIds("#"+e.pre+"atomsCustom","focus",(function(e){let i=s.icn3d;t.utilsCls.isMobile()&&$("#"+i.pre+"atomsCustom").val("")}))}deleteSelectedSets(){let e=this.icn3d;e.icn3dui;let t=$("#"+e.pre+"atomsCustom").val();for(let s=0;s0)for(let n=0,l=t.defNames2Residues[e].length;n0)for(let s=0,n=t.defNames2Atoms[e].length;s0&&(n[0]=i.commands[0]);let l=e.trim().split("\n");i.commands=l;let r=l[0].indexOf("command=");if(t&&-1!=r){let e=l[0].substr(0,r-1);i.commands.splice(0,1,e)}i.STATENUMBER=i.commands.length,i.commands=n.concat(i.commands),i.STATENUMBER=i.commands.length,i.CURRENTNUMBER=0,i.bReplay?await this.replayFirstStep(i.CURRENTNUMBER):await this.execCommands(i.CURRENTNUMBER,i.STATENUMBER-1,i.STATENUMBER,s)}async execCommands(e,t,s,i){let n=this.icn3d;n.icn3dui,n.bRender=!1,i||n.reinitAfterLoad(),await this.execCommandsBase(e,t,s)}getNameArray(e){let t=this.icn3d;t.icn3dui;let s=e.split(" | "),i=[];return 2==s.length&&(i=s[1].split(","),t.hAtoms=t.definedSetsCls.getAtomsFromNameArray(i)),i}async execCommandsBase(e,t,s,i){let n,l=this.icn3d,r=l.icn3dui,o=this;for(n=e;n<=t;++n){let i=n===s-1;if(!l.commands[n].trim())continue;if(!l.atoms&&-1==l.commands[n].indexOf("load"))continue;let a=l.commands[n].split("|||"),d=a[0].trim();if(-1!==d.indexOf("load")){if(0===t&&e===t)return void(l.bNotLoadStructure?(l.hAtoms=r.hashUtilsCls.cloneHash(l.atoms),1===l.commands.length&&(l.bAddCommands=!0),i&&this.renderFinalStep(s)):(await o.applyCommandLoad(l.commands[n]),1===l.commands.length&&(l.bAddCommands=!0),i&&o.renderFinalStep(s)));l.bNotLoadStructure?(l.hAtoms=r.hashUtilsCls.cloneHash(l.atoms),l.backForward&&this.renderFinalStep(1)):(await o.applyCommandLoad(l.commands[n]),l.backForward&&o.renderFinalStep(1))}else if(0==d.indexOf("set map")&&-1==d.indexOf("set map wireframe")){let e=a[0].trim().split(" | ")[0].substr(8).split(" ");3==e.length&&"sigma"==e[1]&&(e[2],e[0],await o.applyCommandMap(a[0].trim()))}else if(0==d.indexOf("set emmap")&&-1==d.indexOf("set emmap wireframe")){let e=a[0].trim().substr(10).split(" ");2==e.length&&"percentage"==e[0]&&(e[1],await o.applyCommandEmmap(a[0].trim()))}else if(0==d.indexOf("set phi"))await l.delphiCls.applyCommandPhi(a[0].trim());else if(0==d.indexOf("set delphi"))await l.delphiCls.applyCommandDelphi(a[0].trim());else if(0==d.indexOf("view annotations"))Object.keys(l.proteins).length>0&&await o.applyCommandAnnotationsAndCddSite(a[0].trim());else if(0==d.indexOf("set annotation clinvar"))Object.keys(l.proteins).length>0&&await o.applyCommandClinvar(a[0].trim());else if(0==d.indexOf("set annotation snp"))Object.keys(l.proteins).length>0&&await o.applyCommandSnp(a[0].trim());else if(0==d.indexOf("set annotation ptm"))Object.keys(l.proteins).length>0&&await o.applyCommandPTM(a[0].trim());else if(0==d.indexOf("ig refnum on"))await l.refnumCls.showIgRefNum();else if(0==d.indexOf("set annotation 3ddomain"))Object.keys(l.proteins).length>0&&o.applyCommand3ddomain(a[0].trim());else if(0==d.indexOf("set annotation all"))Object.keys(l.proteins).length>0&&(await o.applyCommandClinvar(a[0].trim()),await o.applyCommandSnp(a[0].trim()),o.applyCommand3ddomain(a[0].trim())),await l.annotationCls.setAnnoTabAll();else if(0==d.indexOf("view interactions")&&void 0!==r.cfg.align)await o.applyCommandViewinteraction(a[0].trim());else if(0==d.indexOf("symmetry")){l.bAxisOnly=!1;let e=d.substr(d.indexOf(" ")+1);l.symmetrytitle="none"===e?void 0:e,"none"!==e&&await l.symdCls.retrieveSymmetry(Object.keys(l.structures)[0]),l.drawCls.draw()}else if(0==d.indexOf("symd symmetry"))l.bAxisOnly=!1,await l.symdCls.applyCommandSymd(d),l.drawCls.draw();else if(0==d.indexOf("scap"))await l.scapCls.applyCommandScap(d);else if(0==d.indexOf("realign on seq align"))this.getNameArray(d),await o.applyCommandRealign(d);else if(0==d.indexOf("realign on structure align msa")){let e=this.getNameArray(d);r.cfg.aligntool="vast",await l.realignParserCls.realignOnStructAlignMsa(e)}else if(0==d.indexOf("realign on structure align"))this.getNameArray(d),r.cfg.aligntool="vast",await l.realignParserCls.realignOnStructAlign();else if(0==d.indexOf("realign on tmalign msa")){let e=this.getNameArray(d);r.cfg.aligntool="tmalign",await l.realignParserCls.realignOnStructAlignMsa(e)}else if(0==d.indexOf("realign on tmalign"))this.getNameArray(d),r.cfg.aligntool="tmalign",await l.realignParserCls.realignOnStructAlign();else if(0==d.indexOf("realign on vastplus"))o.getHAtoms(l.commands[n]),await l.vastplusCls.realignOnVastplus();else if(0==d.indexOf("graph interaction pairs"))await o.applyCommandGraphinteraction(d);else if(0==d.indexOf("cartoon 2d domain"))await o.applyCommandCartoon2d(d);else if(0==d.indexOf("set half pae map"))await o.applyCommandAfmap(d);else if(0==d.indexOf("set full pae map"))await o.applyCommandAfmap(d,!0);else if(0==d.indexOf("export pqr"))await r.htmlCls.setHtmlCls.exportPqr();else if(0==d.indexOf("cartoon 2d chain")||0==d.indexOf("cartoon 2d secondary")){let e=d.lastIndexOf(" "),t=d.substr(e+1);await l.cartoon2dCls.draw2Dcartoon(t)}else await l.applyCommandCls.applyCommand(l.commands[n])}(n===s||i)&&this.renderFinalStep(n)}pressCommandtext(){let e=this.icn3d,t=e.icn3dui,s=this;$("#"+e.pre+"logtext").keypress((async function(e){let i=s.icn3d;if(i.bAddLogs=!1,13==(e.keyCode?e.keyCode:e.which)){e.preventDefault();let n=$(this).val();i.bRender=!0;let l=n.split("\n"),r=i.logs.length;for(let e=r,n=l.length;e "+i.logs.join("\n> ")+"\n> ").scrollTop($("#"+i.pre+"logtext")[0].scrollHeight)}i.bAddLogs=!0}))}async applyCommandLoad(e){let t=this.icn3d,s=t.icn3dui;t.bAddCommands=!1;let i=e.split("|||")[0].replace(/\s\s/g," ").trim();if(-1!==i.indexOf("load")){let e=i.split(" | "),n=e[0];if(e.length>1){let t=e[e.length-1].indexOf(" ");s.cfg.inpara=e[e.length-1].substr(t+1),"undefined"===s.cfg.inpara&&(s.cfg.inpara="")}let l=n.substr(n.lastIndexOf(" ")+1);if(t.structures.hasOwnProperty(l))return;if(t.inputid=l,-1!==i.indexOf("load mmtf"))s.cfg.mmtfid=l,await t.mmtfParserCls.downloadMmtf(l);else if(-1!==i.indexOf("load pdb"))s.cfg.pdbid=l,await t.pdbParserCls.downloadPdb(l);else if(-1!==i.indexOf("load af"))s.cfg.afid=l,await t.pdbParserCls.downloadPdb(l,!0);else if(-1!==i.indexOf("load opm"))s.cfg.opmid=l,await t.opmParserCls.downloadOpm(l);else if(-1!==i.indexOf("load mmcif"))s.cfg.mmcifid=l,await t.mmcifParserCls.downloadMmcif(l);else if(-1!==i.indexOf("load mmdb ")||-1!==i.indexOf("load mmdb1 "))s.cfg.mmdbid=l,s.cfg.bu=1,await t.mmdbParserCls.downloadMmdb(l);else if(-1!==i.indexOf("load mmdb0"))s.cfg.mmdbid=l,s.cfg.bu=0,await t.mmdbParserCls.downloadMmdb(l);else if(-1!==i.indexOf("load mmdbaf1"))s.cfg.mmdbafid=l,s.cfg.bu=1,await t.chainalignParserCls.downloadMmdbAf(l);else if(-1!==i.indexOf("load mmdbaf0"))s.cfg.mmdbafid=l,s.cfg.bu=0,await t.chainalignParserCls.downloadMmdbAf(l);else if(-1!==i.indexOf("load gi"))s.cfg.gi=l,await t.mmdbParserCls.downloadGi(l);else if(-1!==i.indexOf("load refseq"))s.cfg.refseqid=l,await t.mmdbParserCls.downloadRefseq(l);else if(-1!==i.indexOf("load seq_struct_ids "))t.bSmithwm=!1,t.bLocalSmithwm=!1,await t.mmdbParserCls.downloadBlast_rep_id(l);else if(-1!==i.indexOf("load seq_struct_ids_smithwm "))t.bSmithwm=!0,await t.mmdbParserCls.downloadBlast_rep_id(l);else if(-1!==i.indexOf("load seq_struct_ids_local_smithwm "))t.bLocalSmithwm=!0,await t.mmdbParserCls.downloadBlast_rep_id(l);else if(-1!==i.indexOf("load cid"))s.cfg.cid=l,await t.sdfParserCls.downloadCid(l);else if(-1!==i.indexOf("load alignment"))if(s.cfg.align=l,s.cfg.inpara||-1==s.cfg.inpara.indexOf("atype=2"))await t.alignParserCls.downloadAlignment(s.cfg.align);else{let e=2;await t.chainalignParserCls.downloadMmdbAf(s.cfg.align,void 0,e)}else if(-1!==i.indexOf("load chainalignment")){let e=i.split(" | ");e.length>1&&-1!=e[1].indexOf("resnum")&&(s.cfg.resnum=e[1].substr(e[1].indexOf("resnum")+7)),e.length>2&&-1!=e[2].indexOf("resdef")&&(s.cfg.resdef=e[2].substr(e[1].indexOf("resdef")+7)),e.length>3&&-1!=e[3].indexOf("aligntool")&&(s.cfg.aligntool=e[3].substr(e[1].indexOf("aligntool")+10)),s.cfg.chainalign=l,await t.chainalignParserCls.downloadChainalignment(l,s.cfg.resnum,s.cfg.resdef)}else if(-1!==i.indexOf("load url")){let i=e[1],n=void 0!==i?i.indexOf("type "):-1,r="pdb";-1!==n&&(r=i.substr(n+5)),s.cfg.url=l,await t.pdbParserCls.downloadUrl(l,r)}}t.bAddCommands=!0}applyCommandMap(e){let t=this.icn3d;t.icn3dui;let s=e.split(" | "),i=s[0].substr(8).split(" ");if(3==i.length&&"sigma"==i[1]){let e=i[2],n=i[0];2==s.length?t.dsn6ParserCls.dsn6ParserBase(s[1],n,e):t.dsn6ParserCls.dsn6Parser(t.inputid,n,e)}}applyCommandEmmap(e){let t=this.icn3d;t.icn3dui;let s=e.substr(10).split(" ");if(2==s.length&&"percentage"==s[0]){let e=s[1],i="em";t.densityCifParserCls.densityCifParser(t.inputid,i,e,t.emd)}}async applyCommandRealign(e){let t=this.icn3d;t.icn3dui,await t.realignParserCls.realignOnSeqAlign()}async applyCommandRealignByStruct(e){let t=this.icn3d;t.icn3dui,t.drawCls.draw(),await t.realignParserCls.realignOnStructAlign()}async applyCommandAfmap(e,t){let s=this.icn3d;s.icn3dui;let i=e.substr(e.lastIndexOf(" ")+1);await s.contactMapCls.afErrorMap(i,t)}async applyCommandGraphinteraction(e){let t=this.icn3d;t.icn3dui;let s=e.split(" | ");if(s.length>=3){let e,i=s[1].split(" "),n=i[0].split(","),l=i[1].split(","),r=-1!==s[2].indexOf("hbonds"),o=-1!==s[2].indexOf("salt bridge"),a=-1!==s[2].indexOf("interactions"),d=-1!==s[2].indexOf("halogen"),c=-1!==s[2].indexOf("pi-cation"),h=-1!==s[2].indexOf("pi-stacking");s.length>=4&&(e="true"==s[3]),t.applyCommandCls.setStrengthPara(s),await t.viewInterPairsCls.viewInteractionPairs(n,l,e,"graph",r,o,a,d,c,h)}}async applyCommandCartoon2d(e){let t=this.icn3d;t.icn3dui;let s=e.substr(e.lastIndexOf(" ")+1);await t.cartoon2dCls.draw2Dcartoon(s)}async applyCommandAnnotationsAndCddSite(e){let t=this.icn3d;t.icn3dui,"view annotations"==e&&await t.showAnnoCls.showAnnotations()}async applyCommandClinvar(e){let t=this.icn3d;t.icn3dui;let s=e.lastIndexOf(" ");e.substr(s+1),await t.annotationCls.setAnnoTabClinvar()}async applyCommandSnp(e){let t=this.icn3d;t.icn3dui;let s=e.lastIndexOf(" ");e.substr(s+1),await t.annotationCls.setAnnoTabSnp()}async applyCommandPTM(e){let t=this.icn3d;t.icn3dui;let s=e.lastIndexOf(" ");e.substr(s+1),await t.annotationCls.setAnnoTabPTM()}applyCommand3ddomain(e){let t=this.icn3d;t.icn3dui;let s=e.lastIndexOf(" "),i=e.substr(s+1);"3ddomain"!=i&&"all"!=i||t.annotationCls.setAnnoTab3ddomain()}async applyCommandViewinteraction(e){let t=this.icn3d,s=t.icn3dui;if(void 0!==s.cfg.align||void 0!==s.cfg.chainalign){let e=Object.keys(t.structures);await t.ParserUtilsCls.set2DDiagramsForAlign(e[0].toUpperCase(),e[1].toUpperCase())}}renderFinalStep(e){let t=this.icn3d,s=t.icn3dui;t.bCommandLoad=!1,t.ParserUtilsCls.hideLoading(),e+1===t.commands.length&&(t.bAddCommands=!0),t.bRender=!0;let i=t.commands[e-1]?t.commands[e-1].split("|||"):[];if(2==i.length){let e=JSON.parse(i[1]);t._zoomFactor=e.factor,t.mouseChange.x=e.mouseChange.x,t.mouseChange.y=e.mouseChange.y,t.quaternion._x=e.quaternion._x,t.quaternion._y=e.quaternion._y,t.quaternion._z=e.quaternion._z,t.quaternion._w=e.quaternion._w}if(t.selectionCls.oneStructurePerWindow(),1===e||t.hAtoms&&t.atoms&&Object.keys(t.hAtoms).length===Object.keys(t.atoms).length||void 0!==t.optsHistory[e-1]&&t.optsHistory[e-1].hasOwnProperty("hlatomcount")&&t.optsHistory[e-1].hlatomcount===Object.keys(t.atoms).length)if(t.optsHistory.length>=e){let s=t.optsHistory[e-1].pk;"no"===s?t.pk=0:"atom"===s?t.pk=1:"residue"===s?t.pk=2:"strand"===s&&(t.pk=3),t.hlUpdateCls.updateHlAll(),t.drawCls.draw()}else t.hlUpdateCls.updateHlAll(),t.drawCls.draw();else t.hlUpdateCls.updateHlAll(),t.drawCls.draw();s.cfg.closepopup&&(setTimeout((function(){t.resizeCanvasCls.closeDialogs()}),100),t.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH,s.htmlCls.HEIGHT,!0)),t.bTransparentSurface&&t.bRender&&t.drawCls.render()}async replayFirstStep(e){let t=this.icn3d,s=t.icn3dui;t.reinitAfterLoad(),await this.execCommandsBase(e,e,t.STATENUMBER);let i=t.commands[e],n=t.commands[e].indexOf("|");-1!=n&&(i=t.commands[e].substr(0,n));let l=i.length>20?i.substr(0,20)+"...":i,r=t.applyCommandCls.getMenuFromCmd(i);$("#"+t.pre+"replay_cmd").html("Cmd: "+l),$("#"+t.pre+"replay_menu").html("Menu: "+r),s.htmlCls.clickMenuCls.setLogCmd(i,!0),t.bCommandLoad=!1,t.ParserUtilsCls.hideLoading(),t.bRender=!0,t.drawCls.draw()}getHAtoms(e){let t=this.icn3d;t.icn3dui;let s=e.split("|||")[0].trim().split(" | ");if(2==s.length){let e=s[1].split(",");t.hAtoms=t.definedSetsCls.getAtomsFromNameArray(e)}}}class as{constructor(e){this.icn3d=e}async selectByCommand(e,t,s){let i=this.icn3d,n=i.icn3dui;if(0===e.indexOf("saved atoms")){let s=12,n=e.substr(s);i.definedSetsCls.selectCombinedSets(n,t)}else{let l=e.replace(/ AND /g," and ").replace(/ OR /g," or ").replace(/ or and /g," and ").replace(/ and /g," or and ").replace(/ or not /g," not ").replace(/ not /g," or not "),r=("select"===l.trim().substr(0,6)?l.trim().substr(7):l.trim()).split(" or "),o={};for(let e=0,t=r.length;e1||1==o.length&&"*"!==o[0])&&(h=!1);let C,y,v,w,_=[],S=[];if(_="*"===t?Object.keys(l.structures):t.split(","),"*"===s){let e=Object.keys(l.chains);for(let t=0,s=e.length;t1&&"3"===x[t][0]&&isNaN(x[t][1])&&"-"!==x[t][0]){i=x[t].toUpperCase().substr(1),m=!0}else if(""===x[t]||isNaN(parseInt(x[t]))){if("*"===x[t])h=!0;else if("proteins"!==x[t]&&"nucleotides"!==x[t]&&"chemicals"!==x[t]&&"ions"!==x[t]&&"water"!==x[t]){s=x[t].toUpperCase(),p=!0}}else v=x[t],w=v,n=!0;for(let a=0,u=S.length;a1?e.substr(0,l-1)===n.atoms[i].name.substr(0,l-1)&&(0===s?t[i]=1:t.hasOwnProperty(i)||delete t[i]):"*"!==e&&e!==n.atoms[i].name||(0===s?t[i]=1:t.hasOwnProperty(i)||delete t[i]),t}}class ds{constructor(e){this.icn3d=e}selectAll(){let e=this.icn3d;e.icn3dui,this.selectAll_base(),e.hlObjectsCls.removeHlObjects(),e.hlUpdateCls.removeHl2D(),e.hlUpdateCls.removeHlMenus(),e.bSelectResidue=!1,e.bSelectAlignResidue=!1,e.hlUpdateCls.removeSeqResidueBkgd(),e.hlUpdateCls.update2DdgmContent(),$("#"+e.pre+"dl_annotations > .icn3d-annotation").show(),e.definedSetsCls.setMode("all"),e.saveFileCls.showTitle()}selectAll_base(){let e=this.icn3d,t=e.icn3dui;e.hAtoms={},e.dAtoms={};for(let s in e.chains)e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.chains[s]);e.dAtoms=t.hashUtilsCls.cloneHash(e.hAtoms),e.viewSelectionAtoms=t.hashUtilsCls.cloneHash(e.hAtoms),e.ALTERNATE_STRUCTURE=-1}selectAChain(e,t,s,i){let n=this.icn3d,l=n.icn3dui;t=t.replace(/\s/g,"");let r=void 0!==s||s?"select alignChain "+e:"select chain "+e;void 0!==i&&i?(n.hAtoms=l.hashUtilsCls.unionHash(n.hAtoms,n.chains[e]),void 0===n.nameArray&&(n.nameArray=[])):(n.hAtoms={},n.nameArray=[]),n.nameArray.push(e);let o,a=s?n.alnChainsSeq[e]:n.chainsSeq[e];o=void 0===a?0:a.length;let d={};for(let t=0,s=o;t0){if(void 0!==i&&i?void 0===r.nameArray&&(r.nameArray=[]):(r.hAtoms={},r.nameArray=[]),l)for(let t in e)r.hAtoms[t]=1;else for(let t in e)for(let e in r.residues[t])r.hAtoms[e]=1;let o,a;t=t.replace(/\s/g,""),r.nameArray.push(t),l?(o="select "+r.resid2specCls.atoms2spec(r.hAtoms),a=!1):(o="select "+r.resid2specCls.residueids2spec(Object.keys(e)),a=!0);let d=Object.keys(e);this.addCustomSelection(d,t,s,o,a),(void 0===n||n)&&r.hlUpdateCls.updateHlAll(r.nameArray,void 0,i)}}selectMainChains(){let e=this.icn3d,t=e.icn3dui.hashUtilsCls.cloneHash(e.hAtoms);e.hAtoms=e.applyDisplayCls.selectMainChainSubset(t),e.hlUpdateCls.showHighlight()}selectSideChains(){let e=this.icn3d,t=e.icn3dui,s=t.hashUtilsCls.cloneHash(e.hAtoms);e.hAtoms={};for(let i in s)(e.proteins.hasOwnProperty(i)&&"N"!==e.atoms[i].name&&"H"!==e.atoms[i].name&&"C"!==e.atoms[i].name&&"O"!==e.atoms[i].name&&("CA"!==e.atoms[i].name||"C"!==e.atoms[i].elem)&&"HA"!==e.atoms[i].name||e.nucleotides.hasOwnProperty(i)&&-1===t.parasCls.nuclMainArray.indexOf(e.atoms[i].name))&&(e.hAtoms[i]=1);e.hlUpdateCls.showHighlight()}selectMainSideChains(){let e=this.icn3d,t=e.icn3dui,s=e.firstAtomObjCls.getResiduesFromAtoms(e.hAtoms);e.hAtoms={};for(let i in s)e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.residues[i]),e.dAtoms=t.hashUtilsCls.unionHash(e.dAtoms,e.residues[i]);e.drawCls.draw(),e.hlUpdateCls.showHighlight()}clickShow_selected(){let e=this.icn3d,t=e.icn3dui,s=this;t.myEventCls.onIds(["#"+e.pre+"show_selected","#"+e.pre+"mn2_show_selected"],"click",(function(e){s.icn3d,s.showSelection(),t.htmlCls.clickMenuCls.setLogCmd("show selection",!0)}))}clickHide_selected(){let e=this.icn3d,t=e.icn3dui,s=this;t.myEventCls.onIds("#"+e.pre+"mn2_hide_selected","click",(function(e){s.icn3d,s.hideSelection(),t.htmlCls.clickMenuCls.setLogCmd("hide selection",!0)}))}getGraphDataForDisplayed(){let e=this.icn3d;e.icn3dui;let t=JSON.parse(e.graphStr),s=e.firstAtomObjCls.getResiduesFromAtoms(e.dAtoms),i=[],n=[],l={};for(let e=0,n=t.nodes.length;e0)if(1==s.pk){let n=!0;this.selectResidueList(s.hAtoms,e,t,void 0,void 0,n),this.updateSelectionNameDesc(),i.htmlCls.clickMenuCls.setLogCmd("select "+s.resid2specCls.atoms2spec(s.hAtoms)+" | name "+e,!0)}else this.selectResidueList(s.selectedResidues,e,t),this.updateSelectionNameDesc(),i.htmlCls.clickMenuCls.setLogCmd("select "+s.resid2specCls.residueids2spec(Object.keys(s.selectedResidues))+" | name "+e,!0)}saveSelInCommand(){let e=this.icn3d,t=e.icn3dui;e.selectedResidues=e.firstAtomObjCls.getResiduesFromCalphaAtoms(e.hAtoms),t.htmlCls.clickMenuCls.setLogCmd("select "+e.resid2specCls.residueids2spec(Object.keys(e.selectedResidues)),!0)}saveEachResiInSel(){let e=this.icn3d;e.icn3dui,e.selectionCls.saveSelectionPrep(),e.selectedResidues={},e.selectedResidues=e.firstAtomObjCls.getResiduesFromCalphaAtoms(e.hAtoms);for(let t in e.selectedResidues){let s={};s[t]=1;let i=t+"_"+e.selectedResidues[t];this.selectResidueList(s,i,i)}}removeSelection(){let e=this.icn3d;e.icn3dui,e.bAnnotations||e.hlUpdateCls.removeSeqChainBkgd(),e.bCtrl||e.bShift||(e.hlUpdateCls.removeSeqResidueBkgd(),e.hlUpdateCls.removeSeqChainBkgd()),e.selectedResidues={},e.bSelectResidue=!1,e.hAtoms={},e.hlObjectsCls.removeHlObjects(),e.hlUpdateCls.removeHl2D()}resetAll(){let e=this.icn3d,t=e.icn3dui;e.maxD=e.oriMaxD,e.center=e.oriCenter.clone(),e.opts=t.hashUtilsCls.cloneHash(e.optsOri),e.setOptionCls.setStyle("sidec","nothing"),e.reinitAfterLoad(),e.loadScriptCls.renderFinalStep(1),e.definedSetsCls.setMode("all"),e.selectionCls.selectAll(),t.htmlCls.clickMenuCls.setLogCmd("reset",!0),e.hlUpdateCls.removeSeqChainBkgd(),e.hlUpdateCls.removeSeqResidueBkgd(),e.hlUpdateCls.removeHl2D(),e.hlUpdateCls.removeHlMenus()}async loadSelection(e){let t=this.icn3d,s=t.icn3dui,i=e.trim().split("\n");for(let e=0,n=i.length;e=t&&l.coord.z<=e)){i[l.structure+"_"+l.chain+"_"+l.resi]=1}}let n="z_planes_"+e+"_"+t,l=n;this.selectResidueList(i,n,l,!1)}}class cs{constructor(e){this.icn3d=e}residueids2spec(e){var t=this.icn3d;t.icn3dui;let s="";if(void 0!==e){let i,n,l,r,o,a,d,c=e.sort((function(e,t){if(""!==e&&!isNaN(e))return parseInt(e)-parseInt(t);{let s=e.lastIndexOf("_"),i=t.lastIndexOf("_");if(e.substr(0,s)t.substr(0,i))return 1;if(e.substr(0,s)==t.substr(0,i)){if(parseInt(e.substr(s+1))parseInt(t.substr(i+1)))return 1;if(parseInt(e.substr(s+1))==parseInt(t.substr(i+1)))return 0}}})),h="",p=0,m=1!=Object.keys(t.structures).length;for(let e=0,u=c.length;e0&&(s+=p===d?m?"$"+o+"."+a+":"+d+" or ":"."+a+":"+d+" or ":m?"$"+o+"."+a+":"+d+"-"+p+" or ":"."+a+":"+d+"-"+p+" or "),d=n;else if(h===i){let e=t.ParserUtilsCls.getResiNCBI(h,p);t.ParserUtilsCls.getResiNCBI(i,n)!=e+1&&(s+=p===d?m?"$"+o+"."+a+":"+d+" or ":"."+a+":"+d+" or ":m?"$"+o+"."+a+":"+d+"-"+p+" or ":"."+a+":"+d+"-"+p+" or ",d=n)}h=i,p=n}}r=h.indexOf("_"),o=h.substr(0,r),a=h.substr(r+1),s+=p===d?m?"$"+o+"."+a+":"+d:"."+a+":"+d:m?"$"+o+"."+a+":"+d+"-"+p:"."+a+":"+d+"-"+p}return s}atoms2spec(e){var t=this.icn3d;t.icn3dui;let s,i="",n=0,l={},r={},o={};for(let a in e)s=t.atoms[a],n>0&&(i+=" or "),i+="$"+s.structure+"."+s.chain+":"+s.resi+"@"+s.name,l[s.structure]=1,r[s.structure+"_"+s.chain]=1,o[s.structure+"_"+s.chain+"_"+s.resi]=1,++n;if(1==Object.keys(o).length){let e="\\$"+s.structure+"\\."+s.chain+":"+s.resi;i=i.replace(new RegExp(e,"g"),"")}else if(1==Object.keys(r).length){let e="\\$"+s.structure+"\\."+s.chain;i=i.replace(new RegExp(e,"g"),"")}else if(1==Object.keys(l).length){let e="\\$"+s.structure;i=i.replace(new RegExp(e,"g"),"")}return i}atoms2residues(e){var t=this.icn3d;t.icn3dui;let s={};for(let t=0,i=e.length;t=parseInt(t)&&e.b<=parseInt(s)&&(i.hAtoms=n.hashUtilsCls.unionHash(i.hAtoms,i.residues[e.structure+"_"+e.chain+"_"+e.resi]))}}else if("percent out"==e){i.bCalcArea=!0,i.opts.surface="solvent accessible surface",i.applyMapCls.applySurfaceOptions(),i.bCalcArea=!1,i.hAtoms={};for(let e in i.resid2area){let l=e.lastIndexOf("_"),r=e.substr(l+1);if(n.parasCls.residueArea.hasOwnProperty(r)){let o=parseInt(i.resid2area[e]/n.parasCls.residueArea[r]*100);if(o>=t&&o<=s){let t=e.substr(0,l);i.hAtoms=n.hashUtilsCls.unionHash(i.hAtoms,i.residues[t])}}}}i.hAtoms=n.hashUtilsCls.intHash(i.hAtoms,l),i.drawCls.draw(),i.hlUpdateCls.updateHlAll()}selectComplement(){let e=this.icn3d,t=e.icn3dui,s={};for(let t in e.atoms)e.hAtoms.hasOwnProperty(t)||(s[t]=1);e.hAtoms=t.hashUtilsCls.cloneHash(s),e.hlUpdateCls.updateHlAll()}switchHighlightLevel(){var e=this.icn3d.icn3dui;if(e.bNode)return;let t=this;document.addEventListener("keydown",(function(s){let i=t.icn3d;38===s.keyCode?(s.preventDefault(),0!=Object.keys(i.pickedAtomList).length&&i.hAtoms.hasOwnProperty(i.firstAtomObjCls.getFirstAtomObj(i.pickedAtomList).serial)||(i.pickedAtomList=e.hashUtilsCls.cloneHash(i.hAtoms)),t.switchHighlightLevelUp(),e.htmlCls.clickMenuCls.setLogCmd("highlight level up",!0)):40===s.keyCode&&(s.preventDefault(),0!=Object.keys(i.pickedAtomList).length&&i.hAtoms.hasOwnProperty(i.firstAtomObjCls.getFirstAtomObj(i.pickedAtomList).serial)||(i.pickedAtomList=e.hashUtilsCls.cloneHash(i.hAtoms)),t.switchHighlightLevelDown(),e.htmlCls.clickMenuCls.setLogCmd("highlight level down",!0))}))}switchHighlightLevelUp(){var e=this.icn3d,t=e.icn3dui;if(!t.bNode){if(e.bShift||e.bCtrl||e.hlObjectsCls.removeHlObjects(),void 0!==e.pickedAtomList&&0!==Object.keys(e.pickedAtomList).length||(e.pickedAtomList=t.hashUtilsCls.cloneHash(e.hAtoms)),0===Object.keys(e.pickedAtomList).length&&(e.pickedAtomList=e.dAtoms),1===e.highlightlevel){e.highlightlevel=2;let s=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);e.bShift||e.bCtrl?e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.residues[s.structure+"_"+s.chain+"_"+s.resi]):e.hAtoms=t.hashUtilsCls.cloneHash(e.residues[s.structure+"_"+s.chain+"_"+s.resi])}else if(2===e.highlightlevel){e.highlightlevel=3;let s=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);e.bShift||e.bCtrl?e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.pickingCls.selectStrandHelixFromAtom(s)):e.hAtoms=t.hashUtilsCls.cloneHash(e.pickingCls.selectStrandHelixFromAtom(s))}else if(3===e.highlightlevel){let s;if(void 0!==t.cfg.mmdbid||void 0!==t.cfg.gi){e.highlightlevel=4;let i=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);s=e.pickingCls.select3ddomainFromAtom(i),e.bShift||e.bCtrl?e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,s):e.hAtoms=t.hashUtilsCls.cloneHash(s)}if(void 0===t.cfg.mmdbid&&void 0===t.cfg.gi||0==Object.keys(s).length){e.highlightlevel=5;let s=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);e.bShift||e.bCtrl?e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.chains[s.structure+"_"+s.chain]):e.hAtoms=t.hashUtilsCls.cloneHash(e.chains[s.structure+"_"+s.chain])}}else if(4===e.highlightlevel){e.highlightlevel=5;let s=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);e.bShift||e.bCtrl?e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.chains[s.structure+"_"+s.chain]):e.hAtoms=t.hashUtilsCls.cloneHash(e.chains[s.structure+"_"+s.chain])}else if(5===e.highlightlevel||6===e.highlightlevel){e.highlightlevel=6;let s=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);e.bShift||e.bCtrl||(e.hAtoms={});let i=e.structures[s.structure];for(let s=0,n=i.length;s3e4)return void(e?console.log("The maximum number of allowed atoms is 30,000. Please try it again with selected chains..."):alert("The maximum number of allowed atoms is 30,000. Please try it again with selected chains..."));let o="";return o+=s.cfg.cid?t.saveFileCls.getAtomPDB(n,!0):t.saveFileCls.getAtomPDB(n),o+=t.saveFileCls.getAtomPDB(i,!0,void 0,!0),o}async CalcPhi(e,t,s,i,n){let l=this.icn3d;l.icn3dui;let r=await this.CalcPhiPrms(e,t,s,i,n);this.loadPhiData(r,s,i),l.bAjaxPhi=!0,i?l.setOptionCls.setOption("phisurface","phi"):l.setOptionCls.setOption("phimap","phi")}CalcPhiPrms(e,t,s,i,n){let l=this.icn3d,r=l.icn3dui;l.loadPhiFrom="delphi";let o=r.htmlCls.baseUrl+"delphi/delphi.cgi",a=r.cfg.cid?r.cfg.cid:Object.keys(l.structures).toString(),d={};if(n)d={pqr2phi:n,gsize:e,salt:t,pdbid:a};else{let s=this.getPdbStr();d={pdb2phi:s,gsize:e,salt:t,pdbid:a}}return new Promise((function(e,t){$.ajax({url:o,type:"POST",data:d,dataType:"binary",responseType:"arraybuffer",cache:!0,beforeSend:function(){l.ParserUtilsCls.showLoading()},complete:function(){l.ParserUtilsCls.hideLoading()},success:function(t){e(t)},error:function(e,t,s){}})}))}PhiParser(e,t,s,i){let n=this.icn3d;n.icn3dui;let l=this,r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="phiurl"==t||"phiurl2"==t?"arraybuffer":"text",r.onreadystatechange=function(){if(4==this.readyState)if(200==this.status){let e=r.response;"phiurl"==t||"phiurl2"==t?l.loadPhiData(e,s,i):l.loadCubeData(e,s,i),n.bAjaxPhi=!0,i?n.setOptionCls.setOption("phisurface","phi"):n.setOptionCls.setOption("phimap","phi")}else alert("The potential file is unavailable...");else n.ParserUtilsCls.showLoading()},r.send()}loadPhiData(e,t,s){let i=this.icn3d;i.icn3dui;let n={filetype:"phi"},l=e.buffer&&e.buffer instanceof ArrayBuffer?e.buffer:e,r=new Float32Array(l.slice(l.byteLength-24,l.byteLength-8));n.scale=r[0];let o=r[1],a=r[2],d=r[3];n.n=new Int32Array(l.slice(l.byteLength-8,l.byteLength-4)),n.xExtent=n.yExtent=n.zExtent=n.n;let c=1/n.scale*((n.n-1)/2);n.ori=new THREE.Vector3(o-c,a-c,d-c);let h=new Float32Array(l.slice(110,l.byteLength-56));n.bSurface=s,i.mapData.headerPhi=n,i.mapData.dataPhi=h,i.mapData.contourPhi=t;let p=new THREE.Matrix4;p.identity(),p.multiply((new THREE.Matrix4).makeTranslation(n.ori.x,n.ori.y,n.ori.z)),i.mapData.matrixPhi=p}loadCubeData(e,t,s){let i=this.icn3d;i.icn3dui;let n={filetype:"cube"},l=e.split("\n"),r=[];r.push(parseFloat(l[0].substr(0,10))),r.push(parseFloat(l[0].substr(10,6))),r.push(parseFloat(l[0].substr(16,10))),r.push(parseFloat(l[0].substr(26,10))),r.push(parseFloat(l[0].substr(36,10))),n.scale=r[0];let o=r[2],a=r[3],d=r[4];n.n=r[1],n.xExtent=n.yExtent=n.zExtent=n.n;let c=1/n.scale*((n.n-1)/2);n.ori=new THREE.Vector3(o-c,a-c,d-c);let h=[];for(let e=7,t=l.length;e0)e.bShowRefnum=!0,e.hAtomsRefnum={},await e.showAnnoCls.showAnnotations(),e.annotationCls.setAnnoViewAndDisplay("detailed view");else if(e.refpdbArray=["1bqu_fn3","1cd8_igv","1cdh_cd4","1dr9_cd80","1hnf_cd2","1hxm_d","1hxm_g","1ifr_lamin","1ncn_cd86","1t6v_vnar","1yjd_cd28","2atp_a","2atp_b","2dm3_iset","3kys_tead1","3pv7_ncr","4f9l_cd277","4gos_vtc","4i0k_cd276","4jqi_b","4z18_cd274","4zqk_pd1","4zt1_e","5esv_vh","5esv_vl","6al5_cd19","6jxr_a","6jxr_b","6jxr_d","6jxr_e","6jxr_g","6oil_vista","6rp8_at","6rp8_t","6umt_cd273","6x4g_cd275","6x4g_icos","7xq8_a","7xq8_b","q71h61_ild","q9um44_hhl"],e.pdbDataArray)await s.parseRefPdbData(e.pdbDataArray);else{let i=[];for(let s=0,n=e.refpdbArray.length;sl[d])&&(l[d]=o[0].score,i.bNode||console.log(d+" TM-score: "+l[d]+" matched "+s.refpdbArray[a[1]]),s.domainid2index[d]=a[1],r[d]=o[0].segs,s.domainid2ig2kabat[d]=o[0].ig2kabat,s.domainid2ig2imgt[d]=o[0].ig2imgt))}for(let e in s.domainid2index){let t=e.split("-")[0];s.chainid2index.hasOwnProperty(t)||(s.chainid2index[t]=[]),s.chainid2index[t].push(s.domainid2index[e])}for(let e in r){let t=e.split("-")[0];o[t]||(o[t]=[]),o[t]=o[t].concat(r[e])}s.resid2refnum||(s.resid2refnum={}),s.refnum2residArray||(s.refnum2residArray={}),s.chainsMapping||(s.chainsMapping={});for(let e in o){let t,l=o[e];if(!i.bNode){let t="";for(let i=0,n=s.chainid2index[e].length;i0?(s.bShowRefnum=!0,s.hAtomsRefnum={},await s.showAnnoCls.showAnnotations(),s.annotationCls.setAnnoViewAndDisplay("detailed view")):alert("No Ig reference numbers are assigned based on the reference structures in iCn3D...")}getLabelFromRefnum(e,t,s){this.icn3d.icn3dui;let i=parseInt(e);return i<100?" "+e:i>=100&&i<1e3?s?" "+e:"A^"+e:i>=1e3&&i<1200?"A"+e:i>=1200&&i<1300?"A'"+e:i>=1300&&i<1400?"A*"+e:i>=1400&&i<2e3?"A"==t.substr(0,1)?t+e:"A"+e:i>=2e3&&i<3e3?"B"+e:i>=3e3&&i<4e3?"C"+e:i>=4e3&&i<5e3?"C'"+e:i>=5e3&&i<6e3?"C''"+e:i>=6e3&&i<7e3?"D"+e:i>=7e3&&i<8e3?"E"+e:i>=8e3&&i<9e3?"F"+e:i>=9e3&&i<9400?"G"+e:i>=9400&&i<9500?"G*"+e:i>=9500?"G"+e:void 0}async parseCustomRefFile(e){let t=this.icn3d;t.icn3dui,t.bShowCustomRefnum=!0;let s=e.split("\n");t.resid2refnum||(t.resid2refnum={}),t.refnum2residArray||(t.refnum2residArray={}),t.chainsMapping||(t.chainsMapping={});let i=[];for(let e=0,t=s.length;e1e4)return void alert("The maximum number of allowed atoms is 10,000. Please try it again with smaller sets...");let o="";o+=e.saveFileCls.getAtomPDB(n);let a,d={pdb:o,pdbid:Object.keys(e.structures).toString()};try{a=await t.getAjaxPostPromise(i,d,!0);let n,l,o,c=a.rcsb_struct_symmetry,h="none";if(void 0!==c){let i;void 0!==e.rmsd_supr&&void 0!==e.rmsd_supr.rot&&(n=e.rmsd_supr.rot,l=e.rmsd_supr.trans1,o=e.rmsd_supr.trans2),void 0===e.symdArray&&(e.symdArray=[]);for(let t=0,n=c.length;tThe selected residues have no detected symmetry with a Z score of "+a.zscore+" from the program SymD."),t.htmlCls.dialogCls.openDlg("dl_symd","Dynamically Calculated Symmetry Using SymD");else{let n=a.seqalign.replace(/ /g,"").split(","),l=a.nres,o=a.shift,d=a.rmsd,h=Object.keys(r),p={},m={},u=[],g=[],f=0,b=0,C={};for(let e=0,s=n[0].length;et&&(t=C[s].length,e=s);let s=Object.keys(p),i=Object.keys(m);for(let t=0,n=C[e].length;tSymD. The Z score "+a.zscore+" is greater than the threshold Z score 8. The RMSD is "+d+' angstrom.

    The following sequence alignment shows the residue mapping of the best aligned sets: "symOri" and "symPerm", which are also available in the menu "Analysis > Defined Sets".
    ',$("#"+e.pre+"symd_info").html(A),s.setSeqAlignForSymmetry(w,_,S);let x=!1,k=t.htmlCls.alignSeqCls.getAlignSequencesAnnotations(Object.keys(e.alnChains),void 0,void 0,x,S);A=$("#"+e.pre+"dl_sequence2").html()+k.sequencesHtml,$("#"+e.pre+"dl_sequence2").html(A),$("#"+e.pre+"dl_sequence2").width(t.htmlCls.RESIDUE_WIDTH*k.maxSeqCnt+200),t.htmlCls.dialogCls.openDlg("dl_alignment","Select residues in aligned sequences from SymD");let O=Object.keys(e.defNames2Residues).length+Object.keys(e.defNames2Atoms).length,R="symOri"+O;e.selectionCls.selectResidueList(y,R,R),e.selectionCls.updateSelectionNameDesc(),t.htmlCls.clickMenuCls.setLogCmd("select "+e.resid2specCls.residueids2spec(Object.keys(y))+" | name "+R,!1),R="symPerm"+O,e.selectionCls.selectResidueList(v,R,R),e.selectionCls.updateSelectionNameDesc(),t.htmlCls.clickMenuCls.setLogCmd("select "+e.resid2specCls.residueids2spec(Object.keys(v))+" | name "+R,!1),R="symBoth"+O,y=t.hashUtilsCls.unionHash(y,v),e.selectionCls.selectResidueList(y,R,R),e.selectionCls.updateSelectionNameDesc(),t.htmlCls.clickMenuCls.setLogCmd("select "+e.resid2specCls.residueids2spec(Object.keys(y))+" | name "+R,!1)}}else $("#"+e.pre+"dl_symd").html("
    The selected residues have no detected symmetry with a Z score of "+a.zscore+" from the program SymD."),t.htmlCls.dialogCls.openDlg("dl_symd","Dynamically Calculated Symmetry Using SymD");e.symdtitle="none"===h?void 0:h,e.drawCls.draw()}catch(s){return $("#"+e.pre+"dl_symd").html("
    The web service can not determine the symmetry of the input set."),t.htmlCls.dialogCls.openDlg("dl_symd","Dynamically Calculated Symmetry Using SymD"),void e.ParserUtilsCls.hideLoading()}}getResObj(e){this.icn3d.icn3dui;let t=e.substr(0,e.indexOf(" ")),s=e.indexOf("$"),i=e.indexOf("."),n=e.indexOf(":"),l=e.substr(s+1,i-s-1),r=e.substr(i+1,n-i-1),o=e.substr(n+1);return{resn:t,resid:l+"_"+r+"_"+o,resi:o,aligned:!0}}setSeqAlignForSymmetry(e,t,s){let i=this.icn3d,n=i.icn3dui;i.conservedName1="symOri_cons",i.conservedName2="symPerm_cons",i.consHash1={},i.consHash2={},i.alnChainsAnTtl={},i.alnChainsAnno={},i.alnChainsSeq={},i.alnChains={},i.alnChainsSeq={};let l={};for(let r=0,o=e.length;rThis structure has no symmetry."),void i.htmlCls.dialogCls.openDlg("dl_symmetry","Symmetry")}let r,o,a,d=t.rcsb_struct_symmetry;if(void 0!==d){void 0!==s.rmsd_supr&&void 0!==s.rmsd_supr.rot&&(r=s.rmsd_supr.rot,o=s.rmsd_supr.trans1,a=s.rmsd_supr.trans2),s.symmetryHash={};for(let e=0,t=d.length;eThis structure has no symmetry.");else{let e="",t=0;for(let i in s.symmetryHash){e+="",++t}$("#"+s.pre+"selectSymmetry").html(e)}}else $("#"+s.pre+"dl_symmetry").html("
    This structure has no symmetry.");i.htmlCls.dialogCls.openDlg("dl_symmetry","Symmetry")}getPolygonColor(e){let t=this.icn3d.icn3dui,s=e.substr(0,1);return"C"==s?t.parasCls.thr(16747520):"D"==s?t.parasCls.thr(65535):"T"==s?t.parasCls.thr(15631086):"O"==s?t.parasCls.thr(16753920):"I"==s?t.parasCls.thr(65280):t.parasCls.thr(11119017)}getAxisColor(e,t){let s=this.icn3d.icn3dui,i=e.substr(0,1);return"C"==i?s.parasCls.thr(16711680):"D"==i?2==t?s.parasCls.thr(65535):s.parasCls.thr(16711680):"T"==i?2==t?s.parasCls.thr(65535):s.parasCls.thr(65280):"O"==i||"I"==i?2==t?s.parasCls.thr(65535):3==t?s.parasCls.thr(65280):s.parasCls.thr(16711680):s.parasCls.thr(16711680)}}class bs{constructor(e){this.icn3d=e}alignSW(e,t,s,i,n,l,r){this.icn3d.icn3dui;let o=this.bsa_align(r,e,t,[s,i],[n,l]),a="score: "+o[0]+"\n";a+="start: "+o[1]+"\n",a+="cigar: "+this.bsa_cigar2str(o[2])+"\n\n",a+="alignment:\n\n";let d=this.bsa_cigar2gaps(e,t,o[1],o[2]),c={};return c.score=o[0],c.start=o[1],c.cigar=this.bsa_cigar2str(o[2]),c.target=d[0],c.query=d[1],c}bsg_enc_seq(e,t){if(this.icn3d.icn3dui,null==t)return null;let s=[];s.length=e.length;for(let i=0;i0&&(s=-s),i=0;i=2&&"number"==typeof t[0]&&"number"==typeof t[1]){if(null==s)return null;let e="number"==typeof s?s:s[s.length-1]+1;i=this.bsa_gen_score_matrix(e,t[0],t[1])}else i=t;for(let e=0;eo.length?d:o.length;l=null==l||l<0?c:l;let h,p,m=o.target>d?o.target-d:d-o.target;l=l>m?l:m,"number"==typeof n?(h=0,p=n>0?n:-n):(h=n[0]>0?n[0]:-n[0],p=n[1]>0?n[1]:-n[1]);let u,g=h+p,f=-1073741824,b=[],C=[],y=[],v=0,w=-1,_=-1;if(e)for(let e=0;e<=d;++e)b[e]=C[e]=0;else{b[0]=0,C[0]=-g-g;for(let e=1;e<=d;++e)e>=l?b[e]=C[e]=f:(b[e]=-(g+p*(e-1)),C[e]=-(g+g+p*e))}for(let t=0;tl?t-l:0,u=t+l+10?f:-(g+p*t),n=m>0?f:-(g+g+p*t));for(let t=m;t=o?0:1,a=a>=o?a:o,l=a>=n?l:2,a=a>=n?a:n,l=!e||a>0?l:64,i=a,c=r>a?c:t,r=r>a?r:a,a-=g,a=!e||a>0?a:0,o-=p,l|=o>a?4:0,o=o>a?o:a,C[t]=o,n-=p,l|=n>a?32:0,n=n>a?n:a,s[t]=l}b[u]=i,C[u]=e?0:f,r>v&&(v=r,w=t,_=c)}if(e&&0==v)return null;u=e?v:b[d];let S,A,x,k=[],O=0,R=0;for(e?(A=w,x=_,_!=d-1&&this.push_cigar(k,4,d-1-_)):(A=o.length-1,x=(A+l+1=0&&x>=0&&(S=y[A][x-(A>l?A-l:0)],O=S>>(O<<1)&3,!(0==O&&S>>6));)0==O&&(O=3&S),0==O?(this.push_cigar(k,0,1),--A,--x):1==O?(this.push_cigar(k,2,1),--A):(this.push_cigar(k,1,1),--x);e?(x>=0&&this.push_cigar(k,4,x+1),R=A+1):(A>=0&&this.push_cigar(k,2,A+1),x>=0&&this.push_cigar(k,1,x+1));for(let e=0;e>1;++e)S=k[e],k[e]=k[k.length-1-e],k[k.length-1-e]=S;return[u,R,k]}push_cigar(e,t,s){this.icn3d.icn3dui,0==e.length||t!=(15&e[e.length-1])?e.push(s<<4|t):e[e.length-1]+=s<<4}bsa_cigar2gaps(e,t,s,i){this.icn3d.icn3dui;let n="",l="",r="",o=0,a=s;for(let s=0;s>4;0==r?(n+=t.substr(o,d),l+=e.substr(a,d),o+=d,a+=d):1==r?(n+=t.substr(o,d),l+=Array(d+1).join("-"),o+=d):2==r?(n+=Array(d+1).join("-"),l+=e.substr(a,d),a+=d):4==r&&(o+=d)}let d=l.toUpperCase(),c=n.toUpperCase();for(let e=0;e>4).toString()+"MIDNSHP=XB".charAt(15&e[s]));return t.join("")}}class Cs{constructor(e){this.icn3d=e}calculateArea(){var e=this.icn3d,t=e.icn3dui;e.bCalcArea=!0,e.opts.surface="solvent accessible surface",e.applyMapCls.applySurfaceOptions(),$("#"+e.pre+"areavalue").val(e.areavalue),$("#"+e.pre+"areatable").html(e.areahtml),t.htmlCls.dialogCls.openDlg("dl_area","Surface area calculation"),e.bCalcArea=!1}calcBuriedSurface(e,t){var s=this.icn3d,i=s.icn3dui;if(0==e.length)alert("Please select the first set");else{let n=i.hashUtilsCls.cloneHash(s.hAtoms),l=s.definedSetsCls.getAtomsFromNameArray(e),r=s.definedSetsCls.getAtomsFromNameArray(t);s.bCalcArea=!0,s.opts.surface="solvent accessible surface",s.hAtoms=i.hashUtilsCls.cloneHash(l),s.applyMapCls.applySurfaceOptions();let o=s.areavalue,a=i.hashUtilsCls.cloneHash(s.resid2area);s.hAtoms=i.hashUtilsCls.cloneHash(r),s.applyMapCls.applySurfaceOptions();let d=s.areavalue,c=i.hashUtilsCls.cloneHash(s.resid2area);s.hAtoms=i.hashUtilsCls.unionHash(s.hAtoms,l),s.applyMapCls.applySurfaceOptions();let h=s.areavalue,p=i.hashUtilsCls.cloneHash(s.resid2area),m=0,u=0,g=0,f=0;for(let e in a)p.hasOwnProperty(e)&&(f+=parseFloat(p[e]));u=(o-f).toFixed(2);for(let e in c)p.hasOwnProperty(e)&&(g+=parseFloat(p[e]));m=(d-g).toFixed(2),s.bCalcArea=!1,s.hAtoms=i.hashUtilsCls.cloneHash(n);let b=(parseFloat(d)+parseFloat(o)-parseFloat(h)).toFixed(2),C="
    Calculate solvent accessible surface area in the interface:

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

    ",$("#"+s.pre+"dl_buriedarea").html(C),i.htmlCls.dialogCls.openDlg("dl_buriedarea","Buried solvent accessible surface area in the interface"),i.htmlCls.clickMenuCls.setLogCmd("buried surface "+b,!1)}}measureDistTwoSets(e,t){var s=this.icn3d,i=s.icn3dui;if(0==e.length||0==t.length)alert("Please select two sets");else{let n=i.hashUtilsCls.cloneHash(s.hAtoms),l=s.definedSetsCls.getAtomsFromNameArray(e),r=s.definedSetsCls.getAtomsFromNameArray(t),o=s.contactCls.getExtent(l),a=s.contactCls.getExtent(r),d=new THREE.Vector3(o[2][0],o[2][1],o[2][2]),c=new THREE.Vector3(a[2][0],a[2][1],a[2][2]);s.hAtoms=i.hashUtilsCls.cloneHash(n),void 0===s.distPnts&&(s.distPnts=[]),s.distPnts.push(d),s.distPnts.push(c);let h=$("#"+s.pre+"distancecolor2").val();this.addLine(d.x,d.y,d.z,c.x,c.y,c.z,h,!0,"distance");let p=0,m=0,u=d.clone().add(c).multiplyScalar(.5),g=(parseInt(10*d.distanceTo(c))/10).toString()+" A";this.addLabel(g,u.x,u.y,u.z,p,h,m,"distance"),s.drawCls.draw()}}measureDistManySets(e,t){var s=this.icn3d,i=s.icn3dui;if(0==e.length||0==t.length)alert("Please select sets for distance calculation...");else{let n=i.hashUtilsCls.cloneHash(s.hAtoms),l={};for(let i=0,n=e.length;i"+t[e]+" (Å)"}r+="";for(let s=0,i=e.length;s"+i+" (Å)";for(let e=0,s=t.length;e'+l[i][s]+"":r+="0"}r+=""}r+="

    ",$("#"+i.pre+"dl_disttable").html(r)}}addLine(e,t,s,i,n,l,r,o,a,d,c){var h=this.icn3d;h.icn3dui;let p={};p.position1=new THREE.Vector3(e,t,s),p.position2=new THREE.Vector3(i,n,l),p.color=r,p.dashed=o,p.radius=d,p.opacity=c,void 0===h.lines[a]&&(h.lines[a]=[]),void 0!==a?h.lines[a].push(p):(void 0===h.lines.custom&&(h.lines.custom=[]),h.lines.custom.push(p)),h.hlObjectsCls.removeHlObjects()}addLineFromPicking(e){var t=this.icn3d,s=t.icn3dui;let i=$("#"+t.pre+e+"color").val();t.pAtom.coord.x,t.pAtom2.coord.x,t.pAtom.coord.y,t.pAtom2.coord.y,t.pAtom.coord.z,t.pAtom2.coord.z;let n="stabilizer"!=e;s.htmlCls.clickMenuCls.setLogCmd("add line | x1 "+t.pAtom.coord.x.toPrecision(4)+" y1 "+t.pAtom.coord.y.toPrecision(4)+" z1 "+t.pAtom.coord.z.toPrecision(4)+" | x2 "+t.pAtom2.coord.x.toPrecision(4)+" y2 "+t.pAtom2.coord.y.toPrecision(4)+" z2 "+t.pAtom2.coord.z.toPrecision(4)+" | color "+i+" | dashed "+n+" | type "+e,!0),this.addLine(t.pAtom.coord.x,t.pAtom.coord.y,t.pAtom.coord.z,t.pAtom2.coord.x,t.pAtom2.coord.y,t.pAtom2.coord.z,i,n,e),t.pickpair=!1}addLabel(e,t,s,i,n,l,r,o){var a=this.icn3d;a.icn3dui;let d={};"0"!==n&&""!==n&&"undefined"!==n||(n=void 0),"0"!==l&&""!==l&&"undefined"!==l||(l=void 0),"0"!==r&&""!==r&&"undefined"!==r||(r=void 0);let c=new THREE.Vector3;c.x=t,c.y=s,c.z=i,d.position=c,d.text=e,d.size=n,d.color=l,d.background=r,void 0===a.labels[o]&&(a.labels[o]=[]),void 0!==o?a.labels[o].push(d):(void 0===a.labels.custom&&(a.labels.custom=[]),a.labels.custom.push(d)),a.hlObjectsCls.removeHlObjects()}addChainLabels(e){var t=this.icn3d;let s=t.icn3dui.hashUtilsCls.intHash(t.hAtoms,e);void 0===t.labels.chain&&(t.labels.chain=[]);let i=t.firstAtomObjCls.getChainsFromAtoms(s);for(let e in i){let s={};s.position=t.applyCenterCls.centerAtoms(t.chains[e]).center;let i=e.indexOf("_"),n=e.substr(i+1),l=t.showSeqCls.getProteinName(e);l.length>20&&(l=l.substr(0,20)+"..."),s.text="Chain "+n+": "+l,s.size=18,t.firstAtomObjCls.getFirstCalphaAtomObj(t.chains[e]).color.getHexString().toUpperCase(),s.color="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd,s.background="#FFFFFF",t.labels.chain.push(s)}t.hlObjectsCls.removeHlObjects()}addTerminiLabels(e){var t=this.icn3d,s=t.icn3dui;let i,n="#FFFFFF";i=s.hashUtilsCls.unionHash(i,t.proteins),i=s.hashUtilsCls.unionHash(i,t.nucleotides);let l=s.hashUtilsCls.intHash(t.dAtoms,i),r=s.hashUtilsCls.intHash(l,e);void 0===t.labels.chain&&(t.labels.chain=[]);let o=t.firstAtomObjCls.getChainsFromAtoms(r);for(let e in o){let i=s.hashUtilsCls.intHash(l,t.chains[e]),r=Object.keys(i),o=t.atoms[r[0]],a=t.atoms[r[r.length-1]],d={},c={};d.position=o.coord,c.position=a.coord,d.text="N-",c.text="C-",t.nucleotides.hasOwnProperty(o.serial)&&(d.text="5'",c.text="3'"),d.size=18,c.size=18,o.color.getHexString().toUpperCase(),a.color.getHexString().toUpperCase(),d.color="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd,c.color="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd,d.background=n,c.background=n,t.labels.chain.push(d),t.labels.chain.push(c)}t.hlObjectsCls.removeHlObjects()}}class ys{constructor(e){this.icn3d=e}draw2Ddgm(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=.667,o={},a={},d={},c={},h={};if(void 0===e)return"";for(let s in e.moleculeInfor){let i="#"+("000000"+e.moleculeInfor[s].color.toString(16)).slice(-6),l=e.moleculeInfor[s].chain.trim();void 0===h[l]?h[l]=1:++h[l];let r=t+"_"+(1===h[l]?l:l+h[l].toString());void 0!==n.mmdbid_q&&(n.mmdbid_q,n.mmdbid_t),o[s]=r,a[s]=i,d[s]=e.moleculeInfor[s].name,c[r]=s}if(void 0===i||!i)for(let s=0,i=e.intracResidues.length;s";p+=""+t.toUpperCase()+"
    ",p+="";let m={},u=[],g="",f="",b={};if(i)for(let e in n.dAtoms){let t=n.atoms[e];b[c[t.structure+"_"+t.chain]]=1}let C=Object.keys(e.moleculeInfor),y=Object.keys(e.intrac),v=[];for(let e=0,t=C.length;e0)for(let t in e.intrac){let s=e.intrac[t];for(let e=0,i=s.intrac.length;e0&&(y="#"+n.atoms[e[0]].color.getHexString().toUpperCase())}let S="";n.bInitial&&void 0!==s&&(void 0!==n.alignmolid2color&&n.alignmolid2color[s].hasOwnProperty(l)?(S=n.alignmolid2color[s][l],y="#FF0000"):y="#FFFFFF");let A=d[l],x=" ",k=" ";if(void 0!==c){let e=c.indexOf("_");k=c.substr(e+1),x=k.length>1?k.substr(0,1)+"..":k}else c="Misc";void 0===y&&(y="#FFFFFF");let O=1;if(n.bInitial&&void 0!==n.alnChains[c]){let e=0;for(let t in n.alnChains[c]){let s=n.atoms[t].color.getHexString().toUpperCase();"FF0000"!==s&&"00FF00"!==s||++e}O=1*e/Object.keys(n.chains[c]).length}if(O<.2&&(O=.2),-1===v.indexOf(l)){for(let e=0,t=h.intrac.length;e1){let s=0,i=0;for(let e=0,t=w[l].length;e",p+="Interaction of chain "+c+" with chain "+h+"",p+="",p+="",p+="Interaction of chain "+h+" with chain "+c+"",p+=""}return p+=f+g,p+="",p+="",n.html2ddgm+=p,$("#"+n.pre+"dl_2ddgm").html(n.html2ddgm),p}set2DdgmNote(e){let t="
    Nodes:
    ";return this.icn3d.icn3dui.utilsCls.isMac()?(t+="Protein
    ",t+="Nucleotide
    ",t+="Chemical
    ",t+="Biopolymer
    "):(t+="OProtein
    ",t+="Nucleotide
    ",t+="Chemical
    ",t+="Biopolymer
    "),t+="
    Lines:
    Interactions at 4 Å
    ",e&&(t+="Numbers in red:
    Aligned chains"),t+="

    ",t}highlightNode(e,t,s,i){let n=this.icn3d.icn3dui;i<.2&&(i=.2);if("rect"===e){$(t).attr("stroke",n.htmlCls.ORANGE),$(t).attr("stroke-width",3);let e=Number($(s).attr("x")),l=Number($(s).attr("y")),r=Number($(s).attr("width")),o=Number($(s).attr("height"));$(t).attr("x",e+r/2*(1-i)),$(t).attr("y",l+o/2*(1-i)),$(t).attr("width",r*i),$(t).attr("height",o*i)}else if("circle"===e)$(t).attr("stroke",n.htmlCls.ORANGE),$(t).attr("stroke-width",3),$(t).attr("r",Number($(s).attr("r"))*i);else if("polygon"===e){$(t).attr("stroke",n.htmlCls.ORANGE),$(t).attr("stroke-width",3);let e=Number($(s).attr("x")),l=Number($(s).attr("y")),r=Number($(s).attr("x0d")),o=Number($(s).attr("y0d")),a=Number($(s).attr("x1d")),d=Number($(s).attr("y1d")),c=Number($(s).attr("x2d")),h=Number($(s).attr("y2d")),p=Number($(s).attr("x3d")),m=Number($(s).attr("y3d"));$(t).attr("points",(e+r*i).toString()+", "+(l+o*i).toString()+", "+(e+a*i).toString()+", "+(l+d*i).toString()+", "+(e+c*i).toString()+", "+(l+h*i).toString()+", "+(e+p*i).toString()+", "+(l+m*i).toString())}}removeLineGraphSelection(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"dl_linegraph circle").attr("stroke","#000000"),$("#"+e.pre+"dl_linegraph circle").attr("stroke-width",1),$("#"+e.pre+"dl_linegraph svg line.icn3d-hlline").attr("stroke","#FFF")}removeScatterplotSelection(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"dl_scatterplot circle").attr("stroke","#000000"),$("#"+e.pre+"dl_scatterplot circle").attr("stroke-width",1),$("#"+e.pre+"dl_scatterplot rect").attr("stroke","#000000"),$("#"+e.pre+"dl_scatterplot rect").attr("stroke-width",1)}click2Ddgm(){let e=this.icn3d,t=e.icn3dui,s=this;$(document).on("click","#"+e.pre+"dl_2ddgm .icn3d-node",(function(e){let i=s.icn3d;e.stopImmediatePropagation(),Object.keys(i.hAtoms).length1)s="inter_"+e+"_"+t;else{let i=e.indexOf("_"),n=t.indexOf("_");s="inter_"+e.substr(i+1)+"_"+t.substr(n+1)}i="select the atoms in chain "+e+" interacting with chain "+t+" in a distance of 4 angstrom";let o="select interaction "+e+","+t;n.selectionCls.addCustomSelection(r,s,i,o,!0)}draw2DProtein(e,t,s,i,n,l,r,o,a,d,c){this.icn3d.icn3dui;let h=20*d,p="";return p+="Chain "+i+": "+l+"",p+="",p+="",p+=""+n+"",""!==r&&(p+=""+r+""),p+="",p}draw2DNucleotide(e,t,s,i,n,l,r,o,a,d,c){this.icn3d.icn3dui;let h=30*d,p=30*d,m="";return m+="Chain "+i+": "+l+"",m+="",m+="",m+=""+n+"",""!==r&&(m+=""+r+""),m+="",m}draw2DChemical(e,t,s,i,n,l,r,o,a,d,c,h){this.icn3d.icn3dui;let p,m,u,g,f,b,C,y,v=30*d;if(h){let s=.5*v/Math.sqrt(3),i=.5*v;p=e-s,m=t-i,u=e+3*s,g=t-i,f=e+s,b=t+i,C=e-3*s,y=t+i}else{let s=.5*v,i=.5*v;p=e-s,m=t,u=e,g=t+i,f=e+s,b=t,C=e,y=t-i}let w=p-e,_=m-t,S=u-e,A=g-t,x=f-e,k=b-t,O=C-e,R=y-t,E="";return E+="Chain "+i+": "+l+"",E+="",E+="",E+=""+n+"",""!==r&&(E+=""+r+""),E+="",E}}class vs{constructor(e){this.icn3d=e}async draw2Dcartoon(e,t){let s=this.icn3d,i=s.icn3dui,n=this;if(i.htmlCls.clickMenuCls.setLogCmd("cartoon 2d "+e,!0),s.cartoon2dType=e,t){let t=n.getCartoonSvg(e,s.graphStr);$("#"+i.svgid_ct).html(t)}else{await this.getNodesLinksForSetCartoon(e),s.graphStr=n.getCartoonData(e,s.node_link);let t=n.getCartoonSvg(e,s.graphStr);$("#"+i.svgid_ct).html(t),n.setEventsForCartoon2d(),i.htmlCls.dialogCls.openDlg("dl_2dctn","2D Cartoon")}}getCartoonSvg(e,t){let s=this.icn3d,i=s.icn3dui,n="",l="",r=JSON.parse(t);s.ctnNodeHash={};for(let t=0,i=r.nodes.length;t":"domain"==e?n+="":"secondary"==e&&(a=s.ctnNodeHash[l].x2,d=i.htmlCls.width2d-s.ctnNodeHash[l].y2,c=s.ctnNodeHash[o].x1,h=i.htmlCls.width2d-s.ctnNodeHash[o].y1,n+="");let p=l+"--"+o;n+="Interaction of "+e+" "+this.getLabelFromId(l,e)+" with "+e+" "+this.getLabelFromId(o,e)+"",n+="",s.nodeid2lineid.hasOwnProperty(l)||(s.nodeid2lineid[l]=[]),s.nodeid2lineid.hasOwnProperty(o)||(s.nodeid2lineid[o]=[]),s.nodeid2lineid[l].push(p),s.nodeid2lineid[o].push(p)}return n+=l,n}setEventsForCartoon2d(){let e=this.icn3d,t=e.icn3dui;$("#"+t.svgid_ct+" .icn3d-ctnode").draggable({start:function(e,t){let s=parseFloat(e.target.getAttribute("cx")),i=parseFloat(e.target.getAttribute("cy"));e.target.setAttribute("cx",s),e.target.setAttribute("cy",i);let n=e.target.getAttribute("ang");if(n)e.target.setAttribute("transform","rotate("+n+","+s+","+i+")");else{let t=parseFloat(e.target.getAttribute("x1")),s=parseFloat(e.target.getAttribute("y1")),i=parseFloat(e.target.getAttribute("x2")),n=parseFloat(e.target.getAttribute("y2"));e.target.setAttribute("x1",t),e.target.setAttribute("y1",s),e.target.setAttribute("x2",i),e.target.setAttribute("y2",n)}},drag:function(s,i){let n=$("#"+t.svgid_ct).offset().left,l=$("#"+t.svgid_ct).offset().top,r=s.target.getAttribute("id"),o=s.target.getAttribute("ang"),a=s.clientX-n,d=s.clientY-l,c=parseFloat(s.target.getAttribute("cx")),h=parseFloat(s.target.getAttribute("cy")),p=(a-c)/e.resizeRatioX,m=(d-h)/e.resizeRatioY,u=parseFloat($("#"+r+"_text").attr("x")),g=parseFloat($("#"+r+"_text").attr("y"));if($("#"+r+"_text").attr("x",u+p),$("#"+r+"_text").attr("y",g+m),s.target.setAttribute("cx",a),s.target.setAttribute("cy",d),o)s.target.setAttribute("transform","rotate("+o+","+a+","+d+")");else{let e=parseFloat(s.target.getAttribute("x1")),t=parseFloat(s.target.getAttribute("y1")),i=parseFloat(s.target.getAttribute("x2")),n=parseFloat(s.target.getAttribute("y2"));if(s.target.setAttribute("x1",e+p),s.target.setAttribute("y1",t+m),s.target.setAttribute("x2",i+p),s.target.setAttribute("y2",n+m),"S"==r.substr(0,1)){let e=parseFloat($("#"+r+"_box").attr("x1")),t=parseFloat($("#"+r+"_box").attr("y1")),s=parseFloat($("#"+r+"_box").attr("x2")),i=parseFloat($("#"+r+"_box").attr("y2"));$("#"+r+"_box").attr("x1",e+p),$("#"+r+"_box").attr("y1",t+m),$("#"+r+"_box").attr("x2",s+p),$("#"+r+"_box").attr("y2",i+m)}}if(e.nodeid2lineid[r])for(let t=0,s=e.nodeid2lineid[r].length;t";return u+=""+e+" "+m+"","H"==t.substr(0,1)?u+="":(u+="",u+=""),u+=""+m+"",u+="",u}drawOval(e,t,s,i,n,l,r,o,a,d){let c=this.icn3d.icn3dui,h=this.getLabelFromId(t,e);i=c.htmlCls.width2d-i,r=180-r;let p="chain"==e?"":"";return p+=""+e+" "+h+"",p+="",p+="",p+=" ",p+=" ",p+="",p+="",p+="":" from='"+a+"' to='"+d+"' />",p+=""+h+"",p+="",p}getCartoonData(e,t){let s=this.icn3d;s.icn3dui;let i,n,l=[],r=[];l=t.node;let o=[],a={},d=0;for(let e=0,t=l.length;e0?n.y=s.htmlCls.width2d-n.y:n.y=-n.y,n}async getNodesLinksForSetCartoon(e){let t,s,i,n,l,r=this.icn3d,o=r.icn3dui,a=this,d=[],c=[],h=0,p=o.htmlCls.defaultValue,m="",u="",g="",f=!1,b=!0;if("chain"==e){let e={};for(let t in r.hAtoms){let s=r.atoms[t];if("DUM"==s.chain)continue;let i=s.structure+"_"+s.chain;(r.proteins.hasOwnProperty(t)||r.nucleotides.hasOwnProperty(t))&&(e.hasOwnProperty(i)||(e[i]={}),e[i][s.serial]=s)}let t=r.contactCls.getExtent(r.atoms),s=9999,i=9999,n=-9999,a=-9999,h=-9999,p=[];for(let d in e){r.hAtom={},r.hAtoms=o.hashUtilsCls.cloneHash(r.chains[d]);let e=r.axesCls.setPc1Axes(),c=e[0],m=e[1].distanceTo(e[0]),u=e[2].distanceTo(e[0]),g=180*new THREE.Vector2(e[1].x-e[0].x,e[1].y-e[0].y).angle()/Math.PI;g>180&&(g-=180);let f=Object.keys(r.hAtoms)[0],b=r.atoms[f];l=d,c=this.projectTo2d(c);let C=c.x,y=c.y;Cn&&(n=C),ya&&(a=y);let v=.5;m=v*o.htmlCls.width2d*m/(t[1][0]-t[0][0]),u=v*o.htmlCls.width2d*u/(t[1][1]-t[0][1]),m>h&&(h=m),u>h&&(h=u),p.push({id:d,r:l,x:C,y:y,rx:m,ry:u,ang:g,c:b.color.getHexString()})}let m=h+2,u=n-s,g=a-i;for(let e=0,t=p.length;e1&&(e+="__"+S.structure),a.push(e)),g==S.chain&&f&&S.ssend){let o=this.projectTo2d(t.coord.clone()),d=o.x,g=o.y,x=this.projectTo2d(S.coord.clone()),k=x.x,O=x.y;s=.5*(d+k),i=.5*(g+O),d=.5*(s+d),g=.5*(i+g),k=.5*(s+k),O=.5*(i+O),dw&&(w=d),g_&&(_=g),kw&&(w=k),O_&&(_=O),f=!1,b=!0,n+="-"+S.resi,l+="-"+S.resi,n+="__"+S.chain,Object.keys(r.structures).length>1&&(n+="__"+S.structure);for(let t=0,s=a.length;t0&&m==S.chain&&c.push('{"source": "'+u+'", "target": "'+n+'", "v": '+p+', "c": "'+t.color.getHexString().toUpperCase()+'"}'),A.push({id:n,r:l,ss:C,x:s,y:i,x1:d,y1:g,x2:k,y2:O,c:S.color.getHexString()}),m=S.chain,u=n,++h}}}let x=S+2,k=w-y,O=_-v;for(let e=0,t=A.length;e1&&(v+="__"+i.substr(0,i.indexOf("_")));let w=g[b],_=f[b];t.hAtoms={};for(let e=0,n=w.length;e180&&(O-=180);let R=Object.keys(t.hAtoms)[0],E=t.atoms[R];A=this.projectTo2d(A);let I=A.x,T=A.y;Ic&&(c=I),Th&&(h=T);let M=.5;x=M*s.htmlCls.width2d*x/(o[1][0]-o[0][0]),k=M*s.htmlCls.width2d*k/(o[1][1]-o[0][1]),x>p&&(p=x),k>p&&(p=k),void 0!==C&&n.push('{"source": "'+C+'", "target": "'+v+'", "v": '+l+', "c": "'+y.color.getHexString().toUpperCase()+'"}'),m.push({id:v,from:w+"",to:_+"",x:I,y:T,rx:x,ry:k,ang:O,c:E.color.getHexString()}),C=v,y=E}}let g=p+2,f=c-a,b=h-d;for(let e=0,t=m.length;e=2?d+"_"+e[1]:Object.keys(i.chains)[0];for(let e=0,t=o.length;es.transformCls.rotateCountMax)return s.transformCls.resetOrientation(),!1;if(++s.transformCls.rotateCount,t)if("left"===e)s.ROT_DIR="left";else if("right"===e)s.ROT_DIR="right";else if("up"===e)s.ROT_DIR="up";else{if("down"!==e)return!1;s.ROT_DIR="down"}if("left"===e&&"left"===s.ROT_DIR)s.transformCls.rotateLeft(1);else if("right"===e&&"right"===s.ROT_DIR)s.transformCls.rotateRight(1);else if("up"===e&&"up"===s.ROT_DIR)s.transformCls.rotateUp(1);else{if("down"!==e||"down"!==s.ROT_DIR)return!1;s.transformCls.rotateDown(1)}setTimeout((function(){i.rotStruc(e)}),100)}async back(){var e=this.icn3d;e.icn3dui,e.backForward=!0,e.STATENUMBER--,e.bAddCommands=!1,e.bAddLogs=!1,e.bNotLoadStructure=!0,e.STATENUMBER<1?e.STATENUMBER=1:await e.loadScriptCls.execCommands(0,e.STATENUMBER-1,e.STATENUMBER,!0),e.setStyleCls.adjustIcon(),e.bAddCommands=!0,e.bAddLogs=!0}async forward(){var e=this.icn3d;e.icn3dui,e.backForward=!0,e.STATENUMBER++,e.bAddCommands=!1,e.bAddLogs=!1,e.bNotLoadStructure=!0,e.STATENUMBER>e.commands.length?e.STATENUMBER=e.commands.length:await e.loadScriptCls.execCommands(0,e.STATENUMBER-1,e.STATENUMBER,!0),e.setStyleCls.adjustIcon(),e.bAddCommands=!0,e.bAddLogs=!0}async replayon(){var e=this.icn3d;e.icn3dui,e.CURRENTNUMBER=0,e.bReplay=1,$("#"+e.pre+"replay").show(),e.commands.length>0&&await e.loadScriptCls.replayFirstStep(e.CURRENTNUMBER)}async replayoff(){var e=this.icn3d;e.icn3dui,e.bReplay=0,$("#"+e.pre+"replay").hide(),++e.CURRENTNUMBER,await e.loadScriptCls.execCommands(e.CURRENTNUMBER,e.STATENUMBER-1,e.STATENUMBER)}closeDialogs(){var e=this.icn3d,t=e.icn3dui;let s=["dl_2ddgm","dl_2dctn","dl_alignment","dl_sequence2","dl_definedsets","dl_setsmenu","dl_command","dl_setoperations","dl_vast","dl_foldseek","dl_mmtfid","dl_pdbid","dl_afid","dl_opmid","dl_pdbfile","dl_pdbfile_app","dl_rescolorfile","dl_customcolor","dl_align","dl_alignaf","dl_chainalign","dl_chainalign2","dl_chainalign3","dl_mutation","dl_mol2file","dl_sdffile","dl_xyzfile","dl_afmapfile","dl_urlfile","dl_mmciffile","dl_mmcifid","dl_mmdbid","dl_mmdbafid","dl_blast_rep_id","dl_yournote","dl_gi","dl_refseqid","dl_cid","dl_pngimage","dl_state","dl_fixedversion","dl_selection","dl_dsn6","dl_dsn6url","dl_clr","dl_symmetry","dl_symd","dl_contact","dl_hbonds","dl_realign","dl_realignbystruct","dl_allinteracton","dl_interactionsorted","dl_linegraph","dl_linegraphcolor","dl_scatterplot","dl_scatterploitcolor","dl_contactmap","dl_alignerrormap","dl_elecmap2fofc","dl_elecmapfofc","dl_emmap","dl_aroundsphere","dl_adjustmem","dl_selectplane","dl_addlabel","dl_addlabelselection","dl_labelColor","dl_distance","dl_stabilizer","dl_disttwosets","dl_distmanysets","dl_stabilizer_rm","dl_thickness","dl_thickness2","dl_addtrack","dl_addtrack_tabs","dl_saveselection","dl_copyurl","dl_selectannotations","dl_annotations_tabs","dl_anno_view_tabs","dl_annotations","dl_graph","dl_svgcolor","dl_area","dl_colorbyarea","dl_rmsd","dl_buriedarea","dl_propbypercentout","dl_propbybfactor","dl_legend","dl_disttable"];for(let i in s){let n=s[i];t.cfg.notebook?$("#"+e.pre+n).hide():$("#"+e.pre+n).hasClass("ui-dialog-content")&&$("#"+e.pre+n).dialog("isOpen")&&$("#"+e.pre+n).dialog("close").remove()}t.cfg.notebook||this.resizeCanvas(t.htmlCls.WIDTH,t.htmlCls.HEIGHT,!0)}}class _s{constructor(e){this.icn3d=e}resetOrientation(){let e=this.icn3d;e.icn3dui;let t=!1;if(e.commands.length>0){let s=e.commands[0].split("|||");if(2==s.length){let i=JSON.parse(s[1]);e._zoomFactor=i.factor,e.mouseChange.x=i.mouseChange.x,e.mouseChange.y=i.mouseChange.y,e.quaternion._x=i.quaternion._x,e.quaternion._y=i.quaternion._y,e.quaternion._z=i.quaternion._z,e.quaternion._w=i.quaternion._w,t=!0}}t||(e._zoomFactor=1,e.mouseChange=new THREE.Vector2(0,0),e.quaternion=new THREE.Quaternion(0,0,0,1)),e.maxD=e.oriMaxD,e.center=e.oriCenter.clone(),"show"==e.ori_chemicalbinding?e.bSkipChemicalbinding=!1:"hide"==e.ori_chemicalbinding&&(e.bSkipChemicalbinding=!0)}rotateLeft(e){let t=this.icn3d,s=t.icn3dui,i=new THREE.Vector3(0,1,0),n=-e/180*Math.PI;t.bControlGl&&!s.bNode?i.applyQuaternion(window.cam.quaternion).normalize():i.applyQuaternion(t.cam.quaternion).normalize();let l=new THREE.Quaternion;l.setFromAxisAngle(i,-n);let r={};r.quaternion=l,r.update=!0,t.bControlGl&&!s.bNode?window.controls.update(r):t.controls.update(r),t.bRender&&t.drawCls.render()}rotateRight(e){let t=this.icn3d,s=t.icn3dui,i=new THREE.Vector3(0,1,0),n=e/180*Math.PI;t.bControlGl&&!s.bNode?i.applyQuaternion(window.cam.quaternion).normalize():i.applyQuaternion(t.cam.quaternion).normalize();let l=new THREE.Quaternion;l.setFromAxisAngle(i,-n);let r={};r.quaternion=l,r.update=!0,t.bControlGl&&!s.bNode?window.controls.update(r):t.controls.update(r),t.bRender&&t.drawCls.render()}rotateUp(e){this.icn3d.icn3dui,this.rotate_base(-e)}rotateDown(e){this.icn3d.icn3dui,this.rotate_base(e)}rotate_base(e){let t=this.icn3d,s=t.icn3dui,i=new THREE.Vector3(1,0,0),n=e/180*Math.PI;t.bControlGl&&!s.bNode?i.applyQuaternion(window.cam.quaternion).normalize():i.applyQuaternion(t.cam.quaternion).normalize();let l=new THREE.Quaternion;l.setFromAxisAngle(i,-n);let r={};r.quaternion=l,r.update=!0,t.bControlGl&&!s.bNode?window.controls.update(r):t.controls.update(r),t.bRender&&t.drawCls.render()}setRotation(e,t){let s=this.icn3d,i=s.icn3dui;s.bControlGl&&!i.bNode&&window.cam?e.applyQuaternion(window.cam.quaternion).normalize():s.cam&&e.applyQuaternion(s.cam.quaternion).normalize();let n=new THREE.Quaternion;n.setFromAxisAngle(e,-t);let l={};l.quaternion=n,l.update=!0,s.bControlGl&&!i.bNode&&window.controls?window.controls.update(l):s.controls&&s.controls.update(l),s.bRender&&s.drawCls.render()}translateLeft(e){this.icn3d.icn3dui,this.translate_base(-e,0)}translateRight(e){this.icn3d.icn3dui,this.translate_base(e,0)}translateUp(e){this.icn3d.icn3dui,this.translate_base(0,-e)}translateDown(e){this.icn3d.icn3dui,this.translate_base(0,e)}translate_base(e,t){let s=this.icn3d,i=s.icn3dui,n=new THREE.Vector2(0,0);n.x+=e/100,n.y+=t/100;let l={};l.mouseChange=n,l.update=!0,s.bControlGl&&!i.bNode?window.controls.update(l):s.controls.update(l),s.bRender&&s.drawCls.render()}zoominSelection(e){let t=this.icn3d,s=t.icn3dui,i={};if(i._zoomFactor=1/t._zoomFactor,i.update=!0,t.bControlGl&&!s.bNode?window.controls&&window.controls.update(i):t.controls&&t.controls.update(i),void 0===e&&(e=s.hashUtilsCls.hash2Atoms(t.hAtoms,t.atoms)),Object.keys(e).length>1){let s=t.applyCenterCls.centerAtoms(e);t.maxD=s.maxD,t.maxD<5&&(t.maxD=5),t.center=s.center,t.applyCenterCls.setCenter(t.center),t.cameraCls.setCamera()}}getTransformationStr(e){this.icn3d.icn3dui;let t={factor:1,mouseChange:{x:0,y:0},quaternion:{_x:0,_y:0,_z:0,_w:1}};return t.factor=parseFloat(e.factor).toPrecision(4),t.mouseChange.x=parseFloat(e.mouseChange.x).toPrecision(4),t.mouseChange.y=parseFloat(e.mouseChange.y).toPrecision(4),t.quaternion._x=parseFloat(e.quaternion._x).toPrecision(4),t.quaternion._y=parseFloat(e.quaternion._y).toPrecision(4),t.quaternion._z=parseFloat(e.quaternion._z).toPrecision(4),t.quaternion._w=parseFloat(e.quaternion._w).toPrecision(4),"1.0000"==t.factor&&(t.factor=1),"0.0000"==t.mouseChange.x&&(t.mouseChange.x=0),"0.0000"==t.mouseChange.y&&(t.mouseChange.y=0),"0.0000"==t.quaternion._x&&(t.quaternion._x=0),"0.0000"==t.quaternion._y&&(t.quaternion._y=0),"0.0000"==t.quaternion._z&&(t.quaternion._z=0),"1.0000"==t.quaternion._w&&(t.quaternion._w=1),JSON.stringify(t)}}class Ss{constructor(e){this.icn3d=e}saveFile(e,t,s){let i,n=this.icn3d,l=n.icn3dui;if("command"===t){let e=n.loadCmd?n.loadCmd+"\n":"";for(let t=0,s=n.commands.length;t'+""+document.getElementById(e).innerHTML+""}savePng(e,t,s){let i=this.icn3d,n=i.icn3dui;if(n.bNode)return"";let l=$("#"+e).width(),r=$("#"+e).height();s&&(r=l);let o=document.getElementById(e),a=o.getBBox(),d=o.cloneNode(!0);i.lineGraphCls.copyStylesInline(d,o);let c=document.createElement("CANVAS");c.width=l,c.height=r;let h=c.getContext("2d");h.clearRect(0,0,a.width,a.height);let p=this.getSvgXml(e,l,r,s),m=window.URL||window.webkitURL||window,u=new Blob([p],{type:"image/svg+xml;charset=utf-8"}),g=new Image;g.src=m.createObjectURL(u),g.onload=function(){if(h.drawImage(g,0,0),m.revokeObjectURL(this.src),n.utilsCls.isIE()){let e=c.msToBlob();e&&(saveAs(e,t),c.remove())}else c.toBlob((function(e){e&&(saveAs(e,t),c.remove())}))}}exportCustomAtoms(e){var t=this.icn3d;t.icn3dui;let s="",i=void 0!==t.defNames2Residues?Object.keys(t.defNames2Residues).sort():[];for(let n=0,l=i.length;n0)if(s){let s={};for(let e=0,l=t.length;e1,_=1,S="",A="",x={};for(let h in e){let e=r.atoms[h];if(s&&e.het)continue;if(e.structure!=S){a+=v,v="",_>1&&(a+="\nENDMDL\n"),w&&(a+="MODEL "+_+"\n");let t=n?"Mutated chain_residue "+Object.keys(n)+"; ":"";i||(a+=this.getPDBHeader(_-1,y,t,l)),S=e.structure,++_}else e.chain!=A&&(A&&(a+="TER\n"),A=e.chain);let p=e.chain+"_"+e.resi;if(n&&n.hasOwnProperty(p)){x.hasOwnProperty(p)||(a+=n[p],x[p]=1);continue}let m="";m+=e.het?"HETATM":"ATOM ",m+=h.toString().padStart(5," "),m+=" ";let u=e.name.trim();isNaN(u.substr(0,1))||(u=u.substr(1)+u.substr(0,1)),4==u.length?m+=u:(m+=" ",u=u.replace(/\*/g,"'"),"O1P"==u?u="OP1":"O2P"==u?u="OP2":"C5M"==u&&(u="C7 "),m+=u.padEnd(3," ")),m+=" ";let g=e.resn;if(m+=g.length<=3?g.padStart(3," "):g.substr(0,3),e.chain.length>=2){m+=e.chain.replace(/_/gi,"").substr(0,2)}else 1==e.chain.length?m+=" "+e.chain.substr(0,1):0==e.chain.length&&(m+=" A");let f=e.resi;!isNaN(f)&&e.chain.length>3&&!isNaN(e.chain.substr(3))&&(f=f-1+parseInt(e.chain.substr(3)));let b=parseInt(f);m+=b.toString().length<=4?b.toString().padStart(4," "):b.toString().substr(0,4);let C=e.resi.toString().substr(e.resi.toString().length-1,1);if(isNaN(C)?m+=C:m+=" ",m+=" ".padStart(3," "),m+=e.coord.x.toFixed(3).toString().padStart(8," "),m+=e.coord.y.toFixed(3).toString().padStart(8," "),m+=e.coord.z.toFixed(3).toString().padStart(8," "),t&&e.het){let t=1.5,s=0;"C"==e.elem?t=1.908:"N"==e.elem?t=1.824:"O"==e.elem?t=1.6612:"H"==e.elem?t=1.25:"S"==e.elem?t=2:"P"==e.elem?t=2.1:o.parasCls.vdwRadii.hasOwnProperty(e.elem)&&(t=o.parasCls.vdwRadii[e.elem]),void 0!==o.cfg.cid&&void 0!==e.crg?s=e.crg:d.hasOwnProperty(h)?s=1.38:c.hasOwnProperty(h)?s=-.595:o.parasCls.ionCharges.hasOwnProperty(e.elem)&&(s=o.parasCls.ionCharges[e.elem]),m+=s.toFixed(4).toString().padStart(8," "),m+=t.toFixed(4).toString().padStart(7," ")}else m+="1.00".padStart(6," "),m+=e.b?parseFloat(e.b).toFixed(2).toString().padStart(6," "):" ".padStart(6," "),m+=" ".padStart(10," "),m+=e.elem.padStart(2," "),m+=" ".padStart(2," ");if(e.het&&e.bonds.length>0){v+="CONECT"+h.toString().padStart(5," ");let t={};for(let s=0,i=e.bonds.length;s50?n.molTitle.substr(0,47)+"...":n.molTitle;-1!=e.indexOf('"')&&(e=""),s&&(e=s+e),l+="TITLE "+e+"\n"}return t&&t[r]&&(l+=t[r]),l}showTitle(){var e=this.icn3d,t=e.icn3dui;if(void 0!==e.molTitle&&""!==e.molTitle){let s=e.molTitle,i="black"==e.opts.background?t.htmlCls.GREYD:"black";if(void 0===e.inputid)e.molTitle.length>40&&(s=e.molTitle.substr(0,40)+"..."),$("#"+e.pre+"title").html(s);else if(void 0!==t.cfg.cid){let t=this.getLinkToStructureSummary();$("#"+e.pre+"title").html("PubChem CID "+e.inputid.toUpperCase()+": "+s)}else if(void 0!==t.cfg.align)s="VAST+ alignment of "+Object.keys(e.structures),$("#"+e.pre+"title").html(s);else if(void 0!==t.cfg.chainalign){s="Dynamic Structure Alignment of Chains: "+t.cfg.chainalign.split(","),$("#"+e.pre+"title").html(s)}else if(void 0!==t.cfg.mmdbafid){let t=Object.keys(e.structures);if(t.length>1)s="Multiple structures: "+t,$("#"+e.pre+"title").html(s);else if(1==t.length){let e=this.getLinkToStructureSummary();this.setStructureTitle(e,s,i)}}else{let e=this.getLinkToStructureSummary();this.setStructureTitle(e,s,i)}}else $("#"+e.pre+"title").html("")}setStructureTitle(e,t,s){var i=this.icn3d,n=i.icn3dui;i.molTitle.length>40&&(t=i.molTitle.substr(0,40)+"...");let l=i.inputid.toUpperCase(),r=isNaN(i.inputid)&&i.inputid.length>5?"AlphaFold ID":"PDB ID";if(-1!=i.inputid.indexOf("http")&&(r="Data from",e=i.inputid,l=i.inputid),n.cfg.refseqid&&(r="NCBI Protein Acc."),i.inputid&&i.inputid.substr(0,4)!=i.defaultPdbId)if(n.cfg.blast_rep_id){let e=n.cfg.oriQuery_id?n.cfg.oriQuery_id:n.cfg.query_id,s=n.cfg.oriBlast_rep_id?n.cfg.oriBlast_rep_id:n.cfg.blast_rep_id;e.length>20&&(e=e.substr(0,17)+"..."),l="Query: "+e+"; target: "+s,$("#"+i.pre+"title").html(l+", "+t)}else $("#"+i.pre+"title").html(r+" "+l+": "+t);else $("#"+i.pre+"title").html(t)}getLinkToStructureSummary(e){var t=this.icn3d,s=t.icn3dui;let i="https://www.ncbi.nlm.nih.gov/structure/?term=";if(i=void 0!==s.cfg.cid?"https://www.ncbi.nlm.nih.gov/pccompound/?term=":void 0!==s.cfg.refseqid?"https://www.ncbi.nlm.nih.gov/protein/":void 0!==s.cfg.afid?"https://alphafold.ebi.ac.uk/search/text/":Object.keys(t.structures).length>1?"https://www.ncbi.nlm.nih.gov/structure/?term=":s.htmlCls.baseUrl+"pdb/",void 0===t.inputid)i="https://www.ncbi.nlm.nih.gov/pccompound/?term="+t.molTitle;else{let n=t.inputid.split("_");1===n.length?(i+=t.inputid,e&&s.htmlCls.clickMenuCls.setLogCmd("link to "+t.inputid+": "+i,!1)):2===n.length&&(s.cfg.afid?i+=n[0]+" "+n[1]:i+=n[0]+" OR "+n[1],e&&s.htmlCls.clickMenuCls.setLogCmd("link to structures "+n[0]+" and "+n[1]+": "+i,!1))}return i}setEntrezLinks(e){var t=this.icn3d,s=t.icn3dui;let i,n=Object.keys(t.structures);if(1===n.length){i="https://www.ncbi.nlm.nih.gov/"+e+"/?term="+n[0],s.htmlCls.clickMenuCls.setLogCmd("Entrez "+e+" about PDB "+n[0]+": "+i,!1);let l=t.structures&&Object.keys(t.structures).length>0?"_blank":"_self";window.open(i,l)}else if(2===n.length){i="https://www.ncbi.nlm.nih.gov/"+e+"/?term="+n[0]+" OR "+n[1],s.htmlCls.clickMenuCls.setLogCmd("Entrez "+e+" about PDB "+n[0]+" OR "+n[1]+": "+i,!1);let l=t.structures&&Object.keys(t.structures).length>0?"_blank":"_self";window.open(i,l)}}}class As{constructor(e){this.icn3d=e}async shareLink(e,t){let s=this.icn3d,i=s.icn3dui,n=this.shareLinkUrl(),l=n.length>4e3||0!==n.indexOf("http");e&&(n+="&random="+parseInt(1e3*Math.random()));let r=Object.keys(s.structures).join("_");if(r==s.defaultPdbId&&(s.filename?r=s.filename:s.inputid&&(r=s.inputid)),e){if(t||s.bInputfile||l)return void s.saveFileCls.saveFile(r+"_icn3d_loadable.png","png")}else{if(s.bInputfile&&!s.bInputUrlfile)return void alert("Share Link does NOT work when the data are from custom files. Please save 'iCn3D PNG Image' in the File menu and open it in iCn3D.");if(l)return void alert("The url is more than 4000 characters and may not work. Please save 'iCn3D PNG Image' or 'State File' and open them in iCn3D.");i.htmlCls.clickMenuCls.setLogCmd("share link: "+n,!1)}let o=await this.getShareLinkPrms(n,e),a="Problem in getting shortened URL";if(void 0!==o.shortLink&&(a=o.shortLink,e)){let e=a.split("/"),t=e[e.length-1];s.saveFileCls.saveFile(r+"-"+t+".png","png");let i='\n\n",s.saveFileCls.saveFile(r+"-"+t+".html","html",i)}e&&void 0===o.shortLink&&s.saveFileCls.saveFile(r+"_icn3d_loadable.png","png");let d=a.split("page.link/");2==d.length&&(a="https://structure.ncbi.nlm.nih.gov/icn3d/share.html?"+d[1]),$("#"+s.pre+"ori_url").val(n),$("#"+s.pre+"short_url").val(a),$("#"+s.pre+"short_url_title").val(a+"&t="+s.yournote),e||i.htmlCls.dialogCls.openDlg("dl_copyurl","Copy a Share Link URL")}getShareLinkPrms(e,t){let s=this.icn3d,i=s.icn3dui;return new Promise((function(n,l){$.ajax({url:"https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=AIzaSyBxl9CgM0dY5lagHL4UOhEpLWE1fuwdnvc",type:"POST",data:{longDynamicLink:"https://icn3d.page.link/?link="+encodeURIComponent(e)},dataType:"json",success:function(e){n(e)},error:function(n,l,r){let o="Problem in getting shortened URL";$("#"+s.pre+"ori_url").val(e),$("#"+s.pre+"short_url").val(o),$("#"+s.pre+"short_url_title").val(o+"&t="+s.yournote),t||i.htmlCls.dialogCls.openDlg("dl_copyurl","Copy a Share Link URL")}})}))}shareLinkUrl(e){let t=this.icn3d,s=t.icn3dui,i=s.htmlCls.baseUrl+"icn3d/full.html?";if(s.cfg.bSidebyside&&(i=s.htmlCls.baseUrl+"icn3d/full2.html?"),t.bInputUrlfile){i=window.location.href.split("?")[0]+"?"+t.inputurl+"&"}let n,l={};for(let e in t.cfg){let s=t.cfg[e];"inpara"!==e&&"command"!==e&&"usepdbnum"!==e&&"date"!==e&&"v"!==e&&void 0!==s&&("width"===e&&"100%"===s||"height"===e&&"100%"===s||"resize"===e&&!0===s||"showmenu"===e&&!0===s||"showtitle"===e&&!0===s||"showcommand"===e&&!0===s||"mobilemenu"===e&&!1===s||"showanno"===e&&!1===s||"showseq"===e&&!1===s||"showalignseq"===e&&!1===s||"show2d"===e&&!1===s||"showsets"===e&&!1===s||"rotate"===e&&"right"===s||"command"!==e&&("options"===e?Object.keys(s).length>0&&(l[e]=JSON.stringify(s)):!0===s?l[e]=1:!1===s?l[e]=0:""!==s&&(l[e]=s)))}t.bAfMem?l.afmem="on":(s.cfg.afid||1==Object.keys(t.structures).length&&Object.keys(t.structures)[0].length>5)&&(l.afmem="off");let r=-1;void 0!==s.cfg.inpara&&(r=s.cfg.inpara.indexOf("&command=")),n=-1!==r?s.cfg.inpara.substr(0,r):s.cfg.inpara;let o=!1;if(!t.bInputUrlfile){let e=n&&n.substr(1)?n.substr(1).split("&"):[];for(let t=0,s=e.length;tp){u=t.commands[p].split("|||")[0].split("&command=")[0].trim(),-1!==u.indexOf(f)&&++b}let C,y=p+1,v="";for(let e=t.commands.length;y0&&b%2==0&&u!==f&&(i+=f+"; "),i+=u+"|||"+t.transformCls.getTransformationStr(m),g+=u+"|||"+t.transformCls.getTransformationStr(m)+"\n"),g=g.replace(/!/g,Object.keys(t.structures)[0]+"_"),(t.bInputfile&&!t.bInputUrlfile||t.bInputUrlfile&&t.bAppend||i.length>4e3)&&(i=g),void 0!==t.structures&&1==Object.keys(t.structures).length&&void 0!==t.inputid&&(C=Object.keys(t.structures)[0],i=i.replace(new RegExp(C+"_","g"),"!")),void 0!==s.cfg.blast_rep_id&&(i=i.replace(new RegExp("blast_rep_id=!","g"),"blast_rep_id="+C+"_")),i}getPngText(){let e,t=this.icn3d;t.icn3dui;let s="";if(t.bInputfile)e=this.shareLinkUrl(true),"http"==e.substr(0,4)?s+="\nShare Link: "+e:(s+="\nStart of type file======\n",s+=t.InputfileType+"\n",s+="End of type file======\n",s+="Start of data file======\n",s+=t.saveFileCls.getAtomPDB(t.atoms),s+="End of data file======\n",s+="Start of state file======\n",s+=e+"\n",s+="End of state file======\n");else{e=this.shareLinkUrl(),e.length>4e3||0!==e.indexOf("http")?(e=this.shareLinkUrl(true),s+="\nStart of state file======\n",s+=e+"\n",s+="End of state file======\n"):s+="\nShare Link: "+e}return s=s.replace(/!/g,Object.keys(t.structures)[0]+"_"),s}}class xs{constructor(e){this.icn3d=e}setThichknessFor3Dprint(){let e=this.icn3d,t=e.icn3dui;e.lineRadius=1,e.coilWidth=1.2,e.cylinderRadius=.8,e.crosslinkRadius=.8,e.traceRadius=1,e.dotSphereScale=.6,e.sphereRadius=1.5,e.ribbonthickness=1,e.helixSheetWidth=2,e.nucleicAcidWidth=1.4,t.htmlCls.setHtmlCls.setCookieForThickness()}prepareFor3Dprint(){let e=this.icn3d,t=e.icn3dui;if(e.bShowHighlight=!1,e.hlObjectsCls.removeHlObjects(),e.bDashedLines=!1,e.bSetThickness||void 0!==t.cfg.cid||this.setThichknessFor3Dprint(),void 0!==e.lines.hbond)for(let t=0,s=e.lines.hbond.length;tt.substr(0,s))return 1;if(e.substr(0,s)==t.substr(0,s)){if(parseInt(e.substr(s+1))parseInt(t.substr(i+1)))return 1;if(parseInt(e.substr(s+1))==parseInt(t.substr(i+1)))return 0}}})),i="";for(let e=0,t=s.length;e"}let n=e.inputid?e.inputid:"custom";e.saveFileCls.saveFile(n+"_residues.txt","html",i)}addStabilizer(){let e=this.icn3d,t=e.icn3dui,s=3.5;if(Object.keys(e.dAtoms).length>0){let i,n={},l=12.25,r=3.2*3.2;for(let t in e.dAtoms){let s=e.atoms[t];!e.nucleotides.hasOwnProperty(s.serial)||"N1"!==s.name&&"N2"!==s.name&&"N3"!==s.name&&"N4"!==s.name&&"N6"!==s.name&&"O2"!==s.name&&"O6"!==s.name||(i=s.structure+"_"+s.chain+"_"+s.resi+"_"+s.name,n[i]=s)}let o=Object.keys(n),a=o.length;void 0===e.pairArray&&(e.pairArray=[]);for(let t=0;ts)continue;let h=Math.abs(n[a].coord.y-n[d].coord.y);if(h>s)continue;let p=Math.abs(n[a].coord.z-n[d].coord.z);if(p>s)continue;let m=c*c+h*h+p*p;m>l||ms+1||rs+2||rs+4||r0&&o.length>0)if(a){let t=parseInt((r.length+.5)/2);e.pairArray.push(o[0]),e.pairArray.push(r[t])}else{let t=10,s=parseInt(r.length/(t+1));for(let i=0,n=o.length;i1&&t.bAssembly&&(t.threshbox=180/Math.pow(t.biomtMatrices.length,.33),t.applyMapCls.removeSurfaces(),t.applyMapCls.applySurfaceOptions(),t.applyMapCls.removeMaps(),t.applyMapCls.applyMapOptions(),t.applyMapCls.removeEmmaps(),t.applyMapCls.applyEmmapOptions());let s=this.saveStlFile(),i=t.inputid?t.inputid:"custom";if(t.saveFileCls.saveFile(i+e+".stl","binary",s),void 0!==t.biomtMatrices&&t.biomtMatrices.length>1&&t.bAssembly&&Object.keys(t.dAtoms).length*t.biomtMatrices.length>t.maxAtoms3DMultiFile){alert(t.biomtMatrices.length+" files will be generated for this assembly. Please merge these files using some software and 3D print the merged file.");let n=new THREE.Matrix4;n.identity();let l=1;for(let r=0;r1&&t.bAssembly&&(t.threshbox=180/Math.pow(t.biomtMatrices.length,.33),t.applyMapCls.removeSurfaces(),t.applyMapCls.applySurfaceOptions(),t.applyMapCls.removeMaps(),t.applyMapCls.applyMapOptions(),t.applyMapCls.removeEmmaps(),t.applyMapCls.applyEmmapOptions());let s=this.saveVrmlFile(),i=t.inputid?t.inputid:"custom";if(t.saveFileCls.saveFile(i+e+".wrl","text",s),void 0!==t.biomtMatrices&&t.biomtMatrices.length>1&&t.bAssembly&&Object.keys(t.dAtoms).length*t.biomtMatrices.length>t.maxAtoms3DMultiFile){alert(t.biomtMatrices.length+" files will be generated for this assembly. Please merge these files using some software and 3D print the merged file.");let i=new THREE.Matrix4;i.identity();let n=1;for(let l=0;l7e4)return alert("Please display a subset of the structure to export 3D files. Then merge the files for 3D printing..."),[""];t.threeDPrintCls.prepareFor3Dprint();let i=0;i+=this.getFaceCnt(t.mdl),i+=this.getFaceCnt(t.mdl_ghost);let n=[],l=new Uint8Array(84),r="STL file for the structure(s) ",o=Object.keys(t.structures);for(let e=0,t=o.length;e80&&(r=r.substr(0,80));for(let e=0;e<80;++e)e1&&t.bAssembly&&Object.keys(t.dAtoms).length*t.biomtMatrices.length<=t.maxAtoms3DMultiFile?this.updateArray(l,s.convertTypeCls.passInt32([i*t.biomtMatrices.length]),80):this.updateArray(l,s.convertTypeCls.passInt32([i]),80),n.push(new Blob([l],{type:"application/octet-stream"})),n=this.processStlMeshGroup(t.mdl,n,e),n=this.processStlMeshGroup(t.mdl_ghost,n,e),void 0!==t.biomtMatrices&&t.biomtMatrices.length>1&&t.bAssembly&&Object.keys(t.dAtoms).length*t.biomtMatrices.length<=t.maxAtoms3DMultiFile){let e=new THREE.Matrix4;e.identity();for(let s=0;s5e4)return alert("Please display a subset of the structure to export 3D files. Then merge the files for 3D printing..."),[""];t.threeDPrintCls.prepareFor3Dprint();let s=[];s.push("#VRML V2.0 utf8\n");let i=0,n=this.processVrmlMeshGroup(t.mdl,s,i,e);if(s=n.vrmlStrArray,i=n.vertexCnt,n=this.processVrmlMeshGroup(t.mdl_ghost,s,i,e),s=n.vrmlStrArray,i=n.vertexCnt,void 0!==t.biomtMatrices&&t.biomtMatrices.length>1&&t.bAssembly&&Object.keys(t.dAtoms).length*t.biomtMatrices.length<=t.maxAtoms3DMultiFile){let e=new THREE.Matrix4;e.identity();for(let l=0;l0?h.z=-1:h.z=1,s.cam===s.perspectiveCamera?(s.cam_z>0?h.z=-1:h.z=1,h.unproject(s.cam),s.raycaster.set(s.cam.position,h.sub(s.cam.position).normalize())):s.cam===s.orthographicCamera&&(s.cam_z>0?h.z=1:h.z=-1,h.unproject(s.cam),s.raycaster.set(h,new THREE.Vector3(0,0,-1).transformDirection(s.cam.matrixWorld)));let p=this.isIntersect(s.objects,s.mdl,t,d,c);p||(p=this.isIntersect(s.objects_ghost,s.mdl_ghost,t,d,c))}isIntersect(e,t,s,i,n){let l=this.icn3d;l.icn3dui;let r=l.raycaster.intersectObjects(e),o=!1,a=t.position;if(r.length>0){r[0].point.sub(a);let e=l.rayThreshold,t=this.getAtomsFromPosition(r[0].point,e);for(;!t&&e<10;)e+=.5,t=this.getAtomsFromPosition(r[0].point,e);t?(o=!0,l.pickpair?s&&(l.pAtomNum%2==0?l.pAtom=t:l.pAtom2=t,++l.pAtomNum):l.pAtom=t,s?l.pickingCls.showPicking(t):l.pickingCls.showPicking(t,i,n)):console.log("No atoms were found in 10 andstrom range")}return o}getAtomsFromPosition(e,t){let s,i=this.icn3d,n=i.icn3dui;for(s in null==t&&(t=1),i.dAtoms){let l=i.atoms[s];if(i.ions.hasOwnProperty(s)&&"sphere"===i.opts.ions){let s=n.parasCls.vdwRadii[l.elem.toUpperCase()];if(Math.abs(l.coord.x-e.x)-s>t)continue;if(Math.abs(l.coord.y-e.y)-s>t)continue;if(Math.abs(l.coord.z-e.z)-s>t)continue}else{if(l.coord.xe.x+t)continue;if(l.coord.ye.y+t)continue;if(l.coord.ze.z+t)continue}return l}return null}}class Rs{constructor(e){this.icn3d=e}setControl(){let e=this.icn3d,t=e.icn3dui;if(t.bNode)return;let s=this;e.WIDTH=e.container.width(),e.HEIGHT=e.container.height(),e.applyCenterCls.setWidthHeight(e.WIDTH,e.HEIGHT),e._zoomFactor=1,e.mouseChange=new THREE.Vector2(0,0),e.quaternion=new THREE.Quaternion(0,0,0,1),e.container.bind("contextmenu",(function(e){e.preventDefault()})),e.typetext=!1,$(document).bind("keyup",(function(t){16===t.keyCode&&(e.bShift=!1),17!==t.keyCode&&224!==t.keyCode&&91!==t.keyCode||(e.bCtrl=!1)})),$("input[type=text], textarea").focus((function(){e.typetext=!0})),$("input[type=text], textarea").blur((function(){e.typetext=!1})),$(document).bind("keydown",(function(s){if((s.shiftKey||16===s.keyCode)&&(e.bShift=!0),(s.ctrlKey||17===s.keyCode||224===s.keyCode||91===s.keyCode)&&(e.bCtrl=!0),!e.bControlGl&&!e.controls||e.bControlGl&&!window.controls)return;e.bStopRotate=!0;let i=e.bShift?90:5;if(!e.typetext)if(90===s.keyCode){let s={};e.bControlGl&&!t.bNode?window.cam===e.perspectiveCamera?s._zoomFactor=.9:window.cam===e.orthographicCamera&&(e._zoomFactor<.1?e._zoomFactor=.1:e._zoomFactor>1&&(e._zoomFactor=1),s._zoomFactor=.8*e._zoomFactor,s._zoomFactor<.1&&(s._zoomFactor=.1)):e.cam===e.perspectiveCamera?s._zoomFactor=.9:e.cam===e.orthographicCamera&&(e._zoomFactor<.1?e._zoomFactor=.1:e._zoomFactor>1&&(e._zoomFactor=1),s._zoomFactor=.8*e._zoomFactor,s._zoomFactor<.1&&(s._zoomFactor=.1)),s.update=!0,e.bControlGl&&!t.bNode?window.controls.update(s):e.controls.update(s),e.bRender&&e.drawCls.render()}else if(88===s.keyCode){let s={};e.bControlGl&&!t.bNode?window.cam===e.perspectiveCamera?s._zoomFactor=1.03:window.cam===e.orthographicCamera&&(e._zoomFactor>10?e._zoomFactor=10:e._zoomFactor<1&&(e._zoomFactor=1),s._zoomFactor=1.01*e._zoomFactor,s._zoomFactor>10&&(s._zoomFactor=10)):e.cam===e.perspectiveCamera?s._zoomFactor=1.03:e.cam===e.orthographicCamera&&(e._zoomFactor>10?e._zoomFactor=10:e._zoomFactor<1&&(e._zoomFactor=1),s._zoomFactor=1.01*e._zoomFactor,s._zoomFactor>10&&(s._zoomFactor=10)),s.update=!0,e.bControlGl&&!t.bNode?window.controls.update(s):e.controls.update(s),e.bRender&&e.drawCls.render()}else if(76===s.keyCode){let t=new THREE.Vector3(0,1,0),s=-i/180*Math.PI;e.transformCls.setRotation(t,s)}else if(74===s.keyCode){let t=new THREE.Vector3(0,1,0),s=i/180*Math.PI;e.transformCls.setRotation(t,s)}else if(73===s.keyCode){let t=new THREE.Vector3(1,0,0),s=-i/180*Math.PI;e.transformCls.setRotation(t,s)}else if(77===s.keyCode){let t=new THREE.Vector3(1,0,0),s=i/180*Math.PI;e.transformCls.setRotation(t,s)}else 65===s.keyCode&&Object.keys(e.structures).length>1&&e.alternateCls.alternateWrapper()})),e.container.bind("mouseup",(function(t){e.isDragging=!1})),e.container.bind("touchend",(function(t){e.isDragging=!1})),e.container.bind("mousedown",(function(s){if(e.isDragging=!0,e.scene){if(e.bStopRotate=!0,e.pk&&(s.altKey||s.ctrlKey||s.shiftKey||18===s.keyCode||16===s.keyCode||17===s.keyCode||224===s.keyCode||91===s.keyCode)){e.highlightlevel=e.pk;let t=!0;e.rayCls.rayCaster(s,t)}e.bControlGl&&!t.bNode?(window.controls.handleResize(),window.controls.update()):(e.controls.handleResize(),e.controls.update()),e.bRender&&e.drawCls.render()}})),e.container.bind("touchstart",(function(s){if(s.preventDefault(),e.isDragging=!0,!e.scene)return;e.bStopRotate=!0,$("#"+e.pre+"popup").hide();e.rayCls.rayCaster(s,!0),e.bControlGl&&!t.bNode?(window.controls.handleResize(),window.controls.update()):(e.controls.handleResize(),e.controls.update()),e.bRender&&e.drawCls.render()})),e.container.bind("mousemove touchmove",(function(e){s.mouseMove(e)})),e.container.bind("mousewheel",(function(s){s.preventDefault(),e.scene&&(e.bStopRotate=!0,e.bControlGl&&!t.bNode?(window.controls.handleResize(),window.controls.update()):(e.controls.handleResize(),e.controls.update()),e.bRender&&e.drawCls.render())})),e.container.bind("DOMMouseScroll",(function(s){s.preventDefault(),e.scene&&(e.bStopRotate=!0,e.bControlGl&&!t.bNode?(window.controls.handleResize(),window.controls.update()):(e.controls.handleResize(),e.controls.update()),e.bRender&&e.drawCls.render())}))}mouseMove(e){let t=this.icn3d,s=t.icn3dui;if(s.bNode)return;if(e.preventDefault(),!t.scene)return;$("#"+t.pre+"popup").hide();if(t.rayCls.rayCaster(e,!1),t.bControlGl&&!s.bNode){window.controls.handleResize(),window.controls.update();for(let e in window.icn3duiHash){let t=window.icn3duiHash[e].icn3d;t.bRender&&t.drawCls.render()}}else t.controls.handleResize(),t.controls.update(),t.bRender&&t.drawCls.render()}}class Es{constructor(e){this.icn3d=e}showPicking(e,t,s){let i=this.icn3d,n=i.icn3dui;if(void 0!==n.cfg.cid&&0!=i.pk&&(i.pk=1),i.highlightlevel=i.pk,this.showPickingBase(e,t,s),0!=i.pk)if(void 0!==t&&void 0!==s){null!=n.cfg.showmenu&&1==n.cfg.showmenu&&(s+=n.htmlCls.MENU_HEIGHT);let l=1==i.pk?e.resn+e.resi+"@"+e.name:e.resn+e.resi;void 0!==i.structures&&Object.keys(i.structures).length>1?(l=e.structure+"_"+e.chain+" "+l,$("#"+i.pre+"popup").css("width","160px")):$("#"+i.pre+"popup").css("width","80px"),$("#"+i.pre+"popup").html(l),$("#"+i.pre+"popup").css("top",s).css("left",t+20).show()}else{i.hlUpdateCls.updateHlAll();let t={};t.factor=i._zoomFactor,t.mouseChange=i.mouseChange,t.quaternion={},t.quaternion._x=parseFloat(i.quaternion._x).toPrecision(5),t.quaternion._y=parseFloat(i.quaternion._y).toPrecision(5),t.quaternion._z=parseFloat(i.quaternion._z).toPrecision(5),t.quaternion._w=parseFloat(i.quaternion._w).toPrecision(5),n.htmlCls.clickMenuCls.setLogCmd("pickatom "+e.serial,!0),i.selectionCls.saveSelInCommand(),i.bSphereCalc=!1,i.bHbondCalc=!1}}showPickingBase(e,t,s){this.icn3d.icn3dui,void 0===t&&void 0===s&&this.showPickingHilight(e)}showPickingHilight(e){let t=this.icn3d,s=t.icn3dui;if(t.bShift||t.bCtrl||t.hlObjectsCls.removeHlObjects(),t.pickedAtomList={},1===t.pk)t.pickedAtomList[e.serial]=1;else if(2===t.pk){let s=e.structure+"_"+e.chain+"_"+e.resi;t.pickedAtomList=t.residues[s]}else if(3===t.pk)t.pickedAtomList=this.selectStrandHelixFromAtom(e);else if(4===t.pk)t.pickedAtomList=this.select3ddomainFromAtom(e);else if(5===t.pk){let s=e.structure+"_"+e.chain;t.pickedAtomList=t.chains[s]}0===t.pk?t.bShowHighlight=!1:t.bShowHighlight=!0;let i=Object.keys(t.hAtoms).length==Object.keys(t.atoms).length?{}:s.hashUtilsCls.intHash(t.hAtoms,t.pickedAtomList),n=Object.keys(i).length;if(t.bShift||t.bCtrl)if(t.bShift){if(void 0===t.prevPickedAtomList)t.hAtoms=s.hashUtilsCls.unionHash(t.hAtoms,t.pickedAtomList);else{let e=t.firstAtomObjCls.getFirstAtomObj(t.prevPickedAtomList),i=t.firstAtomObjCls.getFirstAtomObj(t.pickedAtomList);if(e.structure+"_"+e.chain!=i.structure+"_"+i.chain)t.hAtoms=s.hashUtilsCls.unionHash(t.hAtoms,t.pickedAtomList);else{let e;e=s.hashUtilsCls.unionHash(e,t.prevPickedAtomList),e=s.hashUtilsCls.unionHash(e,t.pickedAtomList);let i=t.firstAtomObjCls.getFirstAtomObj(e),n=t.firstAtomObjCls.getLastAtomObj(e);for(let e=i.serial;e<=n.serial;++e)t.hAtoms[e]=1}}t.prevPickedAtomList=s.hashUtilsCls.cloneHash(t.pickedAtomList)}else t.bCtrl&&(t.hAtoms=n>0?s.hashUtilsCls.exclHash(t.hAtoms,t.pickedAtomList):s.hashUtilsCls.unionHash(t.hAtoms,t.pickedAtomList));else t.hAtoms=s.hashUtilsCls.cloneHash(t.pickedAtomList);t.hlObjectsCls.removeHlObjects(),t.hlObjectsCls.addHlObjects()}select3ddomainFromAtom(e){let t,s=this.icn3d,i=s.icn3dui,n=e.structure+"_"+e.chain,l=n+"_"+e.resi;for(let e in s.tddomains){let i=e.indexOf("_3d_domain");if(e.substr(0,i)==n&&-1!==Object.keys(s.tddomains[e]).indexOf(l)){t=e;break}}let r={};for(let e in s.tddomains[t])r=i.hashUtilsCls.unionHash(r,s.residues[e]);return r}selectStrandHelixFromAtom(e){let t=this.icn3d,s=t.icn3dui,i=e,n=e,l={},r=i.resi;if(!i.ssbegin&&!isNaN(i.resi)){for(let e=i.resi-1;e>0;--e){let s=i.structure+"_"+i.chain+"_"+e;if(!t.residues.hasOwnProperty(s))break;let n=t.firstAtomObjCls.getFirstCalphaAtomObj(t.residues[s]);if(r=n.resi,"coil"!==i.ss&&n.ss===i.ss&&n.ssbegin||"coil"===i.ss&&n.ss!==i.ss){"coil"===i.ss&&n.ss!==i.ss&&(r=parseInt(n.resi)+1);break}}for(let e=r;e<=i.resi;++e){let n=i.structure+"_"+i.chain+"_"+e;l=s.hashUtilsCls.unionHash(l,s.hashUtilsCls.hash2Atoms(t.residues[n],t.atoms))}}let o=n.resi,a=t.firstAtomObjCls.getLastAtomObj(t.chains[n.structure+"_"+n.chain]).resi;for(let e=parseInt(n.resi)+1;e<=parseInt(a);++e){let s=n.structure+"_"+n.chain+"_"+e;if(!t.residues.hasOwnProperty(s))break;let i=t.firstAtomObjCls.getFirstCalphaAtomObj(t.residues[s]);if(o=i.resi,"coil"!==n.ss&&i.ss===n.ss&&i.ssend||"coil"===n.ss&&i.ss!==n.ss){"coil"!==n.ss||i.ss===n.ss||isNaN(i.resi)||(o=i.resi-1);break}}for(let e=parseInt(n.resi)+1;e<=parseInt(o);++e){let i=n.structure+"_"+n.chain+"_"+e;l=s.hashUtilsCls.unionHash(l,s.hashUtilsCls.hash2Atoms(t.residues[i],t.atoms))}return l}}class Is{constructor(e){this.icn3d=e,this.xrSessionIsGranted=!1}createButton(e,t){let s=this.icn3d,i=s.icn3dui;t&&console.error('THREE.VRButton: The "options" parameter has been removed. Please set the reference space type via renderer.xr.setReferenceSpaceType() instead.');const n=document.createElement("button");function l(){n.style.display="",n.style.cursor="auto",n.style.left="calc(33% - 75px)",n.style.width="150px",n.onmouseenter=null,n.onmouseleave=null,n.onclick=null}let r=this;if("xr"in navigator)return n.id=i.pre+"VRButton",n.style.display="none",(o=n).style.position="absolute",o.style.bottom="20px",o.style.padding="12px 6px",o.style.border="1px solid #fff",o.style.borderRadius="4px",o.style.background="#000",o.style.color="#f8b84e",o.style.font="bold 13px sans-serif",o.style.textAlign="center",o.style.opacity="0.8",o.style.outline="none",o.style.zIndex="999",navigator.xr.isSessionSupported("immersive-vr").then((function(t){t?function(){let t=null;async function i(s){s.addEventListener("end",l),await e.xr.setSession(s),n.textContent="EXIT VR",t=s}function l(){s.transformCls.resetOrientation(),s.bVr=!1,s.drawCls.draw(),t.removeEventListener("end",l),n.textContent="ENTER VR",t=null}n.style.display="",n.style.cursor="pointer",n.style.left="calc(33% - 50px)",n.style.width="100px",n.textContent="ENTER VR",n.onmouseenter=function(){n.style.opacity="1.0"},n.onmouseleave=function(){n.style.opacity="0.8"},n.onclick=function(){if(s.bImpo=!1,s.bVr=!0,s.drawCls.draw(s.bVr),null===t){const e={optionalFeatures:["local-floor","bounded-floor","hand-tracking","layers"]};navigator.xr.requestSession("immersive-vr",e).then(i)}else t.end()}}():(l(),n.style.display="none"),t&&r.xrSessionIsGranted&&n.click()})).catch((function(e){l(),console.warn("Exception when trying to call xr.isSessionSupported",e),n.style.display="none"})),n;return document.createElement("span");var o}registerSessionGrantedListener(){"xr"in navigator&&navigator.xr.addEventListener("sessiongranted",(()=>{this.xrSessionIsGranted=!0}))}}class Ts{constructor(e){this.icn3d=e,this.xrSessionIsGranted=!1}createButton(e,t={}){let s=this.icn3d,i=s.icn3dui;const n=document.createElement("button");function l(){n.style.display="",n.style.cursor="auto",n.style.left="calc(66% - 50px)",n.style.width="150px",n.onmouseenter=null,n.onmouseleave=null,n.onclick=null}function r(e){e.style.position="absolute",e.style.bottom="20px",e.style.padding="12px 6px",e.style.border="1px solid #fff",e.style.borderRadius="4px",e.style.background="#000",e.style.color="#f8b84e",e.style.font="bold 13px sans-serif",e.style.textAlign="center",e.style.opacity="0.8",e.style.outline="none",e.style.zIndex="999"}if(i.utilsCls.isAndroid()&&i.utilsCls.isChrome()){if("xr"in navigator)return n.id=i.pre+"ARButton",n.style.display="none",r(n),navigator.xr.isSessionSupported("immersive-ar").then((function(i){i?function(){if(void 0===t.domOverlay){const e=document.createElement("div");e.style.display="none",document.body.appendChild(e);const s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("width",38),s.setAttribute("height",38),s.style.position="absolute",s.style.right="20px",s.style.top="20px",s.addEventListener("click",(function(){i.end()})),e.appendChild(s);const n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d","M 12,12 L 28,28 M 28,12 12,28"),n.setAttribute("stroke","#fff"),n.setAttribute("stroke-width",2),s.appendChild(n),void 0===t.optionalFeatures&&(t.optionalFeatures=[]),t.optionalFeatures.push("dom-overlay"),t.domOverlay={root:e}}let i=null;async function l(s){s.addEventListener("end",r),e.xr.setReferenceSpaceType("local"),await e.xr.setSession(s),n.textContent="STOP AR",t.domOverlay.root.style.display="",i=s}function r(){s.transformCls.resetOrientation(),s.bAr=!1,s.drawCls.draw(),i.removeEventListener("end",r),n.textContent="START AR",t.domOverlay.root.style.display="none",i=null}n.style.display="",n.style.cursor="pointer",n.style.left="calc(66% - 50px)",n.style.width="100px",n.textContent="START AR",n.onmouseenter=function(){n.style.opacity="1.0"},n.onmouseleave=function(){n.style.opacity="0.8"},n.onclick=function(){s.bImpo=!1,s.opts.background="transparent",s.bAr=!0,s.drawCls.draw(s.bAr),null===i?navigator.xr.requestSession("immersive-ar",t).then(l):i.end()}}():(l(),n.style.display="none")})).catch((function(e){l(),console.warn("Exception when trying to call xr.isSessionSupported",e),n.style.display="none"})),n;return document.createElement("span")}return n.id=i.pre+"ARButton",n.style.display="none",r(n),l(),n.style.display="none",n}}class Ms{constructor(e){let t,s,i,n=e;if(this.icn3dui=e,this.id=this.icn3dui.pre+"canvas",this.pre=this.icn3dui.pre,this.container=$("#"+this.id),this.oriContainer=$("#"+this.id),this.bControlGl=!1,this.maxatomcnt=1e5,this.overdraw=0,this.bDrawn=!1,this.bOpm=!1,this.crossstrucinter=0,this.bSecondaryStructure=!1,this.bHighlight=1,this.renderOrderPicking=-1,this.bInitial=!0,this.bDoublecolor=!1,this.originSize=1,this.ALTERNATE_STRUCTURE=-1,this.bUsePdbNum=!0,!this.icn3dui.bNode){let e=document.createElement("canvas");t=!(!window.WebGLRenderingContext||!e.getContext("webgl")&&!e.getContext("experimental-webgl")),e.remove(),e=document.createElement("canvas"),s=!(!window.WebGLRenderingContext||!e.getContext("webgl2")),e.remove(),i="xr"in navigator,t?(s&&i?(this.renderer=new THREE.WebGLRenderer({canvas:this.oriContainer.get(0),antialias:!0,preserveDrawingBuffer:!0,sortObjects:!1,alpha:!0}),this.renderer.xr.enabled=!0):this.renderer=new THREE.WebGL1Renderer({canvas:this.oriContainer.get(0),antialias:!0,preserveDrawingBuffer:!0,sortObjects:!1,alpha:!0}),this.overdraw=0):alert("Currently your web browser has a problem on WebGL. If you are using Chrome, open a new tab for the same URL and WebGL may work again.")}this.frac=new THREE.Color(.1,.1,.1),this.shininess=40,this.emissive=1118481,this.light1=.6,this.light2=.4,this.light3=.2,this.lineRadius=.1,this.coilWidth=.3,this.cylinderRadius=.4,this.crosslinkRadius=.4,this.traceRadius=.4,this.dotSphereScale=.3,this.sphereRadius=1.5,this.cylinderHelixRadius=1.6,this.ribbonthickness=.2,this.helixSheetWidth=1.3,this.nucleicAcidWidth=.8,this.scaleFactor=1,this.labelScale=1,this.resizeRatioX=1,this.resizeRatioY=1,this.bImpo=!0,this.bInstanced=!0,this.chainMissingResidueArray={},this._zoomFactor=1,this.transparentRenderOrder=!1,this.AFUniprotVersion="v4",this.defaultPdbId="stru",this.icn3dui.bNode||(s&&i?(this.bExtFragDepth=!0,this.bImpo=!0,this.bInstanced=!0):(this.bExtFragDepth=this.renderer.extensions.get("EXT_frag_depth"),this.bExtFragDepth?console.log("EXT_frag_depth is supported. All spheres and cylinders are drawn using shaders."):(this.bImpo=!1,console.log("EXT_frag_depth is NOT supported. All spheres and cylinders are drawn using geometry.")),this.bInstanced=this.renderer.extensions.get("ANGLE_instanced_arrays"),this.bInstanced?console.log("ANGLE_instanced_arrays is supported. Assembly is drawn with one copy of the asymmetric unit using hardware instancing."):console.log("ANGLE_instanced_arrays is NOT supported. Assembly is drawn by making copies of the asymmetric unit."))),this.posArray=new Array,this.colorArray=new Array,this.pos2Array=new Array,this.color2Array=new Array,this.radiusArray=new Array,this.posArraySphere=new Array,this.colorArraySphere=new Array,this.radiusArraySphere=new Array,this.axis=!1,this.pk=1,this.highlightlevel=1,this.pickpair=!1,this.pAtomNum=0,this.pAtom=void 0,this.pAtom2=void 0,this.bCtrl=!1,this.bShift=!1,this.bStopRotate=!1,this.bCalphaOnly=!1,this.bConsiderNeighbors=!1,this.bShowCrossResidueBond=!0,this.bExtrude=!0,this.effects={none:this.renderer},this.maxD=500,this.oriMaxD=this.maxD,this.cam_z=2*this.maxD,this.commands=[],this.optsHistory=[],this.logs=[],this.bRender=!0,this.hColor=new THREE.Color(16777011),this.sphereGeometry=new THREE.SphereGeometry(1,32,32),this.boxGeometry=new THREE.BoxGeometry(1,1,1),this.cylinderGeometry=new THREE.CylinderGeometry(1,1,1,32,1),this.cylinderGeometryOutline=new THREE.CylinderGeometry(1,1,1,32,1,!0),this.axisDIV=15,this.strandDIV=6,this.tubeDIV=8,this.nucleicAcidStrandDIV=6,this.linewidth=1,this.hlLineRadius=.1,this.threshbox=180,this.maxAtoms3DMultiFile=4e4,this.tsHbond=3.8,this.tsIonic=6,this.tsContact=4,this.tsHalogen=3.8,this.tsPication=6,this.tsPistacking=5.5,this.LABELSIZE=30,this.rayThreshold=.5,this.colorBlackbkgd="#ffff00",this.colorWhitebkgd="#000000",this.optsOri={},this.optsOri.camera="perspective",this.optsOri.background="black",this.optsOri.color="chain",this.optsOri.proteins="ribbon",this.optsOri.sidec="nothing",this.optsOri.nucleotides="nucleotide cartoon",this.optsOri.ntbase="nothing",this.optsOri.surface="nothing",this.optsOri.opacity="1.0",this.optsOri.wireframe="no",this.optsOri.map="nothing",this.optsOri.mapwireframe="yes",this.optsOri.emmap="nothing",this.optsOri.emmapwireframe="yes",this.optsOri.phimap="nothing",this.optsOri.phimapwireframe="yes",this.optsOri.phisurface="nothing",this.optsOri.phisurftype="nothing",this.optsOri.phisurfop="1.0",this.optsOri.phisurfwf="yes",this.optsOri.chemicals="stick",this.optsOri.water="nothing",this.optsOri.ions="sphere",this.optsOri.hbonds="no",this.optsOri.saltbridge="no",this.optsOri.contact="no",this.optsOri.halogen="no",this.optsOri["pi-cation"]="no",this.optsOri["pi-stacking"]="no",this.optsOri.ssbonds="yes",this.optsOri.clbonds="yes",this.optsOri.rotationcenter="molecule center",this.optsOri.axis="no",this.optsOri.fog="no",this.optsOri.slab="no",this.optsOri.pk="residue",this.optsOri.chemicalbinding="hide",this.opts=n.hashUtilsCls.cloneHash(this.optsOri),this.sheetcolor="green",this.bShowHighlight=!0,this.mapData={},this.bFullUi=!0,this.divid=this.icn3dui.cfg.divid,this.inputid="",this.setOperation="or",this.ROT_DIR="right",this.currSelectedSets=[],this.selectedResidues={},this.ncbi2resid={},this.resid2ncbi={},this.shapeCmdHash={},this.bHideSelection=!0,this.bSelectResidue=!1,this.bSelectAlignResidue=!1,this.bAnnoShown=!1,this.bSetChainsAdvancedMenu=!1,this.b2DShown=!1,this.bCrashed=!1,this.bAddCommands=!0,this.bAddLogs=!0,this.bNotLoadStructure=!1,this.InputfileData="",this.bVr=!1,this.bAr=!1,this.startColor="blue",this.midColor="white",this.endColor="red",this.startValue=0,this.midValue=50,this.endValue=100,this.crosslinkRadius=.4,this.sceneCls=new Ee(this),this.cameraCls=new Ie(this),this.fogCls=new Te(this),this.boxCls=new Me(this),this.brickCls=new Pe(this),this.curveStripArrowCls=new De(this),this.curveCls=new He(this),this.cylinderCls=new Fe(this),this.lineCls=new Le(this),this.reprSubCls=new Ne(this),this.sphereCls=new Ue(this),this.stickCls=new qe(this),this.strandCls=new $e(this),this.stripCls=new je(this),this.tubeCls=new Be(this),this.cartoonNuclCls=new ze(this),this.surfaceCls=new Je(this),this.labelCls=new Ve(this),this.axesCls=new We(this),this.glycanCls=new Ye(this),this.applyCenterCls=new Ze(this),this.applyClbondsCls=new et(this),this.applyDisplayCls=new tt(this),this.applyMapCls=new lt(this),this.applyOtherCls=new st(this),this.applySsbondsCls=new it(this),this.applySymdCls=new nt(this),this.hlObjectsCls=new Dt(this),this.residueLabelsCls=new rt(this),this.alternateCls=new dt(this),this.drawCls=new ct(this),this.firstAtomObjCls=new hs(this),this.impostorCls=new ot(this),this.instancingCls=new at(this),this.contactCls=new ht(this),this.hBondCls=new pt(this),this.piHalogenCls=new mt(this),this.saltbridgeCls=new ut(this),this.loadPDBCls=new is(this),this.vastplusCls=new ns(this),this.transformCls=new _s(this),this.setStyleCls=new gt(this),this.setColorCls=new ft(this),this.threeDPrintCls=new xs(this),this.export3DCls=new ks(this),this.annoCddSiteCls=new yt(this),this.annoContactCls=new vt(this),this.annoPTMCls=new wt(this),this.annoCrossLinkCls=new _t(this),this.annoDomainCls=new St(this),this.annoSnpClinVarCls=new At(this),this.annoSsbondCls=new xt(this),this.annoTransMemCls=new kt(this),this.domain3dCls=new Ot(this),this.addTrackCls=new Rt(this),this.annotationCls=new Et(this),this.showAnnoCls=new It(this),this.showSeqCls=new Tt(this),this.hlSeqCls=new Mt(this),this.hlUpdateCls=new Pt(this),this.lineGraphCls=new Ht(this),this.getGraphCls=new Ft(this),this.showInterCls=new Lt(this),this.viewInterPairsCls=new Nt(this),this.drawGraphCls=new Ut(this),this.contactMapCls=new qt(this),this.alignParserCls=new $t(this),this.chainalignParserCls=new jt(this),this.dsn6ParserCls=new Bt(this),this.mmcifParserCls=new zt(this),this.mmdbParserCls=new Gt(this),this.mmtfParserCls=new Vt(this),this.mol2ParserCls=new Wt(this),this.opmParserCls=new Yt(this),this.pdbParserCls=new Xt(this),this.sdfParserCls=new Kt(this),this.xyzParserCls=new Qt(this),this.realignParserCls=new Jt(this),this.densityCifParserCls=new Zt(this),this.ParserUtilsCls=new es(this),this.loadAtomDataCls=new ts(this),this.setSeqAlignCls=new ss(this),this.applyCommandCls=new ls(this),this.definedSetsCls=new rs(this),this.legendTableCls=new Ct(this),this.loadScriptCls=new os(this),this.selByCommCls=new as(this),this.selectionCls=new ds(this),this.resid2specCls=new cs(this),this.delphiCls=new ps(this),this.dsspCls=new ms(this),this.refnumCls=new us(this),this.scapCls=new gs(this),this.symdCls=new fs(this),this.alignSWCls=new bs(this),this.analysisCls=new Cs(this),this.resizeCanvasCls=new ws(this),this.saveFileCls=new Ss(this),this.setOptionCls=new bt(this),this.shareLinkCls=new As(this),this.diagram2dCls=new ys(this),this.cartoon2dCls=new vs(this),this.rayCls=new Os(this),this.controlCls=new Rs(this),this.pickingCls=new Es(this),this.VRButtonCls=new Is(this),this.ARButtonCls=new Ts(this),this.matShader=this.setColorCls.setOutlineColor("yellow")}}Ms.prototype.init=function(e){this.init_base(),this.molTitle="",this.ssbondpnts={},this.clbondpnts={},this.biomtMatrices=[],this.bAssembly=!0,this.bDrawn=!1,this.bSecondaryStructure=!1,this.bHighlight=1,this.axes=[]},Ms.prototype.init_base=function(e){this.resetConfig(),this.structures={},this.chains={},this.tddomains={},this.residues={},this.secondaries={},this.alnChains={},this.chainsSeq={},this.chainsColor={},this.chainsGene={},this.chainsAn={},this.chainsAnTitle={},this.chainsMapping={},this.resid2refnum={},this.residIgLoop={},this.refnum2residArray={},this.bShowRefnum=!1,this.alnChainsSeq={},this.alnChainsAnno={},this.alnChainsAnTtl={},this.pickedAtomList={},this.prevHighlightObjects=[],this.prevHighlightObjects_ghost=[],this.prevSurfaces=[],this.prevMaps=[],this.prevEmmaps=[],this.prevPhimaps=[],this.prevOtherMesh=[],this.defNames2Residues={},this.defNames2Atoms={},this.defNames2Descr={},this.defNames2Command={},this.residueId2Name={},this.atoms={},this.dAtoms={},this.hAtoms={},this.proteins={},this.sidec={},this.ntbase={},this.nucleotides={},this.nucleotidesO3={},this.chemicals={},this.ions={},this.water={},this.calphas={},this.hbondpnts=[],this.saltbridgepnts=[],this.contactpnts=[],this.stabilizerpnts=[],this.halogenpnts=[],this.picationpnts=[],this.pistackingpnts=[],this.distPnts=[],this.doublebonds={},this.triplebonds={},this.aromaticbonds={},this.atomPrevColors={},this.style2atoms={},this.labels={},this.lines={},this.resids2inter={},this.resids2interAll={},this.transformCls.rotateCount=0,this.transformCls.rotateCountMax=20,e&&(this.commands=[]),this.axes=[],this.bGlycansCartoon=0,this.bMembrane=1,this.bCmdWindow=0,this.chainMissingResidueArray={},this.nTotalGap=0},Ms.prototype.reinitAfterLoad=function(){let e=this,t=e.icn3dui;e.resetConfig(),e.setStyleCls.setAtomStyleByOptions(),e.setColorCls.setColorByOptions(e.opts,e.atoms),e.dAtoms=t.hashUtilsCls.cloneHash(e.atoms),e.hAtoms=t.hashUtilsCls.cloneHash(e.atoms),e.prevHighlightObjects=[],e.prevHighlightObjects_ghost=[],e.prevSurfaces=[],e.prevMaps=[],e.prevEmmaps=[],e.prevPhimaps=[],e.prevOtherMesh=[],e.labels={},e.lines={},e.shapeCmdHash={},e.bAssembly=!0},Ms.prototype.resetConfig=function(){let e=this,t=e.icn3dui;if(this.opts=t.hashUtilsCls.cloneHash(this.optsOri),void 0===t.cfg.align&&void 0===t.cfg.chainalign||(this.opts.color="identity",this.opts.proteins="c alpha trace",this.opts.nucleotides="o3 trace"),void 0!==t.cfg.cid&&(this.opts.color="atom",this.opts.pk="atom",this.opts.chemicals="ball and stick"),void 0!==t.cfg.afid&&(this.opts.color="confidence"),void 0!==t.cfg.blast_rep_id&&(this.opts.color="conservation"),void 0!==t.cfg.mmdbafid){let s=t.cfg.mmdbafid.split(",");if(s.length>1)e.opts.color="structure";else if(1==s.length){let t=s[0];isNaN(t)&&t.length>5?this.opts.color="confidence":e.opts.color="chain"}}void 0!==t.cfg.options&&$.extend(this.opts,t.cfg.options)};class Ps{constructor(e){this.cfg=e,this.pre=this.cfg.divid+"_",this.REVISION="3.23.2",this.bNode=Object.keys(window).length<2,void 0===this.cfg.command&&(this.cfg.command=""),void 0===this.cfg.width&&(this.cfg.width="100%"),void 0===this.cfg.height&&(this.cfg.height="100%"),void 0===this.cfg.resize&&(this.cfg.resize=!0),void 0===this.cfg.showmenu&&(this.cfg.showmenu=!0),void 0===this.cfg.showtitle&&(this.cfg.showtitle=!0),void 0===this.cfg.showcommand&&(this.cfg.showcommand=!0),void 0===this.cfg.mobilemenu&&(this.cfg.mobilemenu=!1),void 0===this.cfg.closepopup&&(this.cfg.closepopup=!1),void 0===this.cfg.showanno&&(this.cfg.showanno=!1),void 0===this.cfg.showseq&&(this.cfg.showseq=!1),void 0===this.cfg.showalignseq&&(this.cfg.showalignseq=!1),void 0===this.cfg.show2d&&(this.cfg.show2d=!1),void 0===this.cfg.showsets&&(this.cfg.showsets=!1),void 0===this.cfg.rotate&&(this.cfg.rotate="right"),void 0===this.cfg.hidelicense&&(this.cfg.hidelicense=!1),this.hashUtilsCls=new t(this),this.utilsCls=new s(this),this.parasCls=new i(this),this.myEventCls=new n(this),this.rmsdSuprCls=new l(this),this.subdivideCls=new r(this),this.convertTypeCls=new o(this),this.htmlCls=new g(this)}allCustomEvents(){}}Ps.prototype.show3DStructure=async function(e){let t=this;t.cfg.menuicon?(t.htmlCls.wifiStr=' ',t.htmlCls.licenseStr=' '):(t.htmlCls.wifiStr="",t.htmlCls.licenseStr=""),t.setIcn3d();let s=t.icn3d;t.utilsCls.isSessionStorageSupported()&&s.setStyleCls.getCommandsBeforeCrash();let i=t.htmlCls.WIDTH,n=t.htmlCls.HEIGHT;t.oriWidth=i,t.oriHeight=n,t.htmlCls.eventsCls.allEventFunctions(),this.allCustomEvents();let l=0;if((null==t.cfg.showmenu||t.cfg.showmenu)&&(l+=t.htmlCls.MENU_HEIGHT),(null==t.cfg.showcommand||t.cfg.showcommand)&&(l+=t.htmlCls.CMD_HEIGHT),null!=t.cfg.showmenu&&0==t.cfg.showmenu?t.htmlCls.setMenuCls.hideMenu():t.htmlCls.setMenuCls.showMenu(),null!=t.cfg.showtitle&&0==t.cfg.showtitle?$("#"+s.pre+"title").hide():$("#"+s.pre+"title").show(),$("#"+s.pre+"viewer").width(i).height(parseInt(n)+l),$("#"+s.pre+"canvas").width(i).height(parseInt(n)),$("#"+s.pre+"canvas").resizable({resize:function(e,i){t.htmlCls.WIDTH=i.size.width,t.htmlCls.HEIGHT=i.size.height,void 0===s||t.icn3d.bFullscreen||s.resizeCanvasCls.resizeCanvas(t.htmlCls.WIDTH,t.htmlCls.HEIGHT,!0)}}),void 0!==t.cfg.usepdbnum?t.icn3d.bUsePdbNum=t.cfg.usepdbnum:void 0!==t.cfg.date?t.icn3d.bUsePdbNum=parseInt(t.cfg.date)>=20201222:"1tup"==t.cfg.mmdbid&&1==t.cfg.showanno&&1==t.cfg.show2d&&1==t.cfg.showsets||"118496"==t.cfg.mmdbid&&0==t.cfg.showanno&&-1!=t.cfg.inpara.indexOf("bu=1")||"163605,1,91105,1,1,1"==t.cfg.align&&-1!=t.cfg.inpara.indexOf("atype=1")?t.icn3d.bUsePdbNum=!1:t.icn3d.bUsePdbNum=!0,t.cfg.replay?(s.bReplay=1,$("#"+s.pre+"replay").show()):(s.bReplay=0,$("#"+s.pre+"replay").hide()),t.utilsCls.isMobile()&&(s.threshbox=60),t.cfg.controlGl&&(s.bControlGl=!0,s.container=s.bControlGl&&!t.bNode?$(document):$("#"+s.id)),s.setStyleCls.handleContextLost(),s.applyCenterCls.setWidthHeight(i,n),s.ori_chemicalbinding=s.opts.chemicalbinding,void 0!==t.cfg.bCalphaOnly&&(s.bCalphaOnly=t.cfg.bCalphaOnly),s.opts=t.hashUtilsCls.cloneHash(s.opts),s.STATENUMBER=s.commands.length,t.utilsCls.isSessionStorageSupported()&&s.bCrashed){s.bCrashed=!1;let e=s.commandsBeforeCrash.split("|||")[0],i=e.substr(e.lastIndexOf(" ")+1);if(i===t.cfg.mmtfid||i===t.cfg.pdbid||i===t.cfg.opmid||i===t.cfg.mmdbid||i===t.cfg.gi||i===t.cfg.blast_rep_id||i===t.cfg.cid||i===t.cfg.mmcifid||i===t.cfg.align||i===t.cfg.chainalign||i===t.cfg.mmdbafid)return void await s.loadScriptCls.loadScript(s.commandsBeforeCrash,!0)}if(s.molTitle="",s.loadCmd,t.htmlCls.clickMenuCls.getHiddenMenusFromCache(),t.htmlCls.clickMenuCls.applyShownMenus(),e){if(s.init(),s.bInputfile=!0,s.InputfileType="pdb",s.InputfileData=s.InputfileData?s.InputfileData+"\nENDMDL\n"+e:e,await s.pdbParserCls.loadPdbData(e),void 0!==t.cfg.resdef&&void 0!==t.cfg.chains){let e=Object.keys(s.structures),i=t.cfg.chains.split(" | "),n=[];if(e.length==i.length){for(let t=0,s=e.length;t0&&(l+=","),l+=n[e].substr(0,n[e].indexOf("_"));s.chainidArray=[e].concat(n),s.chainidArray=s.chainalignParserCls.addPostfixForChainids(s.chainidArray),t.htmlCls.clickMenuCls.setLogCmd("resdef "+t.cfg.resdef,!0),s.loadCmd="vast_search_chainid "+s.chainidArray,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),s.bMmdbafid=!0;let r=!0;await s.chainalignParserCls.downloadMmdbAf(l,r)}}else if(void 0!==t.cfg.url){s.bInputUrlfile=!0;let e=t.cfg.url.split("|"),i=e[0],n=e[1];s.molTitle="",s.inputid=n,s.inputurl="type="+i+"&url="+encodeURIComponent(n),s.loadCmd="load url "+n+" | type "+i,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.pdbParserCls.downloadUrl(n,i,t.cfg.command)}else if(void 0!==t.cfg.mmtfid)s.inputid=t.cfg.mmtfid,s.loadCmd="load mmtf "+t.cfg.mmtfid,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.mmtfParserCls.downloadMmtf(t.cfg.mmtfid);else if(void 0!==t.cfg.pdbid)s.inputid=t.cfg.pdbid,s.loadCmd="load pdb "+t.cfg.pdbid,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.pdbParserCls.downloadPdb(t.cfg.pdbid);else if(void 0!==t.cfg.afid){s.inputid=t.cfg.afid,s.loadCmd="load af "+t.cfg.afid,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0);let e=!0;await s.pdbParserCls.downloadPdb(t.cfg.afid,e)}else if(void 0!==t.cfg.opmid)s.inputid=t.cfg.opmid,s.loadCmd="load opm "+t.cfg.opmid,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.opmParserCls.downloadOpm(t.cfg.opmid);else if(void 0!==t.cfg.mmdbid)s.inputid=t.cfg.mmdbid,s.loadCmd="load mmdb "+t.cfg.mmdbid+" | parameters "+t.cfg.inpara,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.mmdbParserCls.downloadMmdb(t.cfg.mmdbid);else if(void 0!==t.cfg.gi)s.loadCmd="load gi "+t.cfg.gi,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.mmdbParserCls.downloadGi(t.cfg.gi);else if(void 0!==t.cfg.refseqid)s.inputid=t.cfg.refseqid,s.loadCmd="load refseq "+t.cfg.refseqid,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.mmdbParserCls.downloadRefseq(t.cfg.refseqid);else if(void 0!==t.cfg.blast_rep_id)if(s.inputid=t.cfg.query_id+","+t.cfg.blast_rep_id,t.cfg.oriQuery_id=t.cfg.query_id,t.cfg.oriBlast_rep_id=t.cfg.blast_rep_id,"Query"!==t.cfg.query_id.substr(0,5)&&void 0===t.cfg.rid)"icn3d"==t.cfg.from&&"1TSR_A"==t.cfg.blast_rep_id&&"NP_001108451.1"==t.cfg.query_id&&(t.cfg.command="view annotations; set annotation cdd; set annotation site; set view detailed view; select chain 1TSR_A; show selection"),"smithwm"==t.cfg.alg?(s.loadCmd="load seq_struct_ids_smithwm "+t.cfg.query_id+","+t.cfg.blast_rep_id,s.bSmithwm=!0):"local_smithwm"==t.cfg.alg?(s.loadCmd="load seq_struct_ids_local_smithwm "+t.cfg.query_id+","+t.cfg.blast_rep_id,s.bLocalSmithwm=!0):(s.loadCmd="load seq_struct_ids "+t.cfg.query_id+","+t.cfg.blast_rep_id,s.bSmithwm=!1,s.bLocalSmithwm=!1),t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.mmdbParserCls.downloadBlast_rep_id(t.cfg.query_id+","+t.cfg.blast_rep_id);else if(void 0!==t.cfg.rid){let e="https://blast.ncbi.nlm.nih.gov/Blast.cgi?RESULTS_FILE=on&FORMAT_TYPE=JSON2_S&FORMAT_OBJECT=Alignment&CMD=Get&RID="+t.cfg.rid,i=await t.getAjaxPromise(e,"json",!1,"The RID "+t.cfg.rid+" may have expired...");for(let e=0,n=i.BlastOutput2.length;e
    ",s="All atoms  ";e.utilsCls.setViewerWidthHeight(e),e.utilsCls.isMobile()||e.cfg.mobilemenu?e.htmlCls.setMenuCls.setTopMenusHtmlMobile(e.cfg.divid,t,s):e.htmlCls.setMenuCls.setTopMenusHtml(e.cfg.divid,t,s),e.icn3d=new Ms(e),e.icn3d.controlCls.setControl(),e.setDialogAjax()},Ps.prototype.getAjaxPromise=function(e,t,s,i,n,l){let r=this;return new Promise((function(o,a){$.ajax({url:e,dataType:t,cache:!0,beforeSend:function(){s&&r.icn3d.ParserUtilsCls.showLoading()},complete:function(){l&&r.icn3d.ParserUtilsCls.hideLoading()},success:function(e){o(e)},error:function(){i&&alert(i),n&&console.log(n),a("error")}})}))},Ps.prototype.getAjaxPostPromise=function(e,t,s,i,n,l,r){let o=this;return r=r||"json",new Promise((function(a,d){$.ajax({url:e,type:"POST",data:t,dataType:r,cache:!0,beforeSend:function(){s&&o.icn3d.ParserUtilsCls.showLoading()},complete:function(){l&&o.icn3d.ParserUtilsCls.hideLoading()},success:function(e){a(e)},error:function(){i&&alert(i),n&&console.log(n),d("error")}})}))},Ps.prototype.setDialogAjax=function(){this.bNode||$.ui.dialog.prototype._makeDraggableBase||($.ui.dialog.prototype._makeDraggableBase=$.ui.dialog.prototype._makeDraggable,$.ui.dialog.prototype._makeDraggable=function(){this._makeDraggableBase(),this.uiDialog.draggable("option","containment",!1)}),$.ajaxTransport("+binary",(function(e,t,s){if(window.FormData&&(e.dataType&&"binary"==e.dataType||e.data&&(window.ArrayBuffer&&e.data instanceof ArrayBuffer||window.Blob&&e.data instanceof Blob)))return{send:function(t,s){let i=new XMLHttpRequest,n=e.url,l=e.type,r=e.async||!0,o=e.responseType||"blob",a=e.data||null;i.addEventListener("load",(function(){let t={};t[e.dataType]=i.response,s(i.status,i.statusText,t,i.getAllResponseHeaders())})),i.open(l,n,r);for(let e in t)i.setRequestHeader(e,t[e]);i.responseType=o,i.send(a)},abort:function(){s.abort()}}}))};return e.ARButton=Ts,e.AddTrack=Rt,e.AlignParser=$t,e.AlignSW=bs,e.AlignSeq=m,e.Alternate=dt,e.Analysis=Cs,e.AnnoCddSite=yt,e.AnnoContact=vt,e.AnnoCrossLink=_t,e.AnnoDomain=St,e.AnnoSnpClinVar=At,e.AnnoSsbond=xt,e.AnnoTransMem=kt,e.Annotation=Et,e.ApplyCenter=Ze,e.ApplyClbonds=et,e.ApplyCommand=ls,e.ApplyDisplay=tt,e.ApplyMap=lt,e.ApplyOther=st,e.ApplySsbonds=it,e.ApplySymd=nt,e.Axes=We,e.Box=Me,e.Brick=Pe,e.Camera=Ie,e.CartoonNucl=ze,e.ChainalignParser=jt,e.ClickMenu=a,e.Contact=ht,e.Control=Rs,e.ConvertTypeCls=o,e.Curve=He,e.CurveStripArrow=De,e.Cylinder=Fe,e.DefinedSets=rs,e.Delphi=ps,e.DensityCifParser=Zt,e.Diagram2d=ys,e.Dialog=c,e.Domain3d=Ot,e.Draw=ct,e.DrawGraph=Ut,e.Dsn6Parser=Bt,e.Dssp=ms,e.ElectronMap=Qe,e.Events=p,e.Export3D=ks,e.FirstAtomObj=hs,e.Fog=Te,e.GetGraph=Ft,e.Glycan=Ye,e.HBond=pt,e.HashUtilsCls=t,e.HlObjects=Dt,e.HlSeq=Mt,e.HlUpdate=Pt,e.Html=g,e.Impostor=ot,e.Instancing=at,e.Label=Ve,e.Line=Le,e.LineGraph=Ht,e.LoadAtomData=ts,e.LoadPDB=is,e.LoadScript=os,e.MarchingCube=Xe,e.MmcifParser=zt,e.MmdbParser=Gt,e.MmtfParser=Vt,e.Mol2Parser=Wt,e.MyEventCls=n,e.OpmParser=Yt,e.ParasCls=i,e.ParserUtils=es,e.PdbParser=Xt,e.PiHalogen=mt,e.Picking=Es,e.ProteinSurface=Ke,e.Ray=Os,e.RealignParser=Jt,e.Refnum=us,e.ReprSub=Ne,e.Resid2spec=cs,e.ResidueLabels=rt,e.ResizeCanvas=ws,e.RmsdSuprCls=l,e.Saltbridge=ut,e.SaveFile=Ss,e.Scap=gs,e.Scene=Ee,e.SdfParser=Kt,e.SelectByCommand=as,e.Selection=ds,e.SetColor=ft,e.SetDialog=h,e.SetHtml=u,e.SetMenu=d,e.SetOption=bt,e.SetSeqAlign=ss,e.SetStyle=gt,e.ShareLink=As,e.ShowAnno=It,e.ShowInter=Lt,e.ShowSeq=Tt,e.Sphere=Ue,e.Stick=qe,e.Strand=$e,e.Strip=je,e.SubdivideCls=r,e.Surface=Je,e.Symd=fs,e.ThreeDPrint=xs,e.Transform=_s,e.Tube=Be,e.UtilsCls=s,e.VRButton=Is,e.Vastplus=ns,e.ViewInterPairs=Nt,e.XyzParser=Qt,e.iCn3D=Ms,e.iCn3DUI=Ps,e.printMsg=class{constructor(){console.log("This is a message from the icn3d package")}},Object.defineProperty(e,"__esModule",{value:!0}),e}({}); diff --git a/dist/icn3d.module.js b/dist/icn3d.module.js index 7b6af3fe..2880e55d 100644 --- a/dist/icn3d.module.js +++ b/dist/icn3d.module.js @@ -11586,7 +11586,7 @@ class SetDialog { html += me.htmlCls.divStr + "dl_mmdbafid' class='" + dialogClass + "' style='max-width:600px'>"; html += "List of PDB, MMDB, or AlphaFold UniProt structures: " + me.htmlCls.inputTextStr + "id='" + me.pre + "mmdbafid' placeholder='e.g., 1HHO,4N7N,P69905,P01942' size=30>

    "; html += "
    " + me.htmlCls.buttonStr + "reload_mmdbaf' style='width:150px'>Load Biological Unit" + me.htmlCls.buttonStr + "reload_mmdbaf_asym' style='margin-left:30px; width:250px'>Load Asymmetric Unit (All Chains)" + "

    "; - html += "
    or
    " + me.htmlCls.buttonStr + "reload_mmdbaf_append' style='width:150px'>Append Biological Unit" + me.htmlCls.buttonStr + "reload_mmdbaf_asym_append' style='margin-left:30px; width:250px'>Append Asymmetric ; Unit (All Chains)" + "

    "; + html += "
    or
    " + me.htmlCls.buttonStr + "reload_mmdbaf_append' style='width:150px'>Append Biological Unit" + me.htmlCls.buttonStr + "reload_mmdbaf_asym_append' style='margin-left:30px; width:250px'>Append Asymmetric Unit (All Chains)" + "

    "; html += 'Note: The "biological unit" is the biochemically active form of a biomolecule,
    0.0 ){"," cameraPos = rayDirection * posT + rayOrigin;"," interior = true;"," flag2 = true;"," return false;","}else{"," cameraNormal = normalize( cameraPos - cameraSpherePos );","}"," #else","if( calcDepth( cameraPos ) <= 0.0 ){"," cameraPos = rayDirection * posT + rayOrigin;"," interior = true;"," return false;","}else{"," cameraNormal = normalize( cameraPos - cameraSpherePos );","}"," #endif",""," cameraNormal = normalize( cameraPos - cameraSpherePos );"," cameraNormal *= float(!interior) * 2.0 - 1.0;"," return !interior;","","}","","void main(void){",""," bool flag = Impostor( cameraPos, cameraNormal );",""," #ifdef NEAR_CLIP"," if( calcClip( cameraPos ) > 0.0 )"," discard;"," #endif",""," // FIXME not compatible with custom clipping plane"," //Set the depth based on the new cameraPos."," gl_FragDepthEXT = calcDepth( cameraPos );"," if( !flag ){",""," // clamp to near clipping plane and add a tiny value to"," // make spheres with a greater radius occlude smaller ones"," #ifdef NEAR_CLIP","if( flag2 ){"," gl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( nearClip - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );","}else if( gl_FragDepthEXT >= 0.0 ){"," gl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );","}"," #else","if( gl_FragDepthEXT >= 0.0 ){"," gl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );","}"," #endif",""," }",""," // bugfix (mac only?)"," if (gl_FragDepthEXT < 0.0)"," discard;"," if (gl_FragDepthEXT > 1.0)"," discard;",""," #ifdef PICKING",""," gl_FragColor = vec4( vPickingColor, objectId );",""," #else",""," vec3 vNormal = cameraNormal;"," vec3 vViewPosition = -cameraPos;",""," vec4 diffuseColor = vec4( diffuse, opacity );"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveLight = emissive;",""," #include color_fragment"," #include roughnessmap_fragment"," #include metalnessmap_fragment",""," // don't use include normal_fragment"," vec3 normal = normalize( vNormal );",""," #include lights_physical_fragment"," //include lights_template"," #include lights_fragment_begin"," #include lights_fragment_end",""," vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;",""," gl_FragColor = vec4( outgoingLight, diffuseColor.a );"," //gl_FragColor = vec4( reflectedLight.directSpecular, diffuseColor.a );",""," #include premultiplied_alpha_fragment"," #include tonemapping_fragment"," #include encodings_fragment"," //include fog_fragment"," #ifdef USE_FOG"," #ifdef USE_LOGDEPTHBUF_EXT"," float depth = gl_FragDepthEXT / gl_FragCoord.w;"," #else"," float depth = gl_FragCoord.z / gl_FragCoord.w;"," #endif"," #ifdef FOG_EXP2"," float fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );"," #else"," float fogFactor = smoothstep( fogNear, fogFar, depth );"," #endif"," gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );"," #endif",""," #endif","","}"].join("\n"),$NGL_shaderTextHash["SphereImpostor.vert"]=["uniform mat4 projectionMatrixInverse;","uniform float nearClip;","","varying float vRadius;","varying float vRadiusSq;","varying vec3 vPoint;","varying vec3 vPointViewPosition;","varying float fogDepth;","varying float fogNear;","varying float fogFar;","","attribute vec2 mapping;","//attribute vec3 position;","attribute float radius;","","#ifdef PICKING"," #include unpack_clr"," attribute float primitiveId;"," varying vec3 vPickingColor;","#else"," #include color_pars_vertex","#endif","","//include matrix_scale","float matrixScale( in mat4 m ){"," vec4 r = m[ 0 ];"," return sqrt( r[ 0 ] * r[ 0 ] + r[ 1 ] * r[ 1 ] + r[ 2 ] * r[ 2 ] );","}","","const mat4 D = mat4("," 1.0, 0.0, 0.0, 0.0,"," 0.0, 1.0, 0.0, 0.0,"," 0.0, 0.0, 1.0, 0.0,"," 0.0, 0.0, 0.0, -1.0",");","","mat4 transposeTmp( in mat4 inMatrix ) {"," vec4 i0 = inMatrix[0];"," vec4 i1 = inMatrix[1];"," vec4 i2 = inMatrix[2];"," vec4 i3 = inMatrix[3];",""," mat4 outMatrix = mat4("," vec4(i0.x, i1.x, i2.x, i3.x),"," vec4(i0.y, i1.y, i2.y, i3.y),"," vec4(i0.z, i1.z, i2.z, i3.z),"," vec4(i0.w, i1.w, i2.w, i3.w)"," );"," return outMatrix;","}","","//------------------------------------------------------------------------------","// Compute point size and center using the technique described in:","// 'GPU-Based Ray-Casting of Quadratic Surfaces'","// by Christian Sigg, Tim Weyrich, Mario Botsch, Markus Gross.","//","// Code based on","/*=========================================================================",""," Program: Visualization Toolkit"," Module: Quadrics_fs.glsl and Quadrics_vs.glsl",""," Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen"," All rights reserved."," See Copyright.txt or http://www.kitware.com/Copyright.htm for details.",""," This software is distributed WITHOUT ANY WARRANTY; without even"," the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR"," PURPOSE. See the above copyright notice for more information.",""," =========================================================================*/","","// .NAME Quadrics_fs.glsl and Quadrics_vs.glsl","// .SECTION Thanks","// ","//","// This file is part of the PointSprites plugin developed and contributed by","//","// Copyright (c) CSCS - Swiss National Supercomputing Centre","// EDF - Electricite de France","//","// John Biddiscombe, Ugo Varetto (CSCS)","// Stephane Ploix (EDF)","//","// ","//","// Contributions by Alexander Rose","// - ported to WebGL","// - adapted to work with quads","void ComputePointSizeAndPositionInClipCoordSphere(){",""," vec2 xbc;"," vec2 ybc;",""," mat4 T = mat4("," radius, 0.0, 0.0, 0.0,"," 0.0, radius, 0.0, 0.0,"," 0.0, 0.0, radius, 0.0,"," position.x, position.y, position.z, 1.0"," );",""," mat4 R = transposeTmp( projectionMatrix * modelViewMatrix * T );"," float A = dot( R[ 3 ], D * R[ 3 ] );"," float B = -2.0 * dot( R[ 0 ], D * R[ 3 ] );"," float C = dot( R[ 0 ], D * R[ 0 ] );"," xbc[ 0 ] = ( -B - sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," xbc[ 1 ] = ( -B + sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," float sx = abs( xbc[ 0 ] - xbc[ 1 ] ) * 0.5;",""," A = dot( R[ 3 ], D * R[ 3 ] );"," B = -2.0 * dot( R[ 1 ], D * R[ 3 ] );"," C = dot( R[ 1 ], D * R[ 1 ] );"," ybc[ 0 ] = ( -B - sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," ybc[ 1 ] = ( -B + sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," float sy = abs( ybc[ 0 ] - ybc[ 1 ] ) * 0.5;",""," gl_Position.xy = vec2( 0.5 * ( xbc.x + xbc.y ), 0.5 * ( ybc.x + ybc.y ) );"," gl_Position.xy -= mapping * vec2( sx, sy );"," gl_Position.xy *= gl_Position.w;","","}","","void main(void){",""," #ifdef PICKING"," vPickingColor = unpackColor( primitiveId );"," #else"," #include color_vertex"," #endif",""," vRadius = radius * matrixScale( modelViewMatrix );",""," vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );"," // avoid clipping, added again in fragment shader"," mvPosition.z -= vRadius;",""," gl_Position = projectionMatrix * vec4( mvPosition.xyz, 1.0 );"," ComputePointSizeAndPositionInClipCoordSphere();","",""," vRadiusSq = vRadius * vRadius;"," vec4 vPoint4 = projectionMatrixInverse * gl_Position;"," vPoint = vPoint4.xyz / vPoint4.w;"," vPointViewPosition = -mvPosition.xyz / mvPosition.w;","","}"].join("\n"),$NGL_shaderTextHash["CylinderImpostor.frag"]=["#define STANDARD","#define IMPOSTOR","","// Open-Source PyMOL is Copyright (C) Schrodinger, LLC.","//","// All Rights Reserved","//","// Permission to use, copy, modify, distribute, and distribute modified","// versions of this software and its built-in documentation for any","// purpose and without fee is hereby granted, provided that the above","// copyright notice appears in all copies and that both the copyright","// notice and this permission notice appear in supporting documentation,","// and that the name of Schrodinger, LLC not be used in advertising or","// publicity pertaining to distribution of the software without specific,","// written prior permission.","//","// SCHRODINGER, LLC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,","// INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN","// NO EVENT SHALL SCHRODINGER, LLC BE LIABLE FOR ANY SPECIAL, INDIRECT OR","// CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS","// OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE","// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE","// USE OR PERFORMANCE OF THIS SOFTWARE.","","// Contributions by Alexander Rose","// - ported to WebGL","// - dual color","// - pk color","// - custom clipping","// - three.js lighting","","uniform vec3 diffuse;","uniform vec3 emissive;","uniform float roughness;","uniform float metalness;","uniform float opacity;","uniform float nearClip;","uniform mat4 projectionMatrix;","uniform float ortho;","","varying vec3 axis;","varying vec4 base_radius;","varying vec4 end_b;","varying vec3 U;","varying vec3 V;","varying vec4 w;","","#ifdef PICKING"," uniform float objectId;"," varying vec3 vPickingColor;","#else"," varying vec3 vColor1;"," varying vec3 vColor2;"," #include common"," #include fog_pars_fragment"," #include bsdfs"," #include lights_pars_begin"," #include lights_physical_pars_fragment","#endif","","bool interior = false;","","float distSq3( vec3 v3a, vec3 v3b ){"," return ("," ( v3a.x - v3b.x ) * ( v3a.x - v3b.x ) +"," ( v3a.y - v3b.y ) * ( v3a.y - v3b.y ) +"," ( v3a.z - v3b.z ) * ( v3a.z - v3b.z )"," );","}","","// Calculate depth based on the given camera position.","float calcDepth( in vec3 cameraPos ){"," vec2 clipZW = cameraPos.z * projectionMatrix[2].zw + projectionMatrix[3].zw;"," return 0.5 + 0.5 * clipZW.x / clipZW.y;","}","","float calcClip( vec3 cameraPos ){"," return dot( vec4( cameraPos, 1.0 ), vec4( 0.0, 0.0, 1.0, nearClip - 0.5 ) );","}","","void main(){",""," vec3 point = w.xyz / w.w;",""," // unpacking"," vec3 base = base_radius.xyz;"," float vRadius = base_radius.w;"," vec3 end = end_b.xyz;"," float b = end_b.w;",""," vec3 end_cyl = end;"," vec3 surface_point = point;",""," vec3 ray_target = surface_point;"," vec3 ray_origin = vec3(0.0);"," vec3 ray_direction = mix(normalize(ray_origin - ray_target), vec3(0.0, 0.0, 1.0), ortho);"," mat3 basis = mat3( U, V, axis );",""," vec3 diff = ray_target - 0.5 * (base + end_cyl);"," vec3 P = diff * basis;",""," // angle (cos) between cylinder cylinder_axis and ray direction"," float dz = dot( axis, ray_direction );",""," float radius2 = vRadius*vRadius;",""," // calculate distance to the cylinder from ray origin"," vec3 D = vec3(dot(U, ray_direction),"," dot(V, ray_direction),"," dz);"," float a0 = P.x*P.x + P.y*P.y - radius2;"," float a1 = P.x*D.x + P.y*D.y;"," float a2 = D.x*D.x + D.y*D.y;",""," // calculate a dicriminant of the above quadratic equation"," float d = a1*a1 - a0*a2;"," if (d < 0.0)"," // outside of the cylinder"," discard;",""," float dist = (-a1 + sqrt(d)) / a2;",""," // point of intersection on cylinder surface"," vec3 new_point = ray_target + dist * ray_direction;",""," vec3 tmp_point = new_point - base;"," vec3 _normal = normalize( tmp_point - axis * dot(tmp_point, axis) );",""," ray_origin = mix( ray_origin, surface_point, ortho );",""," // test caps"," float front_cap_test = dot( tmp_point, axis );"," float end_cap_test = dot((new_point - end_cyl), axis);",""," // to calculate caps, simply check the angle between"," // the point of intersection - cylinder end vector"," // and a cap plane normal (which is the cylinder cylinder_axis)"," // if the angle < 0, the point is outside of cylinder"," // test front cap",""," #ifndef CAP"," vec3 new_point2 = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;"," vec3 tmp_point2 = new_point2 - base;"," #endif",""," // flat"," if (front_cap_test < 0.0)"," {"," // ray-plane intersection"," float dNV = dot(-axis, ray_direction);"," if (dNV < 0.0)"," discard;"," float near = dot(-axis, (base)) / dNV;"," vec3 front_point = ray_direction * near + ray_origin;"," // within the cap radius?"," if (dot(front_point - base, front_point-base) > radius2)"," discard;",""," #ifdef CAP"," new_point = front_point;"," _normal = axis;"," #else"," new_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;"," dNV = dot(-axis, ray_direction);"," near = dot(axis, end_cyl) / dNV;"," new_point2 = ray_direction * near + ray_origin;"," if (dot(new_point2 - end_cyl, new_point2-base) < radius2)"," discard;"," interior = true;"," #endif"," }",""," // test end cap","",""," // flat"," if( end_cap_test > 0.0 )"," {"," // ray-plane intersection"," float dNV = dot(axis, ray_direction);"," if (dNV < 0.0)"," discard;"," float near = dot(axis, end_cyl) / dNV;"," vec3 end_point = ray_direction * near + ray_origin;"," // within the cap radius?"," if( dot(end_point - end_cyl, end_point-base) > radius2 )"," discard;",""," #ifdef CAP"," new_point = end_point;"," _normal = axis;"," #else"," new_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;"," dNV = dot(-axis, ray_direction);"," near = dot(-axis, (base)) / dNV;"," new_point2 = ray_direction * near + ray_origin;"," if (dot(new_point2 - base, new_point2-base) < radius2)"," discard;"," interior = true;"," #endif"," }",""," gl_FragDepthEXT = calcDepth( new_point );",""," #ifdef NEAR_CLIP"," if( calcClip( new_point ) > 0.0 ){"," dist = (-a1 - sqrt(d)) / a2;"," new_point = ray_target + dist * ray_direction;"," if( calcClip( new_point ) > 0.0 )"," discard;"," interior = true;"," gl_FragDepthEXT = calcDepth( new_point );"," if( gl_FragDepthEXT >= 0.0 ){"," gl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( nearClip - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );"," }"," }else if( gl_FragDepthEXT <= 0.0 ){"," dist = (-a1 - sqrt(d)) / a2;"," new_point = ray_target + dist * ray_direction;"," interior = true;"," gl_FragDepthEXT = calcDepth( new_point );"," if( gl_FragDepthEXT >= 0.0 ){"," gl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );"," }"," }"," #else"," if( gl_FragDepthEXT <= 0.0 ){"," dist = (-a1 - sqrt(d)) / a2;"," new_point = ray_target + dist * ray_direction;"," interior = true;"," gl_FragDepthEXT = calcDepth( new_point );"," if( gl_FragDepthEXT >= 0.0 ){"," gl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );"," }"," }"," #endif",""," // this is a workaround necessary for Mac"," // otherwise the modified fragment won't clip properly"," if (gl_FragDepthEXT < 0.0)"," discard;"," if (gl_FragDepthEXT > 1.0)"," discard;",""," #ifdef PICKING",""," gl_FragColor = vec4( vPickingColor, objectId );",""," #else",""," vec3 vViewPosition = -new_point;"," vec3 vNormal = _normal;"," vec3 vColor;",""," if( distSq3( new_point, end_cyl ) < distSq3( new_point, base ) ){"," if( b < 0.0 ){"," vColor = vColor1;"," }else{"," vColor = vColor2;"," }"," }else{"," if( b > 0.0 ){"," vColor = vColor1;"," }else{"," vColor = vColor2;"," }"," }",""," vec4 diffuseColor = vec4( diffuse, opacity );"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveLight = emissive;",""," #include color_fragment"," //ifdef USE_COLOR"," //diffuseColor.r *= vColor[0];"," //diffuseColor.g *= vColor[1];"," //diffuseColor.b *= vColor[2];"," //endif"," #include roughnessmap_fragment"," #include metalnessmap_fragment",""," // don't use include normal_fragment"," vec3 normal = normalize( vNormal );",""," #include lights_physical_fragment"," //include lights_template"," #include lights_fragment_begin"," #include lights_fragment_end",""," vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;",""," gl_FragColor = vec4( outgoingLight, diffuseColor.a );"," //gl_FragColor = vec4( reflectedLight.directSpecular, diffuseColor.a );",""," #include premultiplied_alpha_fragment"," #include tonemapping_fragment"," #include encodings_fragment"," //include fog_fragment"," #ifdef USE_FOG"," #ifdef USE_LOGDEPTHBUF_EXT"," float depth = gl_FragDepthEXT / gl_FragCoord.w;"," #else"," float depth = gl_FragCoord.z / gl_FragCoord.w;"," #endif"," #ifdef FOG_EXP2"," float fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );"," #else"," float fogFactor = smoothstep( fogNear, fogFar, depth );"," #endif"," gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );"," #endif",""," #endif","","}"].join("\n"),$NGL_shaderTextHash["CylinderImpostor.vert"]=["// Open-Source PyMOL is Copyright (C) Schrodinger, LLC.","//","// All Rights Reserved","//","// Permission to use, copy, modify, distribute, and distribute modified","// versions of this software and its built-in documentation for any","// purpose and without fee is hereby granted, provided that the above","// copyright notice appears in all copies and that both the copyright","// notice and this permission notice appear in supporting documentation,","// and that the name of Schrodinger, LLC not be used in advertising or","// publicity pertaining to distribution of the software without specific,","// written prior permission.","//","// SCHRODINGER, LLC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,","// INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN","// NO EVENT SHALL SCHRODINGER, LLC BE LIABLE FOR ANY SPECIAL, INDIRECT OR","// CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS","// OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE","// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE","// USE OR PERFORMANCE OF THIS SOFTWARE.","","// Contributions by Alexander Rose","// - ported to WebGL","// - dual color","// - pk color","// - shift","","attribute vec3 mapping;","attribute vec3 position1;","attribute vec3 position2;","attribute float radius;","","varying vec3 axis;","varying vec4 base_radius;","varying vec4 end_b;","varying vec3 U;","varying vec3 V;","varying vec4 w;","varying float fogDepth;","varying float fogNear;","varying float fogFar;","","#ifdef PICKING"," #include unpack_clr"," attribute float primitiveId;"," varying vec3 vPickingColor;","#else"," //attribute vec3 color;"," attribute vec3 color2;"," varying vec3 vColor1;"," varying vec3 vColor2;","#endif","","uniform mat4 modelViewMatrixInverse;","uniform float ortho;","","//include matrix_scale","float matrixScale( in mat4 m ){"," vec4 r = m[ 0 ];"," return sqrt( r[ 0 ] * r[ 0 ] + r[ 1 ] * r[ 1 ] + r[ 2 ] * r[ 2 ] );","}","","void main(){",""," #ifdef PICKING"," vPickingColor = unpackColor( primitiveId );"," #else"," vColor1 = color;"," vColor2 = color2;"," #endif",""," // vRadius = radius;"," base_radius.w = radius * matrixScale( modelViewMatrix );",""," //vec3 center = position;"," vec3 center = ( position2 + position1 ) / 2.0;"," vec3 dir = normalize( position2 - position1 );"," float ext = length( position2 - position1 ) / 2.0;",""," // using cameraPosition fails on some machines, not sure why"," // vec3 cam_dir = normalize( cameraPosition - mix( center, vec3( 0.0 ), ortho ) );"," vec3 cam_dir;"," if( ortho == 0.0 ){"," cam_dir = ( modelViewMatrixInverse * vec4( 0, 0, 0, 1 ) ).xyz - center;"," }else{"," cam_dir = ( modelViewMatrixInverse * vec4( 0, 0, 1, 0 ) ).xyz;"," }"," cam_dir = normalize( cam_dir );",""," vec3 ldir;",""," float b = dot( cam_dir, dir );"," end_b.w = b;"," // direction vector looks away, so flip"," if( b < 0.0 )"," ldir = -ext * dir;"," // direction vector already looks in my direction"," else"," ldir = ext * dir;",""," vec3 left = normalize( cross( cam_dir, ldir ) );"," left = radius * left;"," vec3 up = radius * normalize( cross( left, ldir ) );",""," // transform to modelview coordinates"," axis = normalize( normalMatrix * ldir );"," U = normalize( normalMatrix * up );"," V = normalize( normalMatrix * left );",""," vec4 base4 = modelViewMatrix * vec4( center - ldir, 1.0 );"," base_radius.xyz = base4.xyz / base4.w;",""," vec4 top_position = modelViewMatrix * vec4( center + ldir, 1.0 );"," vec4 end4 = top_position;"," end_b.xyz = end4.xyz / end4.w;",""," w = modelViewMatrix * vec4("," center + mapping.x*ldir + mapping.y*left + mapping.z*up, 1.0"," );",""," gl_Position = projectionMatrix * w;",""," // avoid clipping (1.0 seems to induce flickering with some drivers)"," gl_Position.z = 0.99;","","}"].join("\n"),$NGL_shaderTextHash["SphereInstancing.frag"]=$NGL_shaderTextHash["SphereImpostor.frag"],$NGL_shaderTextHash["SphereInstancing.vert"]=["uniform mat4 projectionMatrixInverse;","uniform float nearClip;","","varying float vRadius;","varying float vRadiusSq;","varying vec3 vPoint;","varying vec3 vPointViewPosition;","varying float fogDepth;","varying float fogNear;","varying float fogFar;","","attribute vec2 mapping;","//attribute vec3 position;","attribute float radius;","attribute vec4 matrix1;","attribute vec4 matrix2;","attribute vec4 matrix3;","attribute vec4 matrix4;","","#ifdef PICKING"," #include unpack_clr"," attribute float primitiveId;"," varying vec3 vPickingColor;","#else"," #include color_pars_vertex","#endif","","//include matrix_scale","float matrixScale( in mat4 m ){"," vec4 r = m[ 0 ];"," return sqrt( r[ 0 ] * r[ 0 ] + r[ 1 ] * r[ 1 ] + r[ 2 ] * r[ 2 ] );","}","","const mat4 D = mat4("," 1.0, 0.0, 0.0, 0.0,"," 0.0, 1.0, 0.0, 0.0,"," 0.0, 0.0, 1.0, 0.0,"," 0.0, 0.0, 0.0, -1.0",");","","mat4 transposeTmp( in mat4 inMatrix ) {"," vec4 i0 = inMatrix[0];"," vec4 i1 = inMatrix[1];"," vec4 i2 = inMatrix[2];"," vec4 i3 = inMatrix[3];",""," mat4 outMatrix = mat4("," vec4(i0.x, i1.x, i2.x, i3.x),"," vec4(i0.y, i1.y, i2.y, i3.y),"," vec4(i0.z, i1.z, i2.z, i3.z),"," vec4(i0.w, i1.w, i2.w, i3.w)"," );"," return outMatrix;","}","","//------------------------------------------------------------------------------","// Compute point size and center using the technique described in:","// 'GPU-Based Ray-Casting of Quadratic Surfaces'","// by Christian Sigg, Tim Weyrich, Mario Botsch, Markus Gross.","//","// Code based on","/*=========================================================================",""," Program: Visualization Toolkit"," Module: Quadrics_fs.glsl and Quadrics_vs.glsl",""," Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen"," All rights reserved."," See Copyright.txt or http://www.kitware.com/Copyright.htm for details.",""," This software is distributed WITHOUT ANY WARRANTY; without even"," the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR"," PURPOSE. See the above copyright notice for more information.",""," =========================================================================*/","","// .NAME Quadrics_fs.glsl and Quadrics_vs.glsl","// .SECTION Thanks","// ","//","// This file is part of the PointSprites plugin developed and contributed by","//","// Copyright (c) CSCS - Swiss National Supercomputing Centre","// EDF - Electricite de France","//","// John Biddiscombe, Ugo Varetto (CSCS)","// Stephane Ploix (EDF)","//","// ","//","// Contributions by Alexander Rose","// - ported to WebGL","// - adapted to work with quads","void ComputePointSizeAndPositionInClipCoordSphere(vec4 updatePosition){",""," vec2 xbc;"," vec2 ybc;",""," mat4 T = mat4("," radius, 0.0, 0.0, 0.0,"," 0.0, radius, 0.0, 0.0,"," 0.0, 0.0, radius, 0.0,"," updatePosition.x, updatePosition.y, updatePosition.z, 1.0"," );",""," mat4 R = transposeTmp( projectionMatrix * modelViewMatrix * T );"," float A = dot( R[ 3 ], D * R[ 3 ] );"," float B = -2.0 * dot( R[ 0 ], D * R[ 3 ] );"," float C = dot( R[ 0 ], D * R[ 0 ] );"," xbc[ 0 ] = ( -B - sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," xbc[ 1 ] = ( -B + sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," float sx = abs( xbc[ 0 ] - xbc[ 1 ] ) * 0.5;",""," A = dot( R[ 3 ], D * R[ 3 ] );"," B = -2.0 * dot( R[ 1 ], D * R[ 3 ] );"," C = dot( R[ 1 ], D * R[ 1 ] );"," ybc[ 0 ] = ( -B - sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," ybc[ 1 ] = ( -B + sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," float sy = abs( ybc[ 0 ] - ybc[ 1 ] ) * 0.5;",""," gl_Position.xy = vec2( 0.5 * ( xbc.x + xbc.y ), 0.5 * ( ybc.x + ybc.y ) );"," gl_Position.xy -= mapping * vec2( sx, sy );"," gl_Position.xy *= gl_Position.w;","","}",""," mat4 computeMat(vec4 v1, vec4 v2, vec4 v3, vec4 v4) {"," return mat4("," v1.x, v1.y, v1.z, v1.w,"," v2.x, v2.y, v2.z, v2.w,"," v3.x, v3.y, v3.z, v3.w,"," v4.x, v4.y, v4.z, v4.w"," );"," }","","void main(void){",""," #ifdef PICKING"," vPickingColor = unpackColor( primitiveId );"," #else"," #include color_vertex"," #endif",""," vRadius = radius * matrixScale( modelViewMatrix );",""," mat4 matrix = computeMat(matrix1, matrix2, matrix3, matrix4);"," vec4 updatePosition = matrix * vec4(position, 1.0);","","// vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );"," vec4 mvPosition = modelViewMatrix * vec4( updatePosition.xyz, 1.0 );"," // avoid clipping, added again in fragment shader"," mvPosition.z -= vRadius;","","// gl_Position = projectionMatrix * vec4( mvPosition.xyz, 1.0 );"," gl_Position = projectionMatrix * vec4( mvPosition.xyz, 1.0 );"," ComputePointSizeAndPositionInClipCoordSphere(updatePosition);","",""," vRadiusSq = vRadius * vRadius;"," vec4 vPoint4 = projectionMatrixInverse * gl_Position;"," vPoint = vPoint4.xyz / vPoint4.w;"," vPointViewPosition = -mvPosition.xyz / mvPosition.w;","","}"].join("\n"),$NGL_shaderTextHash["CylinderInstancing.frag"]=$NGL_shaderTextHash["CylinderImpostor.frag"],$NGL_shaderTextHash["CylinderInstancing.vert"]=["// Open-Source PyMOL is Copyright (C) Schrodinger, LLC.","//","// All Rights Reserved","//","// Permission to use, copy, modify, distribute, and distribute modified","// versions of this software and its built-in documentation for any","// purpose and without fee is hereby granted, provided that the above","// copyright notice appears in all copies and that both the copyright","// notice and this permission notice appear in supporting documentation,","// and that the name of Schrodinger, LLC not be used in advertising or","// publicity pertaining to distribution of the software without specific,","// written prior permission.","//","// SCHRODINGER, LLC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,","// INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN","// NO EVENT SHALL SCHRODINGER, LLC BE LIABLE FOR ANY SPECIAL, INDIRECT OR","// CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS","// OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE","// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE","// USE OR PERFORMANCE OF THIS SOFTWARE.","","// Contributions by Alexander Rose","// - ported to WebGL","// - dual color","// - pk color","// - shift","","attribute vec3 mapping;","attribute vec3 position1;","attribute vec3 position2;","attribute float radius;","attribute vec4 matrix1;","attribute vec4 matrix2;","attribute vec4 matrix3;","attribute vec4 matrix4;","","varying vec3 axis;","varying vec4 base_radius;","varying vec4 end_b;","varying vec3 U;","varying vec3 V;","varying vec4 w;","varying float fogDepth;","varying float fogNear;","varying float fogFar;","","#ifdef PICKING"," #include unpack_clr"," attribute float primitiveId;"," varying vec3 vPickingColor;","#else"," //attribute vec3 color;"," attribute vec3 color2;"," varying vec3 vColor1;"," varying vec3 vColor2;","#endif","","uniform mat4 modelViewMatrixInverse;","uniform float ortho;","","//include matrix_scale","float matrixScale( in mat4 m ){"," vec4 r = m[ 0 ];"," return sqrt( r[ 0 ] * r[ 0 ] + r[ 1 ] * r[ 1 ] + r[ 2 ] * r[ 2 ] );","}",""," mat4 computeMat(vec4 v1, vec4 v2, vec4 v3, vec4 v4) {"," return mat4("," v1.x, v1.y, v1.z, v1.w,"," v2.x, v2.y, v2.z, v2.w,"," v3.x, v3.y, v3.z, v3.w,"," v4.x, v4.y, v4.z, v4.w"," );"," }","","void main(){",""," #ifdef PICKING"," vPickingColor = unpackColor( primitiveId );"," #else"," vColor1 = color;"," vColor2 = color2;"," #endif",""," // vRadius = radius;"," base_radius.w = radius * matrixScale( modelViewMatrix );",""," //vec3 center = ( position2 + position1 ) / 2.0;",""," mat4 matrix = computeMat(matrix1, matrix2, matrix3, matrix4);"," vec4 updatePosition1 = matrix * vec4(position1, 1.0);"," vec4 updatePosition2 = matrix * vec4(position2, 1.0);"," vec3 center = ( updatePosition2.xyz + updatePosition1.xyz ) / 2.0;",""," //vec3 dir = normalize( position2 - position1 );"," vec3 dir = normalize( updatePosition2.xyz - updatePosition1.xyz );"," float ext = length( position2 - position1 ) / 2.0;",""," // using cameraPosition fails on some machines, not sure why"," // vec3 cam_dir = normalize( cameraPosition - mix( center, vec3( 0.0 ), ortho ) );"," vec3 cam_dir;"," if( ortho == 0.0 ){"," cam_dir = ( modelViewMatrixInverse * vec4( 0, 0, 0, 1 ) ).xyz - center;"," }else{"," cam_dir = ( modelViewMatrixInverse * vec4( 0, 0, 1, 0 ) ).xyz;"," }"," cam_dir = normalize( cam_dir );",""," vec3 ldir;",""," float b = dot( cam_dir, dir );"," end_b.w = b;"," // direction vector looks away, so flip"," if( b < 0.0 )"," ldir = -ext * dir;"," // direction vector already looks in my direction"," else"," ldir = ext * dir;",""," vec3 left = normalize( cross( cam_dir, ldir ) );"," left = radius * left;"," vec3 up = radius * normalize( cross( left, ldir ) );",""," // transform to modelview coordinates"," axis = normalize( normalMatrix * ldir );"," U = normalize( normalMatrix * up );"," V = normalize( normalMatrix * left );",""," vec4 base4 = modelViewMatrix * vec4( center - ldir, 1.0 );"," base_radius.xyz = base4.xyz / base4.w;",""," vec4 top_position = modelViewMatrix * vec4( center + ldir, 1.0 );"," vec4 end4 = top_position;"," end_b.xyz = end4.xyz / end4.w;",""," w = modelViewMatrix * vec4("," center + mapping.x*ldir + mapping.y*left + mapping.z*up, 1.0"," );",""," gl_Position = projectionMatrix * w;",""," // avoid clipping (1.0 seems to induce flickering with some drivers)"," gl_Position.z = 0.99;","","}"].join("\n"),$NGL_shaderTextHash["Instancing.frag"]=["#define STANDARD","uniform vec3 diffuse;","uniform vec3 emissive;","uniform float roughness;","uniform float metalness;","uniform float opacity;","uniform float nearClip;","uniform float clipRadius;","uniform mat4 projectionMatrix;","uniform float ortho;","varying float bCylinder;","","#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || ( !defined( PICKING ) && !defined( NOLIGHT ) )"," varying vec3 vViewPosition;","#endif","","#if defined( RADIUS_CLIP )"," varying vec3 vClipCenter;","#endif","","#if defined( PICKING )"," uniform float objectId;"," varying vec3 vPickingColor;","#elif defined( NOLIGHT )"," varying vec3 vColor;","#else"," #ifndef FLAT_SHADED"," varying vec3 vNormal;"," #endif"," #include common"," #include color_pars_fragment"," #include fog_pars_fragment"," #include bsdfs"," #include lights_pars_begin"," #include lights_physical_pars_fragment","#endif","","void main(){"," #include nearclip_fragment"," #include radiusclip_fragment",""," #if defined( PICKING )",""," gl_FragColor = vec4( vPickingColor, objectId );",""," #elif defined( NOLIGHT )",""," gl_FragColor = vec4( vColor, opacity );",""," #else",""," vec4 diffuseColor = vec4( diffuse, opacity );"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveLight = emissive;",""," #include color_fragment"," #include roughnessmap_fragment"," #include metalnessmap_fragment"," #include normal_flip"," #include normal_fragment_begin",""," //include dull_interior_fragment",""," #include lights_physical_fragment"," //include lights_template"," #include lights_fragment_begin"," #include lights_fragment_end",""," vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;",""," #include interior_fragment",""," gl_FragColor = vec4( outgoingLight, diffuseColor.a );",""," #include premultiplied_alpha_fragment"," #include tonemapping_fragment"," #include encodings_fragment"," #include fog_fragment",""," #include opaque_back_fragment",""," #endif","","}"].join("\n"),$NGL_shaderTextHash["Instancing.vert"]=["#define STANDARD","","uniform mat4 projectionMatrixInverse;","uniform float nearClip;","uniform vec3 clipCenter;","attribute vec4 matrix1;","attribute vec4 matrix2;","attribute vec4 matrix3;","attribute vec4 matrix4;","attribute float cylinder;","varying float bCylinder;","","#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || ( !defined( PICKING ) && !defined( NOLIGHT ) )"," varying vec3 vViewPosition;","#endif","","#if defined( RADIUS_CLIP )"," varying vec3 vClipCenter;","#endif","","#if defined( PICKING )"," #include unpack_color"," attribute float primitiveId;"," varying vec3 vPickingColor;","#elif defined( NOLIGHT )"," varying vec3 vColor;","#else"," #include color_pars_vertex"," #ifndef FLAT_SHADED"," varying vec3 vNormal;"," #endif","#endif","","#include common",""," mat4 computeMat(vec4 v1, vec4 v2, vec4 v3, vec4 v4) {"," return mat4("," v1.x, v1.y, v1.z, v1.w,"," v2.x, v2.y, v2.z, v2.w,"," v3.x, v3.y, v3.z, v3.w,"," v4.x, v4.y, v4.z, v4.w"," );"," }","","void main(){"," bCylinder = cylinder;",""," mat4 matrix = computeMat(matrix1, matrix2, matrix3, matrix4);"," vec4 updatePosition = matrix * vec4(position, 1.0);",""," #if defined( PICKING )"," vPickingColor = unpackColor( primitiveId );"," #elif defined( NOLIGHT )"," vColor = color;"," #else"," #include color_vertex"," //include beginnormal_vertex"," //vec3 objectNormal = vec3( normal );"," vec3 objectNormal = vec3(matrix * vec4(normal,0.0));"," #include defaultnormal_vertex"," // Normal computed with derivatives when FLAT_SHADED"," #ifndef FLAT_SHADED"," vNormal = normalize( transformedNormal );"," #endif"," #endif",""," //include begin_vertex"," vec3 transformed = updatePosition.xyz;"," //include project_vertex"," vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );"," gl_Position = projectionMatrix * mvPosition;",""," #if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || ( !defined( PICKING ) && !defined( NOLIGHT ) )"," vViewPosition = -mvPosition.xyz;"," #endif",""," #if defined( RADIUS_CLIP )"," vClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;"," #endif",""," #include nearclip_vertex","","}"].join("\n"),THREE.RenderableObject=function(){"use strict";this.id=0,this.object=null,this.z=0},THREE.RenderableFace=function(){"use strict";this.id=0,this.v1=new THREE.RenderableVertex,this.v2=new THREE.RenderableVertex,this.v3=new THREE.RenderableVertex,this.normalModel=new THREE.Vector3,this.vertexNormalsModel=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3],this.vertexNormalsLength=0,this.color=new THREE.Color,this.material=null,this.uvs=[new THREE.Vector2,new THREE.Vector2,new THREE.Vector2],this.z=0},THREE.RenderableVertex=function(){"use strict";this.position=new THREE.Vector3,this.positionWorld=new THREE.Vector3,this.positionScreen=new THREE.Vector4,this.visible=!0},THREE.RenderableVertex.prototype.copy=function(e){"use strict";this.positionWorld.copy(e.positionWorld),this.positionScreen.copy(e.positionScreen)},THREE.RenderableLine=function(){"use strict";this.id=0,this.v1=new THREE.RenderableVertex,this.v2=new THREE.RenderableVertex,this.vertexColors=[new THREE.Color,new THREE.Color],this.material=null,this.z=0},THREE.RenderableSprite=function(){"use strict";this.id=0,this.object=null,this.x=0,this.y=0,this.z=0,this.rotation=0,this.scale=new THREE.Vector2,this.material=null},THREE.Projector=function(){"use strict";var e,t,i,o,n,r,a,s,c,d,l,u=[],p=0,f=[],v=0,h=[],m=0,g=[],y=0,E=[],_=0,b={objects:[],lights:[],elements:[]},w=(new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3),T=new THREE.Vector4,x=new THREE.Box3(new THREE.Vector3(-1,-1,-1),new THREE.Vector3(1,1,1)),C=new THREE.Box3,R=new Array(3),S=(new Array(4),new THREE.Matrix4),L=new THREE.Matrix4,A=(new THREE.Matrix4,new THREE.Matrix3,new THREE.Frustum);new THREE.Vector4,new THREE.Vector4;this.projectVector=function(e,t){console.warn("THREE.Projector: .projectVector() is now vector.project()."),e.project(t)},this.unprojectVector=function(e,t){console.warn("THREE.Projector: .unprojectVector() is now vector.unproject()."),e.unproject(t)},this.pkRay=function(e,t){console.error("THREE.Projector: .pkRay() is now raycaster.setFromCamera().")};var I=new function(){var e=[],t=[],c=null,d=null,u=new THREE.Matrix3,p=function(e){var t=e.position,i=e.positionWorld,o=e.positionScreen;i.copy(t).applyMatrix4(l),o.copy(i).applyMatrix4(L);var n=1/o.w;o.x*=n,o.y*=n,o.z*=n,e.visible=o.x>=-1&&o.x<=1&&o.y>=-1&&o.y<=1&&o.z>=-1&&o.z<=1},E=function(e,t,i){return!0===e.visible||!0===t.visible||!0===i.visible||(R[0]=e.positionScreen,R[1]=t.positionScreen,R[2]=i.positionScreen,x.isIntersectionBox(C.setFromPoints(R)))},_=function(e,t,i){return(i.positionScreen.x-e.positionScreen.x)*(t.positionScreen.y-e.positionScreen.y)-(i.positionScreen.y-e.positionScreen.y)*(t.positionScreen.x-e.positionScreen.x)<0};return{setObject:function(i){d=(c=i).material,u.getNormalMatrix(c.matrixWorld),e.length=0,t.length=0},projectVertex:p,checkTriangleVisibility:E,checkBackfaceCulling:_,pushVertex:function(e,t,n){(i=function(){if(o===v){var e=new THREE.RenderableVertex;return f.push(e),v++,o++,e}return f[o++]}()).position.set(e,t,n),p(i)},pushNormal:function(t,i,o){e.push(t,i,o)},pushUv:function(e,i){t.push(e,i)},pushLine:function(e,t){var i=f[e],o=f[t];(a=function(){if(s===y){var e=new THREE.RenderableLine;return g.push(e),y++,s++,e}return g[s++]}()).id=c.id,a.v1.copy(i),a.v2.copy(o),a.z=(i.positionScreen.z+o.positionScreen.z)/2,a.material=c.material,b.elements.push(a)},pushTriangle:function(i,o,a){var s=f[i],l=f[o],p=f[a];if(!1!==E(s,l,p)&&(d.side===THREE.DoubleSide||!0===_(s,l,p))){(n=function(){if(r===m){var e=new THREE.RenderableFace;return h.push(e),m++,r++,e}return h[r++]}()).id=c.id,n.v1.copy(s),n.v2.copy(l),n.v3.copy(p),n.z=(s.positionScreen.z+l.positionScreen.z+p.positionScreen.z)/3;for(var v=0;v<3;v++){var g=3*arguments[v],y=n.vertexNormalsModel[v];y.set(e[g],e[g+1],e[g+2]),y.applyMatrix3(u).normalize();var w=2*arguments[v];n.uvs[v].set(t[w],t[w+1])}n.vertexNormalsLength=3,n.material=c.material,b.elements.push(n)}}}};function O(){if(d===_){var e=new THREE.RenderableSprite;return E.push(e),_++,d++,e}return E[d++]}function N(e,t){return e.z!==t.z?t.z-e.z:e.id!==t.id?e.id-t.id:0}this.projectScene=function(i,n,a,f){r=0,s=0,d=0,b.elements.length=0,!0===i.autoUpdate&&i.updateMatrixWorld(),void 0===n.parent&&n.updateMatrixWorld(),S.copy(n.matrixWorldInverse.copy(n.matrixWorld).invert()),L.multiplyMatrices(n.projectionMatrix,S),A.setFromMatrix(L),t=0,b.objects.length=0,b.lights.length=0,i.traverseVisible(function(i){if(i instanceof THREE.Light)b.lights.push(i);else if(i instanceof THREE.Mesh||i instanceof THREE.Line||i instanceof THREE.Sprite){if(!1===i.material.visible)return;!1!==i.frustumCulled&&!0!==A.intersectsObject(i)||((e=function(){if(t===p){var e=new THREE.RenderableObject;return u.push(e),p++,t++,e}return u[t++]}()).id=i.id,e.object=i,w.setFromMatrixPosition(i.matrixWorld),w.applyProjection(L),e.z=w.z,b.objects.push(e))}}),!0===a&&b.objects.sort(N);for(var v=0,h=b.objects.length;v0)for(v=0;v=-1&&T.z<=1&&((c=O()).id=m.id,c.x=T.x*j,c.y=T.y*j,c.z=T.z,c.object=m,c.rotation=m.rotation,c.scale.x=m.scale.x*Math.abs(c.x-(T.x+n.projectionMatrix.elements[0])/(T.w+n.projectionMatrix.elements[12])),c.scale.y=m.scale.y*Math.abs(c.y-(T.y+n.projectionMatrix.elements[5])/(T.w+n.projectionMatrix.elements[13])),c.material=m.material,b.elements.push(c))}}return!0===f&&b.elements.sort(N),b}},THREE.TrackballControls=function(e,t,i){"use strict";var o=this;this.STATE={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4},this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.screen={left:0,top:0,width:0,height:0},this.rotateSpeed=1,this.zoomSpeed=1.2,this.panSpeed=.3,this.noRotate=!1,this.noZoom=!1,this.noPan=!1,this.noRoll=!1,this.staticMoving=!1,this.dynamicDampingFactor=.2,this.minDistance=0,this.maxDistance=1/0,this.keys=[65,83,68],this.target=new THREE.Vector3;var n=new THREE.Vector3;this._state=this.STATE.NONE;var r=this.STATE.NONE,a=new THREE.Vector3;this._rotateStart=new THREE.Vector3,this._rotateEnd=new THREE.Vector3,this._zoomStart=new THREE.Vector2,this._zoomEnd=new THREE.Vector2;var s=0,c=0;this._panStart=new THREE.Vector2,this._panEnd=new THREE.Vector2,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.up0=this.object.up.clone();var d={type:"change"},l={type:"start"},u={type:"end"};this.handleResize=function(){if(this.domElement===document)this.screen.left=0,this.screen.top=0,this.screen.width=window.innerWidth,this.screen.height=window.innerHeight;else{var e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}},this.handleEvent=function(e){"function"==typeof this[e.type]&&this[e.type](e)};var p,f,v,h,m,g,y,E,_,b=(p=new THREE.Vector2,function(e,t){return p.set((e-o.screen.left)/o.screen.width,(t-o.screen.top)/o.screen.height),p}),w=(f=new THREE.Vector3,v=new THREE.Vector3,h=new THREE.Vector3,function(e,t){h.set((e-.5*o.screen.width-o.screen.left)/(.5*o.screen.width),(.5*o.screen.height+o.screen.top-t)/(.5*o.screen.height),0);var i=h.length();return o.noRoll?i1?h.normalize():h.z=Math.sqrt(1-i*i),a.copy(o.object.position).sub(o.target),f.copy(o.object.up).setLength(h.y),f.add(v.copy(o.object.up).cross(a).setLength(h.x)),f.add(a.setLength(h.z)),f});function T(e){!1===o.enabled||Object.keys(window).length<2||(window.removeEventListener("keydown",T),r=o._state,o._state===o.STATE.NONE&&(e.keyCode!==o.keys[o.STATE.ROTATE]||o.noRotate?e.keyCode!==o.keys[o.STATE.ZOOM]||o.noZoom?e.keyCode!==o.keys[o.STATE.PAN]||o.noPan||(o._state=o.STATE.PAN):o._state=o.STATE.ZOOM:o._state=o.STATE.ROTATE))}function x(e){!1===o.enabled||Object.keys(window).length<2||(e.stopPropagation(),o._state!==o.STATE.ROTATE||o.noRotate?o._state!==o.STATE.ZOOM||o.noZoom?o._state!==o.STATE.PAN||o.noPan||o._panEnd.copy(b(e.pageX,e.pageY)):o._zoomEnd.copy(b(e.pageX,e.pageY)):o._rotateEnd.copy(w(e.pageX,e.pageY)))}function C(e){!1===o.enabled||Object.keys(window).length<2||(e.stopPropagation(),o._state=o.STATE.NONE,document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",C),o.dispatchEvent(u))}function R(e){if(!(!1===o.enabled||Object.keys(window).length<2)){e.stopPropagation();var t=0;e.wheelDelta?t=e.wheelDelta/40:e.detail&&(t=-e.detail/3),o._zoomStart.y=.005*t,o.dispatchEvent(l),o.dispatchEvent(u)}}this.rotateCamera=(m=new THREE.Vector3,g=new THREE.Quaternion,function(e,t){var n;void 0===e&&(n=Math.acos(o._rotateStart.dot(o._rotateEnd)/o._rotateStart.length()/o._rotateEnd.length())),(n||void 0!==e)&&(void 0===e?(m.crossVectors(o._rotateStart,o._rotateEnd).normalize(),n*=o.rotateSpeed,g.setFromAxisAngle(m,-n)):g.copy(e),void 0===i||void 0===i.quaternion||void 0!==t&&!0!==t||i.quaternion.multiplyQuaternions(g,i.quaternion),a.applyQuaternion(g),o.object.up.applyQuaternion(g),o._rotateEnd.applyQuaternion(g),o.staticMoving?o._rotateStart.copy(o._rotateEnd):(g.setFromAxisAngle(m,n*(o.dynamicDampingFactor-1)),o._rotateStart.applyQuaternion(g)))}),this.zoomCamera=function(e,t){var n;o._state===o.STATE.TOUCH_ZOOM_PAN?(void 0!==e?n=e:(n=s/c,s=c),a.multiplyScalar(n),void 0===i||void 0===i._zoomFactor||void 0!==t&&!0!==t||(i._zoomFactor*=n,i.fogCls.setFog())):(n=void 0!==e?e:1+(o._zoomEnd.y-o._zoomStart.y)*o.zoomSpeed,void 0===i||void 0===i._zoomFactor||void 0!==t&&!0!==t||(i._zoomFactor*=n,i.fogCls.setFog()),1!==n&&(a.multiplyScalar(n),o.staticMoving?o._zoomStart.copy(o._zoomEnd):o._zoomStart.y+=(o._zoomEnd.y-o._zoomStart.y)*this.dynamicDampingFactor))},this.panCamera=(y=new THREE.Vector2,E=new THREE.Vector3,_=new THREE.Vector3,function(e,t){void 0!==e?(y=e,void 0===i||void 0===i.mouseChange||void 0!==t&&!0!==t||i.mouseChange.add(e)):(y.copy(o._panEnd).sub(o._panStart),void 0===i||void 0===i.mouseChange||void 0!==t&&!0!==t||i.mouseChange.add(o._panEnd).sub(o._panStart)),y.lengthSq()&&(y.multiplyScalar(a.length()*o.panSpeed),_.copy(a).cross(o.object.up).setLength(y.x),_.add(E.copy(o.object.up).setLength(y.y)),o.object.position.add(_),o.target.add(_),o.staticMoving?o._panStart.copy(o._panEnd):o._panStart.add(y.subVectors(o._panEnd,o._panStart).multiplyScalar(o.dynamicDampingFactor)))}),this.checkDistances=function(){o.noZoom&&o.noPan||(a.lengthSq()>o.maxDistance*o.maxDistance&&o.object.position.addVectors(o.target,a.setLength(o.maxDistance)),a.lengthSq()1e-6&&(o.dispatchEvent(d),n.copy(o.object.position))},this.reset=function(){o._state=o.STATE.NONE,r=o.STATE.NONE,o.target.copy(o.target0),o.object.position.copy(o.position0),o.object.up.copy(o.up0),a.subVectors(o.object.position,o.target),o.object.lookAt(o.target),o.dispatchEvent(d),n.copy(o.object.position)},Object.keys(window).length>=2&&(this.domElement.addEventListener("contextmn",function(e){},!1),this.domElement.addEventListener("mousedown",function(e){!1===o.enabled||Object.keys(window).length<2||(e.stopPropagation(),o._state===o.STATE.NONE&&(o._state=e.button),o._state!==o.STATE.ROTATE||o.noRotate?o._state!==o.STATE.ZOOM||o.noZoom?o._state!==o.STATE.PAN||o.noPan||(o._panStart.copy(b(e.pageX,e.pageY)),o._panEnd.copy(o._panStart)):(o._zoomStart.copy(b(e.pageX,e.pageY)),o._zoomEnd.copy(o._zoomStart)):(o._rotateStart.copy(w(e.pageX,e.pageY)),o._rotateEnd.copy(o._rotateStart)),document.addEventListener("mousemove",x,!1),document.addEventListener("mouseup",C,!1),o.dispatchEvent(l))},!1),this.domElement.addEventListener("mousewheel",R,!1),this.domElement.addEventListener("DOMMouseScroll",R,!1),this.domElement.addEventListener("touchstart",function(e){if(!(!1===o.enabled||Object.keys(window).length<2)){switch(e.touches.length){case 1:o._state=o.STATE.TOUCH_ROTATE,o._rotateStart.copy(w(e.touches[0].pageX,e.touches[0].pageY)),o._rotateEnd.copy(o._rotateStart);break;case 2:o._state=o.STATE.TOUCH_ZOOM_PAN;var t=e.touches[0].pageX-e.touches[1].pageX,i=e.touches[0].pageY-e.touches[1].pageY;c=s=Math.sqrt(t*t+i*i);var n=(e.touches[0].pageX+e.touches[1].pageX)/2,r=(e.touches[0].pageY+e.touches[1].pageY)/2;o._panStart.copy(b(n,r)),o._panEnd.copy(o._panStart);break;default:o._state=o.STATE.NONE}o.dispatchEvent(l)}},!1),this.domElement.addEventListener("touchend",function(e){if(!(!1===o.enabled||Object.keys(window).length<2)){switch(e.touches.length){case 1:o._rotateEnd.copy(w(e.touches[0].pageX,e.touches[0].pageY)),o._rotateStart.copy(o._rotateEnd);break;case 2:s=c=0;var t=(e.touches[0].pageX+e.touches[1].pageX)/2,i=(e.touches[0].pageY+e.touches[1].pageY)/2;o._panEnd.copy(b(t,i)),o._panStart.copy(o._panEnd)}o._state=o.STATE.NONE,o.dispatchEvent(u)}},!1),this.domElement.addEventListener("touchmove",function(e){if(!(!1===o.enabled||Object.keys(window).length<2))switch(e.stopPropagation(),e.touches.length){case 1:o._rotateEnd.copy(w(e.touches[0].pageX,e.touches[0].pageY));break;case 2:var t=e.touches[0].pageX-e.touches[1].pageX,i=e.touches[0].pageY-e.touches[1].pageY;c=Math.sqrt(t*t+i*i);var n=(e.touches[0].pageX+e.touches[1].pageX)/2,r=(e.touches[0].pageY+e.touches[1].pageY)/2;o._panEnd.copy(b(n,r));break;default:o._state=o.STATE.NONE}},!1),Object.keys(window).length>=2&&window.addEventListener("keydown",T,!1),Object.keys(window).length>=2&&window.addEventListener("keyup",function(e){!1===o.enabled||Object.keys(window).length<2||(o._state=r,window.addEventListener("keydown",T,!1))},!1)),this.handleResize(),this.update()},THREE.TrackballControls.prototype=Object.create(THREE.EventDispatcher.prototype),THREE.TrackballControls.prototype.constructor=THREE.TrackballControls,THREE.OrthographicTrackballControls=function(e,t,i){this.icn3d;var o=this,n={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4};this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.screen={left:0,top:0,width:0,height:0},this.rotateSpeed=.5,this.zoomSpeed=1.2;this.zoomSpeed*=.01,this.panSpeed=.03,this.noRotate=!1,this.noZoom=!1,this.noPan=!1,this.noRoll=!1,this.staticMoving=!1,this.dynamicDampingFactor=.2,this.keys=[65,83,68],this.target=new THREE.Vector3;var r=new THREE.Vector3;this._state=n.NONE;var a=n.NONE,s=new THREE.Vector3;this._rotateStart=new THREE.Vector3,this._rotateEnd=new THREE.Vector3,this._zoomStart=new THREE.Vector2,this._zoomEnd=new THREE.Vector2;var c=1,d=0,l=0;this._panStart=new THREE.Vector2,this._panEnd=new THREE.Vector2,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.up0=this.object.up.clone(),this.left0=this.object.left,this.right0=this.object.right,this.top0=this.object.top,this.bottom0=this.object.bottom,this.center0=new THREE.Vector2((this.left0+this.right0)/2,(this.top0+this.bottom0)/2);var u={type:"change"},p={type:"start"},f={type:"end"};this.handleResize=function(){if(this.domElement===document)this.screen.left=0,this.screen.top=0,this.screen.width=window.innerWidth,this.screen.height=window.innerHeight;else{var e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}this.left0=this.object.left,this.right0=this.object.right,this.top0=this.object.top,this.bottom0=this.object.bottom,this.center0.set((this.left0+this.right0)/2,(this.top0+this.bottom0)/2)},this.handleEvent=function(e){"function"==typeof this[e.type]&&this[e.type](e)};var v,h,m,g,y,E,_,b,w,T=(v=new THREE.Vector2,function(e,t){return v.set((e-o.screen.left)/o.screen.width,(t-o.screen.top)/o.screen.height),v}),x=(h=new THREE.Vector3,m=new THREE.Vector3,g=new THREE.Vector3,function(e,t){g.set((e-.5*o.screen.width-o.screen.left)/(.5*o.screen.width),(.5*o.screen.height+o.screen.top-t)/(.5*o.screen.height),0);var i=g.length();return o.noRoll?i1?g.normalize():g.z=Math.sqrt(1-i*i),s.copy(o.object.position).sub(o.target),h.copy(o.object.up).setLength(g.y),h.add(m.copy(o.object.up).cross(s).setLength(g.x)),h.add(s.setLength(g.z)),h});function C(e){!1===o.enabled||Object.keys(window).length<2||(window.removeEventListener("keydown",C),a=o._state,o._state===n.NONE&&(e.keyCode!==o.keys[n.ROTATE]||o.noRotate?e.keyCode!==o.keys[n.ZOOM]||o.noZoom?e.keyCode!==o.keys[n.PAN]||o.noPan||(o._state=n.PAN):o._state=n.ZOOM:o._state=n.ROTATE))}function R(e){!1===o.enabled||Object.keys(window).length<2||(e.stopPropagation(),o._state!==n.ROTATE||o.noRotate?o._state!==n.ZOOM||o.noZoom?o._state!==n.PAN||o.noPan||o._panEnd.copy(T(e.pageX,e.pageY)):o._zoomEnd.copy(T(e.pageX,e.pageY)):o._rotateEnd.copy(x(e.pageX,e.pageY)))}function S(e){!1===o.enabled||Object.keys(window).length<2||(e.stopPropagation(),o._state=n.NONE,document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",S),o.dispatchEvent(f))}function L(e){if(!(!1===o.enabled||Object.keys(window).length<2)){e.stopPropagation();var t=0;e.wheelDelta?t=e.wheelDelta/40:e.detail&&(t=-e.detail/3),o._zoomStart.y=.01*t,o.dispatchEvent(p),o.dispatchEvent(f)}}this.rotateCamera=(y=new THREE.Vector3,E=new THREE.Quaternion,function(e,t){var n;void 0===e&&(n=Math.acos(o._rotateStart.dot(o._rotateEnd)/o._rotateStart.length()/o._rotateEnd.length())),(n||void 0!==e)&&(void 0===e?(y.crossVectors(o._rotateStart,o._rotateEnd).normalize(),n*=o.rotateSpeed,E.setFromAxisAngle(y,-n)):E.copy(e),void 0===i||void 0===i.quaternion||void 0!==t&&!0!==t||i.quaternion.multiplyQuaternions(E,i.quaternion),s.applyQuaternion(E),o.object.up.applyQuaternion(E),o._rotateEnd.applyQuaternion(E),o.staticMoving?o._rotateStart.copy(o._rotateEnd):(E.setFromAxisAngle(y,n*(o.dynamicDampingFactor-1)),o._rotateStart.applyQuaternion(E)))}),this.zoomCamera=function(e,t){var r;o._state===n.TOUCH_ZOOM_PAN?void 0!==e?r=e:(r=d/l,d=l):r=void 0!==e?e:1+(o._zoomEnd.y-o._zoomStart.y)*o.zoomSpeed/.01,void 0===i||void 0===i._zoomFactor||void 0!==t&&!0!==t||(i._zoomFactor*=r),1!==r&&(c=r,o.object.left=c*o.left0+(1-c)*o.center0.x,o.object.right=c*o.right0+(1-c)*o.center0.x,o.object.top=c*o.top0+(1-c)*o.center0.y,o.object.bottom=c*o.bottom0+(1-c)*o.center0.y,o.staticMoving?o._zoomStart.copy(o._zoomEnd):o._zoomStart.y+=(o._zoomEnd.y-o._zoomStart.y)*this.dynamicDampingFactor)},this.panCamera=(_=new THREE.Vector2,b=new THREE.Vector3,w=new THREE.Vector3,function(e,t){void 0!==e?(_=e,void 0===i||void 0===i.mouseChange||void 0!==t&&!0!==t||i.mouseChange.add(e)):(_.copy(o._panEnd).sub(o._panStart),void 0===i||void 0===i.mouseChange||void 0!==t&&!0!==t||i.mouseChange.add(o._panEnd).sub(o._panStart)),_.lengthSq()&&(_.multiplyScalar(s.length()*o.panSpeed),w.copy(s).cross(o.object.up).setLength(_.x),w.add(b.copy(o.object.up).setLength(_.y)),o.object.position.add(w),o.target.add(w),o.staticMoving?o._panStart.copy(o._panEnd):o._panStart.add(_.subVectors(o._panEnd,o._panStart).multiplyScalar(o.dynamicDampingFactor)))}),this.update=function(e){s.subVectors(o.object.position,o.target),o.noRotate||(void 0!==e&&void 0!==e.quaternion?o.rotateCamera(e.quaternion,e.update):o.rotateCamera()),o.noZoom||(void 0!==e&&void 0!==e._zoomFactor?o.zoomCamera(e._zoomFactor,e.update):o.zoomCamera(),o.object.updateProjectionMatrix()),o.noPan||(void 0!==e&&void 0!==e.mouseChange?o.panCamera(e.mouseChange,e.update):o.panCamera()),o.object.position.addVectors(o.target,s),o.object.lookAt(o.target),r.distanceToSquared(o.object.position)>1e-6&&(o.dispatchEvent(u),r.copy(o.object.position))},this.reset=function(){o._state=n.NONE,a=n.NONE,o.target.copy(o.target0),o.object.position.copy(o.position0),o.object.up.copy(o.up0),s.subVectors(o.object.position,o.target),o.object.left=o.left0,o.object.right=o.right0,o.object.top=o.top0,o.object.bottom=o.bottom0,o.object.lookAt(o.target),o.dispatchEvent(u),r.copy(o.object.position)},Object.keys(window).length>=2&&(this.domElement.addEventListener("contextmn",function(e){},!1),this.domElement.addEventListener("mousedown",function(e){!1===o.enabled||Object.keys(window).length<2||(e.stopPropagation(),o._state===n.NONE&&(o._state=e.button),o._state!==n.ROTATE||o.noRotate?o._state!==n.ZOOM||o.noZoom?o._state!==n.PAN||o.noPan||(o._panStart.copy(T(e.pageX,e.pageY)),o._panEnd.copy(o._panStart)):(o._zoomStart.copy(T(e.pageX,e.pageY)),o._zoomEnd.copy(o._zoomStart)):(o._rotateStart.copy(x(e.pageX,e.pageY)),o._rotateEnd.copy(o._rotateStart)),document.addEventListener("mousemove",R,!1),document.addEventListener("mouseup",S,!1),o.dispatchEvent(p))},!1),this.domElement.addEventListener("mousewheel",L,!1),this.domElement.addEventListener("DOMMouseScroll",L,!1),this.domElement.addEventListener("touchstart",function(e){if(!(!1===o.enabled||Object.keys(window).length<2)){switch(e.touches.length){case 1:o._state=n.TOUCH_ROTATE,o._rotateStart.copy(x(e.touches[0].pageX,e.touches[0].pageY)),o._rotateEnd.copy(o._rotateStart);break;case 2:o._state=n.TOUCH_ZOOM_PAN;var t=e.touches[0].pageX-e.touches[1].pageX,i=e.touches[0].pageY-e.touches[1].pageY;l=d=Math.sqrt(t*t+i*i);var r=(e.touches[0].pageX+e.touches[1].pageX)/2,a=(e.touches[0].pageY+e.touches[1].pageY)/2;o._panStart.copy(T(r,a)),o._panEnd.copy(o._panStart);break;default:o._state=n.NONE}o.dispatchEvent(p)}},!1),this.domElement.addEventListener("touchend",function(e){if(!(!1===o.enabled||Object.keys(window).length<2)){switch(e.touches.length){case 1:o._rotateEnd.copy(x(e.touches[0].pageX,e.touches[0].pageY)),o._rotateStart.copy(o._rotateEnd);break;case 2:d=l=0;var t=(e.touches[0].pageX+e.touches[1].pageX)/2,i=(e.touches[0].pageY+e.touches[1].pageY)/2;o._panEnd.copy(T(t,i)),o._panStart.copy(o._panEnd)}o._state=n.NONE,o.dispatchEvent(f)}},!1),this.domElement.addEventListener("touchmove",function(e){if(!(!1===o.enabled||Object.keys(window).length<2))switch(e.stopPropagation(),e.touches.length){case 1:o._rotateEnd.copy(x(e.touches[0].pageX,e.touches[0].pageY));break;case 2:var t=e.touches[0].pageX-e.touches[1].pageX,i=e.touches[0].pageY-e.touches[1].pageY;l=Math.sqrt(t*t+i*i);var r=(e.touches[0].pageX+e.touches[1].pageX)/2,a=(e.touches[0].pageY+e.touches[1].pageY)/2;o._panEnd.copy(T(r,a));break;default:o._state=n.NONE}},!1),window.addEventListener("keydown",C,!1),window.addEventListener("keyup",function(e){!1===o.enabled||Object.keys(window).length<2||(o._state=a,window.addEventListener("keydown",C,!1))},!1)),this.handleResize(),this.update()},THREE.OrthographicTrackballControls.prototype=Object.create(THREE.EventDispatcher.prototype),THREE.OrthographicTrackballControls.prototype.constructor=THREE.OrthographicTrackballControls;var MMTF={};function initIcn3dpyMMTF(e){function t(e,t,i){for(var o=(e.byteLength,0),n=i.length;n>o;o++){var r=i.charCodeAt(o);if(128>r)e.setUint8(t++,r>>>0&127|0);else if(2048>r)e.setUint8(t++,r>>>6&31|192),e.setUint8(t++,r>>>0&63|128);else if(65536>r)e.setUint8(t++,r>>>12&15|224),e.setUint8(t++,r>>>6&63|128),e.setUint8(t++,r>>>0&63|128);else{if(!(1114112>r))throw new Error("bad codepoint "+r);e.setUint8(t++,r>>>18&7|240),e.setUint8(t++,r>>>12&63|128),e.setUint8(t++,r>>>6&63|128),e.setUint8(t++,r>>>0&63|128)}}}function i(e){for(var t=0,i=0,o=e.length;o>i;i++){var n=e.charCodeAt(i);if(128>n)t+=1;else if(2048>n)t+=2;else if(65536>n)t+=3;else{if(!(1114112>n))throw new Error("bad codepoint "+n);t+=4}}return t}function o(e){var o=new ArrayBuffer(function e(t){var o=typeof t;if("string"===o){if(32>(n=i(t)))return 1+n;if(256>n)return 2+n;if(65536>n)return 3+n;if(4294967296>n)return 5+n}if(t instanceof Uint8Array){if(256>(n=t.byteLength))return 2+n;if(65536>n)return 3+n;if(4294967296>n)return 5+n}if("number"===o){if(Math.floor(t)!==t)return 9;if(t>=0){if(128>t)return 1;if(256>t)return 2;if(65536>t)return 3;if(4294967296>t)return 5;throw new Error("Number too big 0x"+t.toString(16))}if(t>=-32)return 1;if(t>=-128)return 2;if(t>=-32768)return 3;if(t>=-2147483648)return 5;throw new Error("Number too small -0x"+t.toString(16).substr(1))}if("boolean"===o||null===t)return 1;if("object"===o){var n,r=0;if(Array.isArray(t)){n=t.length;for(var a=0;n>a;a++)r+=e(t[a])}else{var s=Object.keys(t);for(n=s.length,a=0;n>a;a++){var c=s[a];r+=e(c)+e(t[c])}}if(16>n)return 1+r;if(65536>n)return 3+r;if(4294967296>n)return 5+r;throw new Error("Array or object too long 0x"+n.toString(16))}throw new Error("Unknown type "+o)}(e));return function e(o,n,r){var a=typeof o;if("string"===a){if(32>(s=i(o)))return n.setUint8(r,160|s),t(n,r+1,o),1+s;if(256>s)return n.setUint8(r,217),n.setUint8(r+1,s),t(n,r+2,o),2+s;if(65536>s)return n.setUint8(r,218),n.setUint16(r+1,s),t(n,r+3,o),3+s;if(4294967296>s)return n.setUint8(r,219),n.setUint32(r+1,s),t(n,r+5,o),5+s}if(o instanceof Uint8Array){var s=o.byteLength,c=new Uint8Array(n.buffer);if(256>s)return n.setUint8(r,196),n.setUint8(r+1,s),c.set(o,r+2),2+s;if(65536>s)return n.setUint8(r,197),n.setUint16(r+1,s),c.set(o,r+3),3+s;if(4294967296>s)return n.setUint8(r,198),n.setUint32(r+1,s),c.set(o,r+5),5+s}if("number"===a){if(!isFinite(o))throw new Error("Number not finite: "+o);if(Math.floor(o)!==o)return n.setUint8(r,203),n.setFloat64(r+1,o),9;if(o>=0){if(128>o)return n.setUint8(r,o),1;if(256>o)return n.setUint8(r,204),n.setUint8(r+1,o),2;if(65536>o)return n.setUint8(r,205),n.setUint16(r+1,o),3;if(4294967296>o)return n.setUint8(r,206),n.setUint32(r+1,o),5;throw new Error("Number too big 0x"+o.toString(16))}if(o>=-32)return n.setInt8(r,o),1;if(o>=-128)return n.setUint8(r,208),n.setInt8(r+1,o),2;if(o>=-32768)return n.setUint8(r,209),n.setInt16(r+1,o),3;if(o>=-2147483648)return n.setUint8(r,210),n.setInt32(r+1,o),5;throw new Error("Number too small -0x"+(-o).toString(16).substr(1))}if(null===o)return n.setUint8(r,192),1;if("boolean"===a)return n.setUint8(r,o?195:194),1;if("object"===a){var d=0,l=Array.isArray(o);if(l)s=o.length;else{var u=Object.keys(o);s=u.length}if(16>s?(n.setUint8(r,s|(l?144:128)),d=1):65536>s?(n.setUint8(r,l?220:222),n.setUint16(r+1,s),d=3):4294967296>s&&(n.setUint8(r,l?221:223),n.setUint32(r+1,s),d=5),l)for(var p=0;s>p;p++)d+=e(o[p],n,r+d);else for(p=0;s>p;p++){var f=u[p];d+=e(f,n,r+d),d+=e(o[f],n,r+d)}return d}throw new Error("Unknown type "+a)}(e,new DataView(o),0),new Uint8Array(o)}function n(e,t,i){return t?new e(t.buffer,t.byteOffset,t.byteLength/(i||1)):void 0}function r(e){return n(DataView,e)}function a(e){return n(Uint8Array,e)}function s(e){return n(Int8Array,e)}function c(e){return n(Int32Array,e,4)}function d(e,t){var i=e.length/2;t||(t=new Int16Array(i));for(var o=0,n=0;i>o;++o,n+=2)t[o]=e[n]<<8^e[n+1]<<0;return t}function l(e,t){var i=e.length/4;t||(t=new Int32Array(i));for(var o=0,n=0;i>o;++o,n+=4)t[o]=e[n]<<24^e[n+1]<<16^e[n+2]<<8^e[n+3]<<0;return t}function u(e,t){var i=e.length;t||(t=new Uint8Array(4*i));for(var o=r(t),n=0;i>n;++n)o.setInt32(4*n,e[n]);return a(t)}function p(e,t,i){var o=e.length,n=1/t;i||(i=new Float32Array(o));for(var r=0;o>r;++r)i[r]=e[r]*n;return i}function f(e,t,i){var o=e.length;i||(i=new Int32Array(o));for(var n=0;o>n;++n)i[n]=Math.round(e[n]*t);return i}function v(e,t){var i,o;if(!t){var n=0;for(i=0,o=e.length;o>i;i+=2)n+=e[i+1];t=new e.constructor(n)}var r=0;for(i=0,o=e.length;o>i;i+=2)for(var a=e[i],s=e[i+1],c=0;s>c;++c)t[r]=a,++r;return t}function h(e){if(0===e.length)return new Int32Array;var t,i,o=2;for(t=1,i=e.length;i>t;++t)e[t-1]!==e[t]&&(o+=2);var n=new Int32Array(o),r=0,a=1;for(t=1,i=e.length;i>t;++t)e[t-1]!==e[t]?(n[r]=e[t-1],n[r+1]=a,a=1,r+=2):++a;return n[r]=e[e.length-1],n[r+1]=a,n}function m(e,t){var i=e.length;t||(t=new e.constructor(i)),i&&(t[0]=e[0]);for(var o=1;i>o;++o)t[o]=e[o]+t[o-1];return t}function g(e,t){var i=e.length;t||(t=new e.constructor(i)),t[0]=e[0];for(var o=1;i>o;++o)t[o]=e[o]-e[o-1];return t}function y(e,t){var i,o,n=e instanceof Int8Array?127:32767,r=-n-1,a=e.length;if(!t){var s=0;for(i=0;a>i;++i)e[i]r&&++s;t=new Int32Array(s)}for(i=0,o=0;a>i;){for(var c=0;e[i]===n||e[i]===r;)c+=e[i],++i;c+=e[i],++i,t[o]=c,++o}return t}function E(e,t,i){return p(y(e,c(i)),t,i)}function _(e,t,i){var o,r,a,s=y(e,c(i));return o=s,r=t,a=n(Float32Array,s,4),p(m(o,c(a)),r,a)}function b(e,t,i){return function(e,t){var i,o=t?127:32767,n=-o-1,r=e.length,a=0;for(i=0;r>i;++i)0===(d=e[i])?++a:d>0?(a+=Math.ceil(d/o),d%o==0&&(a+=1)):(a+=Math.ceil(d/n),d%n==0&&(a+=1));var s=t?new Int8Array(a):new Int16Array(a),c=0;for(i=0;r>i;++i){var d;if((d=e[i])>=0)for(;d>=o;)s[c]=o,++c,d-=o;else for(;n>=d;)s[c]=n,++c,d-=n;s[c]=d,++c}return s}(g(f(e,t),o),i);var o}function w(e,t,i,o){var n=new ArrayBuffer(12+o.byteLength),r=new Uint8Array(n),a=new DataView(n);return a.setInt32(0,e),a.setInt32(4,t),i&&r.set(i,8),r.set(o,12),r}function T(e){return w(2,e.length,void 0,a(e))}function x(e){return w(4,e.length,void 0,u(e))}function C(e,t){return w(5,e.length/t,u([t]),a(e))}function R(e){return w(6,e.length,void 0,u(h(e)))}function S(e){return w(8,e.length,void 0,u(h(g(e))))}function L(e,t){return w(9,e.length,u([t]),u(h(f(e,t))))}function A(e,t){return w(10,e.length,u([t]),function(e,t){var i=e.length;t||(t=new Uint8Array(2*i));for(var o=r(t),n=0;i>n;++n)o.setInt16(2*n,e[n]);return a(t)}(b(e,t)))}function I(e){var t={};return D.forEach(function(i){void 0!==e[i]&&(t[i]=e[i])}),e.bondAtomList&&(t.bondAtomList=x(e.bondAtomList)),e.bondOrderList&&(t.bondOrderList=T(e.bondOrderList)),t.xCoordList=A(e.xCoordList,1e3),t.yCoordList=A(e.yCoordList,1e3),t.zCoordList=A(e.zCoordList,1e3),e.bFactorList&&(t.bFactorList=A(e.bFactorList,100)),e.atomIdList&&(t.atomIdList=S(e.atomIdList)),e.altLocList&&(t.altLocList=R(e.altLocList)),e.occupancyList&&(t.occupancyList=L(e.occupancyList,100)),t.groupIdList=S(e.groupIdList),t.groupTypeList=x(e.groupTypeList),e.secStructList&&(t.secStructList=T(e.secStructList)),e.insCodeList&&(t.insCodeList=R(e.insCodeList)),e.sequenceIndexList&&(t.sequenceIndexList=S(e.sequenceIndexList)),t.chainIdList=C(e.chainIdList,4),e.chainNameList&&(t.chainNameList=C(e.chainNameList,4)),t}function O(e){function t(e){for(var t={},i=0;e>i;i++){t[r()]=r()}return t}function i(t){var i=e.subarray(a,a+t);return a+=t,i}function o(t){var i=e.subarray(a,a+t);a+=t;if(t>65535){for(var o=[],n=0;ni;i++)t[i]=r();return t}function r(){var r,c,d=e[a];if(0==(128&d))return a++,d;if(128==(240&d))return a++,t(c=15&d);if(144==(240&d))return a++,n(c=15&d);if(160==(224&d))return a++,o(c=31&d);if(224==(224&d))return r=s.getInt8(a),a++,r;switch(d){case 192:return a++,null;case 194:return a++,!1;case 195:return a++,!0;case 196:return c=s.getUint8(a+1),a+=2,i(c);case 197:return c=s.getUint16(a+1),a+=3,i(c);case 198:return c=s.getUint32(a+1),a+=5,i(c);case 202:return r=s.getFloat32(a+1),a+=5,r;case 203:return r=s.getFloat64(a+1),a+=9,r;case 204:return r=e[a+1],a+=2,r;case 205:return r=s.getUint16(a+1),a+=3,r;case 206:return r=s.getUint32(a+1),a+=5,r;case 208:return r=s.getInt8(a+1),a+=2,r;case 209:return r=s.getInt16(a+1),a+=3,r;case 210:return r=s.getInt32(a+1),a+=5,r;case 217:return c=s.getUint8(a+1),a+=2,o(c);case 218:return c=s.getUint16(a+1),a+=3,o(c);case 219:return c=s.getUint32(a+1),a+=5,o(c);case 220:return c=s.getUint16(a+1),a+=3,n(c);case 221:return c=s.getUint32(a+1),a+=5,n(c);case 222:return c=s.getUint16(a+1),a+=3,t(c);case 223:return c=s.getUint32(a+1),a+=5,t(c)}throw new Error("Unknown type 0x"+d.toString(16))}var a=0,s=new DataView(e.buffer);return r()}function N(e,t,i,o){switch(e){case 1:return function(e,t){var i=e.length;t||(t=new Float32Array(i/4));for(var o=r(t),n=r(e),a=0,s=0,c=i/4;c>a;++a,s+=4)o.setFloat32(s,n.getFloat32(s),!0);return t}(t);case 2:return s(t);case 3:return d(t);case 4:return l(t);case 5:return a(t);case 6:return v(l(t),new Uint8Array(i));case 7:return v(l(t));case 8:return m(v(l(t)),h);case 9:return n=l(t),u=l(o)[0],p(v(n,c(f)),u,f);case 10:return _(d(t),l(o)[0]);case 11:return p(d(t),l(o)[0]);case 12:return E(d(t),l(o)[0]);case 13:return E(s(t),l(o)[0]);case 14:return y(d(t));case 15:return y(s(t))}var n,u,f,h}function P(e,t){var i=(t=t||{}).ignoreFields,o={};return j.forEach(function(t){var n,a,s,c,d,l=!!i&&-1!==i.indexOf(t),u=e[t];l||void 0===u||(u instanceof Uint8Array?o[t]=N.apply(null,(a=r(n=u),s=a.getInt32(0),c=a.getInt32(4),d=n.subarray(8,12),[s,n=n.subarray(12),c,d])):o[t]=u)}),o}function M(e){return String.fromCharCode.apply(null,e).replace(/\0/g,"")}function H(e,t){return e instanceof ArrayBuffer&&(e=new Uint8Array(e)),P(e instanceof Uint8Array?O(e):e,t)}function z(e,t,i,o){var n=new XMLHttpRequest;n.addEventListener("load",function(){try{var e=H(n.response);i(e)}catch(e){o(e)}},!0),n.addEventListener("error",o,!0),n.responseType="arraybuffer",n.open("GET",t+e.toUpperCase()),n.send()}var D=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"],j=D.concat(["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"]),F="//mmtf.rcsb.org/v1.0/",V=F+"full/",U=F+"reduced/";return e.encode=function(e){return o(I(e))},e.decode=H,e.traverse=function(e,t,i){var o,n,r,a,s,c,d=(i=i||{}).firstModelOnly,l=t.onModel,u=t.onChain,p=t.onGroup,f=t.onAtom,v=t.onBond,h=0,m=0,g=0,y=0,E=0,_=-1,b=e.chainNameList,w=e.secStructList,T=e.insCodeList,x=e.sequenceIndexList,C=e.atomIdList,R=e.bFactorList,S=e.altLocList,L=e.occupancyList,A=e.bondAtomList,I=e.bondOrderList;for(o=0,n=e.chainsPerModel.length;n>o&&!(d&&h>0);++o){var O=e.chainsPerModel[h];for(l&&l({chainCount:O,modelIndex:h}),r=0;O>r;++r){var N=e.groupsPerChain[m];if(u){var P=M(e.chainIdList.subarray(4*m,4*m+4)),H=null;b&&(H=M(b.subarray(4*m,4*m+4))),u({groupCount:N,chainIndex:m,modelIndex:h,chainId:P,chainName:H})}for(a=0;N>a;++a){var z=e.groupList[e.groupTypeList[g]],D=z.atomNameList.length;if(p){var j=null;w&&(j=w[g]);var F=null;e.insCodeList&&(F=String.fromCharCode(T[g]));var V=null;x&&(V=x[g]),p({atomCount:D,groupIndex:g,chainIndex:m,modelIndex:h,groupId:e.groupIdList[g],groupType:e.groupTypeList[g],groupName:z.groupName,singleLetterCode:z.singleLetterCode,chemCompType:z.chemCompType,secStruct:j,insCode:F,sequenceIndex:V})}for(s=0;D>s;++s){if(f){var U=null;C&&(U=C[y]);var k=null;R&&(k=R[y]);var G=null;S&&(G=String.fromCharCode(S[y]));var B=null;L&&(B=L[y]),f({atomIndex:y,groupIndex:g,chainIndex:m,modelIndex:h,atomId:U,element:z.elementList[s],atomName:z.atomNameList[s],formalCharge:z.formalChargeList[s],xCoord:e.xCoordList[y],yCoord:e.yCoordList[y],zCoord:e.zCoordList[y],bFactor:k,altLoc:G,occupancy:B})}y+=1}if(v){var X=z.bondAtomList;for(s=0,c=z.bondOrderList.length;c>s;++s)v({atomIndex1:y-D+X[2*s],atomIndex2:y-D+X[2*s+1],bondOrder:z.bondOrderList[s]})}g+=1}m+=1}if(E=_+1,_=y-1,v&&A)for(s=0,c=A.length;c>s;s+=2){var q=A[s],W=A[s+1];(q>=E&&_>=q||W>=E&&_>=W)&&v({atomIndex1:q,atomIndex2:W,bondOrder:I?I[s/2]:null})}h+=1}},e.fetch=function(e,t,i){z(e,V,t,i)},e.fetchReduced=function(e,t,i){z(e,U,t,i)},e.version="v1.0.1",e.fetchUrl=V,e.fetchReducedUrl=U,e.encodeMsgpack=o,e.encodeMmtf=I,e.decodeMsgpack=O,e.decodeMmtf=P,e}MMTF=initIcn3dpyMMTF(MMTF),function(e,t,i){var o,n="__instance__",r="firstChild",a=setTimeout;function s(e){return void 0!==e}function c(e){return"object"==typeof e}function d(e){return Object.keys(e).length}function l(e,t,i){return ei?i:e}function u(e,t){return parseInt(e,t||10)}function p(e){return Math.round(e)}function f(e){var t,i,o,n,r,a,s,c,d=+e[0],l=+e[1],u=+e[2];switch(a=u*(1-l),s=u*(1-(r=6*d-(n=Math.floor(6*d)))*l),c=u*(1-(1-r)*l),n=n||0,s=s||0,c=c||0,n%6){case 0:t=u,i=c,o=a;break;case 1:t=s,i=u,o=a;break;case 2:t=a,i=u,o=c;break;case 3:t=a,i=s,o=u;break;case 4:t=c,i=a,o=u;break;case 5:t=u,i=a,o=s}return[p(255*t),p(255*i),p(255*o)]}function v(e){return m(f(e))}function h(e){var t,i=+e[0],o=+e[1],n=+e[2],r=Math.max(i,o,n),a=Math.min(i,o,n),s=r-a,c=0===r?0:s/r,d=r/255;switch(r){case a:t=0;break;case i:t=o-n+s*(o
    ';var H,z=_[r].children,D=N([0,1,1]),j=z[0],F=z[1],V=j[r],U=F[r],k=0,G=0,B=0,X=0,q=0,W=0,Y=0,Z=0,Q=v(D);function K(e,t){e&&"h"!==e||M("change:h",t),e&&"sv"!==e||M("change:sv",t),M("change",t)}function $(){return _.parentNode}function J(n,r){n||((u||r||p).appendChild(_),m.visible=!0),Y=O(_).w,Z=O(_).h;var a=O(F),s=O(U),c=O(j).h,d=a.w,h=a.h,g=O(V).h,y=s.w,E=s.h;if(n){function L(e){var t=e.target,o=t===i||A(t,i)===i;o?J():m.exit(),M(o?"enter":"exit",[m])}_.style.left=_.style.top="-9999px",!1!==o&&C(o,i,L),m.create=function(){return J(1),M("create",[m]),m},m.destroy=function(){return!1!==o&&R(o,i,L),m.exit(),P(!1),M("destroy",[m]),m}}else ee();function z(e){f(D);var t=f([D[0],1,1]);F.style.backgroundColor="rgb("+t.join(",")+")",P(D),I(e)}function q(e){var t,i,o,n,r,a;B&&(i=l(S(j,t=e).y,0,c),D[0]=(c-i)/c,V.style.top=i-g/2+"px",z(t),Q=v(D),k||(M("drag:h",[Q,m]),M("drag",[Q,m]),K("h",[Q,m]))),X&&(n=S(F,o=e),r=l(n.x,0,d),a=l(n.y,0,h),D[1]=1-(d-r)/d,D[2]=(h-a)/h,U.style.right=d-r-y/2+"px",U.style.top=a-E/2+"px",z(o),Q=v(D),G||(M("drag:sv",[Q,m]),M("drag",[Q,m]),K("sv",[Q,m]))),k=0,G=0}function W(e){var t=e.target,n=B?"h":"sv",r=[v(D),m],a=t===i||A(t,i)===i,s=t===_||A(t,_)===_;a||s?s&&(M("stop:"+n,r),M("stop",r),K(n,r)):$()&&!1!==o&&(m.exit(),M("exit",[m]),K(0,r)),B=0,X=0}function te(e){k=1,B=1,q(e),I(e),M("start:h",[Q,m]),M("start",[Q,m]),K("h",[Q,m])}function ie(e){G=1,X=1,q(e),I(e),M("start:sv",[Q,m]),M("start",[Q,m]),K("sv",[Q,m])}H=function(){D=N(D),z(),V.style.top=c-g/2-c*+D[0]+"px",U.style.right=d-y/2-d*+D[1]+"px",U.style.top=h-E/2-h*+D[2]+"px"},m.exit=function(i){return $()&&($().removeChild(_),m.visible=!1),R(b,j,te),R(b,F,ie),R(w,t,q),R(T,t,W),R(x,e,ee),m},H(),n||(C(b,j,te),C(b,F,ie),C(w,t,q),C(T,t,W),C(x,e,ee))}function ee(){return m.fit()}return J(1),a(function(){var e=[v(D),m];M("create",e),K(0,e)},0),m.fit=function(t){var o=O(e),n=O(h),r=o.w-n.w,a=o.h-h.clientHeight,d=L(e),u=L(i);if(q=u.l+d.l,W=u.t+d.t+O(i).h,c(t))s(t[0])&&(q=t[0]),s(t[1])&&(W=t[1]);else{var p=d.l,f=d.t,v=d.l+o.w-Y-r,g=d.t+o.h-Z-a;q=l(q,p,v)>>0,W=l(W,f,g)>>0}return _.style.left=q+"px",_.style.top=W+"px",M("fit",[m]),m},m.set=function(e){return s(e)?("string"==typeof e&&(e=g.parse(e)),P(e),H(),m):N()},m.get=function(e){return N(e)},m.target=i,m.picker=_,m.visible=!1,m.on=function(e,t,i){return s(e)?s(t)?(s(E[e])||(E[e]={}),s(i)||(i=d(E[e])),E[e][i]=t,m):E[e]:E},m.off=function(e,t){return s(e)?s(t)?(delete E[e][t],m):(E[e]={},m):(E={},m)},m.fire=M,m.hooks=E,m.enter=function(e){return J(0,e)},m}).version="1.3.9",o[n]={},o.each=function(e,t){return a(function(){var t,i=o[n];for(t in i)e(i[t],t,i)},0===t?0:t||1),o},o.parse=b,o._HSV2RGB=f,o._HSV2HEX=v,o._RGB2HSV=h,o._HEX2HSV=g,o._HEX2RGB=function(e){return[+(t=y(e))[0]/255,+t[1]/255,+t[2]/255];var t},o.HSV2RGB=function(e){return f(E(e))},o.HSV2HEX=function(e){return v(E(e))},o.RGB2HSV=function(e){return _(h(e))},o.RGB2HEX=m,o.HEX2HSV=function(e){return _(g(e))},o.HEX2RGB=y}(window,document);var saveAs=function(e){"use strict";if(!(void 0===e||"undefined"!=typeof navigator&&/MSIE [1-9]\./.test(navigator.userAgent))){var t=function(){return e.URL||e.webkitURL||e},i=e.document.createElementNS("http://www.w3.org/1999/xhtml","a"),o="download"in i,n=/constructor/i.test(e.HTMLElement)||e.safari,r=/CriOS\/[\d]+/.test(navigator.userAgent),a=e.setImmediate||e.setTimeout,s=function(e){a(function(){throw e},0)},c=function(e){setTimeout(function(){"string"==typeof e?t().revokeObjectURL(e):e.remove()},4e4)},d=function(e){return/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob([String.fromCharCode(65279),e],{type:e.type}):e},l=function(l,u,p){p||(l=d(l));var f,v=this,h="application/octet-stream"===(l?l.type:void 0),m=function(){!function(e,t,i){for(var o=(t=[].concat(t)).length;o--;){var n=e["on"+t[o]];if("function"==typeof n)try{n.call(e,i||e)}catch(e){s(e)}}}(v,"writestart progress write writeend".split(" "))};if(v.readyState=v.INIT,o)return f||(f=t().createObjectURL(l)),void a(function(){var e,t;i.href=f,i.download=u,e=i,t=new MouseEvent("click"),e.dispatchEvent(t),m(),c(f),v.readyState=v.DONE},0);!function(){if((r||h&&n)&&e.FileReader){var i=new FileReader;return i.onloadend=function(){var t=r?i.result:i.result.replace(/^data:[^;]*;/,"data:attachment/file;");e.open(t,"_blank")||(e.location.href=t),t=void 0,v.readyState=v.DONE,m()},i.readAsDataURL(l),void(v.readyState=v.INIT)}f||(f=t().createObjectURL(l)),h?e.location.href=f:e.open(f,"_blank")||(e.location.href=f);v.readyState=v.DONE,m(),c(f)}()},u=l.prototype;return"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(e,t,i){return t=t||e.name||"download",i||(e=d(e)),navigator.msSaveOrOpenBlob(e,t)}:(u.abort=function(){},u.readyState=u.INIT=0,u.WRITING=1,u.DONE=2,u.error=u.onwritestart=u.onprogress=u.onwrite=u.onabort=u.onerror=u.onwriteend=null,function(e,t,i){return new l(e,t||e.name||"download",i)})}}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this);!function(e){"use strict";var t=e.HTMLCanvasElement&&e.HTMLCanvasElement.prototype,i=e.Blob&&function(){try{return Boolean(new Blob)}catch(e){return!1}}(),o=i&&e.Uint8Array&&function(){try{return 100===new Blob([new Uint8Array(100)]).size}catch(e){return!1}}(),n=e.BlobBuilder||e.WebKitBlobBuilder||e.MozBlobBuilder||e.MSBlobBuilder,r=/^data:((.*?)(;charset=.*?)?)(;base64)?,/,a=(i||n)&&e.atob&&e.ArrayBuffer&&e.Uint8Array&&function(e){var t,a,s,c,d,l,u,p,f;if(!(t=e.match(r)))throw new Error("invalid data URI");for(a=t[2]?t[1]:"text/plain"+(t[3]||";charset=US-ASCII"),s=!!t[4],c=e.slice(t[0].length),d=s?atob(c):decodeURIComponent(c),l=new ArrayBuffer(d.length),u=new Uint8Array(l),p=0;p0||window.navigator.userAgent.match(/Trident.*rv\:11\./))}isMobile(){return this.icn3dui,/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)}isMac(){return this.icn3dui,/Mac/i.test(window.navigator.userAgent)}isAndroid(){return this.icn3dui,/android/i.test(window.navigator.userAgent.toLowerCase())}isChrome(){return this.icn3dui,navigator.userAgent.includes("Chrome")&&navigator.vendor.includes("Google Inc")}isSessionStorageSupported(){return this.icn3dui,window.sessionStorage}isLocalStorageSupported(){return this.icn3dui,window.localStorage}hexToRgb(e,t){this.icn3dui;let s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return s?{r:parseInt(s[1],16),g:parseInt(s[2],16),b:parseInt(s[3],16),a:t}:null}isCalphaPhosOnly(e){this.icn3dui;let t=!1,s=0,i=0;for(let t in e){if(!(s<100))break;{let s=e[t].name.trim();"CA"!==s&&"P"!==s&&"O3'"!==s&&"O3*"!==s&&++i}++s}return i<.5*s&&(t=!0),t}hasCovalentBond(e,t){let s=this.icn3dui,i=s.parasCls.covalentRadii[e.elem.toUpperCase()]+s.parasCls.covalentRadii[t.elem.toUpperCase()],n=e.coord.x-t.coord.x,l=e.coord.y-t.coord.y,r=e.coord.z-t.coord.z;return n*n+l*l+r*r<("N"==e.elem&&"H"==t.elem.substr(0,1)||"N"==t.elem&&"H"==e.elem.substr(0,1)?2.2:1.3)*i*i}residueName2Abbr(e){this.icn3dui;let t=e.indexOf(" ");switch(t>0&&(e=e.substr(0,t)),e){case" A":case" DA":case"DA":case"ALA":return"A";case" C":case" DC":case"DC":case"CYS":return"C";case" G":case" DG":case"DG":case"GLY":return"G";case" T":case" DT":case"DT":case"THR":return"T";case" U":case" DU":case"DU":case"SEC":return"U";case" I":case" DI":case"DI":case"ILE":return"I";case"ARG":return"R";case"ASN":return"N";case"ASP":return"D";case"GLU":return"E";case"GLN":return"Q";case"HIS":return"H";case"LEU":return"L";case"LYS":return"K";case"MET":return"M";case"PHE":return"F";case"PRO":return"P";case"SER":return"S";case"TRP":return"W";case"TYR":return"Y";case"VAL":return"V";case"HOH":case"WAT":return"O";default:return e.trim()}}residueAbbr2Name(e){if(this.icn3dui,(e=e.toUpperCase()).length>1)return e;switch(e){case"A":return"ALA";case"R":return"ARG";case"N":return"ASN";case"D":return"ASP";case"C":return"CYS";case"E":return"GLU";case"Q":return"GLN";case"G":return"GLY";case"H":return"HIS";case"I":return"ILE";case"L":return"LEU";case"K":return"LYS";case"M":return"MET";case"F":return"PHE";case"P":return"PRO";case"S":return"SER";case"T":return"THR";case"W":return"TRP";case"Y":return"TYR";case"V":return"VAL";case"O":return"HOH";default:return e.trim()}}getJSONFromArray(e){this.icn3dui;let t="";for(let s=0,i=e.length;sd?1:ah?1:cs&&(e.htmlCls.WIDTH=s),i&&e.htmlCls.HEIGHT>i&&(e.htmlCls.HEIGHT=i)}sumArray(e){let t=0;for(let s=0,i=e.length;sRed and blue membranes indicate extracellular and intracellular membranes, respectively.

    "}}class i{constructor(e){this.icn3dui=e,this.glycanHash={GLC:{c:"1E90FF",s:"sphere"},BGC:{c:"1E90FF",s:"sphere"},NAG:{c:"1E90FF",s:"cube"},NDG:{c:"1E90FF",s:"cube"},GCS:{c:"1E90FF",s:"cube"},PA1:{c:"1E90FF",s:"cube"},GCU:{c:"1E90FF",s:"cone"},BDP:{c:"1E90FF",s:"cone"},G6D:{c:"1E90FF",s:"cone"},DDA:{c:"1E90FF",s:"cylinder"},B6D:{c:"1E90FF",s:"cylinder"},XXM:{c:"1E90FF",s:"cylinder"},MAN:{c:"00FF00",s:"sphere"},BMA:{c:"00FF00",s:"sphere"},BM3:{c:"00FF00",s:"cube"},"95Z":{c:"00FF00",s:"cube"},MAV:{c:"00FF00",s:"cone"},BEM:{c:"00FF00",s:"cone"},RAM:{c:"00FF00",s:"cone"},RM4:{c:"00FF00",s:"cone"},TYV:{c:"00FF00",s:"cylinder"},ARA:{c:"00FF00",s:"cylinder"},ARB:{c:"00FF00",s:"cylinder"},KDN:{c:"00FF00",s:"cylinder"},KDM:{c:"00FF00",s:"cylinder"},"6PZ":{c:"00FF00",s:"cylinder"},GMH:{c:"00FF00",s:"cylinder"},BDF:{c:"00FF00",s:"cylinder"},GAL:{c:"FFFF00",s:"sphere"},GLA:{c:"FFFF00",s:"sphere"},NGA:{c:"FFFF00",s:"cube"},A2G:{c:"FFFF00",s:"cube"},X6X:{c:"FFFF00",s:"cube"},"1GN":{c:"FFFF00",s:"cube"},ADA:{c:"FFFF00",s:"cone"},GTR:{c:"FFFF00",s:"cone"},LDY:{c:"FFFF00",s:"cylinder"},KDO:{c:"FFFF00",s:"cylinder"},T6T:{c:"FFFF00",s:"cylinder"},GUP:{c:"A52A2A",s:"sphere"},GL0:{c:"A52A2A",s:"sphere"},LGU:{c:"A52A2A",s:"cone"},ABE:{c:"A52A2A",s:"cylinder"},XYS:{c:"A52A2A",s:"cylinder"},XYP:{c:"A52A2A",s:"cylinder"},SOE:{c:"A52A2A",s:"cylinder"},PZU:{c:"FF69B4",s:"cylinder"},RIP:{c:"FF69B4",s:"cylinder"},"0MK":{c:"FF69B4",s:"cylinder"},ALL:{c:"8A2BE2",s:"sphere"},AFD:{c:"8A2BE2",s:"sphere"},NAA:{c:"8A2BE2",s:"cube"},SIA:{c:"8A2BE2",s:"cylinder"},SIB:{c:"8A2BE2",s:"cylinder"},AMU:{c:"8A2BE2",s:"cylinder"},X0X:{c:"1E90FF",s:"cone"},X1X:{c:"1E90FF",s:"cone"},NGC:{c:"1E90FF",s:"cylinder"},NGE:{c:"1E90FF",s:"cylinder"},"4N2":{c:"A0522D",s:"sphere"},HSQ:{c:"A0522D",s:"cube"},IDR:{c:"A0522D",s:"cone"},MUR:{c:"A0522D",s:"cylinder"},FUC:{c:"FF0000",s:"cone"},FUL:{c:"FF0000",s:"cone"}},this.nucleotidesArray=[" G"," A"," T"," C"," U"," DG"," DA"," DT"," DC"," DU","G","A","T","C","U","DG","DA","DT","DC","DU"],this.ionsArray=[" K"," NA"," MG"," AL"," CA"," TI"," MN"," FE"," NI"," CU"," ZN"," AG"," BA"," F"," CL"," BR"," I","K","NA","MG","AL","CA","TI","MN","FE","NI","CU","ZN","AG","BA","F","CL","BR","I"],this.cationsTrimArray=["K","NA","MG","AL","CA","TI","MN","FE","NI","CU","ZN","AG","BA"],this.anionsTrimArray=["F","CL","BR","I"],this.ionCharges={K:1,NA:1,MG:2,AL:3,CA:2,TI:3,MN:2,FE:3,NI:2,CU:2,ZN:2,AG:1,BA:2},this.vdwRadii={H:1.08,HE:1.34,LI:1.75,BE:2.05,B:1.47,C:1.49,N:1.41,O:1.4,F:1.39,NE:1.68,NA:1.84,MG:2.05,AL:2.11,SI:2.07,P:1.92,S:1.82,CL:1.83,AR:1.93,K:2.05,CA:2.21,SC:2.16,TI:1.87,V:1.79,CR:1.89,MN:1.97,FE:1.94,CO:1.92,NI:1.84,CU:1.86,ZN:2.1,GA:2.08,GE:2.15,AS:2.06,SE:1.93,BR:1.98,KR:2.12,RB:2.16,SR:2.24,Y:2.19,ZR:1.86,NB:2.07,MO:2.09,TC:2.09,RU:2.07,RH:1.95,PD:2.02,AG:2.03,CD:2.3,IN:2.36,SN:2.33,SB:2.25,TE:2.23,I:2.23,XE:2.21,CS:2.22,BA:2.51,LA:2.4,CE:2.35,PR:2.39,ND:2.29,PM:2.36,SM:2.29,EU:2.33,GD:2.37,TB:2.21,DY:2.29,HO:2.16,ER:2.35,TM:2.27,YB:2.42,LU:2.21,HF:2.12,TA:2.17,W:2.1,RE:2.17,OS:2.16,IR:2.02,PT:2.09,AU:2.17,HG:2.09,TL:2.35,PB:2.32,BI:2.43,PO:2.29,AT:2.36,RN:2.43,FR:2.56,RA:2.43,AC:2.6,TH:2.37,PA:2.43,U:2.4,NP:2.21,PU:2.56,AM:2.56,CM:2.56,BK:2.56,CF:2.56,ES:2.56,FM:2.56},this.covalentRadii={H:.31,HE:.28,LI:1.28,BE:.96,B:.84,C:.76,N:.71,O:.66,F:.57,NE:.58,NA:1.66,MG:1.41,AL:1.21,SI:1.11,P:1.07,S:1.05,CL:1.02,AR:1.06,K:2.03,CA:1.76,SC:1.7,TI:1.6,V:1.53,CR:1.39,MN:1.39,FE:1.32,CO:1.26,NI:1.24,CU:1.32,ZN:1.22,GA:1.22,GE:1.2,AS:1.19,SE:1.2,BR:1.2,KR:1.16,RB:2.2,SR:1.95,Y:1.9,ZR:1.75,NB:1.64,MO:1.54,TC:1.47,RU:1.46,RH:1.42,PD:1.39,AG:1.45,CD:1.44,IN:1.42,SN:1.39,SB:1.39,TE:1.38,I:1.39,XE:1.4,CS:2.44,BA:2.15,LA:2.07,CE:2.04,PR:2.03,ND:2.01,PM:1.99,SM:1.98,EU:1.98,GD:1.96,TB:1.94,DY:1.92,HO:1.92,ER:1.89,TM:1.9,YB:1.87,LU:1.87,HF:1.75,TA:1.7,W:1.62,RE:1.51,OS:1.44,IR:1.41,PT:1.36,AU:1.36,HG:1.32,TL:1.45,PB:1.46,BI:1.48,PO:1.4,AT:1.5,RN:1.5,FR:2.6,RA:2.21,AC:2.15,TH:2.06,PA:2,U:1.96,NP:1.9,PU:1.87,AM:1.8,CM:1.69},this.atomColors={H:this.thr(16777215),He:this.thr(16761035),HE:this.thr(16761035),Li:this.thr(11674146),LI:this.thr(11674146),B:this.thr(65280),C:this.thr(11184810),N:this.thr(255),O:this.thr(15728640),F:this.thr(14329120),Na:this.thr(255),NA:this.thr(255),Mg:this.thr(2263842),MG:this.thr(2263842),Al:this.thr(8421520),AL:this.thr(8421520),Si:this.thr(14329120),SI:this.thr(14329120),P:this.thr(16753920),S:this.thr(16762930),Cl:this.thr(65280),CL:this.thr(65280),Ca:this.thr(8421520),CA:this.thr(8421520),Ti:this.thr(8421520),TI:this.thr(8421520),Cr:this.thr(8421520),CR:this.thr(8421520),Mn:this.thr(8421520),MN:this.thr(8421520),Fe:this.thr(16753920),FE:this.thr(16753920),Ni:this.thr(10824234),NI:this.thr(10824234),Cu:this.thr(10824234),CU:this.thr(10824234),Zn:this.thr(10824234),ZN:this.thr(10824234),Br:this.thr(10824234),BR:this.thr(10824234),Ag:this.thr(8421520),AG:this.thr(8421520),I:this.thr(10494192),Ba:this.thr(16753920),BA:this.thr(16753920),Au:this.thr(14329120),AU:this.thr(14329120)},this.atomnames={H:"Hydrogen",HE:"Helium",LI:"Lithium",B:"Boron",C:"Carbon",N:"Nitrogen",O:"Oxygen",F:"Fluorine",NA:"Sodium",MG:"Magnesium",AL:"Aluminum",SI:"Silicon",P:"Phosphorus",S:"Sulfur",CL:"Chlorine",CA:"Calcium",TI:"Titanium",CR:"Chromium",MN:"Manganese",FE:"Iron",NI:"Nickel",CU:"Copper",ZN:"Zinc",BR:"Bromine",AG:"Silver",I:"Iodine",BA:"Barium",AU:"Gold"},this.defaultAtomColor=this.thr(13421772),this.stdChainColors=[this.thr(16711935),this.thr(255),this.thr(10053171),this.thr(65433),this.thr(16750848),this.thr(16737894),this.thr(3329330),this.thr(2003199),this.thr(16416882),this.thr(16753920),this.thr(52945),this.thr(16738740),this.thr(65280),this.thr(255),this.thr(16711680),this.thr(16776960),this.thr(65535),this.thr(16711935),this.thr(3978097),this.thr(4620980),this.thr(13458524),this.thr(16770229),this.thr(11529966),this.thr(15631086),this.thr(25600),this.thr(139),this.thr(9109504),this.thr(13468991),this.thr(35723),this.thr(9699539)],this.backgroundColors={black:this.thr(0),grey:this.thr(13421772),white:this.thr(16777215),transparent:this.thr(16777215)},this.residueColors={ALA:this.thr(13158600),ARG:this.thr(1334015),ASN:this.thr(56540),ASP:this.thr(15075850),CYS:this.thr(15132160),GLN:this.thr(56540),GLU:this.thr(15075850),GLY:this.thr(15461355),HIS:this.thr(8553170),ILE:this.thr(1016335),LEU:this.thr(1016335),LYS:this.thr(1334015),MET:this.thr(15132160),PHE:this.thr(3289770),PRO:this.thr(14456450),SER:this.thr(16422400),THR:this.thr(16422400),TRP:this.thr(11819700),TYR:this.thr(3289770),VAL:this.thr(1016335),ASX:this.thr(16738740),GLX:this.thr(16738740),G:this.thr(32768),A:this.thr(6324479),T:this.thr(16744448),C:this.thr(16711680),U:this.thr(16744448),DG:this.thr(32768),DA:this.thr(6324479),DT:this.thr(16744448),DC:this.thr(16711680),DU:this.thr(16744448)},this.residueArea={ALA:247,ARG:366,ASN:290,ASP:285,CYS:271,GLN:336,GLU:325,GLY:217,HIS:340,ILE:324,LEU:328,LYS:373,MET:346,PHE:366,PRO:285,SER:265,THR:288,TRP:414,TYR:387,VAL:293,ASX:290,GLX:336,G:520,A:507,T:515,C:467,U:482,DG:520,DA:507,DT:515,DC:467,DU:482},this.defaultResidueColor=this.thr(12492910),this.chargeColors={" G":this.thr(16711680)," A":this.thr(16711680)," T":this.thr(16711680)," C":this.thr(16711680)," U":this.thr(16711680)," DG":this.thr(16711680)," DA":this.thr(16711680)," DT":this.thr(16711680)," DC":this.thr(16711680)," DU":this.thr(16711680),G:this.thr(16711680),A:this.thr(16711680),T:this.thr(16711680),C:this.thr(16711680),U:this.thr(16711680),DG:this.thr(16711680),DA:this.thr(16711680),DT:this.thr(16711680),DC:this.thr(16711680),DU:this.thr(16711680),ARG:this.thr(255),LYS:this.thr(255),ASP:this.thr(16711680),GLU:this.thr(16711680),HIS:this.thr(8421631),GLY:this.thr(8947848),PRO:this.thr(8947848),ALA:this.thr(8947848),VAL:this.thr(8947848),LEU:this.thr(8947848),ILE:this.thr(8947848),PHE:this.thr(8947848),SER:this.thr(8947848),THR:this.thr(8947848),ASN:this.thr(8947848),GLN:this.thr(8947848),TYR:this.thr(8947848),MET:this.thr(8947848),CYS:this.thr(8947848),TRP:this.thr(8947848)},this.hydrophobicColors={" G":this.thr(16711680)," A":this.thr(16711680)," T":this.thr(16711680)," C":this.thr(16711680)," U":this.thr(16711680)," DG":this.thr(16711680)," DA":this.thr(16711680)," DT":this.thr(16711680)," DC":this.thr(16711680)," DU":this.thr(16711680),G:this.thr(16711680),A:this.thr(16711680),T:this.thr(16711680),C:this.thr(16711680),U:this.thr(16711680),DG:this.thr(16711680),DA:this.thr(16711680),DT:this.thr(16711680),DC:this.thr(16711680),DU:this.thr(16711680),ARG:this.thr(255),LYS:this.thr(255),ASP:this.thr(16711680),GLU:this.thr(16711680),HIS:this.thr(8421631),TRP:this.thr().setHSL(1/3,1,.5),PHE:this.thr().setHSL(1/3,1,.6945945945945946),TYR:this.thr().setHSL(1/3,1,.745945945945946),LEU:this.thr().setHSL(1/3,1,.5+.645/1.85),ILE:this.thr().setHSL(1/3,1,.5+.77/1.85),CYS:this.thr().setHSL(1/3,1,.5+.805/1.85),MET:this.thr().setHSL(1/3,1,.5+.81/1.85),GLY:this.thr().setHSL(1/6,1,.5+.285/.58),VAL:this.thr().setHSL(1/6,1,.5+.255/.58),SER:this.thr().setHSL(1/6,1,.8879310344827587),THR:this.thr().setHSL(1/6,1,.8793103448275862),ALA:this.thr().setHSL(1/6,1,.853448275862069),ASN:this.thr().setHSL(1/6,1,.6379310344827587),PRO:this.thr().setHSL(1/6,1,.6120689655172413),GLN:this.thr().setHSL(1/6,1,.5)},this.normalizedHPColors={" G":this.thr(16777215)," A":this.thr(16777215)," T":this.thr(16777215)," C":this.thr(16777215)," U":this.thr(16777215)," DG":this.thr(16777215)," DA":this.thr(16777215)," DT":this.thr(16777215)," DC":this.thr(16777215)," DU":this.thr(16777215),G:this.thr(16777215),A:this.thr(16777215),T:this.thr(16777215),C:this.thr(16777215),U:this.thr(16777215),DG:this.thr(16777215),DA:this.thr(16777215),DT:this.thr(16777215),DC:this.thr(16777215),DU:this.thr(16777215),ARG:this.thr(16777215),LYS:this.thr(16777215),ASP:this.thr(16777215),GLU:this.thr(16777215),HIS:this.thr(16777215),TRP:this.thr().setHSL(1/3,1,.5),PHE:this.thr().setHSL(1/3,1,.644),TYR:this.thr().setHSL(1/3,1,.682),LEU:this.thr().setHSL(1/3,1,.758),ILE:this.thr().setHSL(1/3,1,.808),CYS:this.thr().setHSL(1/3,1,.5+.322),MET:this.thr().setHSL(1/3,1,.5+.324),GLY:this.thr().setHSL(1/3,1,.872),VAL:this.thr().setHSL(1/3,1,.884),SER:this.thr().setHSL(1/3,1,.896),THR:this.thr().setHSL(1/3,1,.898),ALA:this.thr().setHSL(1/3,1,.904),ASN:this.thr().setHSL(1/3,1,.954),PRO:this.thr().setHSL(1/3,1,.9600000000000001),GLN:this.thr().setHSL(1/3,1,.986)},this.hydrophobicValues={" G":3," A":3," T":3," C":3," U":3," DG":3," DA":3," DT":3," DC":3," DU":3,G:3,A:3,T:3,C:3,U:3,DG:3,DA:3,DT:3,DC:3,DU:3,ARG:1,LYS:1,ASP:3,GLU:3,HIS:2,TRP:-1.85,PHE:-1.13,TYR:-.94,LEU:-.56,ILE:-.31,CYS:-.24,MET:-.23,GLY:.01,VAL:.07,SER:.13,THR:.14,ALA:.17,ASN:.42,PRO:.45,GLN:.58},this.residueAbbrev={ALA:"A (Ala)",ARG:"R (Arg)",ASN:"N (Asn)",ASP:"D (Asp)",CYS:"C (Cys)",GLN:"Q (Gln)",GLU:"E (Glu)",GLY:"G (Gly)",HIS:"H (His)",ILE:"I (Ile)",LEU:"L (Leu)",LYS:"K (Lys)",MET:"M (Met)",PHE:"F (Phe)",PRO:"P (Pro)",SER:"S (Ser)",THR:"T (Thr)",TRP:"W (Trp)",TYR:"Y (Tyr)",VAL:"V (Val)",ASX:"X (Asx)",GLX:"X (Glx)",G:"Guanine",A:"Adenine",T:"Thymine",C:"Cytosine",U:"Uracil",DG:"deoxy-Guanine",DA:"deoxy-Adenine",DT:"deoxy-Thymine",DC:"deoxy-Cytosine",DU:"deoxy-Uracil"},this.ssColors={helix:this.thr(16711680),sheet:this.thr(32768),coil:this.thr(6324479)},this.ssColors2={helix:this.thr(16711680),sheet:this.thr(16762880),coil:this.thr(6324479)},this.resn2restype={ALA:1,ARG:4,ASN:7,ASP:10,CYS:13,GLN:16,GLU:19,GLY:22,HIS:25,ILE:28,LEU:31,LYS:34,MET:37,PHE:40,PRO:43,SER:46,THR:49,TRP:52,TYR:55,VAL:58},this.nuclMainArray=["C1'","C1*","C2'","C2*","C3'","C3*","C4'","C4*","C5'","C5*","O3'","O3*","O4'","O4*","O5'","O5*","P","OP1","O1P","OP2","O2P"],this.b62ResArray=["A","R","N","D","C","Q","E","G","H","I","L","K","M","F","P","S","T","W","Y","V","B","Z","X","*"],this.b62Matrix=[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0,-4],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1,-4],[-2,0,6,1,-3,0,0,0,1,-3,-3,0,-2,-3,-2,1,0,-4,-2,-3,3,0,-1,-4],[-2,-2,1,6,-3,0,2,-1,-1,-3,-4,-1,-3,-3,-1,0,-1,-4,-3,-3,4,1,-1,-4],[0,-3,-3,-3,9,-3,-4,-3,-3,-1,-1,-3,-1,-2,-3,-1,-1,-2,-2,-1,-3,-3,-2,-4],[-1,1,0,0,-3,5,2,-2,0,-3,-2,1,0,-3,-1,0,-1,-2,-1,-2,0,3,-1,-4],[-1,0,0,2,-4,2,5,-2,0,-3,-3,1,-2,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-2,0,-1,-3,-2,-2,6,-2,-4,-4,-2,-3,-3,-2,0,-2,-2,-3,-3,-1,-2,-1,-4],[-2,0,1,-1,-3,0,0,-2,8,-3,-3,-1,-2,-1,-2,-1,-2,-2,2,-3,0,0,-1,-4],[-1,-3,-3,-3,-1,-3,-3,-4,-3,4,2,-3,1,0,-3,-2,-1,-3,-1,3,-3,-3,-1,-4],[-1,-2,-3,-4,-1,-2,-3,-4,-3,2,4,-2,2,0,-3,-2,-1,-2,-1,1,-4,-3,-1,-4],[-1,2,0,-1,-3,1,1,-2,-1,-3,-2,5,-1,-3,-1,0,-1,-3,-2,-2,0,1,-1,-4],[-1,-1,-2,-3,-1,0,-2,-3,-2,1,2,-1,5,0,-2,-1,-1,-1,-1,1,-3,-1,-1,-4],[-2,-3,-3,-3,-2,-3,-3,-3,-1,0,0,-3,0,6,-4,-2,-2,1,3,-1,-3,-3,-1,-4],[-1,-2,-2,-1,-3,-1,-1,-2,-2,-3,-3,-1,-2,-4,7,-1,-1,-4,-3,-2,-2,-1,-2,-4],[1,-1,1,0,-1,0,0,0,-1,-2,-2,0,-1,-2,-1,4,1,-3,-2,-2,0,0,0,-4],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,1,5,-2,-2,0,-1,-1,0,-4],[-3,-3,-4,-4,-2,-2,-3,-2,-2,-3,-2,-3,-1,1,-4,-3,-2,11,2,-3,-4,-3,-2,-4],[-2,-2,-2,-3,-2,-1,-2,-3,2,-1,-1,-2,-1,3,-3,-2,-2,2,7,-1,-3,-2,-1,-4],[0,-3,-3,-3,-1,-2,-2,-3,-3,3,1,-2,1,-1,-2,-2,0,-3,-1,4,-3,-2,-1,-4],[-2,-1,3,4,-3,0,1,-1,0,-3,-4,0,-3,-3,-2,0,-1,-4,-3,-3,4,1,-1,-4],[-1,0,0,1,-3,3,4,-2,0,-3,-3,1,-1,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,0,0,-2,-1,-1,-1,-1,-1,-4],[-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,1]]}thr(e){return this.icn3dui,"#0"==e&&(e="#000"),new THREE.Color(e)}}class n{constructor(e){this.icn3dui=e}onId(e,t,s){if(this.icn3dui,!(Object.keys(window).length<2)&&("#"==e.substr(0,1)&&(e=e.substr(1)),document.getElementById(e))){t.split(" ").forEach((t=>{document.getElementById(e).addEventListener(t,s)}))}}onIds(e,t,s){let i=this.icn3dui;Array.isArray(e)?e.forEach((e=>{i.myEventCls.onId(e,t,s)})):i.myEventCls.onId(e,t,s)}}class l{constructor(e){this.icn3dui=e}getRmsdSuprCls(e,t,s){let i,n,l,r,o,a,d,c,h,p,m,u,g,f=this.icn3dui,b=new Array(9),C=new THREE.Vector3,y=new THREE.Vector3,v=[],w=[],_=new Array(3),S=new Array(3),A=new Array(3),x=new Array(3),k=new Array(3),O=new Array(3);if(i=0,s<=1)return{rot:void 0,trans1:void 0,trans2:void 0,rmsd:999};let R=s;for(n=0;n0?(b[0]=x[0]*_[0]+k[0]*S[0]+O[0]*A[0],b[1]=x[0]*_[1]+k[0]*S[1]+O[0]*A[1],b[2]=x[0]*_[2]+k[0]*S[2]+O[0]*A[2],b[3]=x[1]*_[0]+k[1]*S[0]+O[1]*A[0],b[4]=x[1]*_[1]+k[1]*S[1]+O[1]*A[1],b[5]=x[1]*_[2]+k[1]*S[2]+O[1]*A[2],b[6]=x[2]*_[0]+k[2]*S[0]+O[2]*A[0],b[7]=x[2]*_[1]+k[2]*S[1]+O[2]*A[1],b[8]=x[2]*_[2]+k[2]*S[2]+O[2]*A[2]):(b[0]=x[0]*_[0]+k[0]*S[0]-O[0]*A[0],b[1]=x[0]*_[1]+k[0]*S[1]-O[0]*A[1],b[2]=x[0]*_[2]+k[0]*S[2]-O[0]*A[2],b[3]=x[1]*_[0]+k[1]*S[0]-O[1]*A[0],b[4]=x[1]*_[1]+k[1]*S[1]-O[1]*A[1],b[5]=x[1]*_[2]+k[1]*S[2]-O[1]*A[2],b[6]=x[2]*_[0]+k[2]*S[0]-O[2]*A[0],b[7]=x[2]*_[1]+k[2]*S[1]-O[2]*A[1],b[8]=x[2]*_[2]+k[2]*S[2]-O[2]*A[2]),c=Math.sqrt(c),h=Math.sqrt(h),p=Math.sqrt(p),g=c+h+u*p,m=a+d-2*g,i=m>0?Math.sqrt(m):void 0,{rot:b,trans1:E,trans2:I,rmsd:i})}eigen_values(e){let t,s,i,n,l,r,o,a,d,c,h,p,m,u,g,f,b,C,y,v;if(this.icn3dui,t=e[0],s=e[1],i=e[2],n=e[3],l=e[4],r=e[5],o=e[6],a=e[7],d=e[8],c=-(t+l+d),h=t*l+(t+l)*d-r*a-s*n-i*o,p=-t*l*d+t*r*a+s*n*d-s*r*o-i*n*a+i*l*o,m=-c*c/3+h,u=c*c*c/13.5-c*h/3+p,g=.25*u*u+m*m*m/27,g<0){let e,t;e=Math.sqrt(.25*u*u-g),t=Math.acos(-.5*u/e),C=2*Math.cbrt(e)*Math.cos(t/3)}else f=Math.cbrt(-.5*u+Math.sqrt(g)),b=Math.cbrt(-.5*u-Math.sqrt(g)),C=f+b;return C-=c/3,c+=C,p/=-C,y=.5*(-c+Math.sqrt(c*c-4*p)),v=.5*(-c-Math.sqrt(c*c-4*p)),y_&&(_=Math.abs(d)),Math.abs(c)>_&&(_=Math.abs(c)),Math.abs(h)>_&&(_=Math.abs(h)),Math.abs(p)>_&&(_=Math.abs(p)),Math.abs(m)>_&&(_=Math.abs(m)),Math.abs(u)>_&&(_=Math.abs(u)),Math.abs(g)>_&&(_=Math.abs(g)),Math.abs(f)>_&&(_=Math.abs(f)),_<1e-10)return r=3,{k:r,v1:t,v2:s,v3:i};if(o=0,a/=_,d/=_,c/=_,h/=_,p/=_,m/=_,u/=_,g/=_,f/=_,Math.abs(a)_&&(w=a,a=h,h=w,w=d,d=p,p=w,w=c,c=m,m=w,_=Math.abs(d)),Math.abs(g)>_&&(w=a,a=u,u=w,w=d,d=g,g=w,w=c,c=f,f=w),y=m-p*c/d,v=f-g*c/d,Math.abs(y)_&&(w=a,a=h,h=w,w=d,d=p,p=w,w=c,c=m,m=w,_=Math.abs(a)),Math.abs(c)>_&&(w=a,a=u,u=w,w=d,d=g,g=w,w=c,c=f,f=w),b=p-h*d/a,C=m-h*c/a,y=g-u*d/a,v=f-u*c/a,Math.abs(b)0&&(1==o?(a=s[0],d=s[1],c=s[2],w=Math.sqrt(a*a+d*d+c*c),s[0]=a/w,s[1]=d/w,s[2]=c/w):2==o?(a=t[0],d=t[1],c=t[2],h=s[0],p=s[1],m=s[2],w=a*h+d*p+c*m,Math.abs(w)>=n&&(s[0]=a+w*h,s[1]=d+w*p,s[2]=c+w*m,h=s[0],p=s[1],m=s[2]),w=Math.sqrt(a*a+d*d+c*c),t[0]=a/w,t[1]=d/w,t[2]=c/w,w=Math.sqrt(h*h+p*p+m*m),s[0]=h/w,s[1]=p/w,s[2]=m/w):(a=t[0],d=t[1],c=t[2],w=Math.sqrt(a*a+d*d+c*c),t[0]=a/w,t[1]=d/w,t[2]=c/w)),{k:r,v1:t,v2:s,v3:i}}getEigenForSelection(e,t){let s,i=this.icn3dui,n=new THREE.Vector3,l=[];for(s=0;s0&&Math.abs(l[0].x-e[0].x)<=6&&Math.abs(l[0].y-e[0].y)<=6&&Math.abs(l[0].z-e[0].z)<=6?(p.push(l[0]),m=1):m=0,p.push(e[0]);for(let t=1,s=e.length-1;t0&&Math.abs(r[0].x-e[e.length-1].x)<=6&&Math.abs(r[0].y-e[e.length-1].y)<=6&&Math.abs(r[0].z-e[e.length-1].z)<=6&&(p.push(r[0]),++g),u>1&&Math.abs(r[0].x-r[1].x)<=6&&Math.abs(r[0].y-r[1].y)<=6&&Math.abs(r[0].z-r[1].z)<=6&&(p.push(r[1]),++g);let f=[],b=[],C=[];o&&(g=u>0?u-1:0);let y;for(let e=-1,n=p.length,l=1/s;e<=n-3;++e){y=e-m;let r=p[-1===e?0:e],o=p[e+1],u=p[e+2],v=p[e===n-3?n-1:e+3],w=0,_=a.subdivideCls.getKnot(1,w,r,o),S=a.subdivideCls.getKnot(1,_,o,u),A=a.subdivideCls.getKnot(1,S,u,v);_-w<1e-4&&(_=w+1),S-_<1e-4&&(S=_+1),A-S<1e-4&&(A=S+1),e>-1&&(void 0===i||i[y+1])&&e>=-1+m&&e<=n-3-g+1&&(d=d.concat(f),c=c.concat(b),h=h.concat(C)),f=[],b=[],C=[];let x=(S-_)*l;for(let l=0;l=-1+m&&e<=n-3-g&&i[y+1]&&l<=parseInt(s/2)&&(d.push(new THREE.Vector3(k,O,R)),c.push(i[y+1]),h.push(t[y+1])),e>=-1+m&&e<=n-3-g+1&&i[y+2]&&l>parseInt(s/2)&&(f.push(new THREE.Vector3(k,O,R)),b.push(i[y+2]),C.push(t[y+2]))):e>=-1+m&&e<=n-3-g&&(d.push(new THREE.Vector3(k,O,R)),c.push(y+1),h.push(t[y+1]))}}i&&!i[y+1]||(d=d.concat(f),c=c.concat(b),h=h.concat(C),d.push(p[p.length-1-g]),c.push(p.length-1-g),h.push(t[p.length-1-g])),f=[],b=[],C=[],p=[];let v=[];return v.push(d),v.push(c),v.push(h),v}getKnot(e,t,s,i){return this.icn3dui,s.distanceTo(i)+t}getValueFromKnot(e,t,s,i,n,l,r,o,a){this.icn3dui;let d,c,h=(r-l)/(s-t),p=(o-r)/(i-s),m=(a-o)/(n-i),u=(s+i)*(s+i)-4*(t*s+i*n-t*n);return 0==u?(d=9999,c=9999):(d=6*(3*p*s+2*h*n+m*s-2*h*s-2*p*n-p*i-m*s)/u,c=6*(3*p*i+2*m*t+h*s-2*p*t-2*m*i-h*i-p*s)/u),p*(e-s)+r+((2*d+c)/6/(s-i)*(e-s)*(e-i)*(e-i)+(2*c+d)/6/(i-s)*(e-s)*(e-s)*(e-i))}}class o{constructor(e){this.icn3dui=e}passFloat32(e,t){let s=this.icn3dui,i=e.length;t||(t=new Uint8Array(4*i));let n=s.convertTypeCls.getDataView(t);for(let t=0;t  Very high (pLDDT > 90)
      Confident (90 > pLDDT > 70)
      Low (70 > pLDDT > 50)
      Very low (pLDDT < 50)
    '}setLegendHtml(e){let t=this.icn3dui.icn3d,s="
    ";if(e)s+=this.setAlphaFoldLegend();else{s+="
    StructureChainResidue Number
    "+s[e].substr(0,t)+""+s[e].substr(t+1,n-t-1)+""+s[e].substr(n+1)+"
    "+t.startValue+""+t.midValue+""+t.endValue+"
    "}return s}SetChainsAdvancedMenu(){let e=this.icn3dui,t=e.icn3d;if(void 0===t.bSetChainsAdvancedMenu||!t.bSetChainsAdvancedMenu){let s=e.hashUtilsCls.cloneHash(t.hAtoms);t.definedSetsCls.setPredefinedInMenu(),t.bSetChainsAdvancedMenu=!0,t.hAtoms=e.hashUtilsCls.cloneHash(s)}}setSetsMenus(e,t){let s=this.icn3dui,i=s.icn3d;this.SetChainsAdvancedMenu();let n=e,l=e+"2",r=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+s.pre+n).length&&$("#"+s.pre+n).html(" "+r),!t&&$("#"+s.pre+l).length&&$("#"+s.pre+l).html(" "+r),$("#"+s.pre+n).resizable(),t||$("#"+s.pre+l).resizable()}applyShownMenus(){let e=this.icn3dui;e.icn3d;let t=[];for(let s in e.htmlCls.allMenus)e.htmlCls.shownMenus.hasOwnProperty(s)?$("#"+e.pre+s).parent().show():($("#"+e.pre+s).parent().hide(),t.push(s));Object.keys(e.htmlCls.shownMenus).length==Object.keys(e.htmlCls.allMenus).length?$(".icn3d-menusep").show():$(".icn3d-menusep").hide(),localStorage&&localStorage.setItem("hiddenmenus",JSON.stringify(t))}getHiddenMenusFromCache(){let e=this.icn3dui;e.icn3d,e.htmlCls.shownMenus={};let t=localStorage?localStorage.getItem("hiddenmenus"):"";if(t&&"[]"!=t){let s=JSON.parse(t);for(let t in e.htmlCls.allMenus)-1==s.indexOf(t)&&(e.htmlCls.shownMenus[t]=1)}else e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.allMenus)}displayShownMenus(){let e=this.icn3dui;e.icn3d;let t="
    ";t+="",t+="";for(let s in e.htmlCls.allMenusSel){if("uniclr"==s.substr(0,6)||"mn5_opacity"==s.substr(0,11)||"mn6_labelscale"==s.substr(0,14)||"faq_"==s.substr(0,4)||"dev_"==s.substr(0,4))continue;"mn1_searchstru"==s?t+="
    FileSelectViewStyleColorAnalysisHelp
    ":("mn2_definedsets"==s||"mn2_show_selected"==s||"mn3_proteinwrap"==s||e.cfg.cid&&"mn3_ligwrap"==s||"mn4_clrwrap"==s||"mn6_selectannotations"==s||"abouticn3d"==s)&&(t+="");let i=e.htmlCls.shownMenus.hasOwnProperty(s)?"checked":"",n=e.htmlCls.allMenusSel[s];t+=""+e.htmlCls.allMenus[s]+"
    "}t+="
    ",$("#"+e.pre+"menulist").html(t)}clickMenu1(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds("#"+e.pre+"mn1_vastplus","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_vastplus","Please input PDB ID for VAST+")})),e.myEventCls.onIds("#"+e.pre+"mn1_vast","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_vast","Please input chain or PDB file for VAST")})),e.myEventCls.onIds("#"+e.pre+"mn1_foldseek","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_foldseek","Submit your selection to Foldseek")})),e.myEventCls.onIds("#"+e.pre+"mn1_mmtfid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmtfid","Please input MMTF ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_pdbid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pdbid","Please input PDB ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_afid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_afid","Please input AlphaFold UniProt ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_refseqid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_refseqid","Please input NCBI Protein Accession")})),e.myEventCls.onIds("#"+e.pre+"mn1_opmid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_opmid","Please input OPM PDB ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_align","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_align","Align two PDB structures")})),e.myEventCls.onIds("#"+e.pre+"mn1_alignaf","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_alignaf","Align two AlphaFold structures")})),e.myEventCls.onIds("#"+e.pre+"mn1_chainalign","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_chainalign","Align multiple chains by structure alignment")})),e.myEventCls.onIds("#"+e.pre+"mn1_chainalign2","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_chainalign2","Align multiple chains by sequence alignment")})),e.myEventCls.onIds("#"+e.pre+"mn1_chainalign3","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_chainalign3","Align multiple chains residue by residue")})),e.myEventCls.onIds("#"+e.pre+"mn1_mutation","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mutation","Show the mutations in 3D")})),e.myEventCls.onIds("#"+e.pre+"mn1_pdbfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pdbfile","Please input PDB File")})),e.myEventCls.onIds(["#"+e.pre+"mn1_pdbfile_app","#"+e.pre+"tool_pdbfile"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pdbfile_app","Please append PDB Files")})),e.myEventCls.onIds("#"+e.pre+"mn1_mol2file","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mol2file","Please input Mol2 File")})),e.myEventCls.onIds("#"+e.pre+"mn1_sdffile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_sdffile","Please input SDF File")})),e.myEventCls.onIds("#"+e.pre+"mn1_xyzfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_xyzfile","Please input XYZ File")})),e.myEventCls.onIds("#"+e.pre+"mn1_afmapfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_afmapfile","Please input AlphaFold PAE File")})),e.myEventCls.onIds("#"+e.pre+"mn1_urlfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_urlfile","Load data by URL")})),e.myEventCls.onIds("#"+e.pre+"mn1_fixedversion","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_fixedversion","Open Share Link URL in the archived version of iCn3D")})),e.myEventCls.onIds("#"+e.pre+"reload_fixedversion","click",(function(s){let i=e.icn3d,n=$("#"+e.pre+"sharelinkurl").val();t.setLogCmd("open "+n,!1),localStorage.setItem("fixedversion","1");let l=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(n,l)})),e.myEventCls.onIds("#"+e.pre+"mn1_mmciffile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmciffile","Please input mmCIF File")})),e.myEventCls.onIds("#"+e.pre+"mn1_mmcifid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmcifid","Please input mmCIF ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_mmdbid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmdbid","Please input MMDB or PDB ID")})),e.myEventCls.onIds(["#"+e.pre+"mn1_mmdbafid",,"#"+e.pre+"tool_mmdbafid"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmdbafid","Please input PDB/MMDB/AlphaFold UniProt IDs")})),e.myEventCls.onIds("#"+e.pre+"mn1_blast_rep_id","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_blast_rep_id","Align sequence to structure")})),e.myEventCls.onIds("#"+e.pre+"mn1_gi","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_gi","Please input protein gi")})),e.myEventCls.onIds("#"+e.pre+"mn1_cid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_cid","Please input PubChem CID")})),e.myEventCls.onIds("#"+e.pre+"mn1_pngimage","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pngimage","Please input the PNG image")})),e.myEventCls.onIds("#"+e.pre+"mn1_state","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_state","Please input the state file")})),e.myEventCls.onIds("#"+e.pre+"mn1_selection","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_selection","Please input the selection file")})),e.myEventCls.onIds("#"+e.pre+"mn1_dsn6","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_dsn6","Please input the DSN6 file to display electron density map")})),e.myEventCls.onIds(["#"+e.pre+"mn1_delphi","#"+e.pre+"mn1_delphi2","#"+e.pre+"tool_delphi"],"click",(function(t){e.icn3d.loadPhiFrom="delphi",$("#"+e.pre+"dl_delphi_tabs").tabs(),e.htmlCls.dialogCls.openDlg("dl_delphi","Please set parameters to display DelPhi potential map")})),e.myEventCls.onIds("#"+e.pre+"mn1_phi","click",(function(t){e.icn3d.loadPhiFrom="phi",$("#"+e.pre+"dl_phi_tabs").tabs(),$("#"+e.pre+"phitab1_tabs").tabs(),$("#"+e.pre+"phitab2_tabs").tabs(),e.htmlCls.dialogCls.openDlg("dl_phi","Please input local phi or cube file to display DelPhi potential map")})),e.myEventCls.onIds("#"+e.pre+"mn1_phiurl","click",(function(t){e.icn3d.loadPhiFrom="phiurl",$("#"+e.pre+"dl_phiurl_tabs").tabs(),$("#"+e.pre+"phiurltab1_tabs").tabs(),$("#"+e.pre+"phiurltab2_tabs").tabs(),e.htmlCls.dialogCls.openDlg("dl_phiurl","Please input URL phi or cube file to display DelPhi potential map")})),e.myEventCls.onIds("#"+e.pre+"mn1_dsn6url","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_dsn6url","Please input the DSN6 file to display electron density map")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportState","click",(function(s){let i=e.icn3d;t.setLogCmd("export state file",!1);let n=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(n+"_statefile.txt","command")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportPdbRes","click",(function(s){e.icn3d,e.htmlCls.setHtmlCls.exportPdb(),t.setLogCmd("export pdb",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportSecondary","click",(function(s){e.icn3d,e.htmlCls.setHtmlCls.exportSecondary(),t.setLogCmd("export secondary structure",!0)})),e.myEventCls.onIds(["#"+e.pre+"delphipdb","#"+e.pre+"phipdb"],"click",(function(s){let i=e.icn3d,n=i.saveFileCls.getSelectedResiduePDB();t.setLogCmd("export PDB of selected residues",!1);let l=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(l+"_icn3d_residues.pdb","text",[n])})),e.myEventCls.onIds(["#"+e.pre+"delphipqr","#"+e.pre+"phipqr","#"+e.pre+"phiurlpqr"],"click",(async function(s){e.icn3d,await e.htmlCls.setHtmlCls.exportPqr(),t.setLogCmd("export pqr",!0)})),e.myEventCls.onIds("#"+e.pre+"profixpdb","click",(async function(s){let i=e.icn3d;await i.scapCls.exportPdbProfix(!1),t.setLogCmd("export pdb missing atoms",!0)})),e.myEventCls.onIds("#"+e.pre+"profixpdbh","click",(async function(s){let i=e.icn3d;await i.scapCls.exportPdbProfix(!0),t.setLogCmd("export pdb hydrogen",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportStl","click",(function(s){let i=e.icn3d;t.setLogCmd("export stl file",!1),i.export3DCls.exportStlFile("")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportVrml","click",(function(s){let i=e.icn3d;t.setLogCmd("export vrml file",!1),i.export3DCls.exportVrmlFile("")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportStlStab","click",(function(s){let i=e.icn3d;t.setLogCmd("export stl stabilizer file",!1),i.threeDPrintCls.hideStabilizer(),i.threeDPrintCls.resetAfter3Dprint(),i.threeDPrintCls.addStabilizer(),i.export3DCls.exportStlFile("_stab")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportVrmlStab","click",(function(s){let i=e.icn3d;t.setLogCmd("export vrml stabilizer file",!1),i.threeDPrintCls.hideStabilizer(),i.threeDPrintCls.resetAfter3Dprint(),i.threeDPrintCls.addStabilizer(),i.export3DCls.exportVrmlFile("_stab")})),e.myEventCls.onIds("#"+e.pre+"mn6_exportInteraction","click",(async function(s){let i=e.icn3d;t.setLogCmd("export interactions",!1),void 0!==e.cfg.mmdbid&&await i.viewInterPairsCls.retrieveInteractionData(),i.viewInterPairsCls.exportInteractions()})),e.myEventCls.onIds(["#"+e.pre+"mn1_exportCanvas","#"+e.pre+"saveimage"],"click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas",!1);await i.shareLinkCls.shareLink(!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas1","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 1",!0),i.scaleFactor=1,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas2","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 2",!0),i.scaleFactor=2,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas4","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 4",!0),i.scaleFactor=4,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas8","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 8",!0),i.scaleFactor=8,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCounts","click",(function(s){let i=e.icn3d;t.setLogCmd("export counts",!1);let n='

    Total Count for atoms with coordinates:
    ';n+="",n+="
    Structure CountChain CountResidue CountAtom Count
    "+Object.keys(i.structures).length+""+Object.keys(i.chains).length+""+Object.keys(i.residues).length+""+Object.keys(i.atoms).length+"

    ",n+="Counts by Chain for atoms with coordinates:
    ";let l=Object.keys(i.chains);for(let e=0,t=l.length;e"}n+="
    StructureChainResidue CountAtom Count
    "+r+""+o+""+Object.keys(a).length+""+Object.keys(i.chains[t]).length+"

    ";let r=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(r+"_counts.html","html",n)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportSelections","click",(function(s){let i=e.icn3d;t.setLogCmd("export all selections",!1),t.SetChainsAdvancedMenu();let n=i.saveFileCls.exportCustomAtoms(),l=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(l+"_selections.txt","text",[n])})),e.myEventCls.onIds("#"+e.pre+"mn1_exportSelDetails","click",(function(s){let i=e.icn3d;t.setLogCmd("export all selections with details",!1),t.SetChainsAdvancedMenu();let n=i.saveFileCls.exportCustomAtoms(!0),l=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(l+"_sel_details.txt","text",[n])})),e.myEventCls.onIds(["#"+e.pre+"mn1_sharelink","#"+e.pre+"tool_sharelink"],"click",(async function(t){let s=e.icn3d;await s.shareLinkCls.shareLink()})),e.myEventCls.onIds("#"+e.pre+"mn1_replayon","click",(async function(s){let i=e.icn3d;await i.resizeCanvasCls.replayon(),t.setLogCmd("replay on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_replayoff","click",(async function(s){let i=e.icn3d;await i.resizeCanvasCls.replayoff(),t.setLogCmd("replay off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_menuall","click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.allMenus),t.applyShownMenus()})),e.myEventCls.onIds("#"+e.pre+"mn1_menusimple","click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.simpleMenus),t.applyShownMenus()})),e.myEventCls.onIds("#"+e.pre+"mn1_menupref","click",(function(s){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_menupref","Select Menus"),t.getHiddenMenusFromCache(),t.displayShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"apply_menupref","#"+e.pre+"apply_menupref2"],"click",(function(s){e.icn3d;var i=document.querySelectorAll('form[name="'+e.pre+'selmenu"] input:checked');for(var n of(e.htmlCls.shownMenus={},i))e.htmlCls.shownMenus[n.value]=1;t.applyShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"reset_menupref","#"+e.pre+"reset_menupref2"],"click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.simpleMenus),t.applyShownMenus(),t.displayShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"reset_menupref_all","#"+e.pre+"reset_menupref_all2"],"click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.allMenus),t.applyShownMenus(),t.displayShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"savepref","#"+e.pre+"savepref2"],"click",(function(t){let s=e.icn3d,i="[";var n=document.querySelectorAll('form[name="'+e.pre+'selmenu"] input:not(:checked)');let l=0;for(var r of n)l>0&&(i+=", "),i+='"'+r.value+'"',++l;i+="]",s.saveFileCls.saveFile("icn3d_menus_pref.txt","text",[i])})),e.myEventCls.onIds("#"+e.pre+"reload_menupreffile","click",(function(s){e.icn3d,e.cfg.notebook||dialog.dialog("close");let i=$("#"+e.pre+"menupreffile")[0].files[0];if(i){e.htmlCls.setHtmlCls.fileSupport();let s=new FileReader;s.onload=function(s){let i=s.target.result,n=JSON.parse(i);e.htmlCls.shownMenus={};for(let t in e.htmlCls.allMenus)-1==n.indexOf(t)&&(e.htmlCls.shownMenus[t]=1);t.applyShownMenus(),t.displayShownMenus()},s.readAsText(i)}else alert("Please select a file before clicking 'Load'")})),e.myEventCls.onIds("#"+e.pre+"mn1_menuloadpref","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_menuloadpref","Please input the menu preference file")})),e.myEventCls.onIds("#"+e.pre+"mn1_link_structure","click",(function(t){let s=e.icn3d,i=s.saveFileCls.getLinkToStructureSummary(!0),n=s.structures&&Object.keys(s.structures).length>0?"_blank":"_self";window.open(i,n)})),e.myEventCls.onIds("#"+e.pre+"mn1_link_bind","click",(function(s){let i=e.icn3d;url="https://www.ncbi.nlm.nih.gov/pccompound?LinkName=pccompound_structure&from_uid="+i.inputid,t.setLogCmd("link to 3D protein structures bound to CID "+i.inputid+": "+url,!1);let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(url,n)})),e.myEventCls.onIds("#"+e.pre+"mn1_link_vast","click",(function(s){let i=e.icn3d;if(void 0===i.inputid)url="https://www.ncbi.nlm.nih.gov/pccompound?term="+i.molTitle,t.setLogCmd("link to compounds "+i.molTitle+": "+url,!1);else{let s;if(void 0!==e.cfg.cid)s="https://www.ncbi.nlm.nih.gov/pccompound?LinkName=pccompound_pccompound_3d&from_uid="+i.inputid,t.setLogCmd("link to compounds with structure similar to CID "+i.inputid+": "+s,!1);else{let n=i.inputid.split("_");1===n.length?(s=e.htmlCls.baseUrl+"vastplus/vastplus.cgi?uid="+i.inputid,t.setLogCmd("link to structures similar to "+i.inputid+": "+s,!1)):2===n.length&&(s=e.htmlCls.baseUrl+"vastplus/vastplus.cgi?uid="+n[0],t.setLogCmd("link to structures similar to "+n[0]+": "+s,!1))}}let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(url,n)})),e.myEventCls.onIds("#"+e.pre+"mn1_link_pubmed","click",(function(s){let i=e.icn3d;if(void 0===i.inputid){let e;e="https://www.ncbi.nlm.nih.gov/pubmed/?term="+i.molTitle,t.setLogCmd("link to literature about "+i.molTitle+": "+e,!1);let s=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(e,s)}else if(i.pmid){let e,s=i.pmid.toString().split("_");1===s.length?(e="https://www.ncbi.nlm.nih.gov/pubmed/"+i.pmid,t.setLogCmd("link to PubMed ID "+i.pmid+": "+e,!1)):2===s.length&&(e="https://www.ncbi.nlm.nih.gov/pubmed/?term="+s[0]+" OR "+s[1],t.setLogCmd("link to PubMed IDs "+s[0]+", "+s[1]+": "+e,!1));let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(e,n)}else if(isNaN(i.inputid)){let e,s=i.inputid.toString().split("_");1===s.length?(e="https://www.ncbi.nlm.nih.gov/pubmed/?term="+i.inputid,t.setLogCmd("link to literature about PDB "+i.inputid+": "+e,!1)):2===s.length&&(e="https://www.ncbi.nlm.nih.gov/pubmed/?term="+s[0]+" OR "+s[1],t.setLogCmd("link to literature about PDB "+s[0]+" OR "+s[1]+": "+e,!1));let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(e,n)}else void 0!==e.cfg.cid?alert("No literature information is available for this compound in the SDF file."):alert("No literature information is available for this structure.")})),e.myEventCls.onIds("#"+e.pre+"mn1_link_protein","click",(function(s){let i=e.icn3d,n=Object.keys(i.structures),l=Object.keys(i.chains),r="";for(let e=0,t=l.length;e0&&(r=r.substr(0,r.length-4));let o="https://www.ncbi.nlm.nih.gov/protein/?term="+r;t.setLogCmd("link to Entrez protein about PDB "+n+": "+o,!1);let a=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(o,a)}))}clickMenu2(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds(["#"+e.pre+"mn6_selectannotations","#"+e.pre+"tool_selectannotations"],"click",(async function(s){let i=e.icn3d;await i.showAnnoCls.showAnnotations(),t.setLogCmd("view annotations",!0)})),e.myEventCls.onIds("#"+e.pre+"mn2_selectall","click",(function(s){let i=e.icn3d;t.setLogCmd("select all",!0),i.selectionCls.selectAll(),i.hlUpdateCls.removeHlAll(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"clearall","click",(function(s){let i=e.icn3d;t.setLogCmd("clear all",!0),i.bSelectResidue=!1,i.selectionCls.selectAll(),i.hlUpdateCls.removeHlAll(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn2_selectdisplayed","click",(function(s){let i=e.icn3d;t.setLogCmd("select displayed set",!0),i.hAtoms=e.hashUtilsCls.cloneHash(i.viewSelectionAtoms),i.hlUpdateCls.updateHlAll()})),e.myEventCls.onIds("#"+e.pre+"mn2_fullstru","click",(function(s){let i=e.icn3d;t.setLogCmd("show all",!0),i.selectionCls.showAll()})),e.myEventCls.onIds("#"+e.pre+"mn2_selectcomplement","click",(function(s){let i=e.icn3d;Object.keys(i.hAtoms).lengthnon-selected"+n),$("#"+e.pre+"atomsCustomSphere2").length&&$("#"+e.pre+"atomsCustomSphere2").html(" "+n),e.htmlCls.dialogCls.openDlg("dl_aroundsphere","Select a sphere around a set of residues"),i.bSphereCalc=!1,$("#"+e.pre+"atomsCustomSphere").resizable(),$("#"+e.pre+"atomsCustomSphere2").resizable()})),e.myEventCls.onIds(["#"+e.pre+"mn2_select_chain","#"+e.pre+"definedSets"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_select_chain","Select Structure/Chain/Custom Selection")}))}clickMenu3(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds(["#"+e.pre+"mn3_proteinsRibbon","#"+e.pre+"tool_proteinsRibbon"],"click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","ribbon"),t.setLogCmd("style proteins ribbon",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsStrand","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","strand"),t.setLogCmd("style proteins strand",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsCylinder","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","cylinder and plate"),t.setLogCmd("style proteins cylinder and plate",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsSchematic","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","schematic"),t.setLogCmd("style proteins schematic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsCalpha","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","c alpha trace"),t.setLogCmd("style proteins c alpha trace",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsBackbone","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","backbone"),t.setLogCmd("style proteins backbone",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsBfactor","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","b factor tube"),t.setLogCmd("style proteins b factor tube",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsLines","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","lines"),t.setLogCmd("style proteins lines",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsStick","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","stick"),t.setLogCmd("style proteins stick",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn3_proteinsBallstick","#"+e.pre+"tool_proteinsBallstick"],"click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","ball and stick"),t.setLogCmd("style proteins ball and stick",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn3_proteinsSphere","#"+e.pre+"tool_proteinsSphere"],"click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","sphere"),t.setLogCmd("style proteins sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsNo","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","nothing"),t.setLogCmd("style proteins nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecLines","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","lines2"),t.setLogCmd("style sidec lines2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecStick","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","stick2"),t.setLogCmd("style sidec stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","ball and stick2"),t.setLogCmd("style sidec ball and stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","sphere2"),t.setLogCmd("style sidec sphere2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecNo","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","nothing"),t.setLogCmd("style sidec nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseLines","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","lines2"),t.setLogCmd("style ntbase lines2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseStick","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","stick2"),t.setLogCmd("style ntbase stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","ball and stick2"),t.setLogCmd("style ntbase ball and stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","sphere2"),t.setLogCmd("style ntbase sphere2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseNo","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","nothing"),t.setLogCmd("style ntbase nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclCartoon","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","nucleotide cartoon"),t.setLogCmd("style nucleotides nucleotide cartoon",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclBackbone","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","backbone"),t.setLogCmd("style nucleotides backbone",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclSchematic","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","schematic"),t.setLogCmd("style nucleotides schematic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclPhos","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","o3 trace"),t.setLogCmd("style nucleotides o3 trace",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclLines","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","lines"),t.setLogCmd("style nucleotides lines",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclStick","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","stick"),t.setLogCmd("style nucleotides stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","ball and stick"),t.setLogCmd("style nucleotides ball and stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","sphere"),t.setLogCmd("style nucleotides sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclNo","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","nothing"),t.setLogCmd("style nucleotides nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligLines","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","lines"),t.setLogCmd("style chemicals lines",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligStick","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","stick"),t.setLogCmd("style chemicals stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","ball and stick"),t.setLogCmd("style chemicals ball and stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligSchematic","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","schematic"),t.setLogCmd("style chemicals schematic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","sphere"),t.setLogCmd("style chemicals sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligNo","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","nothing"),t.setLogCmd("style chemicals nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_glycansCartYes","click",(function(s){let i=e.icn3d;i.bGlycansCartoon=!0,i.drawCls.draw(),t.setLogCmd("glycans cartoon yes",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_glycansCartNo","click",(function(s){let i=e.icn3d;i.bGlycansCartoon=!1,i.drawCls.draw(),t.setLogCmd("glycans cartoon no",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_hydrogensYes","click",(function(s){let i=e.icn3d;i.showInterCls.showHydrogens(),i.drawCls.draw(),t.setLogCmd("hydrogens",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_hydrogensNo","click",(function(s){let i=e.icn3d;i.showInterCls.hideHydrogens(),i.drawCls.draw(),t.setLogCmd("set hydrogens off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ionsSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("ions","sphere"),t.setLogCmd("style ions sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ionsDot","click",(function(s){e.icn3d.setOptionCls.setStyle("ions","dot"),t.setLogCmd("style ions dot",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ionsNo","click",(function(s){e.icn3d.setOptionCls.setStyle("ions","nothing"),t.setLogCmd("style ions nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_waterSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("water","sphere"),t.setLogCmd("style water sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_waterDot","click",(function(s){e.icn3d.setOptionCls.setStyle("water","dot"),t.setLogCmd("style water dot",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_waterNo","click",(function(s){e.icn3d.setOptionCls.setStyle("water","nothing"),t.setLogCmd("style water nothing",!0)}))}clickMenu4(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrum","click",(function(s){e.icn3d.setOptionCls.setOption("color","spectrum"),t.setLogCmd("color spectrum",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrumChain","click",(function(s){e.icn3d.setOptionCls.setOption("color","spectrum for chains"),t.setLogCmd("color spectrum for chains",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrumAcrossSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorSpectrumAcross").length&&$("#"+e.pre+"atomsCustomColorSpectrumAcross").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorspectrumacrosssets","Please select sets to apply spectrum color for sets"),$("#"+e.pre+"atomsCustomColorSpectrumAcross").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrumSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorSpectrum").length&&$("#"+e.pre+"atomsCustomColorSpectrum").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorspectrumbysets","Please select sets to apply spectrum color for residues"),$("#"+e.pre+"atomsCustomColorSpectrum").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrRainbowAcrossSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorRainbowAcross").length&&$("#"+e.pre+"atomsCustomColorRainbowAcross").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorrainbowacrosssets","Please select sets to apply rainbow color for sets"),$("#"+e.pre+"atomsCustomColorRainbowAcross").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrRainbowSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorRainbow").length&&$("#"+e.pre+"atomsCustomColorRainbow").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorrainbowbysets","Please select sets to apply rainbow color for residues"),$("#"+e.pre+"atomsCustomColorRainbow").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrRainbow","click",(function(s){e.icn3d.setOptionCls.setOption("color","rainbow"),t.setLogCmd("color rainbow",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrRainbowChain","#"+e.pre+"tool_clrRainbowChain"],"click",(function(s){e.icn3d.setOptionCls.setOption("color","rainbow for chains"),t.setLogCmd("color rainbow for chains",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrChain","#"+e.pre+"tool_clrChain"],"click",(function(s){e.icn3d.setOptionCls.setOption("color","chain"),t.setLogCmd("color chain",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrStructure","click",(function(s){e.icn3d.setOptionCls.setOption("color","structure"),t.setLogCmd("color structure",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrdomain","click",(function(s){e.icn3d.setOptionCls.setOption("color","domain"),t.setLogCmd("color domain",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrsets","click",(function(s){e.icn3d.setOptionCls.setOption("color","defined sets"),t.setLogCmd("color defined sets",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrSSGreen","#"+e.pre+"tool_clrSSGreen"],"click",(function(s){let i=e.icn3d;i.sheetcolor="green",i.setOptionCls.setOption("color","secondary structure green"),t.setLogCmd("color secondary structure green",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSSYellow","click",(function(s){let i=e.icn3d;i.sheetcolor="yellow",i.setOptionCls.setOption("color","secondary structure yellow"),t.setLogCmd("color secondary structure yellow",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSSSpectrum","click",(function(s){e.icn3d.setOptionCls.setOption("color","secondary structure spectrum"),t.setLogCmd("color secondary structure spectrum",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrResidue","click",(function(s){e.icn3d.setOptionCls.setOption("color","residue"),t.setLogCmd("color residue",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrResidueCustom","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_rescolorfile","Please input the file on residue colors")})),e.myEventCls.onIds("#"+e.pre+"reload_rescolorfile","click",(function(s){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close");let n=$("#"+e.pre+"rescolorfile")[0].files[0];if(n){e.htmlCls.setHtmlCls.fileSupport();let s=new FileReader;s.onload=function(s){let n=s.target.result.replace(/#/g,"");i.customResidueColors=JSON.parse(n);for(let t in i.customResidueColors)i.customResidueColors[t.toUpperCase()]=e.parasCls.thr("#"+i.customResidueColors[t]);i.setOptionCls.setOption("color","residue custom"),t.setLogCmd("color residue custom | "+n,!0)},s.readAsText(n)}else alert("Please select a file before clicking 'Load'")})),e.myEventCls.onIds("#"+e.pre+"reload_customcolorfile","click",(function(s){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close"),i.startColor=$("#"+e.pre+"startColor").val(),i.midColor=$("#"+e.pre+"midColor").val(),i.endColor=$("#"+e.pre+"endColor").val();let n=t.setLegendHtml();$("#"+e.pre+"dl_legend").html(n),e.htmlCls.dialogCls.openDlg("dl_legend","Color range"),i.addTrackCls.setCustomFile("color",i.startColor,i.midColor,i.endColor)})),e.myEventCls.onIds("#"+e.pre+"mn6_customref","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_customref","Set custom reference numbers")})),e.myEventCls.onIds("#"+e.pre+"reload_customreffile","click",(function(s){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close");let n=$("#"+i.pre+"cstreffile")[0].files[0];if(n){e.utilsCls.checkFileAPI();let s=new FileReader;s.onload=async function(e){let s=e.target.result;await i.refnumCls.parseCustomRefFile(s),s=s.replace(/\r/g,"").replace(/\n/g,"\\n"),t.setLogCmd("custom refnum | "+s,!0)},s.readAsText(n)}else alert("Please select a file before clicking 'Apply'")})),e.myEventCls.onIds("#"+e.pre+"remove_legend","click",(function(s){e.icn3d,$("#"+e.pre+"legend").hide(),t.setLogCmd("remove legend",!0)})),e.myEventCls.onIds("#"+e.pre+"reload_customtubefile","click",(function(t){let s=e.icn3d;e.cfg.notebook||dialog.dialog("close"),s.addTrackCls.setCustomFile("tube")})),e.myEventCls.onIds("#"+e.pre+"mn4_clrCharge","click",(function(s){e.icn3d.setOptionCls.setOption("color","charge"),t.setLogCmd("color charge",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrHydrophobic","click",(function(s){e.icn3d.setOptionCls.setOption("color","hydrophobic"),t.setLogCmd("color hydrophobic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrNormalizedHP","click",(function(s){e.icn3d.setOptionCls.setOption("color","normalized hydrophobic"),t.setLogCmd("color normalized hydrophobic",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrAtom","#"+e.pre+"tool_clrAtom"],"click",(function(s){e.icn3d.setOptionCls.setOption("color","atom"),t.setLogCmd("color atom",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrBfactor","click",(function(s){e.icn3d.setOptionCls.setOption("color","b factor"),t.setLogCmd("color b factor",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrConfidence","click",(function(s){e.icn3d.setOptionCls.setOption("color","confidence"),t.setLogCmd("color confidence",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrIgstrand","click",(function(s){e.icn3d.setOptionCls.setOption("color","ig strand"),t.setLogCmd("color ig strand",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrArea","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_colorbyarea","Color based on residue's solvent accessibility")})),e.myEventCls.onIds("#"+e.pre+"applycolorbyarea","click",(function(s){let i=e.icn3d;i.midpercent=$("#"+e.pre+"midpercent").val(),i.setOptionCls.setOption("color","area"),t.setLogCmd("color area | "+i.midpercent,!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrBfactorNorm","click",(function(s){e.icn3d.setOptionCls.setOption("color","b factor percentile"),t.setLogCmd("color b factor percentile",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrIdentity","click",(function(s){e.icn3d.setOptionCls.setOption("color","identity"),t.setLogCmd("color identity",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrConserved","click",(function(s){e.icn3d.setOptionCls.setOption("color","conservation"),t.setLogCmd("color conservation",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrCustom","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_clr","Color picker")})),$(document).on("click",".icn3d-color-rad-text",(function(s){let i=e.icn3d;s.stopImmediatePropagation(),s.preventDefault();let n=$(this).attr("color");i.setOptionCls.setOption("color",n),t.setLogCmd("color "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSave","click",(function(s){e.icn3d.setOptionCls.saveColor(),t.setLogCmd("save color",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrApplySave","click",(function(s){e.icn3d.setOptionCls.applySavedColor(),t.setLogCmd("apply saved color",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_styleSave","click",(function(s){e.icn3d.setOptionCls.saveStyle(),t.setLogCmd("save style",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_styleApplySave","click",(function(s){e.icn3d.setOptionCls.applySavedStyle(),t.setLogCmd("apply saved style",!0)}))}clickMenu5(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds("#"+e.pre+"mn5_neighborsYes","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.applyMapCls.removeLastSurface(),i.applyMapCls.applySurfaceOptions(),i.bRender&&i.drawCls.render(),t.setLogCmd("set surface neighbors on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_neighborsNo","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.applyMapCls.removeLastSurface(),i.applyMapCls.applySurfaceOptions(),i.bRender&&i.drawCls.render(),t.setLogCmd("set surface neighbors off",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn5_surfaceVDW","#"+e.pre+"tool_surfaceVDW"],"click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.setOptionCls.setOption("surface","Van der Waals surface"),t.setLogCmd("set surface Van der Waals surface",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceSAS","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.setOptionCls.setOption("surface","solvent accessible surface"),t.setLogCmd("set surface solvent accessible surface",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceMolecular","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.setOptionCls.setOption("surface","molecular surface"),t.setLogCmd("set surface molecular surface",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceVDWContext","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.setOptionCls.setOption("surface","Van der Waals surface with context"),t.setLogCmd("set surface Van der Waals surface with context",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceSASContext","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.setOptionCls.setOption("surface","solvent accessible surface with context"),t.setLogCmd("set surface solvent accessible surface with context",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceMolecularContext","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.setOptionCls.setOption("surface","molecular surface with context"),t.setLogCmd("set surface molecular surface with context",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceNo","click",(function(s){e.icn3d.setOptionCls.setOption("surface","nothing"),t.setLogCmd("set surface nothing",!0)})),$(document).on("click","."+e.pre+"mn5_opacity",(function(s){let i=e.icn3d;i.transparentRenderOrder=!1;let n=$(this).attr("v");i.setOptionCls.setOption("opacity",n),t.setLogCmd("set surface opacity "+n,!0)})),$(document).on("click","."+e.pre+"mn5_opacityslow",(function(s){let i=e.icn3d;i.transparentRenderOrder=!0;let n=$(this).attr("v");i.setOptionCls.setOption("opacity",n),t.setLogCmd("set surface2 opacity "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_wireframeYes","click",(function(s){e.icn3d.setOptionCls.setOption("wireframe","yes"),t.setLogCmd("set surface wireframe on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_wireframeNo","click",(function(s){e.icn3d.setOptionCls.setOption("wireframe","no"),t.setLogCmd("set surface wireframe off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_elecmap2fofc","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_elecmap2fofc","2Fo-Fc Electron Density Map")})),e.myEventCls.onIds("#"+e.pre+"mn5_elecmapfofc","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_elecmapfofc","Fo-Fc Electron Density Map")})),e.myEventCls.onIds(["#"+e.pre+"mn5_elecmapNo","#"+e.pre+"elecmapNo2","#"+e.pre+"elecmapNo3","#"+e.pre+"elecmapNo4","#"+e.pre+"elecmapNo5"],"click",(function(s){e.icn3d.setOptionCls.setOption("map","nothing"),t.setLogCmd("setoption map nothing",!0)})),e.myEventCls.onIds(["#"+e.pre+"delphimapNo","#"+e.pre+"phimapNo","#"+e.pre+"phiurlmapNo","#"+e.pre+"mn1_phimapNo"],"click",(function(s){e.icn3d.setOptionCls.setOption("phimap","nothing"),t.setLogCmd("setoption phimap nothing",!0)})),e.myEventCls.onIds(["#"+e.pre+"delphimapNo2","#"+e.pre+"phimapNo2","#"+e.pre+"phiurlmapNo2"],"click",(function(s){e.icn3d.setOptionCls.setOption("phisurface","nothing"),t.setLogCmd("setoption phisurface nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"applymap2fofc","click",(function(s){let i=e.icn3d,n=parseFloat($("#"+e.pre+"sigma2fofc").val());i.dsn6ParserCls.dsn6Parser(i.inputid,"2fofc",n),t.setLogCmd("set map 2fofc sigma "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"applymapfofc","click",(function(s){let i=e.icn3d,n=parseFloat($("#"+e.pre+"sigmafofc").val());i.dsn6ParserCls.dsn6Parser(i.inputid,"fofc",n),t.setLogCmd("set map fofc sigma "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_mapwireframeYes","click",(function(s){e.icn3d.setOptionCls.setOption("mapwireframe","yes"),t.setLogCmd("set map wireframe on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_mapwireframeNo","click",(function(s){e.icn3d.setOptionCls.setOption("mapwireframe","no"),t.setLogCmd("set map wireframe off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_emmap","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_emmap","EM Density Map")})),e.myEventCls.onIds(["#"+e.pre+"mn5_emmapNo","#"+e.pre+"emmapNo2"],"click",(function(s){e.icn3d.setOptionCls.setOption("emmap","nothing"),t.setLogCmd("setoption emmap nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"applyemmap","click",(function(s){let i=e.icn3d,n=parseFloat($("#"+e.pre+"empercentage").val());i.densityCifParserCls.densityCifParser(i.inputid,"em",n,i.emd),t.setLogCmd("set emmap percentage "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_emmapwireframeYes","click",(function(s){e.icn3d.setOptionCls.setOption("emmapwireframe","yes"),t.setLogCmd("set emmap wireframe on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_emmapwireframeNo","click",(function(s){e.icn3d.setOptionCls.setOption("emmapwireframe","no"),t.setLogCmd("set emmap wireframe off",!0)}))}clickMenu6(){let e=this.icn3dui,t=e.icn3d;if(e.bNode)return;let s=this;e.myEventCls.onIds("#"+e.pre+"mn6_assemblyYes","click",(function(t){let i=e.icn3d;i.bAssembly=!0,s.setLogCmd("set assembly on",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_assemblyNo","click",(function(t){let i=e.icn3d;i.bAssembly=!1,s.setLogCmd("set assembly off",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_igrefYes","click",(async function(t){let i=e.icn3d;s.setLogCmd("ig refnum on",!0),await i.refnumCls.showIgRefNum()})),e.myEventCls.onIds("#"+e.pre+"mn6_igrefNo","click",(async function(t){let i=e.icn3d;s.setLogCmd("ig refnum off",!0),await i.refnumCls.hideIgRefNum()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelAtoms","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addAtomLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add atom labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelElements","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addAtomLabels(i.hAtoms,!0),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add element labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelResidues","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addResidueLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add residue labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelResnum","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addResidueLabels(i.hAtoms,void 0,void 0,!0),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add residue number labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelChains","click",(function(t){let i=e.icn3d;i.analysisCls.addChainLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add chain labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelTermini","click",(function(t){let i=e.icn3d;i.analysisCls.addTerminiLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add terminal labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelYes","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_addlabel","Add custom labels by selection"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelSelection","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_addlabelselection","Add custom labels by the selected")})),e.myEventCls.onIds("#"+e.pre+"mn6_labelColor","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_labelColor","Change color for all labels")})),e.myEventCls.onIds(["#"+e.pre+"mn2_saveselection","#"+e.pre+"tool_saveselection"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_saveselection","Save the selected")})),e.myEventCls.onIds(["#"+e.pre+"mn6_addlabelNo","#"+e.pre+"removeLabels"],"click",(function(t){let i=e.icn3d;i.labelcolor=void 0,i.pickpair=!1;s.setLogCmd("set labels off",!0);for(let e in i.labels)i.labels[e]=[];i.drawCls.draw()})),$(document).on("click","."+e.pre+"mn6_labelscale",(function(t){let i=e.icn3d,n=$(this).attr("v");i.labelScale=n,i.drawCls.draw(),s.setLogCmd("set label scale "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_distanceYes","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_distance","Measure the distance of atoms"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0,s.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_distTwoSets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_disttwosets","Measure the distance between two sets"),s.setSetsMenus("atomsCustomDist"),i.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_distManySets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_distmanysets","Measure the pairwise distance among many sets"),s.setSetsMenus("atomsCustomDistTable"),i.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_distanceNo","click",(function(t){let i=e.icn3d;i.pickpair=!1;s.setLogCmd("set lines off",!0),i.labels.distance=[],i.lines.distance=[],i.distPnts=[],i.pk=2,i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn5_cartoonshape","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_cartoonshape","Draw cartoon for a set");s.setSetsMenus("cartoonshape",!0),i.bCartoonshape=!0})),e.myEventCls.onIds("#"+e.pre+"mn5_linebtwsets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_linebtwsets","Draw a line between two sets"),s.setSetsMenus("linebtwsets"),i.bLinebtwsets=!0})),e.myEventCls.onIds(["#"+e.pre+"mn2_selectedcenter","#"+e.pre+"zoomin_selection","#"+e.pre+"tool_selectedcenter"],"click",(function(t){let i=e.icn3d;i.transformCls.zoominSelection(),i.drawCls.draw(),s.setLogCmd("zoom selection",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_center","click",(function(t){let i=e.icn3d;i.applyCenterCls.centerSelection(),i.drawCls.draw(),s.setLogCmd("center selection",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_resetOrientation","#"+e.pre+"resetOrientation","#"+e.pre+"tool_resetOrientation"],"click",(function(t){let i=e.icn3d;i.transformCls.resetOrientation(),i.drawCls.draw(),s.setLogCmd("reset orientation",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_chemicalbindingshow","#"+e.pre+"chemicalbindingshow"],"click",(function(t){e.icn3d.setOptionCls.setOption("chemicalbinding","show"),s.setLogCmd("set chemicalbinding show",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_chemicalbindinghide","#"+e.pre+"chemicalbindinghide"],"click",(function(t){e.icn3d.setOptionCls.setOption("chemicalbinding","hide"),s.setLogCmd("set chemicalbinding hide",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_sidebyside","click",(function(t){let i=e.icn3d;if(i.bInputfile)return void alert("Side-by-Side does NOT work when the input is from a local file.");let n=i.shareLinkCls.shareLinkUrl(void 0);n=n.replace("full.html","full2.html"),n+="&closepopup=1";let l=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(n,l),s.setLogCmd("side by side | "+n,!0)})),$(document).on("click","."+e.pre+"mn6_rotate",(function(t){let i=e.icn3d,n=$(this).attr("v").toLowerCase(),l=n.split(" ")[1];s.setLogCmd(n,!0),i.bStopRotate=!1,i.transformCls.rotateCount=0,i.transformCls.rotateCountMax=6e3,i.ROT_DIR=l,i.resizeCanvasCls.rotStruc(l)})),$(document).on("click","."+e.pre+"mn6_rotate90",(function(t){let i,n=e.icn3d,l=$(this).attr("v").toLowerCase(),r=l.split("-")[0];s.setLogCmd(l,!0),"x"==r?i=new THREE.Vector3(1,0,0):"y"==r?i=new THREE.Vector3(0,1,0):"z"==r&&(i=new THREE.Vector3(0,0,1));let o=.5*Math.PI;n.transformCls.setRotation(i,o)})),e.myEventCls.onIds("#"+e.pre+"mn6_cameraPers","click",(function(t){e.icn3d.setOptionCls.setOption("camera","perspective"),s.setLogCmd("set camera perspective",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_cameraOrth","click",(function(t){e.icn3d.setOptionCls.setOption("camera","orthographic"),s.setLogCmd("set camera orthographic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_bkgdBlack","click",(function(t){e.icn3d.setStyleCls.setBackground("black")})),e.myEventCls.onIds("#"+e.pre+"tool_bkgd","click",(function(t){let s=e.icn3d;"black"==s.opts.background?s.setStyleCls.setBackground("white"):s.setStyleCls.setBackground("black")})),e.myEventCls.onIds("#"+e.pre+"mn6_bkgdGrey","click",(function(t){e.icn3d.setStyleCls.setBackground("grey")})),e.myEventCls.onIds(["#"+e.pre+"mn6_bkgdWhite","#"+e.pre+"tool_bkgdWhite"],"click",(function(t){e.icn3d.setStyleCls.setBackground("white")})),e.myEventCls.onIds("#"+e.pre+"mn6_bkgdTransparent","click",(function(t){e.icn3d.setStyleCls.setBackground("transparent")})),e.myEventCls.onIds("#"+e.pre+"mn6_showfogYes","click",(function(t){let i=e.icn3d;i.opts.fog="yes",i.fogCls.setFog(!0),i.drawCls.draw(),s.setLogCmd("set fog on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showfogNo","click",(function(t){let i=e.icn3d;i.opts.fog="no",i.fogCls.setFog(!0),i.drawCls.draw(),s.setLogCmd("set fog off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showslabYes","click",(function(t){e.icn3d.setOptionCls.setOption("slab","yes"),s.setLogCmd("set slab on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showslabNo","click",(function(t){e.icn3d.setOptionCls.setOption("slab","no"),s.setLogCmd("set slab off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showaxisYes","click",(function(t){e.icn3d.setOptionCls.setOption("axis","yes"),s.setLogCmd("set axis on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showaxisSel","click",(function(t){let i=e.icn3d;i.pc1=!0,i.axesCls.setPc1Axes(),s.setLogCmd("set pc1 axis",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showaxisNo","click",(function(t){let i=e.icn3d;i.pc1=!1,i.axes=[],i.setOptionCls.setOption("axis","no"),s.setLogCmd("set axis off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_symmetry","click",(async function(t){let s=e.icn3d;s.bAxisOnly=!1,await s.symdCls.retrieveSymmetry(Object.keys(s.structures)[0])})),e.myEventCls.onIds("#"+e.pre+"mn6_symd","click",(async function(t){let i=e.icn3d;i.bAxisOnly=!1,await i.symdCls.retrieveSymd(),i.bSymd=!0,s.setLogCmd("symd symmetry",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_clear_sym","click",(function(t){let i=e.icn3d;i.symdArray=[],i.drawCls.draw(),s.setLogCmd("clear symd symmetry",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_axes_only","click",(function(t){let i=e.icn3d;i.bAxisOnly=!0,i.drawCls.draw(),s.setLogCmd("show axis",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_area","click",(function(t){e.icn3d.analysisCls.calculateArea(),s.setLogCmd("area",!0)})),e.myEventCls.onIds("#"+e.pre+"applysymmetry","click",(function(t){let i=e.icn3d;i.bAxisOnly=!1;let n=$("#"+e.pre+"selectSymmetry").val();i.symmetrytitle="none"===n?void 0:n,i.drawCls.draw(),s.setLogCmd("symmetry "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"clearsymmetry","click",(function(t){let i=e.icn3d;i.symmetrytitle=void 0,i.drawCls.draw(),s.setLogCmd("symmetry none",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_hbondsYes","#"+e.pre+"hbondsYes"],"click",(function(t){let i=e.icn3d;s.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomHbond").length&&$("#"+e.pre+"atomsCustomHbond").html(" "+n),$("#"+e.pre+"atomsCustomHbond2").length&&$("#"+e.pre+"atomsCustomHbond2").html(" "+n),e.htmlCls.dialogCls.openDlg("dl_hbonds","Hydrogen bonds/interactions between two sets of atoms"),i.bHbondCalc=!1,$("#"+e.pre+"atomsCustomHbond").resizable(),$("#"+e.pre+"atomsCustomHbond2").resizable()})),e.myEventCls.onIds(["#"+e.pre+"mn6_contactmap"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_contact","Set contact map")})),e.myEventCls.onIds("#"+e.pre+"mn6_hbondsNo","click",(function(t){let s=e.icn3d;s.showInterCls.hideHbondsContacts(),s.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerYes","click",(function(t){let i=e.icn3d;i.threeDPrintCls.addStabilizer(),i.threeDPrintCls.prepareFor3Dprint(),s.setLogCmd("stabilizer",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerNo","click",(function(t){let i=e.icn3d;s.setLogCmd("set stabilizer off",!0),i.threeDPrintCls.hideStabilizer(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerOne","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_stabilizer","Add One Stabilizer"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerRmOne","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_stabilizer_rm","Remove One Stabilizer"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0})),e.myEventCls.onIds("#"+e.pre+"mn1_thicknessSet","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_thickness","Set Thickness for 3D Printing")})),e.myEventCls.onIds("#"+e.pre+"mn3_setThickness","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_thickness2","Style Preferences")})),e.myEventCls.onIds("#"+e.pre+"mn6_ssbondsYes","click",(function(t){let i=e.icn3d;s.setLogCmd("disulfide bonds",!0),i.showInterCls.showSsbonds()})),e.myEventCls.onIds("#"+e.pre+"mn6_ssbondsExport","click",(function(t){e.icn3d.viewInterPairsCls.exportSsbondPairs(),s.setLogCmd("export disulfide bond pairs",!1)})),e.myEventCls.onIds("#"+e.pre+"mn6_ssbondsNo","click",(function(t){let i=e.icn3d;i.opts.ssbonds="no";s.setLogCmd("set disulfide bonds off",!0),i.lines.ssbond=[],i.setOptionCls.setStyle("sidec","nothing")})),e.myEventCls.onIds("#"+e.pre+"mn6_clbondsYes","click",(function(t){let i=e.icn3d;s.setLogCmd("cross linkage",!0),i.showInterCls.showClbonds()})),e.myEventCls.onIds("#"+e.pre+"mn6_clbondsExport","click",(function(t){e.icn3d.viewInterPairsCls.exportClbondPairs(),s.setLogCmd("export cross linkage pairs",!1)})),e.myEventCls.onIds("#"+e.pre+"mn6_clbondsNo","click",(function(t){let i=e.icn3d;i.opts.clbonds="no";s.setLogCmd("set cross linkage off",!0),i.lines.clbond=[],i.setOptionCls.setStyle("sidec","nothing")})),$("#"+e.pre+"newvs2").on("submit",(function(){let s=t.saveFileCls.getAtomPDB(t.hAtoms);return $("#"+e.pre+"pdbstr").val(s),!0})),$("#"+e.pre+"fssubmit").on("click",(function(){let e=t.saveFileCls.getAtomPDB(t.hAtoms),s=window.open("","_blank");s.document.body.innerHTML="\n\nLoading Foldseek\n\n\n\n
    Foldseek is loading...
    \n",$.ajax({url:"https://search.foldseek.com/api/ticket",type:"POST",data:{q:e,database:["afdb50","afdb-swissprot","gmgcl_id","pdb100","afdb-proteome","mgnify_esm30"],mode:"3diaa"},dataType:"text",success:function(e){s.location="https://search.foldseek.com/queue/"+JSON.parse(e).id},error:function(e,t,s){console.log("Error in submitting data to Foldseek...")}})}))}setLogCmd(e,t,s){var i=this.icn3dui,n=i.icn3d;if(""===e.trim())return!1;let l=e.indexOf("|||");-1!==l&&(e=e.substr(0,l));let r={};if(r.factor=n._zoomFactor,r.mouseChange=n.mouseChange,r.quaternion={},r.quaternion._x=parseFloat(n.quaternion._x).toPrecision(5),r.quaternion._y=parseFloat(n.quaternion._y).toPrecision(5),r.quaternion._z=parseFloat(n.quaternion._z).toPrecision(5),r.quaternion._w=parseFloat(n.quaternion._w).toPrecision(5),t&&n.bAddCommands)if(n.STATENUMBER "+n.logs.join("\n> ")+"\n> "),$("#"+i.pre+"logtext")[0]&&$("#"+i.pre+"logtext").scrollTop($("#"+i.pre+"logtext")[0].scrollHeight)}n.setStyleCls.adjustIcon()}}class d{constructor(e){this.icn3dui=e}getLink(e,t,s,i){return this.icn3dui.htmlCls.setHtmlCls.getLink(e,t,s,i)}getMenuText(e,t,s,i,n){return this.icn3dui.htmlCls.setHtmlCls.getMenuText(e,t,s,i,n)}getMenuUrl(e,t,s,i,n){return this.icn3dui.htmlCls.setHtmlCls.getMenuUrl(e,t,s,i,n)}getMenuSep(){return this.icn3dui.htmlCls.setHtmlCls.getMenuSep()}getLinkWrapper(e,t,s,i,n,l){let r=this.icn3dui;return r.icn3d,r.htmlCls.setHtmlCls.getLinkWrapper(e,t,s,i,n,l)}getLinkWrapper2(e,t,s,i,n){let l=this.icn3dui;return l.icn3d,l.htmlCls.setHtmlCls.getLinkWrapper2(e,t,s,i,n)}getRadio(e,t,s,i,n,l){return this.icn3dui.htmlCls.setHtmlCls.getRadio(e,t,s,i,n,l)}getRadClr(e,t,s,i,n,l,r){return this.icn3dui.htmlCls.setHtmlCls.getRadioColor(e,t,s,i,n,l,r)}setTopMenusHtml(e,t,s){let i=this.icn3dui;if(i.bNode)return"";let n="black"==i.htmlCls.opts.background?i.htmlCls.GREYD:"black",l="";l+="
    ",l+=i.htmlCls.divStr+"popup' class='icn3d-text icn3d-popup'>
    ",l+=this.setReplayHtml(),l+="\x3c!--https://forum.jquery.com/topic/looking-for-a-jquery-horizontal-menu-bar--\x3e",l+=i.htmlCls.divStr+"mnlist' style='position:absolute; z-index:999; float:left; display:table-row; margin-top: -2px;'>",l+="";let r='",l+=r+this.setMenu2()+"",l+=r+this.setMenu2b()+"",l+=r+this.setMenu3()+"",l+=r+this.setMenu4()+"",l+=r+this.setMenu5()+"",l+=r+this.setMenu6()+"",i.htmlCls.shownMenus=i.hashUtilsCls.cloneHash(i.htmlCls.simpleMenus),l+=r+"
    "+t,l+="
    "+s,l+=r+'
    '+i.htmlCls.space2+'Toolbar '+i.htmlCls.space2+'
    ",l+=r+'
    '+i.htmlCls.space2+' ?
    ',l+="
    ",l+="
    ';if(l+=r+this.setMenu1()+"
    ",l+="",l+=this.setTools(),l+=i.htmlCls.divStr+"title' class='icn3d-commandTitle' style='font-size:1.2em; font-weight:normal; position:absolute; z-index:1; float:left; display:table-row; margin: 85px 0px 0px 5px; color:"+n+"; width:"+i.htmlCls.WIDTH+"px'>",l+=i.htmlCls.divStr+"viewer' style='position:relative; width:100%; height:100%; background-color: "+i.htmlCls.GREYD+";'>",l+=i.htmlCls.divStr+"mnLogSection'>",l+="
    ",l+=" ",void 0===i.cfg.mmtfid){let e="top:180px; font-size: 1.8em;";l+=i.htmlCls.divStr+"wait' style='position:absolute; left:50px; "+e+" color: #444444;'>Loading data..."}l+="Your browser does not support WebGL.",(void 0===i.cfg.showcommand||i.cfg.showcommand)&&(l+=this.setLogWindow()),l+="",l+="",l+=i.htmlCls.setDialogCls.setDialogs(),l+=i.htmlCls.setDialogCls.setCustomDialogs(),$("#"+e).html(l),$("accordion").accordion({collapsible:!0,active:!1,heightStyle:"content"}),$("accordion div").removeClass("ui-accordion-content ui-corner-all ui-corner-bottom ui-widget-content"),$(".icn3d-mn-item").menu({position:{my:"left top",at:"right top"}}),$(".icn3d-mn-item").hover((function(){}),(function(){$("accordion").accordion("option","active","none")})),$("#"+i.pre+"accordion1").hover((function(){$("#"+i.pre+"accordion1 div").css("display","block")}),(function(){$("#"+i.pre+"accordion1 div").css("display","none")})),$("#"+i.pre+"accordion2").hover((function(){$("#"+i.pre+"accordion2 div").css("display","block")}),(function(){$("#"+i.pre+"accordion2 div").css("display","none")})),$("#"+i.pre+"accordion2b").hover((function(){$("#"+i.pre+"accordion2b div").css("display","block")}),(function(){$("#"+i.pre+"accordion2b div").css("display","none")})),$("#"+i.pre+"accordion3").hover((function(){$("#"+i.pre+"accordion3 div").css("display","block")}),(function(){$("#"+i.pre+"accordion3 div").css("display","none")})),$("#"+i.pre+"accordion4").hover((function(){$("#"+i.pre+"accordion4 div").css("display","block")}),(function(){$("#"+i.pre+"accordion4 div").css("display","none")})),$("#"+i.pre+"accordion5").hover((function(){$("#"+i.pre+"accordion5 div").css("display","block")}),(function(){$("#"+i.pre+"accordion5 div").css("display","none")})),$("#"+i.pre+"accordion6").hover((function(){$("#"+i.pre+"accordion6 div").css("display","block")}),(function(){$("#"+i.pre+"accordion6 div").css("display","none")}))}setTopMenusHtmlMobile(e,t,s){let i=this.icn3dui;if(i.bNode)return"";let n="black"==i.htmlCls.opts.background?i.htmlCls.GREYD:"black",l="";if(l+="
    ",l+=i.htmlCls.divStr+"popup' class='icn3d-text icn3d-popup'>
    ",l+=this.setReplayHtml(),!i.utilsCls.isMobile()){let e=i.htmlCls.WIDTH-40+5;l+=i.htmlCls.buttonStr+"fullscreen' style='position:absolute; z-index:1999; display:block; padding:0px; margin: 12px 0px 0px "+e+"px; width:30px; height:34px; border-radius:4px; border:none; background-color:#f6f6f6;' title='Full screen'>",l+="",l+="",l+="",l+="",l+=""}l+="\x3c!--https://forum.jquery.com/topic/looking-for-a-jquery-horizontal-menu-bar--\x3e",l+=i.htmlCls.divStr+"mnlist' style='position:absolute; z-index:999; float:left; display:block; margin: 5px 0px 0px 5px;'>",l+="
    ",l+="",i.cfg.notebook?l+="

    ":l+="

    ",l+="
    ";let r="
  • File",l+=this.setMenu1_base(),l+=r+">Select",l+=this.setMenu2_base(),l+=r+">View",l+=this.setMenu2b_base(),l+=r+" id='"+i.pre+"style'>Style",l+=this.setMenu3_base(),l+=r+" id='"+i.pre+"color'>Color",l+=this.setMenu4_base(),l+=r+">Analysis",l+=this.setMenu5_base(),l+=r+">Help",l+=this.setMenu6_base(),i.htmlCls.shownMenus=i.hashUtilsCls.cloneHash(i.htmlCls.simpleMenus),l+="
  • "+t,l+="
    "+s,l+="
  • Alternate",l+="",l+="
  • ",l+="
    ",l+="
    ",l+="",l+=i.htmlCls.divStr+"title' class='icn3d-commandTitle' style='font-size:1.2em; font-weight:normal; position:absolute; z-index:1; float:left; display:block; margin: 12px 0px 0px 40px; color:"+n+"; width:"+(i.htmlCls.WIDTH-40).toString()+"px'>",l+=i.htmlCls.divStr+"viewer' style='position:relative; width:100%; height:100%; background-color: "+i.htmlCls.GREYD+";'>",l+=i.htmlCls.divStr+"mnLogSection'>",l+="
    ",l+="",void 0===i.cfg.mmtfid){let e="top:180px; font-size: 1.8em;";l+=i.htmlCls.divStr+"wait' style='position:absolute; left:50px; "+e+" color: #444444;'>Loading data..."}l+="Your browser does not support WebGL.",(void 0===i.cfg.showcommand||i.cfg.showcommand)&&(l+=this.setLogWindow()),l+="",l+="",l+=i.htmlCls.setDialogCls.setDialogs(),l+=i.htmlCls.setDialogCls.setCustomDialogs(),$("#"+e).html(l),$("accordion").accordion({collapsible:!0,active:!1,heightStyle:"content"}),$("accordion div").removeClass("ui-accordion-content ui-corner-all ui-corner-bottom ui-widget-content"),$(".icn3d-mn-item").menu({position:{my:"left top",at:"right top"}}),$(".icn3d-mn-item").hover((function(){}),(function(){$("accordion").accordion("option","active","none")})),$("#"+i.pre+"accordion0").hover((function(){$("#"+i.pre+"accordion0 div").css("display","block")}),(function(){$("#"+i.pre+"accordion0 div").css("display","none")}))}setReplayHtml(e){let t=this.icn3dui;if(t.bNode)return"";let s="";return s+=t.htmlCls.divStr+"replay' style='display:none; position:absolute; z-index:9999; top:"+parseInt(t.htmlCls.HEIGHT-100).toString()+"px; left:20px;'>",s+="
    ",s+='',s+="",s+='',s+='',s+="",s+="
    ",s+=t.htmlCls.divStr+"replay_menu' style='background-color:#DDDDDD; padding:3px; font-weight:bold;'>",s+=t.htmlCls.divStr+"replay_cmd' style='background-color:#DDDDDD; padding:3px; max-width:250px'>",s+="",s}setTools(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+=e.htmlCls.divStr+"selection' style='display:none;'>
    ",t+="",t+=this.setTools_base(),t+="
    ",t+="
    ",t}setButton(e,t,s,i,n){let l=this.icn3dui;return l.bNode?"":(n=void 0!==n?"color:"+n:"","
    ")}setIcon(e,t,s,i,n,l,r){let o=this.icn3dui;if(o.bNode)return"";let a,d=r?"color:#f8b84e; ":"color:#1c94c4; ",c=" background-color:#EEE; ",h="text"==e?"":"cursor:pointer;";return a=l?'
    '+i+"
    ":'',"link"==e?''+a+"":a}setTools_base(){if(this.icn3dui.bNode)return"";let e="",t="regular",s="",i="";return e+=s+this.setIcon(t,"tool_mmdbafid","Input PDB/MMDB/AlphaFold IDs","id",void 0,!0)+"",e+=s+this.setIcon(t,"tool_pdbfile","Input PDB Files (appendable)","file-alt")+"",e+=s+this.setIcon(t,"tool_sharelink","Get Share Link","link")+"",e+=s+this.setIcon(t,"saveimage","Save iCn3D PNG Image","camera")+"",e+=i+this.setIcon(t,"tool_definedsets","Defined Sets","object-group")+"",e+=s+this.setIcon(t,"tool_aroundsphere","Select by Distance","dot-circle")+"",e+=s+this.setIcon(t,"tool_saveselection","Save Selection as a Set","save")+"",e+=s+this.setIcon(t,"toggleHighlight","Toggle Highlight","highlighter")+"",e+=i+this.setIcon(t,"show_selected","View Selection","eye")+"",e+=s+this.setIcon(t,"tool_selectedcenter","Zoom in Selection","search-plus")+"",e+=s+this.setIcon(t,"alternate","Alternate the Structures by keying the letter 'a'","a",void 0,!0,!0)+"",e+=s+this.setIcon(t,"tool_resetOrientation","Reset Orientation","undo-alt")+"",e+=i+this.setIcon(t,"tool_proteinsRibbon","Style Ribbon for proteins","dna")+"",e+=s+this.setIcon(t,"tool_proteinsSphere","Style Sphere for proteins","volleyball-ball")+"",e+=s+this.setIcon(t,"tool_surfaceVDW","Show Van der Waals Surface","cloud")+"",e+=s+this.setIcon(t,"tool_bkgd","Toggle Background Color","adjust")+"",e+=i+this.setIcon(t,"tool_clrRainbowChain","Color Rainbow for Chains","rainbow")+"",e+=s+this.setIcon(t,"tool_clrSSGreen","Color by Secondary Structures","ring")+"",e+=s+this.setIcon(t,"tool_clrChain","Color by Chains","layer-group")+"",e+=s+this.setIcon(t,"tool_clrAtom","Color by Atoms","atom")+"",e+=i+this.setIcon(t,"tool_selectannotations","Sequences & Annotations","grip-lines")+"",e+=s+this.setIcon(t,"hbondsYes","Interactions","users")+"",e+=s+this.setIcon(t,"tool_delphi","Delphi Potentials","cloud-meatball")+"",e+=s+this.setIcon(t,"removeLabels","Remove Labels","remove-format")+"",e+=i+this.setIcon("link","tool-gallery","Gallery","image","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#gallery")+"",e+=s+this.setIcon("link","tool-video","Videos","file-video","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#videos")+"",e+=s+this.setIcon("link","tool-github","iCn3D GitHub","code","https://github.com/ncbi/icn3d")+"",e+=s+this.setIcon("link","tool-hints","Transform Hints","info-circle","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#useicn3d")+"",e+="",e}setTheme(e){let t,s,i,n,l,r=this.icn3dui;if(r.bNode)return"";r.htmlCls.themecolor=e,"orange"==e?(t="#e78f08",s="#f6a828",i="ui-bg_gloss-wave_35_f6a828_500x100.png",n="ui-icons_ef8c08_256x240.png",l="#eb8f00"):"black"==e?(t="#333333",s="#333333",i="ui-bg_gloss-wave_25_333333_500x100.png",n="ui-icons_222222_256x240.png",l="#222222"):"blue"==e&&(t="#4297d7",s="#5c9ccc",i="ui-bg_gloss-wave_55_5c9ccc_500x100.png",n="ui-icons_228ef1_256x240.png",l="#444"),$(".ui-widget-header").css({border:"1px solid "+t,background:s+' url("https://www.ncbi.nlm.nih.gov/Structure/icn3d/lib/images/'+i+'") 50% 50% repeat-x',color:"#fff","font-weight":"bold"}),$(".ui-button .ui-icon").css({"background-image":"url(https://www.ncbi.nlm.nih.gov/Structure/icn3d/lib/images/"+n+")"}),$(".ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited").css({color:l,"text-decoration":"none"})}setLogWindow(e,t){let s=this.icn3dui;if(s.bNode)return"";let i,n="",l=s.htmlCls.setHtmlCls.getCookie("cmdwindow");return""!=l?(i=void 0!==t?t:parseInt(l),1==i?(s.htmlCls.LOG_HEIGHT=180,s.htmlCls.CMD_HEIGHT=.8*s.htmlCls.LOG_HEIGHT,e||(n+=s.htmlCls.divStr+"cmdlog' style='float:left; margin-top: 5px; width: 100%;'>"),n+=""):(s.htmlCls.LOG_HEIGHT=65,s.htmlCls.CMD_HEIGHT=.8*s.htmlCls.LOG_HEIGHT,e||(n+=s.htmlCls.divStr+"cmdlog' style='float:left; margin-top: 5px; width: 100%;'>"),n+="")):(i=0,s.htmlCls.LOG_HEIGHT=65,s.htmlCls.CMD_HEIGHT=.8*s.htmlCls.LOG_HEIGHT,e||(n+=s.htmlCls.divStr+"cmdlog' style='float:left; margin-top: 5px; width: 100%;'>"),n+=""),e||(n+=""),e&&(s.htmlCls.clickMenuCls.setLogCmd("set cmdwindow "+i,!0),$("#"+s.pre+"cmdlog").html(n)),n}setMenu1(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
    ",t+="",t+="

    File

    ",t+="
    ",t+=this.setMenu1_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu1_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getMenuUrl("mn1_searchstru","https://www.ncbi.nlm.nih.gov/structure","Search Structure "+e.htmlCls.wifiStr,1,1),t+=this.getMenuText("mn1_searchsimilar","Search Similar",void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_vastplus","NCBI VAST+ (PDB Complex)"+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_vast","NCBI VAST (PDB Chain)"+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_foldseek","Foldseek (PDB & AlphaFold)"+e.htmlCls.wifiStr,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn1_retrievebyid","Retrieve by ID",void 0,1,1),t+="
        ",t+=this.getLink("mn1_mmdbafid","PDB/MMDB/AlphaFold IDs"+e.htmlCls.wifiStr,1,2),t+=this.getLink("mn1_mmdbid","NCBI MMDB ID (annotation) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_mmtfid","RCSB MMTF ID (fast) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_pdbid","RCSB PDB ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getMenuText("mn1_afwrap","AlphaFold Structures",void 0,void 0,2),t+="
          ",t+=this.getLink("mn1_afid","UniProt ID "+e.htmlCls.wifiStr,void 0,3),t+=this.getLink("mn1_refseqid","NCBI Protein Accession "+e.htmlCls.wifiStr,void 0,3),t+="
        ",t+=this.getLink("mn1_opmid","OPM PDB ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_mmcifid","RCSB mmCIF ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_cid","PubChem CID "+e.htmlCls.wifiStr,1,2),t+="
      ",t+="",t+=this.getMenuText("mn1_openfile","Open File",void 0,1,1),t+="
        ",t+=this.getLink("mn1_pdbfile_app","PDB Files (appendable)",1,2),t+=this.getLink("mn1_mmciffile","mmCIF File",void 0,2),t+=this.getLink("mn1_mol2file","Mol2 File",void 0,2),t+=this.getLink("mn1_sdffile","SDF File",void 0,2),t+=this.getLink("mn1_xyzfile","XYZ File",void 0,2),t+=this.getLink("mn1_afmapfile","AlphaFold PAE File",void 0,2),t+=this.getLink("mn1_urlfile","URL(CORS) "+e.htmlCls.wifiStr,void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_pngimage","iCn3D PNG Image",1,2),t+=this.getLink("mn1_state","State/Script File",void 0,2),t+=this.getLink("mn1_fixedversion","Share Link in Archived Ver. "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_selection","Selection File",void 0,2),t+=this.getMenuSep(),t+=this.getMenuText("mn1_dsn6wrap","Electron Density(DSN6)",void 0,void 0,2),t+="
          ",t+=this.getLink("mn1_dsn6","Local File",void 0,3),t+=this.getLink("mn1_dsn6url","URL(CORS) "+e.htmlCls.wifiStr,void 0,3),t+="
        ",t+="
      ",t+="",t+=this.getMenuText("mn1_alignwrap","Align",void 0,1,1),t+="
        ",t+=this.getMenuText("mn1_chainalignwrap","Multiple Chains",void 0,1,2),t+="
          ",t+=this.getRadio("mn1_chainalignRad","mn1_chainalign","by Structure Alignment "+e.htmlCls.wifiStr,void 0,1,3),t+=this.getRadio("mn1_chainalignRad","mn1_chainalign2","by Sequence Alignment "+e.htmlCls.wifiStr,void 0,1,3),t+=this.getRadio("mn1_chainalignRad","mn1_chainalign3","Residue by Residue",void 0,void 0,3),t+="
        ",t+="",t+=this.getMenuText("mn1_aligntwostru","Protein Complexes",void 0,void 0,2),t+="
          ",t+=this.getLink("mn1_align","Two PDB Structures "+e.htmlCls.wifiStr,void 0,3),t+=this.getLink("mn1_alignaf","Two AlphaFold Structures "+e.htmlCls.wifiStr,void 0,3),t+="
        ",t+=this.getLink("mn1_blast_rep_id","Sequence to Structure",void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_realignWrap","Realign Selection",void 0,void 0,1),t+="
        ",t+=this.getMenuText("mn2_chainrealignwrap","Multiple Chains",void 0,void 0,2),t+="
          ",t+=this.getRadio("mn2_realign","mn2_realignonstruct","by Structure Alignment "+e.htmlCls.wifiStr,void 0,void 0,3),t+=this.getRadio("mn2_realign","mn2_realignonseqalign","by Sequence Alignment "+e.htmlCls.wifiStr,void 0,void 0,3),t+=this.getRadio("mn2_realign","mn2_realignresbyres","Residue by Residue",void 0,void 0,3),t+="
        ",t+=this.getLink("mn2_realigntwostru","Protein Complexes",void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn1_3dpprint","3D Printing",void 0,1,1),t+="
        ",void 0===e.cfg.cid?(t+=this.getLink("mn1_exportVrmlStab","WRL/VRML(Color, W/ Stab.)",1,2),t+=this.getLink("mn1_exportStlStab","STL(W/ Stabilizers)",1,2),t+=this.getMenuSep(),t+=this.getLink("mn1_exportVrml","WRL/VRML(Color)",void 0,2),t+=this.getLink("mn1_exportStl","STL",void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_stabilizerYes","Add All Stabilizers",void 0,2),t+=this.getLink("mn1_stabilizerNo","Remove All Stabilizers",void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_stabilizerOne","Add One Stabilizer",void 0,2),t+=this.getLink("mn1_stabilizerRmOne","Remove One Stabilizer",void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_thicknessSet","Set Thickness",void 0,2)):(t+=this.getLink("mn1_exportVrml","VRML(Color)",1,2),t+=this.getLink("mn1_exportStl","STL",1,2)),t+="
      ",t+="",t+=this.getMenuText("mn1_savefile","Save File",void 0,1,1),t+="
        ",t+=this.getMenuText("mn1_savepngimage","iCn3D PNG Image",void 0,1,2),t+="
          ",t+=this.getLink("mn1_exportCanvas","Original Size & HTML",1,3),t+=this.getLink("mn1_exportCanvas1","Original Size",void 0,3),t+=this.getLink("mn1_exportCanvas2","2X Large",void 0,3),t+=this.getLink("mn1_exportCanvas4","4X Large",void 0,3),t+=this.getLink("mn1_exportCanvas8","8X Large",void 0,3),t+="
        ",t+="",t+=this.getLink("mn1_exportState","State File",void 0,2),t+=this.getLink("mn1_exportSelections","Selection File",void 0,2),t+=this.getLink("mn1_exportSelDetails","Selection Details",void 0,2),t+=this.getLink("mn1_exportCounts","Residue Counts",void 0,2),t+=this.getLink("mn1_exportPdbRes","PDB",1,2),t+=this.getLink("profixpdb","PDB with Missing Atoms",void 0,2),t+=this.getLink("profixpdbh","PDB with Hydrogens",void 0,2),void 0===e.cfg.cid&&(t+=this.getLink("mn1_exportSecondary","Secondary Structure",void 0,2)),t+="

      • ",t+="
      ",t+="",t+=this.getLink("mn1_sharelink","Share Link "+e.htmlCls.wifiStr,1,1),t+=this.getLink("mn1_replayon","Replay Each Step",void 0,1),t+=this.getMenuSep(),t+=this.getMenuText("mn1_menuwrap","Customize Menus",void 0,1,1),t+="
        ",t+=this.getLink("mn1_menuall","All Menus",1,2),t+=this.getLink("mn1_menusimple","Simple Menus",1,2),t+=this.getMenuSep(),t+=this.getLink("mn1_menupref","Preferences",1,2),t+=this.getLink("mn1_menuloadpref","Load Preferences",1,2),t+="
      ",t+="",t+="

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

    Select

    ",t+="
    ",t+=this.setMenu2_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu2_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getLink("mn2_definedsets","Defined Sets",1,1),t+=this.getLink("mn2_selectall","All",void 0,1),t+=this.getLink("mn2_selectdisplayed","Displayed Set",void 0,1),t+=this.getLink("mn2_aroundsphere","by Distance",1,1),t+=this.getMenuText("mn2_selbyprop","by Property",void 0,void 0,1),t+="
        ",t+=this.getLink("mn2_propPos","Positive",void 0,2),t+=this.getLink("mn2_propNeg","Negative",void 0,2),t+=this.getLink("mn2_propHydro","Hydrophobic",void 0,2),t+=this.getLink("mn2_propPolar","Polar",void 0,2),t+=this.getLink("mn2_propBfactor","B-factor/pLDDT",void 0,2),t+=this.getLink("mn2_propSolAcc","Solvent Accessibility",void 0,2),t+="
      ",t+="",t+=this.getLink("mn2_selectcomplement","Inverse",void 0,1),t+=this.getLink("mn2_selectmainchains","Main Chains",void 0,1),t+=this.getLink("mn2_selectsidechains","Side Chains",void 0,1),t+=this.getLink("mn2_selectmainsidechains","Main & Side Chains",void 0,1),t+=this.getLink("mn2_command","Advanced",void 0,1),void 0===e.cfg.cid?(t+=this.getMenuText("mn2_selon3d","Select on 3D",void 0,1,1),t+="
        ",t+='
      • "Alt"+Click: start selection
      • ',t+='
      • "Ctrl"+Click: union selection
      • ',t+='
      • "Shift"+Click: range Selection
      • ',t+=this.getMenuSep(),t+=this.getRadio("mn2_pk","mn2_pkChain","Chain",void 0,1,2),void 0===e.cfg.mmdbid&&void 0===e.cfg.gi||(t+=this.getRadio("mn2_pk","mn2_pkDomain","3D Domain",void 0,void 0,2)),t+=this.getRadio("mn2_pk","mn2_pkStrand","Strand/Helix",void 0,void 0,2),t+=this.getRadio("mn2_pk","mn2_pkResidue","Residue",!0,1,2),t+=this.getRadio("mn2_pk","mn2_pkYes","Atom",void 0,1,2),t+=this.getRadio("mn2_pk","mn2_pkNo","None",void 0,void 0,2),t+="
      ",t+=""):e.utilsCls.isMobile()?t+="
    • Touch to pick
    • ":t+='
    • Picking with
      "Alt" + Click
    • ',t+=this.getMenuSep(),t+=this.getLink("mn2_saveselection","Save Selection",1,1),t+=this.getLink("clearall","Clear Selection",void 0,1),t+=this.getLink("mn2_saveresidue","Save Res. in Sel.",1,1),t+=this.getMenuSep(),t+=this.getMenuText("mn2_hlcolor","Highlight Color",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn2_hl_clr","mn2_hl_clrYellow","Yellow",!0,void 0,2),t+=this.getRadio("mn2_hl_clr","mn2_hl_clrGreen","Green",void 0,void 0,2),t+=this.getRadio("mn2_hl_clr","mn2_hl_clrRed","Red",void 0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_hlstyle","Highlight Style",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn2_hl_style","mn2_hl_styleOutline","Outline",!0,void 0,2),t+=this.getRadio("mn2_hl_style","mn2_hl_styleObject","3D Objects",void 0,void 0,2),t+="
      ",t+="",t+=this.getLink("toggleHighlight2","Toggle Highlight",1,1),t+="

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

    View

    ",t+="
    ",t+=this.setMenu2b_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu2b_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getLink("mn2_show_selected","View Selection",1,1),t+=this.getLink("mn2_hide_selected","Hide Selection",1,1),t+=this.getLink("mn2_selectedcenter","Zoom in Selection",1,1),t+=this.getLink("mn6_center","Center Selection",1,1),t+=this.getLink("mn2_fullstru","View Full Structure"),t+=this.getLinkWrapper("mn2_alternate",'Alternate(Key "a")',"mn2_alternateWrap",void 0,1),void 0!==e.cfg.opmid?t+=this.getLinkWrapper("togglemem","Toggle Membrane","togglememli",void 0,1):void 0===e.cfg.cid&&(t+=this.getLinkWrapper("togglemem","Toggle Membrane","togglememli",void 0,1,!0)),void 0!==e.cfg.opmid&&(t+=this.getLinkWrapper("adjustmem","Adjust Membrane","adjustmemli",void 0,1),t+=this.getLinkWrapper("selectplane","Select between
      Two X-Y Planes","selectplaneli",void 0,1)),t+=this.getMenuSep(),t+=this.getMenuText("mn2_vrarhints","VR & AR Hints",void 0,1,1),t+="
        ",t+=this.getMenuUrl("vrhint",e.htmlCls.baseUrl+"icn3d/icn3d.html#vr","VR: VR Headsets",1,2),t+=this.getMenuUrl("arhint",e.htmlCls.baseUrl+"icn3d/icn3d.html#ar","AR: Chrome in Android",1,2),t+="
      ",t+="",t+=this.getLink("mn6_sidebyside","Side by Side",1,1),t+=this.getMenuText("mn2_rotate","Rotate",void 0,1,1),t+="
        ",t+=this.getMenuText("mn2_rotate90","Rotate 90°",void 0,void 0,2),t+="
          ",t+=this.getRadio("mn6_rotate90","mn6_rotatex","X-axis(Shift + Key M)",void 0,void 0,2),t+=this.getRadio("mn6_rotate90","mn6_rotatey","Y-axis(Shift + Key J)",void 0,void 0,2),t+=this.getRadio("mn6_rotate90","mn6_rotatez","Z-axis",void 0,void 0,2),t+="
        ",t+="",t+=this.getMenuText("mn2_rotateauto","Auto Rotation",void 0,1,2),t+="
          ",t+=this.getRadio("mn6_rotate","mn6_rotateleft","Rotate Left",void 0,1,3),t+=this.getRadio("mn6_rotate","mn6_rotateright","Rotate Right",void 0,1,3),t+=this.getRadio("mn6_rotate","mn6_rotateup","Rotate Up",void 0,1,3),t+=this.getRadio("mn6_rotate","mn6_rotatedown","Rotate Down",void 0,1,3),t+="
        ",t+="",t+="
      ",t+="",t+=this.getMenuText("mn2_camera","Camera",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_camera","mn6_cameraPers","Perspective",!0,void 0,2),t+=this.getRadio("mn6_camera","mn6_cameraOrth","Orthographic",void 0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_fog","Fog for Selection",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_showfog","mn6_showfogYes","On",void 0,void 0,2),t+=this.getRadio("mn6_showfog","mn6_showfogNo","Off",!0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_slab","Slab for Selection",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_showslab","mn6_showslabYes","On",void 0,void 0,2),t+=this.getRadio("mn6_showslab","mn6_showslabNo","Off",!0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_axes","XYZ-axes",void 0,1),t+="
        ",t+=this.getRadio("mn6_showaxis","mn6_showaxisYes","Original",void 0,void 0,2),t+=this.getRadio("mn6_showaxis","mn6_showaxisSel","Prin. Axes on Sel.",void 0,void 0,2),t+=this.getRadio("mn6_showaxis","mn6_showaxisNo","Hide",!0,void 0,2),t+="
      ",t+="",t+=this.getMenuSep(),t+=this.getMenuText("mn2_resetwrap","Reset",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_reset","reset","All",void 0,1,2),t+=this.getRadio("mn6_reset","mn6_resetOrientation","Orientation",void 0,1,2),t+="
      ",t+="",t+=this.getLink("mn6_back","Undo",void 0,1),t+=this.getLink("mn6_forward","Redo",void 0,1),t+=this.getLink("mn6_fullscreen","Full Screen",void 0,1),t+="

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

    Style

    ",t+="
    ",t+=this.setMenu3_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu3_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";t+="
      ",void 0===e.cfg.cid&&(t+=this.getMenuText("mn3_proteinwrap","Proteins",void 0,1,1),t+="
        ",void 0!==e.cfg.align||void 0!==e.cfg.chainalign?t+=this.getRadio("mn3_proteins","mn3_proteinsRibbon","Ribbon",void 0,1,2):t+=this.getRadio("mn3_proteins","mn3_proteinsRibbon","Ribbon",!0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsStrand","Strand",void 0,void 0,2),t+=this.getRadio("mn3_proteins","mn3_proteinsCylinder","Cylinder and Plate",void 0,void 0,2),t+=this.getRadio("mn3_proteins","mn3_proteinsSchematic","Schematic",void 0,1,2),void 0!==e.cfg.align||void 0!==e.cfg.chainalign?t+=this.getRadio("mn3_proteins","mn3_proteinsCalpha","C Alpha Trace",!0,1,2):t+=this.getRadio("mn3_proteins","mn3_proteinsCalpha","C Alpha Trace",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsBackbone","Backbone",void 0,void 0,2),t+=this.getRadio("mn3_proteins","mn3_proteinsBfactor","B-factor Tube",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsLines","Lines",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsStick","Stick",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsBallstick","Ball and Stick",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_sidecwrap","Side Chains",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_sidec","mn3_sidecLines","Lines",void 0,1,2),t+=this.getRadio("mn3_sidec","mn3_sidecStick","Stick",void 0,1,2),t+=this.getRadio("mn3_sidec","mn3_sidecBallstick","Ball and Stick",void 0,1,2),t+=this.getRadio("mn3_sidec","mn3_sidecSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_sidec","mn3_sidecNo","Hide",!0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_nuclwrap","Nucleotides",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_nucl","mn3_nuclCartoon","Cartoon",!0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclPhos","O3' Trace",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclBackbone","Backbone",void 0,void 0,2),t+=this.getRadio("mn3_nucl","mn3_nuclSchematic","Schematic",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclLines","Lines",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclStick","Stick",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclBallstick","Ball and Stick",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_ntbasewrap","Nucl. Bases",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_ntbase","mn3_ntbaseLines","Lines",void 0,1,2),t+=this.getRadio("mn3_ntbase","mn3_ntbaseStick","Stick",void 0,1,2),t+=this.getRadio("mn3_ntbase","mn3_ntbaseBallstick","Ball and Stick",void 0,1,2),t+=this.getRadio("mn3_ntbase","mn3_ntbaseSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_ntbase","mn3_ntbaseNo","Hide",!0,1,2),t+="
      ",t+=""),t+=this.getMenuText("mn3_ligwrap","Chemicals",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_lig","mn3_ligLines","Lines",void 0,1,2),void 0===e.cfg.cid?(t+=this.getRadio("mn3_lig","mn3_ligStick","Stick",!0,1,2),t+=this.getRadio("mn3_lig","mn3_ligBallstick","Ball and Stick",void 0,1,2)):(t+=this.getRadio("mn3_lig","mn3_ligStick","Stick",void 0,1,2),t+=this.getRadio("mn3_lig","mn3_ligBallstick","BalHydrogensl and Stick",!0,1,2)),t+=this.getRadio("mn3_lig","mn3_ligSchematic","Schematic",void 0,1,2),t+=this.getRadio("mn3_lig","mn3_ligSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_lig","mn3_ligNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_hydrogenswrap","Hydrogens",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_hydrogens","mn3_hydrogensYes","Show",!0,1,2),t+=this.getRadio("mn3_hydrogens","mn3_hydrogensNo","Hide",void 0,1,2),t+="
      ",t+="",void 0===e.cfg.cid&&(t+=this.getMenuText("mn3_glycanwrap","Glycans",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn3_glycansCart","mn3_glycansCartYes","Show Cartoon",void 0,void 0,2),t+=this.getRadio("mn3_glycansCart","mn3_glycansCartNo","Hide Cartoon",!0,void 0,2),t+="
      ",t+=""),t+=this.getMenuText("mn3_ionswrap","Ions",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_ions","mn3_ionsSphere","Sphere",!0,1,2),t+=this.getRadio("mn3_ions","mn3_ionsDot","Dot",void 0,1,2),t+=this.getRadio("mn3_ions","mn3_ionsNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_waterwrap","Water",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_water","mn3_waterSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_water","mn3_waterDot","Dot",void 0,1,2),t+=this.getRadio("mn3_water","mn3_waterNo","Hide",!0,1,2),t+="
      ",t+="",t+=this.getLink("mn3_setThickness","Preferences",void 0,1),t+=this.getMenuSep(),t+=this.getLink("mn3_styleSave","Save Style",void 0,2),t+=this.getLink("mn3_styleApplySave","Apply Saved Style",void 0,2),t+=this.getMenuSep(),t+=this.getMenuText("mn5_surfacewrap","Surface Type",void 0,1,1),t+="
        ",t+=this.getRadio("mn5_surface","mn5_surfaceVDW","Van der Waals",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceVDWContext","VDW with Context",void 0,void 0,2),t+=this.getRadio("mn5_surface","mn5_surfaceMolecular","Molecular Surface",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceMolecularContext","MS with Context",void 0,void 0,2),t+=this.getRadio("mn5_surface","mn5_surfaceSAS","Solvent Accessible",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceSASContext","SA with Context",void 0,void 0,2),t+="
      ",t+="",t+=this.getLink("mn5_surfaceNo","Remove Surface",1,1),t+=this.getMenuText("mn5_surfaceop","Surface Opacity",void 0,1,1),t+="
        ",t+=this.getMenuText("mn5_surfaceopfast","Fast Transparency",void 0,1,2),t+="
          ",t+=this.getRadio("mn5_opacity","mn5_opacity10","1.0",!0,1,3);for(let e=9;e>0;--e)t+=this.getRadio("mn5_opacity","mn5_opacity0"+e,"0."+e,1,3);t+="
        ",t+="",t+=this.getMenuText("mn5_surfaceopslow","Slow Transparency",void 0,void 0,2),t+="
          ",t+=this.getRadio("mn5_opacityslow","mn5_opacityslow10","1.0",!0,void 0,3);for(let e=9;e>0;--e)t+=this.getRadio("mn5_opacityslow","mn5_opacityslow0"+e,"0."+e,void 0,void 0,3);return t+="
        ",t+="",t+="
      ",t+=this.getMenuText("mn5_wireframewrap","Surface Wireframe",void 0,1,1),t+="
        ",t+=this.getRadio("mn5_wireframe","mn5_wireframeYes","Yes",void 0,1,2),t+=this.getRadio("mn5_wireframe","mn5_wireframeNo","No",!0,1,2),t+="
      ",t+="",t+=this.getMenuSep(),t+=this.getLink("mn5_cartoonshape","Cartoon for a Set",void 0,1),t+=this.getLink("mn5_linebtwsets","Line btw. Two Sets",void 0,1),void 0===e.cfg.cid&&void 0===e.cfg.align&&void 0===e.cfg.chainalign&&void 0===e.cfg.mmdbaf&&(t+=this.getMenuSep(),t+=this.getLinkWrapper2("mn5_map","Electron Density","mapWrapper1",void 0,1),t+="
        ",t+=this.getLink("mn5_elecmap2fofc","2Fo-Fc Map",void 0,2),t+=this.getLink("mn5_elecmapfofc","Fo-Fc Map",void 0,2),t+=this.getLinkWrapper("mn5_elecmapNo","Remove Map","mapWrapper2",void 0,2),t+="
      ",t+="",t+=this.getLinkWrapper2("mn5_map3","Map Wireframe","mapWrapper3",void 0,1),t+="
        ",t+=this.getRadio("mn5_mapwireframe","mn5_mapwireframeYes","Yes",!0,void 0,2),t+=this.getRadio("mn5_mapwireframe","mn5_mapwireframeNo","No",void 0,void 0,2),t+="
      ",t+="",void 0===e.cfg.mmtfid&&(t+=this.getLinkWrapper("mn5_emmap","EM Density Map","emmapWrapper1",void 0,1),t+=this.getLinkWrapper("mn5_emmapNo","Remove EM Map","emmapWrapper2",void 0,1),t+=this.getLinkWrapper2("mn5_emmap3","EM Map Wireframe","emmapWrapper3",void 0,1),t+="
        ",t+=this.getRadio("mn5_emmapwireframe","mn5_emmapwireframeYes","Yes",!0,void 0,2),t+=this.getRadio("mn5_emmapwireframe","mn5_emmapwireframeNo","No",void 0,void 0,2),t+="
      ",t+="")),t+=this.getMenuSep(),t+=this.getMenuText("mn6_bkgdwrap","Background",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_bkgd","mn6_bkgdTransparent","Transparent",void 0,1,2),t+=this.getRadio("mn6_bkgd","mn6_bkgdBlack","Black",!0,1,2),t+=this.getRadio("mn6_bkgd","mn6_bkgdGrey","Gray",void 0,1,2),t+=this.getRadio("mn6_bkgd","mn6_bkgdWhite","White",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn6_themewrap","Dialog Color",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_theme","mn6_themeBlue","Blue",!0,void 0,2),t+=this.getRadio("mn6_theme","mn6_themeOrange","Orange",void 0,void 0,2),t+=this.getRadio("mn6_theme","mn6_themeBlack","Black",void 0,void 0,2),t+="
      ",t+="",t+="

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

    Color

    ",t+="
    ",t+=this.setMenu4_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu4_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getMenuText("mn4_clrwrap","Unicolor","icn3d-menupd",1,1),t+="
        ",t+=this.getMenuText("uniclrRedwrap","Red",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrRed1","Red","F00",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed2","Indian Red","CD5C5C",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed3","Light Coral","F08080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed4","Salmon","FA8072",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed5","Dark Salmon","E9967A",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed6","Light Salmon","FFA07A",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed7","Crimson","DC143C",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed8","Fire Brick","B22222",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed9","Dark Red","8B0000",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrPinkwrap","Pink",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrPink1","Pink","FFC0CB",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink2","Light Pink","FFB6C1",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink3","Hot Pink","FF69B4",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink4","Deep Pink","FF1493",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink5","Medium Violet Red","C71585",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink6","Pale Violet Red","DB7093",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrOrangewrap","Orange",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrOran1","Orange","FFA500",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran2","Dark Orange","FF8C00",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran3","Orange Red","FF4500",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran4","Tomato","FF6347",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran5","Coral","FF7F50",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran6","Light Salmon","FFA07A",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrYellowwrap","Yellow",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrYllw1","Yellow","FF0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw2","Gold","FFD700",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw3","Light Yellow","FFFFE0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw4","Lemon Chiffon","FFFACD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw5","Light Golden Rod","FAFAD2",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw6","Papaya Whip","FFEFD5",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw7","Moccasin","FFE4B5",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw8","Peach Puff","FFDAB9",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw9","Pale Golden Rod","EEE8AA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw10","Khaki","F0E68C",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw11","Dark Khaki","BDB76B",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrMagentawrap","Magenta",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrMgnt1","Magenta","F0F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt2","Orchid","DA70D6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt3","Violet","EE82EE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt4","Plum","DDA0DD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt5","Thistle","D8BFD8",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt6","Lavender","E6E6FA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt7","Medium Orchid","BA55D3",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt8","Medium Purple","9370DB",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt9","Rebecca Purple","663399",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt10","Blue Violet","8A2BE2",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt11","Dark Violet","9400D3",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt12","Dark Orchid","9932CC",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt13","Dark Magenta","8B008B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt14","Purple","800080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt15","Indigo","4B0082",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt16","Slat Blue","6A5ACD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt17","Dark Slate Blue","483D8B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt18","Medium Slat Blue","6A5ACD",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrGreenwrap","Green",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrGrn1","Green","0F0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn2","Dark Green","006400",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn3","Yellow Green","9ACD32",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn4","Olive Drab","6B8E23",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn5","Olive","808000",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn6","Dark Olive Green","556B2F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn7","Medium Aquamarine","66CDAA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn8","Dark Sea Green","8FBC8B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn9","Lignt Sea Green","20B2AA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn10","Dark Cyan","008B8B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn11","Teal","008080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn12","Forest Green","228B22",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn13","Sea Green","2E8B57",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn14","Medium Sea Green","3CB371",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn15","Spring Green","00FF7F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn16","Medium Spring","00FA9A",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn17","Light Green","90EE90",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn18","Pale Green","98FB98",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn19","Lime Green","32CD32",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn20","Lawn Green","7CFC00",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn21","Chartreuse","7FFF00",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn22","Green Yellow","ADFF2F",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrCyanwrap","Cyan",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrCyan1","Cyan","0FF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan2","Light Cyan","E0FFFF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan3","Pale Turquoise","AFEEEE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan4","Aquamarine","7FFFD4",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan5","Turquoise","40E0D0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan6","Medium Turquoise","48D1CC",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan7","Dark Turquoise","00CED1",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrBluewrap","Blue",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrBlue1","Blue","00F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue2","Medium Blue","0000CD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue3","Dark Blue","00008B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue4","Navy","000080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue5","Midnight Blue","191970",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue6","Royal Blue","4169E1",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue7","Medium Slate Blue","7B68EE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue8","Corn Flower Blue","6495ED",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue9","Dodger Blue","1E90FF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue10","Deep Sky Blue","00BFFF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue11","Light Sky Blue","87CEFA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue12","Sky Blue","87CEEB",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue13","Light Blue","ADD8E6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue14","Powder Blue","B0E0E6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue15","Light Steel Blue","B0C4DE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue16","Steel Blue","4682B4",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue17","Cadet Blue","5F9EA0",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrBrownwrap","Brown",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrBrown1","Brown","A52A2A",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown2","Maroon","800000",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown3","Sienna","A0522D",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown4","Saddle Brown","8B4513",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown5","Chocolate","D2691E",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown6","Peru","CD853F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown7","Dark Golden Rod","B8860B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown8","Golden Rod","DAA520",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown9","Sandy Brown","F4A460",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown10","Rosy Brown","BC8F8F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown11","Tan","D2B48C",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown12","Burlywood","DEB887",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown13","Wheat","F5DEB3",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown14","Navajo White","FFDEAD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown15","Bisque","FFE4C4",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown16","Blanched Almond","FFEBCD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown17","Corn Silk","FFF8DC",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrWhitewrap","White",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrWhite1","White","FFF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite2","Snow","FFFAFA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite3","Honey Dew","F0FFF0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite4","Mint Cream","F5FFFA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite5","Azure","F0FFFF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite6","Alice Blue","F0F8FF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite7","Ghost White","F8F8FF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite8","White Smoke","F5F5F5",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite9","Sea Shell","FFF5EE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite10","Beige","F5F5DC",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite11","Old Lace","FDF5E6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite12","Floral White","FFFAF0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite13","Ivory","FFFFF0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite14","Antique White","FAEBD7",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite15","Linen","FAF0E6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite16","Lavenderblush","FFF0F5",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite17","Misty Rose","FFE4E1",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrGraywrap","Gray",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrGray1","Gray","808080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray2","Dim Gray","696969",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray3","Light Slate Gray","778899",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray4","Slate Gray","708090",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray5","Dark Slate Gray","2F4F4F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray6","Black","000000",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray7","Dark Gray","A9A9A9",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray8","Silver","C0C0C0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray9","Light Gray","D3D3D3",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray10","Gainsboro","DCDCDC",void 0,1,3),t+="
        ",t+="
      ",t+=this.getRadio("mn4_clr","mn4_clrCustom","Color Picker",void 0,void 0,1),t+=this.getMenuSep(),void 0===e.cfg.cid?(t+=this.getMenuText("mn4_clrRainbowwrap","Rainbow (R-V)","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrRainbow","for Selection",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrRainbowChain","for Chains",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrRainbowSets","for Sets",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrRainbowAcrossSets","across Sets",void 0,void 0,2),t+="
      ",t+=this.getMenuText("mn4_clrSpectrumwrap","Spectrum (V-R)","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrSpectrum","for Selection",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSpectrumChain","for Chains",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSpectrumSets","for Sets",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrSpectrumAcrossSets","across Sets",void 0,void 0,2),t+="
      ",t+=this.getMenuText("mn4_clrSSwrap","Secondary","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrSSGreen","Sheet in Green",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSSYellow","Sheet in Yellow",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSSSpectrum","Spectrum",void 0,void 0,2),t+="
      ",t+=this.getRadio("mn4_clr","mn4_clrCharge","Charge",void 0,1,1),t+=this.getMenuText("mn4_hydrophobicwrap","Hydrophobicity","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrNormalizedHP","Normalized",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrHydrophobic","Wimley-White",void 0,void 0,2),t+="
      ",t+=this.getMenuText("mn4_clrBfactorwrap","B-factor","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrBfactor","Original",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrBfactorNorm","Percentile",void 0,1,2),t+="
      ",t+=this.getRadio("mn4_clr","mn4_clrArea",'Solvent
      Accessibility',void 0,void 0,1),t+=this.getRadio("mn4_clr","mn4_clrStructure","Structure",void 0,1,1),void 0!==e.cfg.align||void 0!==e.cfg.chainalign||void 0!==e.cfg.blast_rep_id?t+=this.getRadio("mn4_clr","mn4_clrChain","Chain",void 0,1,1):t+=this.getRadio("mn4_clr","mn4_clrChain","Chain",!0,1,1),t+=this.getRadio("mn4_clr","mn4_clrdomain","3D Domain",void 0,void 0,1),void 0===e.cfg.cid&&(t+=this.getMenuText("mn4_clrsetswrap","Defined Sets","icn3d-menupd",void 0,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrsets",'Rainbow for Selected Sets
        in "Analysis > Defined Sets"',void 0,void 0,2),t+="
      ",t+=""),t+=this.getMenuText("mn4_clrResiduewrap","Residue","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrResidue","Default",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrResidueCustom","Custom",void 0,void 0,2),t+="
      ",t+=this.getRadio("mn4_clr","mn4_clrAtom","Atom",void 0,1,1),void 0!==e.cfg.align||void 0!==e.cfg.chainalign?(t+=this.getRadio("mn4_clr","mn4_clrIdentity","Identity",!0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrConserved","Conservation",void 0,void 0,2)):void 0!==e.cfg.blast_rep_id?(t+=this.getRadio("mn4_clr","mn4_clrIdentity","Identity",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrConserved","Conservation",!0,void 0,2)):(t+=this.getRadio("mn4_clr","mn4_clrIdentity","Identity",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrConserved","Conservation",void 0,void 0,2)),t+=this.getRadio("mn4_clr","mn4_clrConfidence",'AlphaFold
      Confidence',void 0,1,1)):t+=this.getRadio("mn4_clr","mn4_clrAtom","Atom",!0,1,1),t+=this.getMenuSep(),t+=this.getLink("mn4_clrSave","Save Color",void 0,1),t+=this.getLink("mn4_clrApplySave","Apply Saved Color",void 0,1),t+="

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

     Analysis

    ",t+="
    ",t+=this.setMenu5_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu5_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";t+="
      ",void 0===e.cfg.cid&&(t+=this.getLink("mn6_selectannotations","Seq. & Annotations "+e.htmlCls.wifiStr,1,1),t+=this.getLink("mn2_alignment","Aligned Seq. "+e.htmlCls.wifiStr,void 0,1),void 0===e.cfg.mmdbid&&void 0===e.cfg.gi&&void 0===e.cfg.blast_rep_id&&void 0===e.cfg.align&&void 0===e.cfg.chainalign||(t+=this.getLink("mn2_2ddgm","2D Diagram "+e.htmlCls.wifiStr,1,1)),t+=this.getMenuText("2dctnwrap","2D Cartoon",void 0,void 0,1),t+="
        ",t+=this.getLink("2dctn_chain","Chain Level",void 0,2),t+=this.getLink("2dctn_domain","Domain Level",void 0,2),t+=this.getLink("2dctn_secondary","Helix/Sheet Level",void 0,2),t+="
      ",t+="",t+=this.getLink("definedsets2","Defined Sets",1,1),t+=this.getMenuSep(),t+=this.getLink("mn6_hbondsYes","Interactions",1,1),t+=this.getMenuText("mn1_window","Bring to Front",void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_window_table","Interaction Table",void 0,2),t+=this.getLink("mn1_window_linegraph","2D Interaction Network",void 0,2),t+=this.getLink("mn1_window_scatterplot","2D Interaction Map",void 0,2),t+=this.getLink("mn1_window_graph","2D Graph(Force-Directed)",void 0,2),t+="
      ",t+="",t+=this.getLink("mn6_contactmap","Contact Map",void 0,1),e.cfg.notebook||(t+=this.getLink("mn1_mutation","Mutation "+e.htmlCls.wifiStr,1,1))),e.cfg.notebook||e.cfg.hidelicense||(t+=this.getMenuText("mn1_delphiwrap","DelPhi Potential",void 0,1,1),t+="
        ",t+=this.getLink("mn1_delphi","DelPhi Potential "+e.htmlCls.licenseStr,1,2),t+=this.getMenuText("mn1_phiwrap","Load PQR/Phi",void 0,void 0,2),t+="
          ",t+=this.getLink("mn1_phi","Local PQR/Phi/Cube File",void 0,3),t+=this.getLink("mn1_phiurl","URL PQR/Phi/Cube File",void 0,3),t+="
        ",t+="",t+=this.getLink("delphipqr","Download PQR",void 0,2),t+="
      ",t+=""),t+=this.getMenuSep(),t+=this.getMenuText("mn6_distancewrap","Distance",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_distance","mn6_distanceYes","between Two Atoms",void 0,1,2),t+=this.getRadio("mn6_distance","mn6_distTwoSets","between Two Sets",void 0,void 0,2),t+=this.getRadio("mn6_distance","mn6_distManySets","Among Many Sets",void 0,void 0,2),t+=this.getRadio("mn6_distance","mn6_distanceNo","Hide",!0,1,2),t+="
      ",t+="",t+=this.getLink("mn6_area","Surface Area",1,1),t+=this.getMenuText("mn6_addlabelwrap","Label",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_addlabel","mn6_addlabelYes","by Picking Atoms",void 0,void 0,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelSelection","per Selection",void 0,void 0,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelAtoms","per Atom",void 0,void 0,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelElements","per Atom Element",void 0,1,2),void 0===e.cfg.cid&&(t+=this.getRadio("mn6_addlabel","mn6_addlabelResidues","per Residue",void 0,1,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelResnum","per Residue & Number",void 0,1,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelChains","per Chain",void 0,void 0,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelTermini","N- & C-Termini",void 0,1,2)),t+=this.getMenuSep(),t+=this.getRadio("mn6_addlabel","mn6_labelColor","Change Label Color",void 0,1,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelNo","Remove",!0,1,2),t+="
      ",t+="",t+=this.getMenuText("labelscalewrap","Label Scale",void 0,1,1),t+="
        ";for(let e=1;e<=4;++e){let s=2*e;t+=this.getRadio("mn6_labelscale","mn6_labelscale0"+s,"0."+s,void 0,1,2)}for(let e=1;e<=5;++e)t+=1==e?this.getRadio("mn6_labelscale","mn6_labelscale"+e+"0",e+".0",!0,1,2):this.getRadio("mn6_labelscale","mn6_labelscale"+e+"0",e+".0",void 0,1,2);if(t+="
      ",t+="",t+=this.getMenuSep(),void 0===e.cfg.cid){t+=this.getMenuText("mn6_chemicalbindingwrap","Chem. Binding",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_chemicalbinding","mn6_chemicalbindingshow","Show",void 0,void 0,2),t+=this.getRadio("mn6_chemicalbinding","mn6_chemicalbindinghide","Hide",!0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn6_ssbondswrap","Disulfide Bonds",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_ssbonds","mn6_ssbondsYes","Show",!0,1,2),t+=this.getRadio("mn6_ssbonds","mn6_ssbondsExport","Export Pairs",void 0,void 0,2),t+=this.getRadio("mn6_ssbonds","mn6_ssbondsNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn6_clbondswrap","Cross-Linkages",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_clbonds","mn6_clbondsYes","Show",!0,void 0,2),t+=this.getRadio("mn6_clbonds","mn6_clbondsExport","Export Pairs",void 0,void 0,2),t+=this.getRadio("mn6_clbonds","mn6_clbondsNo","Hide",void 0,void 0,2),t+="
      ",t+="";let s=void 0!==e.cfg.mmtfid||void 0!==e.cfg.pdbid||void 0!==e.cfg.opmid||void 0!==e.cfg.mmcifid||void 0!==e.cfg.mmdbid||void 0!==e.cfg.mmdbafid||void 0!==e.cfg.gi||void 0!==e.cfg.blast_rep_id;s&&(t+=this.getMenuText("assemblyWrapper","Assembly",void 0,1,1),t+="
        ",e.cfg.bu?(t+=this.getRadio("mn6_assembly","mn6_assemblyYes","Biological Assembly",!0,1,2),t+=this.getRadio("mn6_assembly","mn6_assemblyNo","Asymmetric Unit",void 0,1,2)):(t+=this.getRadio("mn6_assembly","mn6_assemblyYes","Biological Assembly",void 0,1,2),t+=this.getRadio("mn6_assembly","mn6_assemblyNo","Asymmetric Unit",!0,1,2)),t+="
      ",t+=""),t+=this.getMenuText("mn6_symmetrywrap","Symmetry",void 0,void 0,1),t+="
        ",s&&(t+=this.getLink("mn6_symmetry","from PDB(precalculated) "+e.htmlCls.wifiStr,void 0,2)),t+=this.getLink("mn6_symd","from SymD(Dynamic) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn6_clear_sym","Clear SymD Symmetry",void 0,2),t+=this.getLink("mn6_axes_only","Show Axes Only",void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn6_igrefwrap","Ref. Number",void 0,void 0,1),t+="
        ",t+=this.getLink("mn6_customref","Custom Ref. Number",void 0,2),t+="
      ",t+="",t+=this.getMenuSep()}return t+=this.getLink("mn6_yournote","Window Title",void 0,1),void 0!==e.cfg.cid?(t+=this.getMenuText("mn1_linkwrap","Links",void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_link_structure","Compound Summary "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_vast","Similar Compounds "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_bind","Structures Bound "+e.htmlCls.wifiStr,void 0,2),t+="
      ",t+=""):(t+=this.getMenuText("mn1_linkwrap","Links",void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_link_structure","Structure Summary "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_vast","Similar Structures "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_pubmed","Literature "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_protein","Protein "+e.htmlCls.wifiStr,void 0,2),t+="
      ",t+=""),t+="

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

    Help

    ",t+="
    ",t+=this.setMenu6_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu6_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getMenuUrl("abouticn3d",e.htmlCls.baseUrl+"icn3d/icn3d.html#about","About iCn3D "+e.REVISION+"",1,1),t+=this.getMenuUrl("gallery",e.htmlCls.baseUrl+"icn3d/icn3d.html#gallery","Live Gallery "+e.htmlCls.wifiStr,1,1),t+=this.getMenuUrl("video",e.htmlCls.baseUrl+"icn3d/icn3d.html#videos","iCn3D Videos",1,1),t+=this.getMenuText("mn6_faq","FAQ",void 0,1,1),t+="
        ",t+=this.getMenuUrl("faq_viewstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#viewstru","View structure",1,2),t+=this.getMenuUrl("faq_tfstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#tfstru","Transform Structure",1,2),t+=this.getMenuUrl("faq_selsubset",e.htmlCls.baseUrl+"icn3d/icn3d.html#selsubset","Select Subsets",1,2),t+=this.getMenuUrl("faq_stylecolor",e.htmlCls.baseUrl+"icn3d/icn3d.html#changestylecolor","Change Style/Color",1,2),t+=this.getMenuUrl("faq_savework",e.htmlCls.baseUrl+"icn3d/icn3d.html#saveview","Save Work",1,2),t+=this.getMenuUrl("faq_showanno",e.htmlCls.baseUrl+"icn3d/icn3d.html#showanno","Show Annotations",1,2),t+=this.getMenuUrl("faq_exportanno",e.htmlCls.baseUrl+"icn3d/icn3d.html#exportanno","Export Annotations",1,2),t+=this.getMenuUrl("faq_interanal",e.htmlCls.baseUrl+"icn3d/icn3d.html#interanalysis","Interaction Analysis",1,2),t+=this.getMenuUrl("faq_mutanal",e.htmlCls.baseUrl+"icn3d/icn3d.html#mutationanalysis","Mutation Analysis",1,2),t+=this.getMenuUrl("faq_elecpot",e.htmlCls.baseUrl+"icn3d/icn3d.html#elecpot","Electrostatic Pot.",1,2),t+=this.getMenuUrl("faq_simipdb",e.htmlCls.baseUrl+"icn3d/icn3d.html#simivast","Similar PDB",1,2),t+=this.getMenuUrl("faq_simialphapdb",e.htmlCls.baseUrl+"icn3d/icn3d.html#simifoldseek","Similar AlphaFold/PDB",1,2),t+=this.getMenuUrl("faq_alnstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#alignmul","Align Multiple Structures",1,2),t+=this.getMenuUrl("faq_batchanal",e.htmlCls.baseUrl+"icn3d/icn3d.html#batchanalysis","Batch Analysis",1,2),t+=this.getMenuUrl("faq_embedicn3d",e.htmlCls.baseUrl+"icn3d/icn3d.html#embedicn3d","Embed iCn3D",1,2),t+="
      ",t+="",t+=this.getMenuUrl("citing",e.htmlCls.baseUrl+"icn3d/icn3d.html#citing","Citing iCn3D",void 0,1),t+=this.getMenuText("mn6_source","Source Code",void 0,1,1),t+="
        ",t+=this.getMenuUrl("github","https://github.com/ncbi/icn3d","GitHub (browser) "+e.htmlCls.wifiStr,1,2),t+=this.getMenuUrl("npm","https://www.npmjs.com/package/icn3d","npm (Node.js) "+e.htmlCls.wifiStr,1,2),t+=this.getMenuUrl("notebook","https://pypi.org/project/icn3dpy","Jupyter Notebook "+e.htmlCls.wifiStr,1,2),t+="
      ",t+="",t+=this.getMenuText("mn6_develop","Develop",void 0,void 0,1),t+="
        ",t+=this.getMenuUrl("dev_embedicn3d2",e.htmlCls.baseUrl+"icn3d/icn3d.html#HowToUse","Embed iCn3D",void 0,2),t+=this.getMenuUrl("dev_urlpara",e.htmlCls.baseUrl+"icn3d/icn3d.html#parameters","URL Parameters",void 0,2),t+=this.getMenuUrl("dev_command",e.htmlCls.baseUrl+"icn3d/icn3d.html#commands","Commands",void 0,2),t+=this.getMenuUrl("dev_datastru",e.htmlCls.baseUrl+"icn3d/icn3d.html#datastructure","Data Structure",void 0,2),t+=this.getMenuUrl("dev_classstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#classstructure","Class Structure",void 0,2),t+=this.getMenuUrl("dev_addclass",e.htmlCls.baseUrl+"icn3d/icn3d.html#addclass","Add New Classes",void 0,2),t+=this.getMenuUrl("dev_modfunc",e.htmlCls.baseUrl+"icn3d/icn3d.html#modifyfunction","Modify Functions",void 0,2),t+=this.getMenuUrl("dev_restful",e.htmlCls.baseUrl+"icn3d/icn3d.html#restfulapi","RESTful APIs",void 0,2),t+=this.getMenuUrl("dev_contributor",e.htmlCls.baseUrl+"icn3d/icn3d.html#contributors","iCn3D Contributors",void 0,2),t+="
      ",t+="",t+=this.getMenuUrl("helpdoc",e.htmlCls.baseUrl+"icn3d/docs/icn3d_help.html","Help Doc "+e.htmlCls.wifiStr,1,1),t+=this.getMenuSep(),t+=this.getMenuText("mn6_tfhint","Transform Hints",void 0,1,1),t+="
        ",t+=this.getMenuText("mn6_rotate","Rotate",void 0,1,2),t+="
          ",t+="
        • Left Mouse (Click & Drag)
        • ",t+="
        • Key l: Left
        • ",t+="
        • Key j: Right
        • ",t+="
        • Key i: Up
        • ",t+="
        • Key m: Down
        • ",t+="
        • Shift + Key l: Left 90°
        • ",t+="
        • Shift + Key j: Right 90°
        • ",t+="
        • Shift + Key i: Up 90°
        • ",t+="
        • Shift + Key m: Down 90°
        • ",t+="
        ",t+="",t+=this.getMenuText("mn6_zoom","Zoom",void 0,1,2),t+="
          ",t+="
        • Middle Mouse
          (Pinch & Spread)
        • ",t+="
        • Key z: Zoom in
        • ",t+="
        • Key x: Zoom out
        • ",t+="
        ",t+="",t+=this.getMenuText("mn6_translate","Translate",void 0,1,2),t+="
          ",t+="
        • Right Mouse
          (Two Finger Click & Drag)
        • ",t+="
        ",t+="",t+="
      ",t+="",t+=this.getMenuUrl("selhints",e.htmlCls.baseUrl+"icn3d/icn3d.html#selsubset","Selection Hints",void 0,1),t+=this.getMenuUrl("helpdesk","https://support.nlm.nih.gov/support/create-case/","Write to Help Desk",1,1),t+="

    • ",t+="
    ",t}hideMenu(){let e=this.icn3dui;e.bNode||(void 0!==$("#"+e.pre+"mnlist")[0]&&($("#"+e.pre+"mnlist")[0].style.display="none"),void 0!==$("#"+e.pre+"mnLogSection")[0]&&($("#"+e.pre+"mnLogSection")[0].style.display="none"),void 0!==$("#"+e.pre+"cmdlog")[0]&&($("#"+e.pre+"cmdlog")[0].style.display="none"),$("#"+e.pre+"title")[0].style.margin="10px 0 0 10px")}showMenu(){let e=this.icn3dui;e.bNode||(void 0!==$("#"+e.pre+"mnlist")[0]&&($("#"+e.pre+"mnlist")[0].style.display="block"),void 0!==$("#"+e.pre+"mnLogSection")[0]&&($("#"+e.pre+"mnLogSection")[0].style.display="block"),void 0!==$("#"+e.pre+"cmdlog")[0]&&($("#"+e.pre+"cmdlog")[0].style.display="block"))}}class c{constructor(e){this.icn3dui=e}openDlg(e,t){let s=this.icn3dui;s.icn3d,s.bNode||(e=s.pre+e,s.cfg.notebook?this.openDlgNotebook(e,t):this.openDlgRegular(e,t),s.htmlCls.themecolor||(s.htmlCls.themecolor="blue"),s.htmlCls.setMenuCls.setTheme(s.htmlCls.themecolor))}addSaveButton(e){let t=this.icn3dui;t.icn3d,t.bNode||void 0!==this.dialogHashSave&&this.dialogHashSave.hasOwnProperty(e)||($("#"+e).parent().children(".ui-dialog-titlebar").append("
    "),void 0===this.dialogHashSave&&(this.dialogHashSave={}),this.dialogHashSave[e]=1)}addHideButton(e){let t=this.icn3dui;t.icn3d,t.bNode||void 0!==this.dialogHashHide&&this.dialogHashHide.hasOwnProperty(e)||($("#"+e).parent().children(".ui-dialog-titlebar").append("
    "),void 0===this.dialogHashHide&&(this.dialogHashHide={}),this.dialogHashHide[e]=1)}getDialogStatus(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t={},s={},i=$("#"+e.pre+"dl_selectannotations").hasClass("ui-dialog-content"),n=$("#"+e.pre+"dl_graph").hasClass("ui-dialog-content"),l=$("#"+e.pre+"dl_linegraph").hasClass("ui-dialog-content"),r=$("#"+e.pre+"dl_scatterplot").hasClass("ui-dialog-content"),o=$("#"+e.pre+"dl_contactmap").hasClass("ui-dialog-content"),a=$("#"+e.pre+"dl_alignerrormap").hasClass("ui-dialog-content"),d=$("#"+e.pre+"dl_interactionsorted").hasClass("ui-dialog-content"),c=$("#"+e.pre+"dl_alignment").hasClass("ui-dialog-content"),h=$("#"+e.pre+"dl_2ddgm").hasClass("ui-dialog-content"),p=$("#"+e.pre+"dl_2dctn").hasClass("ui-dialog-content"),m=$("#"+e.pre+"dl_definedsets").hasClass("ui-dialog-content");return t.bSelectannotationsInit2=!1,t.bGraph2=!1,t.bLineGraph2=!1,t.bScatterplot2=!1,t.bTable2=!1,t.bAlignmentInit2=!1,t.bTwoddgmInit2=!1,t.bTwodctnInit2=!1,t.bSetsInit2=!1,s.dl_selectannotations="bSelectannotationsInit2",s.dl_graph="bGraph2",s.dl_linegraph="bLineGraph2",s.dl_scatterplot="bScatterplot2",s.dl_contactmap="bContactmap2",s.dl_alignerrormap="bAlignerrormap2",s.dl_interactionsorted="bTable2",s.dl_alignment="bAlignmentInit2",s.dl_2ddgm="bTwoddgmInit2",s.dl_2dctn="bTwodctnInit2",s.dl_definedsets="bSetsInit2",i&&(t.bSelectannotationsInit2=$("#"+e.pre+"dl_selectannotations").dialog("isOpen")),n&&(t.bGraph2=$("#"+e.pre+"dl_graph").dialog("isOpen")),l&&(t.bLineGraph2=$("#"+e.pre+"dl_linegraph").dialog("isOpen")),r&&(t.bScatterplot2=$("#"+e.pre+"dl_scatterplot").dialog("isOpen")),o&&(t.bContactmap2=$("#"+e.pre+"dl_contactmap").dialog("isOpen")),a&&(t.bAlignerror2=$("#"+e.pre+"dl_alignerrormap").dialog("isOpen")),d&&(t.bTable2=$("#"+e.pre+"dl_interactionsorted").dialog("isOpen")),c&&(t.bAlignmentInit2=$("#"+e.pre+"dl_alignment").dialog("isOpen")),h&&(t.bTwoddgmInit2=$("#"+e.pre+"dl_2ddgm").dialog("isOpen")),p&&(t.bTwodctnInit2=$("#"+e.pre+"dl_2dctn").dialog("isOpen")),m&&(t.bSetsInit2=$("#"+e.pre+"dl_definedsets").dialog("isOpen")),{status:t,id2flag:s}}openDlgHalfWindow(e,t,s,i){let n=this.icn3dui,l=n.icn3d;if(n.bNode)return;let r=this,o=n.htmlCls.width2d+20;l.resizeCanvasCls.resizeCanvas(n.htmlCls.WIDTH-s,n.htmlCls.HEIGHT,i);let a,d=n.htmlCls.HEIGHT,c=s;a=!n.cfg.showmenu||n.utilsCls.isMobile()||n.cfg.mobilemenu?{my:"left top",at:"right top",of:"#"+n.pre+"viewer",collision:"none"}:{my:"left top",at:"right top+40",of:"#"+n.pre+"viewer",collision:"none"},n.cfg.resize=!1,window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:d,width:c,modal:!1,position:a,close:function(t){let s=r.getDialogStatus(),i=s.status,a=s.id2flag,d=!1;for(let t in a){let s=e===n.pre+t;for(let e in i)i.hasOwnProperty(e)||(s=s&&!i[e]);d=d||s}if(d)if(i.bTwoddgmInit2||i.bTwodctnInit2||i.bSetsInit2){let e=n.utilsCls.isMobile()?n.htmlCls.WIDTH:n.htmlCls.WIDTH-o;l.resizeCanvasCls.resizeCanvas(e,n.htmlCls.HEIGHT,!0),i.bTwoddgmInit2&&r.openDlg2Ddgm(n.pre+"dl_2ddgm",void 0,i.bSetsInit2),i.bTwodctnInit2&&r.openDlg2Ddgm(n.pre+"dl_2dctn",void 0,i.bSetsInit2),i.bSetsInit2&&r.openDlg2Ddgm(n.pre+"dl_definedsets")}else l.resizeCanvasCls.resizeCanvas(n.htmlCls.WIDTH,n.htmlCls.HEIGHT,!0)},resize:function(t){if(e==n.pre+"dl_selectannotations")l.annotationCls.hideFixedTitle();else if(e==n.pre+"dl_graph"){let t=$("#"+e).width(),s=$("#"+e).height();d3.select("#"+n.svgid).attr("width",t).attr("height",s)}else if(e==n.pre+"dl_linegraph"||e==n.pre+"dl_scatterplot"||e==n.pre+"dl_contactmap"||e==n.pre+"dl_alignerrormap"){let t=status.bTwoddgmInit2||status.bSetsInit2?(n.htmlCls.WIDTH-o)/2:n.htmlCls.WIDTH/2,s=$("#"+e).width()/t;if(e==n.pre+"dl_linegraph"){let e=l.linegraphWidth*s;$("#"+n.linegraphid).attr("width",e)}else if(e==n.pre+"dl_scatterplot"){let e=l.scatterplotWidth*s;$("#"+n.scatterplotid).attr("width",e)}else if(e==n.pre+"dl_contactmap"){let e=l.contactmapWidth*s;$("#"+n.contactmapid).attr("width",e)}else if(e==n.pre+"dl_alignerrormap"){let e=l.alignerrormapWidth*s;$("#"+n.alignerrormapid).attr("width",e)}}}}),this.addSaveButton(e),this.addHideButton(e)}openDlg2Ddgm(e,t,s){let i=this.icn3dui,n=i.icn3d;if(i.bNode)return;let l,r,o=this,a=i.htmlCls.width2d+20;e===i.pre+"dl_definedsets"?(l="right top",r="Select sets"):e!==i.pre+"dl_2ddgm"&&e!==i.pre+"dl_2dctn"||(l=s?"right top+240":"right top",r=e===i.pre+"dl_2ddgm"?"2D Diagram":"2D Cartoon");let d={my:"left top+"+i.htmlCls.MENU_HEIGHT,at:l,of:"#"+i.pre+"viewer",collision:"none"};window.dialog=$("#"+e).dialog({autoOpen:!0,title:r,height:"auto",width:a,modal:!1,position:d,close:function(e){let t=o.getDialogStatus().status;t.bSelectannotationsInit2||t.bGraph2||t.bLineGraph2||t.bScatterplot2||t.bTable2||t.bAlignmentInit2||n.resizeCanvasCls.resizeCanvas(i.htmlCls.WIDTH,i.htmlCls.HEIGHT,!0)},resize:function(t,s){e==i.pre+"dl_2dctn"&&(n.resizeRatioX=s.size.width/i.htmlCls.width2d,n.resizeRatioY=s.size.height/(i.htmlCls.width2d+70))},resizeStop:function(e,t){n.resizeRatioX=t.size.width/i.htmlCls.width2d,n.resizeRatioY=t.size.height/(i.htmlCls.width2d+70)}}),this.addSaveButton(e),this.addHideButton(e)}openDlgRegular(e,t){let s=this.icn3dui,i=s.icn3d;if(s.bNode)return;let n=400,l=150,r=s.htmlCls.width2d+20,o=this.getDialogStatus().status;if(e===s.pre+"dl_selectannotations"||e===s.pre+"dl_graph"||e===s.pre+"dl_linegraph"||e===s.pre+"dl_scatterplot"||e===s.pre+"dl_contactmap"||e===s.pre+"dl_alignerrormap"||e===s.pre+"dl_interactionsorted"||e===s.pre+"dl_alignment"){let a=.5*s.htmlCls.WIDTH-.5*r;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)this.openDlgHalfWindow(e,t,a,!0),(o.bTwoddgmInit2||o.bTwodctnInit2||o.bSetsInit2)&&(i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-a-r,s.htmlCls.HEIGHT,!0),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,o.bSetsInit2),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,o.bSetsInit2),o.bSetsInit2&&this.openDlg2Ddgm(s.pre+"dl_definedsets"));else{i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH,.5*s.htmlCls.HEIGHT,!0),l=.5*s.htmlCls.HEIGHT,n=s.htmlCls.WIDTH;let a={my:"left top",at:"left bottom+32",of:"#"+s.pre+"canvas",collision:"none"};window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:l,width:n,modal:!1,position:a,close:function(t){if(!((e!==s.pre+"dl_selectannotations"||o.bAlignmentInit2||o.bGraph2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_graph"||o.bSelectannotationsInit2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_alignment"||o.bSelectannotationsInit2||o.bGraph2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_interactionsorted"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_linegraph"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_scatterplot"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_contactmap"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bAlignerrormap2)&&(e!==s.pre+"dl_alignerrormap"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2)))if(o.bTwoddgmInit2||o.bTwodctnInit2||o.bSetsInit2){let e=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(e,s.htmlCls.HEIGHT,!0),o.bTwoddgmInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,o.bSetsInit2),o.bTwodctnInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,o.bSetsInit2),o.bSetsInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_definedsets")}else i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH,s.htmlCls.HEIGHT,!0)},resize:function(t){if(e==s.pre+"dl_selectannotations")i.annotationCls.hideFixedTitle();else if(e==s.pre+"dl_graph"){let t=$("#"+e).width(),i=$("#"+e).height();d3.select("#"+s.svgid).attr("width",t).attr("height",i)}else if(e==s.pre+"dl_linegraph"||e==s.pre+"dl_scatterplot"||e==s.pre+"dl_contactmap"||e==s.pre+"dl_alignerrormap"){let t=o.bTwoddgmInit2||o.bSetsInit2?(s.htmlCls.WIDTH-r)/2:s.htmlCls.WIDTH/2,n=$("#"+e).width()/t;if(e==s.pre+"dl_linegraph"){let e=i.linegraphWidth*n;$("#"+s.linegraphid).attr("width",e)}else if(e==s.pre+"dl_scatterplot"){let e=i.scatterplotWidth*n;$("#"+s.scatterplotid).attr("width",e)}else if(e==s.pre+"dl_contactmap"){let e=i.contactmapWidth*n;$("#"+s.contactmapid).attr("width",e)}else if(e==s.pre+"dl_alignerrormap"){let e=i.alignerrormapWidth*n;$("#"+s.alignerrormapid).attr("width",e)}}}}),this.addSaveButton(e),this.addHideButton(e)}}else if(e===s.pre+"dl_2ddgm"||e===s.pre+"dl_2dctn"){let t=0;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)(o.bSelectannotationsInit2||o.bGraph2||o.bLineGraph2||o.bScatterplot2||o.bTable2||o.bAlignmentInit2)&&(t=.5*s.htmlCls.WIDTH-.5*r),i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-t-r,s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,void 0,o.bSetsInit2);else{let t=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(t,.5*s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT,o.bSetsInit2)}}else{let a;if(l="auto",n="auto",e===s.pre+"dl_addtrack"?n="50%":e===s.pre+"dl_menupref"&&(n=600,l=500),e===s.pre+"dl_definedsets"){let t=0;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)(o.bSelectannotationsInit2||o.bGraph2||o.bLineGraph2||o.bScatterplot2||o.bTable2||o.bAlignmentInit2)&&(t=.5*s.htmlCls.WIDTH-.5*r),i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-t-r,s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,!0),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,!0);else{let t=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(t,.5*s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",.5*s.htmlCls.HEIGHT,!0),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",.5*s.htmlCls.HEIGHT,!0)}}else s.utilsCls.isMobile()?a={my:"left top",at:"left bottom-50",of:"#"+s.pre+"canvas",collision:"none"}:e===s.pre+"dl_allinteraction"||e===s.pre+"dl_buriedarea"?(a={my:"right top",at:"right top+50",of:"#"+i.divid,collision:"none"},n=700,l=500):a=e===s.pre+"dl_rmsd"||e===s.pre+"dl_legend"?{my:"left bottom",at:"left+20 bottom-20",of:"#"+s.pre+"canvas",collision:"none"}:e===s.pre+"dl_symd"?{my:"left top",at:"right-200 bottom-200",of:"#"+s.pre+"canvas",collision:"none"}:s.cfg.align?{my:"left top",at:"left top+90",of:"#"+s.pre+"canvas",collision:"none"}:{my:"left top",at:"left top+50",of:"#"+s.pre+"canvas",collision:"none"},window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:l,width:n,modal:!1,position:a}),this.addSaveButton(e),this.addHideButton(e)}$(".ui-dialog .ui-button span").removeClass("ui-icon-closethick").addClass("ui-icon-close")}openDlgNotebook(e,t){let s=this.icn3dui,i=s.icn3d;if(s.bNode)return;let n=400,l=150,r=s.htmlCls.width2d+20;e===s.pre+"dl_selectannotations"||e===s.pre+"dl_graph"||e===s.pre+"dl_linegraph"||e===s.pre+"dl_scatterplot"||e===s.pre+"dl_contactmap"||e===s.pre+"dl_alignerrormap"||e===s.pre+"dl_interactionsorted"||e===s.pre+"dl_alignment"?($("#"+e).show(),l=.5*s.htmlCls.HEIGHT,n=s.htmlCls.WIDTH,$("#"+e).width(n),$("#"+e).height(l),$("#"+e).resize((function(t){let n=s.htmlCls.WIDTH/2,l=$("#"+e).width()/n;if(e==s.pre+"dl_selectannotations")i.annotationCls.hideFixedTitle();else if(e==s.pre+"dl_graph"){let t=$("#"+e).width(),i=$("#"+e).height();d3.select("#"+s.svgid).attr("width",t).attr("height",i)}else if(e==s.pre+"dl_linegraph"){let e=i.linegraphWidth*l;$("#"+s.linegraphid).attr("width",e)}else if(e==s.pre+"dl_scatterplot"){let e=i.scatterplotWidth*l;$("#"+s.scatterplotid).attr("width",e)}else if(e==s.pre+"dl_contactmap"){let e=i.contactmapWidth*l;$("#"+s.contactmapid).attr("width",e)}else if(e==s.pre+"dl_alignerrormap"){let e=i.alignerrormapWidth*l;$("#"+s.alignerrormapid).attr("width",e)}}))):(i.bRender&&$("#"+e).show(),l="auto",n="auto",e===s.pre+"dl_addtrack"?n="50%":e===s.pre+"dl_2ddgm"||e===s.pre+"dl_2dctn"||e===s.pre+"dl_definedsets"?n=r:e!==s.pre+"dl_allinteraction"&&e!==s.pre+"dl_buriedarea"||(n=700,l=500),$("#"+e).width(n),$("#"+e).height(l))}}class h{constructor(e){this.icn3dui=e}setCustomDialogs(){let e=this.icn3dui;if(e.icn3d,e.bNode)return"";return""}getHtmlAlignResidueByResidue(e,t,s){let i=this.icn3dui;i.icn3d;let n="";return n+="All chains will be aligned to the first chain in the comma-separated chain IDs. Each chain ID has the form of PDBID_chain (e.g., 1HHO_A, case sensitive) or UniprotID (e.g., P69905 for AlphaFold structures).

    ",n+="Chain IDs: "+i.htmlCls.inputTextStr+"id='"+i.pre+e+"' value='P69905,P01942,1HHO_A' size=50>

    ",n+='Each alignment is defined as " | "-separated residue lists in one line. "10-50" means a range of residues from 10 to 50.

    ",n+=i.htmlCls.buttonStr+s+"'>Align Residue by Residue
    ",n}setDialogs(){let e=this.icn3dui,t=e.icn3d;if(e.bNode)return"";let s="";e.htmlCls.optionStr="":s.htmlCls.optionStr+"'"+l+"'>"+l+""}return i}setColorHints(){let e=this.icn3dui;e.icn3d;let t="";return t+=e.htmlCls.divNowrapStr+'Green: H-Bonds; ',t+='Cyan: Salt Bridge/Ionic; ',t+='Grey: contacts',t+=e.htmlCls.divNowrapStr+'Magenta: Halogen Bonds; ',t+='Red: π-Cation; ',t+='Blue: π-Stacking',t}setThicknessHtml(e){let t=this.icn3dui,s=t.icn3d,i="",n="3dprint"==e?"1":"0.1",l="3dprint"==e?"1.2":"0.3",r="3dprint"==e?"0.8":"0.4",o="3dprint"==e?"0.8":"0.4",a="3dprint"==e?"1":"0.4",d="3dprint"==e?"0.6":"0.3",c="3dprint"==e?"1":"0.2",h="3dprint"==e?"2":"1.3",p="3dprint"==e?"1.4":"0.8",m=40,u=.6,g=.4,f=.2,b=0,C=1,y=0;if("style"==e){if(""!=this.getCookie("shininess")&&(m=parseFloat(this.getCookie("shininess"))),""!=this.getCookie("light1")&&(u=parseFloat(this.getCookie("light1")),g=parseFloat(this.getCookie("light2")),f=parseFloat(this.getCookie("light3"))),""!=this.getCookie("lineRadius")){n=parseFloat(this.getCookie("lineRadius")),l=parseFloat(this.getCookie("coilWidth")),r=parseFloat(this.getCookie("cylinderRadius"));let e=this.getCookie("crosslinkRadius");o=isNaN(e)?s.crosslinkRadius:parseFloat(e),a=parseFloat(this.getCookie("traceRadius")),d=parseFloat(this.getCookie("dotSphereScale")),c=parseFloat(this.getCookie("ribbonthickness")),h=parseFloat(this.getCookie("helixSheetWidth")),p=parseFloat(this.getCookie("nucleicAcidWidth"))}""!=this.getCookie("glycan")&&(b=parseFloat(this.getCookie("glycan"))),""!=this.getCookie("membrane")&&(C=parseFloat(this.getCookie("membrane"))),""!=this.getCookie("cmdwindow")&&(y=parseFloat(this.getCookie("cmdwindow"))),i+="Note: The following parameters will be saved in cache. You just need to set them once.

    ",i+="1. Shininess: "+t.htmlCls.inputTextStr+"id='"+t.pre+"shininess' value='"+m+"' size=4>"+t.htmlCls.space3+"(for the shininess of the 3D objects, default 40)

    ",i+="2. Three directional lights:
    ",i+="Key Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light1' value='"+u+"' size=4>"+t.htmlCls.space3+"(for the light strength of the key light, default 0.6)
    ",i+="Fill Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light2' value='"+g+"' size=4>"+t.htmlCls.space3+"(for the light strength of the fill light, default 0.4)
    ",i+="Back Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light3' value='"+f+"' size=4>"+t.htmlCls.space3+"(for the light strength of the back light, default 0.2)

    ",i+="3. Thickness:
    "}return i+="Line Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"linerad_"+e+"' value='"+n+"' size=4>"+t.htmlCls.space3+"(for stabilizers, hydrogen bonds, distance lines, default 0.1)
    ",i+="Coil Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"coilrad_"+e+"' value='"+l+"' size=4>"+t.htmlCls.space3+"(for coils, default 0.3)
    ",i+="Stick Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"stickrad_"+e+"' value='"+r+"' size=4>"+t.htmlCls.space3+"(for sticks, default 0.4)
    ",i+="Cross-Linkage Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"crosslinkrad_"+e+"' value='"+o+"' size=4>"+t.htmlCls.space3+"(for cross-linkages, default 0.4)
    ",i+="Trace Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"tracerad_"+e+"' value='"+a+"' size=4>"+t.htmlCls.space3+"(for C alpha trace, O3' trace, default 0.4)
    ",i+="Ribbon Thickness: "+t.htmlCls.inputTextStr+"id='"+t.pre+"ribbonthick_"+e+"' value='"+c+"' size=4>"+t.htmlCls.space3+"(for helix and sheet ribbons, nucleotide ribbons, default 0.2)
    ",i+="Protein Ribbon Width: "+t.htmlCls.inputTextStr+"id='"+t.pre+"prtribbonwidth_"+e+"' value='"+h+"' size=4>"+t.htmlCls.space3+"(for helix and sheet ribbons, default 1.3)
    ",i+="Nucleotide Ribbon Width: "+t.htmlCls.inputTextStr+"id='"+t.pre+"nucleotideribbonwidth_"+e+"' value='"+p+"' size=4>"+t.htmlCls.space3+"(for nucleotide ribbons, default 0.8)
    ",i+="Ball Scale: "+t.htmlCls.inputTextStr+"id='"+t.pre+"ballscale_"+e+"' value='"+d+"' size=4>"+t.htmlCls.space3+"(for styles 'Ball and Stick' and 'Dot', default 0.3)
    ","style"==e&&(i+="
    4. Show Glycan Cartoon: "+t.htmlCls.inputTextStr+"id='"+t.pre+"glycan' value='"+b+"' size=4>"+t.htmlCls.space3+"(0: hide, 1: show, default 0)
    ",i+="
    5. Show Membrane: "+t.htmlCls.inputTextStr+"id='"+t.pre+"membrane' value='"+C+"' size=4>"+t.htmlCls.space3+"(0: hide, 1: show, default 1)
    ",i+="
    6. Enlarge Command Window: "+t.htmlCls.inputTextStr+"id='"+t.pre+"cmdwindow' value='"+y+"' size=4>"+t.htmlCls.space3+"(0: Regular, 1: Large, default 0)

    "),i+=t.htmlCls.spanNowrapStr+""+t.htmlCls.buttonStr+"apply_thickness_"+e+"'>Apply   ",i+=t.htmlCls.spanNowrapStr+""+t.htmlCls.buttonStr+"reset_thickness_"+e+"'>Reset",i}getCookie(e){let t=e+"=",s=decodeURIComponent(document.cookie).split(";");for(let e=0;e":(n+='
    ',n+="
    Selection: Name: "+s.htmlCls.inputTextStr+"id='"+s.pre+"seq_command_name"+e+"' value='seq_"+l+"' size='5'> "+s.htmlCls.space2+"

    ",n+=s.htmlCls.divStr+"seqguide"+e+"' style='display:none; white-space:normal;' class='icn3d-box'>"),n+=this.getSelectionHints();return n+="Residue labeling: standard residue with coordinates: UPPER case letter; nonstandard residue with coordinates: the first UPPER case letter plus a period except that water residue uses the letter 'O'; residue missing coordinates: lower case letter."+(s.utilsCls.isMac()&&!s.utilsCls.isMobile()?"

    Turn on scroll bar: System preferences -> General -> show scroll bars -> check Always":"")+"
    ",n}setAlignSequenceGuide(e,t){let s=this.icn3dui,i=s.icn3d,n="";let l=i&&i.defNames2Atoms?Object.keys(i.defNames2Atoms).length:1;n+='
    ',n+="
    Selection: Name: "+s.htmlCls.inputTextStr+"id='"+s.pre+"alignseq_command_name' value='alseq_"+l+"' size='10'> "+s.htmlCls.space2+"

    ",n+=s.htmlCls.divStr+"alignseqguide' style='display:none; white-space:normal;' class='icn3d-box'>",n+=this.getSelectionHints();return n+="Residue labeling: aligned residue with coordinates: UPPER case letter; non-aligned residue with coordinates: lower case letter which can be highlighted; residue missing coordinates: lower case letter which can NOT be highlighted."+(s.utilsCls.isMac()&&!s.utilsCls.isMobile()?"

    Turn on scroll bar: System preferences -> General -> show scroll bars -> check Always":"")+"
    ",n}getSelectionHints(){let e=this.icn3dui;e.icn3d;let t="";if(e.utilsCls.isMobile())t+='Select Aligned Sequences: touch to select, touch again to deselect, multiple selection is allowed without Ctrl key, click "Save Selection" to save the current selection.
    ';else{t+='Select on 1D sequences: drag to select, drag again to deselect, multiple selection is allowed without Ctrl key, click "Save Selection" to save the current selection.

    ',t+="Select on 2D interaction diagram: click on the nodes or lines. The nodes are chains and can be united with the Ctrl key. The lines are interactions and can NOT be united. Each click on the lines selects half of the lines, i.e., select the interacting residues in one of the two chains.

    ",t+="Select on 3D structures: "+(e.utilsCls.isMobile()?"use finger to pick":'hold "Alt" and use mouse to pick')+', click the second time to deselect, hold "Ctrl" to union selection, hold "Shift" to select a range, press the up/down arrow to switch among atom/residue/strand/chain/structure, click "Save Selection" to save the current selection.

    ',t+='Save the current selection(either on 3D structure, 2D interactions, or 1D sequence): open the menu "Select -> Save Selection", specify the name and description for the selection, and click "Save".

    '}return t}addGsizeSalt(e){let t=this.icn3dui;t.icn3d;let s="";s+="Grid Size: ",s+="Salt Concentration: M
    ",s}getFootHtml(e,t){let s=this.icn3dui;s.icn3d;let i="
    ";return"delphi"==e?s.cfg.cid?i+="Note: Partial charges(MMFF94) are from PubChem Compound SDF files.

    ":(i+="Note: Only the selected residues are used for DelPhi potential calculation by solving linear Poisson-Boltzmann equation.",i+='

    ',i+=s.htmlCls.divStr+t+"' style='display:none;'>",i+="
    The hydrogens and partial charges of proteins and nucleotides are added using DelPhiPKa with the Amber charge and size files. The hydrogens of ligands are added using Open Babel. The partial charges of ligands are calculated using Antechamber with the Gasteiger charge method. All partial charges are calculated at pH 7.

    ",i+='Lipids are treated as ligands. Please use "HETATM" instead of "ATOM " for each lipid atom in your PDB file. Each phosphate in lipids is assigned with a charge of -1. You can download PQR and modify it, or prepare your PQR file using other tools. Then load the PQR file at the menu "Analysis > Load PQR/Potential".

    ',i+="
    "):(i+="Note: Always load a PDB file before loading a PQR or DelPhi potential file.",i+='

    ',i+=s.htmlCls.divStr+t+"' style='display:none;'>",i+='The PDB file can be loaded in the URL with "pdbid=" or at "File > Open File". The PQR file can be prepared at the menu "Analysis > Download PQR" with your modification or using other tools. The DelPhi potential file can be calculated at DelPhi Web Server and be exported as a Cube file. ',"url"==e&&(i+="The PQR or potential file can be accessed in a URL if it is located in the same host as iCn3D."),i+="

    ",i+=""),i+="",i}getPotentialHtml(e,t){let s=this.icn3dui;s.icn3d;let i,n,l,r,o,a="";r="Equipotential Map",o="Surface with Potential","delphi"==e?n="delphi":"local"==e?(i="pqr",n="phi",l="cube"):"url"==e&&(i="pqrurl",n="phiurl",l="cubeurl"),a+=s.htmlCls.divStr+"dl_"+n+"' class='"+t+"'>",a+=s.htmlCls.divStr+"dl_"+n+"_tabs' style='border:0px;'>",a+="",a+=s.htmlCls.divStr+n+"tab1'>","delphi"==e&&(a+=this.addGsizeSalt(n)+"
    "),a+="Potential contour at: kT/e(25.6mV at 298K)

    ","delphi"==e?(a+=s.htmlCls.buttonStr+"reload_"+n+"file' style='margin-top: 6px;'>Equipotential Map",a+=s.htmlCls.buttonStr+n+"mapNo' style='margin-left:30px;'>Remove Map
    "):"local"==e?(a+=s.htmlCls.divStr+n+"tab1_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo'>Remove Map",a+=s.htmlCls.divStr+n+"tab1_"+i+"'>",a+=this.addGsizeSalt(i)+"
    ",a+="PQR File: "+s.htmlCls.inputFileStr+"id='"+s.pre+i+"file'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+n+"'>",a+="Phi File: "+s.htmlCls.inputFileStr+"id='"+s.pre+n+"file'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+l+"'>",a+="Cube File: "+s.htmlCls.inputFileStr+"id='"+s.pre+l+"file'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=""):"url"==e&&(a+=s.htmlCls.divStr+n+"tab1_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo'>Remove Map",a+=s.htmlCls.divStr+n+"tab1_"+i+"2'>",a+=this.addGsizeSalt(i)+"
    ",a+="PQR URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+i+"file'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+n+"2'>",a+="Phi URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+n+"file'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+l+"2'>",a+="Cube URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+l+"file'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=""),a+="
    "+this.getFootHtml(e,n+"tab1_foot"),a+="",a+=s.htmlCls.divStr+n+"tab2'>","delphi"==e&&(a+=this.addGsizeSalt(n)+"
    "),a+="Surface with max potential at: kT/e(25.6mV at 298K)

    ",a+="Surface: ",a+="Opacity: ",a+="Wireframe:
    ",a+="
    ","delphi"==e?(a+=s.htmlCls.buttonStr+"reload_"+n+"file2' style='margin-top: 6px;'>Surface with Potential",a+=s.htmlCls.buttonStr+n+"mapNo2' style='margin-left:30px;'>Remove Surface
    "):"local"==e?(a+=s.htmlCls.divStr+n+"tab2_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo2'>Remove Surface",a+=s.htmlCls.divStr+n+"tab2_"+i+"'>",a+=this.addGsizeSalt(i+"2")+"
    ",a+="PQR File: "+s.htmlCls.inputFileStr+"id='"+s.pre+i+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+n+"'>",a+="Phi File: "+s.htmlCls.inputFileStr+"id='"+s.pre+n+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+l+"'>",a+="Cube File: "+s.htmlCls.inputFileStr+"id='"+s.pre+l+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=""):"url"==e&&(a+=s.htmlCls.divStr+n+"tab2_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo2'>Remove Surface",a+=s.htmlCls.divStr+n+"tab2_"+i+"2'>",a+=this.addGsizeSalt(i+"2")+"
    ",a+="PQR URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+i+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+n+"2'>",a+="Phi URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+n+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+l+"2'>",a+="Cube URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+l+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=""),a+="
    "+this.getFootHtml(e,n+"tab2_foot"),a+="",a+="",a+="",a}async exportPqr(e){let t=this.icn3dui,s=t.icn3d,i={},n={},l=t.hashUtilsCls.intHash(s.dAtoms,s.hAtoms);for(let e in l)s.atoms[e],s.ions.hasOwnProperty(e)?i[e]=1:n[e]=1;let r=e?"pdb":"pqr";if(t.cfg.cid){let t="",l=!e;t+=s.saveFileCls.getAtomPDB(n,l)+s.saveFileCls.getAtomPDB(i,l);let o=s.inputid?s.inputid:"custom";s.saveFileCls.saveFile(o+"_icn3d."+r,"text",[t])}else{if(t.utilsCls.isCalphaPhosOnly(t.hashUtilsCls.hash2Atoms(n,s.atoms)))return void alert("The potential will not be shown because the side chains are missing in the structure...");let l="";l+=s.saveFileCls.getAtomPDB(n),l+=s.saveFileCls.getAtomPDB(i,!0,void 0,!0);let o="https://www.ncbi.nlm.nih.gov/Structure/delphi/delphi.fcgi",a={pdb2pqr:l,pdbid:t.cfg.cid?t.cfg.cid:Object.keys(s.structures).toString()},d=await t.getAjaxPostPromise(o,a,!0,void 0,void 0,!0,"text");if(e){let e=d.split("\n"),s="";for(let i=0,n=e.length;i PNG Image" in the Data menu...');else if(-1!=l){let t=e.substr(l+n.length);s.htmlCls.clickMenuCls.setLogCmd("load iCn3D PNG image "+$("#"+s.pre+"pngimage").val(),!1),window.open(t,"_self")}else if(-1!=o){let n="Start of data file======\n",l=e.indexOf(n);i.bInputfile=-1!=l;let a,d=t?t.replace(/;/g,"\n"):"";if(i.bInputfile){let t=e.indexOf("End of data file======\n"),s=e.substr(l+n.length,t-l-n.length);i.InputfileData=i.InputfileData?i.InputfileData+"\nENDMDL\n"+s:s;let c="Start of type file======\n",h=e.indexOf(c),p=e.indexOf("End of type file======\n"),m=e.substr(h+c.length,p-h-c.length-1);i.InputfileType=m;let u=e.indexOf("End of state file======\n");a=e.substr(o+r.length,u-o-r.length),a=decodeURIComponent(a+"\n"+d),"pdb"===m?(await i.pdbParserCls.loadPdbData(s),i.commands=[],i.optsHistory=[]):("mol2"===m?await i.mol2ParserCls.loadMol2Data(s):"sdf"===m?await i.sdfParserCls.loadSdfData(s):"xyz"===m?await i.xyzParserCls.loadXyzData(s):"mmcif"===m&&await i.mmcifParserCls.loadMmcifData(s),i.commands=[],i.optsHistory=[])}else{let t=e.indexOf("End of state file======\n");a=e.substr(o+r.length,t-o-r.length),a=decodeURIComponent(a+"\n"+d),i.commands=[],i.optsHistory=[]}await i.loadScriptCls.loadScript(a,!0),s.htmlCls.clickMenuCls.setLogCmd("load iCn3D PNG image "+$("#"+s.pre+"pngimage").val(),!1)}}fileSupport(){window.File&&window.FileReader&&window.FileList&&window.Blob||alert("The File APIs are not fully supported in this browser.")}getLinkColor(){let e="";return e+=", linkmap: {\n",e+='3: {"type": "peptidebond", "c":""},\n',e+='4: {"type": "ssbond", "c":"FFA500"},\n',e+='5: {"type": "ionic", "c":"0FF"},\n',e+='6: {"type": "ionicInside", "c":"FFF"},\n',e+='11: {"type": "contact", "c":"888"},\n',e+='12: {"type": "contactInside", "c":"FFF"},\n',e+='13: {"type": "hbond", "c":"0F0"},\n',e+='14: {"type": "hbondInside", "c":"FFF"},\n',e+='15: {"type": "clbond", "c":"006400"},\n',e+='17: {"type": "halogen", "c":"F0F"},\n',e+='18: {"type": "halogenInside", "c":"FFF"},\n',e+='19: {"type": "pication", "c":"F00"},\n',e+='20: {"type": "picationInside", "c":"FFF"},\n',e+='21: {"type": "pistacking", "c":"00F"},\n',e+='22: {"type": "pistackingInside", "c":"FFF"}\n',e+="}}\n",', linkmap: {\n3: {"type": "peptidebond", "c":""},\n4: {"type": "ssbond", "c":"FFA500"},\n5: {"type": "ionic", "c":"0FF"},\n6: {"type": "ionicInside", "c":"FFF"},\n11: {"type": "contact", "c":"888"},\n12: {"type": "contactInside", "c":"FFF"},\n13: {"type": "hbond", "c":"0F0"},\n14: {"type": "hbondInside", "c":"FFF"},\n15: {"type": "clbond", "c":"006400"},\n17: {"type": "halogen", "c":"F0F"},\n18: {"type": "halogenInside", "c":"FFF"},\n19: {"type": "pication", "c":"F00"},\n20: {"type": "picationInside", "c":"FFF"},\n21: {"type": "pistacking", "c":"00F"},\n22: {"type": "pistackingInside", "c":"FFF"}\n}}\n'}setCookieForThickness(){let e=this.icn3dui,t=e.icn3d;if(!e.bNode){let e=3650;this.setCookie("lineRadius",t.lineRadius,e),this.setCookie("coilWidth",t.coilWidth,e),this.setCookie("cylinderRadius",t.cylinderRadius,e),this.setCookie("crosslinkRadius",t.crosslinkRadius,e),this.setCookie("traceRadius",t.traceRadius,e),this.setCookie("dotSphereScale",t.dotSphereScale,e),this.setCookie("ribbonthickness",t.ribbonthickness,e),this.setCookie("helixSheetWidth",t.helixSheetWidth,e),this.setCookie("nucleicAcidWidth",t.nucleicAcidWidth,e)}}setLineThickness(e,t){let s=this.icn3dui,i=s.icn3d;if(i.bSetThickness=!0,"style"==e&&(t&&($("#"+s.pre+"shininess").val("40"),$("#"+s.pre+"light1").val("0.6"),$("#"+s.pre+"light2").val("0.4"),$("#"+s.pre+"light3").val("0.2"),$("#"+s.pre+"glycan").val("0"),$("#"+s.pre+"membrane").val("1"),$("#"+s.pre+"cmdwindow").val("0")),i.shininess=parseFloat($("#"+s.pre+"shininess").val()),i.light1=parseFloat($("#"+s.pre+"light1").val()),i.light2=parseFloat($("#"+s.pre+"light2").val()),i.light3=parseFloat($("#"+s.pre+"light3").val()),i.bGlycansCartoon=parseInt($("#"+s.pre+"glycan").val()),i.bMembrane=parseInt($("#"+s.pre+"membrane").val()),i.bCmdWindow=parseInt($("#"+s.pre+"cmdwindow").val())),t&&($("#"+s.pre+"linerad_"+e).val(.1),$("#"+s.pre+"coilrad_"+e).val(.3),$("#"+s.pre+"stickrad_"+e).val(.4),$("#"+s.pre+"crosslinkrad_"+e).val(.4),$("#"+s.pre+"tracerad_"+e).val(.4),$("#"+s.pre+"ballscale_"+e).val(.3),$("#"+s.pre+"ribbonthick_"+e).val(.2),$("#"+s.pre+"prtribbonwidth_"+e).val(1.3),$("#"+s.pre+"nucleotideribbonwidth_"+e).val(.8)),i.lineRadius=parseFloat($("#"+s.pre+"linerad_"+e).val()),i.coilWidth=parseFloat($("#"+s.pre+"coilrad_"+e).val()),i.cylinderRadius=parseFloat($("#"+s.pre+"stickrad_"+e).val()),i.crosslinkRadius=parseFloat($("#"+s.pre+"crosslinkrad_"+e).val()),i.traceRadius=parseFloat($("#"+s.pre+"tracerad_"+e).val()),i.dotSphereScale=parseFloat($("#"+s.pre+"ballscale_"+e).val()),i.ribbonthickness=parseFloat($("#"+s.pre+"ribbonthick_"+e).val()),i.helixSheetWidth=parseFloat($("#"+s.pre+"prtribbonwidth_"+e).val()),i.nucleicAcidWidth=parseFloat($("#"+s.pre+"nucleotideribbonwidth_"+e).val()),!s.bNode){let e=3650;this.setCookie("shininess",i.shininess,e),this.setCookie("light1",i.light1,e),this.setCookie("light2",i.light2,e),this.setCookie("light3",i.light3,e),this.setCookie("glycan",i.bGlycansCartoon,e),this.setCookie("membrane",i.bMembrane,e),this.setCookie("cmdwindow",i.bCmdWindow,e)}if(this.setCookieForThickness(),e=t){let e="reset thickness";s.htmlCls.clickMenuCls.setLogCmd(e,!0),i.bSetThickness=!1,i.threeDPrintCls.resetAfter3Dprint()}else s.htmlCls.clickMenuCls.setLogCmd("set thickness | linerad "+i.lineRadius+" | coilrad "+i.coilWidth+" | stickrad "+i.cylinderRadius+" | crosslinkrad "+i.crosslinkRadius+" | tracerad "+i.traceRadius+" | ribbonthick "+i.ribbonthickness+" | proteinwidth "+i.helixSheetWidth+" | nucleotidewidth "+i.nucleicAcidWidth+" | ballscale "+i.dotSphereScale,!0),s.htmlCls.clickMenuCls.setLogCmd("set glycan "+i.bGlycansCartoon,!0),s.htmlCls.clickMenuCls.setLogCmd("set membrane "+i.bMembrane,!0),s.htmlCls.clickMenuCls.setLogCmd("set cmdwindow "+i.bCmdWindow,!0);i.drawCls.draw()}setCookie(e,t,s){let i=new Date;i.setTime(i.getTime()+24*s*60*60*1e3);let n="expires="+i.toUTCString();document.cookie=e+"="+t+";"+n+";path=/"}updateSurfPara(e){let t=this.icn3dui,s=t.icn3d;s.phisurftype=$("#"+t.pre+e+"surftype").val(),s.phisurfop=$("#"+t.pre+e+"surfop").val(),s.phisurfwf=$("#"+t.pre+e+"surfwf").val()}exportPdb(){let e=this.icn3dui,t=e.icn3d,s="",i=e.hashUtilsCls.intHash(t.dAtoms,t.hAtoms);if(s+=t.saveFileCls.getAtomPDB(i),!e.bNode){let e=t.inputid?t.inputid:"custom";t.saveFileCls.saveFile(e+"_icn3d.pdb","text",[s])}return s}exportSecondary(){let e=this.icn3dui,t=e.icn3d,s="",i=e.hashUtilsCls.intHash(t.dAtoms,t.hAtoms);if(s+=t.saveFileCls.getSecondary(i),!e.bNode){let e=t.inputid?t.inputid:"custom";t.saveFileCls.saveFile(e+"_icn3d_ss.txt","text",[s])}return s}}class g{constructor(e){let t=e;this.icn3dui=e,this.cfg=this.icn3dui.cfg,this.opts={},this.opts.background="black",this.allMenus={},this.allMenusSel={},this.simpleMenus={},this.shownMenus={},this.WIDTH=400,this.HEIGHT=400,this.RESIDUE_WIDTH=10,t.utilsCls.isMobile()||this.cfg.mobilemenu?this.MENU_HEIGHT=0:this.MENU_HEIGHT=40,this.LOG_HEIGHT=65,this.MENU_WIDTH=750,this.LESSWIDTH=20,this.LESSWIDTH_RESIZE=20,this.LESSHEIGHT=20,this.width2d=200,this.CMD_HEIGHT=.8*this.LOG_HEIGHT,this.EXTRAHEIGHT=this.MENU_HEIGHT+this.CMD_HEIGHT,null!=this.cfg.showmenu&&0==this.cfg.showmenu&&(this.EXTRAHEIGHT-=this.MENU_HEIGHT),null!=this.cfg.showcommand&&0==this.cfg.showcommand&&(this.EXTRAHEIGHT-=this.CMD_HEIGHT),this.GREY8="#AAAAAA",this.GREYB="#CCCCCC",this.GREYC="#DDDDDD",this.GREYD="#EEEEEE",this.ORANGE="#FFA500",this.themecolor="blue",this.defaultValue=1,this.ssValue=3,this.coilValue=3,this.contactValue=11,this.contactInsideValue=12,this.hbondValue=13,this.hbondInsideValue=14,this.ssbondValue=4,this.ionicValue=5,this.ionicInsideValue=6,this.clbondValue=15,this.halogenValue=17,this.halogenInsideValue=18,this.picationValue=19,this.picationInsideValue=20,this.pistackingValue=21,this.pistackingInsideValue=22,this.contactColor="888",this.contactInsideColor="FFF",this.hbondColor="0F0",this.hbondInsideColor="FFF",this.ssbondColor="FFA500",this.ionicColor="0FF",this.ionicInsideColor="FFF",this.clbondColor="006400",this.halogenColor="F0F",this.halogenInsideColor="FFF",this.picationColor="F00",this.picationInsideColor="FFF",this.pistackingColor="00F",this.pistackingInsideColor="FFF",this.hideedges=1,this.force=4,this.simulation=void 0,this.baseUrl=window&&window.location&&"structure.ncbi.nlm.nih.gov"==window.location.hostname?"https://structure.ncbi.nlm.nih.gov/Structure/":"https://www.ncbi.nlm.nih.gov/Structure/",this.divStr="
    ",this.spanNowrapStr="",this.inputTextStr="=2.0 are supported.")));const a=new pe(o,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});a.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===r[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}a.setExtensions(l),a.setPlugins(r),a.parse(s,i)}parseAsync(e,t){const s=this;return new Promise((function(i,n){s.parse(e,t,i,n)}))}}function b(){let e={};return{get:function(t){return e[t]},add:function(t,s){e[t]=s},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const C={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class y{constructor(e){this.parser=e,this.name=C.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,i=t.length;s=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,n.source,l)}}class R{constructor(e){this.parser=e,this.name=C.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,i=s.json,n=i.textures[e];if(!n.extensions||!n.extensions[t])return null;const l=n.extensions[t],r=i.images[l.source];let o=s.textureLoader;if(r.uri){const e=s.options.manager.getHandler(r.uri);null!==e&&(o=e)}return this.detectSupport().then((function(n){if(n)return s.loadTextureImage(e,l.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class E{constructor(e){this.name=C.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const e=s.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),n=this.parser.options.meshoptDecoder;if(!n||!n.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([i,n.ready]).then((function(t){const s=e.byteOffset||0,i=e.byteLength||0,l=e.count,r=e.byteStride,o=new ArrayBuffer(l*r),a=new Uint8Array(t[0],s,i);return n.decodeGltfBuffer(new Uint8Array(o),l,r,a,e.mode,e.filter),o}))}return null}}const I="glTF",T=1313821514,M=5130562;class P{constructor(e){this.name=C.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:THREE.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==I)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-12,i=new DataView(e,12);let n=0;for(;n",t).replace("#include ",s).replace("#include ",i).replace("#include ",n).replace("#include ",l)},Object.defineProperties(this,{specular:{get:function(){return r.specular.value},set:function(e){r.specular.value=e}},specularMap:{get:function(){return r.specularMap.value},set:function(e){r.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return r.glossiness.value},set:function(e){r.glossiness.value=e}},glossinessMap:{get:function(){return r.glossinessMap.value},set:function(e){r.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class L{constructor(){this.name=C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity"]}getMaterialType(){return F}extendParams(e,t,s){const i=t.extensions[this.name];e.color=new Color(1,1,1),e.opacity=1;const n=[];if(Array.isArray(i.diffuseFactor)){const t=i.diffuseFactor;e.color.fromArray(t),e.opacity=t[3]}if(void 0!==i.diffuseTexture&&n.push(s.assignTexture(e,"map",i.diffuseTexture,sRGBEncoding)),e.emissive=new Color(0,0,0),e.glossiness=void 0!==i.glossinessFactor?i.glossinessFactor:1,e.specular=new Color(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),void 0!==i.specularGlossinessTexture){const t=i.specularGlossinessTexture;n.push(s.assignTexture(e,"glossinessMap",t)),n.push(s.assignTexture(e,"specularMap",t,sRGBEncoding))}return Promise.all(n)}createMaterial(e){const t=new F(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=TangentSpaceNormalMap,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t}}class N{constructor(){this.name=C.KHR_MESH_QUANTIZATION}}class U extends THREE.Interpolant{constructor(e,t,s,i){super(e,t,s,i)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,i=this.valueSize,n=e*i*3+i;for(let e=0;e!==i;e++)t[e]=s[n+e];return t}}U.prototype.beforeStart_=U.prototype.copySampleValue_,U.prototype.afterEnd_=U.prototype.copySampleValue_,U.prototype.interpolate_=function(e,t,s,i){const n=this.resultBuffer,l=this.sampleValues,r=this.valueSize,o=2*r,a=3*r,d=i-t,c=(s-t)/d,h=c*c,p=h*c,m=e*a,u=m-a,g=-2*p+3*h,f=p-h,b=1-g,C=f-h+c;for(let e=0;e!==r;e++){const t=l[u+e+r],s=l[u+e+o]*d,i=l[m+e+r],a=l[m+e]*d;n[e]=b*t+C*s+g*i+f*a}return n};const q=new THREE.Quaternion;class j extends U{interpolate_(e,t,s,i){const n=super.interpolate_(e,t,s,i);return q.fromArray(n).normalize().toArray(n),n}}const B=0,z=1,G=2,V=3,W=4,Y=5,X=6,K={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Q={9728:THREE.NearestFilter,9729:THREE.LinearFilter,9984:THREE.NearestMipmapNearestFilter,9985:THREE.LinearMipmapNearestFilter,9986:THREE.NearestMipmapLinearFilter,9987:THREE.LinearMipmapLinearFilter},J={33071:THREE.ClampToEdgeWrapping,33648:THREE.MirroredRepeatWrapping,10497:THREE.RepeatWrapping},Z={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ee={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},te={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},se={CUBICSPLINE:void 0,LINEAR:THREE.InterpolateLinear,STEP:THREE.InterpolateDiscrete},ie="OPAQUE",ne="MASK",le="BLEND";function re(e,t,s){for(const i in s.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=s.extensions[i])}function oe(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function ae(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let s=0,i=t.weights.length;s{const s=this.associations.get(e);null!=s&&this.associations.set(t,s);for(const[s,i]of e.children.entries())n(i,t.children[s])};return n(s,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s=2&&m.setY(t,c[e*l+1]),l>=3&&m.setZ(t,c[e*l+2]),l>=4&&m.setW(t,c[e*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m}))}loadTexture(e){const t=this.json,s=this.options,i=t.textures[e].source,n=t.images[i];let l=this.textureLoader;if(n.uri){const e=s.manager.getHandler(n.uri);null!==e&&(l=e)}return this.loadTextureImage(e,i,l)}loadTextureImage(e,t,s){const i=this,n=this.json,l=n.textures[e],r=n.images[t],o=(r.uri||r.bufferView)+":"+l.sampler;if(this.textureCache[o])return this.textureCache[o];const a=this.loadImageSource(t,s).then((function(t){t.flipY=!1,l.name&&(t.name=l.name);const s=(n.samplers||{})[l.sampler]||{};return t.magFilter=Q[s.magFilter]||LinearFilter,t.minFilter=Q[s.minFilter]||LinearMipmapLinearFilter,t.wrapS=J[s.wrapS]||RepeatWrapping,t.wrapT=J[s.wrapT]||RepeatWrapping,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=a,a}loadImageSource(e,t){const s=this,i=this.json,n=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const l=i.images[e],r=self.URL||self.webkitURL;let o=l.uri||"",a=!1;if(void 0!==l.bufferView)o=s.getDependency("bufferView",l.bufferView).then((function(e){a=!0;const t=new Blob([e],{type:l.mimeType});return o=r.createObjectURL(t),o}));else if(void 0===l.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(o).then((function(e){return new Promise((function(s,i){let l=s;!0===t.isImageBitmapLoader&&(l=function(e){const t=new Texture(e);t.needsUpdate=!0,s(t)}),t.load(THREE.LoaderUtils.resolveURL(e,n.path),l,void 0,i)}))})).then((function(e){var t;return!0===a&&r.revokeObjectURL(o),e.userData.mimeType=l.mimeType||((t=l.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),e}));return this.sourceCache[e]=d,d}assignTexture(e,t,s,i){const n=this;return this.getDependency("texture",s.index).then((function(l){if(void 0===s.texCoord||0==s.texCoord||"aoMap"===t&&1==s.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+s.texCoord+" for texture "+t+" not yet supported."),n.extensions[C.KHR_TEXTURE_TRANSFORM]){const e=void 0!==s.extensions?s.extensions[C.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=n.associations.get(l);l=n.extensions[C.KHR_TEXTURE_TRANSFORM].extendTexture(l,e),n.associations.set(l,t)}}return void 0!==i&&(l.encoding=i),e[t]=l,l}))}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const i=void 0===t.attributes.tangent,n=void 0!==t.attributes.color,l=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new PointsMaterial,Material.prototype.copy.call(t,s),t.color.copy(s.color),t.map=s.map,t.sizeAttenuation=!1,this.cache.add(e,t)),s=t}else if(e.isLine){const e="LineBasicMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new LineBasicMaterial,Material.prototype.copy.call(t,s),t.color.copy(s.color),this.cache.add(e,t)),s=t}if(i||n||l){let e="ClonedMaterial:"+s.uuid+":";s.isGLTFSpecularGlossinessMaterial&&(e+="specular-glossiness:"),i&&(e+="derivative-tangents:"),n&&(e+="vertex-colors:"),l&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=s.clone(),n&&(t.vertexColors=!0),l&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(s))),s=t}s.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),e.material=s}getMaterialType(){return MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,i=this.extensions,n=s.materials[e];let l;const r={},o=n.extensions||{},a=[];if(o[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=i[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];l=e.getMaterialType(),a.push(e.extendParams(r,n,t))}else if(o[C.KHR_MATERIALS_UNLIT]){const e=i[C.KHR_MATERIALS_UNLIT];l=e.getMaterialType(),a.push(e.extendParams(r,n,t))}else{const s=n.pbrMetallicRoughness||{};if(r.color=new Color(1,1,1),r.opacity=1,Array.isArray(s.baseColorFactor)){const e=s.baseColorFactor;r.color.fromArray(e),r.opacity=e[3]}void 0!==s.baseColorTexture&&a.push(t.assignTexture(r,"map",s.baseColorTexture,sRGBEncoding)),r.metalness=void 0!==s.metallicFactor?s.metallicFactor:1,r.roughness=void 0!==s.roughnessFactor?s.roughnessFactor:1,void 0!==s.metallicRoughnessTexture&&(a.push(t.assignTexture(r,"metalnessMap",s.metallicRoughnessTexture)),a.push(t.assignTexture(r,"roughnessMap",s.metallicRoughnessTexture))),l=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),a.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,r)}))))}!0===n.doubleSided&&(r.side=DoubleSide);const d=n.alphaMode||ie;if(d===le?(r.transparent=!0,r.depthWrite=!1):(r.transparent=!1,d===ne&&(r.alphaTest=void 0!==n.alphaCutoff?n.alphaCutoff:.5)),void 0!==n.normalTexture&&l!==MeshBasicMaterial&&(a.push(t.assignTexture(r,"normalMap",n.normalTexture)),r.normalScale=new Vector2(1,1),void 0!==n.normalTexture.scale)){const e=n.normalTexture.scale;r.normalScale.set(e,e)}return void 0!==n.occlusionTexture&&l!==MeshBasicMaterial&&(a.push(t.assignTexture(r,"aoMap",n.occlusionTexture)),void 0!==n.occlusionTexture.strength&&(r.aoMapIntensity=n.occlusionTexture.strength)),void 0!==n.emissiveFactor&&l!==MeshBasicMaterial&&(r.emissive=(new Color).fromArray(n.emissiveFactor)),void 0!==n.emissiveTexture&&l!==MeshBasicMaterial&&a.push(t.assignTexture(r,"emissiveMap",n.emissiveTexture,sRGBEncoding)),Promise.all(a).then((function(){let s;return s=l===F?i[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(r):new l(r),n.name&&(s.name=n.name),oe(s,n),t.associations.set(s,{materials:e}),n.extensions&&re(i,s,n),s}))}createUniqueName(e){const t=PropertyBinding.sanitizeNodeName(e||"");let s=t;for(let e=1;this.nodeNamesUsed[s];++e)s=t+"_"+e;return this.nodeNamesUsed[s]=!0,s}loadGeometries(e){const t=this,s=this.extensions,i=this.primitiveCache;function n(e){return s[C.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(s){return ue(s,e,t)}))}const l=[];for(let s=0,r=e.length;s0&&ae(h,n),h.name=t.createUniqueName(n.name||"mesh_"+e),oe(h,n),c.extensions&&re(i,h,c),t.assignFinalMaterial(h),a.push(h)}for(let s=0,i=a.length;s1?new Group:1===t.length?t[0]:new Object3D,r!==t[0])for(let e=0,s=t.length;e{const t=new Map;for(const[e,s]of n.associations)(e instanceof Material||e instanceof Texture)&&t.set(e,s);return e.traverse((e=>{const s=n.associations.get(e);null!=s&&t.set(e,s)})),t})(l),l}))}}function me(e,t,s,i){const n=s.nodes[e];return i.getDependency("node",e).then((function(e){if(void 0===n.skin)return e;let t;return i.getDependency("skin",n.skin).then((function(e){t=e;const s=[];for(let e=0,n=t.joints.length;e{const s=n[e];return s&&(l={profileId:e,profilePath:`${t}/${s.path}`,deprecated:!!s.deprecated}),!!l})),!l){if(!s)throw new Error("No matching profile name found");const e=n[s];if(!e)throw new Error(`No matching profile name found and default profile "${s}" missing.`);l={profileId:s,profilePath:`${t}/${e.path}`,deprecated:!!e.deprecated}}const r=await be(l.profilePath);let o;if(i){let t;if(t="any"===e.handedness?r.layouts[Object.keys(r.layouts)[0]]:r.layouts[e.handedness],!t)throw new Error(`No matching handedness, ${e.handedness}, in profile ${l.profileId}`);t.assetPath&&(o=l.profilePath.replace("profile.json",t.assetPath))}return{profile:r,assetPath:o}}const ye={xAxis:0,yAxis:0,button:0,state:fe.ComponentState.DEFAULT};class ve{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===fe.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(ye)}updateFromComponent({xAxis:e,yAxis:t,button:s,state:i}){const{normalizedXAxis:n,normalizedYAxis:l}=function(e=0,t=0){let s=e,i=t;if(Math.sqrt(e*e+t*t)>1){const n=Math.atan2(t,e);s=Math.cos(n),i=Math.sin(n)}return{normalizedXAxis:.5*s+.5,normalizedYAxis:.5*i+.5}}(e,t);switch(this.componentProperty){case fe.ComponentProperty.X_AXIS:this.value=this.states.includes(i)?n:.5;break;case fe.ComponentProperty.Y_AXIS:this.value=this.states.includes(i)?l:.5;break;case fe.ComponentProperty.BUTTON:this.value=this.states.includes(i)?s:0;break;case fe.ComponentProperty.STATE:this.valueNodeProperty===fe.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(i):this.value=this.states.includes(i)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}}class we{constructor(e,t){if(!(e&&t&&t.visualResponses&&t.gamepadIndices&&0!==Object.keys(t.gamepadIndices).length))throw new Error("Invalid arguments supplied");this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach((e=>{const s=new ve(t.visualResponses[e]);this.visualResponses[e]=s})),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:fe.ComponentState.DEFAULT,button:void 0!==this.gamepadIndices.button?0:void 0,xAxis:void 0!==this.gamepadIndices.xAxis?0:void 0,yAxis:void 0!==this.gamepadIndices.yAxis?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(e){if(this.values.state=fe.ComponentState.DEFAULT,void 0!==this.gamepadIndices.button&&e.buttons.length>this.gamepadIndices.button){const t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||1===this.values.button?this.values.state=fe.ComponentState.PRESSED:(t.touched||this.values.button>fe.ButtonTouchThreshold)&&(this.values.state=fe.ComponentState.TOUCHED)}void 0!==this.gamepadIndices.xAxis&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===fe.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>fe.AxisTouchThreshold&&(this.values.state=fe.ComponentState.TOUCHED)),void 0!==this.gamepadIndices.yAxis&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===fe.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>fe.AxisTouchThreshold&&(this.values.state=fe.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach((e=>{e.updateFromComponent(this.values)}))}}class _e{constructor(e,t,s){if(!e)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No profile supplied");this.xrInputSource=e,this.assetUrl=s,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach((e=>{const t=this.layoutDescription.components[e];this.components[e]=new we(e,t)})),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const e=[];return Object.values(this.components).forEach((t=>{e.push(t.data)})),e}updateFromGamepad(){Object.values(this.components).forEach((e=>{e.updateFromGamepad(this.xrInputSource.gamepad)}))}}class Se extends THREE.Object3D{constructor(){super(),this.motionController=null,this.envMap=null}setEnvironmentMap(e){return this.envMap==e||(this.envMap=e,this.traverse((e=>{e.isMesh&&(e.material.envMap=this.envMap,e.material.needsUpdate=!0)}))),this}updateMatrixWorld(e){super.updateMatrixWorld(e),this.motionController&&(this.motionController.updateFromGamepad(),Object.values(this.motionController.components).forEach((e=>{Object.values(e.visualResponses).forEach((e=>{const{valueNode:t,minNode:s,maxNode:i,value:n,valueNodeProperty:l}=e;t&&(l===fe.VisualResponseProperty.VISIBILITY?t.visible=n:l===fe.VisualResponseProperty.TRANSFORM&&(t.quaternion.slerpQuaternions(s.quaternion,i.quaternion,n),t.position.lerpVectors(s.position,i.position,n)))}))})))}}function Ae(e,t){!function(e,t){Object.values(e.components).forEach((e=>{const{type:s,touchPointNodeName:i,visualResponses:n}=e;if(s===fe.ComponentType.TOUCHPAD)if(e.touchPointNode=t.getObjectByName(i),e.touchPointNode){const t=new SphereGeometry(.001),s=new MeshBasicMaterial({color:255}),i=new Mesh(t,s);e.touchPointNode.add(i)}else console.warn(`Could not find touch dot, ${e.touchPointNodeName}, in touchpad component ${e.id}`);Object.values(n).forEach((e=>{const{valueNodeName:s,minNodeName:i,maxNodeName:n,valueNodeProperty:l}=e;if(l===fe.VisualResponseProperty.TRANSFORM){if(e.minNode=t.getObjectByName(i),e.maxNode=t.getObjectByName(n),!e.minNode)return void console.warn(`Could not find ${i} in the model`);if(!e.maxNode)return void console.warn(`Could not find ${n} in the model`)}e.valueNode=t.getObjectByName(s),e.valueNode||console.warn(`Could not find ${s} in the model`)}))}))}(e.motionController,t),e.envMap&&t.traverse((t=>{t.isMesh&&(t.material.envMap=e.envMap,t.material.needsUpdate=!0)})),e.add(t)}class xe{constructor(e=null){this.gltfLoader=e,this.path="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",this._assetCache={},this.gltfLoader||(this.gltfLoader=new f)}createControllerModel(e){const t=new Se;let s=null;return e.addEventListener("connected",(e=>{const i=e.data;"tracked-pointer"===i.targetRayMode&&i.gamepad&&Ce(i,this.path,"generic-trigger").then((({profile:e,assetPath:n})=>{t.motionController=new _e(i,e,n);const l=this._assetCache[t.motionController.assetUrl];if(l)s=l.scene.clone(),Ae(t,s);else{if(!this.gltfLoader)throw new Error("GLTFLoader not set.");this.gltfLoader.setPath(""),this.gltfLoader.load(t.motionController.assetUrl,(e=>{this._assetCache[t.motionController.assetUrl]=e,s=e.scene.clone(),Ae(t,s)}),null,(()=>{throw new Error(`Asset ${t.motionController.assetUrl} missing or malformed.`)}))}})).catch((e=>{console.warn(e)}))})),e.addEventListener("disconnected",(()=>{t.motionController=null,t.remove(s),s=null})),t}}class ke extends THREE.EventDispatcher{constructor(e){if(super(),void 0===e)return void console.error("ControllerGestures must be passed a renderer");const t=new THREE.Clock;this.controller1=e.xr.getController(0),this.controller1.userData.gestures={index:0},this.controller1.userData.selectPressed=!1,this.controller1.addEventListener("selectstart",i),this.controller1.addEventListener("selectend",n),this.controller2=e.xr.getController(1),this.controller2.userData.gestures={index:1},this.controller2.userData.selectPressed=!1,this.controller2.addEventListener("selectstart",i),this.controller2.addEventListener("selectend",n),this.doubleClickLimit=.2,this.pressMinimum=.4,this.right=new THREE.Vector3(1,0,0),this.up=new THREE.Vector3(0,1,0),this.type="unknown",this.prevTap="none",this.clock=t;const s=this;function i(){const e=this.userData.gestures;e.startPosition=void 0,e.startTime=t.getElapsedTime(),-1==s.type.indexOf("tap")&&(e.taps=0),s.type="unknown",this.userData.selectPressed=!0}function n(){const e=this.userData.gestures;e.endTime=t.getElapsedTime();e.endTime-e.startTime.05&&(e.startPosition=this.controller1.position.clone())),this.controller2.userData.selectPressed&&void 0===t.startPosition&&(i=s-t.startTime,i>.05&&(t.startPosition=this.controller2.position.clone())),!this.controller1.userData.selectPressed&&"tap"===this.type&&(i=this.clock.getElapsedTime()-e.endTime,i>this.doubleClickLimit)){switch(e.taps){case 1:self.prevTap="tap";break;case 2:this.dispatchEvent({type:"doubletap",position:this.controller1.position,matrixWorld:this.controller1.matrixWorld}),self.prevTap="doubletap"}this.type="unknown",e.taps=0}if("unknown"===this.type&&this.touch)"doubletap"==self.prevTap?(this.type="pinch",this.startDistance=this.controller1.position.distanceTo(this.controller2.position),this.dispatchEvent({type:"pinch",delta:new THREE.Vector3(0,0,0),scale:1,initialise:!0})):(this.type="pan",this.startPosition=this.controller1.position.clone(),this.dispatchEvent({type:"pan",delta:new THREE.Vector3(0,0,0),initialise:!0}));else if(("pinch"===this.type||"pan"===this.type)&&"doubletap"==self.prevTap&&this.controller2.position){const e=this.controller1.position.distanceTo(this.controller2.position)/this.startDistance,t=this.controller1.position.clone().sub(this.startPosition);this.dispatchEvent({type:"pinch",delta:t,scale:e})}}}class Oe{constructor(e,t){this.config=void 0===t?{panelSize:{width:1,height:1},width:512,height:512,opacity:.7,body:{fontFamily:"Arial",fontSize:30,padding:20,backgroundColor:"#000",fontColor:"#fff",borderRadius:6}}:t,void 0===this.config.width&&(this.config.width=512),void 0===this.config.height&&(this.config.height=512),void 0===this.config.body&&(this.config.body={fontFamily:"Arial",size:30,padding:20,backgroundColor:"#000",fontColor:"#fff",borderRadius:6});const s=this.config.body;void 0===s.borderRadius&&(s.borderRadius=6),void 0===s.fontFamily&&(s.fontFamily="Arial"),void 0===s.padding&&(s.padding=20),void 0===s.fontSize&&(s.fontSize=30),void 0===s.backgroundColor&&(s.backgroundColor="#000"),void 0===s.fontColor&&(s.fontColor="#fff"),Object.entries(this.config).forEach((([e,t])=>{if(!("object"!=typeof t||"panelSize"===e||t instanceof THREE.WebGLRenderer||t instanceof THREE.Scene)){const e=void 0!==t.position?t.position:{x:0,y:0};void 0!==e.left&&void 0===e.x&&(e.x=e.left),void 0!==e.top&&void 0===e.y&&(e.y=e.top);const s=void 0!==t.width?t.width:this.config.width,i=void 0!==t.height?t.height:this.config.height;void 0!==e.right&&void 0===e.x&&(e.x=this.config.width-e.right-s),void 0!==e.bottom&&void 0===e.y&&(e.y=this.config.height-e.bottom-i),void 0===e.x&&(e.x=0),void 0===e.y&&(e.y=0),t.position=e,void 0===t.type&&(t.type="text")}}));const i=this.createOffscreenCanvas(this.config.width,this.config.height);this.context=i.getContext("2d"),this.context.save();const n=void 0!==this.config.opacity?this.config.opacity:.7,l=new THREE.MeshBasicMaterial({transparent:!0,opacity:n});this.panelSize=void 0!==this.config.panelSize?this.config.panelSize:{width:1,height:1};const r=new THREE.PlaneGeometry(this.panelSize.width,this.panelSize.height);this.mesh=new THREE.Mesh(r,l),this.texture=new THREE.CanvasTexture(i),this.mesh.material.map=this.texture,this.scene=this.config.scene;if(Object.values(this.config).filter((e=>"input-text"===e.type)).length>0){this.keyboard=new Re(this.panelSize.width,this.config.renderer);this.keyboard.mesh.position.set(0,-.3,.2),this.mesh.add(this.keyboard.mesh)}if(void 0===e)this.content={body:""},this.config.body.type="text";else{this.content=e;Object.values(t).filter((e=>"button"===e.type||"scroll"===e.overflow||"input-text"===e.type)).length>0&&(void 0===t||void 0===t.renderer?console.warn("CanvasUI: button, scroll or input-text in the config but no renderer"):(this.renderer=t.renderer,this.initControllers()))}this.selectedElements=[void 0,void 0],this.selectPressed=[!1,!1],this.scrollData=[void 0,void 0],this.intersects=[void 0,void 0],this.needsUpdate=!0,this.update()}getIntersectY(e){const t=this.config.height||512,s=this.intersects[e];return void 0===s||void 0===s.uv?0:(1-s.uv.y)*t}initControllers(){this.vec3=new THREE.Vector3,this.mat4=new THREE.Matrix4,this.raycaster=new THREE.Raycaster;const e=this;function t(t){const s=t.target===e.controller?0:1,i=e.selectedElements[s];if(void 0!==i)if("button"==i.type)e.select(s);else if("input-text"==i.type&&e.keyboard)if(e.keyboard.visible)e.keyboard.linkedUI=void 0,e.keyboard.linkedText=void 0,e.keyboard.linkedElement=void 0,e.keyboard.visible=!1;else{let t;e.keyboard.linkedUI=e,Object.entries(e.config).forEach((([e,s])=>{s==i&&(t=e)}));const s=(.5-(i.position.y+i.height+e.config.body.padding)/e.config.height)*e.panelSize.height,n=Math.max(e.panelSize.width,e.panelSize.height)/2;e.keyboard.position.set(0,-n/1.5-s,.1),e.keyboard.linkedText=e.content[t],e.keyboard.linkedName=t,e.keyboard.linkedElement=i,e.keyboard.visible=!0}}function s(t){const s=t.target===e.controller?0:1;if(e.selectPressed[s]=!0,void 0!==e.selectedElements[s]&&"scroll"==e.selectedElements[s].overflow){const t=e.selectedElements[s];e.scrollData[s]={scrollY:t.scrollY,rayY:e.getIntersectY(s)}}}function i(t){const s=t.target===e.controller?0:1;e.selectPressed[s]=!1,void 0!==e.selectedElements[s]&&"scroll"==e.selectedElements[s].overflow&&(e.scrollData[s]=void 0)}if(this.controller=this.renderer.xr.getController(0),this.controller.addEventListener("select",t),this.controller.addEventListener("selectstart",s),this.controller.addEventListener("selectend",i),this.controller1=this.renderer.xr.getController(1),this.controller1.addEventListener("select",t),this.controller1.addEventListener("selectstart",s),this.controller1.addEventListener("selectend",i),this.scene){const e=.015,t=new THREE.IcosahedronBufferGeometry(e),s=new THREE.MeshBasicMaterial({color:170}),i=new THREE.Mesh(t,s);i.visible=!1,this.scene.add(i);const n=new THREE.Mesh(t,s);n.visible=!1,this.scene.add(n),this.intersectMesh=[i,n]}}setClip(e){const t=this.context;if(t.restore(),t.save(),void 0!==e.clipPath){const s=new Path2D(e.clipPath);t.clip(s)}else{const s=void 0!==e.position?e.position:{x:0,y:0},i=e.borderRadius||0,n=e.width||this.config.width,l=e.height||this.config.height;if(t.beginPath(),0!==i){const e=Math.PI/2;t.moveTo(s.x+i,s.y),t.arc(s.x+i,s.y+i,i,e,2*e,!0),t.lineTo(s.x,s.y+l-i),t.arc(s.x+i,s.y+l-i,i,0,e,!0),t.lineTo(s.x+n-i,s.y+l),t.arc(s.x+n-i,s.y+l-i,i,3*e,4*e,!0),t.lineTo(s.x+n,s.y+i),t.arc(s.x+n-i,s.y+i,i,2*e,3*e,!0),t.closePath(),t.clip()}else t.rect(s.x,s.y,n,l),t.clip()}}setPosition(e,t,s){void 0!==this.mesh&&this.mesh.position.set(e,t,s)}setRotation(e,t,s){void 0!==this.mesh&&this.mesh.rotation.set(e,t,s)}updateElement(e,t){let s=this.content[e];void 0!==s?("object"==typeof s?s.content=t:s=t,this.content[e]=s,this.needsUpdate=!0):console.warn(`CanvasGUI.updateElement: No ${e} found`)}get panel(){return this.mesh}getElementAtLocation(e,t){const s=this,i=Object.entries(this.config).filter((([i,n])=>{if(!("object"!=typeof n||"panelSize"===i||"body"===i||n instanceof THREE.WebGLRenderer||n instanceof THREE.Scene)){const i=n.position,l=void 0!==n.width?n.width:s.config.width,r=void 0!==n.height?n.height:s.config.height;return e>=i.x&&e=i.y&&t0?(this.hover(t,s[0].uv),this.intersects[t]=s[0],this.scroll(t)):(this.hover(t),this.intersects[t]=void 0,this.scroll(t))}update(){if(void 0===this.mesh)return;if(this.controller&&this.handleController(this.controller,0),this.controller1&&this.handleController(this.controller1,1),this.keyboard&&this.keyboard.visible&&this.keyboard.update(),!this.needsUpdate)return;let e=this.context;e.clearRect(0,0,this.config.width,this.config.height);const t=this.config.body.backgroundColor?this.config.body.backgroundColor:"#000";!this.config.body.fontFamily||this.config.body.fontFamily;const s=this.config.body.fontColor?this.config.body.fontColor:"#fff";!this.config.body.fontSize||this.config.body.fontSize,this.setClip(this.config.body),e.fillStyle=t,e.fillRect(0,0,this.config.width,this.config.height);const i=this;Object.entries(this.content).forEach((([t,n])=>{const l=void 0!==i.config[t]?i.config[t]:i.config.body;if("none"!==(void 0!==l.display?l.display:"block")){const r=void 0!==l.position?l.position:{x:0,y:0},o=void 0!==l.width?l.width:i.config.width,a=void 0!==l.height?l.height:i.config.height;"button"!=l.type||n.toLowerCase().startsWith("")||(void 0===l.borderRadius&&(l.borderRadius=6),void 0===l.textAlign&&(l.textAlign="center")),i.setClip(l);const d=n.toLowerCase().startsWith(""),c=void 0!==i.selectedElements[0]&&this.selectedElements[0]===l||void 0!==i.selectedElements[1]&&this.selectedElements[1]===l;if(void 0!==l.backgroundColor&&(c&&"button"==l.type&&void 0!==l.hover?e.fillStyle=l.hover:e.fillStyle=l.backgroundColor,e.fillRect(r.x,r.y,o,a)),"text"==l.type||"button"==l.type||"input-text"==l.type){let h=!1;if(c?(d||"button"!=l.type?e.fillStyle=void 0!==l.hover?l.hover:void 0!==l.fontColor?l.fontColor:s:e.fillStyle=void 0!==l.fontColor?l.fontColor:s,h=void 0===l.hover):e.fillStyle=void 0!==l.fontColor?l.fontColor:s,d){const t=n.toUpperCase().substring(6,n.length-7);e.save(),e.translate(r.x,r.y);const s=new Path2D(t);e.fill(s),e.restore()}else i.wrapText(t,n);h&&(e.beginPath(),e.strokeStyle="#fff",e.lineWidth=2,e.rect(r.x,r.y,o,a),e.stroke())}else if("img"==l.type)if(void 0===l.img)this.loadImage(n).then((e=>{console.log(`w: ${e.width} | h: ${e.height}`),l.img=e,i.needsUpdate=!0,i.update()})).catch((e=>console.error(e)));else{const t=o/(l.img.width/l.img.height);e.drawImage(l.img,r.x,r.y,o,t)}}})),this.needsUpdate=!1,this.texture.needsUpdate=!0}loadImage(e){return new Promise(((t,s)=>{const i=new THREE.Image;i.addEventListener("load",(()=>t(i))),i.addEventListener("error",(e=>s(e))),i.src=e}))}createOffscreenCanvas(e,t){const s=document.createElement("canvas");return s.width=e,s.height=t,s}fillRoundedRect(e,t,s,i,n){const l=this.context;l.beginPath(),l.moveTo(e+n,t),l.lineTo(e+s-n,t),l.quadraticCurveTo(e+s,t,e+s,t+n),l.lineTo(e+s,t+i-n),l.quadraticCurveTo(e+s,t+i,e+s-n,t+i),l.lineTo(e+n,t+i),l.quadraticCurveTo(e,t+i,e,t+i-n),l.lineTo(e,t+n),l.quadraticCurveTo(e,t,e+n,t),l.closePath(),l.fill()}lookAt(e){void 0!==this.mesh&&(e instanceof Vector3?this.mesh.lookAt(e):console.error("CanvasUI lookAt called parameter not a THREE.Vector3"))}get visible(){return void 0!==this.mesh&&this.mesh.visible}set visible(e){this.mesh&&(this.mesh.visible=e)}get position(){if(void 0!==this.mesh)return this.mesh.position}set position(e){void 0!==this.mesh&&(e instanceof Vector3?this.mesh.position.copy(e):console.error("CanvasUI trying to set the mesh position using a parameter that is not a THREE.Vector3"))}get quaternion(){if(void 0!==this.mesh)return this.mesh.quaternion}set quaternion(e){void 0!==this.mesh&&(e instanceof QUaternion?this.mesh.quaternion.copy(e):console.error("CanvasUI trying to set the mesh quaternion using a parameter that is not a THREE.Quaternion"))}wrapText(e,t){const s=t.split(" ");let i="";const n=[],l=void 0!==this.config[e]?this.config[e]:this.config.body,r=void 0!==l.width?l.width:this.config.width,o=void 0!==l.height?l.height:this.config.height,a=void 0!==l.position?l.position:{x:0,y:0},d=void 0!==l.padding?l.padding:void 0!==this.config.body.padding?this.config.body.padding:10,c=void 0!==l.paddingTop?l.paddingTop:d,h=void 0!==l.paddingLeft?l.paddingLeft:d,p=void 0!==l.paddingBottom?l.paddingBottom:d,m=void 0!==l.paddingRight?l.paddingRight:d,u={x:a.x+h,y:a.y+c,width:r-h-m,height:o-c-p},g=void 0!==l.textAlign?l.textAlign:void 0!==this.config.body.textAlign?this.config.body.textAlign:"left",f=void 0!==l.fontSize?l.fontSize:void 0!==this.config.body.fontSize?this.config.body.fontSize:30,b=void 0!==l.fontFamily?l.fontFamily:void 0!==this.config.body.fontFamily?this.config.body.fontFamily:"Arial",C=f+(void 0!==l.leading?l.leading:void 0!==this.config.body.leading?this.config.body.leading:8),y=this.context;y.textAlign=g,y.font=`${f}px '${b}'`,s.forEach((function(e){let t=s.length>1?`${i}${e} `:e,l=y.measureText(t);if(l.width>u.width&&e.length>1)if(0==i.length&&l.width>u.width){for(;l.width>u.width;){let s=0;do{s++,t=e.substr(0,s),l=y.measureText(t)}while(l.widthu.height&&"scroll"===l.overflow){void 0===l.scrollY&&(l.scrollY=0);const e=void 0!==l.fontColor?l.fontColor:this.config.body.fontColor;y.fillStyle="#aaa",this.fillRoundedRect(a.x+r-12,a.y,12,o,6),y.fillStyle="#666";const t=u.height/v,s=t*o,i=-l.scrollY*t;this.fillRoundedRect(a.x+r-12,a.y+i,12,s,6),y.fillStyle=e,w=l.scrollY,l.minScrollY=u.height-v}let _,S=w+u.y+f/2;switch(g){case"center":_=u.x+u.width/2;break;case"right":_=u.x+u.width;break;default:_=u.x}n.forEach((e=>{S+C>0&&y.fillText(e,_,S),S+=C}))}}class Re{constructor(e,t,s="EN"){const i=this.getConfig(s);i.panelSize={width:e,height:.5*e},i.height=256,i.body={backgroundColor:"#555"},i.renderer=t;const n=this.getContent(s);this.keyboard=new Oe(n,i),this.keyboard.mesh.visible=!1,this.shift=!1}get mesh(){return this.keyboard.mesh}getConfig(e){const t={};let s=10;const i=39.2,n=49,l="#333",r="#000";let o=s,a=s;for(let e=0;e<10;e++){const d={type:"button",position:{x:a,y:o},width:i,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e)};t[`btn${e}`]=d,a+=49.2}o+=59,a=s;for(let e=0;e<10;e++){const d={type:"button",position:{x:a,y:o},width:i,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+10)};t[`btn${e+10}`]=d,a+=49.2}o+=59,a=s;for(let e=0;e<9;e++){const d=0==e||8==e?1.5*i+5:i,c={type:"button",position:{x:a,y:o},width:d,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+20)};t[`btn${e+20}`]=c,a+=d+s}o+=59,a=s;for(let e=0;e<5;e++){const d=0==e||4==e?88.4:2==e?186.8:i,c={type:"button",position:{x:a,y:o},width:d,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+30)};0==e&&(c.fontSize=20),t[`btn${e+30}`]=c,a+=d+s}return t}getContent(e,t=0){let s,i={};switch(this.language=e,this.keyboardIndex=t,t){case 0:s=["q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","@","⇧","z","x","c","v","b","n","m","⇦","","?123",","," ",".","↲"];for(let e=0;e","_","`","~",":",";","⇦","","abc",","," ",".","↲"];for(let e=0;e=0;e--){let s=t.scene.children[e];t.scene.remove(s)}else t.scene=new THREE.Scene;if(void 0!==t.scene_ghost)for(let e=t.scene_ghost.children.length-1;e>=0;e--){let s=t.scene_ghost.children[e];t.scene_ghost.remove(s)}else t.scene_ghost=new THREE.Scene;if(""!=s.htmlCls.setHtmlCls.getCookie("shininess")){let e=parseFloat(s.htmlCls.setHtmlCls.getCookie("shininess"));t.shininess!=e&&s.htmlCls.clickMenuCls.setLogCmd("set shininess "+e,!0),t.shininess=e}if(!s.bNode&&""!=s.htmlCls.setHtmlCls.getCookie("light1")){let e=parseFloat(s.htmlCls.setHtmlCls.getCookie("light1")),i=parseFloat(s.htmlCls.setHtmlCls.getCookie("light2")),n=parseFloat(s.htmlCls.setHtmlCls.getCookie("light3"));t.light1==e&&t.light2==i&&t.light3==n||s.htmlCls.clickMenuCls.setLogCmd("set light | light1 "+e+" | light2 "+i+" | light3 "+n,!0),t.light1=e,t.light2=i,t.light3=n}t.directionalLight=new THREE.DirectionalLight(16777215,t.light1),t.directionalLight2=new THREE.DirectionalLight(16777215,t.light2),t.directionalLight3=new THREE.DirectionalLight(16777215,t.light3),t.cam_z>0?(t.directionalLight.position.set(-1,1,1),t.directionalLight2.position.set(1,1,1),t.directionalLight3.position.set(1,1,-1),t.lightPos=new THREE.Vector3(-1,1,1),t.lightPos2=new THREE.Vector3(1,1,1),t.lightPos3=new THREE.Vector3(1,1,-1)):(t.directionalLight.position.set(-1,1,-1),t.directionalLight2.position.set(1,1,-1),t.directionalLight3.position.set(1,1,1),t.lightPos=new THREE.Vector3(-1,1,-1),t.lightPos2=new THREE.Vector3(1,1,-1),t.lightPos3=new THREE.Vector3(1,1,1));let i=new THREE.AmbientLight(8947848);if(t.scene.add(t.directionalLight),t.scene.add(i),void 0!==t.mdl)for(let e=t.mdl.children.length-1;e>=0;e--){let s=t.mdl.children[e];s.geometry&&s.geometry.dispose(),s.material&&s.material.dispose(),t.mdl.remove(s)}if(void 0!==t.mdlImpostor){for(let e=t.mdlImpostor.children.length-1;e>=0;e--){let s=t.mdlImpostor.children[e];s.geometry&&s.geometry.dispose(),s.material&&s.material.dispose(),t.mdlImpostor.remove(s)}t.mdlImpostor.children.length=0}s.bNode||t.renderer.renderLists.dispose(),t.mdl=new THREE.Object3D,t.mdlImpostor=new THREE.Object3D,t.scene.add(t.mdl),t.scene.add(t.mdlImpostor),t.mdl_ghost=new THREE.Object3D,t.scene_ghost.add(t.mdl_ghost),t.objects=[],t.objects_ghost=[],t.raycaster=new THREE.Raycaster,t.projector=new THREE.Projector,t.mouse=new THREE.Vector2;let n=s.parasCls.backgroundColors[t.opts.background.toLowerCase()];s.bNode||("transparent"===t.opts.background.toLowerCase()?t.renderer.setClearColor(n,0):t.renderer.setClearColor(n,1)),t.perspectiveCamera=new THREE.PerspectiveCamera(20,t.container.whratio,.1,1e4),t.perspectiveCamera.position.set(0,0,t.cam_z),t.perspectiveCamera.lookAt(new THREE.Vector3(0,0,0)),t.orthographicCamera=new THREE.OrthographicCamera,t.orthographicCamera.position.set(0,0,t.cam_z),t.orthographicCamera.lookAt(new THREE.Vector3(0,0,0)),t.cams={perspective:t.perspectiveCamera,orthographic:t.orthographicCamera}}setVrAr(){let e=this.icn3d;e.icn3dui;let t=this;e.bSetVrAr=!0,e.bVr?(e.canvasUI=this.createUI(),e.raycasterVR=new THREE.Raycaster,e.workingMatrix=new THREE.Matrix4,e.workingVector=new THREE.Vector3,e.origin=new THREE.Vector3,e.dolly=new THREE.Object3D,e.dolly.position.z=5,e.dolly.add(e.cam),e.scene.add(e.dolly),e.dollyId=e.dolly.id,e.dummyCam=new THREE.Object3D,e.cam.add(e.dummyCam),e.clock=new THREE.Clock,e.controllers=this.getControllers(),e.controllers.forEach((s=>{s.addEventListener("connected",(function(e){try{const s={},i="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",n="generic-trigger";Ce(e.data,i,n).then((({profile:i,assetPath:n})=>{s.name=i.profileId,s.targetRayMode=e.data.targetRayMode,Object.entries(i.layouts).forEach((([e,t])=>{const i={};Object.values(t.components).forEach((e=>{i[e.rootNodeName]=e.gamepadIndices})),s[e]=i})),t.updateControllers(s)}))}catch(e){}})),s.addEventListener("disconnected",(function(){this.remove(this.children[0]),e.controllers.forEach((e=>{}))}))}))):e.bAr&&(e.gestures=new ke(e.renderer),e.scene.add(e.gestures.controller1),e.scene.add(e.gestures.controller2),e.gestures.addEventListener("doubletap",(e=>{t.positionCenter()})),e.gestures.addEventListener("pinch",(s=>{if(void 0!==s.initialise)t.startPosition=e.mdl.position.clone(),t.startScale=e.mdl.scale.clone();else{let i=1;const n=t.startScale.clone().multiplyScalar(s.scale*i);e.mdl.scale.copy(n)}})))}positionCenter(){let e=this.icn3d;e.icn3dui;const t=e.gestures.controller1;e.mdl.position.set(-.06,0,-.6).applyMatrix4(t.matrixWorld),e.mdl.scale.copy(new THREE.Vector3(.005,.005,.005))}setVrArButtons(){let e=this.icn3d,t=e.icn3dui;e.bSetVrArButtons=!0,t.bNode||($("#"+t.pre+"VRButton").remove(),$("#"+t.pre+"viewer").get(0).appendChild(e.VRButtonCls.createButton(e.renderer)),$("#"+t.pre+"ARButton").remove(),$("#"+t.pre+"viewer").get(0).appendChild(e.ARButtonCls.createButton(e.renderer)))}updateControllers(e){this.icn3d.icn3dui,this.addEventForController(e,"right"),this.addEventForController(e,"left")}addEventForController(e,t){let s=this.icn3d;s.icn3dui;const i="right"==t?s.renderer.xr.getController(0):s.renderer.xr.getController(1),n="right"==t?e.right:e.left;if(void 0!==n){let e=!1,t=!1;Object.keys(n).forEach((i=>{-1!=i.indexOf("trigger")&&(e=!0),-1!=i.indexOf("squeeze")&&(t=!0),-1==i.indexOf("thumbstick")&&-1==i.indexOf("touchpad")||(s.xAxisIndex=n[i].xAxis,s.yAxisIndex=n[i].yAxis)})),e&&(i.addEventListener("selectstart",(function(){this.userData.selectPressed=!0})),i.addEventListener("selectend",(function(){this.userData.selectPressed=!1,this.userData.selected=void 0}))),t&&(i.addEventListener("squeezestart",(function(){this.userData.squeezePressed=!0,s.cam.add(s.canvasUI.mesh)})),i.addEventListener("squeezeend",(function(){this.userData.squeezePressed=!1,s.cam.remove(s.canvasUI.mesh)})))}}createUI(){let e=this.icn3d;e.icn3dui;let t=94,s=50,i=44,n=12,l="#1c94c4",r="#ccc",o="#fbcb09";const a={panelSize:{width:2,height:1.2},height:300,select:{type:"button",position:{top:6,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},residue:{type:"button",position:{top:6,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.pk=2,e.cam.remove(e.canvasUI.mesh)}},secondarySelect:{type:"button",position:{top:6,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.pk=3,e.cam.remove(e.canvasUI.mesh)}},chainSelect:{type:"button",position:{top:6,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.pk=5,e.cam.remove(e.canvasUI.mesh)}},style:{type:"button",position:{top:62,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},ribbon:{type:"button",position:{top:62,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","ribbon"),e.setOptionCls.setStyle("nucleotides","nucleotide cartoon"),e.cam.remove(e.canvasUI.mesh)}},schematic:{type:"button",position:{top:62,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","schematic"),e.setOptionCls.setStyle("nucleotides","schematic"),e.cam.remove(e.canvasUI.mesh)}},stick:{type:"button",position:{top:62,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","stick"),e.setOptionCls.setStyle("nucleotides","stick"),e.cam.remove(e.canvasUI.mesh)}},sphere:{type:"button",position:{top:62,left:406},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","sphere"),e.setOptionCls.setStyle("nucleotides","sphere"),e.cam.remove(e.canvasUI.mesh)}},color:{type:"button",position:{top:118,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},rainbow:{type:"button",position:{top:118,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","rainbow for chains"),e.cam.remove(e.canvasUI.mesh)}},atomColor:{type:"button",position:{top:118,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","atom"),e.cam.remove(e.canvasUI.mesh)}},secondaryColor:{type:"button",position:{top:118,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","secondary structure green"),e.cam.remove(e.canvasUI.mesh)}},AlphaFold:{type:"button",position:{top:118,left:406},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","confidence"),e.cam.remove(e.canvasUI.mesh)}},unicolor:{type:"button",position:{top:174,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},red:{type:"button",position:{top:168,left:100},width:i,height:s,fontColor:"red",hover:o,onSelect:function(){e.setOptionCls.setOption("color","red"),e.cam.remove(e.canvasUI.mesh)}},green:{type:"button",position:{top:168,left:150},width:i,height:s,fontColor:"green",hover:o,onSelect:function(){e.setOptionCls.setOption("color","green"),e.cam.remove(e.canvasUI.mesh)}},blue:{type:"button",position:{top:168,left:200},width:i,height:s,fontColor:"blue",hover:o,onSelect:function(){e.setOptionCls.setOption("color","blue"),e.cam.remove(e.canvasUI.mesh)}},magenta:{type:"button",position:{top:168,left:250},width:i,height:s,fontColor:"magenta",hover:o,onSelect:function(){e.setOptionCls.setOption("color","magenta"),e.cam.remove(e.canvasUI.mesh)}},orange:{type:"button",position:{top:168,left:300},width:i,height:s,fontColor:"orange",hover:o,onSelect:function(){e.setOptionCls.setOption("color","FFA500"),e.cam.remove(e.canvasUI.mesh)}},cyan:{type:"button",position:{top:168,left:350},width:i,height:s,fontColor:"cyan",hover:o,onSelect:function(){e.setOptionCls.setOption("color","cyan"),e.cam.remove(e.canvasUI.mesh)}},gray:{type:"button",position:{top:168,left:400},width:i,height:s,fontColor:"gray",hover:o,onSelect:function(){e.setOptionCls.setOption("color","888888"),e.cam.remove(e.canvasUI.mesh)}},white:{type:"button",position:{top:168,left:450},width:i,height:s,fontColor:"white",hover:o,onSelect:function(){e.setOptionCls.setOption("color","white"),e.cam.remove(e.canvasUI.mesh)}},analysis:{type:"button",position:{top:230,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},interaction:{type:"button",position:{top:230,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){try{e.viewInterPairsCls.viewInteractionPairs(["selected"],["non-selected"],!1,"3d",1,1,1,1,1,1),e.cam.remove(e.canvasUI.mesh)}catch(e){}}},removeLabel:{type:"button",position:{top:230,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){for(let t in e.labels)e.labels[t]=[];e.drawCls.draw(),e.cam.remove(e.canvasUI.mesh)}},reset:{type:"button",position:{top:230,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.selectionCls.resetAll(),e.cam.remove(e.canvasUI.mesh)}},renderer:e.renderer},d=new Oe({select:"Select",residue:"Residue",secondarySelect:"SSE",chainSelect:"Chain",style:"Style",ribbon:"Ribbon",schematic:"Schem.",stick:"Stick",sphere:"Sphere",color:"Color",rainbow:"Rainbow",atomColor:"Atom",secondaryColor:"SSE",AlphaFold:"AlphaFold",unicolor:"UniColor",red:"M 50 15 L 15 15 L 15 50 L 50 50 Z",green:"M 50 15 L 15 15 L 15 50 L 50 50 Z",blue:"M 50 15 L 15 15 L 15 50 L 50 50 Z",magenta:"M 50 15 L 15 15 L 15 50 L 50 50 Z",orange:"M 50 15 L 15 15 L 15 50 L 50 50 Z",cyan:"M 50 15 L 15 15 L 15 50 L 50 50 Z",gray:"M 50 15 L 15 15 L 15 50 L 50 50 Z",white:"M 50 15 L 15 15 L 15 50 L 50 50 Z",analysis:"Analysis",interaction:"Interact",removeLabel:"No Label",reset:"Reset"},a);return d.mesh.position.set(0,0,-3),d}createUILog(){let e=this.icn3d;e.icn3dui;const t={panelSize:{width:2,height:2},height:512,info:{type:"text",overflow:"scroll",position:{top:6,left:6},width:506,height:506,backgroundColor:"#aaa",fontColor:"#000"},renderer:e.renderer},s=new Oe({info:"Debug info"},t);return s.mesh.position.set(0,-1,-2),s}getControllers(){let e=this.icn3d;e.icn3dui;const t=new xe,s=(new THREE.BufferGeometry).setFromPoints([new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,-1)]),i=new THREE.Line(s);i.name="line",i.scale.z=50;const n=[];for(let s=0;s<=1;s++){const l=e.renderer.xr.getController(s);e.dolly.add(l),l.add(i.clone()),l.userData.selectPressed=!1,e.cam.add(l),n.push(l);const r=e.renderer.xr.getControllerGrip(s);r.add(t.createControllerModel(r)),e.scene.add(r)}return n}}class Ie{constructor(e){this.icn3d=e}setCamera(){let e=this.icn3d,t=e.icn3dui;if(e.bControlGl&&!t.bNode){window.cam=e.cams[e.opts.camera.toLowerCase()];let s=e.maxD;if(window.cam===e.perspectiveCamera){let i=void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>e.maxatomcnt;i?window.camMaxDFactor=1:void 0!==window.camMaxDFactorFog?window.camMaxDFactor=window.camMaxDFactorFog:window.camMaxDFactor=3,window.cam_z>0?window.cam.position.z=s*window.camMaxDFactor:window.cam.position.z=-s*window.camMaxDFactor,"yes"===e.opts.slab?i?window.cam.near=.1:void 0!==window.camMaxDFactorFog?window.cam.near=s*window.camMaxDFactorFog-10:window.cam.near=s*window.camMaxDFactor:window.cam.near=.1,window.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.TrackballControls(window.cam,void 0,e):t.bNode?e.controls=new THREE.TrackballControls(e.cam,document,e):e.controls=new THREE.TrackballControls(e.cam,document.getElementById(e.id),e)}else window.cam===e.orthographicCamera&&(void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>10*e.maxatomcnt?window.cam.right=e.maxD/2*1.5:window.cam.right=e.maxD/2*2.5,window.cam.left=-window.cam.right,window.cam.top=window.cam.right/e.container.whratio,window.cam.bottom=-window.cam.right/e.container.whratio,"yes"===e.opts.slab?window.cam.near=2*e.maxD:window.cam.near=0,window.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.OrthographicTrackballControls(window.cam,void 0,e):t.bNode?e.controls=new THREE.OrthographicTrackballControls(e.cam,document,e):e.controls=new THREE.OrthographicTrackballControls(e.cam,document.getElementById(e.id),e));window.cam.updateProjectionMatrix()}e.cam=e.cams[e.opts.camera.toLowerCase()];let s=e.maxD;if(e.cam===e.perspectiveCamera){let i=void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>e.maxatomcnt;i?e.camMaxDFactor=1:void 0!==e.camMaxDFactorFog?e.camMaxDFactor=e.camMaxDFactorFog:e.camMaxDFactor=3,e.cam_z>0?e.cam.position.z=s*e.camMaxDFactor:e.cam.position.z=-s*e.camMaxDFactor,"yes"===e.opts.slab?i?e.cam.near=.1:void 0!==e.camMaxDFactorFog?e.cam.near=s*e.camMaxDFactorFog-10:e.cam.near=s*e.camMaxDFactor:e.cam.near=.1,e.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.TrackballControls(e.cam,void 0,e):t.bNode?e.controls=new THREE.TrackballControls(e.cam,document,e):e.controls=new THREE.TrackballControls(e.cam,document.getElementById(e.id),e)}else e.cam===e.orthographicCamera&&(void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>10*e.maxatomcnt?e.cam.right=e.maxD/2*1.5:e.cam.right=e.maxD/2*2.5,e.cam.left=-e.cam.right,e.cam.top=e.cam.right/e.container.whratio,e.cam.bottom=-e.cam.right/e.container.whratio,"yes"===e.opts.slab?e.cam.near=2*e.maxD:e.cam.near=0,e.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.OrthographicTrackballControls(e.cam,void 0,e):t.bNode?e.controls=new THREE.OrthographicTrackballControls(e.cam,document,e):e.controls=new THREE.OrthographicTrackballControls(e.cam,document.getElementById(e.id),e));e.cam.updateProjectionMatrix()}}class Te{constructor(e){this.icn3d=e}setFog(e){let t=this.icn3d,s=t.icn3dui.parasCls.backgroundColors[t.opts.background.toLowerCase()];if(e){let e=t.applyCenterCls.centerAtoms(t.hAtoms);t.maxD=e.maxD,t.maxD<25&&(t.maxD=25)}let i=void 0!==t.biomtMatrices&&t.biomtMatrices.length*t.cnt>t.maxatomcnt;if("yes"===t.opts.fog)if("perspective"===t.opts.camera)if(i)t.scene.fog=void 0,t.bSetFog=!1;else{let e=t._zoomFactor>1?1*t._zoomFactor:t._zoomFactor;t.scene.fog=new THREE.Fog(s,2.5*t.maxD*e,4*t.maxD*e),t.bSetFog=!0,t.camMaxDFactorFog=3}else"orthographic"===t.opts.camera&&(t.scene.fog=void 0,t.bSetFog=!1);else t.scene.fog=void 0,t.bSetFog=!1}}class Me{constructor(e){this.icn3d=e}createBox(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(o.bNode)return;void 0===t&&(t=.8),void 0===s&&(s=!1),void 0===i&&(i=.8),l?void 0===n&&(n=r.hColor):void 0===n&&(n=e.color);let a=s?t:(o.parasCls.vdwRadii[e.elem.toUpperCase()]||t)*(i||1);this.createBox_base(e.coord,a,n,l)}createBox_base(e,t,s,i,n,l,r){let o,a=this.icn3d;a.icn3dui.bNode||(void 0===r&&(r=l?.5:1),new THREE.BoxGeometry(1,1,1),o=new THREE.Mesh(a.boxGeometry,new THREE.MeshPhongMaterial({transparent:!0,opacity:r,specular:a.frac,shininess:a.shininess,emissive:a.emissive,color:s})),o.scale.x=o.scale.y=o.scale.z=t,o.position.copy(e),a.mdl.add(o),i?a.prevHighlightObjects.push(o):n?a.prevOtherMesh.push(o):a.objects.push(o))}createBoxRepresentation_P_CA(e,t,s){let i=this.icn3d;if(i.icn3dui.bNode)return;let n=this;i.reprSubCls.createRepresentationSub(e,(function(e){"CA"!==e.name&&"O3'"!==e.name&&"O3*"!==e.name||n.createBox(e,void 0,void 0,t,void 0,s)}))}}class Pe{constructor(e){this.icn3d=e}createBrick(e,t,s,i){let n=this.icn3d;if(n.icn3dui.bNode)return;let l=new THREE.CylinderGeometry(1,1,1,4,1),r=new THREE.Mesh(l,new THREE.MeshPhongMaterial({specular:n.frac,shininess:n.shininess,emissive:n.emissive,color:i}));r.position.copy(e).add(t).multiplyScalar(.5),r.matrixAutoUpdate=!1,r.lookAt(t.clone().sub(e)),r.updateMatrix(),r.matrix.multiply((new THREE.Matrix4).makeScale(s,s,e.distanceTo(t))).multiply((new THREE.Matrix4).makeRotationX(.5*Math.PI)),n.mdl.add(r)}}class De{constructor(e){this.icn3d=e}createCurveSubArrow(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u){if(this.icn3d.icn3dui.bNode)return;let g=[],f=[];g.push(e),f.push(o),this.prepareStrand(g,f,t,s,i,void 0,n,l,r,a,d,!1,c,h,p,m,u),g=[],f=[]}createStripArrow(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g){if(this.icn3d.icn3dui.bNode)return;let f=[],b=[];f.push(e),f.push(t),b.push(o),b.push(a),this.prepareStrand(f,b,void 0,s,i,n,l,void 0,r,d,c,!0,h,p,m,u,g),f=[],b=[]}prepareStrand(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g,f){let b=this.icn3d,C=b.icn3dui;if(1===d.length)return;let y=i,v=!u,w=[];w.push(i[i.length-2]),w.push(i[i.length-1]),n=n||b.axisDIV;let _,S,A,x,k=2/(a-1),O={};for(let e=0,s=t.length;e1)if(void 0!==d){let i,n,l=[];for(let r=0,o=p.length;r0&&i.tubeCls.createTube(a,"CA",i.coilWidth,s),Object.keys(d).length>0&&i.strandCls.createStrand(d,void 0,void 0,!0,0,i.helixSheetWidth,!1,2*i.ribbonthickness,s)):(Object.keys(a).length>0&&i.tubeCls.createTube(a,"CA",i.coilWidth),Object.keys(d).length>0&&i.strandCls.createStrand(d,void 0,void 0,!0,0,i.helixSheetWidth,!1,2*i.ribbonthickness))}createCylinderCurve(e,t,s,i,n){let l=this.icn3d;if(l.icn3dui.bNode)return;let r,o,a,d,c,h,p=null;for(a in e)if(d=e[a],!d.het&&(c=d.structure+"_"+d.chain,h=d.structure+"_"+r,-1!=t.indexOf(d.name))){if(null!==p&&r===d.chain&&l.ParserUtilsCls.getResiNCBI(h,o)+1===l.ParserUtilsCls.getResiNCBI(c,d.resi)&&Math.abs(p.coord.x-d.coord.x)<8&&Math.abs(p.coord.y-d.coord.y)<8&&Math.abs(p.coord.z-d.coord.z)<8){let e=p.coord.clone().add(d.coord).multiplyScalar(.5);if(n)1===n&&(this.createCylinder(p.coord,e,s,p.color,n),this.createCylinder(e,d.coord,s,d.color,n),l.sphereCls.createSphere(d,s,!0,1,n));else if(i){let t=l.lineCls.createSingleLine(p.coord,e,p.color,!1);l.mdl.add(t),l.objects.push(t),t=l.lineCls.createSingleLine(e,d.coord,d.color,!1),l.mdl.add(t),l.objects.push(t)}else this.createCylinder(p.coord,e,s,p.color),this.createCylinder(e,d.coord,s,d.color),l.sphereCls.createSphere(d,s,!0,1,n)}p=d,r=d.chain,o=d.resi,l.sphereCls.createSphere(d,s,!0,1,n),2===n&&l.boxCls.createBox(d,void 0,void 0,void 0,void 0,n)}if(null!==p&&r===d.chain&&l.ParserUtilsCls.getResiNCBI(h,o)+1===l.ParserUtilsCls.getResiNCBI(c,d.resi)&&Math.abs(p.coord.x-d.coord.x)<8&&Math.abs(p.coord.y-d.coord.y)<8&&Math.abs(p.coord.z-d.coord.z)<8){let e=p.coord.add(d.coord).multiplyScalar(.5);if(n)1===n&&(this.createCylinder(p.coord,e,s,p.color,n),this.createCylinder(e,d.coord,s,d.color,n),l.sphereCls.createSphere(d,s,!0,1,n));else if(i){let t=l.lineCls.createSingleLine(p.coord,e,p.color,!1);l.mdl.add(t),l.objects.push(t),t=l.lineCls.createSingleLine(e,d.coord,d.color,!1),l.mdl.add(t),l.objects.push(t)}else this.createCylinder(p.coord,e,s,p.color),this.createCylinder(e,d.coord,s,d.color)}}}class Le{constructor(e){this.icn3d=e}createLineRepresentation(e,t){let s=this.icn3d;if(s.icn3dui.bNode)return;let i=new THREE.BufferGeometry,n=[],l=[],r=0,o=0;s.reprSubCls.createRepresentationSub(e,void 0,(function(e,t){if(e.color===t.color)n[r++]=e.coord.x,n[r++]=e.coord.y,n[r++]=e.coord.z,n[r++]=t.coord.x,n[r++]=t.coord.y,n[r++]=t.coord.z,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b;else{let s=e.coord.clone().add(t.coord).multiplyScalar(.5);n[r++]=e.coord.x,n[r++]=e.coord.y,n[r++]=e.coord.z,n[r++]=s.x,n[r++]=s.y,n[r++]=s.z,n[r++]=t.coord.x,n[r++]=t.coord.y,n[r++]=t.coord.z,n[r++]=s.x,n[r++]=s.y,n[r++]=s.z,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b}}));if(i.setAttribute("position",new THREE.BufferAttribute(new Float32Array(n),3)),i.setAttribute("color",new THREE.BufferAttribute(new Float32Array(l),3)),2!==t){let e;1===t||(e=new THREE.LineSegments(i,new THREE.LineBasicMaterial({linewidth:s.linewidth,vertexColors:!0})),s.mdl.add(e)),1===t?s.prevHighlightObjects.push(e):s.objects.push(e)}else 2===t&&s.boxCls.createBoxRepresentation_P_CA(e,.8,t)}createConnCalphSidechain(e,t){let s=this.icn3d;if(s.icn3dui.bNode)return;let i={};for(let s in e){let n=e[s];if(!n.het&&n.style2===t){i[n.structure+"_"+n.chain+"_"+n.resi]=1}}let n=[],l=[];for(let e in i){let t=s.firstAtomObjCls.getFirstAtomObjByName(s.residues[e],"CA");if(void 0!==t)for(let e=0,i=t.bonds.length;e=t.bonds.length&&e.bonds.length>1)s=e.serial,l=e.bonds[0],d=e.bonds[1];else{if(!(t.bonds.length>=e.bonds.length&&t.bonds.length>1))return void console.log("Double bond was not drawn due to the undefined cross plane");s=t.serial,l=t.bonds[0],d=t.bonds[1]}let i=r.atoms[s].coord.clone();i.sub(r.atoms[l].coord);let n=r.atoms[s].coord.clone();n.sub(r.atoms[d].coord),i.cross(n),0==parseInt(1e4*i.length())&&(i=new THREE.Vector3(.2,.3,.5)),c=t.coord.clone(),c.sub(e.coord),c.cross(i).normalize().multiplyScalar(.2*o),0==parseInt(1e4*c.length())&&(i=new THREE.Vector3(.5,.3,.2),c.cross(i).normalize().multiplyScalar(.2*o))}e.color===t.color?r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),t.coord.clone().add(c),a,e.color,n),r.cylinderCls.createCylinder(e.coord.clone().sub(c),t.coord.clone().sub(c),a,e.color,n)):r.bImpo?r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),t.coord.clone().add(c),a,e.color,n,t.color),r.cylinderCls.createCylinder(e.coord.clone().sub(c),t.coord.clone().sub(c),a,e.color,n,t.color)):r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),i.clone().add(c),a,e.color,n),r.cylinderCls.createCylinder(t.coord.clone().add(c),i.clone().add(c),a,t.color,n),r.cylinderCls.createCylinder(e.coord.clone().sub(c),i.clone().sub(c),a,e.color,n),r.cylinderCls.createCylinder(t.coord.clone().sub(c),i.clone().sub(c),a,t.color,n))}else if(r.aromaticbonds.hasOwnProperty(l)){let s,l,d;if(e.bonds.length>t.bonds.length&&e.bonds.length>1)s=e.serial,l=e.bonds[0],d=e.bonds[1];else{if(!(t.bonds.length>1))return;s=t.serial,l=t.bonds[0],d=t.bonds[1]}let c=r.atoms[s].coord.clone();c.sub(r.atoms[l].coord);let h=r.atoms[s].coord.clone();h.sub(r.atoms[d].coord),c.cross(h);let p=t.coord.clone();p.sub(e.coord),p.cross(c).normalize().multiplyScalar(.2*o);let m=0;for(let s=0,i=e.bondOrder.length;so+1?(s=k.clone(),i=d.atoms[G[G.length-1-o-1]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random()))):d.bCalphaOnly&&"CA"===b.name&&(G.length>o+1?(s=k.clone(),i=d.atoms[G[G.length-1-o-1]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random())),s.normalize(),s.multiplyScalar(f),null!==E&&s.dot(E)<0&&s.negate(),E=s;for(let e=0,s=2/(t-1);e6||c&&Math.abs(S.y-c.y)>6||c&&Math.abs(S.z-c.z)>6;if((u!==b.chain||b.ssbegin||b.ssend||B===j-1||p)&&m[0].length>0){let c="CA",u=[],g=[];if(isNaN(d.atoms[P].resi))u=[];else{let e=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)-1).toString(),t=d.firstAtomObjCls.getAtomCoordFromResi(e,c);u=void 0!==t?[t]:[]}if(!isNaN(d.atoms[P].resi)){let e=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)+1).toString(),t=d.firstAtomObjCls.getAtomCoordFromResi(e,c);void 0!==t&&g.push(t);let s=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)+2).toString(),i=d.firstAtomObjCls.getAtomCoordFromResi(s,c);void 0!==i&&g.push(i)}if(!p){1===a||2===a?_.push(d.hColor):_.push(R),f=b.ssend&&"sheet"===b.ss?0:"coil"===I&&b.ssbegin||T&&b.ssbegin||"coil"===b.ss?n:l;let s,i,o=4;"O"===b.name?(s=A.clone(),s.sub(S)):d.bCalphaOnly&&"CA"===b.name&&(G.length>o?(s=S.clone(),i=d.atoms[G[G.length-1-o]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random())),s.normalize(),s.multiplyScalar(f),null!==E&&s.dot(E)<0&&s.negate(),E=s;for(let e=0,s=2/(t-1);e0){let e="CA",n=[],l=[];if(isNaN(d.atoms[P].resi))n=[];else{let t=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)-1).toString();d.firstAtomObjCls.getAtomCoordFromResi(t,e)}for(let e=0;!i&&e0;--e){let t=a.structure+"_"+a.chain+"_"+e;if(!c.residues.hasOwnProperty(t))break;let s=c.firstAtomObjCls.getFirstCalphaAtomObj(c.residues[t]);if(s.ss===a.ss&&s.ssbegin){g=s.resi;break}}for(let e=g;e0&&(o!==c.chain||Math.abs(c.coord.x-h.coord.x)>6||Math.abs(c.coord.y-h.coord.y)>6||Math.abs(c.coord.z-h.coord.z)>6||r.ParserUtilsCls.getResiNCBI(c.structure+"_"+o,a)+13||Math.abs(c.coord.y-h.coord.y)>3||Math.abs(c.coord.z-h.coord.z)>3))){if(2!==i){if(!isNaN(d.resi)&&!isNaN(h.resi)){let e=d.structure+"_"+d.chain+"_"+(parseInt(d.resi)-1).toString(),i=r.firstAtomObjCls.getAtomCoordFromResi(e,t);g=void 0!==i?[i]:[];let l=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+1).toString(),o=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+2).toString(),a=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+3).toString();if(r.residues.hasOwnProperty(l)){let e=r.firstAtomObjCls.getAtomFromResi(l,t);void 0!==e&&e.ssbegin&&(l=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+2).toString(),o=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+3).toString(),p.push(e.coord),n?u.push(this.getCustomtubesize(l)):u.push(this.getRadius(s,e)),m.push(e.color))}if(1==p.length&&r.residues.hasOwnProperty(l)){let e=r.firstAtomObjCls.getAtomFromResi(l,t);if(e){p.push(e.coord),m.push(e.color);let t=this.getRadius(s,c);u.push(t),l=o,o=a}}let b=r.firstAtomObjCls.getAtomCoordFromResi(l,t);void 0!==b&&f.push(b);let C=r.firstAtomObjCls.getAtomCoordFromResi(o,t);void 0!==C&&f.push(C)}C.push({pnts:p,colors:m,radii:u,prevone:g,nexttwo:f})}p=[],m=[],u=[],g=[],f=[],d=c,b=0}if(0==p.length&&!isNaN(c.resi)){let e=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)-1).toString();r.residues.hasOwnProperty(e)&&(h=r.firstAtomObjCls.getAtomFromResi(e,t),void 0!==h&&h.ssend&&(p.push(h.coord),n?u.push(this.getCustomtubesize(e)):u.push(this.getRadius(s,h)),m.push(h.color)))}let e;p.push(c.coord),e=n?this.getCustomtubesize(c.structure+"_"+c.chain+"_"+c.resi):this.getRadius(s,c),u.push(e),m.push(c.color),1===b&&(m[m.length-2]=c.color),o=c.chain,a=c.resi;let l=1.2;2!==i||c.ssbegin||r.boxCls.createBox(c,void 0,void 0,l,void 0,i),++b,h=c}if(2!==i){if(g=[],void 0!==d&&!isNaN(d.resi)){let e=d.structure+"_"+d.chain+"_"+(parseInt(d.resi)-1).toString(),s=r.firstAtomObjCls.getAtomCoordFromResi(e,t);g=void 0!==s?[s]:[]}if(f=[],void 0!==c&&!isNaN(c.resi)){let e=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+1).toString(),i=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+2).toString(),n=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+3).toString();if(1==p.length&&r.residues.hasOwnProperty(e)){let l=r.firstAtomObjCls.getAtomFromResi(e,t);if(l){p.push(l.coord),m.push(l.color);let t=this.getRadius(s,c);u.push(t),e=i,i=n}}let l=r.firstAtomObjCls.getAtomCoordFromResi(e,t);void 0!==l&&f.push(l);let o=r.firstAtomObjCls.getAtomCoordFromResi(i,t);void 0!==o&&f.push(o)}C.push({pnts:p,colors:m,radii:u,prevone:g,nexttwo:f})}for(let e=0,t=C.length;e1?a.parasCls.thr(t[t.length-2]):a.parasCls.thr(t[e]),f[y++]=d.r,f[y++]=d.g,f[y++]=d.b}}let x,k=0;for(let e=0,t=_.length-1;er&&(l=r,e=1);for(let t=0;t0&&t.b<=100?.01*t.b:t.b>100?1:s.coilWidth),i}}class ze{constructor(e){this.icn3d=e}drawCartoonNucleicAcid(e,t,s,i){this.drawStrandNucleicAcid(e,2,t,!0,void 0,s,i)}drawStrandNucleicAcid(e,t,s,i,n,l,r){let o,a,d,c=this.icn3d;if(c.icn3dui.bNode)return;2===r&&(t=void 0,l=void 0),n=n||c.nucleicAcidWidth,s=s||c.axisDIV,t=t||c.nucleicAcidStrandDIV;let h=[];for(d=0;dy?y=C:C=y);let v=.8*b/y;if(g.width=C,g.height=y,f.clearRect(0,0,C,y),h)if(f.fillStyle="rgba("+n.r+","+n.g+","+n.b+","+n.a+")",f.strokeStyle="rgba("+l.r+","+l.g+","+l.b+","+l.a+")",f.lineWidth=r,p){let e=.4*C;this.circle(f,0,0,C,y,e)}else{let e=0;this.roundRect(f,0,0,C,y,e)}f.font="Bold "+a+"px "+o,f.textAlign="center",f.textBaseline="middle",f.fillStyle="rgba("+u.r+", "+u.g+", "+u.b+", 1.0)",f.strokeStyle="rgba("+u.r+", "+u.g+", "+u.b+", 1.0)",f.fillText(e,.5*C,.5*y);let w=new THREE.Texture(g);w.needsUpdate=!0;let _=new THREE.SpriteMaterial({map:w,depthTest:!1,depthWrite:!1});_.map.minFilter=THREE.LinearFilter;let S=new THREE.Sprite(_);return p?S.scale.set(.3*d,.3*d,1):S.scale.set(v*d,d,1),S}roundRect(e,t,s,i,n,l){e.beginPath(),e.moveTo(t+l,s),e.lineTo(t+i-l,s),e.quadraticCurveTo(t+i,s,t+i,s+l),e.lineTo(t+i,s+n-l),e.quadraticCurveTo(t+i,s+n,t+i-l,s+n),e.lineTo(t+l,s+n),e.quadraticCurveTo(t,s+n,t,s+n-l),e.lineTo(t,s+l),e.quadraticCurveTo(t,s,t+l,s),e.closePath(),e.fill(),e.stroke()}circle(e,t,s,i,n,l){e.beginPath(),e.arc(t+i/2,.9*(s+n/2),l,0,2*Math.PI,!0),e.closePath(),e.fill(),e.stroke()}}class Ve{constructor(e){this.icn3d=e,this.textSpriteCls=new Ge(e)}createLabelRepresentation(e){let t=this.icn3d;t.icn3dui;let s=t.oriMaxD/100;s<.4&&(s=.4);let i=3*s*t.labelScale;for(let s in e){let n=void 0!==e[s]?e[s]:[],l="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd;for(let e=0,r=n.length;e.99999)h.set(0,0,0,1);else if(e.y<-.99999)h.set(1,0,0,0);else{let t=new THREE.Vector3;t.set(e.z,0,-e.x).normalize();let s=Math.acos(e.y);h.setFromAxisAngle(t,s)}return c.applyQuaternion(h),c.scale.set(l,n,l),c.position.copy(t),c}setPc1Axes(){let e=this.icn3d,t=e.icn3dui;if(t.bNode)return;let s=t.hashUtilsCls.intHash(e.hAtoms,e.dAtoms),i=[],n=Object.keys(s).length<100;for(let t in s){let s=e.atoms[t],l=s.structure+"_"+s.chain+"_"+s.resi;(n||""!=l)&&i.push(s.coord.clone())}let l=t.rmsdSuprCls.getEigenForSelection(i,i.length),r=new THREE.Vector3(l.h1[0],l.h1[1],l.h1[2]);if(0==l.k&&e.bRender)return void alert("Can't determine the first principal component. Please select a subset and try it again.");let o=e.applyCenterCls.centerAtoms(s),a=o.maxD,d=o.center,c=d.clone().add(r.normalize().multiplyScalar(.4*a)),h=new THREE.Vector3(l.h2[0],l.h2[1],l.h2[2]),p=d.clone().add(h.normalize().multiplyScalar(.3*a)),m=new THREE.Vector3(l.h3[0],l.h3[1],l.h3[2]),u=d.clone().add(m.normalize().multiplyScalar(.3*a));this.buildAxes(void 0,d,c,p,u,!0);let g=[d,c,p,u];return e.axes.push(g),e.drawCls.draw(),g}}class Ye{constructor(e){this.icn3d=e}showGlycans(){let e=this.icn3d,t=e.icn3dui;if(t.bNode)return;let s={},i=e.dAtoms;for(let n in i){let i=e.atoms[n];i.het&&-1!=t.parasCls.glycanHash.hasOwnProperty(i.resn)&&(void 0===s[i.resn]&&(s[i.resn]={}),"Misc"!=i.chain&&(s[i.resn][i.structure+"_"+i.chain+"_"+i.resi]=1))}let n=Object.keys(s);for(let i=0,l=n.length;i>2))+i+((2&t)>>1))*c+n+(1&t)]&this.ISDONE)<=3&&(t.push(t[i]),i=t.length-1,t.push(t[n]),n=t.length-1,t.push(t[l]),l=t.length-1),s.push(i),s.push(n),s.push(l)}}},Xe.prototype.laplacianSmooth=function(e,t,s){let i,n,l,r,o,a=new Array(t.length);for(i=0,n=t.length;ithis.origextent[1][0])&&(!(tthis.origextent[1][1])&&!(sthis.origextent[1][2]))},Ke.prototype.getFacesAndVertices=function(){let e,t,s=this.verts;for(e=0,t=s.length;eh&&(h=this.pmaxy-this.pminy),this.pmaxz-this.pminz>h&&(h=this.pmaxz-this.pminz),this.scaleFactor=(c-1)/h,this.scaleFactor=this.defaultScaleFactor,(this.bCalcArea||this.defaultScaleFactor*h>this.threshbox)&&(c=Math.floor(this.threshbox),this.scaleFactor=(this.threshbox-1)/h),this.pLength=Math.ceil(this.scaleFactor*(this.pmaxx-this.pminx))+1,this.pWidth=Math.ceil(this.scaleFactor*(this.pmaxy-this.pminy))+1,this.pHeight=Math.ceil(this.scaleFactor*(this.pmaxz-this.pminz))+1,this.finalScaleFactor.x=(this.pLength-1)/(this.pmaxx-this.pminx),this.finalScaleFactor.y=(this.pWidth-1)/(this.pmaxy-this.pminy),this.finalScaleFactor.z=(this.pHeight-1)/(this.pmaxz-this.pminz),this.boundingatom(t),this.cutRadius=this.probeRadius*this.scaleFactor,this.vpBits=new Uint8Array(this.pLength*this.pWidth*this.pHeight),this.vpDistance=new Float64Array(this.pLength*this.pWidth*this.pHeight),this.vpAtomID=new Int32Array(this.pLength*this.pWidth*this.pHeight),this.vpColor=[],this.vpPot=[]},Ke.prototype.boundingatom=function(e){let t,s,i,n,l=[];for(let r in this.vdwRadii){if(!this.vdwRadii.hasOwnProperty(r))continue;let o=this.vdwRadii[r];l[r]=e?(o+this.probeRadius)*this.scaleFactor+.5:o*this.scaleFactor+.5,i=l[r]*l[r],this.widxz[r]=Math.floor(l[r])+1,this.depty[r]=new Int32Array(this.widxz[r]*this.widxz[r]),n=0;for(let e=0;ei?this.depty[r][n]=-1:(s=Math.sqrt(i-t),this.depty[r][n]=Math.floor(s)),n++}},Ke.prototype.fillvoxels=function(e,t){let s,i,n,l;for(s=0,l=this.vpBits.length;sc&&(a=c),C>h&&(C=h),v>p&&(v=p);let w,_=g[o*m+d*u+y],S=g[a*m+d*u+y],A=g[o*m+C*u+y],x=g[o*m+d*u+v],k=g[a*m+C*u+y],O=g[o*m+C*u+v],R=g[a*m+d*u+v],E=g[a*m+C*u+v],I=r.x-o,T=r.y-d,M=r.z-y,P=((_*(1-I)+S*I)*(1-T)+(A*(1-I)+k*I)*T)*(1-M)+((x*(1-I)+R*I)*(1-T)+(O*(1-I)+E*I)*T)*M,D=s*f+i*b+n;this.vpPot[D]=P,P>this.isovalue&&(P=this.isovalue),P<-this.isovalue&&(P=-this.isovalue),P>0?(P/=1*this.isovalue,w=new THREE.Color(1-P,1-P,1)):(P/=-1*this.isovalue,w=new THREE.Color(1,1-P,1-P)),this.vpColor[D]=w}}for(s=0,l=this.vpBits.length;s=this.pLength||g>=this.pWidth||f>=this.pHeight)continue;let h=u*S+g*this.pHeight+f;if(this.vpBits[h]&this.INOUT){let p=t[this.vpAtomID[h]];p.serial!=e.serial&&(l=s+a-Math.floor(.5+this.scaleFactor*(p.x+this.ptranx)),r=i+d-Math.floor(.5+this.scaleFactor*(p.y+this.ptrany)),o=n+c-Math.floor(.5+this.scaleFactor*(p.z+this.ptranz)),a*a+d*d+c*c=this.pLength||p>=this.pWidth||m>=this.pHeight)continue;let u=h*S+p*this.pHeight+m;if(this.vpBits[u]&this.ISDONE){let h=t[this.vpAtomID[u]];h.serial!=e.serial&&(l=s+a-Math.floor(.5+this.scaleFactor*(h.x+this.ptranx)),r=i+d-Math.floor(.5+this.scaleFactor*(h.y+this.ptrany)),o=n+c-Math.floor(.5+this.scaleFactor*(h.z+this.ptranz)),a*a+d*d+c*c-1&&r-1&&a-1&&o=h)||(this.vpBits[n]|=this.ISBOUND))},Ke.prototype.fastoneshell=function(e,t){let s,i,n,l,r,o,a,d,c,h,p,m,u=[];if(0===e.length)return u;let g={ix:-1,iy:-1,iz:-1},f=this.pWidth*this.pHeight;for(a=0,c=e.length;a-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,h-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,h-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,hm&&(m=this.pmaxy-this.pminy),this.pmaxz-this.pminz>m&&(m=this.pmaxz-this.pminz),this.scaleFactor=1,this.pLength=Math.floor(.5+this.scaleFactor*(this.pmaxx-this.pminx))+1,this.pWidth=Math.floor(.5+this.scaleFactor*(this.pmaxy-this.pminy))+1,this.pHeight=Math.floor(.5+this.scaleFactor*(this.pmaxz-this.pminz))+1,this.cutRadius=this.probeRadius*this.scaleFactor,this.vpBits=new Uint8Array(this.pLength*this.pWidth*this.pHeight),this.vpAtomID=new Uint8Array(this.pLength*this.pWidth*this.pHeight)},Qe.prototype.transformMemPro=function(e,t,s,i){let n=e.clone();n.sub(s);let l=n.x*t[0]+n.y*t[1]+n.z*t[2]+i.x,r=n.x*t[3]+n.y*t[4]+n.z*t[5]+i.y,o=n.x*t[6]+n.y*t[7]+n.z*t[8]+i.z;return n.x=l,n.y=r,n.z=o,n},Qe.prototype.fillvoxels=function(e,t){let s,i,n,l,r,o;for(s=0,l=this.vpBits.length;sthis.pLength&&(o=this.pLength),p>this.pWidth&&(p=this.pWidth),b>this.pHeight&&(b=this.pHeight);let C,y=l[r*a+h*d+f],v=l[o*a+h*d+f],w=l[r*a+p*d+f],_=l[r*a+h*d+b],S=l[o*a+p*d+f],A=l[r*a+p*d+b],x=l[o*a+h*d+b],k=l[o*a+p*d+b],O=n.x-r,R=n.y-h,E=n.z-f,I=((y*(1-O)+v*O)*(1-R)+(w*(1-O)+S*O)*R)*(1-E)+((_*(1-O)+x*O)*(1-R)+(A*(1-O)+k*O)*R)*E;I>this.isovalue&&(I=this.isovalue),I<-this.isovalue&&(I=-this.isovalue),I>0?(I/=1*this.isovalue,C=new THREE.Color(1-I,1-I,1)):(I/=-1*this.isovalue,C=new THREE.Color(1,1-I,1-I)),this.icn3d.atoms[t[s]].color=C,this.icn3d.atomPrevColors[t[s]]=C}}else{for(let p in t){let f,b=e[t[p]];if("DUM"!==b.resn){if(void 0!==this.rmsd_supr&&void 0!==this.rmsd_supr.rot){f=this.transformMemPro(b.coord,g,u,m).applyMatrix4(c)}else f=b.coord.clone().applyMatrix4(c);for(s=Math.floor(f.x)-this.maxdist,l=Math.ceil(f.x)+this.maxdist;s<=l;++s)if(!(s<0||s>this.header.xExtent*this.scaleFactor-1))for(i=Math.floor(f.y)-this.maxdist,r=Math.ceil(f.y)+this.maxdist;i<=r;++i)if(!(i<0||i>this.header.yExtent*this.scaleFactor-1))for(n=Math.floor(f.z)-this.maxdist,o=Math.ceil(f.z)+this.maxdist;n<=o;++n){if(n<0||n>this.header.zExtent*this.scaleFactor-1)continue;let e=s*a+i*d+n;h.push(e)}}}for(s=0,l=h.length;s=this.isovalue?1:0:"fofc"==this.type?(this.vpBits[e]=this.dataArray[e]>=this.isovalue||this.dataArray[e]<=-this.isovalue?1:0,this.vpAtomID[e]=this.dataArray[e]>=0?1:0):"em"==this.type&&(this.vpBits[e]=this.dataArray[e]>=this.isovalue?1:0)}}}else for(s=0;s=this.isovalue||this.dataArray[e]<=-this.isovalue?1:0,this.vpAtomID[t]=this.dataArray[e]>=0?1:0)}for(s=0,l=this.vpBits.length;s-1&&r-1&&a-1&&o1?"Structure":"",a=Object.keys(i).length>1?"Chain":"";n+=""+o+a+"ResidueNumberSASA (Å2)Percent OutIn/Out";for(let e in l.resid2area){let d=e.lastIndexOf("_"),c=e.substr(d+1),h=r.utilsCls.getIdArray(e.substr(0,d));o=Object.keys(s).length>1?""+h[0]+"":"",a=Object.keys(i).length>1?""+h[1]+"":"";let p="",m="";l.resid2area[e]=(l.resid2area[e]/t).toFixed(2),r.parasCls.residueArea.hasOwnProperty(c)&&(m=parseInt(l.resid2area[e]/r.parasCls.residueArea[c]*100),m>100&&(m=100),m>=50&&(p="out"),m<20&&(p="in")),n+=''+o+a+""+c+''+h[2]+''+l.resid2area[e]+''+m+"%"+p+""}return n+="",void(l.areahtml=n)}let p,m,u,g=c.vertices,f=c.faces,b=r.parasCls.thr("#00FFFF"),C=r.parasCls.thr("#00FF00"),y=r.parasCls.thr("#ff0000"),v=r.parasCls.thr("#00FFFF"),w=r.parasCls.thr("#0000FF"),_=r.parasCls.thr("#FF0000");11!=t&&12!=t&&13!=t&&14!=t||void 0===l.rmsd_supr||void 0===l.rmsd_supr.rot||(p=l.rmsd_supr.rot,m=l.rmsd_supr.trans1,u=l.rmsd_supr.trans2);let S=(11==t||12==t||13==t||14==t&&"delphi"!=l.loadPhiFrom)&&void 0!==l.rmsd_supr&&void 0!==l.rmsd_supr.rot;n=new THREE.BufferGeometry;let A,x=[],k=[],O=[],R=0;for(let e=0,s=g.length;e0?-parseInt(C.z):parseInt(C.z),y.onBeforeRender=function(e,t,s,i,n,o){let a,d=new THREE.Vector3(0,0,0),c=i.getAttribute("position").array;for(let e=0,t=c.length;e0?-parseInt(a.z):parseInt(a.z)},l.mdl.add(y),11==t||12==t?l.prevMaps.push(y):13==t?l.prevEmmaps.push(y):14==t?l.prevPhimaps.push(y):l.prevSurfaces.push(y)}}else{let e=new THREE.Mesh(n,new THREE.MeshPhongMaterial({specular:l.frac,shininess:20,emissive:l.emissive,vertexColors:THREE.VertexColors,wireframe:s,opacity:i,transparent:!0,depthWrite:10==parseInt(10*i),side:THREE.DoubleSide}));e.renderOrder=-2,l.mdl.add(e),11==t||12==t?l.prevMaps.push(e):13==t?l.prevEmmaps.push(e):14==t?l.prevPhimaps.push(e):l.prevSurfaces.push(e)}c=null,g=null,f=null,n=null}transformMemPro(e,t,s,i,n){this.icn3d.icn3dui;let l=e.clone();l.sub(s),n&&console.log("sub coord: "+JSON.stringify(l));let r=l.x*t[0]+l.y*t[1]+l.z*t[2]+i.x,o=l.x*t[3]+l.y*t[4]+l.z*t[5]+i.y,a=l.x*t[6]+l.y*t[7]+l.z*t[8]+i.z;return l.x=r,l.y=o,l.z=a,n&&console.log("out coord: "+JSON.stringify(l)),l}SetupSurface(e){let t=this.icn3d;t.icn3dui;let s=e.threshbox,i=new Ke(t,s);i.initparm(e.extent,1!==e.type,e.bCalcArea,e.atomsToShow,e.header,e.data,e.matrix,e.isovalue,e.loadPhiFrom),i.fillvoxels(e.allatoms,e.extendedAtoms),i.buildboundary(),2===e.type&&(i.fastdistancemap(),i.boundingatom(!1),i.fillvoxelswaals(e.allatoms,e.extendedAtoms));let n=i.marchingcube();i.vpBits=null,i.vpDistance=null,i.vpAtomID=null;let l=i.getFacesAndVertices(e.atomsToShow);return l.area=n.area,l.serial2area=n.serial2area,l.scaleFactor=n.scaleFactor,i.faces=null,i.verts=null,l}SetupMap(e){let t=this.icn3d;t.icn3dui;let s,i=new Qe(t);return i.initparm(e.header,e.data,e.matrix,e.isovalue,e.center,e.maxdist,e.pmin,e.pmax,e.water,e.type,e.rmsd_supr,e.loadPhiFrom,e.icn3d),i.fillvoxels(e.allatoms,e.extendedAtoms),e.header.bSurface||i.buildboundary(),e.header.bSurface||i.marchingcube(),i.vpBits=null,i.vpAtomID=null,e.header.bSurface||(s=i.getFacesAndVertices(e.allatoms,e.atomsToShow)),i.faces=null,i.verts=null,s}}class Ze{constructor(e){this.icn3d=e}applyCenterOptions(e){let t,s=this.icn3d;switch(s.icn3dui,void 0===e&&(e=s.opts),e.rotationcenter.toLowerCase()){case"molecule center":void 0!==s.center&&this.setRotationCenter(s.center);break;case"pick center":void 0!==s.pAtom&&this.setRotationCenter(s.pAtom.coord);break;case"display center":t=this.centerAtoms(s.dAtoms).center,this.setRotationCenter(t);break;case"highlight center":t=this.centerAtoms(s.hAtoms).center,this.setRotationCenter(t)}}setRotationCenter(e){this.icn3d.icn3dui,this.setCenter(e)}setCenter(e){let t=this.icn3d;t.icn3dui,t.mdl.position.set(0,0,0),t.mdlImpostor.position.set(0,0,0),t.mdl_ghost.position.set(0,0,0),t.mdl.position.sub(e),t.mdlImpostor.position.sub(e),t.mdl_ghost.position.sub(e)}centerSelection(e,t){let s=this.icn3d,i=s.icn3dui;if(s.opts.rotationcenter="highlight center",void 0===e&&(e=i.hashUtilsCls.hash2Atoms(s.hAtoms,s.atoms)),t||(s._zoomFactor=1,s.mouseChange=new THREE.Vector2(0,0),s.quaternion=new THREE.Quaternion(0,0,0,1)),Object.keys(e).length>1){let t=this.centerAtoms(e);s.center=t.center,this.setCenter(s.center),s.cameraCls.setCamera()}}centerAtoms(e){let t=this.icn3d;t.icn3dui;let s=new THREE.Vector3(9999,9999,9999),i=new THREE.Vector3(-9999,-9999,-9999),n=new THREE.Vector3;for(let l in e){let e=t.atoms[l].coord;n.add(e),s.min(e),i.max(e)}let l=t.ParserUtilsCls.getGeoCenter(s,i);return{center:l,maxD:t.ParserUtilsCls.getStructureSize(e,s,i,l),pmin:s,pmax:i}}setWidthHeight(e,t){let s=this.icn3d;s.icn3dui,void 0===s.scaleFactor&&(s.scaleFactor=1),s.renderer.setSize(e*s.scaleFactor,t*s.scaleFactor),s.renderer.domElement.style.width=e*s.scaleFactor+"px",s.renderer.domElement.style.height=t*s.scaleFactor+"px",s.renderer.domElement.width=e*s.scaleFactor,s.renderer.domElement.height=t*s.scaleFactor,s.container.whratio=e/t}}class et{constructor(e){this.icn3d=e}applyClbondsOptions(e){let t=this.icn3d,s=t.icn3dui;if(void 0===e&&(e=t.opts),t.bCalcCrossLink||(t.clbondpnts={},t.clbondResid2serial={},this.applyClbondsOptions_base("chemical"),this.applyClbondsOptions_base("all"),t.bCalcCrossLink=!0),"yes"===e.clbonds.toLowerCase()&&"nothing"!==e.chemicals){let e="#006400",i=s.parasCls.thr(25600);if(t.lines.clbond=[],t.residuesHashClbonds={},t.structures){let n=Object.keys(t.structures);for(let l=0,r=n.length;l1&&"sphere"!==a[Object.keys(a)[0]].style&&"dot"!==a[Object.keys(a)[0]].style){if(void 0===i.bCid||!i.bCid)for(let e in a){let t=a[e],n=1;i.boxCls.createBox(t,void 0,void 0,n,void 0,s)}}else for(let e in o){let l=i.firstAtomObjCls.getFirstCalphaAtomObj(i.residues[e]),r=l,o=r.structure+"_"+r.chain+"_"+(parseInt(r.resi)-1).toString(),a=r.structure+"_"+r.chain+"_"+(parseInt(r.resi)+1).toString();if("cylinder and plate"===r.style&&"helix"===r.ss)for(let t in i.residues[e]){let e=i.atoms[t],n=1;i.boxCls.createBox(e,void 0,void 0,n,void 0,s)}else if("ribbon"===r.style&&"coil"===r.ss||"strand"===r.style&&"coil"===r.ss||"o3 trace"===r.style||"schematic"===r.style||"c alpha trace"===r.style||"b factor tube"===r.style||"cylinder and plate"===r.style&&"helix"!==r.ss){if(void 0!==l&&void 0!==l.style2&&"nothing"!==l.style2)continue;let e=!1;if(!isNaN(r.resi)&&!e&&i.residues.hasOwnProperty(a)){let s=Object.keys(i.residues[a])[0],l=n.hashUtilsCls.hash2Atoms(i.residues[a],i.atoms)[s];if(r.style===l.style&&!l.ssbegin||l.ssbegin){let s=i.residues[a];if(t=n.hashUtilsCls.unionHash(t,s),e=!0,l.ssbegin)for(let e in s)i.atoms[e].notshow=!0}}if(!isNaN(r.resi)&&!e&&i.residues.hasOwnProperty(o)){let s=Object.keys(i.residues[o])[0],l=n.hashUtilsCls.hash2Atoms(i.residues[o],i.atoms)[s];r.style===l.style&&(t=n.hashUtilsCls.unionHash(t,i.residues[o]),e=!0)}}else if("ribbon"===r.style&&"coil"!==r.ss&&r.ssend||"strand"===r.style&&"coil"!==r.ss&&r.ssend){if(void 0!==l&&void 0!==l.style2&&"nothing"!==l.style2)continue;let e=!1;if(!isNaN(r.resi)&&!e&&i.residues.hasOwnProperty(a)){let s=Object.keys(i.residues[a])[0];n.hashUtilsCls.hash2Atoms(i.residues[a],i.atoms)[s],t=n.hashUtilsCls.unionHash(t,i.residues[a]),e=!0}}}a={}}if(i.bInitial){if(""!=n.htmlCls.setHtmlCls.getCookie("membrane")){let e=parseInt(n.htmlCls.setHtmlCls.getCookie("membrane"));i.bMembrane!=e&&n.htmlCls.clickMenuCls.setLogCmd("set membrane "+e,!0),i.bMembrane=isNaN(e)?0:parseInt(e)}i.bMembrane?i.selectionCls.toggleMembrane(!0):i.selectionCls.toggleMembrane(!1)}i.setStyleCls.setStyle2Atoms(t);let d=.5*i.cylinderRadius;void 0!==i.labels&&delete i.labels.schematic;for(let e in i.style2atoms){let t=i.style2atoms[e],l=n.hashUtilsCls.intHash(t,i.nucleotides),r=n.utilsCls.isCalphaPhosOnly(n.hashUtilsCls.hash2Atoms(l,i.atoms));if("ribbon"===e)i.strandCls.createStrand(n.hashUtilsCls.hash2Atoms(t,i.atoms),2,void 0,!0,void 0,void 0,!1,i.ribbonthickness,s);else if("strand"===e)i.strandCls.createStrand(n.hashUtilsCls.hash2Atoms(t,i.atoms),null,null,null,null,null,!1,void 0,s);else if("cylinder and plate"===e)i.cylinderCls.createCylinderHelix(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderHelixRadius,s);else if("nucleotide cartoon"===e)r?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["P"],i.traceRadius,!1,s):(i.cartoonNuclCls.drawCartoonNucleicAcid(n.hashUtilsCls.hash2Atoms(t,i.atoms),null,i.ribbonthickness,s),2!==s&&i.cartoonNuclCls.drawNucleicAcidStick(n.hashUtilsCls.hash2Atoms(t,i.atoms),s));else if("o3 trace"===e)r?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["P"],i.traceRadius,!1,s):i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["O3'","O3*"],i.traceRadius,!1,s);else if("schematic"===e){let e=i.firstAtomObjCls.getFirstAtomObj(t);if(i.chemicals.hasOwnProperty(e.serial)){i.residueLabelsCls.addNonCarbonAtomLabels(n.hashUtilsCls.hash2Atoms(t,i.atoms));let e=!0;i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),d,d,void 0,s,e)}else i.residueLabelsCls.addResidueLabels(n.hashUtilsCls.hash2Atoms(t,i.atoms),!0),r?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["P"],i.traceRadius,!1,s):i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["O3'","O3*"],i.traceRadius,!1,s),i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["CA"],i.traceRadius,!1,s)}else"c alpha trace"===e?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["CA"],i.traceRadius,!1,s):"b factor tube"===e?i.tubeCls.createTube(n.hashUtilsCls.hash2Atoms(t,i.atoms),"CA",null,s,!1,!0):"custom tube"===e?i.tubeCls.createTube(n.hashUtilsCls.hash2Atoms(t,i.atoms),"CA",null,s,!0,!0):"lines"===e||"lines2"===e?(1===s?i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.hlLineRadius,i.hlLineRadius,void 0,s):i.lineCls.createLineRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),s),i.lineCls.createConnCalphSidechain(n.hashUtilsCls.hash2Atoms(t,i.atoms),e)):"stick"===e||"stick2"===e?(i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderRadius,i.cylinderRadius,void 0,s,void 0),i.lineCls.createConnCalphSidechain(n.hashUtilsCls.hash2Atoms(t,i.atoms),e)):"backbone"===e?(t=this.selectMainChainSubset(t),i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderRadius,i.cylinderRadius,void 0,s,void 0)):"ball and stick"===e||"ball and stick2"===e?(i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderRadius,.5*i.cylinderRadius,i.dotSphereScale,s,void 0),i.lineCls.createConnCalphSidechain(n.hashUtilsCls.hash2Atoms(t,i.atoms),e)):"sphere"===e||"sphere2"===e?i.sphereCls.createSphereRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.sphereRadius,void 0,void 0,s):"dot"===e&&i.sphereCls.createSphereRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.sphereRadius,!1,i.dotSphereScale,s)}if(i.cnt>i.maxmaxatomcnt&&i.init_base(),void 0!==i.labels&&Object.keys(i.labels).length>0){i.labelCls.hideLabels();for(let e in i.labels)"schematic"!=e&&this.changeLabelColor(i.labels[e]);i.labelCls.createLabelRepresentation(i.labels)}}changeLabelColor(e){let t=this.icn3d;if(t.icn3dui,e)for(let s=0,i=e.length;s0){this.updateStabilizer();let e="#FFFFFF",s=t.stabilizerpnts;t.lines.stabilizer=[];for(let i=0,n=Math.floor(s.length/2);i0)for(let e=0,s=t.distPnts.length;e0&&t.applySymdCls.applySymd(),void 0!==t.prevOtherMesh)for(let e=0,s=t.prevOtherMesh.length;e0&&(e=s.hashUtilsCls.hash2Atoms(t.chemicals,t.atoms));let i=4;if(void 0!==e){let n=t.contactCls.getAtomsWithinAtom(t.atoms,e,i),l=3.5;t.opts.hbonds="yes",Object.keys(n).length>0&&t.hBondCls.calculateChemicalHbonds(e,n,parseFloat(l)),t.bSetFog||t.transformCls.zoominSelection(s.hashUtilsCls.unionHash(e,n))}}else"hide"===e.chemicalbinding&&(t.hBondCls.hideHbonds(),t.bSetFog||t.transformCls.zoominSelection(t.atoms))}updateStabilizer(){let e=this.icn3d;if(e.icn3dui,e.stabilizerpnts=[],void 0!==e.pairArray)for(let t=0,s=e.pairArray.length;t=0;i--){let r=t.ssbondpnts[e][2*i],o=t.ssbondpnts[e][2*i+1],a={};a.color=n,a.dashed=!0;let d=[],c=[],h=[],p=[],m=!1,u=!1;for(let e in t.residues[r])"SG"===t.atoms[e].name&&(h.push(t.atoms[e].coord),d.push(t.atoms[e].serial),m=!0);if(!m)for(let e in t.residues[r])if("CA"===t.atoms[e].name){h.push(t.atoms[e].coord),d.push(t.atoms[e].serial),m=!0,u=!0;break}m=!1;for(let e in t.residues[o])"SG"===t.atoms[e].name&&(p.push(t.atoms[e].coord),c.push(t.atoms[e].serial),m=!0);if(!m)for(let e in t.residues[o])if("CA"===t.atoms[e].name){p.push(t.atoms[e].coord),c.push(t.atoms[e].serial),m=!0,u=!0;break}let g=u?7:3,f=!1;for(let e=0,t=h.length;e1&&(l=!0)}if(t)if(l){let t=Object.keys(r)[0];e=i.chains[t]}else{0==Object.keys(i.hAtoms).length&&(i.hAtoms=n.hashUtilsCls.cloneHash(i.dAtoms));let t,s=parseInt(Object.keys(i.hAtoms).length/u),l=0;for(let n in i.hAtoms)if(e[n]=1,t=n,++l,l>s)break;let r=i.atoms[t].structure+"_"+i.atoms[t].chain+"_"+i.atoms[t].resi;e=n.hashUtilsCls.unionHash(e,i.residues[r])}else{let t=Object.keys(i.structures)[0]+"_"+g;if(i.chains.hasOwnProperty(t)||(t=Object.keys(i.structures)[0]+"_"+g.toLowerCase()),!i.chains.hasOwnProperty(t)){t=Object.keys(i.chains)[0];for(let e in i.chains){let s=Object.keys(i.chains[e])[0];if(i.proteins.hasOwnProperty(s)){t=e;break}}}e=i.chains[t]}let a=s.clone().add(h).multiplyScalar(.5),c=new THREE.Vector3,p=0,f=h.clone().sub(s).normalize(),b=new THREE.Vector3(0,0,1),C=new THREE.Quaternion;C.setFromUnitVectors(f,b);let y=-9999;for(let t in e){let e=i.atoms[t].coord.clone();c.add(e),e.sub(a).applyQuaternion(C);let s=e.x*e.x+e.y*e.y;s>y&&(y=s),++p}let v=i.ParserUtilsCls.getMassCenter(c,p),w=new THREE.Line3(s,h),_=new THREE.Vector3;w.closestPointToPoint(v,!0,_);let S,A,x,k,O=Math.sqrt(y),R=v.clone().sub(_).normalize().multiplyScalar(O),E=a.clone().add(s.clone().sub(a).multiplyScalar(.83)).add(R),I=a.clone().add(h.clone().sub(a).multiplyScalar(.83)).add(R),T=2*Math.PI/o;for(let e=0;et&&(i.sphereCls.createSphereBase(r,colorPolygon,d,1,0),i.cylinderCls.createCylinder(e,r,d,colorPolygon,0),i.cylinderCls.createCylinder(s,r,d,colorPolygon,0),void 0!==n&&i.cylinderCls.createCylinder(c[n],r,d,colorPolygon,0),n=l)}}else if("O"==r)for(let e=0,t=c.length;e0&&(e.mdl.remove(e.prevSurfaces[e.prevSurfaces.length-1]),e.prevSurfaces.slice(e.prevSurfaces.length-1,1))}removeMaps(){let e=this.icn3d;e.icn3dui;for(let t=0,s=e.prevMaps.length;t0&&(e.mdl.remove(e.prevMaps[e.prevMaps.length-1]),e.prevMaps.slice(e.prevMaps.length-1,1))}removeLastEmmap(){let e=this.icn3d;e.icn3dui,e.prevEmmaps.length>0&&(e.mdl.remove(e.prevEmmaps[e.prevEmmaps.length-1]),e.prevEmmaps.slice(e.prevEmmaps.length-1,1))}removeLastPhimap(){let e=this.icn3d;e.icn3dui,e.prevPhimaps.length>0&&(e.mdl.remove(e.prevPhimaps[e.prevPhimaps.length-1]),e.prevPhimaps.slice(e.prevPhimaps.length-1,1))}}class rt{constructor(e){this.icn3d=e}addResidueLabels(e,t,s,i){let n=this.icn3d,l=n.icn3dui;if(l.bNode)return;let r=l.hashUtilsCls.intHash(n.hAtoms,e);t?void 0===n.labels.schematic&&(n.labels.schematic=[]):void 0===n.labels.residue&&(n.labels.residue=[]);let o="";for(let e in r){let s=n.atoms[e],r={},a=s.structure+"_"+s.chain+"_"+s.resi;if(!s.het&&("CA"===s.name||"O3'"===s.name||"O3*"===s.name)||n.water.hasOwnProperty(s.serial)||n.ions.hasOwnProperty(s.serial)||n.chemicals.hasOwnProperty(s.serial)&&a!==o){r.position=s.coord,r.bSchematic=0,t&&(r.bSchematic=1),r.text=l.utilsCls.residueName2Abbr(s.resn),i&&(r.text+=s.resi),r.size=18,r.factor=.3;let e=s.color.getHexString().toUpperCase();r.color=i?"black"!=n.opts.background?n.colorWhitebkgd:n.colorBlackbkgd:"CCCCCC"===e||"C8C8C8"===e?"#888888":"#"+e,r.background="#FFFFFF",t?n.labels.schematic.push(r):n.labels.residue.push(r)}o=a}n.hlObjectsCls.removeHlObjects()}addNonCarbonAtomLabels(e){let t=this.icn3d,s=t.icn3dui;if(s.bNode)return;let i=s.hashUtilsCls.intHash(t.hAtoms,e);void 0===t.labels.schematic&&(t.labels.schematic=[]);for(let e in i){let s=t.atoms[e];if(!t.residues.hasOwnProperty(s.structure+"_"+s.chain+"_"+s.resi))continue;if("C"===s.elem)continue;let i={};i.position=s.coord,i.bSchematic=1,i.text=s.elem,i.size=18,i.color="black"!=t.opts.background?t.colorWhitebkgd:s.color.getHexString(),i.background="#FFFFFF",t.labels.schematic.push(i)}t.hlObjectsCls.removeHlObjects()}addAtomLabels(e,t){let s=this.icn3d,i=s.icn3dui;if(i.bNode)return;let n=i.hashUtilsCls.intHash(s.hAtoms,e);n=i.hashUtilsCls.intHash(s.dAtoms,n),void 0===s.labels.residue&&(s.labels.residue=[]);for(let e in n){let i=s.atoms[e],n={};n.position=i.coord,n.bSchematic=0,n.text=t?i.elem:i.name.padEnd(2," "),n.size=18,t&&(n.bSchematic=!0);let l=i.color.getHexString().toUpperCase();n.color="black"!=s.opts.background?s.colorWhitebkgd:s.colorBlackbkgd,t&&(n.color="CCCCCC"===l||"C8C8C8"===l?"#888888":"#"+l),n.background="#FFFFFF",s.labels.residue.push(n)}s.hlObjectsCls.removeHlObjects()}}class ot{constructor(e){this.icn3d=e}onBeforeRender(e,t,s,i,n,l){let r=n.uniforms,o=[];if(r.objectId&&(r.objectId.value=SupportsReadPixelsFloat?this.id:this.id/255,o.push("objectId")),(r.modelViewMatrixInverse||r.modelViewMatrixInverseTranspose||r.modelViewProjectionMatrix||r.modelViewProjectionMatrixInverse)&&this.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,this.matrixWorld),r.modelViewMatrixInverse&&(r.modelViewMatrixInverse.value.copy(this.modelViewMatrix).invert(),o.push("modelViewMatrixInverse")),r.modelViewMatrixInverseTranspose&&(r.modelViewMatrixInverse?r.modelViewMatrixInverseTranspose.value.copy(r.modelViewMatrixInverse.value).transpose():r.modelViewMatrixInverseTranspose.value.copy(this.modelViewMatrix).invert().transpose(),o.push("modelViewMatrixInverseTranspose")),r.modelViewProjectionMatrix&&(s.updateProjectionMatrix(),r.modelViewProjectionMatrix.value.multiplyMatrices(s.projectionMatrix,this.modelViewMatrix),o.push("modelViewProjectionMatrix")),r.modelViewProjectionMatrixInverse){let e=new THREE.Matrix4;r.modelViewProjectionMatrix?(e.copy(r.modelViewProjectionMatrix.value),r.modelViewProjectionMatrixInverse.value.copy(e).invert()):(s.updateProjectionMatrix(),e.multiplyMatrices(s.projectionMatrix,this.modelViewMatrix),r.modelViewProjectionMatrixInverse.value.copy(e).invert()),o.push("modelViewProjectionMatrixInverse")}if(r.projectionMatrix&&(s.updateProjectionMatrix(),r.projectionMatrix.value.copy(s.projectionMatrix),o.push("projectionMatrix")),r.projectionMatrixInverse&&(s.updateProjectionMatrix(),r.projectionMatrixInverse.value.copy(s.projectionMatrix).invert(),o.push("projectionMatrixInverse")),o.length){let t=e.properties.get(n);if(t.program){let s=e.getContext(),i=t.program;s.useProgram(i.program);let n=i.getUniforms();o.forEach((function(e){n.setValue(s,e,r[e].value)}))}}}setParametersForShader(e){let t,s=this.icn3d,i=s.icn3dui.parasCls.backgroundColors[s.opts.background.toLowerCase()],n=2.5*s.maxD,l=4*s.maxD,r=void 0!==s.biomtMatrices&&s.biomtMatrices.length*s.cnt>s.maxatomcnt;"yes"===s.opts.slab?r?t=.1:void 0!==s.camMaxDFactorFog?(t=s.maxD*s.camMaxDFactorFog-10,n=2.5*s.maxD-t<0?0:2.5*s.maxD-t,l=4*s.maxD-t):t=s.maxD*s.camMaxDFactor:t=.1;let o=void 0!==e?e:1,a=s.shininess/100*.5;s.uniforms=THREE.UniformsUtils.merge([THREE.UniformsLib.common,{modelViewMatrix:{value:new THREE.Matrix4},modelViewMatrixInverse:{value:new THREE.Matrix4},modelViewMatrixInverseTranspose:{value:new THREE.Matrix4},modelViewProjectionMatrix:{value:new THREE.Matrix4},modelViewProjectionMatrixInverse:{value:new THREE.Matrix4},projectionMatrix:{value:new THREE.Matrix4},projectionMatrixInverse:{value:new THREE.Matrix4},diffuse:{type:"v3",value:[1,1,1]},emissive:{type:"v3",value:[.06,.06,.06]},roughness:{type:"f",value:.5},metalness:{type:"f",value:a},opacity:{type:"f",value:o},nearClip:{type:"f",value:t},ortho:{type:"f",value:0},shrink:{type:"f",value:.13},fogColor:{type:"v3",value:[i.r,i.g,i.b]},fogNear:{type:"f",value:n},fogFar:{type:"f",value:l},fogDensity:{type:"f",value:2}},THREE.UniformsLib.ambient,THREE.UniformsLib.lights]),s.defines={USE_COLOR:1,NEAR_CLIP:1,CAP:1},"yes"!==s.opts.fog||r||(s.defines.USE_FOG=1,"orthographic"===s.opts.camera&&(s.defines.FOG_EXP2=1)),s.bExtFragDepth&&(s.defines.USE_LOGDEPTHBUF_EXT=1)}drawImpostorShader(){this.icn3d.icn3dui.bNode||(this.setParametersForShader(),this.createImpostorShaderSphere("SphereImpostor"),this.createImpostorShaderCylinder("CylinderImpostor"))}getShader(e){this.icn3d.icn3dui;let t=$NGL_shaderTextHash[e];return t=t.replace(/#include\s+(\S+)/gim,(function(e,t){let s;return THREE.ShaderChunk.hasOwnProperty(t)&&(s=THREE.ShaderChunk[t]),s||""})),t}createImpostorShaderBase(e,t,s,i,n,l,r,o,a){let d=this.icn3d;d.icn3dui;let c=new THREE.ShaderMaterial({defines:d.defines,uniforms:d.uniforms,vertexShader:this.getShader(e+".vert"),fragmentShader:this.getShader(e+".frag"),depthTest:!0,depthWrite:!0,lights:!0});c.extensions.fragDepth=!0,"CylinderImpostor"==e?d.CylinderImpostorMaterial=c:"SphereImpostor"==e&&(d.SphereImpostorMaterial=c);let h,p,m=l*r,u=l*o,g=new(m>65535?Uint32Array:Uint16Array)(u);for(let e=0;e=0;t--){let s=a.children[t];s.onBeforeRender=e.impostorCls.onBeforeRender,s.frustumCulled=!1}l.add(a)}void 0!==e.mdl_ghost&&(a=e.mdl_ghost.clone(),this.applyMat(a,d),r.add(a));let c=e.center.clone();this.applyMat(c,d,!0),s.add(c),++t}e.mdl.add(n),e.mdlImpostor.add(l),e.mdl_ghost.add(r),void 0!==e.bSetInstancing&&e.bSetInstancing?(e.maxD=e.maxDAssembly,e.center=e.centerAssembly.clone(),e.applyCenterCls.setCenter(e.center),e.cameraCls.setCamera()):(e.maxD*=Math.sqrt(t),e.center=e.ParserUtilsCls.getMassCenter(s,t),e.maxDAssembly=e.maxD,e.centerAssembly=e.center.clone(),e.applyCenterCls.setCenter(e.center),e.cameraCls.setCamera()),e.bSetInstancing=!0}createInstancedGeometry(e){let t=this.icn3d,s=t.icn3dui,i=e.geometry,n=new THREE.InstancedBufferGeometry,l=[],r=[],o=[],a=[],d=[],c=[],h=[],p=[];if(t.bImpo&&"Cylinder"==e.type){t.instancedMaterial=this.getInstancedMaterial("CylinderInstancing");let e=s.hashUtilsCls.hashvalue2array(i.attributes.position1.array),r=s.hashUtilsCls.hashvalue2array(i.attributes.color.array),m=s.hashUtilsCls.hashvalue2array(i.attributes.position2.array),u=s.hashUtilsCls.hashvalue2array(i.attributes.color2.array),g=s.hashUtilsCls.hashvalue2array(i.index.array),f=s.hashUtilsCls.hashvalue2array(i.attributes.radius.array),b=s.hashUtilsCls.hashvalue2array(i.attributes.mapping.array);l=l.concat(e),o=o.concat(r),h=h.concat(m),p=p.concat(u),a=a.concat(g),d=d.concat(f),c=c.concat(b),n.setAttribute("position1",new THREE.BufferAttribute(new Float32Array(l),3)),n.setAttribute("color",new THREE.BufferAttribute(new Float32Array(o),3)),n.setAttribute("position2",new THREE.BufferAttribute(new Float32Array(h),3)),n.setAttribute("color2",new THREE.BufferAttribute(new Float32Array(p),3)),n.setAttribute("radius",new THREE.BufferAttribute(new Float32Array(d),1)),n.setAttribute("mapping",new THREE.BufferAttribute(new Float32Array(c),3)),n.setIndex(new THREE.BufferAttribute(new Uint32Array(a),1)),e=null,r=null,m=null,u=null,g=null,f=null,b=null}else if(t.bImpo&&"Sphere"==e.type){t.instancedMaterial=this.getInstancedMaterial("SphereInstancing");let e=s.hashUtilsCls.hashvalue2array(i.attributes.position.array),r=s.hashUtilsCls.hashvalue2array(i.attributes.color.array),h=s.hashUtilsCls.hashvalue2array(i.index.array),p=s.hashUtilsCls.hashvalue2array(i.attributes.radius.array),m=s.hashUtilsCls.hashvalue2array(i.attributes.mapping.array);l=l.concat(e),o=o.concat(r),a=a.concat(h),d=d.concat(p),c=c.concat(m),n.setAttribute("position",new THREE.BufferAttribute(new Float32Array(l),3)),n.setAttribute("color",new THREE.BufferAttribute(new Float32Array(o),3)),n.setAttribute("radius",new THREE.BufferAttribute(new Float32Array(d),1)),n.setAttribute("mapping",new THREE.BufferAttribute(new Float32Array(c),2)),n.setIndex(new THREE.BufferAttribute(new Uint32Array(a),1)),e=null,r=null,h=null,p=null,m=null}else{t.instancedMaterial=this.getInstancedMaterial("Instancing");let e=i.attributes.position?s.hashUtilsCls.hashvalue2array(i.attributes.position.array):[],d=i.attributes.normal?s.hashUtilsCls.hashvalue2array(i.attributes.normal.array):[],c=i.attributes.color?s.hashUtilsCls.hashvalue2array(i.attributes.color.array):[],h=i.index?s.hashUtilsCls.hashvalue2array(i.index.array):[];l=l.concat(e),r=r.concat(d),o=o.concat(c),a=a.concat(h);let p=[],m="CylinderGeometry"==i.type?1:0;for(let e=0,t=l.length/3;e0&&(e.dAtoms=t.hashUtilsCls.cloneHash(s)),e.bShowHighlight=!1}e.applyMapCls.removeSurfaces(),e.applyMapCls.applySurfaceOptions(),e.applyMapCls.removeMaps(),e.applyMapCls.applyMapOptions(),e.applyMapCls.removeEmmaps(),e.applyMapCls.applyEmmapOptions(),e.applyMapCls.removePhimaps(),e.axes=[],e.pc1&&e.axesCls.setPc1Axes(),e.drawCls.draw(),e.bShowHighlight=!0,e.opts.rotationcenter="molecule center"}alternateWrapper(){let e=this.icn3d;e.icn3dui,e.bAlternate=!0,this.alternateStructures(),e.bAlternate=!1}}class ct{constructor(e){this.icn3d=e}draw(e){let t=this.icn3d,s=t.icn3dui;if(!t.bRender||t.hAtoms&&0!=Object.keys(t.hAtoms)||(t.hAtoms=s.hashUtilsCls.cloneHash(t.atoms)),t.sceneCls.rebuildScene(),t.bImpo&&t.impostorCls.drawImpostorShader(),t.setColorCls.applyPrevColor(),void 0!==t.biomtMatrices&&t.biomtMatrices.length>1)if(t.bAssembly&&1==Object.keys(t.structures).length&&(void 0===s.cfg.mmdbid&&1==s.cfg.bu||void 0!==s.cfg.mmdbid&&1==s.cfg.bu&&Object.keys(t.atoms).length*t.biomtMatrices.length>t.maxatomcnt))t.instancingCls.drawSymmetryMates();else{let e=!0;t.applyCenterCls.centerSelection(void 0,e)}let i=void 0!==t.hAtoms?Object.keys(t.hAtoms).length:0;if(i>0&&i0){e.children[0].scale.z=t[0].distance,t[0].point.sub(r.mdl.position);let s=r.rayThreshold,i=r.rayCls.getAtomsFromPosition(t[0].point,s);for(;!i&&s<10;)s+=.5,i=r.rayCls.getAtomsFromPosition(t[0].point,s);i&&(r.pAtom=i,this.showPickingVr(r.pk,i))}}}}catch(e){}}showPickingVr(e,t){let s=this.icn3d;if(s.icn3dui,e||(e=2),1===e)s.hAtoms[t.serial]=1;else if(2===e){let e=t.structure+"_"+t.chain+"_"+t.resi;s.hAtoms=s.residues[e]}else if(3===e)s.hAtoms=s.pickingCls.selectStrandHelixFromAtom(t);else if(4===e)s.hAtoms=s.pickingCls.select3ddomainFromAtom(t);else if(5===e){let e=t.structure+"_"+t.chain;s.hAtoms=s.chains[e]}2===e?s.residueLabelsCls.addResidueLabels(s.hAtoms,void 0,void 0,!0):1===e&&s.residueLabelsCls.addAtomLabels(atoms),s.setOptionCls.setStyle("proteins",t.style)}render_base(){let e=this.icn3d,t=e.icn3dui,s=this;if(t.bNode)return;let i=e.bControlGl&&!t.bNode?window.cam:e.cam;if(e.directionalLight){let t=new THREE.Quaternion;t.setFromUnitVectors(new THREE.Vector3(0,0,e.cam_z).normalize(),i.position.clone().normalize()),e.directionalLight.position.copy(e.lightPos.clone().applyQuaternion(t).normalize()),e.directionalLight2.position.copy(e.lightPos2.clone().applyQuaternion(t).normalize()),e.directionalLight3.position.copy(e.lightPos3.clone().applyQuaternion(t).normalize())}if(e.bVr||e.renderer.setPixelRatio(window.devicePixelRatio),e.bVr){let t=.04;if(e.controllers){let i=this.updateGamepadState();for(let n=0,l=e.controllers.length;n{const i=e.gamepad.axes;let r=parseInt(1e3*i[t]),o=parseInt(-1e3*i[s]);n.push(r),l.push(o)})),{xArray:n,yArray:l}}return{xArray:[0,0],yArray:[0,0]}}}class ht{constructor(e){this.icn3d=e}getAtomsWithinAtom(e,t,s,i,n,l,r){let o=this.icn3d;o.icn3dui;let a=this.getNeighboringAtoms(e,t,s,r);i&&(o.resid2Residhash={});let d={};for(let e in t){let c,h,p=o.atoms[e],m=p.structure+"_"+p.chain+"_"+p.resi;for(let e in o.residues[m])if(o.atoms[e]&&("CA"===o.atoms[e].name&&"C"===o.atoms[e].elem||"O3'"===o.atoms[e].name||"O3*"===o.atoms[e].name)){c=o.atoms[e];break}void 0===c&&(c=p),i&&(h=p.resn+" $"+p.structure+"."+p.chain+":"+p.resi,void 0===o.resid2Residhash[h]&&(o.resid2Residhash[h]={}));let u=p.structure+"_"+p.chain+"_"+p.resi;for(let e in a){let m=a[e];if(!o.crossstrucinter&&p.structure!=m.structure)continue;if(!r&&m.serial in t)continue;if(o.bOpm&&"DUM"===m.resn)continue;let g=m.coord.distanceTo(p.coord);if(go?r:o,d=Math.sqrt(a),c=(d+s)*(d+s),h={};for(let r in e){let e=n.atoms[r];!i&&t.hasOwnProperty(e.serial)||(this.bOpm&&"DUM"===e.resn||e.coord.xl[1][0]+s||e.coord.yl[1][1]+s||e.coord.zl[1][2]+s||(e.coord.x-l[2][0])*(e.coord.x-l[2][0])+(e.coord.y-l[2][1])*(e.coord.y-l[2][1])+(e.coord.z-l[2][2])*(e.coord.z-l[2][2])e.coord.x?n:e.coord.x,l=l>e.coord.y?l:e.coord.y,r=r>e.coord.z?r:e.coord.z}return[[t,s,i],[n,l,r],[o/c,a/c,d/c]]}hideContact(){let e=this.icn3d;e.icn3dui,e.opts.contact="no",void 0===e.lines&&(e.lines={}),e.lines.contact=[],e.contactpnts=[];for(let t in e.atoms)e.atoms[t].style2="nothing";for(let t in e.sidec)e.hAtoms.hasOwnProperty(t)&&(e.atoms[t].style2=e.opts.sidec);for(let t in e.water)e.hAtoms.hasOwnProperty(t)&&(e.atoms[t].style=e.opts.water)}}class pt{constructor(e){this.icn3d=e}isHbondDonorAcceptor(e){let t=this.icn3d;if(t.icn3dui,"N"==e.name&&!e.het||"N"==e.elem&&"Arg"==e.resn||"N"==e.elem&&"Asn"==e.resn||"N"==e.elem&&"Gln"==e.resn||"N"==e.elem&&"Lys"==e.resn||"N"==e.elem&&"Trp"==e.resn)return"donor";if("O"==e.name&&!e.het||"S"==e.elem&&"Met"==e.resn||"O"==e.elem&&"Asn"==e.resn||"O"==e.elem&&"Asp"==e.resn||"O"==e.elem&&"Gln"==e.resn||"O"==e.elem&&"Glu"==e.resn)return"acceptor";if("S"==e.elem&&"Cys"==e.resn||"N"==e.elem&&"His"==e.resn||"O"==e.elem&&"Ser"==e.resn||"O"==e.elem&&"Thr"==e.resn||"O"==e.elem&&"Tyr"==e.resn)return"both";if("Pro"==e.resn)return"none";if("N"==e.elem){if("Asn"==e.resn||"Gln"==e.resn)return"both";let s=0,i=0;for(let i=0,n=e.bonds.length;i1?"ring":"donor":"none"}if("O"==e.elem&&1==e.bonds.length){if("Asn"==e.resn||"Gln"==e.resn)return"both";for(let s=0,i=e.bonds.length;s=2?"acceptor":"both"}if("O"==e.elem&&2==e.bonds.length){for(let s=0,i=e.bonds.length;s1);++t)"H"!=s.atoms[e.bonds[t]].elem&&(i=s.atoms[e.bonds[t]],l[r++].subVectors(s.atoms[e.bonds[t]].coord,e.coord));if(1===r)for(let t=0,n=i.bonds.length;t1);++t)"H"!=s.atoms[i.bonds[t]].elem&&s.atoms[i.bonds[t]].serial!=e.serial&&l[r++].subVectors(s.atoms[i.bonds[t]].coord,e.coord);if(2!==r)return;let o=l[0].cross(l[1]);return Math.abs(Math.PI/2-o.angleTo(n))}isValidHbond(e,t,s){let i=this.icn3d;i.icn3dui;let n,l,r=this.isHbondDonorAcceptor(e),o=this.isHbondDonorAcceptor(t),a=50*Math.PI/180,d=50*Math.PI/180,c=90*Math.PI/180,h=30*Math.PI/180;if("donor"==r&&("acceptor"==o||"both"==o||"ring"==o)||"acceptor"==o&&("donor"==r||"both"==r||"ring"==r))n=e,l=t;else if("acceptor"==r&&("donor"==o||"both"==o||"ring"==o)||"donor"==o&&("acceptor"==r||"both"==r||"ring"==r))l=e,n=t;else{if("both"!=r&&"ring"!=r||"both"!=o&&"ring"!=o)return!1;n=e,l=t,i.nucleotides.hasOwnProperty(e.serial)&&i.nucleotides.hasOwnProperty(t.serial)&&("ring"==r||"ring"==o)||(e.het||t.het)&&"ring"==r&&"ring"==o||(h=90*Math.PI/180)}let p=this.calcAngles(n,l),m=90*Math.PI/180;for(let e=0,t=p.length;ed)return!1;let u=this.calcPlaneAngle(n,l);if(void 0!==u&&u>h)return!1;let g=this.calcAngles(l,n),f=90*Math.PI/180;for(let e=0,t=g.length;ea)return!1;let b=this.calcPlaneAngle(l,n);return!(void 0!==b&&b>c)}calculateChemicalHbonds(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(0===Object.keys(e).length||0===Object.keys(t).length)return;r.resid2Residhash={};let a,d,c={},h=s*s;for(let t in e){let s=e[t],n=i?"LYS"===s.resn&&"N"===s.elem&&"N"!==s.name||"ARG"===s.resn&&("NH1"===s.name||"NH2"===s.name)||("GLU"===s.resn||"ASP"===s.resn)&&"O"===s.elem&&"O"!==s.name||s.het&&("N"===s.elem||"O"===s.elem||"S"===s.elem):"N"===s.elem||"O"===s.elem||"S"===s.elem&&(s.het||"Cys"===s.resn||"Met"===s.resn);n=r.bOpm?n&&"DUM"!==s.resn:n,n&&(a=s.structure+"_"+s.chain+"_"+s.resi,d=a+"_"+s.name,c[d]=s)}let p={},m={},u=.5,g=-27.888,f={};for(let e in t){let b=t[e],C=i?"LYS"===b.resn&&"N"===b.elem&&"N"!==b.name||"ARG"===b.resn&&("NH1"===b.name||"NH2"===b.name)||("GLU"===b.resn||"ASP"===b.resn)&&"O"===b.elem&&"O"!==b.name||b.het&&("N"===b.elem||"O"===b.elem||"S"===b.elem):"N"===b.elem||"O"===b.elem||"S"===b.elem&&(b.het||"Cys"===b.resn||"Met"===b.resn);if(C=r.bOpm?C&&"DUM"!==b.resn:C,C){a=b.structure+"_"+b.chain+"_"+b.resi,d=a+"_"+b.name;let e=b.resn+" $"+b.structure+"."+b.chain+":"+b.resi+"@"+b.name;void 0===r.resid2Residhash[e]&&(r.resid2Residhash[e]={});for(let t in c){if(i&&!(("LYS"!==b.resn&&"ARG"!==b.resn||"LYS"!==c[t].resn&&"ARG"!==c[t].resn)&&("GLU"!==b.resn&&"ASP"!==b.resn||"GLU"!==c[t].resn&&"ASP"!==c[t].resn)))continue;if(!r.crossstrucinter&&b.structure!=c[t].structure)continue;if(a==t.substr(0,t.lastIndexOf("_")))continue;let d=Math.abs(b.coord.x-c[t].coord.x);if(d>s)continue;let C=Math.abs(b.coord.y-c[t].coord.y);if(C>s)continue;let y=Math.abs(b.coord.z-c[t].coord.z);if(y>s)continue;let v=d*d+C*C+y*y;if(v>h)continue;if(!r.proteins.hasOwnProperty(b.serial)||!r.proteins.hasOwnProperty(c[t].serial)||"N"!==b.name&&"O"!==b.name||"O"!==c[t].name&&"N"!==c[t].name){if(!this.isValidHbond(b,c[t],s))continue}else{if(b.name===c[t].name)continue;if(b.structure==c[t].structure&&b.chain==c[t].chain&&Math.abs(b.resi-c[t].resi)<=1)continue;let e,i="N"===b.name?b:c[t],n="O"===b.name?b:c[t];if("Pro"===i.resn)continue;if(void 0===i.hcoord){if(!this.isValidHbond(b,c[t],s))continue}else{let s,l=i.hcoord,o=i.coord,a=n.structure+"_"+n.chain+"_"+n.resi;for(let e in r.residues[a])if("C"===r.atoms[e].name){s=r.atoms[e];break}if(!s)continue;let d=s.coord,h=n.coord,p=l.distanceTo(h),m=l.distanceTo(d),f=o.distanceTo(d),C=o.distanceTo(h);e=p2||f[c[t].serial]>2)continue;void 0===f[b.serial]?f[b.serial]=1:++f[b.serial],void 0===f[c[t].serial]?f[c[t].serial]=1:++f[c[t].serial],"graph"!==n&&(i?(r.saltbridgepnts.push({serial:b.serial,coord:b.coord}),r.saltbridgepnts.push({serial:c[t].serial,coord:c[t].coord})):(r.hbondpnts.push({serial:b.serial,coord:b.coord}),r.hbondpnts.push({serial:c[t].serial,coord:c[t].coord})));let w=c[t].structure+"_"+c[t].chain+"_"+c[t].resi;p=o.hashUtilsCls.unionHash(p,r.residues[a]),p=o.hashUtilsCls.unionHash(p,r.residues[w]),m[a]=1,m[w]=1;let _=c[t].resn+" $"+c[t].structure+"."+c[t].chain+":"+c[t].resi+"@"+c[t].name,S=a+"_"+b.resn+","+w+"_"+c[t].resn;void 0!==r.resids2interAll[S]&&void 0!==r.resids2interAll[S].ionic&&r.resids2interAll[S].ionic.hasOwnProperty(e+","+_)||(r.resid2Residhash[e][_]=v.toFixed(1),l||(void 0===r.resids2inter[S]&&(r.resids2inter[S]={}),void 0===r.resids2inter[S].hbond&&(r.resids2inter[S].hbond={}),r.resids2inter[S].hbond[e+","+_]=v.toFixed(1)),void 0===r.resids2interAll[S]&&(r.resids2interAll[S]={}),void 0===r.resids2interAll[S].hbond&&(r.resids2interAll[S].hbond={}),r.resids2interAll[S].hbond[e+","+_]=v.toFixed(1))}}}let b=Object.keys(m);if("graph"!==n)for(let e=0,t=b.length;en)return!1;let c=Math.abs(e.coord.y-t.coord.y);if(c>n)return!1;let h=Math.abs(e.coord.z-t.coord.z);if(h>n)return!1;let p=d*d+c*c+h*h;if(p>l)return!1;"graph"!==s&&("halogen"==i?(a.halogenpnts.push({serial:e.serial,coord:e.coord}),a.halogenpnts.push({serial:t.serial,coord:t.coord})):"pi-cation"==i?(a.picationpnts.push({serial:e.serial,coord:e.coord}),a.picationpnts.push({serial:t.serial,coord:t.coord})):"pi-stacking"==i&&(a.pistackingpnts.push({serial:e.serial,coord:e.coord}),a.pistackingpnts.push({serial:t.serial,coord:t.coord})));let m=t.resn+" $"+t.structure+"."+t.chain+":"+t.resi+"@"+t.name;a.resid2Residhash[r][m]=p.toFixed(1);let u=e.structure+"_"+e.chain+"_"+e.resi+"_"+e.resn+","+t.structure+"_"+t.chain+"_"+t.resi+"_"+t.resn;return o||(void 0===a.resids2inter[u]&&(a.resids2inter[u]={}),void 0===a.resids2inter[u][i]&&(a.resids2inter[u][i]={}),a.resids2inter[u][i][r+","+m]=p.toFixed(1)),void 0===a.resids2interAll[u]&&(a.resids2interAll[u]={}),void 0===a.resids2interAll[u][i]&&(a.resids2interAll[u][i]={}),a.resids2interAll[u][i][r+","+m]=p.toFixed(1),!0}getRingNormal(e){if(this.icn3d.icn3dui,e.length<3)return;let t=e[0].clone().sub(e[1]),s=e[1].clone().sub(e[2]);return t.cross(s).normalize()}getAromaticRings(e,t,s){let i=this.icn3d;i.icn3dui;let n=[],l=[],r=[],o=[];if("nucleotide"==s){let s=new THREE.Vector3,a=new THREE.Vector3;if("A"==e.trim().toUpperCase()||"DA"==e.trim().toUpperCase()||"G"==e.trim().toUpperCase()||"DG"==e.trim().toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"N1"==t.name||"C2"==t.name||"N3"==t.name||"C6"==t.name?(s.add(t.coord),r.push(t.coord)):"C4"==t.name||"C5"==t.name?(s.add(t.coord),a.add(t.coord),r.push(t.coord),o.push(t.coord)):"N7"!=t.name&&"C8"!=t.name&&"N9"!=t.name||(a.add(t.coord),o.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r))),5==o.length&&(a.multiplyScalar(.2),n.push(a),l.push(this.getRingNormal(o)))}else if("C"==e.trim().toUpperCase()||"DC"==e.trim().toUpperCase()||"T"==e.trim().toUpperCase()||"DT"==e.trim().toUpperCase()||"U"==e.trim().toUpperCase()||"DU"==e.trim().toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"N1"==t.name||"C2"==t.name||"N3"==t.name||"C6"==t.name?(s.add(t.coord),r.push(t.coord)):"C4"!=t.name&&"C5"!=t.name||(s.add(t.coord),r.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r)))}}else if("protein"==s){let s=new THREE.Vector3,a=new THREE.Vector3;if("PHE"==e.toUpperCase()||"TYR"==e.toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"CG"!=t.name&&"CD1"!=t.name&&"CE1"!=t.name&&"CZ"!=t.name&&"CE2"!=t.name&&"CD2"!=t.name||(s.add(t.coord),r.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r)))}else if("HIS"==e.toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"CG"!=t.name&&"ND1"!=t.name&&"CE1"!=t.name&&"NE2"!=t.name&&"CD2"!=t.name||(s.add(t.coord),r.push(t.coord))}5==r.length&&(s.multiplyScalar(.2),n.push(s),l.push(this.getRingNormal(r)))}else if("TRP"==e.toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"CZ2"==t.name||"CH2"==t.name||"CZ3"==t.name||"CE3"==t.name?(s.add(t.coord),r.push(t.coord)):"CD2"==t.name||"CE2"==t.name?(s.add(t.coord),a.add(t.coord),r.push(t.coord),o.push(t.coord)):"CG"!=t.name&&"CD1"!=t.name&&"NE1"!=t.name||(a.add(t.coord),o.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r))),5==o.length&&(a.multiplyScalar(.2),n.push(a),l.push(this.getRingNormal(o)))}}return{piPosArray:n,normalArray:l}}dfs_cycle(e,t,s){let i=this.icn3d;if(i.icn3dui,2==i.ring_color[e])return s;if(1==i.ring_color[e]){s++;let n=t;for(i.ring_mark[n]=s;n!=e;)n=i.ring_par[n],i.ring_mark[n]=s;return s}if(i.ring_par[e]=t,i.ring_color[e]=1,void 0!==i.atoms[e])for(let t=0,n=i.atoms[e].bonds.length;t=3&&o<=6&&a[0]&&a[1]&&a[2]&&a[3]){let i=a[0].clone().sub(a[1]).normalize(),r=a[1].clone().sub(a[2]).normalize(),d=a[2].clone().sub(a[3]).normalize(),c=i.cross(r).normalize(),h=c.dot(d);if(Math.abs(h)<.052){l.multiplyScalar(1/o);let i=t.atoms[n];s[e+"_pi"+n]={resn:i.resn,name:"pi"+n,coord:l,serial:i.serial,structure:i.structure,chain:i.chain,resi:i.resi,normal:c}}}}return s}hideHalogenPi(){let e=this.icn3d;e.icn3dui,e.opts.halogen="no",e.opts["pi-cation"]="no",e.opts["pi-stacking"]="no",void 0===e.lines&&(e.lines={}),e.lines.halogen=[],e.lines["pi-cation"]=[],e.lines["pi-stacking"]=[],e.halogenpnts=[],e.picationpnts=[],e.pistackingpnts=[];for(let t in e.atoms)e.atoms[t].style2="nothing";for(let t in e.sidec)e.hAtoms.hasOwnProperty(t)&&(e.atoms[t].style2=e.opts.sidec);for(let t in e.water)e.hAtoms.hasOwnProperty(t)&&(e.atoms[t].style=e.opts.water)}}class ut{constructor(e){this.icn3d=e}calculateIonicInteractions(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(0===Object.keys(e).length||0===Object.keys(t).length)return;r.resid2Residhash={};let a,d,c={},h={},p=s*s;for(let t in e){let s=e[t];if("ARG"===s.resn&&"NH2"===s.name||"GLU"===s.resn&&"OE2"===s.name||"ASP"===s.resn&&"OD2"===s.name)continue;let i=("LYS"===s.resn||"HIS"===s.resn)&&"N"===s.elem&&"N"!==s.name||"ARG"===s.resn&&("NH1"===s.name||"NH2"===s.name)||s.het&&-1!==o.parasCls.cationsTrimArray.indexOf(s.elem)||s.het&&"N"===s.elem&&1==s.bonds.length,n=this.isAnion(s);i=r.bOpm?i&&"DUM"!==s.resn:i,n=r.bOpm?n&&"DUM"!==s.resn:n,(i||n)&&(a=s.structure+"_"+s.chain+"_"+s.resi,d=a+"_"+s.name,i&&(c[d]=s),n&&(h[d]=s))}let m={},u={};for(let e in t){let i=t[e];if("ARG"===i.resn&&"NH2"===i.name||"GLU"===i.resn&&"OE2"===i.name||"ASP"===i.resn&&"OD2"===i.name)continue;let g=("LYS"===i.resn||"HIS"===i.resn)&&"N"===i.elem&&"N"!==i.name||"ARG"===i.resn&&("NH1"===i.name||"NH2"===i.name)||i.het&&-1!==o.parasCls.cationsTrimArray.indexOf(i.elem),f=this.isAnion(i);if(g=r.bOpm?g&&"DUM"!==i.resn:g,f=r.bOpm?f&&"DUM"!==i.resn:f,g||f){a=i.structure+"_"+i.chain+"_"+i.resi,d=a+"_"+i.name;let e=i.resn+" $"+i.structure+"."+i.chain+":"+i.resi+"@"+i.name;void 0===r.resid2Residhash[e]&&(r.resid2Residhash[e]={});let t={};g?t=h:f&&(t=c);let b,C=i.structure+"_"+i.chain+"_"+i.resi;g&&"ARG"===i.resn&&"NH1"===i.name?b=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[C],"NH2"):f&&"GLU"===i.resn&&"OE1"===i.name?b=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[C],"OE2"):f&&"ASP"===i.resn&&"OD1"===i.name&&(b=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[C],"OD2"));let y=void 0===b?i.coord:i.coord.clone().add(b.coord).multiplyScalar(.5);for(let d in t){if(a==d.substr(0,d.lastIndexOf("_")))continue;if(!r.crossstrucinter&&i.structure!=t[d].structure)continue;let c,h=t[d].structure+"_"+t[d].chain+"_"+t[d].resi;f&&"ARG"===t[d].resn&&"NH1"===t[d].name?c=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[h],"NH2"):g&&"GLU"===t[d].resn&&"OE1"===t[d].name?c=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[h],"OE2"):g&&"ASP"===t[d].resn&&"OD1"===t[d].name&&(c=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[h],"OD2"));let b=void 0===c?t[d].coord:t[d].coord.clone().add(c.coord).multiplyScalar(.5),C=Math.abs(y.x-b.x);if(C>s)continue;let v=Math.abs(y.y-b.y);if(v>s)continue;let w=Math.abs(y.z-b.z);if(w>s)continue;let _=C*C+v*v+w*w;if(_>p)continue;"graph"!==n&&(r.saltbridgepnts.push({serial:i.serial,coord:y}),r.saltbridgepnts.push({serial:t[d].serial,coord:b}));let S=t[d].structure+"_"+t[d].chain+"_"+t[d].resi;m=o.hashUtilsCls.unionHash(m,r.residues[a]),m=o.hashUtilsCls.unionHash(m,r.residues[S]),u[a]=1,u[S]=1;let A=t[d].resn+" $"+t[d].structure+"."+t[d].chain+":"+t[d].resi+"@"+t[d].name;r.resid2Residhash[e][A]=_.toFixed(1);let x=a+"_"+i.resn+","+S+"_"+t[d].resn;l||(void 0===r.resids2inter[x]&&(r.resids2inter[x]={}),void 0===r.resids2inter[x].ionic&&(r.resids2inter[x].ionic={}),r.resids2inter[x].ionic[e+","+A]=_.toFixed(1)),void 0===r.resids2interAll[x]&&(r.resids2interAll[x]={}),void 0===r.resids2interAll[x].ionic&&(r.resids2interAll[x].ionic={}),r.resids2interAll[x].ionic[e+","+A]=_.toFixed(1)}}}let g=Object.keys(u);if("graph"!==n)for(let e=0,t=g.length;e1?1/(n-1):1;for(let n in e){let e=t.atoms[n];e.color=e.het?s.parasCls.atomColors[e.elem]||s.parasCls.defaultAtomColor:s.parasCls.thr().setHSL(3/4*(1-i++*l),1,.45),t.atomPrevColors[n]=e.color}}colorRainbow(e){let t=this.icn3d,s=t.icn3dui,i=0,n=0;e=s.hashUtilsCls.intHash(e,t.hAtoms);for(let s in e){t.atoms[s].het||++n}let l=n>1?1/(n-1):1;for(let n in e){let e=t.atoms[n];e.color=e.het?s.parasCls.atomColors[e.elem]||s.parasCls.defaultAtomColor:s.parasCls.thr().setHSL(3/4*i++*l,1,.45),t.atomPrevColors[n]=e.color}}setColorAcrossSets(e,t){let s=this.icn3d,i=s.icn3dui,n=0,l=e.length,r=l>1?1/(l-1):1;for(let l=0,o=e.length;l0)this.setMmdbChainColor();else{let e=-1,s="",l=n.parasCls.stdChainColors.length;for(let r in t){let t=i.atoms[r];t.chain!=s&&(++e,e%=l),t.het?(t.color=n.parasCls.atomColors[t.elem],i.atomPrevColors[r]=t.color):(t.color=n.parasCls.stdChainColors[e],Object.keys(i.chainsColor).length>0&&this.updateChainsColor(t),i.atomPrevColors[r]=t.color),s=t.chain}}break;case"domain":s=0,l=0;let m=Object.keys(i.tddomains);l=m.length,r=l>1?1/(l-1):1;for(let e=0,t=m.length;e1?1/(l-1):1;for(let e=0;e Defined Sets", and try it again.');break;case"secondary structure green":i.sheetcolor="green";for(let e in t){let t=i.atoms[e];t.color=t.het?n.parasCls.atomColors[t.elem]||n.parasCls.defaultAtomColor:n.parasCls.ssColors[t.ss]||n.parasCls.thr(16711935),i.atomPrevColors[e]=t.color}break;case"secondary structure yellow":case"secondary structure":i.sheetcolor="yellow";for(let e in t){let t=i.atoms[e];t.color=t.het?n.parasCls.atomColors[t.elem]||n.parasCls.defaultAtomColor:n.parasCls.ssColors2[t.ss]||n.parasCls.thr(16711935),i.atomPrevColors[e]=t.color}break;case"secondary structure spectrum":s=0,l=0;let u,g,f=[],b=-9999;for(let e in t){if(!i.proteins.hasOwnProperty(e))continue;let t=i.atoms[e];-9999==b&&(u=parseInt(e)),-9999!=b&&(t.ss!=g.ss||Math.abs(t.resi-g.resi)>1||t.ssbegin&&g.ssend)&&("coil"==g.ss||f.push([u,b]),u=e),b=parseInt(e),g=t}"coil"==g.ss||f.push([u,b]),l=f.length,r=l>1?1/(l-1):1;for(let e=0,t=f.length;e100&&(e=100);let r=(i.middB-e)*i.spanBinv1,o=(e-i.middB)*i.spanBinv2;e=90?t.color=n.parasCls.thr().setRGB(0,.325,.839):e>=70&&e<90?t.color=n.parasCls.thr().setRGB(.396,.572,.953):e>=50&&e<70?t.color=n.parasCls.thr().setRGB(1,.859,.075):e<50&&(t.color=n.parasCls.thr().setRGB(1,.49,.271))}i.atomPrevColors[e]=t.color}break;case"b factor":i.middB=50,i.spanBinv1=.02,i.spanBinv2=.02;for(let e in t){let t=i.atoms[e];if(void 0===t.b||isNaN(t.b)||0==parseInt(1e3*t.b))t.color=n.parasCls.thr().setRGB(0,1,0);else{let e=t.b;e>100&&(e=100),e=t.structure.substr(0,4)!=i.defaultPdbId&&t.structure.length>5?100-e:e;let s=(i.middB-e)*i.spanBinv1,l=(e-i.middB)*i.spanBinv2;t.color=et.b&&(o=t.b),a5?100-t.b:t.b,s=i.bfactorArray.indexOf(e)/C;t.color=s<.5?n.parasCls.thr().setRGB(2*s,2*s,1):n.parasCls.thr().setRGB(1,2*(1-s),2*(1-s))}i.atomPrevColors[e]=t.color}break;case"area":if(void 0===i.resid2area){let e=n.hashUtilsCls.cloneHash(i.hAtoms);i.hAtoms=n.hashUtilsCls.cloneHash(i.atoms),i.bCalcArea=!0,i.opts.surface="solvent accessible surface",i.applyMapCls.applySurfaceOptions(),i.bCalcArea=!1,i.hAtoms=n.hashUtilsCls.cloneHash(e)}let y=void 0!==i.midpercent?i.midpercent:35;i.spanBinv1=.02,i.spanBinv2=.02;for(let e in t){let t=i.atoms[e],s=t.structure+"_"+t.chain+"_"+t.resi+"_"+t.resn,l=n.parasCls.residueArea.hasOwnProperty(t.resn)?i.resid2area[s]/n.parasCls.residueArea[t.resn]*100:y;l>100&&(l=100);let r=(y-l)*i.spanBinv1,o=(l-y)*i.spanBinv2;t.color=l

    ";if("atom"==e){let e=["proteins","nucleotides","chemicals","ions","water"];for(let i=0,n=e.length;i[e,s.parasCls.hydrophobicValues[e]]));r.sort(((e,t)=>parseFloat(e[1])-parseFloat(t[1])));var o=r.map((e=>[e[0],Object.keys(n[e[0]])[0]]));l+="
    ","normalized hydrophobic"==e?(l+="Dark green (W, F, Y, L, I, C, M): Hydrophobic
    ",l+="Light green (G, V, S, T, A, N, P, Q): Polar
    ",l+="Grey: Charged, not hydrophobic

    "):(l+="Green (W, F, Y, L, I, C, M): Hydrophobic
    ",l+="Yellow (G, V, S, T, A, N, P, Q): Polar
    ",l+="Red: Negatively Charged
    ",l+="Blue: Positively Charged

    ");let a=0;for(let e of o)s.parasCls.residueAbbrev[e[0]]&&(l+="
    ",l+="
    ",l+=s.parasCls.residueAbbrev[e[0]]+"
    ",a%4==3&&(l+="
    "),++a);l+="
    "}else"b factor"==e?(l+="
    B factor quantitates the uncertainty for each atom. A high B factor reflects that the position is less certain.

    ",l+=s.htmlCls.clickMenuCls.setLegendHtml()):"confidence"==e?l+=s.htmlCls.clickMenuCls.setLegendHtml(!0):(l="",i=!0);$("#"+s.pre+"dl_legend").html(l),s.htmlCls.dialogCls.openDlg("dl_legend","Color Legend"),i&&window.dialog&&window.dialog.dialog("close")}getColorLegendForElem(e,t){let s=this.icn3d,i=s.icn3dui,n="",l={};for(let e in t){let t=s.atoms[e],i=void 0===t||void 0===t.color||"FFFFFF"===t.color.getHexString().toUpperCase()?"DDDDDD":t.color.getHexString();void 0===l[t.elem]&&(l[t.elem]={}),l[t.elem][i]=1}if(Object.keys(l).length>0){n+=""+e+"
    ";let t=Object.keys(l).sort();for(let e=0,s=t.length;e";for(let e in l[s])n+="
    ";n+=i.parasCls.atomnames[s.toUpperCase()]+"

    "}n+="
    "}return n}getRes2color(e,t){let s=this.icn3d,i=s.icn3dui,n={},l=s.firstAtomObjCls.getResiduesFromAtoms(e);for(let e in l){let l=s.residues[e],r=s.firstAtomObjCls.getFirstAtomObj(l),o=t?r.resn:i.parasCls.residueAbbrev[r.resn],a=void 0===r||void 0===r.color||"FFFFFF"===r.color.getHexString().toUpperCase()?"DDDDDD":r.color.getHexString();null!=o&&(void 0===n[o]&&(n[o]={}),n[o][a]=1)}return n}getColorLegendForResidue(e){this.icn3d.icn3dui;let t="",s=this.getRes2color(e);if(Object.keys(s).length>0){t+="
    ";let e=Object.keys(s).sort(),i="",n=0;for(let l=0,r=e.length;l";for(let e in s[o])r+="
    ";r+=o+"
    ",n%4==3&&(r+="
    "),-1!=o.indexOf("(")?(t+=r,++n):i+=r}i&&(t+="
    "+i),t+="
    "}return t}getColorLegendForCharge(e){let t=this.icn3d;t.icn3dui;let s="",i=t.firstAtomObjCls.getResiduesFromAtoms(e),n={};for(let e in i){let s=t.residues[e],i=t.firstAtomObjCls.getFirstAtomObj(s);"ARG"==i.resn||"LYS"==i.resn?n.Positive=1:"HIS"==i.resn?n["Partial-Positive"]=1:"ASP"==i.resn||"GLU"==i.resn||t.nucleotides[i.serial]?n.Negative=1:n.Neutral=1}const l={Positive:"0000ff","Partial-Positive":"8080ff",Negative:"ff0000",Neutral:"888888"};let r=["Positive","Partial-Positive","Negative","Neutral"];s+="
    ";for(let e=0,t=r.length;e",s+="
    ",s+=t,s+="
    ")}return s+="
    (Charges are at pH 7)",s+="
    ",s}getColorLegendForIgstrand(e){this.icn3d.icn3dui;let t="";const s={"A^ Strand":"FF00FF","A Strand":"663399","A* Strand":"FFC0CB","A Strand":"9370db","B Strand":"ba55d3","C Strand":"0000FF","C' Strand":"6495ED","C'' Strand":"006400","D Strand":"00FF00","E Strand":"FFFF00","F Strand":"FFA500","G Strand":"FF0000","G* Strand":"8B0000",Loop:"CCCCCC"};t+="
    ";for(let e in s){t+="",t+="
    ",t+=e,t+="

    "}return t+="
    ",t}}class yt{constructor(e){this.icn3d=e}async showCddSiteAll(){let e=this.icn3d,t=e.icn3dui,s=this;e.chainid2pssmid={};let i=$.map(e.protein_chainid,(function(e){return e})),n=Object.keys(e.protein_chainid),l="https://www.ncbi.nlm.nih.gov/Structure/cdannots/cdannots.fcgi?fmt&frclive&live=lcl&queries="+i;if(1==Object.keys(e.structures).length&&(t.cfg.mmtfid||t.cfg.pdbid||t.cfg.opmid||t.cfg.mmdbid||t.cfg.gi||t.cfg.uniprotid||t.cfg.blast_rep_id||t.cfg.cid||t.cfg.mmcifid)||2==Object.keys(e.structures).length&&t.cfg.align){let e={};try{e.value=await t.getAjaxPromise(l,"jsonp"),s.parseCddData([e],n)}catch(e){return void s.getNoCdd(i)}}else{let i=[];for(let s=0,r=n.length;s',p=h,m=h,u=d.doms;n.bNode&&!i.resid2cdd[c]&&(i.resid2cdd[c]=[]);let g=l.setDomainFeature(u,c,!0,h,p,m);i.chainid2pssmid[c]={pssmid2name:g.pssmid2name,pssmid2fromArray:g.pssmid2fromArray,pssmid2toArray:g.pssmid2toArray};let f=g.acc2domain;h=g.html+"",p=g.html2+"",m=g.html3+"",$("#"+i.pre+"dt_cdd_"+c).html(h),$("#"+i.pre+"ov_cdd_"+c).html(p),$("#"+i.pre+"tt_cdd_"+c).html(m),h='
    ',p=h,m=h;let b=d.motifs;n.bNode&&!i.resid2site[c]&&(i.resid2site[c]=[]),g=l.setDomainFeature(b,c,!1,h,p,m,f),h=g.html,p=g.html2,m=g.html3;let C=a.data[e].sites,y=void 0!==C?C.length:0;for(let e=0;e17&&(s=s.substr(0,17)+"...");let l,r=C[e].title,o=[];for(let t=0,s=C[e].locs.length;t'+s+"
    ",u=''+t.toString()+" Res",g='';m+=d+u+"
    ",h+=d+u+g,p+=d+u+g;let f="site"+e.toString(),b=0,y=0,v=1;for(let t=0,s=i.giSeq[c].length;t1&&(l=s[0]+"..");let r=i.ParserUtilsCls.getResi(c,t);if(h+=''+s+"",n.bNode){let t={};t[c+"_"+r]="site: "+C[e].title,i.resid2site[c].push(t)}p+=i.showSeqCls.insertGapOverview(c,t);let o=n.cfg.blast_rep_id==c?Math.round(i.seqAnnWidth*t/(i.maxAnnoLength+i.nTotalGap)-b-y):Math.round(i.seqAnnWidth*t/i.maxAnnoLength-b-y);o>=0&&(p+='
     
    ',p+='
     
    ',b+=o,y+=v)}else h+="-";g=' '+t.toString()+" Residues",g+="
    ",g+="
    ",h+=g,p+=g}h+="",p+="",m+="",$("#"+i.pre+"dt_site_"+c).html(h),$("#"+i.pre+"ov_site_"+c).html(p),$("#"+i.pre+"tt_site_"+c).html(m)}}for(let e in i.protein_chainid)r.hasOwnProperty(e)||($("#"+i.pre+"dt_cdd_"+e).html(""),$("#"+i.pre+"ov_cdd_"+e).html(""),$("#"+i.pre+"tt_cdd_"+e).html(""),$("#"+i.pre+"dt_site_"+e).html(""),$("#"+i.pre+"ov_site_"+e).html(""),$("#"+i.pre+"tt_site_"+e).html(""));i.showAnnoCls.enableHlSeq(),i.bAjaxCddSite=!0}getNoCdd(e){let t=this.icn3d;t.icn3dui,console.log("No CDD data were found for the protein "+e+"...");for(let e in t.protein_chainid)$("#"+t.pre+"dt_cdd_"+e).html(""),$("#"+t.pre+"ov_cdd_"+e).html(""),$("#"+t.pre+"tt_cdd_"+e).html(""),$("#"+t.pre+"dt_site_"+e).html(""),$("#"+t.pre+"ov_site_"+e).html(""),$("#"+t.pre+"tt_site_"+e).html("");t.showAnnoCls.enableHlSeq(),t.bAjaxCddSite=!0}setDomainFeature(e,t,s,i,n,l,r){let o,a,d,c=this.icn3d,h=c.icn3dui;s&&(r={},o={},a={},d={});let p=void 0!==e?e.length:0,m=s?14:19,u=s?100:120;for(let g=0;gm&&(v=v.substr(0,m)+"...");let w=b+": "+C;s&&(o[p]=C);let _=e[g].locs;if(_)for(let e=0,r=_.length;e'+v+" ",E=''+S.toString()+" Res";l+=R+E+"
    ";let I='';i+=R+E+I,s&&(n+='
    '),n+='
    '+v+"
    ",n+=E+I;let T=b+g.toString();for(let e=0,n=c.giSeq[t].length;e1&&(l=n[0]+"..");let r=c.ParserUtilsCls.getResi(t,e);if(i+=''+n+"",h.bNode){let e={};e[t+"_"+r]=w,s?c.resid2cdd[t].push(e):c.resid2site[t].push(e)}}else i+="-";let M=c.firstAtomObjCls.getFirstCalphaAtomObj(c.chains[t]),P=void 0===M.color||"FFFFFF"===M.color.getHexString()?"DDDDDD":M.color.getHexString(),D=void 0!==M.color?P:"CCCCCC";if(h.cfg.blast_rep_id!=t)for(let s=0,i=r.length;s ',n+='
    '+C+"
    "}else{let s=[],i=[];for(let e=0,t=r.length;e ',n+='
    '+C+"
    "}}I=' '+S.toString()+" Residues",I+="
    ",I+="
    ",i+=I,n+=I,s&&(n+='')}}return{html:i,html2:n,html3:l,acc2domain:r,pssmid2name:o,pssmid2fromArray:a,pssmid2toArray:d}}showAnnoType(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui,a='
    ',d=a,c=a;if(0==n.length)return $("#"+r.pre+"dt_"+s+"_"+e).html(""),$("#"+r.pre+"ov_"+s+"_"+e).html(""),void $("#"+r.pre+"tt_"+s+"_"+e).html("");let h=i;i.length>17&&(i=i.substr(0,17)+"...");let p=[];for(let e=0,t=n.length;e'+i+"
    ",f=''+m.toString()+" Res";c+=g+f+"
    ";let b='';a+=g+f+b,d+=g+f+b;let C=s,y=0,v=0;for(let t=0,i=r.giSeq[e].length;t1&&(c=n[0]+"..");let h=i,p=e+"_"+i,m=n+i;if("ssbond"==s){m="Residue "+p+" has disulfide bond with";let t="";if(void 0!==l[p])for(let e=0,s=l[p].length;e'+c+"",d+=r.showSeqCls.insertGapOverview(e,t);let u=o.cfg.blast_rep_id==e?Math.round(r.seqAnnWidth*t/(r.maxAnnoLength+r.nTotalGap)-y-v):Math.round(r.seqAnnWidth*t/r.maxAnnoLength-y-v);u>=0&&(d+='
     
    ',d+='
     
    ',y+=u,v+=1)}else a+="-"}b=' '+m.toString()+" Residues",b+="",b+="
    ",a+=b,d+=b,a+="",d+="",c+="",$("#"+r.pre+"dt_"+s+"_"+e).html(a),$("#"+r.pre+"ov_"+s+"_"+e).html(d),$("#"+r.pre+"tt_"+s+"_"+e).html(c)}setToolTip(){let e=this.icn3d;e.icn3dui,$("[id^="+e.pre+"snp]").add("[id^="+e.pre+"clinvar]").add("[id^="+e.pre+"ssbond]").add("[id^="+e.pre+"crosslink]").tooltip({content:function(){return $(this).prop("title")},show:null,close:function(e,t){t.tooltip.hover((function(){$(this).stop(!0).fadeTo(400,1)}),(function(){$(this).fadeOut("400",(function(){$(this).remove()}))}))}})}}class vt{constructor(e){this.icn3d=e}showInteraction(e,t){this.icn3d.icn3dui,this.showInteraction_base(e,t)}showInteraction_base(e,t){let s=this.icn3d,i=s.icn3dui;i.bNode&&(s.resid2contact||(s.resid2contact={}),s.resid2contact[e]||(s.resid2contact[e]=[])),void 0===s.chainname2residues&&(s.chainname2residues={});let n=Object.keys(s.chains),l=e,r=Math.round(l.indexOf("_"));if(s.firstAtomObjCls.getFirstCalphaAtomObj(s.chains[l]),void 0===s.chainname2residues[l]){s.chainname2residues[l]={};let t=n.length;if(t>100&&void 0===i.cfg.mmdbid&&void 0===i.cfg.gi&&void 0===i.cfg.blast_rep_id&&void 0===i.cfg.align&&void 0===i.cfg.chainalign)return $("#"+s.pre+"dt_interaction_"+e).html(""),void $("#"+s.pre+"ov_interaction_"+e).html("");for(let e=0;e4)continue;let o,a=s.firstAtomObjCls.getFirstCalphaAtomObj(s.chains[t]);s.chemicals.hasOwnProperty(a.serial)?o="chemical":s.nucleotides.hasOwnProperty(a.serial)?o="nucleotide":s.ions.hasOwnProperty(a.serial)?o="ion":s.proteins.hasOwnProperty(a.serial)?o="protein":s.water.hasOwnProperty(a.serial)&&(o="water");let d=s.contactCls.getAtomsWithinAtom(i.hashUtilsCls.hash2Atoms(s.chains[l],s.atoms),i.hashUtilsCls.hash2Atoms(s.chains[t],s.atoms),4);if(0==Object.keys(d).length)continue;let c={};for(let e in d){let t=s.atoms[e];c[t.structure+"_"+t.chain+"_"+t.resi]=1}let h=t.substr(t.indexOf("_")+1)+"("+o+")";s.chainname2residues[l][h]=Object.keys(c)}}let o='
    ',a=o,d=o,c=0;for(let t in s.chainname2residues[e]){let n=s.chainname2residues[e][t];if(!n)continue;let l="Interact ."+t;l.length>17&&(l=l.substr(0,17)+"...");let r="Interact ."+t,h=[];for(let e=0,t=n.length;e'+l+"
    ",g=''+p.toString()+" Res";d+=u+g+"
    ";let f='';o+=u+g+f,a+=u+g+f;let b="inter"+c.toString(),C=0,y=0,v=1;for(let t=0,n=s.giSeq[e].length;t1&&(d=l[0]+"..");let c=n;if(o+=''+d+"",i.bNode){let t={};t[e+"_"+c]=r,s.resid2contact[e].push(t)}a+=s.showSeqCls.insertGapOverview(e,t);let h=i.cfg.blast_rep_id==e?Math.round(s.seqAnnWidth*t/(s.maxAnnoLength+s.nTotalGap)-C-y):Math.round(s.seqAnnWidth*t/s.maxAnnoLength-C-y);h>=0&&(a+='
     
    ',a+='
     
    ',C+=h,y+=v)}else o+="-"}f=' '+p.toString()+" Residues",f+="
    ",f+="
    ",o+=f,a+=f,++c}o+="",a+="",d+="",$("#"+s.pre+"dt_interaction_"+e).html(o),$("#"+s.pre+"ov_interaction_"+e).html(a),$("#"+s.pre+"tt_interaction_"+e).html(d),i.utilsCls.isMobile()?(s.hlSeqCls.selectSequenceMobile(),s.hlSeqCls.selectChainMobile()):s.hlSeqCls.selectSequenceNonMobile()}}class wt{constructor(e){this.icn3d=e}async showPTM(e,t,s,i,n){let l=this.icn3d,r=l.icn3dui,o=this,a=e.substr(0,e.indexOf("_")),d=e.substr(e.indexOf("_")+1);if("afmem"==s){let t={Transmembrane:[{begin:i,end:n}]};this.setAnnoPtmTransmem("transmem",t,e)}else if(a.length>5){let t,i="https://www.ebi.ac.uk/proteins/api/features/"+a;try{t=await r.getAjaxPromise(i,"json"),o.parsePTM(t,e,s)}catch{return void o.getNoPTM(e,s)}}else{let t,i=a.substr(0,4).toLowerCase(),n="https://www.ebi.ac.uk/pdbe/api/mappings/uniprot/"+i;try{t=await r.getAjaxPromise(n,"json");let a="";l.UPResi2ResiPosPerChain||(l.UPResi2ResiPosPerChain={}),l.UPResi2ResiPosPerChain[e]={};let c=t[i].UniProt,h=!1;for(let t in c){let s=c[t].mappings;for(let i=0,n=s.length;i',o+=r,a+=r;let d=s.substr(0,s.indexOf("_"));for(let c in t){let h=t[c],p=[],m=!1;for(let e=0,t=h.length;e5?p.push(e-1):i.UPResi2ResiPosPerChain&&i.UPResi2ResiPosPerChain[s][e]&&p.push(i.UPResi2ResiPosPerChain[s][e]),!m&&i.residues.hasOwnProperty(s+"_"+e)&&(m=!0)}if(0==p.length)continue;let u=p.length,g="ptm"==e?"PTM: "+c:"Transmembrane";g.length>17&&(g=g.substr(0,17)+"...");let f=c,b='
    '+g+"
    ",C=''+u.toString()+" Res",y='';a+=b+C+"
    ",r+=b+C+y,o+=b+C+y;let v=e+l.toString(),w=0,_=0,S=1;for(let e=0,t=i.giSeq[s].length;e1&&(l=t[0]+"..");let a=i.ParserUtilsCls.getResi(s,e);if(r+=''+t+"",n.bNode){let e={};e[s+"_"+a]=g,i.resid2ptm[s].push(e)}o+=i.showSeqCls.insertGapOverview(s,e);let d=n.cfg.blast_rep_id==s?Math.round(i.seqAnnWidth*e/(i.maxAnnoLength+i.nTotalGap)-w-_):Math.round(i.seqAnnWidth*e/i.maxAnnoLength-w-_);d>=0&&(o+='
     
    ',o+='
     
    ',w+=d,_+=S)}else r+="-";y=' '+u.toString()+" Residues",y+="
    ",y+="
    ",r+=y,o+=y,++l}r+="",o+="",a+="",$("#"+i.pre+"dt_"+e+"_"+s).html(r),$("#"+i.pre+"ov_"+e+"_"+s).html(o),$("#"+i.pre+"tt_"+e+"_"+s).html(a)}getNoPTM(e,t){let s=this.icn3d;s.icn3dui,console.log("No PTM data were found for the chain "+e+"...");let i="ptm"==t?"ptm":"transmem";$("#"+s.pre+"dt_"+i+"_"+e).html(""),$("#"+s.pre+"ov_"+i+"_"+e).html(""),$("#"+s.pre+"tt_"+i+"_"+e).html(""),s.showAnnoCls.enableHlSeq(),s.bAjaxPTM=!0}}class _t{constructor(e){this.icn3d=e}showCrosslink(e,t){let s=this.icn3d;s.icn3dui;let i=this;void 0===s.clbondpnts?setTimeout((function(){i.showCrosslink_base(e,t)}),1e3):this.showCrosslink_base(e,t)}showCrosslink_base(e,t){let s=this.icn3d;s.icn3dui.bNode&&(s.resid2crosslink||(s.resid2crosslink={}),s.resid2crosslink[e]||(s.resid2crosslink[e]=[]));let i=t,n={},l=i.substr(0,i.indexOf("_")),r=s.clbondpnts[l];if(void 0===r)return $("#"+s.pre+"dt_crosslink_"+e).html(""),$("#"+s.pre+"ov_crosslink_"+e).html(""),void $("#"+s.pre+"tt_crosslink_"+e).html("");for(let e=0,t=r.length;e',a=o,d=o,c=e.indexOf("_"),h=e.substr(c+1);if(s)n=e,i=t.domains[e]?t.domains[e].domains:[];else{let e,s=t.moleculeInfor;for(let t in s)if(s[t].chain===h){e=t,n=s[t].name;break}void 0!==e&&void 0!==t.domains[e]&&(i=t.domains[e].domains),void 0===i&&(i=[])}for(let t=0,s=i.length;t17?s.substr(0,17)+"...":s,h=i[t].intervals,p={},m={},u=[],g=[],f={},b=0;for(let e=0,t=h.length;e'+c+" ",y=''+b.toString()+" Res";d+=C+y+"
    ";let v='';o+=C+y+v,a+=C+y+v;let w="domain3d"+t.toString();for(let t=0,s=l.giSeq[e].length;t1&&(n=i[0]+"..");let r=s;o+=''+i+""}else o+="-"}let _=l.firstAtomObjCls.getFirstCalphaAtomObj(l.chains[e]),S=void 0===_.color||"FFFFFF"===_.color.getHexString()?"DDDDDD":_.color.getHexString(),A=void 0!==_.color?S:"CCCCCC";if(r.cfg.blast_rep_id!=e)for(let i=0,n=u.length;i ',a+='"}else{let i=[],n=[];for(let e=0,t=u.length;e ',a+='"}}v=' '+b.toString()+" Residues",v+="",v+="
    ",o+=v,a+=v}o+="",a+="",d+="",$("#"+l.pre+"dt_domain_"+e).html(o),$("#"+l.pre+"ov_domain_"+e).html(a),$("#"+l.pre+"tt_domain_"+e).html(d)}}class At{constructor(e){this.icn3d=e}async showSnp(e,t){this.icn3d.icn3dui,await this.showSnpClinvar(e,t,!0)}async showClinvar(e,t){this.icn3d.icn3dui,await this.showSnpClinvar(e,t,!1)}async showSnpClinvar(e,t,s){let i=this.icn3d.icn3dui,n=this,l=i.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainid="+t;try{let r=await i.getAjaxPromise(l,"jsonp"),o=r.snpgi,a=r.gi;if(s)await n.showSnpPart2(e,t,o);else{let s=o;[6137708,1942289,224510717,2624886,253723219,2554905,75765331,3660278,312207882,319443632,342350956,1827805,109157826,1065265,40889086,6730307,163931185,494469,163931091,60594093,55669745,18655489,17942684,6980537,166235465,6435586,4139398,4389047,364506122,78101667,262118402,20664221,2624640,158430173,494395,28948777,34810587,13399647,3660342,261278854,342350965,384482350,378792570,15988303,213424334,4558333,2098365,10835631,3318817,374074330,332639529,122919696,4389286,319443573,2781341,67464020,194709238,210061039,364506106,28949044,40889076,161172338,17943181,4557976,62738484,365813173,6137343,350610552,17942703,576308,223674070,15826518,1310997,93279697,4139395,255311799,157837067,361132363,357380836,146387678,383280379,1127268,299856826,13786789,1311054,46015217,3402130,381353319,30750059,218766885,340707375,27065817,355333104,2624634,62738384,241913553,304446010].includes(a)&&(s=a),await n.showClinvarPart2(e,t,s)}}catch(t){return void(s?n.processNoSnp(e):n.processNoClinvar(e))}}navClinVar(e){let t=this.icn3d;t.icn3dui;let s=this;t.currClin[e]=-1,$(document).on("click","#"+t.pre+e+"_prevclin",(function(t){let i=s.icn3d;t.stopImmediatePropagation();let n=void 0!==i.resi2disease_nonempty[e]?Object.keys(i.resi2disease_nonempty[e]).length:0;--i.currClin[e],i.currClin[e]<0&&(i.currClin[e]=n-1),s.showClinVarLabelOn3D(e)})),$(document).on("click","#"+t.pre+e+"_nextclin",(function(t){let i=s.icn3d;t.stopImmediatePropagation();let n=void 0!==i.resi2disease_nonempty[e]?Object.keys(i.resi2disease_nonempty[e]).length:0;++i.currClin[e],i.currClin[e]>n-1&&(i.currClin[e]=0),s.showClinVarLabelOn3D(e)}))}showClinVarLabelOn3D(e){let t,s,i=this.icn3d,n=i.icn3dui,l=Object.keys(i.resi2disease_nonempty[e]);t=e,s=t+"_"+(parseInt(l[i.currClin[e]])+i.baseResi[e]).toString();let r="",o=i.resi2disease_nonempty[e][l[i.currClin[e]]];for(let e=0,t=o.length;e0?o[0]:"N/A");let a=i.applyCenterCls.centerAtoms(n.hashUtilsCls.hash2Atoms(i.residues[s],i.atoms));r.length>30&&(r=r.substr(0,30)+"..."),i.selectionCls.removeSelection(),null==i.labels&&(i.labels={}),i.labels.clinvar=[];let d=i.LABELSIZE,c="black"!=i.opts.background?i.colorWhitebkgd:i.colorBlackbkgd;i.analysisCls.addLabel(r,a.center.x+1,a.center.y+1,a.center.z+1,d,c,void 0,"clinvar"),i.hAtoms={};for(let e in i.residues[s])i.hAtoms[e]=1;$("#clinvar_"+i.pre+s).addClass("icn3d-highlightSeq"),void 0===$("#"+i.pre+"modeswitch")[0]||$("#"+i.pre+"modeswitch")[0].checked||i.definedSetsCls.setMode("selection"),i.drawCls.draw()}getSnpLine(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g){let f=this.icn3d,b=f.icn3dui,C="",y=m?"clinvar":"snp",v=!1;for(let e in i){for(let t=0,s=i[e].length;t(from human)",i=" (based on human sequences and mapped to this structure by sequence similarity)"),C+=m?'":'"}else if(2==e&&m){let e=b.utilsCls.isMobile()?"none":"button";C+='
    ',C+='
    '}else C+='
    ';let w=y,_=0,S=0,A={},x={};for(let t=1,i=f.giSeq[h].length;t<=i;++t)if(void 0!==r[t]){++_;let i="";for(let n=0,r=s[t].length;n'+k+" Res":'',u)return C+"
    ";C+='';let O="",R=0,E=0;for(let t=1,a=f.giSeq[h].length;t<=a;++t)if(p){if(void 0!==r[t]){let e=f.giSeq[h][t-1],i=e;e.length>1&&(i=e[0]+"..");let n=f.ParserUtilsCls.getResi(h,t-1)+i+">";for(let e=0,i=s[t].length;e=0&&(C+='
     
    ',C+='
     
    ',R+=r,E+=1):r>0&&(C+='
     
    ',C+='
     
    ',R+=r,E+=1)}}else if(C+=f.showSeqCls.insertGap(h,t-1,"-"),void 0!==r[t])if(m||1!=e){let r=f.giSeq[h][t-1],a=r;r.length>1&&(a=r[0]+"..");let d,c=f.ParserUtilsCls.getResi(h,t-1),p="",u="
    ",y=s[t].length,v=0,_=0;if(2==e&&(v=0,_=y),m){d=1;let r=0;for(let e=v;e0?_+="; ":0!==e&&1!==e||(O='disease="'+v[t]+'"'),_+=v[t]+"("+w[t]+")",++S;""!=_&&(r"+s[t][e],u+=": "+_,C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(m,"snpin3d","3D with scap","SNP in 3D with scap",70,g)+"  ",u+=f.showAnnoCls.addSnpButton(m,"snpinter","Interactions","SNP Interactions in 3D",70,g)+"  ",u+=f.showAnnoCls.addSnpButton(m,"snppdb","PDB","Download SNP PDB",35,g)),u+="
    Links: ClinVar, dbSNP(rs"+i[t][e]+")",e
    "),++r)}r>d&&2==e&&(p+="..")}else{d=1;for(let e=v;e"+s[t][e],g)C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),0!=i[t][e]&&(u+="
    Link: dbSNP(rs"+i[t][e]+")"),e
    ");else{let s=l[t][e].split("; "),a=o[t][e].split("; "),d="",c=0;for(let t=0,i=s.length;t0?d+="; ":0!==e&&1!==e||(O='disease="'+s[t]+'"'),d+=s[t]+"("+a[t]+")",++c;""!=d?(u+=": "+d,C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),u+="
    Links: ClinVar, dbSNP(rs"+i[t][e]+")"):(C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),u+="
    Link: dbSNP(rs"+i[t][e]+")"),e
    ")}}y>d&&2==e&&(p+="..")}u+="
    ",m?"icn3d-clinvar"==A[t]||"icn3d-clinvar-path"==A[t]?C+=1==e?"":""==p||" "==p?"-":''+p+"":C+="-":C+=""==p||" "==p?"-":g?''+p+"":''+p+""}else C+="";else C+="-";return C+=1==e?' '+k+" Residues":'',C+="
    ",C+="
    ",C}processSnpClinvar(e,t,s,i,n){let l=this.icn3d,r=l.icn3dui,o='
    ',a=o,d=o,c='
    ',h=c,p=c,m=!i||n?e.data:e.split("\n"),u={},g={},f={};void 0===l.resi2disease_nonempty[t]&&(l.resi2disease_nonempty[t]={});let b={},C={},y={},v={},w={},_="";r.bNode&&(i?(l.resid2snp||(l.resid2snp={}),l.resid2snp[t]||(l.resid2snp[t]=[])):(l.resid2clinvar||(l.resid2clinvar={}),l.resid2clinvar[t]||(l.resid2clinvar[t]=[])));for(let e=0,s=m.length;e")+1),h=s[4],p=i?"":s[5],S=i?"":s[6],A=i?"":s[7],x=l.ParserUtilsCls.getResi(t,d-1);v[x]=1,""!=S&&(w[x]=1),g[d]=e+1,void 0===u[d]&&(u[d]=[]),u[d].push(c),void 0===C[d]&&(C[d]=[]),C[d].push(h),void 0===y[d]&&(y[d]=[]),y[d].push(p),void 0===f[d]&&(f[d]=[]),f[d].push(S),""!=S&&(void 0===l.resi2disease_nonempty[t][d]&&(l.resi2disease_nonempty[t][d]=[]),l.resi2disease_nonempty[t][d].push(S)),void 0===b[d]&&(b[d]=[]),b[d].push(A)}let S=Object.keys(v),A=Object.keys(w);if(i){let e=!1;o+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,void 0,i),o+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,void 0,i),d+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,!0,i),d+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,!0,i),a+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!0,e,void 0,i),o+="
    ",a+="
    ",d+="",$("#"+l.pre+"dt_snp_"+t).html(o),$("#"+l.pre+"ov_snp_"+t).html(a),$("#"+l.pre+"tt_snp_"+t).html(d)}else{let e=!0;c+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,void 0,i),c+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,void 0,i),p+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,!0,i),p+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,!0,i),h+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!0,e,void 0,i),c+="",h+="",p+="",$("#"+l.pre+"dt_clinvar_"+t).html(c),$("#"+l.pre+"ov_clinvar_"+t).html(h),$("#"+l.pre+"tt_clinvar_"+t).html(p),this.navClinVar(t,s)}l.showAnnoCls.enableHlSeq(),i?l.bAjaxSnp=!0:l.bAjaxClinvar=!0}async showClinvarPart2(e,t,s){let i=this.icn3d,n=i.icn3dui,l=this,r=n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainid_clinvar="+t;i.chainsGene[e]&&i.chainsGene[e].geneSymbol&&(r+="&gene="+i.chainsGene[e].geneSymbol);try{let s=await n.getAjaxPromise(r,"jsonp");if(s&&s.data&&s.data.length>0){let i=!1,n=s;l.processSnpClinvar(n,e,t,i)}else l.processNoClinvar(e)}catch(t){return void l.processNoClinvar(e)}}async showSnpPart2(e,t,s){let i=this.icn3d,n=i.icn3dui,l=this;if(void 0!==s){let s=n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainid_snp="+t;i.chainsGene[e]&&i.chainsGene[e].geneSymbol&&(s+="&gene="+i.chainsGene[e].geneSymbol);try{let i=await n.getAjaxPromise(s,"jsonp");if(i&&i.data&&i.data.length>0){let s=!0,n=!0;l.processSnpClinvar(i,e,t,s,n)}else l.processNoSnp(e)}catch(t){return void l.processNoSnp(e)}}else this.processNoSnp(e),console.log("No gi was found for the chain "+t+"...")}processNoClinvar(e){let t=this.icn3d;t.icn3dui,console.log("No ClinVar data were found for the protein "+e+"..."),$("#"+t.pre+"dt_clinvar_"+e).html(""),$("#"+t.pre+"ov_clinvar_"+e).html(""),t.showAnnoCls.enableHlSeq(),t.bAjaxClinvar=!0}processNoSnp(e){let t=this.icn3d;t.icn3dui,console.log("No SNP data were found for the protein "+e+"..."),$("#"+t.pre+"dt_snp_"+e).html(""),$("#"+t.pre+"ov_snp_"+e).html(""),t.showAnnoCls.enableHlSeq(),t.bAjaxSnp=!0}}class xt{constructor(e){this.icn3d=e}showSsbond(e,t){let s=this.icn3d;s.icn3dui;let i=this;void 0===s.ssbondpnts?setTimeout((function(){i.showSsbond_base(e,t)}),1e3):this.showSsbond_base(e,t)}showSsbond_base(e,t){let s=this.icn3d;s.icn3dui.bNode&&(s.resid2ssbond||(s.resid2ssbond={}),s.resid2ssbond[e]||(s.resid2ssbond[e]=[]));let i=t,n={},l=i.substr(0,i.indexOf("_")),r=s.ssbondpnts[l];if(void 0===r)return $("#"+s.pre+"dt_ssbond_"+e).html(""),$("#"+s.pre+"ov_ssbond_"+e).html(""),void $("#"+s.pre+"tt_ssbond_"+e).html("");for(let e=0,t=r.length;e-s.halfBilayerSize){i[t.structure+"_"+t.chain+"_"+t.resi]=1}}let n=Object.keys(i);s.annoCddSiteCls.showAnnoType(e,t,"transmem","Transmembrane",n)}}class Ot{constructor(e){this.icn3d=e,this.dcut=7,this.MAX_SSE=512,this.ctc_cnt=[];for(let e=0;e=this.curr_ratio+.01||f>this.split_ratio)return e;if(f>this.curr_ratio-.01&&Math.min(m,u)=0&&l[i]==t-e+i;i--);if(i<0)break;for(l[i]++,s=i+1;s-1;i++);for(l=Math.min(i-1,this.max_csz),this.curr_ne0=this.curr_ne1=0,this.curr_ratio=100,s=1;s<=l;s++)this.cut_size(s,i);if(this.top--,0==this.curr_ne0){for(n=this.stack[this.top],e=n;e-1;e++)this.parts[this.np++]=this.elements[e];this.parts[this.np++]=-1,this.n_doms++}else{if(this.save_ratios[this.saved++]=this.curr_ratio,this.curr_ne0>this.min_sse){for(n=this.stack[this.top],e=0;ethis.min_sse){for(n=this.stack[this.top],e=0;e0;)this.process_set()}output(e){let t,s;this.icn3d.icn3dui;let i=[];for(t=0;t<2*e;t++)i.push(0);for(t=s=0;st+n)break;let p=(t-a)*(t-a);p+=(s-c)*(s-c),p+=(i-h)*(i-h);let m=Math.sqrt(p);if(m>n)continue;let u={},g={};parseInt(e.rnum)this.MAX_SSE)return{subdomains:a,substruct:o};let g=h.length,f=r[g-1],b=this.c2b_AlphaContacts(g,i,n,l,t,r),C=[];for(let e=0;e0&&this.elt_size[s.sse-1]>=6&&0!=s.adj_strand2&&e++}for(let e=0;e0)for(let e=0;e0){let e=0;for(let t=0;t<=E;t++){let t=[];for(;e<2*u;){let s=this.parts[e++];if(0==s){I.push(t);break}t.push(s)}}}I.sort((function(e,t){return e[0]-t[0]}));for(let e=0,t=I.length;e=o.length)return{subdomains:a,substruct:o};let n=o[i],l=n.From,r=n.To;for(let e=l;e<=r;e++)s[e]=1;if(0==i&&l>1)for(let e=1;e0){let e=o[i-1].To,t=parseInt(.5*(l-e-1));if(t>0)for(let e=l-t;e<=l-1;e++)s[e]=1}if(i0)for(let e=r+1;e<=r+t;e++)s[e]=1}}let i,n=!1,l=[];for(let e=0;e0&&(d+=", "),d+='{"ss": [';let i=0;for(let s=0,r=n[e].length;s=r&&c<=o&&(i>0&&(d+=", "),d+="["+s+","+n+","+c+","+l[e].x1.toFixed(2)+","+l[e].y1.toFixed(2)+","+l[e].z1.toFixed(2)+","+l[e].x2.toFixed(2)+","+l[e].y2.toFixed(2)+","+l[e].z2.toFixed(2)+"]",++i))}}d+="]",d+=', "domain": [';let r=0;for(let i=0,l=n[e].length;i=l&&n<=a&&(r>0&&(d+=", "),d+="["+n+","+h+","+c.coord.x.toFixed(2)+","+c.coord.y.toFixed(2)+","+c.coord.z.toFixed(2)+"]",++r)}}d+="]}"}return d+="]}",d}}class Rt{constructor(e){this.icn3d=e}clickAddTrackButton(){let e=this.icn3d,t=e.icn3dui,s=this;t.myEventCls.onIds("#"+e.pre+"addtrack_button1","click",(async function(e){let i=s.icn3d;e.stopImmediatePropagation(),dialog.dialog("close");let n=$("#"+i.pre+"track_chainid").val(),l=$("#"+i.pre+"track_gi").val(),r=isNaN(l)?"Acc "+l:"gi "+l,o=t.htmlCls.baseUrl+"pwaln/pwaln.fcgi?from=track",a={targets:n,queries:l},d=await t.getAjaxPostPromise(o,a);s.alignSequenceToStructure(n,d,r)})),t.myEventCls.onIds("#"+e.pre+"addtrack_button2","click",(async function(e){let i=s.icn3d;e.stopImmediatePropagation(),dialog.dialog("close");let n=$("#"+i.pre+"track_chainid").val(),l=$("#"+i.pre+"track_fasta").val(),r=$("#"+i.pre+"fasta_title").val(),o=n.substr(0,n.indexOf("_")),a=n;if(5==o.length)a=a.substr(0,4);else if(o.length>5){a="";for(let e=0,t=i.chainsSeq[n].length;e"),a=o[1].indexOf("\n");o[1].substr(0,a);let d,c=o[1].substr(a+1).replace(/\n/g,""),h=[],p=[];for(let e=2,t=o.length;e0&&(u=f,i.targetGapHash[m+d]={from:m+d,to:u+C-1+d}),g=c[e],f=b,"-"!=c[e]?(++b,w=e,y||(v=e,y=!0)):++C;await i.annotationCls.resetAnnoAll();let _="",S=0;for(let e in i.targetGapHash)S>0&&(_+=" "),_+=e+"_"+i.targetGapHash[e].from+"_"+i.targetGapHash[e].to,++S;t.htmlCls.clickMenuCls.setLogCmd("msa | "+_,!0);let A={};for(let e=0,o=p.length;e0){void 0===i.queryresi2score&&(i.queryresi2score={}),void 0===i.queryresi2score[n]&&(i.queryresi2score[n]={});let e=p.length;for(let t in A){let s=parseInt(A[t]/e*100);i.queryresi2score[n][t]=s}let s=Object.keys(A),l=Math.min.apply(null,s),r=Math.max.apply(null,s),o="";for(let t=l;t<=r;++t)A.hasOwnProperty(t)?o+=Math.round(A[t]/e*9):o+="_";i.opts.color="align custom",i.setColorCls.setColorByOptions(i.opts,i.hAtoms),i.hlUpdateCls.updateHlAll(),i.drawCls.draw(),t.htmlCls.clickMenuCls.setLogCmd("color align custom | "+n+" | range "+l+"_"+r+" | "+o,!0)}})),t.myEventCls.onIds("#"+e.pre+"addtrack_button3","click",(function(e){let i=s.icn3d;e.stopImmediatePropagation(),dialog.dialog("close");let n=$("#"+i.pre+"track_chainid").val(),l=$("#"+i.pre+"track_bed")[0].files[0];if(l){window.File&&window.FileReader&&window.FileList&&window.Blob||alert("The File APIs are not fully supported in this browser.");let e=new FileReader;e.onload=function(e){let l,r=e.target.result.split("\n"),o=!1,a=!1;for(let e=0,d=r.length;e8||d.length<6)&&(a=!1),d.length<9&&(o=!1),d[0];let c,h,p=d[1],m=d[2],u=d[3];d.length,d.length>5&&(c=d[5]),d.length,d.length,d.length>8&&(h=d[8]),d.length,d.length,d.length;let g=u,f="51,51,51";o?f=h:a&&("+"==c&&l.length>0?f=l[0]:"-"==c&&l.length>1?f=l[1]:"."==c&&l.length>2&&(f=l[2]));let b="",C=[];for(let e=0,t=m;e1&&(s=t[0]);let l=i.ParserUtilsCls.getResi(n,e);if(a.hasOwnProperty(n+"_"+l)){let e=i.firstAtomObjCls.getFirstCalphaAtomObj(i.residues[n+"_"+l]),t=void 0===e.color||"FFFFFF"===e.color.getHexString().toUpperCase()?"DDDDDD":e.color.getHexString(),o=void 0!==e.color?t:"CCCCCC";r+=s,d.push("#"+o)}else r+="-",d.push("")}s.showNewTrack(n,l,r,d,void 0,"selection",void 0),t.htmlCls.clickMenuCls.setLogCmd("add track | chainid "+n+" | title "+l+" | text "+s.simplifyText(r)+" | type selection",!0)}))}showNewTrack(e,t,s,i,n,l,r,o,a,d){let c=this.icn3d,h=c.icn3dui,p=!1;"cannot be aligned"==s&&(p=!0);let m=s.replace(/-/g,"").length;if(!o)if(s.length>c.giSeq[e].length)s=s.substr(0,c.giSeq[e].length);else if(s.length20&&(u=u.substr(0,20));let g=h.htmlCls.RESIDUE_WIDTH*s.length+200;$("#"+c.pre+"dt_custom_"+e).append("
    "),$("#"+c.pre+"dt_custom_"+e+"_"+u).width(g),$("#"+c.pre+"ov_custom_"+e).append("
    "),$("#"+c.pre+"ov_custom_"+e+"_"+u).width(g),$("#"+c.pre+"tt_custom_"+e).append("
    "),$("#"+c.pre+"tt_custom_"+e+"_"+u).width(g);let f='
    ',b=f,C=f,y=parseInt(10*Math.random()),v='",w=''+m.toString()+" Pos";C+=v+w+"
    ";let _='';f+=v+w+_,b+=v+w+_;let S=e.indexOf("_"),A="cst"+e.substr(S+1),x=0,k=0,O=(void 0===l||"seq"===l||"custom"===l)&&-1==s.indexOf("cannot-be-aligned")&&-1==s.indexOf("cannot be aligned"),R="identity"===l&&-1==s.indexOf("cannot-be-aligned")&&-1==s.indexOf("cannot be aligned"),E={},I=0,T=1;v="";for(let t=0,a=s.length;t"+d+"",v+=c.showSeqCls.insertGapOverview(e,t);let g=h.cfg.blast_rep_id==e?Math.round(c.seqAnnWidth*t/(c.maxAnnoLength+c.nTotalGap)-x-k):Math.round(c.seqAnnWidth*t/c.maxAnnoLength-x-k);g<0&&(g=0),v+='
     
    ',s=void 0!==i&&""!=i[t]?i[t]:r?"rgb("+r+")":O?"#"+p:"#333",v+='
     
    ',x+=g,k+=1,++T}else f+=p?""+d+"":"-"}if(void 0!==a){v="";let s=[],i=[];for(let e=0,t=a.length;e 
    ',v+='"}}_=''+m.toString()+" Pos",_+="",_+="
    ",_+="",f+=_,b+=v+_,C+="",$("#"+c.pre+"dt_custom_"+e+"_"+u).html(f),$("#"+c.pre+"ov_custom_"+e+"_"+u).html(b),$("#"+c.pre+"tt_custom_"+e+"_"+u).html(C)}alignSequenceToStructure(e,t,s){let i,n,l,r=this.icn3d,o=r.icn3dui;void 0!==t.data&&(i=t.data[0].query,l=Object.keys(t.data[0].targets)[0],n=t.data[0].targets[l],n=n.hsps[0]);let a="",d=[],c={};if(void 0!==i&&void 0!==n){let h=n.scores.e_value.toPrecision(2);h>1e-200&&(h=parseFloat(h).toExponential()),n.scores.bit_score;let p=t.targets[l].seqdata,m=i.seqdata,u=n.segs;for(let e=0,t=u.length;e0&&(l=n+"H"+d+")","coil"==t&&(s.selectionCls.selectResidueList(r,l,l,o,a),o||(o=!0)),r={})),n=e+"_H"+d,r[p]=1,i.ssend&&(h=e+"_C(H"+d,"helix"==t&&(s.selectionCls.selectResidueList(r,n,n,o,a),o||(o=!0)),r={})):"E"==m?(i.ssbegin&&(++c,Object.keys(r).length>0&&(l=n+"S"+c+")","coil"==t&&(s.selectionCls.selectResidueList(r,l,l,o,a),o||(o=!0)),r={})),n=e+"_S"+c,r[p]=1,i.ssend&&(h=e+"_C(S"+c,"sheet"==t&&(s.selectionCls.selectResidueList(r,n,n,o,a),o||(o=!0)),r={})):(n=h+"-",r[p]=1)}}Object.keys(r).length>0&&(l=n+"Cterm)","coil"==t&&s.selectionCls.selectResidueList(r,l,l,o,a))}simplifyText(e){this.icn3d.icn3dui;let t,s,i="",n=!1,l=-1;for(t=0,s=(e=e.replace(/undefined/g," ")).length;t20)return!1;if(void 0!==o.giSeq&&void 0!==o.giSeq[e]){let r=this.getFullText(s);return s=r.text,this.showNewTrack(e,t,s,void 0,void 0,i,n,l),!1}setTimeout((function(){a.checkGiSeq(e,t,s,i,n,l,r+1)}),100)}getFullText(e){this.icn3d.icn3dui;let t="",s=[],i=[],n=e.split(","),l=-1;for(let e=0,r=n.length;ep?t+=c.substr(0,p):t+=c;for(let e=0;e0&&($("#"+e.pre+"anno_cdd")[0].checked?(this.setAnnoTabCdd(),t.htmlCls.clickMenuCls.setLogCmd("set annotation cdd",!0)):(this.hideAnnoTabCdd(),t.htmlCls.clickMenuCls.setLogCmd("hide annotation cdd",!0)))}showAnnoSelectedChains(){let e=this.icn3d,t=e.icn3dui,s={};for(let t in e.hAtoms){let i=e.atoms[t];s[i.structure+"_"+i.chain]=1}$("#"+e.pre+"dl_annotations > .icn3d-annotation").hide();for(let i in s){$("#"+e.pre+"anno_"+i).length&&$("#"+e.pre+"anno_"+i).show();let s=e.firstAtomObjCls.getFirstCalphaAtomObj(e.chains[i]);if(void 0!==s.resn){let i=t.utilsCls.residueName2Abbr(s.resn.substr(0,3));$("#"+e.pre+"anno_"+i).show()}}}showAnnoAllChains(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"dl_annotations > .icn3d-annotation").show()}setAnnoView(e){let t=this.icn3d;t.icn3dui.bNode||("detailed view"===e?(t.view="detailed view",$("#"+t.pre+"dl_anno_view_tabs").tabs("option","active",1)):(t.view="overview",$("#"+t.pre+"dl_anno_view_tabs").tabs("option","active",0)))}setAnnoDisplay(e,t){let s=this.icn3d;s.icn3dui;let i=["giseq","custom","site","ptm","snp","clinvar","cdd","domain","interaction","ssbond","crosslink","transmem"];for(let n in i){let l=i[n];$("[id^="+s.pre+t+"_"+l+"]").attr("style",e)}}showFixedTitle(){this.icn3d.icn3dui;this.setAnnoDisplay("display:block;","tt")}hideFixedTitle(){this.icn3d.icn3dui;this.setAnnoDisplay("display:none!important;","tt")}setAnnoViewAndDisplay(e){let t=this.icn3d;if(t.icn3dui,"detailed view"===e){this.setAnnoView("detailed view");let e="display:block;";this.setAnnoDisplay(e,"dt"),$("#"+t.pre+"seqguide_wrapper").attr("style",e),e="display:none;",this.setAnnoDisplay(e,"ov")}else{this.setAnnoView("overview"),this.hideFixedTitle();let e="display:none;";this.setAnnoDisplay(e,"dt"),$("#"+t.pre+"seqguide_wrapper").attr("style",e),e="display:block;",this.setAnnoDisplay(e,"ov")}}async updateClinvar(){let e=this.icn3d;if(e.icn3dui,void 0===e.bClinvarShown||!e.bClinvarShown)for(let t in e.protein_chainid){let s=e.protein_chainid[t];await e.annoSnpClinVarCls.showClinvar(t,s)}e.bClinvarShown=!0}async updateSnp(){let e=this.icn3d;if(e.icn3dui,void 0===e.bSnpShown||!e.bSnpShown)for(let t in e.protein_chainid){let s=e.protein_chainid[t];await e.annoSnpClinVarCls.showSnp(t,s)}e.bSnpShown=!0}updateDomain(){let e=this.icn3d;e.icn3dui,void 0!==e.bDomainShown&&e.bDomainShown||e.annoDomainCls.showDomainAll(),e.bDomainShown=!0}updateInteraction(){let e=this.icn3d;if(e.icn3dui,void 0===e.bInteractionShown||!e.bInteractionShown)for(let t in e.interactChainbase){let s=e.interactChainbase[t];e.annoContactCls.showInteraction(t,s)}e.bInteractionShown=!0}async updatePTM(){let e=this.icn3d;if(e.icn3dui,void 0===e.bPTMShown||!e.bPTMShown)for(let t in e.PTMChainbase){let s=e.PTMChainbase[t];await e.annoPTMCls.showPTM(t,s,"ptm")}e.bPTMShown=!0}updateSsbond(){let e=this.icn3d;if(e.icn3dui,void 0===e.bSSbondShown||!e.bSSbondShown)for(let t in e.ssbondChainbase){let s=e.ssbondChainbase[t];e.annoSsbondCls.showSsbond(t,s)}e.bSSbondShown=!0}updateCrosslink(){let e=this.icn3d;if(e.icn3dui,void 0===e.bCrosslinkShown||!e.bCrosslinkShown)for(let t in e.crosslinkChainbase){let s=e.crosslinkChainbase[t];e.annoCrossLinkCls.showCrosslink(t,s)}e.bCrosslinkShown=!0}async updateTransmem(){let e=this.icn3d,t=e.icn3dui;if(void 0===e.bTranememShown||!e.bTranememShown)for(let s in e.protein_chainid){let i=e.protein_chainid[s];if(void 0!==t.cfg.opmid)e.annoTransMemCls.showTransmem(s,i);else if(e.bAfMem&&e.afmem_start_end){let t=e.afmem_start_end[0],n=e.afmem_start_end[1];await e.annoPTMCls.showPTM(s,i,"afmem",t,n)}else await e.annoPTMCls.showPTM(s,i,"transmem")}e.bTranememShown=!0}}class It{constructor(e){this.icn3d=e}showAnnotations_part1(){let e=this.icn3d,t=e.icn3dui;if(t.htmlCls.dialogCls.openDlg("dl_selectannotations","Sequences and Annotations"),(void 0===e.bAssemblyNote||!e.bAssemblyNote)&&void 0!==e.asuCnt){let t="
    Assembly Tips: Only the asymmetric unit is shown in the sequence window.
    Click \"Assembly\" in the menu \"View\" to switch between asymmetric unit and biological assembly("+e.asuCnt+" asymmetric unit).
    ";$("#"+e.pre+"dl_annotations_tabs").append(t),e.bAssemblyNote=!0}e.bResetAnno&&(e.giSeq={},e.currClin={},e.resi2disease_nonempty={},e.baseResi={},e.matchedPos={},$("#"+t.pre+"dl_annotations").empty(),e.annotationCls.setAnnoView("overview"));let s={},i={},n={};if(void 0===e.bAnnoShown||!e.bAnnoShown||e.bResetAnno){e.protein_chainid={};let l,r=Object.keys(e.chains);void 0===e.giSeq&&(e.giSeq={}),void 0===e.currClin&&(e.currClin={}),void 0===e.resi2disease_nonempty&&(e.resi2disease_nonempty={}),void 0===e.baseResi&&(e.baseResi={}),void 0===e.matchedPos&&(e.matchedPos={}),l=t.bNode?500:t.cfg.notebook?t.htmlCls.WIDTH/2:$("#"+e.pre+"dl_selectannotations").dialog("option","width"),e.seqAnnWidth=l-120-60-50;for(let l=0,o=r.length;l1)e.protein_chainid[r[l]]=a;else if(e.nucleotides.hasOwnProperty(o.serial)&&e.chainsSeq[r[l]].length>1)s[r[l]]=a;else if(e.chainsSeq[r[l]].length>1)i[r[l]]=a;else{let t=e.chainsSeq[r[l]][0].name,s=r[l]+"_"+e.chainsSeq[r[l]][0].resi;void 0===n[t]&&(n[t]=[]),n[t].push(s)}if((void 0!==t.cfg.pdbid||void 0!==t.cfg.opmid||void 0!==t.cfg.mmcifid||void 0!==t.cfg.mmtfid)&&(e.proteins.hasOwnProperty(o.serial)||e.nucleotides.hasOwnProperty(o.serial)))for(let t=0,s=e.chainsSeq[r[l]].length;te.maxAnnoLength&&(e.protein_chainid.hasOwnProperty(t)||s.hasOwnProperty(t))&&(e.maxAnnoLength=e.chainsSeq[t].length)}return{nucleotide_chainid:s,chemical_chainid:i,chemical_set:n}}async showAnnotations(){let e=this.icn3d,t=e.icn3dui,s=this,i=this.showAnnotations_part1(),n=i.nucleotide_chainid,l=i.chemical_chainid,r=i.chemical_set;if(void 0===e.bAnnoShown||!e.bAnnoShown||e.bResetAnno)if(void 0===t.cfg.blast_rep_id){if(e.bFullUi){if(void 0!==t.cfg.mmtfid){let t=Object.keys(e.structures)[0];await e.mmcifParserCls.downloadMmcifSymmetry(t,"mmtfid")}await this.showAnnoSeqData(n,l,r)}}else if(void 0===t.cfg.blast_rep_id||e.bSmithwm||e.bLocalSmithwm){if(void 0!==t.cfg.blast_rep_id&&(e.bSmithwm||e.bLocalSmithwm)){let i,o,a=[t.cfg.blast_rep_id];if(-1!=t.cfg.query_id.indexOf(">")?o=t.cfg.query_id.substr(t.cfg.query_id.indexOf("\n")+1):!/\d/.test(t.cfg.query_id)||t.cfg.query_id.length>50?o=t.cfg.query_id:a.push(t.cfg.query_id),e.blastAcxn){let s=t.cfg.afid+"_A",n="";for(let t=0,i=e.chainsSeq[s].length;tProteins:

    ":"",a=e.chainsGene[s]&&e.chainsGene[s].geneId?"(Gene: "+e.chainsGene[s].geneSymbol+")":"",d=s.substr(0,s.indexOf("_")),c=d.length>5?''+s+"":s,h="
    "+o+"Annotations of "+c+": "+r+""+a+"   "+this.addButton(s,"icn3d-addtrack","Add Track","Add a custom track",60,i)+"   ";h+=this.addButton(s,"icn3d-customcolor","Custom Color/Tube","Use a custom file to define the colors or tubes in 3D structure",110,i)+"   ",h+=this.addButton(s,"icn3d-helixsets","Helix Sets",'Define sets for each helix in this chain and add them to the menu of "Defined Sets"',60,i)+" "+this.addButton(s,"icn3d-sheetsets","Sheet Sets",'Define sets for each sheet in this chain and add them to the menu of "Defined Sets"',60,i)+" "+this.addButton(s,"icn3d-coilsets","Coil Sets",'Define sets for each coil in this chain and add them to the menu of "Defined Sets"',60,i),$("#"+e.pre+"dl_annotations").append(h);let p=["giseq","cdd","clinvar","snp","site","ptm","ssbond","crosslink","transmem","domain","custom","interaction"];for(let t in p){let i=p[t];$("#"+e.pre+"anno_"+s).append(this.getAnDiv(s,i))}$("#"+e.pre+"anno_"+s).append("


    "),++n}if(t.bNode||e.annoCddSiteCls.setToolTip(),void 0!==e.chainid_seq)await this.processSeqData(e.chainid_seq);else try{let n=[],l=[];for(let e=0,t=i.length;e=6?l.push(i[e]):n.push(i[e]);if(n.length>0){let s=t.htmlCls.baseUrl+"/vastdyn/vastdyn.cgi?chainlist="+n;e.chainid_seq=await t.getAjaxPromise(s,"jsonp")}else e.chainid_seq={};for(let t=0,s=l.length;t40&&(r=r.substr(0,40)+"...");let o="";0==i&&("protein"==s?o="Proteins:

    ":"nucleotide"==s?o="Nucleotides:

    ":"chemical"==s&&(o="Chemicals/Ions/Water:

    ")),$("#"+n.pre+"dl_annotations").append("
    "+o+""+e+": "+r+"
    "),$("#"+n.pre+"anno_"+e).append(this.getAnDiv(e,"giseq")),$("#"+n.pre+"anno_"+e).append(this.getAnDiv(e,"interaction")),$("#"+n.pre+"anno_"+e).append("


    "),n.giSeq[e]=[];for(let t=0;tChemicals/Ions/Water:

    ":"",o=t[0].lastIndexOf("_"),a=t[0].substr(0,o),d=void 0!==l.cfg.mmdbid&&void 0!==n.chainid2sid?n.chainid2sid[a]:void 0;i=void 0!==d?""+e+" ":""+e+"",$("#"+n.pre+"dl_annotations").append("
    "+r+i+"
    "),$("#"+n.pre+"anno_"+e).append("
    "),$("#"+n.pre+"anno_"+e).append("


    ");let c='
    ';c+='",c+='Count: '+t.length+"",c+='';let h=c,p=c;for(let s=0,i=t.length;s3&&(l=i.substr(0,3)),s'+l+""}let m=l.htmlCls.GREY8,u=Math.round(n.seqAnnWidth*t.length/n.maxAnnoLength);u<1&&(u=1),p+='
     
    ',c="",c+="
    ",c+="
    ",h+=c,p+=c,$("#"+n.pre+"dt_giseq_"+e).html(h),$("#"+n.pre+"ov_giseq_"+e).html(p)}async processSeqData(e){let t=this.icn3d,s=t.icn3dui;for(let i in t.protein_chainid){let n=t.protein_chainid[i];if(e.hasOwnProperty(n)){let s=e[n];t.giSeq[i]=s;let l="";for(let e=0;e<10&&e14?"Query: "+o.substr(0,6)+"...":isNaN(s.cfg.query_id)?"Query: "+o:"Query: gi "+o;let a="cannot be aligned";t.queryStart="",t.queryEnd="",t.bRender&&alert("The sequence can NOT be aligned to the structure"),t.showSeqCls.showSeq(i,n,void 0,e,l,a,r)}else if(s.cfg.blast_rep_id==i&&(void 0!==t.seqStructAlignData||void 0!==t.seqStructAlignDataSmithwm)){let e,l,r,o,a,d=s.cfg.oriQuery_id?s.cfg.oriQuery_id:s.cfg.query_id;if(e=d.length>14?"Query: "+d.substr(0,6)+"...":isNaN(s.cfg.query_id)?"Query: "+d:"Query: gi "+d,void 0!==t.seqStructAlignData){let e,s,i=t.seqStructAlignData;if(void 0!==i.data){e=i.data[0].query;let t=Object.keys(i.data[0].targets);s=i.data[0].targets[t[0]],s=void 0!==s&&s.hsps.length>0?s.hsps[0]:void 0}if(void 0!==e&&void 0!==s){l=s.scores.e_value.toPrecision(2),l>1e-200&&(l=parseFloat(l).toExponential()),s.scores.bit_score;let t=Object.keys(i.targets);r=i.targets[t[0]].seqdata,o=e.seqdata,a=s.segs}}else{let e=t.seqStructAlignDataSmithwm;l=e.score,r=e.target.replace(/-/g,""),o=e.query.replace(/-/g,""),a=[];let s=-1,i=-1,n=!1,d={};for(let t=0,l=e.target.length;t0)if(i.orifrom-ni.from-l)for(let t=n+1;t
    "+i+"
    "}addButton(e,t,s,i,n,l){return this.icn3d.icn3dui,"
    "}addSnpButton(e,t,s,i,n,l){let r=this.icn3d;return r.icn3dui,"
    "}conservativeReplacement(e,t){let s=this.icn3d.icn3dui,i=-1!==s.parasCls.b62ResArray.indexOf(e)?s.parasCls.b62ResArray.indexOf(e):s.parasCls.b62ResArray.length-1,n=-1!==s.parasCls.b62ResArray.indexOf(t)?s.parasCls.b62ResArray.indexOf(t):s.parasCls.b62ResArray.length-1;return s.parasCls.b62Matrix[i][n]>0}getColorhexFromBlosum62(e,t){let s=this.icn3d.icn3dui;e=e.toUpperCase(),t=t.toUpperCase();let i=-1!==s.parasCls.b62ResArray.indexOf(e)?s.parasCls.b62ResArray.indexOf(e):s.parasCls.b62ResArray.length-1,n=-1!==s.parasCls.b62ResArray.indexOf(t)?s.parasCls.b62ResArray.indexOf(t):s.parasCls.b62ResArray.length-1,l=s.parasCls.b62Matrix[i][n];if(void 0===l)return"333333";let r="333333";if(l>0){let e=221-parseInt(l/11*221),t=e<10?"0"+e.toString(16):e.toString(16);r="DD"+t+t}else{let e=221-parseInt(-1*l/4*221),t=e<10?"0"+e.toString(16):e.toString(16);r=t+t+"DD"}return r}}class Tt{constructor(e){this.icn3d=e}showSeq(e,t,s,i,n,l,r){let o,a=this.icn3d,d=a.icn3dui,c=!1;if(void 0===d.cfg.mmdbid&&void 0===d.cfg.gi&&void 0===d.cfg.blast_rep_id&&void 0===d.cfg.align&&void 0===d.cfg.chainalign&&void 0===d.cfg.mmdbafid){c=!0,o=[];for(let t=0;t10){u='
    ';let t=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]);void 0===d.cfg.mmdbid&&void 0===d.cfg.gi&&void 0===d.cfg.blast_rep_id&&void 0===d.cfg.align&&void 0===d.cfg.chainalign&&void 0===d.cfg.mmdbafid||void 0===t.resi_ori||t.resi_ori==t.resi||-1!=e.indexOf("Misc")?u+='
    ':u+='
    NCBI Residue Numbers
    ',u+='',b+=u+"
    ",g+=u+'';let s=0,i=0,n="";for(let t=0,l=o.length;t",l%10==0&&(g+=l);let r=e+"_"+l,o=l%10!=0&&l%10!=1&&l%10!=9;if(a.residues.hasOwnProperty(r)){let e=a.firstAtomObjCls.getFirstCalphaAtomObj(a.residues[r]);"H"==a.secondaries[r]&&e.ssbegin?(++s,n='H'+s+"",o&&(g+=n,n="")):"E"==a.secondaries[r]&&e.ssbegin?(++i,"green"==a.sheetcolor?n='S'+i+"":"yellow"==a.sheetcolor&&(n='S'+i+""),o&&(g+=n,n="")):e.ssend&&(n=""),""!=n&&o&&(g+=n,n="")}g+=""}g+='',g+="",g+="
    ",g+="
    ",b+=""}u='
    ',u+='
    ',u+='',b+=u+"
    ",g+=u+'';for(let t=0,s=o.length;t':'',g+=" ";else if("E"==a.secondaries[s]){a.firstAtomObjCls.getFirstCalphaAtomObj(a.residues[s]).ssend?"green"==a.sheetcolor?g+='':"yellow"==a.sheetcolor&&(g+=''):"green"==a.sheetcolor?g+='':"yellow"==a.sheetcolor&&(g+=''),g+=" "}else"c"==a.secondaries[s]?g+=' ':"o"==a.secondaries[s]&&(g+=' ');else g+="-"}g+='',g+="",g+="
    ",g+="
    ",g+="",b+="",u=d.cfg.blast_rep_id===e?'
    ':'
    ';let C="Protein",y="Protein";void 0!==s&&("nucleotide"==s?(C="Nucl.",y="Nucleotide"):"chemical"==s&&(C="Chem.",y="Chemical")),u+='",u+=''+(a.baseResi[e]+1).toString()+"",b+=u+"
    ";let v='';g+=u+v,f+=u+v;let w,_=0;for(let t=0,s=o.length;t1&&(i=s[0]+".."),w=a.ParserUtilsCls.getResi(e,t),a.residues.hasOwnProperty(e+"_"+w)){let n="333333";if(d.cfg.blast_rep_id==e&&void 0!==a.fullpos2ConsTargetpos&&void 0!==a.fullpos2ConsTargetpos[t+_])n=a.fullpos2ConsTargetpos[t+_].color;else{let t=a.firstAtomObjCls.getFirstCalphaAtomObj(a.residues[e+"_"+w]),s=void 0===t.color||"FFFFFF"===t.color.getHexString()?"DDDDDD":t.color.getHexString();n=void 0!==t.color?s:"CCCCCC"}g+=''+i+""}else i=i.toLowerCase(),g+=''+i+""}d.cfg.blast_rep_id==e&&(a.opts.color=a.blastAcxn?"confidence":"conservation",a.setColorCls.setColorByOptions(a.opts,a.atoms));let S=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]),A=S.color?S.color.getHexString():"CCCCCC",x=Math.round(a.seqAnnWidth*o.length/a.maxAnnoLength);if(x<1&&(x=1),d.cfg.blast_rep_id!=e)f+='";else{let t=[],s=[];t.push(0);for(let e=0,i=o.length;e';for(let i=0,n=t.length;i'+e+"
    ";f+="
    "}if(u=''+w+"",u+="",u+="
    ",g+=u,f+=u,d.cfg.blast_rep_id==e){if(void 0!==r&&""!==r){u='",u+='',b+=u+"
    ";let t='';g+=u+t,f+=u+t;let s=0,i=0,l=1;a.queryStart;for(let t=0,n=r.length;t-";else if(" "==n)g+=" ";else{let r=a.fullpos2ConsTargetpos[t].pos;if(a.residues.hasOwnProperty(e+"_"+r)){let s=a.fullpos2ConsTargetpos[t].color;g+=''+n+""}else n=n.toLowerCase(),g+=''+n+"";f+=this.insertGapOverview(e,t);let o=Math.round(a.seqAnnWidth*t/(a.maxAnnoLength+a.nTotalGap)-s-i);o>=0&&(f+='
     
    ',f+='
     
    ',s+=o,i+=l)}}u='',u+="",u+="
    ",g+=u,f+=u}u='
    '+i+"
    ",u+=''+a.queryStart+"",b+=u+"
    ";let t='';g+=u+t,f+=u+t;let s=a.queryStart;for(let t=0,i=l.length;t-":(void 0===a.fullpos2ConsTargetpos||void 0===a.fullpos2ConsTargetpos[t]||a.residues.hasOwnProperty(e+"_"+a.fullpos2ConsTargetpos[t].pos)||(i=i.toLowerCase()),g+=''+i+"",++s)}let o=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]),d=void 0===o.color||"FFFFFF"===o.color.getHexString()?"DDDDDD":o.color.getHexString(),c=void 0!==o.color?d:"CCCCCC",h=[],p=[],m="-";for(let e=0,t=l.length;e ',f+='
    '+i+"
    "}u=''+a.queryEnd+"",u+="",u+="
    ",g+=u,f+=u}if(g+="",f+="",b+="",a.giSeq[e].length>10){let t=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]);if(void 0===d.cfg.mmdbid&&void 0===d.cfg.gi&&void 0===d.cfg.blast_rep_id&&void 0===d.cfg.align&&void 0===d.cfg.chainalign&&void 0===d.cfg.mmdbafid||void 0===t.resi_ori||t.resi_ori==t.resi||-1!=e.indexOf("Misc")){if(a.bShowRefnum&&a.chainid2index.hasOwnProperty(e)){let t=this.showRefNum(o,e);g+=t.html,b+=t.html3;let s=1;t=this.showRefNum(o,e,s),g+=t.html,b+=t.html3,s=2,t=this.showRefNum(o,e,s),g+=t.html,b+=t.html3}else if(a.bShowCustomRefnum&&a.chainsMapping.hasOwnProperty(e)){let t=!0,s=this.showRefNum(o,e,void 0,t);g+=s.html,b+=s.html3}}else{u='
    ',u+='
    ',u+='
    PDB Residue Numbers
    ',u+='',b+=u+"
    ",g+=u+'';for(let t=0,s=o.length;t",e%10==0&&(g+=e+" "),g+=""}else g+=""}g+='',g+="",g+="
    ",g+="
    ",g+="
    ",b+=""}}a.bShowRefnum&&(a.hAtoms=a.hAtomsRefnum,a.hlUpdateCls.updateHlAll()),$("#"+a.pre+"dt_giseq_"+e).html(g),$("#"+a.pre+"ov_giseq_"+e).html(f),$("#"+a.pre+"tt_giseq_"+e).html(b)}showRefNum(e,t,s,i){let n=this.icn3d;n.icn3dui;let l="",r="",o="";for(let e=0,s=n.chainid2index[t].length;eCustom Ref. No.':1==s?'
    Kabat Ref. No.
    ':2==s?'
    IMGT Ref. No.
    ':'
    IgStRAnD Ref. No.
    ',d+='',r+=d+"
    ",l+=d+'';let c=!1;for(let s=0,l=e.length;s0){c=!0;break}}if(1==s&&!c)return{html:"",html3:""};let h=!1;for(let s=0,l=e.length;s0){h=!0;break}}if(2==s&&!h)return{html:"",html3:""};let p,m,u,g,f,b,C,y,v,w=!1,_="",S="",A="",x=1,k={},O=1,R="",E=!1;for(let l=0,r=e.length;l1e3&&"9"!=u.substr(1,1)&&(x=1,E&&R&&(delete k[R],R="")),S&&" "!=_&&f>1e3&&"9"==u.substr(1,1)&&(1==x&&(k.hasOwnProperty(_+g)&&++O,g=u.replace(f.toString(),"")+"_"+O,k[_+g]={},k[_+g].start=b,k[_+g].chainid=t),u=(1e3*parseInt(A)+900+x).toString(),p=_+u,++x))):!S||" "==_||i||s||(1==x&&(k.hasOwnProperty(_+g)?(++O,g=u.replace(f.toString(),"")+"_"+O,k[_+g]={}):k[_+g]={},k[_+g].start=b,k[_+g].chainid=t,R=_+g,E=!0),u=(1e3*parseInt(A)+900+x).toString(),p=_+u,++x),b=u,y=f,C=g,S=_}k[S+C]&&(k[S+C].len=x-1,k[S+C].end=b),O=1,R="",E=!1;let I,T={},M=!0;for(let r=0,o=e.length;r1e3&&"9"!=u.substr(1,1)&&(x=1,E&&R&&(--O,R="")),S&&f>1e3&&"9"==u.substr(1,1)){w=!0,1==x&&(T.hasOwnProperty(I+g)&&(++O,g=u.replace(f.toString(),"")+"_"+O),T[I+g]=1);let e=this.getAdjustedRefnum(k,I,x,A,g,y);f=e.refnum,M=e.bShowRefnum,u=e.refnumStr,p=e.refnumLabel,v=e.refnumLabelNoPostfix,a=e.bHidelabel,_=p.replace(new RegExp(u,"g"),""),++x}y=f}if(i)if(u){l+=parseInt(u)%2==0?''+u+"":' '}else l+="";else if(1==s||2==s)if(u){let e=parseInt(u).toString(),t='style="color:'+this.getRefnumColor(_)+'"';l+=parseInt(e.substr(e.length-2,2))%2==0?"'+u+"":" '}else l+="";else M&&" "!=_?(l+=this.getRefnumHtml(e,u,m,p,_,w,a),w&&(n.residIgLoop[e]=1)):l+=""}else{let t=n.firstAtomObjCls.getFirstAtomObj(n.residues[e]);if(t&&!n.proteins.hasOwnProperty(t.serial)||!S||i||s||I&&"G"==I.substr(0,1))l+="";else{w=!0,1==x&&(T.hasOwnProperty(I+g)&&++O,g=u.replace(f.toString(),"")+"_"+O,T[I+g]=1,E=!0,R=I+g);let t=this.getAdjustedRefnum(k,I,x,A,g,y);f=t.refnum,M=t.bShowRefnum,u=t.refnumStr,p=t.refnumLabel,v=t.refnumLabelNoPostfix,y=f,a=t.bHidelabel,_=p.replace(new RegExp(u,"g"),""),++x,M&&" "!=_?(l+=this.getRefnumHtml(e,u,m,p,_,w,a),w&&(n.residIgLoop[e]=1)):l+=""}}n.resid2refnum[e]=p,n.refnum2residArray.hasOwnProperty(u)?n.refnum2residArray[u].push(e):n.refnum2residArray[u]=[e],n.chainsMapping.hasOwnProperty(t)||(n.chainsMapping[t]={}),n.chainsMapping[t][e]=v,S=I}return l+='',l+="",l+="
    ",l+="",l+="",r+="",{html:l,html3:r}}getAdjustedRefnum(e,t,s,i,n,l){let r,o,a,d;this.icn3d.icn3dui;let c=!1,h=!0;if(e[t+n]){let i=parseInt(e[t+n].start),p=parseInt(e[t+n].end),m=e[t+n].start.replace(i.toString(),""),u=e[t+n].end.replace(p.toString(),""),g=e[t+n].len;s<=(e[t+n].nextStrand?parseInt(g/2+.5):g)?(r=i+s,o=r+m,a=t+o):(r=p-(g+1-s),o=r+u,a=void 0!==e[t+n].nextStrand?e[t+n].nextStrand+o:" "+o),d=t+r,1!=s&&s!=p-1||(c=!0),1==s&&i!=l&&(h=!1,r=0,o="",a="",d="")}else r=0,o="",a="",d="",c=!0;return{refnum:r,refnumStr:o,refnumLabel:a,refnumLabelNoPostfix:d,bHidelabel:c,bShowRefnum:h}}getRefnumHtml(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui,d=parseInt(t).toString(),c=this.getRefnumColor(n),h=l?'style="color:'+c+'"':'style="color:'+c+'; text-decoration: underline overline;"',p=parseInt(d.substr(d.length-2,2));parseInt(d.substr(d.length-3,3));let m="";if(50!=p||l)if(p%2!=0||52==p||r)m+=" ';else{m+="'+(isNaN(t)?p+t.substr(t.length-1,1):p)+""}else o.hAtomsRefnum=a.hashUtilsCls.unionHash(o.hAtomsRefnum,o.residues[e]),m+="'+i.substr(0,1)+""+i.substr(1)+"";return m}getRefnumColor(e){let t=this.icn3d.icn3dui;return"A^"==e?"#FF00FF":"A"==e?"#663399":"A*"==e?"#FFC0CB":"A'"==e?"#9370db":"B"==e?"#ba55d3":"C"==e?"#0000FF":"C'"==e?"#6495ED":"C''"==e?"#006400":"D"==e?"#00FF00":"E"==e?"#FFFF00":"F"==e?"#FFA500":"G"==e?"#FF0000":"G*"==e?"#8B0000":t.htmlCls.GREYB}insertGap(e,t,s,i){let n=this.icn3d;n.icn3dui;let l="";if(void 0!==n.targetGapHash&&n.targetGapHash.hasOwnProperty(t))for(let e=0;e"+s+"";return l}insertGapOverview(e,t){let s=this.icn3d,i="";if(s.icn3dui.cfg.blast_rep_id==e&&void 0!==s.targetGapHash&&s.targetGapHash.hasOwnProperty(t)){i+='
     
    '}return i}setAlternativeSeq(e,t){let s=this.icn3d;s.icn3dui;let i=s.chainsSeq[e];s.giSeq[e]=[];for(let t=0,n=i.length;t1&&s.htmlCls.clickMenuCls.setLogCmd("select sets "+e,!0)}else{let o={};if(void 0!==$(e).attr("domain")||void 0!==$(e).attr("feat")||void 0!==$(e).attr("3ddomain")||void 0!==$(e).attr("custom")){t.hlUpdateCls.hlSummaryDomain3ddomain(e);let a,d,c,h=$(e).attr("from").split(","),p=$(e).attr("to").split(",");r.substr(0,r.indexOf("_"));for(let s=0,i=h.length;s1&&s.htmlCls.clickMenuCls.setLogCmd("select sets "+c,!0)}}else{t.bCtrl||t.bShift?(t.currSelectedSets.push(i),t.selectionCls.selectAChain(r,i,!0,!0)):(t.currSelectedSets=[i],t.selectionCls.selectAChain(r,i,t.bAlignSeq)),t.bAlignSeq?s.htmlCls.clickMenuCls.setLogCmd("select alignChain "+r,!0):s.htmlCls.clickMenuCls.setLogCmd("select chain "+r,!0);let e=t.currSelectedSets.join(" or ");t.currSelectedSets.length>1&&s.htmlCls.clickMenuCls.setLogCmd("select sets "+e,!0)}else t.hlObjectsCls.removeHlObjects(),t.hlUpdateCls.removeHl2D(),$("#"+t.pre+"atomsCustom").val("")}}selectResidues(e,t){let s=this.icn3d,i=s.icn3dui;if(!i.bNode&&(!1!==s.bSelectResidue||s.bShift||s.bCtrl||s.selectionCls.removeSelection(),void 0!==e&&""!==e)){e=e.substr(e.indexOf("_")+1),s.bSelectResidue=!0,$(t).toggleClass("icn3d-highlightSeq");let n=e.substr(e.indexOf("_")+1);if(s.residues.hasOwnProperty(n))if($(t).hasClass("icn3d-highlightSeq")){for(let e in s.residues[n])s.hAtoms[e]=1;if(s.selectedResidues[n]=1,s.bAnnotations&&void 0!==$(t).attr("disease")){let e=$(t).attr("disease"),l=s.applyCenterCls.centerAtoms(i.hashUtilsCls.hash2Atoms(s.residues[n],s.atoms)),r=15;e.length>r&&(e=e.substr(0,r)+"...");let o=s.LABELSIZE,a=i.htmlCls.GREYD;s.analysisCls.addLabel(e,l.center.x,l.center.y,l.center.z,o,a,void 0,"custom")}}else{for(let e in s.residues[n])delete s.hAtoms[e];delete s.selectedResidues[n],s.hlObjectsCls.removeHlObjects()}}}}class Pt{constructor(e){this.icn3d=e}update2DdgmContent(){let e=this.icn3d,t=e.icn3dui,s="";void 0!==t.cfg.mmdbid||void 0!==t.cfg.gi?(s+=e.diagram2dCls.draw2Ddgm(e.interactionData,e.inputid,void 0,!0),s+=e.diagram2dCls.set2DdgmNote(),$("#"+e.pre+"dl_2ddgm").html(s)):e.mmdbidArray&&(void 0!==t.cfg.align||void 0!==t.cfg.chainalign||e.bRealign)&&(s+=e.diagram2dCls.draw2Ddgm(e.interactionData1,e.mmdbidArray[0].toUpperCase(),0,!0),void 0!==e.mmdbid_q&&e.mmdbid_q===e.mmdbid_t?s+=e.diagram2dCls.draw2Ddgm(e.interactionData2,e.mmdbidArray[0].toUpperCase(),1,!0):s+=e.diagram2dCls.draw2Ddgm(e.interactionData2,e.mmdbidArray[1].toUpperCase(),1,!0),s+=e.diagram2dCls.set2DdgmNote(!0),$("#"+e.pre+"dl_2ddgm").html(s))}changeSeqColor(e){let t=this.icn3d,s=t.icn3dui;for(let i=0,n=e.length;i0&&($("#"+e.pre+"dl_2ddgm svg line").attr("stroke","#000000"),$("#"+e.pre+"dl_2ddgm line").attr("stroke-width",1))}removeHlMenus(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"atomsCustom").val(""),$("#"+e.pre+"atomsCustom")[0].blur()}updateHlAll(e,t,s,i){let n=this.icn3d,l=n.icn3dui;n.prevHighlightAtoms=l.hashUtilsCls.cloneHash(n.hAtoms),this.updateHlObjects(i),void 0!==e?this.updateHlSeqInChain(e,s):this.updateHlSeq(void 0,void 0,s),this.updateHl2D(),(void 0===t||t)&&this.updateHlMenus(e)}updateHlObjects(e){let t=this.icn3d;t.icn3dui,t.hlObjectsCls.removeHlObjects(),(t.hAtoms&&t.atoms&&Object.keys(t.hAtoms).length0&&(e=s.defNames2Residues[i]);let t={};if(void 0!==s.defNames2Atoms[i]&&s.defNames2Atoms[i].length>0){for(let e=0,n=s.defNames2Atoms[i].length;e0&&(r=t.firstAtomObjCls.getFirstCalphaAtomObj(l))}let o=void 0!==r&&void 0!==r.color?"#"+r.color.getHexString():"#FFFFFF",a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] rect[class='icn3d-hlnode']"),d=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] rect[class='icn3d-basenode']");void 0!==a&&(t.diagram2dCls.highlightNode("rect",a,d,l),$(a).attr("fill",o)),a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] circle[class='icn3d-hlnode']"),d=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] circle[class='icn3d-basenode']"),void 0!==a&&(t.diagram2dCls.highlightNode("circle",a,d,l),$(a).attr("fill",o)),a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] ellipse[class='icn3d-hlnode']"),void 0!==a&&t.diagram2dCls.highlightNode("ellipse",a,void 0,l),a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] polygon[class='icn3d-hlnode']"),d=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] polygon[class='icn3d-basenode']"),void 0!==a&&(t.diagram2dCls.highlightNode("polygon",a,d,l),$(a).attr("fill",o))}if(void 0!==t.lineArray2d)for(let e=0,i=t.lineArray2d.length;e1){let e={},l=[],o=[],a=[],c=[],h=[],m=[],u=[],g=[],f=[],b=[],C=[],y=[],v={};for(let t=0,s=p.length;t0&&(E=1,t=i.getGraphCls.getNodeTopBottom(c[e],d,void 0,E,g[e]),h[e]=t.nodeArray1,m[e]=t.nodeArray2,d=n.hashUtilsCls.unionHash(d,t.name2node),E=2,t=i.getGraphCls.getNodeTopBottom(c[e],d,void 0,E,y[e]),f[e]=t.nodeArray1,b[e]=t.nodeArray2,d=n.hashUtilsCls.unionHash(d,t.name2node)),x[e]=l[e].length,k[e]=o[e].length,O=Math.max(O,k[e]),R.push(p[e])}let I,T,M,P,D,H=1,F=3*H,L=7*H,N=10,U=10,q=30,$=20;t?(M=(n.utilsCls.sumArray(x)+2*R.length)*(F+L)+4*U+2*q+$*R.length,T=(O+2)*(F+L)+2*N+q):(I=110+$,M=I*R.length,T=(O+2)*(F+L)+2*N),Object.keys(i.chainsMapping).length>0&&(M*=3),t?(i.scatterplotWidth=2*T,D=i.scatterplotWidth,P=n.scatterplotid):(i.linegraphWidth=2*T,D=i.linegraphWidth,P=n.linegraphid),s=0==R.length?"No interactions found for each structure

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

    ",s+="";let j,B=0;E=0,j=this.drawGraphPerType(E,p,t,l,o,a,d,B,I,$,x,F,L,U),B=j.heightFinal,s+=j.html,Object.keys(i.chainsMapping).length>0&&(E=1,j=this.drawGraphPerType(E,p,t,h,m,u,d,B,I,$,x,F,L,U),B=j.heightFinal,s+=j.html,E=2,j=this.drawGraphPerType(E,p,t,f,b,C,d,B,I,$,x,F,L,U),B=j.heightFinal,s+=j.html),s+=""}else if(t){let e,t,l,c,h=p[0],m=o.length,u=a.length,g=1,f=3*g,b=7*g,C=30;t=(m+2)*(f+b)+2*10+C,e=(u+2)*(f+b)+2*10+C,i.scatterplotWidth=2*e,c=i.scatterplotWidth,l=n.scatterplotid,s=r.length>0?"":"No interactions found for these two sets

    ",s+="",s+=this.drawScatterplot_base(o,a,r,d,0),i.lineGraphStr+=i.getGraphCls.updateGraphJson(h,1,o,a,r),s+=""}else{let e=p[0],t=o.length,l=a.length,c=1,h=3*c,m=7*c,u=110,g=10,f=t>l?t*(h+m)+2*g:l*(h+m)+2*g;i.linegraphWidth=2*f,s=r.length>0?"":"No interactions found for these two sets

    ",s+="",s+=this.drawLineGraph_base(o,a,r,d,0),i.lineGraphStr+=i.getGraphCls.updateGraphJson(e,1,o,a,r),s+=""}return i.lineGraphStr+="}\n",i.scatterplotStr=i.lineGraphStr,t?$("#"+i.pre+"scatterplotDiv").html(s):$("#"+i.pre+"linegraphDiv").html(s),s}drawGraphPerType(e,t,s,i,n,l,r,o,a,d,c,h,p,m){let u=this.icn3d;u.icn3dui;let g,f,b="",C=2==t.length&&"2"==t[1].replace(t[0],"");0==e?(g="Interactions in ",f=""):1==e?(g="Common interactions in ",f="_common"):2==e&&(g="Different interactions in ",f="_diff");for(let y=0,v=t.length;y0&&(u.lineGraphStr+=", \n"):u.lineGraphStr+=", \n",u.lineGraphStr+=u.getGraphCls.updateGraphJson(t[y],y+f,i[y],n[y],l[y])}return{heightFinal:o,html:b}}getIdArrayFromNode(e){let t=this.icn3d.icn3dui,s=[];s.push(""),s.push("");let i=e.r.substr(4);return s=s.concat(t.utilsCls.getIdArray(i)),s}drawLineGraph_base(e,t,s,i,n,l,r){let o,a,d=this.icn3d,c=d.icn3dui,h="",p=e.length,m=t.length;p>m?(o=10,a=10*Math.abs(p-m)*.5+10):(a=10,o=10*Math.abs(p-m)*.5+10),l&&(h+=""+l+"");let u=30+n,g=80+n,f="",b={},C={};for(let t=0;t",h+="Interaction of residue "+n.id+" with residue "+l.id+"",h+="
    ")}return h+=f,h}drawScatterplot_base(e,t,s,i,n,l,r,o,a){let d=this.icn3d;d.icn3dui;let c="",h=e.length,p=t.length,m=l?3:7,u=(h+1)*(3+m)+30+40;r&&(c+=""+r+"");let g=n+u-(50+(3+m)),f=40+(3+m),b="",C={},y={};for(let t=0;t"):(h+="",h+="Interaction of residue "+t.id+" with residue "+s.id+"",h+=l?"":"",h+=""))),h}copyStylesInline(e,t){this.icn3d.icn3dui;let s=["svg","g"];for(let i=0;i";return b+=""+e.id+"",o?(b+="",b+=""+g+""):(b+="",b+=""+g+""),b+="",b}getNodeTopBottom(e,t,s,i,n){let l=this.icn3d.icn3dui,r=this,o=[],a=[],d={};for(let s in e){let e=t[s];if(e){if(1==i||2==i){if(e=l.hashUtilsCls.cloneHash(e),1==i){let t=n[s]?n[s]:"-";e.id+="=>"+t}else{let t=n[s]?n[s]:"--";e.id+="==>"+t}d[e.id]=e}"a"==e.s?o.push(e):"b"==e.s?a.push(e):"ab"==e.s&&(o.push(e),a.push(e))}}return o.sort((function(e,t){return r.compNode(e,t)})),a.sort((function(e,t){return r.compNode(e,t,s)})),{nodeArray1:o,nodeArray2:a,name2node:d}}updateGraphJson(e,t,s,i,n){let l=this.icn3d.icn3dui,r="";return r+='"structure'+t+'": {"id": "'+e+'", "nodes1":[',r+=l.utilsCls.getJSONFromArray(s),r+='], \n"nodes2":[',r+=l.utilsCls.getJSONFromArray(i),r+='], \n"links":[',r+=l.utilsCls.getJSONFromArray(n),r+="]}",r}updateGraphColor(){let e=this.icn3d,t=e.icn3dui;if(void 0!==e.graphStr){let s=JSON.parse(e.graphStr),i={};for(let t in e.residues){let s=e.firstAtomObjCls.getFirstAtomObj(e.residues[t]);i[t]=s.color.getHexString().toUpperCase()}let n={};for(let e=0,l=s.nodes.length;e0&&c==e.chain&&(n.resid2ncbi[e.resi]==n.resid2ncbi[p]+1||n.resid2ncbi[e.resi]==n.resid2ncbi[p])&&(o.push('{"source": "'+h+'", "target": "'+u+'", "v": '+d+', "c": "'+f+'"}'),e.ssbegin&&(d=l.htmlCls.ssValue),e.ssend&&(d=l.htmlCls.coilValue)),c=e.chain,h=u,p=e.resi,++a}}return{node:r,link:o}}getHbondLinksForSet(e,t){let s=this.icn3d,i=s.icn3dui,n={},l=parseFloat($("#"+s.pre+"hbondthreshold").val()),r=e,o=r;if(Object.keys(o).length>0&&Object.keys(r).length>0){let e=!1;s.hBondCls.calculateChemicalHbonds(i.hashUtilsCls.intHash2Atoms(s.dAtoms,o,s.atoms),i.hashUtilsCls.intHash2Atoms(s.dAtoms,r,s.atoms),parseFloat(l),e,"graph",!0),n=i.hashUtilsCls.cloneHash(s.resid2Residhash)}return this.getGraphLinks(n,n,i.htmlCls.hbondInsideColor,t,i.htmlCls.hbondValuehbondInsideValue)}getIonicLinksForSet(e,t){let s=this.icn3d,i=s.icn3dui,n={},l=parseFloat($("#"+s.pre+"saltbridgethreshold").val()),r=e,o=r;if(Object.keys(o).length>0&&Object.keys(r).length>0){let e=!1;s.saltbridgeCls.calculateIonicInteractions(i.hashUtilsCls.intHash2Atoms(s.dAtoms,o,s.atoms),i.hashUtilsCls.intHash2Atoms(s.dAtoms,r,s.atoms),parseFloat(l),e,"graph",!0),n=i.hashUtilsCls.cloneHash(s.resid2Residhash)}return this.getGraphLinks(n,n,i.htmlCls.ionicInsideColor,t,i.htmlCls.ionicInsideValue)}getHalogenPiLinksForSet(e,t){let s,i=this.icn3d,n=i.icn3dui,l={},r=e,o=r,a="";return s=parseFloat($("#"+i.pre+"halogenthreshold").val()),Object.keys(o).length>0&&Object.keys(r).length>0&&(i.piHalogenCls.calculateHalogenPiInteractions(n.hashUtilsCls.intHash2Atoms(i.dAtoms,r,i.atoms),n.hashUtilsCls.intHash2Atoms(i.dAtoms,o,i.atoms),parseFloat(s),"graph","halogen",!0),l=n.hashUtilsCls.cloneHash(i.resid2Residhash)),a+=this.getGraphLinks(l,l,n.htmlCls.halogenInsideColor,t,n.htmlCls.halogenInsideValue),s=parseFloat($("#"+i.pre+"picationthreshold").val()),Object.keys(o).length>0&&Object.keys(r).length>0&&(i.piHalogenCls.calculateHalogenPiInteractions(n.hashUtilsCls.intHash2Atoms(i.dAtoms,r,i.atoms),n.hashUtilsCls.intHash2Atoms(i.dAtoms,o,i.atoms),parseFloat(s),"graph","pi-cation",!0),l=n.hashUtilsCls.cloneHash(i.resid2Residhash)),a+=this.getGraphLinks(l,l,n.htmlCls.picationInsideColor,t,n.htmlCls.picationInsideValue),s=parseFloat($("#"+i.pre+"pistackingthreshold").val()),Object.keys(o).length>0&&Object.keys(r).length>0&&(i.piHalogenCls.calculateHalogenPiInteractions(n.hashUtilsCls.intHash2Atoms(i.dAtoms,r,i.atoms),n.hashUtilsCls.intHash2Atoms(i.dAtoms,o,i.atoms),parseFloat(s),"graph","pi-stacking",!0),l=n.hashUtilsCls.cloneHash(i.resid2Residhash)),a+=this.getGraphLinks(l,l,n.htmlCls.pistackingInsideColor,t,n.htmlCls.pistackingInsideValue),a}getContactLinksForSet(e,t,s){let i=this.icn3d;i.icn3dui;let n=[],l="",r="",o={};for(let t in e){let e=i.atoms[t];e.ss==l&&e.chain==r||(Object.keys(o).length>0&&n.push(o),o={}),o[e.serial]=1,l=e.ss,r=e.chain}Object.keys(o).length>0&&n.push(o);let a=n.length,d="";for(let e=0;ed?s?-1:1:ah?1:c0&&Object.keys(a).length>0)){let t,s=c.hBondCls.calculateChemicalHbonds(h.hashUtilsCls.intHash2Atoms(c.dAtoms,d,c.atoms),h.hashUtilsCls.intHash2Atoms(c.dAtoms,a,c.atoms),parseFloat(e),n);n?(c.resid2ResidhashSaltbridge=h.hashUtilsCls.cloneHash(c.resid2Residhash),t="all atoms that have salt bridges with the selected atoms"):(c.resid2ResidhashHbond=h.hashUtilsCls.cloneHash(c.resid2Residhash),t="all atoms that are hydrogen-bonded with the selected atoms");let i={};for(let e in s){i[c.atoms[e].structure+"_"+c.atoms[e].chain+"_"+c.atoms[e].resi]=1}c.hAtoms={};for(let e in i)for(let t in c.residues[e])c.hAtoms[t]=1,c.atoms[t].style2="stick";let l=r+"_auto";c.selectionCls.addCustomSelection(Object.keys(i),l,t,o,!0),c.selectionCls.saveSelectionIfSelected(),c.drawCls.draw()}}showHydrogens(){let e=this.icn3d;if(void 0!==e.icn3dui.cfg.cid)for(let t in e.hAtoms){let s=e.atoms[t];if("H"!==s.elem.substr(0,1)){e.atoms[s.serial].bonds=e.atoms[s.serial].bonds2.concat(),e.atoms[s.serial].bondOrder=e.atoms[s.serial].bondOrder2.concat();for(let t=0,i=e.atoms[s.serial].bonds.length;t0){let i=e.atoms[t].bonds[0];e.atoms[i].bonds.push(s.serial),e.atoms[i].bondOrder&&e.atoms[i].bondOrder.push(1)}e.dAtoms[t]=1}}e.bShowHighlight=!1}hideHydrogens(){let e=this.icn3d;e.icn3dui;for(let t in e.hAtoms){let s=e.atoms[t];if("H"===s.elem.substr(0,1)){if(e.atoms[s.serial].bonds.length>0){let t=e.atoms[s.serial].bonds[0],i=e.atoms[t].bonds?e.atoms[t].bonds.indexOf(s.serial):-1;-1!==i&&(e.atoms[t].bonds.splice(i,1),e.atoms[t].bondOrder&&e.atoms[t].bondOrder.splice(i,1))}delete e.dAtoms[s.serial],delete e.hAtoms[s.serial]}}}hideHbondsContacts(){let e=this.icn3d,t=e.icn3dui,s="set hbonds off";t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.hBondCls.hideHbonds(),s="set salt bridge off",t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.saltbridgeCls.hideSaltbridge(),s="set contact off",t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.contactCls.hideContact(),s="set halogen pi off",t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.piHalogenCls.hideHalogenPi()}showIonicInteractions(e,t,s,i,n,l){let r,o,a,d,c=this.icn3d,h=c.icn3dui;if(!i&&(r="saltbridge",o="salt bridge "+e+" | sets "+t+" "+s+" | "+i,c.opts.saltbridge="yes",a=c.definedSetsCls.getAtomsFromNameArray(t),d=c.definedSetsCls.getAtomsFromNameArray(s),c.firstAtomObjCls.getFirstAtomObj(a),Object.keys(d).length>0&&Object.keys(a).length>0)){let t,s=c.saltbridgeCls.calculateIonicInteractions(h.hashUtilsCls.intHash2Atoms(c.dAtoms,d,c.atoms),h.hashUtilsCls.intHash2Atoms(c.dAtoms,a,c.atoms),parseFloat(e),n);c.resid2ResidhashSaltbridge=h.hashUtilsCls.cloneHash(c.resid2Residhash),t="all atoms that have ionic interactions with the selected atoms";let i={};for(let e in s){i[c.atoms[e].structure+"_"+c.atoms[e].chain+"_"+c.atoms[e].resi]=1}c.hAtoms={};for(let e in i)for(let t in c.residues[e])c.hAtoms[t]=1,c.atoms[t].style2="stick",c.ions.hasOwnProperty(t)&&(c.atoms[t].style2="sphere");let l="saltbridge_auto";c.selectionCls.addCustomSelection(Object.keys(i),l,t,o,!0),c.selectionCls.saveSelectionIfSelected(),c.drawCls.draw()}}showHalogenPi(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(i)return;let a,d,c=l+" "+e+" | sets "+t+" "+s+" | "+i;if(r.opts[l]="yes",a=r.definedSetsCls.getAtomsFromNameArray(t),d=r.definedSetsCls.getAtomsFromNameArray(s),r.firstAtomObjCls.getFirstAtomObj(a),Object.keys(d).length>0&&Object.keys(a).length>0){let t,s=r.piHalogenCls.calculateHalogenPiInteractions(o.hashUtilsCls.intHash2Atoms(r.dAtoms,a,r.atoms),o.hashUtilsCls.intHash2Atoms(r.dAtoms,d,r.atoms),parseFloat(e),n,l);"halogen"==l?(r.resid2ResidhashHalogen=o.hashUtilsCls.cloneHash(r.resid2Residhash),t="all atoms that have halogen bonds with the selected atoms"):"pi-cation"==l?(r.resid2ResidhashPication=o.hashUtilsCls.cloneHash(r.resid2Residhash),t="all atoms that have pi-cation interactions with the selected atoms"):"pi-stacking"==l&&(r.resid2ResidhashPistacking=o.hashUtilsCls.cloneHash(r.resid2Residhash),t="all atoms that have pi-stacking with the selected atoms");let i={};for(let e in s){i[r.atoms[e].structure+"_"+r.atoms[e].chain+"_"+r.atoms[e].resi]=1}r.hAtoms={};for(let e in i)for(let t in r.residues[e])r.hAtoms[t]=1,r.atoms[t].style2="stick",r.ions.hasOwnProperty(t)&&(r.atoms[t].style2="sphere");let h=l+"_auto";r.selectionCls.addCustomSelection(Object.keys(i),h,t,c,!0),r.selectionCls.saveSelectionIfSelected(),r.drawCls.draw()}}showClbonds(){let e=this.icn3d,t=e.icn3dui;e.opts.clbonds="yes";let s=e.applyClbondsCls.applyClbondsOptions();for(let i in s)e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.residues[i]);if(Object.keys(s).length>0){let t="clbonds",i="all atoms that have cross-linkages";e.selectionCls.addCustomSelection(Object.keys(s),t,i,"cross linkage",!0),e.selectionCls.saveSelectionIfSelected(),e.drawCls.draw()}}showSsbonds(){let e=this.icn3d,t=e.icn3dui;e.opts.ssbonds="yes";let s={},i=Object.keys(e.structures);for(let n=0,l=i.length;n0){let t="ssbonds",i="all atoms that have disulfide bonds";e.selectionCls.addCustomSelection(Object.keys(s),t,i,"disulfide bonds",!0),e.selectionCls.saveSelectionIfSelected(),e.drawCls.draw()}}pickCustomSphere(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(i)return;let a,d,c="select zone cutoff "+e+" | sets "+t+" "+s+" | "+i;n&&(c="interactions "+e+" | sets "+t+" "+s+" | "+i,r.opts.contact="yes"),a=r.definedSetsCls.getAtomsFromNameArray(t),d=r.definedSetsCls.getAtomsFromNameArray(s);let h,p,m=this.pickCustomSphere_base(e,a,d,i,n,l,c,!0),u=Object.keys(m.residues);r.hAtoms={};for(let e=0,t=u.length;e1?"structure":v>1?"chain":"residue";let _=[];if(n&&_.push("hbonds"),l&&_.push("salt bridge"),r&&_.push("interactions"),o&&_.push("halogen"),a&&_.push("pi-cation"),d&&_.push("pi-stacking"),s||(p.resids2inter={},p.resids2interAll={}),l){let n=parseFloat($("#"+p.pre+"saltbridgethreshold").val());n&&!isNaN(n)||(n=p.tsIonic),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showIonicInteractions(n,e,t,s,!0,i)),g=m.hashUtilsCls.unionHash(g,p.hAtoms)}if(n){let n=parseFloat($("#"+p.pre+"hbondthreshold").val());n&&!isNaN(n)||(n=p.tsHbond),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHbonds(n,e,t,s,void 0,i)),g=m.hashUtilsCls.unionHash(g,p.hAtoms)}let S,A,x,k,O="";if(n&&(O+=this.exportHbondPairs(i,u)),l&&(O+=this.exportSaltbridgePairs(i,u)),o){let n=parseFloat($("#"+p.pre+"halogenthreshold").val());n&&!isNaN(n)||(n=p.tsHalogen),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHalogenPi(n,e,t,s,i,"halogen")),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportHalogenPiPairs(i,u,"halogen")}if(a){let n=parseFloat($("#"+p.pre+"picationthreshold").val());n&&!isNaN(n)||(n=p.tsPication),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHalogenPi(n,e,t,s,i,"pi-cation")),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportHalogenPiPairs(i,u,"pi-cation")}if(d){let n=parseFloat($("#"+p.pre+"pistackingthreshold").val());n&&!isNaN(n)||(n=p.tsPistacking),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHalogenPi(n,e,t,s,i,"pi-stacking")),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportHalogenPiPairs(i,u,"pi-stacking")}if(r){let n=b?c:parseFloat($("#"+p.pre+"contactthreshold").val());if(n&&!isNaN(n)||(n=p.tsContact),1!=e.length||1!=t.length||e[0]!=t[0])s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.pickCustomSphere(n,e,t,s,!0,i)),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportSpherePairs(!0,i,u);else{if(!s){let l={},o={};if(b){let e=!0,t=p.showInterCls.pickCustomSphere_base(n,C,y,s,!0,void 0,void 0,!0,e);l=m.hashUtilsCls.unionHash(l,t.residues);for(let e in t.resid2Residhash)o[e]=m.hashUtilsCls.unionHash(o[e],t.resid2Residhash[e])}else{let r=[],a="",d="",c={};for(let e in C){let t=p.atoms[e];t.ss==a&&t.chain==d||(Object.keys(c).length>0&&r.push(c),c={}),c[t.serial]=1,a=t.ss,d=t.chain}Object.keys(c).length>0&&r.push(c);let h=r.length;A="interactions "+n+" | sets "+e+" "+t+" | true",p.opts.contact="yes";for(let e=0;e
    ",T=p.resid2specCls.atoms2residues(Object.keys(C)),M=p.resid2specCls.atoms2residues(Object.keys(y)),P="select "+p.resid2specCls.residueids2spec(T),D="select "+p.resid2specCls.residueids2spec(M);I+="Set 1: "+e+'
    ',I+="Set 2: "+t+'

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

    ',I+='
    Note: Each checkbox below selects the corresponding residue. You can click "Save Selection" in the "Select" menu to save the selection and click on "Highlight" button to clear the checkboxes.

    ';let U=I;if(("graph"==i||"linegraph"==i||"scatterplot"==i||b)&&(I=""),I+=O,"save1"==i||"save2"==i){I=U;let e="";"save1"==i?e="Set 1":"save2"==i&&(e="Set 2"),I+='

    Interactions Sorted on '+e+':
    ';let t=this.getAllInteractionTable(i);I+=t.html,h=t.bondCnt,$("#"+p.pre+"dl_interactionsorted").html(I),m.htmlCls.dialogCls.openDlg("dl_interactionsorted","Show sorted interactions")}else if("view"==i)$("#"+p.pre+"dl_allinteraction").html(I),m.htmlCls.dialogCls.openDlg("dl_allinteraction","Show interactions");else if("linegraph"==i){m.htmlCls.dialogCls.openDlg("dl_linegraph","Show interactions between two lines of residue nodes"),p.graphStr=p.getGraphCls.getGraphData(C,y,e,t,I,u),p.bLinegraph=!0;let s=p.lineGraphCls.drawLineGraph(p.graphStr);$("#"+p.pre+"linegraphDiv").html(s)}else if("scatterplot"==i){m.htmlCls.dialogCls.openDlg("dl_scatterplot","Show interactions as scatterplot"),p.graphStr=p.getGraphCls.getGraphData(C,y,e,t,I,u),p.bScatterplot=!0;let s=p.lineGraphCls.drawLineGraph(p.graphStr,!0);$("#"+p.pre+"scatterplotDiv").html(s)}else if(b){m.htmlCls.dialogCls.openDlg("dl_contactmap","Show contact map");let s=!0,i=p.getGraphCls.getGraphData(C,y,e,t,I,u,s);p.bContactMap=!0;let n=p.contactMapCls.drawContactMap(i);$("#"+p.pre+"contactmapDiv").html(n)}else if("graph"==i)if(p.graphStr=p.getGraphCls.getGraphData(C,y,e,t,I,u),p.bGraph=!0,Object.keys(y).length+Object.keys(C).length>Object.keys(p.dAtoms).length&&(p.graphStr=p.selectionCls.getGraphDataForDisplayed()),void 0===p.bD3){await m.getAjaxPromise("https://www.ncbi.nlm.nih.gov/Structure/icn3d/script/d3v4-force-all.min.js","script"),p.bD3=!0,$("#"+m.svgid).empty(),m.htmlCls.dialogCls.openDlg("dl_graph","Force-directed graph"),p.drawGraphCls.drawGraph(p.graphStr,p.pre+"dl_graph")}else $("#"+m.svgid).empty(),m.htmlCls.dialogCls.openDlg("dl_graph","Force-directed graph"),p.drawGraphCls.drawGraph(p.graphStr,p.pre+"dl_graph");return{interactionTypes:_.toString(),bondCnt:h}}clearInteractions(){let e=this.icn3d;e.icn3dui,e.lines.hbond=[],e.hbondpnts=[],e.lines.saltbridge=[],e.saltbridgepnts=[],e.lines.contact=[],e.contactpnts=[],e.lines.halogen=[],e.lines["pi-cation"]=[],e.lines["pi-stacking"]=[],e.halogenpnts=[],e.picationpnts=[],e.pistackingpnts=[]}resetInteractionPairs(){let e=this.icn3d;e.icn3dui,e.bHbondCalc=!1,e.showInterCls.hideHbondsContacts(),e.hlUpdateCls.clearHighlight(),e.resids2inter={},e.resids2interAll={}}async retrieveInteractionData(){let e=this.icn3d,t=e.icn3dui;if(!e.b2DShown)if(void 0!==t.cfg.align){let s=Object.keys(e.structures);if(2==t.cfg.atype){let t=!0;await e.alignParserCls.downloadAlignment(s[0]+","+s[1],t)}await e.ParserUtilsCls.set2DDiagramsForAlign(s[0].toUpperCase(),s[1].toUpperCase())}else void 0!==t.cfg.chainalign?(Object.keys(e.structures),await e.ParserUtilsCls.set2DDiagramsForChainalign(e.chainidArray)):e.ParserUtilsCls.download2Ddgm(e.inputid.toUpperCase())}getAllInteractionTable(e){let t=this.icn3d,s=t.icn3dui,i=[],n=Object.keys(t.resids2inter);("save1"==e||"save2"==e)&&n.sort((function(t,i){return s.utilsCls.compResid(t,i,e)}));let l,r,o="",a="",d="",c="",h="",p="",m="",u="",g="",f=0,b=0,C=0,y=0,v=0,w=0,_="";for(let s=0,S=n.length;s0&&l!=a&&(i.push({res1:a,res2:_,cntHbond:f,cntIonic:b,cntContact:C,cntHalegen:y,cntPication:v,cntPistacking:w}),o+=this.getInteractionPerResidue(d,c,h,p,m,u,g,f,b,C,y,v,w),c="",h="",p="",m="",u="",g="",f=0,b=0,C=0,y=0,v=0,w=0,_=""),x=t.resids2inter[S].hbond,k=this.getInteractionPairDetails(x,e,"hbond"),c+=k.html,f+=k.cnt,k.cnt>0&&(_+=r+":hbond_"+k.cnt+" "),x=t.resids2inter[S].ionic,k=this.getInteractionPairDetails(x,e,"ionic"),h+=k.html,b+=k.cnt,k.cnt>0&&(_+=r+":ionic_"+k.cnt+" "),x=t.resids2inter[S].contact,k=this.getContactPairDetails(x,e,"contact"),p+=k.html,C+=k.cnt,k.cnt>0&&(_+=r+":contact_"+k.cnt+" "),x=t.resids2inter[S].halogen,k=this.getInteractionPairDetails(x,e,"halogen"),m+=k.html,y+=k.cnt,k.cnt>0&&(_+=r+":halogen_"+k.cnt+" "),x=t.resids2inter[S]["pi-cation"],k=this.getInteractionPairDetails(x,e,"pi-cation"),u+=k.html,v+=k.cnt,k.cnt>0&&(_+=r+":pi-cation_"+k.cnt+" "),x=t.resids2inter[S]["pi-stacking"],k=this.getInteractionPairDetails(x,e,"pi-stacking"),g+=k.html,w+=k.cnt,k.cnt>0&&(_+=r+":pi-stacking_"+k.cnt+" "),a=l,d=O}i.push({res1:a,res2:_,cntHbond:f,cntIonic:b,cntContact:C,cntHalegen:y,cntPication:v,cntPistacking:w}),o+=this.getInteractionPerResidue(d,c,h,p,m,u,g,f,b,C,y,v,w);let S="";if(n.length>0){S+='
    ',S+="",S+="",S+="",S+="",S+="";let e='';S+=e,S+=e,S+='',S+=e,S+=e,S+=e,S+="",S+="",S+=o,S+="
    Residue# Hydrogen
    Bond
    # Salt Bridge
    /Ionic Interaction
    # Contact# Halogen
    Bond
    # π-Cation# π-StackingHydrogen Bond (backbone atoms: @CA, @N, @C, @O)Salt Bridge/Ionic InteractionContactHalogen Bondπ-Cationπ-Stacking
    Atom1Atom2Distance(Å)Highlight in 3D
    Atom1Atom2# ContactsMin Distance(Å)C-alpha Distance(Å)Highlight in 3D

    "}return{html:S,bondCnt:i}}getInteractionPerResidue(e,t,s,i,n,l,r,o,a,d,c,h,p){this.icn3d.icn3dui;let m="";m+=''+e[3]+e[2]+""+o+""+a+""+d+""+c+""+h+""+p+"";let u=[t,s,i,n,l,r];for(let e in u){m+=''+u[e]+"
    "}return m+="",m}getInteractionPairDetails(e,t,s){let i=this.icn3d;i.icn3dui;let n="",l=0,r='    ';if(void 0!==e)for(let a in e){let d=a.split(","),c="save1"==t?d[0]:d[1],h="save1"==t?d[1]:d[0],p=i.getGraphCls.convertLabel2Resid(c),m=i.firstAtomObjCls.getFirstAtomObj(i.residues[p]),u=m.color?m.color.getHexString():"",g=i.getGraphCls.convertLabel2Resid(h),f=i.firstAtomObjCls.getFirstAtomObj(i.residues[g]),b=f.color?f.color.getHexString():"",C=Math.sqrt(e[a]).toFixed(1);n+=' '+c+r+u+o+' '+h+r+b+o+''+C+"",n+='',n+="",++l}return{html:n,cnt:l}}getContactPairDetails(e,t){let s=this.icn3d;s.icn3dui;let i="",n=0,l='    ';if(void 0!==e)for(let o in e){let a=o.split(","),d="save1"==t?a[0]:a[1],c="save1"==t?a[1]:a[0],h=s.getGraphCls.convertLabel2Resid(d),p=s.firstAtomObjCls.getFirstAtomObj(s.residues[h]),m=p.color?p.color.getHexString():"",u=s.getGraphCls.convertLabel2Resid(c),g=s.firstAtomObjCls.getFirstAtomObj(s.residues[u]),f=g.color?g.color.getHexString():"",b=e[o].split("_"),C=b[0],y=b[1],v=b[2],w=b[3],_=b[4];i+=' '+d+"@"+v+l+m+r+' '+c+"@"+w+l+f+r+''+_+''+C+''+y+"",i+='',i+="",n+=parseInt(_)}return{html:i,cnt:n}}exportInteractions(){var e=this.icn3d;e.icn3dui;let t='

    Interacting residues:
    ';for(let s in e.chainname2residues)for(let i in e.chainname2residues[s]){let n=s.substr(0,s.indexOf("_"))+"_"+i.substr(0,i.indexOf(" "));t+=""}t+="
    Base Chain: ResiduesInteracting Chain
    "+s+": ",t+=e.resid2specCls.residueids2spec(e.chainname2residues[s][i]),t+=""+n+"

    ";let s=e.inputid?e.inputid:"custom";e.saveFileCls.saveFile(s+"_interactions.html","html",t)}exportSsbondPairs(){var e=this.icn3d;e.icn3dui;let t="",s=0;for(let i in e.structures){let n=e.ssbondpnts[i];if(void 0===n)break;for(let e=0,i=n.length;e"+n[e]+" Cys"+n[e+1]+" Cys",++s}}let i='

    '+s+" disulfide pairs:

    ";i+=t,i+="
    Residue ID 1Residue ID 2

    ";let n=e.inputid?e.inputid:"custom";e.saveFileCls.saveFile(n+"_disulfide_pairs.html","html",i)}exportClbondPairs(){var e=this.icn3d;e.icn3dui;let t="",s=0,i={};for(let n in e.structures){let l=e.clbondpnts[n];if(void 0===l)break;for(let n=0,r=l.length;n"+r+" "+i.resn+""+o+" "+n.resn+"",++s}i[r+"_"+o]=1,i[o+"_"+r]=1}}let n='

    '+s+" cross-linkage pairs:

    ";n+=t,n+="
    Residue ID 1Residue ID 2

    ";let l=e.inputid?e.inputid:"custom";e.saveFileCls.saveFile(l+"_crosslinkage_pairs.html","html",n)}exportHbondPairs(e,t){var s=this.icn3d,i=s.icn3dui;let n="",l=0,r='    ';for(let t in s.resid2ResidhashHbond){let i=s.getGraphCls.convertLabel2Resid(t),a=s.firstAtomObjCls.getFirstAtomObj(s.residues[i]),d=a.color?a.color.getHexString():"";for(let i in s.resid2ResidhashHbond[t]){let a=s.getGraphCls.convertLabel2Resid(i),c=s.firstAtomObjCls.getFirstAtomObj(s.residues[a]),h=c.color?c.color.getHexString():"",p=Math.sqrt(s.resid2ResidhashHbond[t][i]).toFixed(1);n+=' '+t+r+d+o+' '+i+r+h+o+''+p+"","view"==e&&(n+=''),n+="",++l}}let a='

    '+l+" hydrogen bond pairs (backbone atoms: @CA, @N, @C, @O):

    ";if(l>0&&(a+="
    ","view"==e&&(a+=''),a+="",a+=n,a+="
    Atom 1Atom 2Distance(Å)Highlight in 3D

    "),"graph"==e||"linegraph"==e||"scatterplot"==e){return s.getGraphCls.getGraphLinks(s.resid2ResidhashHbond,s.resid2ResidhashHbond,i.htmlCls.hbondColor,t,i.htmlCls.hbondValue)}return a}exportSaltbridgePairs(e,t){var s=this.icn3d,i=s.icn3dui;let n="",l=0,r='    ';for(let t in s.resid2ResidhashSaltbridge){let i=s.getGraphCls.convertLabel2Resid(t),a=s.firstAtomObjCls.getFirstAtomObj(s.residues[i]),d=a.color?a.color.getHexString():"";for(let i in s.resid2ResidhashSaltbridge[t]){let a=s.getGraphCls.convertLabel2Resid(i),c=s.firstAtomObjCls.getFirstAtomObj(s.residues[a]),h=c.color?c.color.getHexString():"",p=Math.sqrt(s.resid2ResidhashSaltbridge[t][i]).toFixed(1);n+=' '+t+r+d+o+' '+i+r+h+o+''+p+"","view"==e&&(n+=''),n+="",++l}}let a='

    '+l+" salt bridge/ionic interaction pairs:

    ";if(l>0&&(a+="
    ","view"==e&&(a+=''),a+="",a+=n,a+="
    Atom 1Atom 2Distance(Å)Highlight in 3D

    "),"graph"==e||"linegraph"==e||"scatterplot"==e){return s.getGraphCls.getGraphLinks(s.resid2ResidhashSaltbridge,s.resid2ResidhashSaltbridge,i.htmlCls.ionicColor,t,i.htmlCls.ionicValue)}return a}exportHalogenPiPairs(e,t,s){var i=this.icn3d,n=i.icn3dui;let l,r,o,a="",d=0,c='    ';"halogen"==s?(l=i.resid2ResidhashHalogen,r=n.htmlCls.halogenColor,o=n.htmlCls.halogenValue):"pi-cation"==s?(l=i.resid2ResidhashPication,r=n.htmlCls.picationColor,o=n.htmlCls.picationValue):"pi-stacking"==s&&(l=i.resid2ResidhashPistacking,r=n.htmlCls.pistackingColor,o=n.htmlCls.pistackingValue);for(let t in l){let n=i.getGraphCls.convertLabel2Resid(t),r=i.firstAtomObjCls.getFirstAtomObj(i.residues[n]),o=r.color?r.color.getHexString():"";for(let n in l[t]){let r=i.getGraphCls.convertLabel2Resid(n),p=i.firstAtomObjCls.getFirstAtomObj(i.residues[r]),m=p.color?p.color.getHexString():"",u=Math.sqrt(l[t][n]).toFixed(1);a+=' '+t+c+o+h+' '+n+c+m+h+''+u+"","view"==e&&(a+=''),a+="",++d}}let p='

    '+d+" "+s+" pairs:

    ";if(d>0&&(p+="
    ","view"==e&&(p+=''),p+="",p+=a,p+="
    Atom 1Atom 2Distance(Å)Highlight in 3D

    "),"graph"==e||"linegraph"==e||"scatterplot"==e){return i.getGraphCls.getGraphLinks(l,l,r,t,o)}return p}exportSpherePairs(e,t,s){var i=this.icn3d,n=i.icn3dui;let l="",r=0,o=e?i.resid2ResidhashInteractions:i.resid2ResidhashSphere,a='    ';for(let s in o){let n=i.getGraphCls.convertLabel2Resid(s),c=i.firstAtomObjCls.getFirstAtomObj(i.residues[n]),h=c.color?c.color.getHexString():"";for(let n in o[s]){let p=i.getGraphCls.convertLabel2Resid(n),m=i.firstAtomObjCls.getFirstAtomObj(i.residues[p]),u=m.color?m.color.getHexString():"",g=o[s][n].split("_"),f=g[0],b=g[1];c=g[2],m=g[3];let C=g[4];e?(l+=' '+s+"@"+c+a+h+d+' '+n+"@"+m+a+u+d+''+C+''+f+''+b+"","view"==t&&(l+=''),l+=""):l+=""+s+""+n+''+C+''+f+''+b+"",++r}}let c='

    '+r+" residue pairs in "+(e?"the contacts":"sphere")+":

    ";if(r>0&&(e?(c+='
    ',"view"==t&&(c+=''),c+=""):c+='
    Residue 1Residue 2Num ContactsMin Distance(Å)C-alpha Distance(Å)Highlight in 3D
    ',c+=l,c+="
    Residue 1Residue 2Num ContactsMin Distance(Å)C-alpha Distance(Å)

    "),"graph"==t||"linegraph"==t||"scatterplot"==t||"calpha"==t||"cbeta"==t||"heavyatoms"==t){return i.getGraphCls.getGraphLinks(o,o,n.htmlCls.contactColor,s,n.htmlCls.contactValue)}return c}}class Ut{constructor(e){this.icn3d=e}drawGraph(e,t){var s=this.icn3d,i=s.icn3dui;if(void 0===n)var n=d3;var l=JSON.parse(e),r=$("#"+t).width(),o=$("#"+t).height(),a=isNaN(r)?300:1*r,d=isNaN(o)?300:1*o,c=r,h=o,p=d3.select("#"+i.svgid).attr("width",r).attr("height",o).attr("viewBox","0,0,"+a+","+d);p.selectAll(".g-main").remove();var m=p.append("g").classed("g-main",!0),u=m.append("rect").attr("width",c).attr("height",h).style("fill","#FFF"),g=m.append("g"),f=n.zoom().on("zoom",(function(){g.attr("transform",n.event.transform)}));if(m.call(f),l.links){for(var b=[],C={},y=0,v=l.nodes.length;y0?n.structures[0]:n.defaultPdbId;p=10*(a.length+2)+20+30,h=10*(d.length+2)+20+30,t?(n.alignerrormapWidth=2*h,u=n.alignerrormapWidth,m=l.alignerrormapid):(n.contactmapWidth=2*h,u=n.contactmapWidth,m=l.contactmapid),i=o.length>0?"":"No interactions found for these two sets

    ",i+="";if(t){n.hex2id={};let e=29/s;n.hex2skip={};let t=1e3;for(let s=0;se&&(n.hex2skip[d]=c)}}if(i+=n.lineGraphCls.drawScatterplot_base(a,d,o,c,0,!0,void 0,void 0,t),g+=n.getGraphCls.updateGraphJson(f,1,a,d,o),i+="",g+="}\n",t){n.alignerrormapStr=g,$("#"+n.pre+"alignerrormapDiv").html(i);let e=$("#"+l.alignerrormapid+"_scale").val();$("#"+l.alignerrormapid).attr("width",(n.alignerrormapWidth*parseFloat(e)).toString()+"px")}else n.contactmapStr=g,$("#"+n.pre+"contactmapDiv").html(i);return i}}class $t{constructor(e){this.icn3d=e}async downloadAlignment(e,t){let s=this.icn3d,i=s.icn3dui,n=this;s.opts.proteins="c alpha trace";let l=e.split(","),r="ids="+e,o=i.htmlCls.baseUrl+"vastplus/vastplus.cgi?v=3&cmd=c&b=1&s=1&w3d&"+r;void 0!==i.cfg.inpara&&(o+=i.cfg.inpara),s.pdbid_chain2title={},void 0===s.chainids2resids&&(s.chainids2resids={});let a={},d="These two MMDB IDs "+l+' do not have 3D alignment data in the VAST+ database. You can try the VAST alignment by visiting the VAST+ page https://www.ncbi.nlm.nih.gov/Structure/vastplus/vastplus.cgi?uid=[PDB ID] (e.g., uid=1KQ2), and clicking "Original VAST"',c=await i.getAjaxPromise(o,"jsonp",!0,d);if(a=c.seqalign,void 0===a)return alert(d),!1;s.pdbid_molid2chain={},s.chainsColor={};for(let e=0,t=2;e5){let t=!1,s=!0;d=await r.pdbParserCls.loadPdbData(e,n,!1,t,"target",h,s)}else{let t=!0;d=await r.mmdbParserCls.parseMmdbData(e,"target",i[0],0,h,t)}for(let e=0,s=t.length;e5){let s=!0,i=!0;c=await r.pdbParserCls.loadPdbData(t[e],l,!1,s,"query",h,i)}else{let s=!0;c=await r.mmdbParserCls.parseMmdbData(t[e],"query",i[e+1],e,h,s)}d=o.hashUtilsCls.unionHash(d,c)}if(o.cfg.resnum)await r.realignParserCls.realignChainOnSeqAlign(s,i);else if(o.cfg.resdef)await r.realignParserCls.realignChainOnSeqAlign(s,i,void 0,!0);else{await r.pdbParserCls.applyCommandDssp(!0);for(let e in r.pdbChainIndexHash){let t=r.pdbChainIndexHash[e].split("_");l=t[0],t[1],n=t[2],t[3],a.transformStructure(l,e-1,"query")}let e=[],t=[],c=[],h=o.htmlCls.baseUrl+"vastdyn/vastdyn.cgi",p=o.htmlCls.baseUrl+"tmalign/tmalign.cgi";for(let s in r.afChainIndexHash){let i=r.afChainIndexHash[s].split("_");l=i[0];let a=i[1];n=i[2];let d,m=i[3];if("tmalign"!=o.cfg.aligntool){let e={domains1:r.domain3dCls.getDomainJsonForAlign(r.chains[l+"_"+a]),domains2:r.domain3dCls.getDomainJsonForAlign(r.chains[n+"_"+m])};d=o.getAjaxPostPromise(h,e)}else{let e={pdb_query:r.saveFileCls.getAtomPDB(r.chains[l+"_"+a]),pdb_target:r.saveFileCls.getAtomPDB(r.chains[n+"_"+m])};d=o.getAjaxPostPromise(p,e)}e.push(d),t.push(s-1),c.push(l)}let m=Promise.allSettled(e);try{let e=await m;await a.downloadChainalignmentPart2b(s,i,d,e,t,n,c)}catch(e){r.bRender&&alert("These structures can NOT be aligned to each other...")}}}async downloadChainalignmentPart2b(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui;for(let e=0,t=i.length;ed&&(d=n[t[0]],o=t[0]),n[t[1]]>d&&(d=n[t[1]],o=t[1])}let c={},h={},p={},m={};for(let e in l){let t,s,i=e.split("_"),n=l[e].split(","),r=n[2];o==i[0]?(t=i[0],s=i[1]):o==i[1]?(t=i[1],s=i[0]):(t=i[0],s=i[1]),p[t]=1,p.hasOwnProperty(s)||(p[s]=1,m[e]=l[e],a="target",this.transformStructure(t,r,a),a="query",this.transformStructure(s,r,a),c[n[0]]=1,c[n[1]]=1)}for(let e in m)if(void 0!==s.q_rotation){let t=m[e].split(","),n=[t[1],t[0],t[2]],l=s.setSeqAlignCls.setSeqAlignChain(void 0,void 0,n);h=i.hashUtilsCls.unionHash(h,l);let r=!1,o=i.htmlCls.alignSeqCls.getAlignSequencesAnnotations(Object.keys(s.alnChains),void 0,void 0,!1,void 0,r),a=$("#"+s.pre+"dl_sequence2").html();$("#"+s.pre+"dl_sequence2").html(a+o.sequencesHtml),$("#"+s.pre+"dl_sequence2").width(i.htmlCls.RESIDUE_WIDTH*o.maxSeqCnt+200)}s.dAtoms=i.hashUtilsCls.cloneHash(h),s.hAtoms=i.hashUtilsCls.cloneHash(h);let u="protein_aligned";s.selectionCls.saveSelection(u,u),s.opts.color="identity",s.setColorCls.setColorByOptions(s.opts,s.hAtoms),i.htmlCls.dialogCls.openDlg("dl_alignment","Select residues in aligned sequences"),s.drawCls.draw(),s.transformCls.zoominSelection(),s.hlUpdateCls.updateHlAll()}transformStructure(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=n.structures[e];for(let e=0,o=r.length;e2){let e=i.firstAtomObjCls.getResiduesFromAtoms(s),t="protein_aligned",n="protein aligned",l="select "+i.resid2specCls.residueids2spec(Object.keys(e));i.selectionCls.addCustomSelection(Object.keys(e),t,n,l,!0)}i.hlUpdateCls.updateHlAll(),void 0!==n.cfg.rotate&&i.resizeCanvasCls.rotStruc(n.cfg.rotate,!0),i.html2ddgm="",n.cfg.show2d&&i.bFullUi&&(n.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions"),i.bFullUi&&(i.bChainAlign?await i.ParserUtilsCls.set2DDiagramsForChainalign(t):i.ParserUtilsCls.download2Ddgm(i.inputid.toUpperCase())))}addPostfixForChainids(e){let t=this.icn3d;t.icn3dui;let s={};for(let i=0,n=e.length;i5?(c="https://alphafold.ebi.ac.uk/files/AF-"+i.mmdbid_t+"-F1-model_"+i.AFUniprotVersion+".pdb",d=n.getAjaxPromise(c,"text")):(c=n.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+n.cfg.bu+"&uid="+i.mmdbid_t,void 0!==n.cfg.inpara&&(c+=n.cfg.inpara),d=n.getAjaxPromise(c,"jsonp")),h.push(d),i.ParserUtilsCls.setYourNote(e.toUpperCase()+" in iCn3D"),i.pdbid_chain2title={},void 0===i.chainids2resids&&(i.chainids2resids={}),i.afChainIndexHash={},i.pdbChainIndexHash={};for(let e=1,t=r.length;e5?(t="https://alphafold.ebi.ac.uk/files/AF-"+i.mmdbid_q+"-F1-model_"+i.AFUniprotVersion+".pdb",s=n.getAjaxPromise(t,"text")):(t=n.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+n.cfg.bu+"&uid="+i.mmdbid_q,void 0!==n.cfg.inpara&&(t+=n.cfg.inpara),s=n.getAjaxPromise(t,"jsonp")),h.push(s)}for(let e=1,t=r.length;e0?o[e]+","+o[0]:void 0;if("tmalign"!=n.cfg.aligntool&&4==i.mmdbid_t.length&&4==i.mmdbid_q.length){let r;r=o.length>0?n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?domainpairs="+l:n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainpairs="+t;let a=n.getAjaxPromise(r,"jsonp");h.push(a),i.pdbChainIndexHash[e]=s+"_"+i.chain_q+"_"+i.mmdbid_t+"_"+i.chain_t}else i.afChainIndexHash[e]=i.mmdbid_q+"_"+i.chain_q+"_"+i.mmdbid_t+"_"+i.chain_t}}let p=Promise.allSettled(h);try{let e=await p;await l.parseChainAlignData(e,r,i.mmdbid_t,i.chain_t)}catch(e){let t="tmalign"==n.cfg.aligntool?"TM-align":"VAST";i.bRender&&alert("These chains can not be aligned by "+t+". You can specify the residue range and try it again...")}}async parseChainAlignData(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=e[0].value,o="HEADER "+s+"\n";isNaN(s)&&s.length>5&&(r=o+r),n.t_trans_add=[],n.q_trans_sub=[],"tmalign"==l.cfg.aligntool&&(n.q_trans_add=[]),n.q_rotation=[],n.qt_start_end=[],n.mmdbidArray=[],n.mmdbidArray.push(s);let a=[];for(let s=1,i=t.length;s5&&(i=o+i),void 0===i||-1!==JSON.stringify(i).indexOf("Oops there was a problem"))return void alert("The coordinate data can NOT be retrieved for the structure "+r+"...");n.mmdbidArray.push(r),a.push(i)}let d=0;for(let r=1,o=t.length;r";"tmalign"==o.cfg.aligntool&&(n+="TM-score: "+e[0].score.toPrecision(4)+"

    "),$("#"+r.pre+"dl_rmsd").html(n),o.cfg.bSidebyside||o.htmlCls.dialogCls.openDlg("dl_rmsd","RMSD of alignment"),a=!0}return a}async loadOpmDataForChainalign(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=this;if(l.cfg.resnum||l.cfg.resdef)n.bCommandLoad||n.init(),await this.downloadChainalignmentPart2(e,t,void 0,s);else{let o=l.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?mmdbids2opm="+i.join("','");try{let i=(await l.getAjaxPromise(o,"jsonp")).mmdbid;if(n.selectedPdbid=i,i){let o="https://opm-assets.storage.googleapis.com/pdb/"+i.toLowerCase()+".pdb";try{let a=await l.getAjaxPromise(o,"text");n.bOpm=!0;let d=!0,c=n.loadPDBCls.loadPDB(a,i,n.bOpm,d);$("#"+n.pre+"selectplane_z1").val(n.halfBilayerSize),$("#"+n.pre+"selectplane_z2").val(-n.halfBilayerSize),$("#"+n.pre+"extra_mem_z").val(n.halfBilayerSize),$("#"+n.pre+"intra_mem_z").val(-n.halfBilayerSize),n.bCommandLoad||n.init(),await r.downloadChainalignmentPart2(e,t,c,s)}catch(i){return n.bCommandLoad||n.init(),void await r.downloadChainalignmentPart2(e,t,void 0,s)}}else n.bCommandLoad||n.init(),await r.downloadChainalignmentPart2(e,t,void 0,s)}catch(i){return n.bCommandLoad||n.init(),void await r.downloadChainalignmentPart2(e,t,void 0,s)}}}async downloadMmdbAf(e,t,s){let i=this.icn3d,n=i.icn3dui,l=this;i.structArray=i.structures?Object.keys(i.structures):[],0==i.structArray.length?i.init():(i.resetConfig(),i.bResetAnno=!0,i.bResetSets=!0);let r=e.split(","),o=[];for(let e=0,t=r.length;e5?(t="https://alphafold.ebi.ac.uk/files/AF-"+l+"-F1-model_"+i.AFUniprotVersion+".pdb",s=n.getAjaxPromise(t,"text")):(t=n.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+n.cfg.bu+"&uid="+l,void 0!==n.cfg.inpara&&(t+=n.cfg.inpara),s=n.getAjaxPromise(t,"jsonp")),a.push(s)}i.ParserUtilsCls.setYourNote(i.structArray+" in iCn3D"),i.ParserUtilsCls.showLoading();let d=Promise.allSettled(a);try{let e=await d;await l.parseMMdbAfData(e,o,t,s),void 0===s&&i.ParserUtilsCls.hideLoading()}catch(e){alert("There are some problems in retrieving the coordinates...")}}async parseMMdbAfData(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=[];for(let s=0,i=t.length;s5&&(i=n+i),void 0===i||-1!==JSON.stringify(i).indexOf("Oops there was a problem"))return void alert("The coordinate data can NOT be retrieved for the structure "+t[s]+"...");r.push(i)}let o={},a={},d=!1;n.opts.color=n.structArray.length>1?"structure":t[0].length>5?"confidence":"chain";for(let e=0,i=t.length;e5){let s=!1;a=await n.pdbParserCls.loadPdbData(r[e],t[e],!1,c,i,d,s)}else{let t=!0;a=await n.mmdbParserCls.parseMmdbData(r[e],i,void 0,void 0,d,t)}o=l.hashUtilsCls.unionHash(o,a)}if(n.structArray.length>1&&(n.opts.color="structure"),n.setColorCls.setColorByOptions(n.opts,n.atoms),await n.ParserUtilsCls.renderStructure(),void 0!==l.cfg.rotate&&n.resizeCanvasCls.rotStruc(l.cfg.rotate,!0),s&&l.cfg.matchedchains){let e=!0,t=!0;await n.realignParserCls.realignChainOnSeqAlign(void 0,n.chainidArray,e,t),$("#"+n.pre+"dl_annotations").html(""),n.bAnnoShown=!1,$("#"+n.pre+"dl_selectannotations").dialog("isOpen")&&$("#"+n.pre+"dl_selectannotations").dialog("close")}else if(void 0!==i){let e=Object.keys(n.structures);await n.vastplusCls.vastplusAlign(e,i)}}}class Bt{constructor(e){this.icn3d=e}dsn6Parser(e,t,s){this.icn3d.icn3dui;let i="https://edmaps.rcsb.org/maps/"+e.toLowerCase()+"_"+t+".dsn6";this.dsn6ParserBase(i,t,s)}dsn6ParserBase(e,t,s){let i=this.icn3d;i.icn3dui;let n=this;if("2fofc"==t&&i.bAjax2fofc)i.mapData.sigma2=s,i.setOptionCls.setOption("map",t);else if("fofc"==t&&i.bAjaxfofc)i.mapData.sigma=s,i.setOptionCls.setOption("map",t);else{let l=new XMLHttpRequest;l.open("GET",e,!0),l.responseType="arraybuffer",l.onreadystatechange=function(){if(4==this.readyState)if(200==this.status){let e=l.response;n.loadDsn6Data(e,t,s),"2fofc"==t?i.bAjax2fofc=!0:"fofc"==t&&(i.bAjaxfofc=!0),i.setOptionCls.setOption("map",t)}else alert("RCSB server has no corresponding eletron density map for this structure.");else i.ParserUtilsCls.showLoading()},l.send()}}loadDsn6Data(e,t,s){let i=this.icn3d;i.icn3dui;let n,l,r={},o=e.buffer&&e.buffer instanceof ArrayBuffer?e.buffer:e,a=new Int16Array(o),d=new Uint8Array(o),c=String.fromCharCode.apply(null,d.subarray(0,512));if(0==c.indexOf(":-)"))r.xStart=parseInt(c.substr(10,5)),r.yStart=parseInt(c.substr(15,5)),r.zStart=parseInt(c.substr(20,5)),r.xExtent=parseInt(c.substr(32,5)),r.yExtent=parseInt(c.substr(38,5)),r.zExtent=parseInt(c.substr(42,5)),r.xRate=parseInt(c.substr(52,5)),r.yRate=parseInt(c.substr(58,5)),r.zRate=parseInt(c.substr(62,5)),r.xlen=1*parseFloat(c.substr(73,10)),r.ylen=1*parseFloat(c.substr(83,10)),r.zlen=1*parseFloat(c.substr(93,10)),r.alpha=parseFloat(c.substr(103,10)),r.beta=parseFloat(c.substr(113,10)),r.gamma=parseFloat(c.substr(123,10)),n=parseFloat(c.substr(138,12))/100,l=parseInt(c.substr(155,8)),r.sigma=100*parseFloat(c.substr(170,12));else{if(100!==a[18])for(let e=0,t=a.length;e>8&255}r.zStart=a[2],r.xStart=a[0],r.yStart=a[1],r.xExtent=a[3],r.yExtent=a[4],r.zExtent=a[5],r.xRate=a[6],r.yRate=a[7],r.zRate=a[8];let e=1/a[17],t=1*e;r.xlen=a[9]*t,r.ylen=a[10]*t,r.zlen=a[11]*t,r.alpha=a[12]*e,r.beta=a[13]*e,r.gamma=a[14]*e,n=a[15]/a[18],l=a[16]}let h=new Float32Array(r.xExtent*r.yExtent*r.zExtent),p=512,m=Math.ceil(r.xExtent/8),u=Math.ceil(r.yExtent/8),g=Math.ceil(r.zExtent/8);for(let e=0;es.maxatomcnt&&(s.bAssembly=!0)}if("mmtfid"===t&&void 0!==o.missingseq){let t=0,n="";for(let l=0,r=o.missingseq.length;lt)&&(s.chainMissingResidueArray[c].push(h),t=d,n=a)}s.loadPDBCls.adjustSeq(s.chainMissingResidueArray)}}async loadMmcifData(e,t){let s=this.icn3d;if(s.icn3dui,t||(t=e.mmcif),t||(t=s.defaultPdbId),void 0===e.atoms)return!1;s.init(),void 0!==e.emd&&(s.emd=e.emd),void 0!==e.organism&&(s.organism=e.organism),void 0!==s.emd?($("#"+s.pre+"mapWrapper1").hide(),$("#"+s.pre+"mapWrapper2").hide(),$("#"+s.pre+"mapWrapper3").hide()):($("#"+s.pre+"emmapWrapper1").hide(),$("#"+s.pre+"emmapWrapper2").hide(),$("#"+s.pre+"emmapWrapper3").hide()),await s.opmParserCls.loadOpmData(e,t,void 0,"mmcif")}}class Gt{constructor(e){this.icn3d=e}async downloadMmdb(e,t){let s,i=this.icn3d,n=i.icn3dui;try{if(s=await this.loadMmdbPrms(e,t),!s||s.error)return void this.getNoData(e,t)}catch(s){return void this.getNoData(e,t)}if(0!=Object.keys(s.atoms).length)if(n.utilsCls.isCalphaPhosOnly(s.atoms)||s.atomCount<=i.maxatomcnt)await this.parseMmdbData(s);else{let s;try{s=await this.loadMmdbPrms(e,t,!0)}catch(s){return void this.getNoData(e,t)}await this.parseMmdbData(s)}else{let e=s.pdbId;i.mmtfParserCls.downloadMmtf(e)}}async downloadGi(e){let t=this.icn3d;t.icn3dui,t.bCid=void 0;await this.downloadMmdb(e,!0)}async downloadBlast_rep_id(e){let t=this.icn3d,s=t.icn3dui,i=e.split(",");s.cfg.query_id=i[0],s.cfg.blast_rep_id=i[1];let n=s.cfg.blast_rep_id.split("_")[0];4==n.length?await this.downloadMmdb(n):(t.blastAcxn=s.cfg.blast_rep_id.split(".")[0],await this.downloadRefseq(t.blastAcxn,!0))}async downloadRefseq(e,t){let s=this.icn3d,i=s.icn3dui,n=i.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?refseq2uniprot="+e;i.cfg.refseqid=e;let l=await i.getAjaxPromise(n,"jsonp",!1,"The protein accession "+e+" can not be mapped to AlphaFold UniProt ID...");if(!l||!l.uniprot)return void alert("The accession "+e+" can not be mapped to AlphaFold UniProt ID. It will be treated as a UniProt ID instead.");i.cfg.afid=l.uniprot,t&&(i.cfg.blast_rep_id=i.cfg.afid+"_A");await s.pdbParserCls.downloadPdb(i.cfg.afid,!0)}getNoData(e,t){let s=this.icn3d.icn3dui;t?alert("This gi "+e+" has no corresponding 3D structure..."):alert("This mmdbid "+e+" with the parameters "+s.cfg.inpara+" may not have 3D structure data. Please visit the summary page for details: "+s.htmlCls.baseUrl+"pdb/"+e)}async parseMmdbData(e,t,s,i,n,l){let r,o=this.icn3d,a=o.icn3dui,d=void 0!==e.pdbId?e.pdbId:e.mmdbId;this.parseMmdbDataPart1(e,t),void 0===t?(void 0!==e.opm&&void 0!==e.opm.rot&&(o.bOpm=!0,o.opmParserCls.setOpmData(e)),r=o.loadAtomDataCls.loadAtomDataIn(e,d,"mmdbid",void 0,t)):(s&&(d=s.substr(0,s.indexOf("_"))),r=o.loadAtomDataCls.loadAtomDataIn(e,d,"mmdbid",void 0,t,s,i,n,l));let c=e.pdbId;void 0===t&&o.ParserUtilsCls.setYourNote(c.toUpperCase()+"(MMDB) in iCn3D");for(let t in e.domains){let s=e.domains[t].chain,i=c+"_"+s,n=e.domains[t].domains;for(let e=0,t=n.length;et.maxatomcnt){let i=!1;if(0==Object.keys(s).length)return void alert("This PDB structure is not found at RCSB...");await t.opmParserCls.loadOpmData(s,e,i,"mmtf")}else s=null,MMTF.fetch(e,(async function(s){0!=Object.keys(s).length?await t.opmParserCls.loadOpmData(s,e,!0,"mmtf"):alert("This PDB structure is not found at RCSB...")}),(function(e){}))}),(function(e){}))}async parseMmtfData(e,t,s){let i=this.icn3d,n=i.icn3dui;e.numAtoms,i.init();let l=new THREE.Vector3(9999,9999,9999),r=new THREE.Vector3(-9999,-9999,-9999),o=new THREE.Vector3,a=e.structureId;if(i.molTitle=e.title,void 0!==e.bioAssemblyList&&void 0!==e.bioAssemblyList[0]&&e.bioAssemblyList[0].transformList.length>1){i.biomtMatrices=[];for(let t=0,s=e.bioAssemblyList[0].transformList.length;t1&&($("#"+i.pre+"assemblyWrapper").show(),i.asuCnt=i.biomtMatrices.length);let d,c,h,p,m,u,g,f,b,C,y,v,w,_,S,A,x,k,O,R={},E=[],I="coil",T="",M=0,P=0,D={onModel:function(e){d=0===e.modelIndex?a:a+(e.modelIndex+1).toString()},onChain:function(e){c=e.chainName;let t=d+"_"+c;void 0===i.structures[d]&&(i.structures[d]=[]),i.structures[d].push(t)},onGroup:function(e){h=e.groupName,p=e.groupId;let t=d+"_"+c+"_"+p;m=0===e.secStruct||2===e.secStruct||4===e.secStruct?"helix":3===e.secStruct?"sheet":-1===e.secStruct?"other":"coil";let s=!1;if(c!==T){if(x=void 0,O=void 0,"coil"!==m&&"other"!==m?(u=!0,g=!1):(u=!1,g=!1),"coil"!==I&&"other"!==I){let e=d+"_"+T+"_"+M.toString();for(let t in i.residues[e])i.atoms[t].ssbegin=!1,i.atoms[t].ssend=!0}}else x=A,O=k,m!==I?"coil"===I||"other"===I?(u=!0,g=!1):"coil"===m||"other"===m?(s=!0,u=!1,g=!1):("sheet"===I&&"helix"===m||"helix"===I&&"sheet"===m)&&(s=!0,u=!0,g=!1):(u=!1,g=!1);if(s&&!isNaN(p)){let e=d+"_"+c+"_"+(p-1).toString();for(let t in i.residues[e])i.atoms[t].ssbegin=!1,i.atoms[t].ssend=!0}I=m,T=c,M=p,f=!1,b=!1,C=!1,"non-polymer"===e.chemCompType.toLowerCase()||"other"===e.chemCompType.toLowerCase()||-1!==e.chemCompType.toLowerCase().indexOf("saccharide")?f=!0:-1!==e.chemCompType.toLowerCase().indexOf("peptide")?b=!0:-1!==e.chemCompType.toLowerCase().indexOf("dna")||-1!==e.chemCompType.toLowerCase().indexOf("rna")?C=!0:b=!0;let l=d+"_"+c,r={};r.resi=p,r.name=n.utilsCls.residueName2Abbr(h),i.residueId2Name[t]=r.name,r.resi%10==0&&r.resi.toString();let o="-";"helix"===m?o="H":"sheet"===m?o="E":"coil"===m?o="c":"other"===m&&(o="o"),void 0===i.chainsSeq[l]&&(i.chainsSeq[l]=[]),i.bFullUi&&i.chainsSeq[l].push(r),i.secondaries[t]=o},onAtom:function(e){if(y=e.element,v=e.atomName,w=new THREE.Vector3(e.xCoord,e.yCoord,e.zCoord),_=e.bFactor,S=e.altLoc,"\0"===e.altLoc&&(S=""),""===S||"A"===S){++P,"SG"===v&&E.push(P),R[e.atomIndex]=P;let t={het:f,serial:P,name:v,alt:S,resn:h,structure:d,chain:c,resi:p,coord:w,b:_,elem:y,bonds:[],bondOrder:[],ss:m,ssbegin:u,ssend:g};if(t.het||"C"!==t.name||(A=P),t.het||"O"!==t.name||(k=P),!t.het&&"N"===t.name&&void 0!==x&&void 0!==O){let e=i.atoms[x].coord.distanceTo(i.atoms[O].coord),s=t.coord.x+(i.atoms[x].coord.x-i.atoms[O].coord.x)/e,n=t.coord.y+(i.atoms[x].coord.y-i.atoms[O].coord.y)/e,l=t.coord.z+(i.atoms[x].coord.z-i.atoms[O].coord.z)/e;t.hcoord=new THREE.Vector3(s,n,l)}i.atoms[P]=t,l.min(w),r.max(w),o.add(w);let a=d+"_"+c,I=a+"_"+p;void 0===i.chains[a]&&(i.chains[a]={}),i.chains[a][P]=1,void 0===i.residues[I]&&(i.residues[I]={}),i.residues[I][P]=1,b?(i.proteins[P]=1,"CA"===v&&(i.calphas[P]=1),"N"!==v&&"H"!==v&&"CA"!==v&&"HA"!==v&&"C"!==v&&"O"!==v&&(i.sidec[P]=1)):C?(i.nucleotides[P]=1,(!s||"O3'"!=v&&"O3*"!=v)&&(s||"P"!=v)||(i.nucleotidesO3[P]=1),-1===n.parasCls.nuclMainArray.indexOf(v)&&(i.ntbase[P]=1)):y.toLowerCase()===h.toLowerCase()?i.ions[P]=1:"HOH"===h||"WAT"===h||"SQL"===h||"H2O"===h||"W"===h||"DOD"===h||"D3O"===h?i.water[P]=1:i.chemicals[P]=1,i.dAtoms[P]=1,i.hAtoms[P]=1}},onBond:function(e){let t=R[e.atomIndex1],s=R[e.atomIndex2];if(R.hasOwnProperty(e.atomIndex1)&&R.hasOwnProperty(e.atomIndex2)&&(i.atoms[t].bonds.push(s),i.atoms[s].bonds.push(t),f)){let n=e.bondOrder;i.atoms[t].bondOrder.push(n),i.atoms[s].bondOrder.push(n),2===n?(i.doublebonds[t+"_"+s]=1,i.doublebonds[s+"_"+t]=1):3===n&&(i.triplebonds[t+"_"+s]=1,i.triplebonds[s+"_"+t]=1)}}};MMTF.traverse(e,D),i.loadPDBCls.setResidMapping();for(let e=0,t=E.length;ei.maxatomcnt||void 0!==i.biomtMatrices&&i.biomtMatrices.length*i.cnt>10*i.maxatomcnt)&&(i.opts.proteins="c alpha trace",i.opts.nucleotides="o3 trace"),i.pmin=l,i.pmax=r,i.center=i.ParserUtilsCls.getGeoCenter(i.pmin,i.pmax),i.maxD=i.ParserUtilsCls.getStructureSize(i.atoms,i.pmin,i.pmax,i.center),i.maxD<5&&(i.maxD=5),i.oriMaxD=i.maxD,i.oriCenter=i.center.clone(),i.ParserUtilsCls.transformToOpmOri(t),void 0===n.cfg.align&&1==Object.keys(i.structures).length&&$("#"+i.pre+"alternateWrapper").hide(),i.setStyleCls.setAtomStyleByOptions(i.opts),i.setColorCls.setColorByOptions(i.opts,i.atoms),await i.ParserUtilsCls.renderStructure(),i.saveFileCls.showTitle(),void 0!==n.cfg.rotate&&i.resizeCanvasCls.rotStruc(n.cfg.rotate,!0)}}class Wt{constructor(e){this.icn3d=e}async loadMol2Data(e){let t=this.icn3d,s=t.icn3dui,i=this.loadMol2AtomData(e);void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),i?(t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.atoms),await t.ParserUtilsCls.renderStructure(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0)):alert("The Mol2 file has the wrong format...")}loadMol2AtomData(e){let t=this.icn3d;t.icn3dui;let s=e.split(/\r?\n|\r/);if(s.length<4)return!1;t.init();let i,n,l="LIG",r={},o="1_A",a=0,d=0,c=1,h=!1,p=!1,m={},u={};for(let e=0,o=s.length;eMOLECULE"==o){t.molTitle=s[e+1].trim();let l=s[e+2].trim().replace(/\s+/g," ").split(" ");i=l[0],n=l[1],e+=4}else"@ATOM"==o?(c=1,h=!0,++e):"@BOND"==o?(p=!0,h=!1,++e):"@SUBSTRUCTURE"==o&&(p=!1,++e);if(o=s[e].trim(),""!==o&&"#"!==o.substr(0,1)){if(h&&a1&&($("#"+l.pre+"assemblyWrapper").show(),l.asuCnt=l.biomtMatrices.length),l.setStyleCls.setAtomStyleByOptions(l.opts),l.setColorCls.setColorByOptions(l.opts,l.atoms),await l.ParserUtilsCls.renderStructure(),void 0!==r.cfg.rotate&&l.resizeCanvasCls.rotStruc(r.cfg.rotate,!0)}else"pdb"===i?await l.pdbParserCls.loadPdbData(e,t):"align"===i&&(l.bOpm?await l.alignParserCls.downloadAlignmentPart2(t):void 0!==n?await this.loadOpmData(e,n,s,i):await l.alignParserCls.downloadAlignmentPart2(t))}}class Xt{constructor(e){this.icn3d=e}async downloadPdb(e,t){let s,i=this.icn3d,n=i.icn3dui;t?(s="https://alphafold.ebi.ac.uk/files/AF-"+e+"-F1-model_"+i.AFUniprotVersion+".pdb",n.cfg.refseqid?i.ParserUtilsCls.setYourNote(n.cfg.refseqid.toUpperCase()+"(NCBI Protein Acc.) in iCn3D"):i.ParserUtilsCls.setYourNote(e.toUpperCase()+"(AlphaFold) in iCn3D")):(s="https://files.rcsb.org/view/"+e+".pdb",i.ParserUtilsCls.setYourNote(e.toUpperCase()+"(PDB) in iCn3D"));let l=await n.getAjaxPromise(s,"text",!0,"The ID "+e+" can not be found in the server "+s+"...");if(t){l="HEADER "+e+"\n"+l,await i.opmParserCls.parseAtomData(l,e,void 0,"pdb",void 0)}else await i.opmParserCls.loadOpmData(l,e,void 0,"pdb")}async downloadUrl(e,t,s){let i=this.icn3d,n=i.icn3dui,l=e.lastIndexOf("/");if(-1!=l){let t=e.lastIndexOf(".");i.filename=e.substr(l+1,t-l-1)}else{let t=e.lastIndexOf(".");i.filename=e.substr(0,t)}let r=await n.getAjaxPromise(e,"text",!0);if(i.InputfileData=i.InputfileData?i.InputfileData+"\nENDMDL\n"+r:r,i.InputfileType=t,"pdb"===t)await this.loadPdbData(r);else if("mmcif"===t){let e=n.htmlCls.baseUrl+"mmcifparser/mmcifparser.cgi",t={mmciffile:r},s=await n.getAjaxPostPromise(e,t,!0);await i.mmcifParserCls.loadMmcifData(s,void 0)}else if("mol2"===t)await i.mol2ParserCls.loadMol2Data(r);else if("sdf"===t)await i.sdfParserCls.loadSdfData(r);else if("xyz"===t)await i.xyzParserCls.loadXyzData(r);else if("mmcif"===t)await i.mmcifParserCls.loadMmcifData(r);else if("icn3dpng"===t)await n.htmlCls.setHtmlCls.loadPng(r,s);else if("pae"===t){n.htmlCls.dialogCls.openDlg("dl_alignerrormap","Show Predicted Aligned Error (PAE) map");let e=!0;i.contactMapCls.processAfErrorMap(JSON.parse(r),e)}}async loadPdbData(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui;if(!i&&(void 0===n||"target"===n)){let e=!!o.bCommandLoad;o.bStatefile||o.init(e)}let d=o.loadPDBCls.loadPDB(e,t,s,void 0,void 0,i,n,l);void 0===a.cfg.opmid&&o.ParserUtilsCls.transformToOpmOri(t),void 0!==o.biomtMatrices&&o.biomtMatrices.length>1&&(a.bNode||$("#"+o.pre+"assemblyWrapper").show(),o.asuCnt=o.biomtMatrices.length),a.bNode||(void 0!==o.emd?($("#"+o.pre+"mapWrapper1").hide(),$("#"+o.pre+"mapWrapper2").hide(),$("#"+o.pre+"mapWrapper3").hide()):($("#"+o.pre+"emmapWrapper1").hide(),$("#"+o.pre+"emmapWrapper2").hide(),$("#"+o.pre+"emmapWrapper3").hide()));let c=!1;return o.bSecondaryStructure&&1==Object.keys(o.structures).length?c=!1:a.cfg.mmtfid||a.cfg.pdbid||a.cfg.opmid||a.cfg.mmdbid||a.cfg.gi||a.cfg.uniprotid||a.cfg.blast_rep_id||a.cfg.cid||a.cfg.mmcifid||a.cfg.align||a.cfg.chainalign||(c=!0),(!o.bSecondaryStructure||c)&&Object.keys(o.proteins).length>0&&!r?await this.applyCommandDssp(i):(await this.loadPdbDataRender(i),a.bNode||await o.ParserUtilsCls.checkMemProteinAndRotate()),d}async applyCommandDssp(e){let t=this.icn3d,s=t.icn3dui,i=s.utilsCls.isCalphaPhosOnly(s.hashUtilsCls.hash2Atoms(t.proteins,t.atoms));await t.dsspCls.applyDssp(i,e)}async loadPdbDataRender(e){let t=this.icn3d,s=t.icn3dui;void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),s.cfg.afid&&!t.bAfMem&&(t.opts.color="confidence"),t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.hAtoms),await t.ParserUtilsCls.renderStructure(),t.saveFileCls.showTitle(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0),e&&t.definedSetsCls.setModeAndDisplay("all")}}class Kt{constructor(e){this.icn3d=e}async downloadCid(e){let t=this.icn3d,s=t.icn3dui;t.ParserUtilsCls.setYourNote("PubChem CID "+e+" in iCn3D"),t.bCid=!0;let i="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/"+t.inputid+"/cids/JSONP?cids_type=parent",n="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/"+(await s.getAjaxPromise(i,"jsonp",!0,"Can not retrieve the parant CID...")).IdentifierList.CID[0]+"/record/SDF/?record_type=3d&response_type=display",l=await s.getAjaxPromise(n,"text",!0,"This CID may not have 3D structure..."),r=this.loadSdfAtomData(l,e);void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),r?(t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.atoms),await t.ParserUtilsCls.renderStructure(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0)):alert("The SDF of CID "+e+" has the wrong format...")}async loadSdfData(e){let t=this.icn3d,s=t.icn3dui,i=this.loadSdfAtomData(e);void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),i?(t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.atoms),await t.ParserUtilsCls.renderStructure(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0)):alert("The SDF file has the wrong format...")}loadSdfAtomData(e,t){let s=this.icn3d;s.icn3dui;let i=e.split(/\r?\n|\r/);if(i.length<4)return!1;s.init();let n=t||1,l="LIG",r=n,o=n+"_A",a=o+"_1",d=parseInt(i[3].substr(0,3));if(isNaN(d)||d<=0)return!1;let c=parseInt(i[3].substr(3,3)),h=4;if(i.lengthr||(Math.abs(t.coord.y-i.coord.y)>r||Math.abs(t.coord.z-i.coord.z)>r||l.utilsCls.hasCovalentBond(t,i)&&(n.atoms[o[e]].bonds.push(o[s]),n.atoms[o[s]].bonds.push(o[e])))}}}loadXyzAtomData(e){let t=this.icn3d;t.icn3dui;let s=e.split(/\r?\n|\r/);if(s.length<3)return!1;t.init();let i,n,l,r={},o=0,a=1;t.molTitle="";for(let e=0,d=s.length;e1&&(t.molTitle+="; "),t.molTitle+=s[e+1].trim(),e+=2),d=s[e].trim(),""===d)continue;let c=d.replace(/,/," ").replace(/\s+/g," ").split(" "),h=c[0],p=parseFloat(c[1]),m=parseFloat(c[2]),u=parseFloat(c[3]),g={het:!0,serial:a,name:h,resn:"LIG",structure:l,chain:"A",resi:1,coord:new THREE.Vector3(p,m,u),b:0,elem:h,bonds:[],ss:"coil",ssbegin:!1,ssend:!1,bondOrder:[]};t.atoms[a]=g,r[a]=1,++a}return this.setXyzAtomSeq(r,o,i,n),t.ParserUtilsCls.setMaxD(),t.saveFileCls.showTitle(),!0}}class Jt{constructor(e){this.icn3d=e}realign(){let e=this.icn3d,t=e.icn3dui;e.selectionCls.saveSelectionPrep();let s="alseq_"+Object.keys(e.defNames2Atoms).length;e.selectionCls.saveSelection(s,s),t.htmlCls.clickMenuCls.setLogCmd("realign",!0);let i={},n={};e.realignResid={};let l="";for(let s in e.hAtoms){let r=e.atoms[s],o=r.structure+"_"+r.chain;if(e.proteins.hasOwnProperty(s)&&"CA"==r.name||e.nucleotides.hasOwnProperty(s)&&("O3'"==r.name||"O3*"==r.name)){if(r.structure+"_"+r.resi==l)continue;i.hasOwnProperty(r.structure)||(i[r.structure]=[]),i[r.structure].push(r.coord.clone()),e.realignResid.hasOwnProperty(o)||(e.realignResid[o]=[]),e.realignResid[o].push({resid:o+"_"+r.resi,resn:t.utilsCls.residueName2Abbr(r.resn.substr(0,3)).substr(0,1)}),n[r.structure]=r.structure+"_"+r.chain,l=r.structure+"_"+r.resi}}let r=Object.keys(i),o=r[0],a=[];e.qt_start_end=[],a.push(n[o]);for(let t=1,s=r.length;t5){let e=r.cfg.chainalign.split(",");e.length>0&&(l.hAtoms=l.definedSetsCls.getAtomsFromNameArray(e)),r.cfg.aligntool="tmalign",await l.realignParserCls.realignOnStructAlign()}else l.hAtoms=l.chainalignParserCls.setMsa(e),l.transformCls.zoominSelection(),await l.chainalignParserCls.downloadChainalignmentPart3(void 0,e,l.hAtoms)}async parseChainRealignData(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui,d=s[0].substr(0,s[0].indexOf("_"));r||(d=d.toUpperCase());let c={};o.realignResid={},o.opts.color="grey",o.setColorCls.setColorByOptions(o.opts,o.dAtoms),o.qt_start_end=[];for(let t=0,h=e.length;t=6&&C.length>=6&&!a.cfg.command&&o.bRender&&alert("These sequences can not be aligned to each other")):o.bRender&&alert("Please do not align residues in the same structure")}if(r){o.hAtoms=o.chainalignParserCls.setMsa(s);let e="protein_aligned";if(o.selectionCls.saveSelection(e,e),o.bAfMem?(o.selectionCls.selectAll_base(),o.opts.chemicals="stick",o.opts.color="confidence",o.setColorCls.setColorByOptions(o.opts,o.atoms)):(o.transformCls.zoominSelection(),o.dAtoms=a.hashUtilsCls.cloneHash(o.hAtoms),o.opts.color="identity",o.setColorCls.setColorByOptions(o.opts,o.hAtoms)),o.drawCls.draw(),o.hlUpdateCls.updateHlAll(),o.bAfMem){let e=new THREE.Vector3(1,0,0),t=-.5*Math.PI;o.transformCls.setRotation(e,t)}}else o.hAtoms=o.chainalignParserCls.setMsa(s),o.transformCls.zoominSelection(),await o.chainalignParserCls.downloadChainalignmentPart3(t,s,o.hAtoms)}async realignOnSeqAlign(e){let t=this.icn3d;t.icn3dui;let s=t.firstAtomObjCls.getChainsFromAtoms(t.hAtoms),i=Object.keys(s),n=[],l="";for(let e=0,t=i.length;ef&&(f=s)}}}return{data:n,min:g,max:f}}(e.getCategory("_volume_data_3d").getColumn("values"),o,n.sampleCount,l);return{name:n.name,spacegroup:function(e,t,s){let i=Math.PI/180*s[0],n=Math.PI/180*s[1],l=Math.PI/180*s[2],r=t[0],o=t[1],a=t[2],d=Math.cos(n),c=(Math.cos(i)-Math.cos(n)*Math.cos(l))/Math.sin(l),h=Math.sqrt(1-d*d-c*c);return{number:e,size:t,angles:s,basis:{x:[r,0,0],y:[Math.cos(l)*o,Math.sin(l)*o,0],z:[d*a,c*a,h*a]}}}(n.spacegroupNumber,n.cellSize,n.cellAngles),box:{origin:r(n.origin),dimensions:r(n.dimensions),sampleCount:o},data:a.data,valuesInfo:{min:a.min,max:a.max,mean:n.mean,sigma:n.sigma}}}BinaryParse(e){this.icn3d.icn3dui;let t=new Uint8Array(e),s=this.MessagePackParse({buffer:t,offset:0,dataView:new DataView(t.buffer)}),i=function(){function e(e){this.additionalData={},this.header=e.header,this.categoryList=e.categories.map((function(e){return new n(e)})),this.categoryMap=new Map;for(let e=0,t=this.categoryList;e=0;s--)t=c(t,e.encoding[s]);return t}function p(e){if(!e.data.data)return _UndefinedColumn;let t,s=h(e.data);return e.mask&&(t=h(e.mask)),s.buffer&&s.byteLength&&s.BYTES_PER_ELEMENT?t?new f(s,t):new g(s):t?new C(s,t):new b(s)}function m(e,t,s){let i=0,n=1;for(45===e.charCodeAt(t)&&(n=-1,t++);t9||s<0)return n*i|0;i=10*i+s|0}return n*i}function u(e,t,s){let i=1,n=0,l=0,r=1;for(45===e.charCodeAt(t)&&(i=-1,++t);t=0&&o<10)){if(-2===o){for(++t;t=0&&o<10))return 53===o||21===o?parseScientific(i*(n+l/r),e,t+1,s):i*(n+l/r);l=10*l+o,r*=10,++t}return i*(n+l/r)}if(53===o||21===o)return parseScientific(i*n,e,t+1,s);break}n=10*n+o,++t}return i*n}let g=function(){function e(e){this.data=e,this.isDefined=!0}return e.prototype.getString=function(e){return""+this.data[e]},e.prototype.getInteger=function(e){return 0|this.data[e]},e.prototype.getFloat=function(e){return 1*this.data[e]},e.prototype.stringEquals=function(e,t){return this.data[e]===u(t,0,t.length)},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return 0},e}(),f=function(){function e(e,t){this.data=e,this.mask=t,this.isDefined=!0}return e.prototype.getString=function(e){return 0===this.mask[e]?""+this.data[e]:null},e.prototype.getInteger=function(e){return 0===this.mask[e]?this.data[e]:0},e.prototype.getFloat=function(e){return 0===this.mask[e]?this.data[e]:0},e.prototype.stringEquals=function(e,t){return 0===this.mask[e]?this.data[e]===u(t,0,t.length):null==t},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return this.mask[e]},e}(),b=function(){function e(e){this.data=e,this.isDefined=!0}return e.prototype.getString=function(e){return this.data[e]},e.prototype.getInteger=function(e){let t=this.data[e];return m(t,0,t.length)},e.prototype.getFloat=function(e){let t=this.data[e];return u(t,0,t.length)},e.prototype.stringEquals=function(e,t){return this.data[e]===t},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return 0},e}(),C=function(){function e(e,t){this.data=e,this.mask=t,this.isDefined=!0}return e.prototype.getString=function(e){return 0===this.mask[e]?this.data[e]:null},e.prototype.getInteger=function(e){if(0!==this.mask[e])return 0;let t=this.data[e];return m(t||"",0,(t||"").length)},e.prototype.getFloat=function(e){if(0!==this.mask[e])return 0;let t=this.data[e];return u(t||"",0,(t||"").length)},e.prototype.stringEquals=function(e,t){return this.data[e]===t},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return this.mask[e]},e}(),y=function(){function e(e){this.dataBlocks=e.dataBlocks.map((function(e){return new i(e)}))}return e.prototype.toJSON=function(){return this.dataBlocks.map((function(e){return e.toJSON()}))},e}();return new y(s)}MessagePackParse(e){this.icn3d.icn3dui;let t=this;function s(e,s){let i={};for(let n=0;n0&&(i[i.length]=l.slice(0,a).join(""));return i.join("")}(e.buffer,e.offset,t);return e.offset+=t,s}let r=function(){let e=[];for(let t=0;t<1024;t++)e[t]=String.fromCharCode(t);return e}();let o,a,d=e.buffer[e.offset];if(0==(128&d))return e.offset++,d;if(128==(240&d))return a=15&d,e.offset++,s(e,a);if(144==(240&d))return a=15&d,e.offset++,n(e,a);if(160==(224&d))return a=31&d,e.offset++,l(e,a);if(224==(224&d))return o=e.dataView.getInt8(e.offset),e.offset++,o;switch(d){case 192:return e.offset++,null;case 194:return e.offset++,!1;case 195:return e.offset++,!0;case 196:return a=e.dataView.getUint8(e.offset+1),e.offset+=2,i(e,a);case 197:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,i(e,a);case 198:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,i(e,a);case 202:return o=e.dataView.getFloat32(e.offset+1),e.offset+=5,o;case 203:return o=e.dataView.getFloat64(e.offset+1),e.offset+=9,o;case 204:return o=e.buffer[e.offset+1],e.offset+=2,o;case 205:return o=e.dataView.getUint16(e.offset+1),e.offset+=3,o;case 206:return o=e.dataView.getUint32(e.offset+1),e.offset+=5,o;case 208:return o=e.dataView.getInt8(e.offset+1),e.offset+=2,o;case 209:return o=e.dataView.getInt16(e.offset+1),e.offset+=3,o;case 210:return o=e.dataView.getInt32(e.offset+1),e.offset+=5,o;case 217:return a=e.dataView.getUint8(e.offset+1),e.offset+=2,l(e,a);case 218:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,l(e,a);case 219:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,l(e,a);case 220:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,n(e,a);case 221:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,n(e,a);case 222:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,s(e,a);case 223:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,s(e,a)}}}class es{constructor(e){this.icn3d=e}alignCoords(e,t,s,i,n,l,r,o){let a,d=this.icn3d,c=d.icn3dui,h=e.length=4&&(d.rmsd_suprTmp=c.rmsdSuprCls.getRmsdSuprCls(e,t,h),void 0!==d.rmsd_suprTmp.rot)){let e=d.rmsd_suprTmp.rot;null===e[0]&&alert("Please select more residues in each structure...");let t=d.rmsd_suprTmp.trans1,i=d.rmsd_suprTmp.trans2;if(a=d.rmsd_suprTmp.rmsd,a){c.htmlCls.clickMenuCls.setLogCmd("realignment RMSD: "+a.toPrecision(4),!1);let e="
    Realignment RMSD: "+a.toPrecision(4)+" Å

    ";d.bAfMem&&(e+=c.utilsCls.getMemDesc()),$("#"+d.pre+"dl_rmsd").html(e),c.cfg.bSidebyside||c.htmlCls.dialogCls.openDlg("dl_rmsd","Realignment RMSD")}let r={};for(let n=0,l=d.structures[s].length;n"+s.diagram2dCls.set2DdgmNote(!0),$("#"+s.pre+"dl_2ddgm").html(s.html2ddgm),s.b2DShown=!0}async set2DDiagramsForChainalign(e){let t=this.icn3d.icn3dui,s=this;t.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions");let i=[];for(let s=0,n=e.length;s"+s.diagram2dCls.set2DdgmNote(!0),s.b2DShown=!0,$("#"+s.pre+"dl_2ddgm").html(s.html2ddgm),i.cfg.show2d&&i.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions")}download2Ddgm(e,t){this.set2DDiagrams(e)}set2DDiagrams(e){let t=this.icn3d;t.icn3dui.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions"),void 0!==t.b2DShown&&t.b2DShown||(t.html2ddgm="",t.diagram2dCls.draw2Ddgm(t.interactionData,e),t.html2ddgm+="
    "+t.diagram2dCls.set2DdgmNote(),$("#"+t.pre+"dl_2ddgm").html(t.html2ddgm)),t.b2DShown=!0}showLoading(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"wait")&&$("#"+e.pre+"wait").show(),$("#"+e.pre+"canvas")&&$("#"+e.pre+"canvas").hide(),$("#"+e.pre+"cmdlog")&&$("#"+e.pre+"cmdlog").hide()}hideLoading(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"wait")&&$("#"+e.pre+"wait").hide(),$("#"+e.pre+"canvas")&&$("#"+e.pre+"canvas").show(),$("#"+e.pre+"cmdlog")&&$("#"+e.pre+"cmdlog").show()}setYourNote(e){let t=this.icn3d,s=t.icn3dui;t.yournote=e,$("#"+t.pre+"yournote").val(t.yournote),s.cfg.shownote&&(document.title=t.yournote)}transformToOpmOri(e){let t=this.icn3d;if(t.icn3dui,void 0!==t.rmsd_supr&&void 0!==t.rmsd_supr.rot){let s=t.rmsd_supr.rot,i=t.rmsd_supr.trans1,n=t.rmsd_supr.trans2;t.rmsd_supr.rmsd;let l=0;for(let e in t.atoms){let r=t.atoms[e];r.coord=t.surfaceCls.transformMemPro(r.coord,s,i,n);let o=r.coord.x*r.coord.x+r.coord.y*r.coord.y;Math.abs(r.coord.z)<=25&&o>l&&(l=o)}this.addMemAtoms(t.halfBilayerSize,e,Math.sqrt(l)),t.bStopRotate=!0,t.bOpm=!0,$("#"+t.pre+"togglememli").show(),$("#"+t.pre+"adjustmemli").show(),$("#"+t.pre+"selectplaneli").show()}else t.bOpm=!1}transformToOpmOriForAlign(e,t,s){let i=this.icn3d,n=i.icn3dui;if(void 0!==t){let l=i.loadPDBCls.getChainCalpha(i.chains,i.atoms,s,e),r=1==Object.keys(l.chainresiCalphaHash).length||1==Object.keys(t.chainresiCalphaHash).length,o=[],a=[];for(let e in l.chainresiCalphaHash)if(t.chainresiCalphaHash.hasOwnProperty(e)){let s=l.chainresiCalphaHash[e],i=t.chainresiCalphaHash[e];if((s.length==i.length||r)&&(o=o.concat(s),a=a.concat(i)),o.length>500)break}let d=o.length=4)if(i.rmsd_supr=n.rmsdSuprCls.getRmsdSuprCls(o,a,d),void 0!==i.rmsd_supr.rot&&i.rmsd_supr.rmsd<.1){let s=i.rmsd_supr.rot,l=i.rmsd_supr.trans1,r=i.rmsd_supr.trans2,o=i.rmsd_supr.rmsd;n.htmlCls.clickMenuCls.setLogCmd("RMSD of alignment to OPM: "+o.toPrecision(4),!1);let a=0;for(let e in i.atoms){let t=i.atoms[e];t.coord=i.surfaceCls.transformMemPro(t.coord,s,l,r);let n=t.coord.x*t.coord.x+t.coord.y*t.coord.y;Math.abs(t.coord.z)<=25&&n>a&&(a=n)}i.center=t.center,i.oriCenter=i.center.clone(),this.addMemAtoms(i.halfBilayerSize,e,Math.sqrt(a)),i.bStopRotate=!0,i.bOpm=!0,$("#"+i.pre+"togglememli").show(),$("#"+i.pre+"adjustmemli").show(),$("#"+i.pre+"selectplaneli").show()}else i.bOpm=!1;else i.bOpm=!1}}addOneDumAtom(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui,a={het:!0,serial:++l,name:t,alt:void 0,resn:"DUM",structure:e,chain:"MEM",resi:1,coord:new THREE.Vector3(s,i,n),b:void 0,elem:t,bonds:[],ss:"",ssbegin:!1,ssend:!1,color:o.parasCls.atomColors[t]};return r.atoms[l]=a,r.chains[e+"_MEM"][l]=1,r.residues[e+"_MEM_1"][l]=1,r.chemicals[l]=1,r.dAtoms[l]=1,r.hAtoms[l]=1,l}addMemAtoms(e,t,s){let i=this.icn3d;if(i.icn3dui,!t)return;t=t?t.toUpperCase():i.defaultPdbId,i.structures[t].push(t+"_MEM"),i.chains[t+"_MEM"]={},i.residues[t+"_MEM_1"]={},i.chainsSeq[t+"_MEM"]=[{name:"DUM",resi:1}];let n=Object.keys(i.atoms).length;for(let e=0;e<1e3;++e)if(!i.atoms.hasOwnProperty(n+e)){n=n+e-1;break}for(let i=0;i<81;++i)for(let l=0;l<81;++l){let r=2*i-80,o=2*l-80;if(Math.sqrt(r*r+o*o)=2?$("#"+e.pre+"mn2_alternateWrap").show():$("#"+e.pre+"mn2_alternateWrap").hide(),setTimeout((async function(){if(e.bInitial){if(void 0!==t.cfg.align||void 0!==t.cfg.chainalign){let s=e.pre+"selection";if($("#"+s).show(),$("#"+s+"_expand").hide(),$("#"+s+"_shrink").show(),void 0!==t.cfg.align&&2!=t.cfg.atype){let s=!1,i=t.htmlCls.alignSeqCls.getAlignSequencesAnnotations(Object.keys(e.alnChains),void 0,void 0,s);$("#"+e.pre+"dl_sequence2").html(i.sequencesHtml),$("#"+e.pre+"dl_sequence2").width(t.htmlCls.RESIDUE_WIDTH*i.maxSeqCnt+200)}}if(t.cfg.showanno){let s="view annotations";t.htmlCls.clickMenuCls.setLogCmd(s,!0),await e.showAnnoCls.showAnnotations()}t.cfg.closepopup&&e.resizeCanvasCls.closeDialogs()}else e.hlUpdateCls.updateHlAll();$("#"+e.pre+"atomsCustom").length>0&&$("#"+e.pre+"atomsCustom")[0].blur(),e.bInitial=!1}),0)}processCommand(){let e=this.icn3d,t=e.icn3dui;if(1==Object.keys(e.structures).length){let s=Object.keys(e.structures)[0];t.cfg.command=t.cfg.command.replace(new RegExp("!","g"),s+"_")}}getMassCenter(e,t){return this.icn3d.icn3dui,e.multiplyScalar(1/t)}getGeoCenter(e,t){return this.icn3d.icn3dui,e.clone().add(t).multiplyScalar(.5)}getStructureSize(e,t,s,i){let n=this.icn3d;n.icn3dui;let l=0;for(let r in e){let e=n.atoms[r].coord;if(Math.round(t.x)==Math.round(e.x)||Math.round(t.y)==Math.round(e.y)||Math.round(t.z)==Math.round(e.z)||Math.round(s.x)==Math.round(e.x)||Math.round(s.y)==Math.round(e.y)||Math.round(s.z)==Math.round(e.z)){let t=2*e.distanceTo(i);t>l&&(l=t)}}return l}async checkMemProteinAndRotate(){let e=this.icn3d,t=e.icn3dui;if(!e.bCheckMemProtein){e.bCheckMemProtein=!0;let s=t.cfg.afid?t.cfg.afid:t.cfg.mmdbafid;if(await e.ParserUtilsCls.checkMemProtein(s),t.cfg.url&&-1!=t.cfg.url.indexOf("membranome")){let t=new THREE.Vector3(1,0,0),s=-.5*Math.PI;e.transformCls.setRotation(t,s)}}}async checkMemProtein(e){let t=this.icn3d,s=t.icn3dui;try{let i=s.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?afid2mem="+e,n=await s.getAjaxPromise(i,"jsonp");if(n&&n.pdbid){let e='This is a single-spanning (bitopic) transmembrane protein according to the Membranome database. Do you want to align the protein with the model from Membranome? If you click "OK", you can press the letter "a" to alternate the structures.';if("off"==s.cfg.afmem);else if("on"==s.cfg.afmem||confirm(e))try{let e="https://storage.googleapis.com/membranome-assets/pdb_files/proteins/"+n.pdbid+".pdb",i=await s.getAjaxPromise(e,"text");t.bAfMem=!0,s.bNode||$("#"+s.pre+"togglememli").show();let l=n.pdbid.substr(0,n.pdbid.indexOf("_")),r=!0,o=!0;await t.pdbParserCls.loadPdbData(i,l,r,o),o&&(t.bSetChainsAdvancedMenu&&t.definedSetsCls.showSets(),t.bAnnoShown&&await t.showAnnoCls.showAnnotations());let a=n.segment.replace(/ /gi,"").split("(")[0];t.afmem_start_end=a.split("-"),t.hAtoms={},t.dAtoms={};for(let e in t.atoms)t.atoms[e].structure!=l&&(t.hAtoms[e]=1),t.dAtoms[e]=1;for(let e=parseInt(t.afmem_start_end[0]);e<=parseInt(t.afmem_start_end[1]);++e)t.hAtoms=s.hashUtilsCls.unionHash(t.hAtoms,t.residues[l+"_A_"+e]);await t.realignParserCls.realignOnSeqAlign(l)}catch(e){return void console.log("Error in retrieving matched PDB from Membranome...")}}}catch(e){return void console.log("Error in finding matched PDB in Membranome...")}}getResi(e,t){let s=this.icn3d;s.icn3dui;let i=s.ncbi2resid[e+"_"+(t+1).toString()];return i?i.substr(i.lastIndexOf("_")+1):""}getResiNCBI(e,t){let s=this.icn3d;s.icn3dui;let i=s.resid2ncbi[e+"_"+t];return i?parseInt(i.substr(i.lastIndexOf("_")+1)):0}}class ts{constructor(e){this.icn3d=e}loadAtomDataIn(e,t,s,i,n,l,r,o,a){let d=this.icn3d,c=d.icn3dui;d.pmin=new THREE.Vector3(9999,9999,9999),d.pmax=new THREE.Vector3(-9999,-9999,-9999),d.psum=new THREE.Vector3;let h=e.atoms,p=d.atoms?Object.keys(d.atoms).length:0,m={},u={};d.pmid=e.pubmedId,void 0===d.chainid2title&&(d.chainid2title={}),void 0===d.chainid2sid&&(d.chainid2sid={});let g={},f={};if("align"===s){d.pmid="",d.molTitle="",c.cfg.inpara&&-1!==c.cfg.inpara.indexOf("atype=1")?d.molTitle="Invariant Core Structure Alignment (VAST) of ":c.cfg.inpara&&-1!==c.cfg.inpara.indexOf("atype=2")?d.molTitle="Structure Alignment (TM-align) of ":d.molTitle="Structure Alignment (VAST) of ";let t=!1;for(let s=0,i=e.alignedStructures[0].length;s'+i.pdbId.toUpperCase()+"",void 0!==i.descr&&(d.pmid+=i.descr.pubmedid),0===s&&(d.molTitle+=" and ",void 0!==i.descr&&(d.pmid+="_")),t=!0}d.molTitle+=" from VAST+",t||(d.molTitle="")}else if(void 0!==e.descr&&(d.molTitle+=e.descr.name),"mmdbid"===s){let s=isNaN(t)?t:e.pdbId,i={};void 0===d.alignmolid2color&&(d.alignmolid2color=[]);let n=1;for(let t in e.moleculeInfor){if(0===Object.keys(e.moleculeInfor[t]).length)continue;let l=e.moleculeInfor[t].chain.trim(),r=s+"_"+l;i.hasOwnProperty(l)?(++i[l],r+=i[l]):i[l]=1,void 0!==d.mmdbid_q&&(d.mmdbid_q,d.mmdbid_t);let o=e.moleculeInfor[t].kind,a=e.moleculeInfor[t].color,c=e.moleculeInfor[t].sid;if(g[r]=o,f[r]=a,"protein"==o&&(d.organism=e.moleculeInfor[t].taxonomyName.toLowerCase()),void 0!==c&&(d.chainid2sid[r]=c),void 0===d.pdbid_chain2title&&(d.pdbid_chain2title={}),d.pdbid_chain2title[r]=e.moleculeInfor[t].name,l==r.substr(r.lastIndexOf("_"))){let e={};e[t]=n.toString(),d.alignmolid2color.push(e)}++n}}let b,C,y,v,w,_={},S="",A="",x="",k="",O="",R="",E=0,I=0,T="",M=!0,P=!1,D="",H=c.utilsCls.isCalphaPhosOnly(h),F=0,L={};for(let e in h){++p,_[e]=p;let i,n=h[e];n.serial=p,"mmdbid"===s||"mmcifid"===s?i=t:"align"===s&&(i=m[p]);let l=!1;if(void 0!==n.chain||"mmdbid"!==s&&"align"!==s)n.chain=""===n.chain?"Misc":n.chain;else if("mmdbid"===s)if(b=n.ids.m,void 0!==d.molid2chain[b]){let e=d.molid2chain[b].indexOf("_");n.chain=d.molid2chain[b].substr(e+1)}else{let e="Misc";("protein"===g[O]&&"nucleotide"===g[O]&&n.resi!=I||"protein"!==g[O]&&"nucleotide"!==g[O]&&(n.resn.substr(0,3)!=T.substr(0,3)||n.resi!=I||"solvent"===g[O]||"HOH"===n.resn))&&++F,n.resi_ori=n.resi,n.resi=F,l=!0,n.chain=e}else if("align"===s)if(b=n.ids.m,void 0!==d.pdbid_molid2chain[i+"_"+b])n.chain=d.pdbid_molid2chain[i+"_"+b];else{let e="Misc";("protein"===g[O]&&"nucleotide"===g[O]&&n.resi!=I||"protein"!==g[O]&&"nucleotide"!==g[O]&&(n.resn.substr(0,3)!=T.substr(0,3)||n.resi!=I||"solvent"===g[O]||"HOH"===n.resn))&&(++F,n.resi_ori=n.resi,n.resi=F,l=!0),n.chain=e}if(n.chain=n.chain.trim(),"mmdbid"!==s&&"align"!==s||(n.structure=i,"mmdbid"===s&&void 0!==d.mmdbid_q&&(d.mmdbid_q,d.mmdbid_t)),k=n.structure,O=k+"_"+n.chain,"mmdbid"===s||"align"===s){l||(n.resi_ori=n.resi,d.bUsePdbNum?n.resi=n.resi_ori:n.resi=n.ids.r);let e=n.resn.indexOf(" ");-1!==e&&0!=e&&(n.resn=n.resn.substr(0,e))}O!==A&&(E=0),n.resi!==E&&(O!==A?(y=void 0,w=void 0):(y=C,w=v)),n.coord="mmdbid"===s?new THREE.Vector3(n.coord[0],n.coord[1],n.coord[2]):new THREE.Vector3(n.coord.x,n.coord.y,n.coord.z);let r=c.utilsCls.residueName2Abbr(n.resn.substr(0,3));"mmdbid"!==s&&"align"!==s||!d.bFullUi||(void 0===d.mmdbMolidResid2mmdbChainResi&&(d.mmdbMolidResid2mmdbChainResi={}),d.mmdbMolidResid2mmdbChainResi[i+"_"+n.ids.m+"_"+n.ids.r]=i+"_"+n.chain+"_"+n.resi),d.pmin.min(n.coord),d.pmax.max(n.coord),d.psum.add(n.coord);let o=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"protein"===g[O]:"p"===n.mt,a=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"nucleotide"===g[O]:"n"===n.mt,u=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"solvent"===g[O]:"s"===n.mt,N=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"ligand"===g[O]||void 0!==g[O]&&-1!==g[O].indexOf("other")||void 0===g[O]:"l"===n.mt;if("Misc"!==n.chain&&"other"!==g[O]||"protein"===L[O]||"nucleotide"===L[O]||("CA"===n.name&&"C"===n.elem?L[O]="protein":"P"===n.name&&"P"===n.elem?L[O]="nucleotide":L[O]="chemical"),o||a?(o?(d.proteins[p]=1,"CA"===n.name&&(d.calphas[p]=1),"N"!==n.name&&"H"!==n.name&&"CA"!==n.name&&"HA"!==n.name&&"C"!==n.name&&"O"!==n.name&&(d.sidec[p]=1)):a&&(d.nucleotides[p]=1,("O3'"==n.name||"O3*"==n.name||H&&"P"==n.name)&&(d.nucleotidesO3[p]=1),-1===c.parasCls.nuclMainArray.indexOf(n.name)&&(d.ntbase[p]=1)),n.het=!1):u?(d.water[p]=1,n.het=!0):N&&("HOH"===n.resn||"O"===n.resn?d.water[p]=1:n.elem===n.resn?d.ions[p]=1:d.chemicals[p]=1,n.het=!0),"mmdbid"===s?n.het?n.color=c.parasCls.atomColors[n.elem]||c.parasCls.defaultAtomColor:n.color=void 0!==f[O]?c.parasCls.thr(f[O]):c.parasCls.chargeColors[n.resn]:void 0!==n.color&&(n.color=c.parasCls.thr(n.color))," "!==n.resn.charAt(0)&&" "===n.resn.charAt(1)&&(n.resn=n.resn.charAt(0)),n.het||"C"!==n.name||(C=p),n.het||"O"!==n.name||(v=p),!n.het&&"N"===n.name&&void 0!==y&&void 0!==w){let e=d.atoms[y].coord.distanceTo(d.atoms[w].coord),t=n.coord.x+(d.atoms[y].coord.x-d.atoms[w].coord.x)/e,s=n.coord.y+(d.atoms[y].coord.y-d.atoms[w].coord.y)/e,i=n.coord.z+(d.atoms[y].coord.z-d.atoms[w].coord.z)/e;n.hcoord=new THREE.Vector3(t,s,i)}"HOH"==n.resn&&(d.water[p]=1),d.atoms[p]=n,d.dAtoms[p]=1,d.hAtoms[p]=1;let U=n.structure+"_"+n.chain;void 0===d.chains[U]&&(d.chains[U]={}),d.chains[U][p]=1;let q=U+"_"+n.resi;void 0===d.residues[q]&&(d.residues[q]={}),d.residues[q][p]=1,R=O+"_"+n.resi,R!==x&&O!==A&&(M=!0,""!==S&&(void 0===d.structures[S]&&(d.structures[S]=[]),d.structures[S].push(A))),d.residueId2Name[q]=r;let $="-";if("helix"===n.ss?$="H":"sheet"===n.ss?$="E":n.het||a?$="o":(!n.het&&c.parasCls.residueColors.hasOwnProperty(n.resn.toUpperCase())||"coil"===n.ss)&&($="c"),d.secondaries[n.structure+"_"+n.chain+"_"+n.resi]=$,(n.resi!=E||b!=D)&&d.bFullUi&&(void 0===d.chainsSeq[U]&&(d.chainsSeq[U]=[],M=!1),!isNaN(n.resi)))if(M&&!P&&void 0!==d.chainsSeq[U][n.resi-1])d.chainsSeq[U][n.resi-1].name=r;else if(!M||!d.chainsSeq[U].hasOwnProperty(n.resi-1)){let e={};e.resi=n.resi,e.name=r,n.resi%10==0&&n.resi.toString(),d.chainsSeq[U].push(e),P=!0}E=n.resi,I=n.resi_ori,T=n.resn,S=k,A=O,x=R,D=b}for(let e in d.chemicals){let t=d.atoms[e];if("P"==t.elem&&t.bonds.length>=4)for(let e=t.bonds.length-1;e>=0;--e){"P"==d.atoms[t.bonds[e]].elem&&t.bonds.splice(e,1)}}for(let e in L)if(!(Object.keys(d.chains[e]).length<10)&&"chemical"!==L[e])for(let t in d.chains[e]){let s=d.atoms[t];delete d.chemicals[t],s.het=!1,"protein"===L[e]?(d.proteins[t]=1,"CA"===s.name&&(d.calphas[t]=1),"N"!==s.name&&"H"!==s.name&&"CA"!==s.name&&"HA"!==s.name&&"C"!==s.name&&"O"!==s.name&&(d.sidec[t]=1)):"nucleotide"===L[e]&&(d.nucleotides[t]=1,("O3'"==s.name||"O3*"==s.name||H&&"P"==s.name)&&(d.nucleotidesO3[t]=1),-1===c.parasCls.nuclMainArray.indexOf(s.name)&&(d.ntbase[t]=1))}if(void 0===d.structures[k]&&(d.structures[k]=[]),d.structures[k].push(O),d.bFullUi)if("mmdbid"===s||"mmcifid"===s)for(let i in e.sequences){let n=e.sequences[i],l=t+"_"+i;void 0!==d.mmdbid_q&&(d.mmdbid_q,d.mmdbid_t),d.ParserUtilsCls.getMissingResidues(n,s,l)}else if("align"===s)for(let e in d.chainid2seq){let t=d.chainid2seq[e];d.ParserUtilsCls.getMissingResidues(t,s,e)}if(d.loadPDBCls.setResidMapping(),"mmcifid"!==s)for(let e in h){let t=_[e],s=void 0===d.atoms[t].bonds?0:d.atoms[t].bonds.length;for(let e=0;ed.maxatomcnt||void 0!==d.biomtMatrices&&d.biomtMatrices.length*d.cnt>10*d.maxatomcnt)&&(d.opts.proteins="c alpha trace",d.opts.nucleotides="o3 trace"),d.center=d.ParserUtilsCls.getGeoCenter(d.pmin,d.pmax),d.maxD=d.ParserUtilsCls.getStructureSize(d.atoms,d.pmin,d.pmax,d.center),d.maxD<5&&(d.maxD=5),d.oriMaxD=d.maxD,("align"===s||o)&&(d.ssbondpnts={},d.loadPDBCls.setSsbond()),"mmdbid"===s&&1==Object.keys(d.structures).length){let t=e.disulfides;if(void 0!==t)for(let e=0,s=t.length;ep&&(p=e)),c[e]={resi:t,resn:i,aligned:n}}r=e[t][1];let u=r.moleculeId,g=s.pdbid_molid2chain[l+"_"+u],f=l+"_"+g;void 0===s.alnChainsAnTtl[d]&&(s.alnChainsAnTtl[d]=[]),void 0===s.alnChainsAnTtl[d][0]&&(s.alnChainsAnTtl[d][0]=[]),void 0===s.alnChainsAnTtl[d][1]&&(s.alnChainsAnTtl[d][1]=[]),void 0===s.alnChainsAnTtl[d][2]&&(s.alnChainsAnTtl[d][2]=[]),void 0===s.alnChainsAnTtl[d][3]&&(s.alnChainsAnTtl[d][3]=[]),void 0===s.alnChainsAnTtl[d][4]&&(s.alnChainsAnTtl[d][4]=[]),void 0===s.alnChainsAnTtl[d][5]&&(s.alnChainsAnTtl[d][5]=[]),void 0===s.alnChainsAnTtl[d][6]&&(s.alnChainsAnTtl[d][6]=[]),s.alnChainsAnTtl[d][0].push(f),s.alnChainsAnTtl[d][1].push(d),s.alnChainsAnTtl[d][2].push(""),s.alnChainsAnTtl[d][3].push(""),s.alnChainsAnTtl[d][4].push(f),s.alnChainsAnTtl[d][5].push(d),s.alnChainsAnTtl[d][6].push("");let b=1;s.chainsMapping[d]||(s.chainsMapping[d]={}),s.chainsMapping[f]||(s.chainsMapping[f]={});for(let e=h;e<=p;++e){let t,o,p,m=s.bUsePdbNum?s.ParserUtilsCls.getResi(f,r.sequence[e][0]-1):r.sequence[e][0],u="~"===r.sequence[e][2]?"-":r.sequence[e][2],C=r.sequence[e][3]?1:0,y=c[e].aligned+C;2===y?(c[e].resn===u?(t="#FF0000",p="icn3d-cons",s.consHash1[d+"_"+c[e].resi]=1,s.consHash2[f+"_"+m]=1):(t="#0000FF",p="icn3d-ncons",s.nconsHash1[d+"_"+c[e].resi]=1,s.nconsHash2[f+"_"+m]=1),s.chainsMapping[d][d+"_"+c[e].resi]=c[e].resn+c[e].resi,s.chainsMapping[f][f+"_"+m]=c[e].resn+c[e].resi,o="#"+s.showAnnoCls.getColorhexFromBlosum62(c[e].resn,u)):(t=i.htmlCls.GREY8,p="icn3d-nalign",s.nalignHash1[d+"_"+c[e].resi]=1,s.nalignHash2[f+"_"+m]=1),void 0===s.alnChainsSeq[d]&&(s.alnChainsSeq[d]=[]);let v={};v.mmdbid=n,v.chain=a,v.resi=c[e].resi,v.resn=""===v.resi||"icn3d-nalign"===p?c[e].resn.toLowerCase():c[e].resn,v.aligned=y,v.color=""===v.resi?i.htmlCls.GREYC:t,v.color2=""===v.resi?i.htmlCls.GREYC:o,v.class=p,s.alnChainsSeq[d].push(v),""!==c[e].resi&&(void 0===s.alnChains[d]&&(s.alnChains[d]={}),$.extend(s.alnChains[d],s.residues[d+"_"+c[e].resi])),void 0===s.alnChainsSeq[f]&&(s.alnChainsSeq[f]=[]),v={},v.mmdbid=l,v.chain=g,v.resi=m,v.resn=""===v.resi||"icn3d-nalign"===p?u.toLowerCase():u,v.aligned=y,v.color=""===v.resi?i.htmlCls.GREYC:t,v.color2=""===v.resi?i.htmlCls.GREYC:o,v.class=p,s.alnChainsSeq[f].push(v),""!==v.resi&&(void 0===s.alnChains[f]&&(s.alnChains[f]={}),$.extend(s.alnChains[f],s.residues[f+"_"+m])),void 0===s.alnChainsAnno[d]&&(s.alnChainsAnno[d]=[]),void 0===s.alnChainsAnno[d][0]&&(s.alnChainsAnno[d][0]=[]),void 0===s.alnChainsAnno[d][1]&&(s.alnChainsAnno[d][1]=[]),void 0===s.alnChainsAnno[d][2]&&(s.alnChainsAnno[d][2]=[]),void 0===s.alnChainsAnno[d][3]&&(s.alnChainsAnno[d][3]=[]),e===h&&(void 0===s.alnChainsAnno[d][4]&&(s.alnChainsAnno[d][4]=[]),void 0===s.alnChainsAnno[d][5]&&(s.alnChainsAnno[d][5]=[]),void 0===s.alnChainsAnno[d][6]&&(s.alnChainsAnno[d][6]=[]),s.alnChainsAnno[d][4].push(s.pdbid_chain2title[f]),s.alnChainsAnno[d][5].push(s.pdbid_chain2title[d]),s.alnChainsAnno[d][6].push(""));let w=d+"_"+c[e].resi,_=f+"_"+m,S=s.secondaries[w],A=s.secondaries[_];A?s.alnChainsAnno[d][0].push(A):s.alnChainsAnno[d][0].push("-"),S?s.alnChainsAnno[d][1].push(S):s.alnChainsAnno[d][1].push("-");let x=".";b%5==0&&(x="*"),b%10==0&&(x="|"),s.alnChainsAnno[d][2].push(x);let k="";b%10==0&&(k=b.toString()),s.alnChainsAnno[d][3].push(k),++b}}e={}}getPosFromResi(e,t){let s=this.icn3d;s.icn3dui;let i,n=s.resid2ncbi[e+"_"+t];if(n){i=n.substr(n.lastIndexOf("_")+1)-1}return i}getResnFromResi(e,t){let s=this.icn3d,i=s.icn3dui,n=this.getPosFromResi(e,t);if(!n)return"?";let l=e+"_"+t,r="";return r=void 0===s.residues[l]?s.chainsSeq[e][n]?s.chainsSeq[e][n].name:"?":i.utilsCls.residueName2Abbr(s.firstAtomObjCls.getFirstAtomObj(s.residues[l]).resn.substr(0,3)),r}setSeqAlignChain(e,t,s){let i,n,l,r,o,a,d,c,h,p,m,u=this.icn3d,g=u.icn3dui,f={},b=!!s;if(b){if(o=s[1],a=s[0],t=s[2],d=o.indexOf("_"),c=a.indexOf("_"),i=o.substr(0,d).toUpperCase(),n=a.substr(0,c).toUpperCase(),l=o.substr(d+1),r=a.substr(d+1),i==n&&l==r){let e=u.chainsSeq[n+"_"+r].length;u.qt_start_end[t]={q_start:1,q_end:e,t_start:1,t_end:e}}}else{let d=s[0].indexOf("_"),c=e.indexOf("_");if(i=u.mmdbid_t,n=e.substr(0,c).toUpperCase(),l=s[0].substr(d+1),r=e.substr(c+1),i==n&&l==r){let e=u.chainsSeq[u.mmdbid_q+"_"+u.chain_q].length;u.qt_start_end[t]={q_start:1,q_end:e,t_start:1,t_end:e}}o=i+"_"+l,a=n+"_"+r,void 0!==n&&u.mmdbid_t}u.conservedName1=o+"_cons",u.nonConservedName1=o+"_ncons",u.notAlignedName1=o+"_nalign",u.conservedName2=a+"_cons",u.nonConservedName2=a+"_ncons",u.notAlignedName2=a+"_nalign",u.consHash1={},u.nconsHash1={},u.nalignHash1={},u.consHash2={},u.nconsHash2={},u.nalignHash2={},u.alnChains={},u.alnChainsSeq[o]=[],u.alnChains[o]={},u.alnChainsSeq[a]=[],u.alnChains[a]={},u.alnChainsAnno[o]=[],u.alnChainsAnTtl[o]=[],void 0===u.alnChainsAnTtl[o]&&(u.alnChainsAnTtl[o]=[]);for(let e=0;e<7;++e)void 0===u.alnChainsAnTtl[o][e]&&(u.alnChainsAnTtl[o][e]=[]);u.alnChainsAnTtl[o][0].push(a),u.alnChainsAnTtl[o][1].push(o),u.alnChainsAnTtl[o][2].push(""),u.alnChainsAnTtl[o][3].push(""),u.alnChainsAnTtl[o][4].push(a),u.alnChainsAnTtl[o][5].push(o),u.alnChainsAnTtl[o][6].push("");let C=0,y=0;if(void 0===u.qt_start_end[t])return;let v=1;u.chainsMapping[o]||(u.chainsMapping[o]={}),u.chainsMapping[a]||(u.chainsMapping[a]={});let w={},_={};for(let e=0,s=u.qt_start_end[t].length;e0){let e=v;for(let t=C+1,i=s;tc&&(c=t)}}}"tmalign"==n.cfg.aligntool&&(s=!0);let p=Object.keys(a);p.sort((function(e,t){return parseInt(e)-parseInt(t)}));let m=-999,u=0,g=0,f=[],b=0;for(let e=0,t=p.length;e0&&i.resid2ncbi[t]!=i.resid2ncbi[m]+1&&i.resid2ncbi[t]!=i.resid2ncbi[m]){g=m;for(let e=0,t=f.length;ec)continue;let o={},p=r.indexOf("_");o.mmdbid=r.substr(0,p),o.chain=r.substr(p+1),o.resi=t,o.resn=a[t]?i.chainsSeq[r][e].name.toUpperCase():i.chainsSeq[r][e].name.toLowerCase(),o.aligned=!!a[t],o.color=a[t]?"#FF0000":n.htmlCls.GREYC,o.color2=a[t]?"#FF0000":n.htmlCls.GREYC,o.class=a[t]?"icn3d-align":"icn3d-nalign",i.alnChainsSeq[r].push(o),a[t]&&($.extend(i.alnChains[r],i.residues[r+"_"+o.resi]),l=n.hashUtilsCls.unionHash(l,i.residues[r+"_"+o.resi]))}let C=[0];for(let i=0,r=t.length;in)for(let e=0,t=u-m;e=n)for(let e=0,s=t-n;e0?void 0!==n?p.alnChainsAnno[t][0].push(n):p.alnChainsAnno[t][0].push("-"):console.log("Error: ic.alnChainsAnno[chainid1] is undefined")}}}class is{constructor(e){this.icn3d=e}getStructureId(e,t,s){let i=this.icn3d;i.icn3dui;let n=e;return(e==i.defaultPdbId||s)&&(n=1===t?e:e+t.toString()),n}loadPDB(e,t,s,i,n,l,r,o){let a,d,c=this.icn3d,h=c.icn3dui,p={},m=!1,u=e.split("\n"),g={},f={};c.atoms||(l=!1),n||l?(c.oriNStru=c.structures?Object.keys(c.structures).length:0,d=c.oriNStru+1,a=c.atoms?Object.keys(c.atoms).length:0):(c.init(),d=1,a=0);let b,C,y,v,w,_,S,A=[],x=[],k=[],O=[],R=[],E=[],I="",T="",M="",P={},D=t||c.defaultPdbId,H=D,F="",L=!1;for(let e in u){let r=u[e],o=r.substr(0,6);if("HEADER"!==o||L||t)if("TITLE "===o){let e=r.substr(10).replace(/ALPHAFOLD MONOMER V2.0 PREDICTION FOR /gi,"");c.molTitle+=e.trim()+" "}else if("HELIX "===o){c.bSecondaryStructure=!0;let e=""==r.substr(18,2).trim()?"A":r.substr(18,2).trim(),t=parseInt(r.substr(21,4)),s=parseInt(r.substr(33,4));for(let i=t;i<=s;++i){let n=H+"_"+e+"_"+i;O.push(n),i===t&&R.push(n),i===s&&E.push(n)}}else if("SHEET "===o){void 0!==s&&s||(c.bSecondaryStructure=!0);let e=""==r.substr(20,2).trim()?"A":r.substr(20,2).trim(),t=parseInt(r.substr(22,4)),i=parseInt(r.substr(33,4));for(let s=t;s<=i;++s){let n=H+"_"+e+"_"+s;A.push(n),s===t&&x.push(n),s===i&&k.push(n)}}else if("HBOND "===o)void 0!==s&&s||(c.bSecondaryStructure=!0);else if("SSBOND"===o){c.bSsbondProvided=!0;let e=D+"_"+(" "==r.substr(15,1)?"A":r.substr(15,1))+"_"+r.substr(17,4).trim(),t=D+"_"+(" "==r.substr(29,1)?"A":r.substr(29,1))+"_"+r.substr(31,4).trim();void 0===c.ssbondpnts[D]&&(c.ssbondpnts[D]=[]),c.ssbondpnts[D].push(e),c.ssbondpnts[D].push(t)}else if("REMARK"===o){let e=parseInt(r.substr(7,3));if(-1!==r.indexOf("1/2 of bilayer thickness:"))c.halfBilayerSize=parseFloat(r.substr(r.indexOf(":")+1).trim());else if(210==e)"EXPERIMENT TYPE"==r.substr(11,32).trim()&&"NMR"==r.substr(45).trim()&&(m=!0);else if(350==e&&"BIOMT"==r.substr(13,5)){let e=parseInt(r[18])-1,t=parseInt(r.substr(21,2))-1;null==c.biomtMatrices[t]&&(c.biomtMatrices[t]=(new THREE.Matrix4).identity()),c.biomtMatrices[t].elements[e]=parseFloat(r.substr(24,9)),c.biomtMatrices[t].elements[e+4]=parseFloat(r.substr(34,9)),c.biomtMatrices[t].elements[e+8]=parseFloat(r.substr(44,9)),c.biomtMatrices[t].elements[e+12]=parseFloat(r.substr(54,14))}else if(465==e&&" "==r.substr(18,1)&&" "==r.substr(20,1)&&"S"!=r.substr(21,1)){let e=r.substr(15,3),t=r.substr(18,2).trim(),s=r.substr(21,5).trim(),i=D+"_"+t;void 0===c.chainMissingResidueArray[i]&&(c.chainMissingResidueArray[i]=[]);let n={};n.resi=s,n.name=h.utilsCls.residueName2Abbr(e).toLowerCase(),""!=F&&t==F&&t!=F||(c.chainMissingResidueArray[i].push(n),F=t)}else 900==e&&void 0===c.emd&&"RELATED DB: EMDB"==r.substr(34).trim()&&(c.emd=r.substr(23,11).trim())}else if("SOURCE"===o&&void 0===c.organism&&"ORGANISM_COMMON"==r.substr(11,15).trim())c.organism=r.substr(28).toLowerCase().trim(),c.organism=c.organism.substr(0,c.organism.length-1);else if("ENDMDL"===o)++d,D=c.defaultPdbId,H=this.getStructureId(D,d,n),m||(A=[],x=[],k=[],O=[],R=[],E=[]),L=!1;else if("JRNL "===o)"PMID"===r.substr(12,4)&&(c.pmid=r.substr(19).trim());else if("ATOM "===o||"HETATM"===o){H=this.getStructureId(D,d,n);let e=r.substr(16,1);++a,P[parseInt(r.substr(6,5))]=a;let t=r.substr(76,2).trim();""===t&&(t=r.substr(12,2).trim());let l=r.substr(12,4).trim(),u=r.substr(17,3),F=r.substr(20,2).trim();""===F&&(F="A");let L=r.substr(22,5).trim(),N=L;if(s&&"DUM"===u&&(t=l,F="MEM",N=1,L=1),i&&"DUM"===u)break;b=H+"_"+F,y=b+"_"+L,C=b+"_"+N;let U=parseFloat(r.substr(30,8)),q=parseFloat(r.substr(38,8)),$=parseFloat(r.substr(46,8)),j=new THREE.Vector3(U,q,$),B={het:"H"===o[0],serial:a,name:l,alt:e,resn:u,structure:H,chain:F,resi:N,coord:j,b:parseFloat(r.substr(60,8)),elem:t,bonds:[],ss:"coil",ssbegin:!1,ssend:!1};if(B.het||"C"!==B.name||(v=a),B.het||"O"!==B.name||(_=a),!B.het&&"N"===B.name&&void 0!==w&&void 0!==S){let e=c.atoms[w].coord.distanceTo(c.atoms[S].coord),t=B.coord.x+(c.atoms[w].coord.x-c.atoms[S].coord.x)/e,s=B.coord.y+(c.atoms[w].coord.y-c.atoms[S].coord.y)/e,i=B.coord.z+(c.atoms[w].coord.z-c.atoms[S].coord.z)/e;B.hcoord=new THREE.Vector3(t,s,i)}c.atoms[a]=B,c.dAtoms[a]=1,c.hAtoms[a]=1,p[a]=1,this.isSecondary(C,A,m)?(c.atoms[a].ss="sheet",this.isSecondary(C,x,m)&&(c.atoms[a].ssbegin=!0),this.isSecondary(C,k,m)&&(c.atoms[a].ssend=!0)):this.isSecondary(C,O,m)&&(c.atoms[a].ss="helix",this.isSecondary(C,R,m)&&(c.atoms[a].ssbegin=!0),this.isSecondary(C,E,m)&&(c.atoms[a].ssend=!0));let z="-";if(z="helix"===c.atoms[a].ss?"H":"sheet"===c.atoms[a].ss?"E":!c.atoms[a].het&&h.parasCls.residueColors.hasOwnProperty(c.atoms[a].resn.toUpperCase())?"c":"o",c.secondaries[C]=z,y!==M){let e=h.utilsCls.residueName2Abbr(u);if(c.residueId2Name[C]=e,1!==a&&""!==T&&(c.residues[T]=f),C!==T&&(f={}),b!==I){w=void 0,S=void 0,1!==a&&""!==I&&(void 0===c.chains[I]&&(c.chains[I]={}),c.chains[I]=h.hashUtilsCls.unionHash(c.chains[I],g)),g={},void 0===c.structures[H.toString()]&&(c.structures[H.toString()]=[]),c.structures[H.toString()].includes(b)||c.structures[H.toString()].push(b),void 0===c.chainsSeq[b]&&(c.chainsSeq[b]=[]);let t={};t.resi=N,t.name=e,c.chainsSeq[b].push(t)}else{w=v,S=_;let t={};t.resi=N,t.name=e,c.chainsSeq[b].push(t)}}g[a]=1,f[a]=1,I=b,T=C,M=y}else if("CONECT"===o){let e=parseInt(r.substr(6,5));for(let t=0;t<4;++t){let s=parseInt(r.substr([11,16,21,26][t],5));isNaN(s)||void 0!==c.atoms[P[e]]&&c.atoms[P[e]].bonds.push(P[s])}}else"TER"===o.substr(0,3)&&++a;else D=r.substr(62).trim(),""==D&&(D=l?c.defaultPdbId:c.inputid&&-1==c.inputid.indexOf("/")?c.inputid.substr(0,10):c.defaultPdbId),H=this.getStructureId(D,d,n),c.molTitle="",L=!0}c.residues[C]=f,void 0===c.chains[b]&&(c.chains[b]={}),c.chains[b]=h.hashUtilsCls.unionHash2Atoms(c.chains[b],g,c.atoms),n||this.adjustSeq(c.chainMissingResidueArray);let N=Object.keys(c.structures);for(let e=0,t=N.length;e=l?n:l,o=new Array(s+i),a=0,d=0,c=0,h=!1;for(;ar&&i>r&&(h=!0),s<=r&&i>r?s>i||h?(o[c]=t[d],d++):(o[c]=e[a],a++):s>r&&i<=r?s<=i||h?(o[c]=e[a],a++):(o[c]=t[d],d++):s<=i?(o[c]=e[a],a++):(o[c]=t[d],d++),c++}if(a4||Math.abs(l.y-r.y)>4||Math.abs(l.z-r.z)>4||(l.x-r.x)*(l.x-r.x)+(l.y-r.y)*(l.y-r.y)+(l.z-r.z)*(l.z-r.z)<16&&(void 0===e.ssbondpnts[s]&&(e.ssbondpnts[s]=[]),e.ssbondpnts[s].push(o),e.ssbondpnts[s].push(a)))}}}getChainCalpha(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r={};for(let o in e){if(void 0!==i){if(o.split("_")[0]!==i)continue}let a=Object.keys(e[o]),d=[],c=0,h=0;for(let e=0,i=a.length;e3?i.resn.trim().substr(0,3):i.resn.trim();if(!l.parasCls.chargeColors.hasOwnProperty(e))continue;s?i.resi_ori:i.resi,d.push(i.coord.clone()),++c,h=i.resi}}if(c>0){r[t[a[0]].chain]=d}}return{chainresiCalphaHash:r,center:n.center.clone()}}isSecondary(e,t,s){if(this.icn3d.icn3dui,s){let s=e.substr(e.indexOf("_")+1),i=!1;for(let e=0,n=t.length;e0&&(d=!0);for(let n=0,l=t.length;na&&(a=l),s.push(l)}o.push(s)}if(!d)return void(n.bRender&&alert("These structures can not be aligned..."));a<1e-6&&(a=1);for(let e=0,s=t.length;ep[e]=4&&(n.rmsd_suprTmp=l.rmsdSuprCls.getRmsdSuprCls(c,a,p),void 0!==n.rmsd_suprTmp.rot))){let e=n.rmsd_suprTmp.rot;if(null===e[0])continue;let i=n.rmsd_suprTmp.trans1,r=n.rmsd_suprTmp.trans2,a=n.rmsd_suprTmp.rmsd;if(aRealignment RMSD: "+a.toPrecision(4)+" Å

    "),l.cfg.bSidebyside||l.htmlCls.dialogCls.openDlg("dl_rmsd","Realignment RMSD"),n.q_rotation=[],n.q_trans_sub=[],n.t_trans_add=[],n.q_rotation.push({x1:e[0],y1:e[1],z1:e[2],x2:e[3],y2:e[4],z2:e[5],x3:e[6],y3:e[7],z3:e[8]}),n.q_trans_sub.push(i),n.t_trans_add.push({x:-r.x,y:-r.y,z:-r.z}),l.cfg.aligntool="vast";//!= 'tmalign'; +var icn3d=function(e){"use strict";class t{constructor(e){this.icn3dui=e}cloneHash(e){this.icn3dui;let t={};void 0===e&&(e={});for(let s in e)t[s]=e[s];return t}intHash(e,t){this.icn3dui;let s={};if(void 0===e&&(e={}),void 0===t&&(t={}),Object.keys(e).length0||window.navigator.userAgent.match(/Trident.*rv\:11\./))}isMobile(){return this.icn3dui,/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)}isMac(){return this.icn3dui,/Mac/i.test(window.navigator.userAgent)}isAndroid(){return this.icn3dui,/android/i.test(window.navigator.userAgent.toLowerCase())}isChrome(){return this.icn3dui,navigator.userAgent.includes("Chrome")&&navigator.vendor.includes("Google Inc")}isSessionStorageSupported(){return this.icn3dui,window.sessionStorage}isLocalStorageSupported(){return this.icn3dui,window.localStorage}hexToRgb(e,t){this.icn3dui;let s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return s?{r:parseInt(s[1],16),g:parseInt(s[2],16),b:parseInt(s[3],16),a:t}:null}isCalphaPhosOnly(e){this.icn3dui;let t=!1,s=0,i=0;for(let t in e){if(!(s<100))break;{let s=e[t].name.trim();"CA"!==s&&"P"!==s&&"O3'"!==s&&"O3*"!==s&&++i}++s}return i<.5*s&&(t=!0),t}hasCovalentBond(e,t){let s=this.icn3dui,i=s.parasCls.covalentRadii[e.elem.toUpperCase()]+s.parasCls.covalentRadii[t.elem.toUpperCase()],n=e.coord.x-t.coord.x,l=e.coord.y-t.coord.y,r=e.coord.z-t.coord.z;return n*n+l*l+r*r<("N"==e.elem&&"H"==t.elem.substr(0,1)||"N"==t.elem&&"H"==e.elem.substr(0,1)?2.2:1.3)*i*i}residueName2Abbr(e){this.icn3dui;let t=e.indexOf(" ");switch(t>0&&(e=e.substr(0,t)),e){case" A":case" DA":case"DA":case"ALA":return"A";case" C":case" DC":case"DC":case"CYS":return"C";case" G":case" DG":case"DG":case"GLY":return"G";case" T":case" DT":case"DT":case"THR":return"T";case" U":case" DU":case"DU":case"SEC":return"U";case" I":case" DI":case"DI":case"ILE":return"I";case"ARG":return"R";case"ASN":return"N";case"ASP":return"D";case"GLU":return"E";case"GLN":return"Q";case"HIS":return"H";case"LEU":return"L";case"LYS":return"K";case"MET":return"M";case"PHE":return"F";case"PRO":return"P";case"SER":return"S";case"TRP":return"W";case"TYR":return"Y";case"VAL":return"V";case"HOH":case"WAT":return"O";default:return e.trim()}}residueAbbr2Name(e){if(this.icn3dui,(e=e.toUpperCase()).length>1)return e;switch(e){case"A":return"ALA";case"R":return"ARG";case"N":return"ASN";case"D":return"ASP";case"C":return"CYS";case"E":return"GLU";case"Q":return"GLN";case"G":return"GLY";case"H":return"HIS";case"I":return"ILE";case"L":return"LEU";case"K":return"LYS";case"M":return"MET";case"F":return"PHE";case"P":return"PRO";case"S":return"SER";case"T":return"THR";case"W":return"TRP";case"Y":return"TYR";case"V":return"VAL";case"O":return"HOH";default:return e.trim()}}getJSONFromArray(e){this.icn3dui;let t="";for(let s=0,i=e.length;sd?1:ah?1:cs&&(e.htmlCls.WIDTH=s),i&&e.htmlCls.HEIGHT>i&&(e.htmlCls.HEIGHT=i)}sumArray(e){let t=0;for(let s=0,i=e.length;sRed and blue membranes indicate extracellular and intracellular membranes, respectively.

    "}}class i{constructor(e){this.icn3dui=e,this.glycanHash={GLC:{c:"1E90FF",s:"sphere"},BGC:{c:"1E90FF",s:"sphere"},NAG:{c:"1E90FF",s:"cube"},NDG:{c:"1E90FF",s:"cube"},GCS:{c:"1E90FF",s:"cube"},PA1:{c:"1E90FF",s:"cube"},GCU:{c:"1E90FF",s:"cone"},BDP:{c:"1E90FF",s:"cone"},G6D:{c:"1E90FF",s:"cone"},DDA:{c:"1E90FF",s:"cylinder"},B6D:{c:"1E90FF",s:"cylinder"},XXM:{c:"1E90FF",s:"cylinder"},MAN:{c:"00FF00",s:"sphere"},BMA:{c:"00FF00",s:"sphere"},BM3:{c:"00FF00",s:"cube"},"95Z":{c:"00FF00",s:"cube"},MAV:{c:"00FF00",s:"cone"},BEM:{c:"00FF00",s:"cone"},RAM:{c:"00FF00",s:"cone"},RM4:{c:"00FF00",s:"cone"},TYV:{c:"00FF00",s:"cylinder"},ARA:{c:"00FF00",s:"cylinder"},ARB:{c:"00FF00",s:"cylinder"},KDN:{c:"00FF00",s:"cylinder"},KDM:{c:"00FF00",s:"cylinder"},"6PZ":{c:"00FF00",s:"cylinder"},GMH:{c:"00FF00",s:"cylinder"},BDF:{c:"00FF00",s:"cylinder"},GAL:{c:"FFFF00",s:"sphere"},GLA:{c:"FFFF00",s:"sphere"},NGA:{c:"FFFF00",s:"cube"},A2G:{c:"FFFF00",s:"cube"},X6X:{c:"FFFF00",s:"cube"},"1GN":{c:"FFFF00",s:"cube"},ADA:{c:"FFFF00",s:"cone"},GTR:{c:"FFFF00",s:"cone"},LDY:{c:"FFFF00",s:"cylinder"},KDO:{c:"FFFF00",s:"cylinder"},T6T:{c:"FFFF00",s:"cylinder"},GUP:{c:"A52A2A",s:"sphere"},GL0:{c:"A52A2A",s:"sphere"},LGU:{c:"A52A2A",s:"cone"},ABE:{c:"A52A2A",s:"cylinder"},XYS:{c:"A52A2A",s:"cylinder"},XYP:{c:"A52A2A",s:"cylinder"},SOE:{c:"A52A2A",s:"cylinder"},PZU:{c:"FF69B4",s:"cylinder"},RIP:{c:"FF69B4",s:"cylinder"},"0MK":{c:"FF69B4",s:"cylinder"},ALL:{c:"8A2BE2",s:"sphere"},AFD:{c:"8A2BE2",s:"sphere"},NAA:{c:"8A2BE2",s:"cube"},SIA:{c:"8A2BE2",s:"cylinder"},SIB:{c:"8A2BE2",s:"cylinder"},AMU:{c:"8A2BE2",s:"cylinder"},X0X:{c:"1E90FF",s:"cone"},X1X:{c:"1E90FF",s:"cone"},NGC:{c:"1E90FF",s:"cylinder"},NGE:{c:"1E90FF",s:"cylinder"},"4N2":{c:"A0522D",s:"sphere"},HSQ:{c:"A0522D",s:"cube"},IDR:{c:"A0522D",s:"cone"},MUR:{c:"A0522D",s:"cylinder"},FUC:{c:"FF0000",s:"cone"},FUL:{c:"FF0000",s:"cone"}},this.nucleotidesArray=[" G"," A"," T"," C"," U"," DG"," DA"," DT"," DC"," DU","G","A","T","C","U","DG","DA","DT","DC","DU"],this.ionsArray=[" K"," NA"," MG"," AL"," CA"," TI"," MN"," FE"," NI"," CU"," ZN"," AG"," BA"," F"," CL"," BR"," I","K","NA","MG","AL","CA","TI","MN","FE","NI","CU","ZN","AG","BA","F","CL","BR","I"],this.cationsTrimArray=["K","NA","MG","AL","CA","TI","MN","FE","NI","CU","ZN","AG","BA"],this.anionsTrimArray=["F","CL","BR","I"],this.ionCharges={K:1,NA:1,MG:2,AL:3,CA:2,TI:3,MN:2,FE:3,NI:2,CU:2,ZN:2,AG:1,BA:2},this.vdwRadii={H:1.08,HE:1.34,LI:1.75,BE:2.05,B:1.47,C:1.49,N:1.41,O:1.4,F:1.39,NE:1.68,NA:1.84,MG:2.05,AL:2.11,SI:2.07,P:1.92,S:1.82,CL:1.83,AR:1.93,K:2.05,CA:2.21,SC:2.16,TI:1.87,V:1.79,CR:1.89,MN:1.97,FE:1.94,CO:1.92,NI:1.84,CU:1.86,ZN:2.1,GA:2.08,GE:2.15,AS:2.06,SE:1.93,BR:1.98,KR:2.12,RB:2.16,SR:2.24,Y:2.19,ZR:1.86,NB:2.07,MO:2.09,TC:2.09,RU:2.07,RH:1.95,PD:2.02,AG:2.03,CD:2.3,IN:2.36,SN:2.33,SB:2.25,TE:2.23,I:2.23,XE:2.21,CS:2.22,BA:2.51,LA:2.4,CE:2.35,PR:2.39,ND:2.29,PM:2.36,SM:2.29,EU:2.33,GD:2.37,TB:2.21,DY:2.29,HO:2.16,ER:2.35,TM:2.27,YB:2.42,LU:2.21,HF:2.12,TA:2.17,W:2.1,RE:2.17,OS:2.16,IR:2.02,PT:2.09,AU:2.17,HG:2.09,TL:2.35,PB:2.32,BI:2.43,PO:2.29,AT:2.36,RN:2.43,FR:2.56,RA:2.43,AC:2.6,TH:2.37,PA:2.43,U:2.4,NP:2.21,PU:2.56,AM:2.56,CM:2.56,BK:2.56,CF:2.56,ES:2.56,FM:2.56},this.covalentRadii={H:.31,HE:.28,LI:1.28,BE:.96,B:.84,C:.76,N:.71,O:.66,F:.57,NE:.58,NA:1.66,MG:1.41,AL:1.21,SI:1.11,P:1.07,S:1.05,CL:1.02,AR:1.06,K:2.03,CA:1.76,SC:1.7,TI:1.6,V:1.53,CR:1.39,MN:1.39,FE:1.32,CO:1.26,NI:1.24,CU:1.32,ZN:1.22,GA:1.22,GE:1.2,AS:1.19,SE:1.2,BR:1.2,KR:1.16,RB:2.2,SR:1.95,Y:1.9,ZR:1.75,NB:1.64,MO:1.54,TC:1.47,RU:1.46,RH:1.42,PD:1.39,AG:1.45,CD:1.44,IN:1.42,SN:1.39,SB:1.39,TE:1.38,I:1.39,XE:1.4,CS:2.44,BA:2.15,LA:2.07,CE:2.04,PR:2.03,ND:2.01,PM:1.99,SM:1.98,EU:1.98,GD:1.96,TB:1.94,DY:1.92,HO:1.92,ER:1.89,TM:1.9,YB:1.87,LU:1.87,HF:1.75,TA:1.7,W:1.62,RE:1.51,OS:1.44,IR:1.41,PT:1.36,AU:1.36,HG:1.32,TL:1.45,PB:1.46,BI:1.48,PO:1.4,AT:1.5,RN:1.5,FR:2.6,RA:2.21,AC:2.15,TH:2.06,PA:2,U:1.96,NP:1.9,PU:1.87,AM:1.8,CM:1.69},this.atomColors={H:this.thr(16777215),He:this.thr(16761035),HE:this.thr(16761035),Li:this.thr(11674146),LI:this.thr(11674146),B:this.thr(65280),C:this.thr(11184810),N:this.thr(255),O:this.thr(15728640),F:this.thr(14329120),Na:this.thr(255),NA:this.thr(255),Mg:this.thr(2263842),MG:this.thr(2263842),Al:this.thr(8421520),AL:this.thr(8421520),Si:this.thr(14329120),SI:this.thr(14329120),P:this.thr(16753920),S:this.thr(16762930),Cl:this.thr(65280),CL:this.thr(65280),Ca:this.thr(8421520),CA:this.thr(8421520),Ti:this.thr(8421520),TI:this.thr(8421520),Cr:this.thr(8421520),CR:this.thr(8421520),Mn:this.thr(8421520),MN:this.thr(8421520),Fe:this.thr(16753920),FE:this.thr(16753920),Ni:this.thr(10824234),NI:this.thr(10824234),Cu:this.thr(10824234),CU:this.thr(10824234),Zn:this.thr(10824234),ZN:this.thr(10824234),Br:this.thr(10824234),BR:this.thr(10824234),Ag:this.thr(8421520),AG:this.thr(8421520),I:this.thr(10494192),Ba:this.thr(16753920),BA:this.thr(16753920),Au:this.thr(14329120),AU:this.thr(14329120)},this.atomnames={H:"Hydrogen",HE:"Helium",LI:"Lithium",B:"Boron",C:"Carbon",N:"Nitrogen",O:"Oxygen",F:"Fluorine",NA:"Sodium",MG:"Magnesium",AL:"Aluminum",SI:"Silicon",P:"Phosphorus",S:"Sulfur",CL:"Chlorine",CA:"Calcium",TI:"Titanium",CR:"Chromium",MN:"Manganese",FE:"Iron",NI:"Nickel",CU:"Copper",ZN:"Zinc",BR:"Bromine",AG:"Silver",I:"Iodine",BA:"Barium",AU:"Gold"},this.defaultAtomColor=this.thr(13421772),this.stdChainColors=[this.thr(16711935),this.thr(255),this.thr(10053171),this.thr(65433),this.thr(16750848),this.thr(16737894),this.thr(3329330),this.thr(2003199),this.thr(16416882),this.thr(16753920),this.thr(52945),this.thr(16738740),this.thr(65280),this.thr(255),this.thr(16711680),this.thr(16776960),this.thr(65535),this.thr(16711935),this.thr(3978097),this.thr(4620980),this.thr(13458524),this.thr(16770229),this.thr(11529966),this.thr(15631086),this.thr(25600),this.thr(139),this.thr(9109504),this.thr(13468991),this.thr(35723),this.thr(9699539)],this.backgroundColors={black:this.thr(0),grey:this.thr(13421772),white:this.thr(16777215),transparent:this.thr(16777215)},this.residueColors={ALA:this.thr(13158600),ARG:this.thr(1334015),ASN:this.thr(56540),ASP:this.thr(15075850),CYS:this.thr(15132160),GLN:this.thr(56540),GLU:this.thr(15075850),GLY:this.thr(15461355),HIS:this.thr(8553170),ILE:this.thr(1016335),LEU:this.thr(1016335),LYS:this.thr(1334015),MET:this.thr(15132160),PHE:this.thr(3289770),PRO:this.thr(14456450),SER:this.thr(16422400),THR:this.thr(16422400),TRP:this.thr(11819700),TYR:this.thr(3289770),VAL:this.thr(1016335),ASX:this.thr(16738740),GLX:this.thr(16738740),G:this.thr(32768),A:this.thr(6324479),T:this.thr(16744448),C:this.thr(16711680),U:this.thr(16744448),DG:this.thr(32768),DA:this.thr(6324479),DT:this.thr(16744448),DC:this.thr(16711680),DU:this.thr(16744448)},this.residueArea={ALA:247,ARG:366,ASN:290,ASP:285,CYS:271,GLN:336,GLU:325,GLY:217,HIS:340,ILE:324,LEU:328,LYS:373,MET:346,PHE:366,PRO:285,SER:265,THR:288,TRP:414,TYR:387,VAL:293,ASX:290,GLX:336,G:520,A:507,T:515,C:467,U:482,DG:520,DA:507,DT:515,DC:467,DU:482},this.defaultResidueColor=this.thr(12492910),this.chargeColors={" G":this.thr(16711680)," A":this.thr(16711680)," T":this.thr(16711680)," C":this.thr(16711680)," U":this.thr(16711680)," DG":this.thr(16711680)," DA":this.thr(16711680)," DT":this.thr(16711680)," DC":this.thr(16711680)," DU":this.thr(16711680),G:this.thr(16711680),A:this.thr(16711680),T:this.thr(16711680),C:this.thr(16711680),U:this.thr(16711680),DG:this.thr(16711680),DA:this.thr(16711680),DT:this.thr(16711680),DC:this.thr(16711680),DU:this.thr(16711680),ARG:this.thr(255),LYS:this.thr(255),ASP:this.thr(16711680),GLU:this.thr(16711680),HIS:this.thr(8421631),GLY:this.thr(8947848),PRO:this.thr(8947848),ALA:this.thr(8947848),VAL:this.thr(8947848),LEU:this.thr(8947848),ILE:this.thr(8947848),PHE:this.thr(8947848),SER:this.thr(8947848),THR:this.thr(8947848),ASN:this.thr(8947848),GLN:this.thr(8947848),TYR:this.thr(8947848),MET:this.thr(8947848),CYS:this.thr(8947848),TRP:this.thr(8947848)},this.hydrophobicColors={" G":this.thr(16711680)," A":this.thr(16711680)," T":this.thr(16711680)," C":this.thr(16711680)," U":this.thr(16711680)," DG":this.thr(16711680)," DA":this.thr(16711680)," DT":this.thr(16711680)," DC":this.thr(16711680)," DU":this.thr(16711680),G:this.thr(16711680),A:this.thr(16711680),T:this.thr(16711680),C:this.thr(16711680),U:this.thr(16711680),DG:this.thr(16711680),DA:this.thr(16711680),DT:this.thr(16711680),DC:this.thr(16711680),DU:this.thr(16711680),ARG:this.thr(255),LYS:this.thr(255),ASP:this.thr(16711680),GLU:this.thr(16711680),HIS:this.thr(8421631),TRP:this.thr().setHSL(1/3,1,.5),PHE:this.thr().setHSL(1/3,1,.6945945945945946),TYR:this.thr().setHSL(1/3,1,.745945945945946),LEU:this.thr().setHSL(1/3,1,.5+.645/1.85),ILE:this.thr().setHSL(1/3,1,.5+.77/1.85),CYS:this.thr().setHSL(1/3,1,.5+.805/1.85),MET:this.thr().setHSL(1/3,1,.5+.81/1.85),GLY:this.thr().setHSL(1/6,1,.5+.285/.58),VAL:this.thr().setHSL(1/6,1,.5+.255/.58),SER:this.thr().setHSL(1/6,1,.8879310344827587),THR:this.thr().setHSL(1/6,1,.8793103448275862),ALA:this.thr().setHSL(1/6,1,.853448275862069),ASN:this.thr().setHSL(1/6,1,.6379310344827587),PRO:this.thr().setHSL(1/6,1,.6120689655172413),GLN:this.thr().setHSL(1/6,1,.5)},this.normalizedHPColors={" G":this.thr(16777215)," A":this.thr(16777215)," T":this.thr(16777215)," C":this.thr(16777215)," U":this.thr(16777215)," DG":this.thr(16777215)," DA":this.thr(16777215)," DT":this.thr(16777215)," DC":this.thr(16777215)," DU":this.thr(16777215),G:this.thr(16777215),A:this.thr(16777215),T:this.thr(16777215),C:this.thr(16777215),U:this.thr(16777215),DG:this.thr(16777215),DA:this.thr(16777215),DT:this.thr(16777215),DC:this.thr(16777215),DU:this.thr(16777215),ARG:this.thr(16777215),LYS:this.thr(16777215),ASP:this.thr(16777215),GLU:this.thr(16777215),HIS:this.thr(16777215),TRP:this.thr().setHSL(1/3,1,.5),PHE:this.thr().setHSL(1/3,1,.644),TYR:this.thr().setHSL(1/3,1,.682),LEU:this.thr().setHSL(1/3,1,.758),ILE:this.thr().setHSL(1/3,1,.808),CYS:this.thr().setHSL(1/3,1,.5+.322),MET:this.thr().setHSL(1/3,1,.5+.324),GLY:this.thr().setHSL(1/3,1,.872),VAL:this.thr().setHSL(1/3,1,.884),SER:this.thr().setHSL(1/3,1,.896),THR:this.thr().setHSL(1/3,1,.898),ALA:this.thr().setHSL(1/3,1,.904),ASN:this.thr().setHSL(1/3,1,.954),PRO:this.thr().setHSL(1/3,1,.9600000000000001),GLN:this.thr().setHSL(1/3,1,.986)},this.hydrophobicValues={" G":3," A":3," T":3," C":3," U":3," DG":3," DA":3," DT":3," DC":3," DU":3,G:3,A:3,T:3,C:3,U:3,DG:3,DA:3,DT:3,DC:3,DU:3,ARG:1,LYS:1,ASP:3,GLU:3,HIS:2,TRP:-1.85,PHE:-1.13,TYR:-.94,LEU:-.56,ILE:-.31,CYS:-.24,MET:-.23,GLY:.01,VAL:.07,SER:.13,THR:.14,ALA:.17,ASN:.42,PRO:.45,GLN:.58},this.residueAbbrev={ALA:"A (Ala)",ARG:"R (Arg)",ASN:"N (Asn)",ASP:"D (Asp)",CYS:"C (Cys)",GLN:"Q (Gln)",GLU:"E (Glu)",GLY:"G (Gly)",HIS:"H (His)",ILE:"I (Ile)",LEU:"L (Leu)",LYS:"K (Lys)",MET:"M (Met)",PHE:"F (Phe)",PRO:"P (Pro)",SER:"S (Ser)",THR:"T (Thr)",TRP:"W (Trp)",TYR:"Y (Tyr)",VAL:"V (Val)",ASX:"X (Asx)",GLX:"X (Glx)",G:"Guanine",A:"Adenine",T:"Thymine",C:"Cytosine",U:"Uracil",DG:"deoxy-Guanine",DA:"deoxy-Adenine",DT:"deoxy-Thymine",DC:"deoxy-Cytosine",DU:"deoxy-Uracil"},this.ssColors={helix:this.thr(16711680),sheet:this.thr(32768),coil:this.thr(6324479)},this.ssColors2={helix:this.thr(16711680),sheet:this.thr(16762880),coil:this.thr(6324479)},this.resn2restype={ALA:1,ARG:4,ASN:7,ASP:10,CYS:13,GLN:16,GLU:19,GLY:22,HIS:25,ILE:28,LEU:31,LYS:34,MET:37,PHE:40,PRO:43,SER:46,THR:49,TRP:52,TYR:55,VAL:58},this.nuclMainArray=["C1'","C1*","C2'","C2*","C3'","C3*","C4'","C4*","C5'","C5*","O3'","O3*","O4'","O4*","O5'","O5*","P","OP1","O1P","OP2","O2P"],this.b62ResArray=["A","R","N","D","C","Q","E","G","H","I","L","K","M","F","P","S","T","W","Y","V","B","Z","X","*"],this.b62Matrix=[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0,-4],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1,-4],[-2,0,6,1,-3,0,0,0,1,-3,-3,0,-2,-3,-2,1,0,-4,-2,-3,3,0,-1,-4],[-2,-2,1,6,-3,0,2,-1,-1,-3,-4,-1,-3,-3,-1,0,-1,-4,-3,-3,4,1,-1,-4],[0,-3,-3,-3,9,-3,-4,-3,-3,-1,-1,-3,-1,-2,-3,-1,-1,-2,-2,-1,-3,-3,-2,-4],[-1,1,0,0,-3,5,2,-2,0,-3,-2,1,0,-3,-1,0,-1,-2,-1,-2,0,3,-1,-4],[-1,0,0,2,-4,2,5,-2,0,-3,-3,1,-2,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-2,0,-1,-3,-2,-2,6,-2,-4,-4,-2,-3,-3,-2,0,-2,-2,-3,-3,-1,-2,-1,-4],[-2,0,1,-1,-3,0,0,-2,8,-3,-3,-1,-2,-1,-2,-1,-2,-2,2,-3,0,0,-1,-4],[-1,-3,-3,-3,-1,-3,-3,-4,-3,4,2,-3,1,0,-3,-2,-1,-3,-1,3,-3,-3,-1,-4],[-1,-2,-3,-4,-1,-2,-3,-4,-3,2,4,-2,2,0,-3,-2,-1,-2,-1,1,-4,-3,-1,-4],[-1,2,0,-1,-3,1,1,-2,-1,-3,-2,5,-1,-3,-1,0,-1,-3,-2,-2,0,1,-1,-4],[-1,-1,-2,-3,-1,0,-2,-3,-2,1,2,-1,5,0,-2,-1,-1,-1,-1,1,-3,-1,-1,-4],[-2,-3,-3,-3,-2,-3,-3,-3,-1,0,0,-3,0,6,-4,-2,-2,1,3,-1,-3,-3,-1,-4],[-1,-2,-2,-1,-3,-1,-1,-2,-2,-3,-3,-1,-2,-4,7,-1,-1,-4,-3,-2,-2,-1,-2,-4],[1,-1,1,0,-1,0,0,0,-1,-2,-2,0,-1,-2,-1,4,1,-3,-2,-2,0,0,0,-4],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,1,5,-2,-2,0,-1,-1,0,-4],[-3,-3,-4,-4,-2,-2,-3,-2,-2,-3,-2,-3,-1,1,-4,-3,-2,11,2,-3,-4,-3,-2,-4],[-2,-2,-2,-3,-2,-1,-2,-3,2,-1,-1,-2,-1,3,-3,-2,-2,2,7,-1,-3,-2,-1,-4],[0,-3,-3,-3,-1,-2,-2,-3,-3,3,1,-2,1,-1,-2,-2,0,-3,-1,4,-3,-2,-1,-4],[-2,-1,3,4,-3,0,1,-1,0,-3,-4,0,-3,-3,-2,0,-1,-4,-3,-3,4,1,-1,-4],[-1,0,0,1,-3,3,4,-2,0,-3,-3,1,-1,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,0,0,-2,-1,-1,-1,-1,-1,-4],[-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,1]]}thr(e){return this.icn3dui,"#0"==e&&(e="#000"),new THREE.Color(e)}}class n{constructor(e){this.icn3dui=e}onId(e,t,s){if(this.icn3dui,!(Object.keys(window).length<2)&&("#"==e.substr(0,1)&&(e=e.substr(1)),document.getElementById(e))){t.split(" ").forEach((t=>{document.getElementById(e).addEventListener(t,s)}))}}onIds(e,t,s){let i=this.icn3dui;Array.isArray(e)?e.forEach((e=>{i.myEventCls.onId(e,t,s)})):i.myEventCls.onId(e,t,s)}}class l{constructor(e){this.icn3dui=e}getRmsdSuprCls(e,t,s){let i,n,l,r,o,a,d,c,h,p,m,u,g,f=this.icn3dui,b=new Array(9),C=new THREE.Vector3,y=new THREE.Vector3,v=[],w=[],_=new Array(3),S=new Array(3),A=new Array(3),x=new Array(3),k=new Array(3),O=new Array(3);if(i=0,s<=1)return{rot:void 0,trans1:void 0,trans2:void 0,rmsd:999};let R=s;for(n=0;n0?(b[0]=x[0]*_[0]+k[0]*S[0]+O[0]*A[0],b[1]=x[0]*_[1]+k[0]*S[1]+O[0]*A[1],b[2]=x[0]*_[2]+k[0]*S[2]+O[0]*A[2],b[3]=x[1]*_[0]+k[1]*S[0]+O[1]*A[0],b[4]=x[1]*_[1]+k[1]*S[1]+O[1]*A[1],b[5]=x[1]*_[2]+k[1]*S[2]+O[1]*A[2],b[6]=x[2]*_[0]+k[2]*S[0]+O[2]*A[0],b[7]=x[2]*_[1]+k[2]*S[1]+O[2]*A[1],b[8]=x[2]*_[2]+k[2]*S[2]+O[2]*A[2]):(b[0]=x[0]*_[0]+k[0]*S[0]-O[0]*A[0],b[1]=x[0]*_[1]+k[0]*S[1]-O[0]*A[1],b[2]=x[0]*_[2]+k[0]*S[2]-O[0]*A[2],b[3]=x[1]*_[0]+k[1]*S[0]-O[1]*A[0],b[4]=x[1]*_[1]+k[1]*S[1]-O[1]*A[1],b[5]=x[1]*_[2]+k[1]*S[2]-O[1]*A[2],b[6]=x[2]*_[0]+k[2]*S[0]-O[2]*A[0],b[7]=x[2]*_[1]+k[2]*S[1]-O[2]*A[1],b[8]=x[2]*_[2]+k[2]*S[2]-O[2]*A[2]),c=Math.sqrt(c),h=Math.sqrt(h),p=Math.sqrt(p),g=c+h+u*p,m=a+d-2*g,i=m>0?Math.sqrt(m):void 0,{rot:b,trans1:E,trans2:I,rmsd:i})}eigen_values(e){let t,s,i,n,l,r,o,a,d,c,h,p,m,u,g,f,b,C,y,v;if(this.icn3dui,t=e[0],s=e[1],i=e[2],n=e[3],l=e[4],r=e[5],o=e[6],a=e[7],d=e[8],c=-(t+l+d),h=t*l+(t+l)*d-r*a-s*n-i*o,p=-t*l*d+t*r*a+s*n*d-s*r*o-i*n*a+i*l*o,m=-c*c/3+h,u=c*c*c/13.5-c*h/3+p,g=.25*u*u+m*m*m/27,g<0){let e,t;e=Math.sqrt(.25*u*u-g),t=Math.acos(-.5*u/e),C=2*Math.cbrt(e)*Math.cos(t/3)}else f=Math.cbrt(-.5*u+Math.sqrt(g)),b=Math.cbrt(-.5*u-Math.sqrt(g)),C=f+b;return C-=c/3,c+=C,p/=-C,y=.5*(-c+Math.sqrt(c*c-4*p)),v=.5*(-c-Math.sqrt(c*c-4*p)),y_&&(_=Math.abs(d)),Math.abs(c)>_&&(_=Math.abs(c)),Math.abs(h)>_&&(_=Math.abs(h)),Math.abs(p)>_&&(_=Math.abs(p)),Math.abs(m)>_&&(_=Math.abs(m)),Math.abs(u)>_&&(_=Math.abs(u)),Math.abs(g)>_&&(_=Math.abs(g)),Math.abs(f)>_&&(_=Math.abs(f)),_<1e-10)return r=3,{k:r,v1:t,v2:s,v3:i};if(o=0,a/=_,d/=_,c/=_,h/=_,p/=_,m/=_,u/=_,g/=_,f/=_,Math.abs(a)_&&(w=a,a=h,h=w,w=d,d=p,p=w,w=c,c=m,m=w,_=Math.abs(d)),Math.abs(g)>_&&(w=a,a=u,u=w,w=d,d=g,g=w,w=c,c=f,f=w),y=m-p*c/d,v=f-g*c/d,Math.abs(y)_&&(w=a,a=h,h=w,w=d,d=p,p=w,w=c,c=m,m=w,_=Math.abs(a)),Math.abs(c)>_&&(w=a,a=u,u=w,w=d,d=g,g=w,w=c,c=f,f=w),b=p-h*d/a,C=m-h*c/a,y=g-u*d/a,v=f-u*c/a,Math.abs(b)0&&(1==o?(a=s[0],d=s[1],c=s[2],w=Math.sqrt(a*a+d*d+c*c),s[0]=a/w,s[1]=d/w,s[2]=c/w):2==o?(a=t[0],d=t[1],c=t[2],h=s[0],p=s[1],m=s[2],w=a*h+d*p+c*m,Math.abs(w)>=n&&(s[0]=a+w*h,s[1]=d+w*p,s[2]=c+w*m,h=s[0],p=s[1],m=s[2]),w=Math.sqrt(a*a+d*d+c*c),t[0]=a/w,t[1]=d/w,t[2]=c/w,w=Math.sqrt(h*h+p*p+m*m),s[0]=h/w,s[1]=p/w,s[2]=m/w):(a=t[0],d=t[1],c=t[2],w=Math.sqrt(a*a+d*d+c*c),t[0]=a/w,t[1]=d/w,t[2]=c/w)),{k:r,v1:t,v2:s,v3:i}}getEigenForSelection(e,t){let s,i=this.icn3dui,n=new THREE.Vector3,l=[];for(s=0;s0&&Math.abs(l[0].x-e[0].x)<=6&&Math.abs(l[0].y-e[0].y)<=6&&Math.abs(l[0].z-e[0].z)<=6?(p.push(l[0]),m=1):m=0,p.push(e[0]);for(let t=1,s=e.length-1;t0&&Math.abs(r[0].x-e[e.length-1].x)<=6&&Math.abs(r[0].y-e[e.length-1].y)<=6&&Math.abs(r[0].z-e[e.length-1].z)<=6&&(p.push(r[0]),++g),u>1&&Math.abs(r[0].x-r[1].x)<=6&&Math.abs(r[0].y-r[1].y)<=6&&Math.abs(r[0].z-r[1].z)<=6&&(p.push(r[1]),++g);let f=[],b=[],C=[];o&&(g=u>0?u-1:0);let y;for(let e=-1,n=p.length,l=1/s;e<=n-3;++e){y=e-m;let r=p[-1===e?0:e],o=p[e+1],u=p[e+2],v=p[e===n-3?n-1:e+3],w=0,_=a.subdivideCls.getKnot(1,w,r,o),S=a.subdivideCls.getKnot(1,_,o,u),A=a.subdivideCls.getKnot(1,S,u,v);_-w<1e-4&&(_=w+1),S-_<1e-4&&(S=_+1),A-S<1e-4&&(A=S+1),e>-1&&(void 0===i||i[y+1])&&e>=-1+m&&e<=n-3-g+1&&(d=d.concat(f),c=c.concat(b),h=h.concat(C)),f=[],b=[],C=[];let x=(S-_)*l;for(let l=0;l=-1+m&&e<=n-3-g&&i[y+1]&&l<=parseInt(s/2)&&(d.push(new THREE.Vector3(k,O,R)),c.push(i[y+1]),h.push(t[y+1])),e>=-1+m&&e<=n-3-g+1&&i[y+2]&&l>parseInt(s/2)&&(f.push(new THREE.Vector3(k,O,R)),b.push(i[y+2]),C.push(t[y+2]))):e>=-1+m&&e<=n-3-g&&(d.push(new THREE.Vector3(k,O,R)),c.push(y+1),h.push(t[y+1]))}}i&&!i[y+1]||(d=d.concat(f),c=c.concat(b),h=h.concat(C),d.push(p[p.length-1-g]),c.push(p.length-1-g),h.push(t[p.length-1-g])),f=[],b=[],C=[],p=[];let v=[];return v.push(d),v.push(c),v.push(h),v}getKnot(e,t,s,i){return this.icn3dui,s.distanceTo(i)+t}getValueFromKnot(e,t,s,i,n,l,r,o,a){this.icn3dui;let d,c,h=(r-l)/(s-t),p=(o-r)/(i-s),m=(a-o)/(n-i),u=(s+i)*(s+i)-4*(t*s+i*n-t*n);return 0==u?(d=9999,c=9999):(d=6*(3*p*s+2*h*n+m*s-2*h*s-2*p*n-p*i-m*s)/u,c=6*(3*p*i+2*m*t+h*s-2*p*t-2*m*i-h*i-p*s)/u),p*(e-s)+r+((2*d+c)/6/(s-i)*(e-s)*(e-i)*(e-i)+(2*c+d)/6/(i-s)*(e-s)*(e-s)*(e-i))}}class o{constructor(e){this.icn3dui=e}passFloat32(e,t){let s=this.icn3dui,i=e.length;t||(t=new Uint8Array(4*i));let n=s.convertTypeCls.getDataView(t);for(let t=0;t  Very high (pLDDT > 90)
      Confident (90 > pLDDT > 70)
      Low (70 > pLDDT > 50)
      Very low (pLDDT < 50)
    '}setLegendHtml(e){let t=this.icn3dui.icn3d,s="
    ";if(e)s+=this.setAlphaFoldLegend();else{s+="
    "+t.startValue+""+t.midValue+""+t.endValue+"
    "}return s}SetChainsAdvancedMenu(){let e=this.icn3dui,t=e.icn3d;if(void 0===t.bSetChainsAdvancedMenu||!t.bSetChainsAdvancedMenu){let s=e.hashUtilsCls.cloneHash(t.hAtoms);t.definedSetsCls.setPredefinedInMenu(),t.bSetChainsAdvancedMenu=!0,t.hAtoms=e.hashUtilsCls.cloneHash(s)}}setSetsMenus(e,t){let s=this.icn3dui,i=s.icn3d;this.SetChainsAdvancedMenu();let n=e,l=e+"2",r=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+s.pre+n).length&&$("#"+s.pre+n).html(" "+r),!t&&$("#"+s.pre+l).length&&$("#"+s.pre+l).html(" "+r),$("#"+s.pre+n).resizable(),t||$("#"+s.pre+l).resizable()}applyShownMenus(){let e=this.icn3dui;e.icn3d;let t=[];for(let s in e.htmlCls.allMenus)e.htmlCls.shownMenus.hasOwnProperty(s)?$("#"+e.pre+s).parent().show():($("#"+e.pre+s).parent().hide(),t.push(s));Object.keys(e.htmlCls.shownMenus).length==Object.keys(e.htmlCls.allMenus).length?$(".icn3d-menusep").show():$(".icn3d-menusep").hide(),localStorage&&localStorage.setItem("hiddenmenus",JSON.stringify(t))}getHiddenMenusFromCache(){let e=this.icn3dui;e.icn3d,e.htmlCls.shownMenus={};let t=localStorage?localStorage.getItem("hiddenmenus"):"";if(t&&"[]"!=t){let s=JSON.parse(t);for(let t in e.htmlCls.allMenus)-1==s.indexOf(t)&&(e.htmlCls.shownMenus[t]=1)}else e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.allMenus)}displayShownMenus(){let e=this.icn3dui;e.icn3d;let t="
    ";t+="",t+="";for(let s in e.htmlCls.allMenusSel){if("uniclr"==s.substr(0,6)||"mn5_opacity"==s.substr(0,11)||"mn6_labelscale"==s.substr(0,14)||"faq_"==s.substr(0,4)||"dev_"==s.substr(0,4))continue;"mn1_searchstru"==s?t+="
    FileSelectViewStyleColorAnalysisHelp
    ":("mn2_definedsets"==s||"mn2_show_selected"==s||"mn3_proteinwrap"==s||e.cfg.cid&&"mn3_ligwrap"==s||"mn4_clrwrap"==s||"mn6_selectannotations"==s||"abouticn3d"==s)&&(t+="");let i=e.htmlCls.shownMenus.hasOwnProperty(s)?"checked":"",n=e.htmlCls.allMenusSel[s];t+=""+e.htmlCls.allMenus[s]+"
    "}t+="
    ",$("#"+e.pre+"menulist").html(t)}clickMenu1(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds("#"+e.pre+"mn1_vastplus","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_vastplus","Please input PDB ID for VAST+")})),e.myEventCls.onIds("#"+e.pre+"mn1_vast","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_vast","Please input chain or PDB file for VAST")})),e.myEventCls.onIds("#"+e.pre+"mn1_foldseek","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_foldseek","Submit your selection to Foldseek")})),e.myEventCls.onIds("#"+e.pre+"mn1_mmtfid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmtfid","Please input MMTF ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_pdbid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pdbid","Please input PDB ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_afid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_afid","Please input AlphaFold UniProt ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_refseqid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_refseqid","Please input NCBI Protein Accession")})),e.myEventCls.onIds("#"+e.pre+"mn1_opmid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_opmid","Please input OPM PDB ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_align","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_align","Align two PDB structures")})),e.myEventCls.onIds("#"+e.pre+"mn1_alignaf","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_alignaf","Align two AlphaFold structures")})),e.myEventCls.onIds("#"+e.pre+"mn1_chainalign","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_chainalign","Align multiple chains by structure alignment")})),e.myEventCls.onIds("#"+e.pre+"mn1_chainalign2","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_chainalign2","Align multiple chains by sequence alignment")})),e.myEventCls.onIds("#"+e.pre+"mn1_chainalign3","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_chainalign3","Align multiple chains residue by residue")})),e.myEventCls.onIds("#"+e.pre+"mn1_mutation","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mutation","Show the mutations in 3D")})),e.myEventCls.onIds("#"+e.pre+"mn1_pdbfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pdbfile","Please input PDB File")})),e.myEventCls.onIds(["#"+e.pre+"mn1_pdbfile_app","#"+e.pre+"tool_pdbfile"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pdbfile_app","Please append PDB Files")})),e.myEventCls.onIds("#"+e.pre+"mn1_mol2file","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mol2file","Please input Mol2 File")})),e.myEventCls.onIds("#"+e.pre+"mn1_sdffile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_sdffile","Please input SDF File")})),e.myEventCls.onIds("#"+e.pre+"mn1_xyzfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_xyzfile","Please input XYZ File")})),e.myEventCls.onIds("#"+e.pre+"mn1_afmapfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_afmapfile","Please input AlphaFold PAE File")})),e.myEventCls.onIds("#"+e.pre+"mn1_urlfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_urlfile","Load data by URL")})),e.myEventCls.onIds("#"+e.pre+"mn1_fixedversion","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_fixedversion","Open Share Link URL in the archived version of iCn3D")})),e.myEventCls.onIds("#"+e.pre+"reload_fixedversion","click",(function(s){let i=e.icn3d,n=$("#"+e.pre+"sharelinkurl").val();t.setLogCmd("open "+n,!1),localStorage.setItem("fixedversion","1");let l=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(n,l)})),e.myEventCls.onIds("#"+e.pre+"mn1_mmciffile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmciffile","Please input mmCIF File")})),e.myEventCls.onIds("#"+e.pre+"mn1_mmcifid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmcifid","Please input mmCIF ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_mmdbid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmdbid","Please input MMDB or PDB ID")})),e.myEventCls.onIds(["#"+e.pre+"mn1_mmdbafid",,"#"+e.pre+"tool_mmdbafid"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmdbafid","Please input PDB/MMDB/AlphaFold UniProt IDs")})),e.myEventCls.onIds("#"+e.pre+"mn1_blast_rep_id","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_blast_rep_id","Align sequence to structure")})),e.myEventCls.onIds("#"+e.pre+"mn1_gi","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_gi","Please input protein gi")})),e.myEventCls.onIds("#"+e.pre+"mn1_cid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_cid","Please input PubChem CID")})),e.myEventCls.onIds("#"+e.pre+"mn1_pngimage","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pngimage","Please input the PNG image")})),e.myEventCls.onIds("#"+e.pre+"mn1_state","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_state","Please input the state file")})),e.myEventCls.onIds("#"+e.pre+"mn1_selection","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_selection","Please input the selection file")})),e.myEventCls.onIds("#"+e.pre+"mn1_dsn6","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_dsn6","Please input the DSN6 file to display electron density map")})),e.myEventCls.onIds(["#"+e.pre+"mn1_delphi","#"+e.pre+"mn1_delphi2","#"+e.pre+"tool_delphi"],"click",(function(t){e.icn3d.loadPhiFrom="delphi",$("#"+e.pre+"dl_delphi_tabs").tabs(),e.htmlCls.dialogCls.openDlg("dl_delphi","Please set parameters to display DelPhi potential map")})),e.myEventCls.onIds("#"+e.pre+"mn1_phi","click",(function(t){e.icn3d.loadPhiFrom="phi",$("#"+e.pre+"dl_phi_tabs").tabs(),$("#"+e.pre+"phitab1_tabs").tabs(),$("#"+e.pre+"phitab2_tabs").tabs(),e.htmlCls.dialogCls.openDlg("dl_phi","Please input local phi or cube file to display DelPhi potential map")})),e.myEventCls.onIds("#"+e.pre+"mn1_phiurl","click",(function(t){e.icn3d.loadPhiFrom="phiurl",$("#"+e.pre+"dl_phiurl_tabs").tabs(),$("#"+e.pre+"phiurltab1_tabs").tabs(),$("#"+e.pre+"phiurltab2_tabs").tabs(),e.htmlCls.dialogCls.openDlg("dl_phiurl","Please input URL phi or cube file to display DelPhi potential map")})),e.myEventCls.onIds("#"+e.pre+"mn1_dsn6url","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_dsn6url","Please input the DSN6 file to display electron density map")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportState","click",(function(s){let i=e.icn3d;t.setLogCmd("export state file",!1);let n=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(n+"_statefile.txt","command")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportPdbRes","click",(function(s){e.icn3d,e.htmlCls.setHtmlCls.exportPdb(),t.setLogCmd("export pdb",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportSecondary","click",(function(s){e.icn3d,e.htmlCls.setHtmlCls.exportSecondary(),t.setLogCmd("export secondary structure",!0)})),e.myEventCls.onIds(["#"+e.pre+"delphipdb","#"+e.pre+"phipdb"],"click",(function(s){let i=e.icn3d,n=i.saveFileCls.getSelectedResiduePDB();t.setLogCmd("export PDB of selected residues",!1);let l=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(l+"_icn3d_residues.pdb","text",[n])})),e.myEventCls.onIds(["#"+e.pre+"delphipqr","#"+e.pre+"phipqr","#"+e.pre+"phiurlpqr"],"click",(async function(s){e.icn3d,await e.htmlCls.setHtmlCls.exportPqr(),t.setLogCmd("export pqr",!0)})),e.myEventCls.onIds("#"+e.pre+"profixpdb","click",(async function(s){let i=e.icn3d;await i.scapCls.exportPdbProfix(!1),t.setLogCmd("export pdb missing atoms",!0)})),e.myEventCls.onIds("#"+e.pre+"profixpdbh","click",(async function(s){let i=e.icn3d;await i.scapCls.exportPdbProfix(!0),t.setLogCmd("export pdb hydrogen",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportStl","click",(function(s){let i=e.icn3d;t.setLogCmd("export stl file",!1),i.export3DCls.exportStlFile("")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportVrml","click",(function(s){let i=e.icn3d;t.setLogCmd("export vrml file",!1),i.export3DCls.exportVrmlFile("")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportStlStab","click",(function(s){let i=e.icn3d;t.setLogCmd("export stl stabilizer file",!1),i.threeDPrintCls.hideStabilizer(),i.threeDPrintCls.resetAfter3Dprint(),i.threeDPrintCls.addStabilizer(),i.export3DCls.exportStlFile("_stab")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportVrmlStab","click",(function(s){let i=e.icn3d;t.setLogCmd("export vrml stabilizer file",!1),i.threeDPrintCls.hideStabilizer(),i.threeDPrintCls.resetAfter3Dprint(),i.threeDPrintCls.addStabilizer(),i.export3DCls.exportVrmlFile("_stab")})),e.myEventCls.onIds("#"+e.pre+"mn6_exportInteraction","click",(async function(s){let i=e.icn3d;t.setLogCmd("export interactions",!1),void 0!==e.cfg.mmdbid&&await i.viewInterPairsCls.retrieveInteractionData(),i.viewInterPairsCls.exportInteractions()})),e.myEventCls.onIds(["#"+e.pre+"mn1_exportCanvas","#"+e.pre+"saveimage"],"click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas",!1);await i.shareLinkCls.shareLink(!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas1","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 1",!0),i.scaleFactor=1,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas2","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 2",!0),i.scaleFactor=2,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas4","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 4",!0),i.scaleFactor=4,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas8","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 8",!0),i.scaleFactor=8,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCounts","click",(function(s){let i=e.icn3d;t.setLogCmd("export counts",!1);let n='

    Total Count for atoms with coordinates:
    ';n+="",n+="
    Structure CountChain CountResidue CountAtom Count
    "+Object.keys(i.structures).length+""+Object.keys(i.chains).length+""+Object.keys(i.residues).length+""+Object.keys(i.atoms).length+"

    ",n+="Counts by Chain for atoms with coordinates:
    ";let l=Object.keys(i.chains);for(let e=0,t=l.length;e"}n+="
    StructureChainResidue CountAtom Count
    "+r+""+o+""+Object.keys(a).length+""+Object.keys(i.chains[t]).length+"

    ";let r=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(r+"_counts.html","html",n)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportSelections","click",(function(s){let i=e.icn3d;t.setLogCmd("export all selections",!1),t.SetChainsAdvancedMenu();let n=i.saveFileCls.exportCustomAtoms(),l=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(l+"_selections.txt","text",[n])})),e.myEventCls.onIds("#"+e.pre+"mn1_exportSelDetails","click",(function(s){let i=e.icn3d;t.setLogCmd("export all selections with details",!1),t.SetChainsAdvancedMenu();let n=i.saveFileCls.exportCustomAtoms(!0),l=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(l+"_sel_details.txt","text",[n])})),e.myEventCls.onIds(["#"+e.pre+"mn1_sharelink","#"+e.pre+"tool_sharelink"],"click",(async function(t){let s=e.icn3d;await s.shareLinkCls.shareLink()})),e.myEventCls.onIds("#"+e.pre+"mn1_replayon","click",(async function(s){let i=e.icn3d;await i.resizeCanvasCls.replayon(),t.setLogCmd("replay on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_replayoff","click",(async function(s){let i=e.icn3d;await i.resizeCanvasCls.replayoff(),t.setLogCmd("replay off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_menuall","click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.allMenus),t.applyShownMenus()})),e.myEventCls.onIds("#"+e.pre+"mn1_menusimple","click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.simpleMenus),t.applyShownMenus()})),e.myEventCls.onIds("#"+e.pre+"mn1_menupref","click",(function(s){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_menupref","Select Menus"),t.getHiddenMenusFromCache(),t.displayShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"apply_menupref","#"+e.pre+"apply_menupref2"],"click",(function(s){e.icn3d;var i=document.querySelectorAll('form[name="'+e.pre+'selmenu"] input:checked');for(var n of(e.htmlCls.shownMenus={},i))e.htmlCls.shownMenus[n.value]=1;t.applyShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"reset_menupref","#"+e.pre+"reset_menupref2"],"click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.simpleMenus),t.applyShownMenus(),t.displayShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"reset_menupref_all","#"+e.pre+"reset_menupref_all2"],"click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.allMenus),t.applyShownMenus(),t.displayShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"savepref","#"+e.pre+"savepref2"],"click",(function(t){let s=e.icn3d,i="[";var n=document.querySelectorAll('form[name="'+e.pre+'selmenu"] input:not(:checked)');let l=0;for(var r of n)l>0&&(i+=", "),i+='"'+r.value+'"',++l;i+="]",s.saveFileCls.saveFile("icn3d_menus_pref.txt","text",[i])})),e.myEventCls.onIds("#"+e.pre+"reload_menupreffile","click",(function(s){e.icn3d,e.cfg.notebook||dialog.dialog("close");let i=$("#"+e.pre+"menupreffile")[0].files[0];if(i){e.htmlCls.setHtmlCls.fileSupport();let s=new FileReader;s.onload=function(s){let i=s.target.result,n=JSON.parse(i);e.htmlCls.shownMenus={};for(let t in e.htmlCls.allMenus)-1==n.indexOf(t)&&(e.htmlCls.shownMenus[t]=1);t.applyShownMenus(),t.displayShownMenus()},s.readAsText(i)}else alert("Please select a file before clicking 'Load'")})),e.myEventCls.onIds("#"+e.pre+"mn1_menuloadpref","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_menuloadpref","Please input the menu preference file")})),e.myEventCls.onIds("#"+e.pre+"mn1_link_structure","click",(function(t){let s=e.icn3d,i=s.saveFileCls.getLinkToStructureSummary(!0),n=s.structures&&Object.keys(s.structures).length>0?"_blank":"_self";window.open(i,n)})),e.myEventCls.onIds("#"+e.pre+"mn1_link_bind","click",(function(s){let i=e.icn3d;url="https://www.ncbi.nlm.nih.gov/pccompound?LinkName=pccompound_structure&from_uid="+i.inputid,t.setLogCmd("link to 3D protein structures bound to CID "+i.inputid+": "+url,!1);let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(url,n)})),e.myEventCls.onIds("#"+e.pre+"mn1_link_vast","click",(function(s){let i=e.icn3d;if(void 0===i.inputid)url="https://www.ncbi.nlm.nih.gov/pccompound?term="+i.molTitle,t.setLogCmd("link to compounds "+i.molTitle+": "+url,!1);else{let s;if(void 0!==e.cfg.cid)s="https://www.ncbi.nlm.nih.gov/pccompound?LinkName=pccompound_pccompound_3d&from_uid="+i.inputid,t.setLogCmd("link to compounds with structure similar to CID "+i.inputid+": "+s,!1);else{let n=i.inputid.split("_");1===n.length?(s=e.htmlCls.baseUrl+"vastplus/vastplus.cgi?uid="+i.inputid,t.setLogCmd("link to structures similar to "+i.inputid+": "+s,!1)):2===n.length&&(s=e.htmlCls.baseUrl+"vastplus/vastplus.cgi?uid="+n[0],t.setLogCmd("link to structures similar to "+n[0]+": "+s,!1))}}let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(url,n)})),e.myEventCls.onIds("#"+e.pre+"mn1_link_pubmed","click",(function(s){let i=e.icn3d;if(void 0===i.inputid){let e;e="https://www.ncbi.nlm.nih.gov/pubmed/?term="+i.molTitle,t.setLogCmd("link to literature about "+i.molTitle+": "+e,!1);let s=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(e,s)}else if(i.pmid){let e,s=i.pmid.toString().split("_");1===s.length?(e="https://www.ncbi.nlm.nih.gov/pubmed/"+i.pmid,t.setLogCmd("link to PubMed ID "+i.pmid+": "+e,!1)):2===s.length&&(e="https://www.ncbi.nlm.nih.gov/pubmed/?term="+s[0]+" OR "+s[1],t.setLogCmd("link to PubMed IDs "+s[0]+", "+s[1]+": "+e,!1));let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(e,n)}else if(isNaN(i.inputid)){let e,s=i.inputid.toString().split("_");1===s.length?(e="https://www.ncbi.nlm.nih.gov/pubmed/?term="+i.inputid,t.setLogCmd("link to literature about PDB "+i.inputid+": "+e,!1)):2===s.length&&(e="https://www.ncbi.nlm.nih.gov/pubmed/?term="+s[0]+" OR "+s[1],t.setLogCmd("link to literature about PDB "+s[0]+" OR "+s[1]+": "+e,!1));let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(e,n)}else void 0!==e.cfg.cid?alert("No literature information is available for this compound in the SDF file."):alert("No literature information is available for this structure.")})),e.myEventCls.onIds("#"+e.pre+"mn1_link_protein","click",(function(s){let i=e.icn3d,n=Object.keys(i.structures),l=Object.keys(i.chains),r="";for(let e=0,t=l.length;e0&&(r=r.substr(0,r.length-4));let o="https://www.ncbi.nlm.nih.gov/protein/?term="+r;t.setLogCmd("link to Entrez protein about PDB "+n+": "+o,!1);let a=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(o,a)}))}clickMenu2(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds(["#"+e.pre+"mn6_selectannotations","#"+e.pre+"tool_selectannotations"],"click",(async function(s){let i=e.icn3d;await i.showAnnoCls.showAnnotations(),t.setLogCmd("view annotations",!0)})),e.myEventCls.onIds("#"+e.pre+"mn2_selectall","click",(function(s){let i=e.icn3d;t.setLogCmd("select all",!0),i.selectionCls.selectAll(),i.hlUpdateCls.removeHlAll(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"clearall","click",(function(s){let i=e.icn3d;t.setLogCmd("clear all",!0),i.bSelectResidue=!1,i.selectionCls.selectAll(),i.hlUpdateCls.removeHlAll(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn2_selectdisplayed","click",(function(s){let i=e.icn3d;t.setLogCmd("select displayed set",!0),i.hAtoms=e.hashUtilsCls.cloneHash(i.viewSelectionAtoms),i.hlUpdateCls.updateHlAll()})),e.myEventCls.onIds("#"+e.pre+"mn2_fullstru","click",(function(s){let i=e.icn3d;t.setLogCmd("show all",!0),i.selectionCls.showAll()})),e.myEventCls.onIds("#"+e.pre+"mn2_selectcomplement","click",(function(s){let i=e.icn3d;Object.keys(i.hAtoms).lengthnon-selected"+n),$("#"+e.pre+"atomsCustomSphere2").length&&$("#"+e.pre+"atomsCustomSphere2").html(" "+n),e.htmlCls.dialogCls.openDlg("dl_aroundsphere","Select a sphere around a set of residues"),i.bSphereCalc=!1,$("#"+e.pre+"atomsCustomSphere").resizable(),$("#"+e.pre+"atomsCustomSphere2").resizable()})),e.myEventCls.onIds(["#"+e.pre+"mn2_select_chain","#"+e.pre+"definedSets"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_select_chain","Select Structure/Chain/Custom Selection")}))}clickMenu3(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds(["#"+e.pre+"mn3_proteinsRibbon","#"+e.pre+"tool_proteinsRibbon"],"click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","ribbon"),t.setLogCmd("style proteins ribbon",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsStrand","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","strand"),t.setLogCmd("style proteins strand",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsCylinder","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","cylinder and plate"),t.setLogCmd("style proteins cylinder and plate",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsSchematic","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","schematic"),t.setLogCmd("style proteins schematic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsCalpha","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","c alpha trace"),t.setLogCmd("style proteins c alpha trace",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsBackbone","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","backbone"),t.setLogCmd("style proteins backbone",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsBfactor","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","b factor tube"),t.setLogCmd("style proteins b factor tube",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsLines","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","lines"),t.setLogCmd("style proteins lines",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsStick","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","stick"),t.setLogCmd("style proteins stick",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn3_proteinsBallstick","#"+e.pre+"tool_proteinsBallstick"],"click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","ball and stick"),t.setLogCmd("style proteins ball and stick",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn3_proteinsSphere","#"+e.pre+"tool_proteinsSphere"],"click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","sphere"),t.setLogCmd("style proteins sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsNo","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","nothing"),t.setLogCmd("style proteins nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecLines","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","lines2"),t.setLogCmd("style sidec lines2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecStick","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","stick2"),t.setLogCmd("style sidec stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","ball and stick2"),t.setLogCmd("style sidec ball and stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","sphere2"),t.setLogCmd("style sidec sphere2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecNo","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","nothing"),t.setLogCmd("style sidec nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseLines","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","lines2"),t.setLogCmd("style ntbase lines2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseStick","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","stick2"),t.setLogCmd("style ntbase stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","ball and stick2"),t.setLogCmd("style ntbase ball and stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","sphere2"),t.setLogCmd("style ntbase sphere2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseNo","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","nothing"),t.setLogCmd("style ntbase nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclCartoon","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","nucleotide cartoon"),t.setLogCmd("style nucleotides nucleotide cartoon",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclBackbone","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","backbone"),t.setLogCmd("style nucleotides backbone",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclSchematic","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","schematic"),t.setLogCmd("style nucleotides schematic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclPhos","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","o3 trace"),t.setLogCmd("style nucleotides o3 trace",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclLines","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","lines"),t.setLogCmd("style nucleotides lines",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclStick","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","stick"),t.setLogCmd("style nucleotides stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","ball and stick"),t.setLogCmd("style nucleotides ball and stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","sphere"),t.setLogCmd("style nucleotides sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclNo","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","nothing"),t.setLogCmd("style nucleotides nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligLines","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","lines"),t.setLogCmd("style chemicals lines",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligStick","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","stick"),t.setLogCmd("style chemicals stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","ball and stick"),t.setLogCmd("style chemicals ball and stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligSchematic","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","schematic"),t.setLogCmd("style chemicals schematic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","sphere"),t.setLogCmd("style chemicals sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligNo","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","nothing"),t.setLogCmd("style chemicals nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_glycansCartYes","click",(function(s){let i=e.icn3d;i.bGlycansCartoon=!0,i.drawCls.draw(),t.setLogCmd("glycans cartoon yes",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_glycansCartNo","click",(function(s){let i=e.icn3d;i.bGlycansCartoon=!1,i.drawCls.draw(),t.setLogCmd("glycans cartoon no",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_hydrogensYes","click",(function(s){let i=e.icn3d;i.showInterCls.showHydrogens(),i.drawCls.draw(),t.setLogCmd("hydrogens",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_hydrogensNo","click",(function(s){let i=e.icn3d;i.showInterCls.hideHydrogens(),i.drawCls.draw(),t.setLogCmd("set hydrogens off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ionsSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("ions","sphere"),t.setLogCmd("style ions sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ionsDot","click",(function(s){e.icn3d.setOptionCls.setStyle("ions","dot"),t.setLogCmd("style ions dot",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ionsNo","click",(function(s){e.icn3d.setOptionCls.setStyle("ions","nothing"),t.setLogCmd("style ions nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_waterSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("water","sphere"),t.setLogCmd("style water sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_waterDot","click",(function(s){e.icn3d.setOptionCls.setStyle("water","dot"),t.setLogCmd("style water dot",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_waterNo","click",(function(s){e.icn3d.setOptionCls.setStyle("water","nothing"),t.setLogCmd("style water nothing",!0)}))}clickMenu4(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrum","click",(function(s){e.icn3d.setOptionCls.setOption("color","spectrum"),t.setLogCmd("color spectrum",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrumChain","click",(function(s){e.icn3d.setOptionCls.setOption("color","spectrum for chains"),t.setLogCmd("color spectrum for chains",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrumAcrossSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorSpectrumAcross").length&&$("#"+e.pre+"atomsCustomColorSpectrumAcross").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorspectrumacrosssets","Please select sets to apply spectrum color for sets"),$("#"+e.pre+"atomsCustomColorSpectrumAcross").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrumSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorSpectrum").length&&$("#"+e.pre+"atomsCustomColorSpectrum").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorspectrumbysets","Please select sets to apply spectrum color for residues"),$("#"+e.pre+"atomsCustomColorSpectrum").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrRainbowAcrossSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorRainbowAcross").length&&$("#"+e.pre+"atomsCustomColorRainbowAcross").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorrainbowacrosssets","Please select sets to apply rainbow color for sets"),$("#"+e.pre+"atomsCustomColorRainbowAcross").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrRainbowSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorRainbow").length&&$("#"+e.pre+"atomsCustomColorRainbow").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorrainbowbysets","Please select sets to apply rainbow color for residues"),$("#"+e.pre+"atomsCustomColorRainbow").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrRainbow","click",(function(s){e.icn3d.setOptionCls.setOption("color","rainbow"),t.setLogCmd("color rainbow",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrRainbowChain","#"+e.pre+"tool_clrRainbowChain"],"click",(function(s){e.icn3d.setOptionCls.setOption("color","rainbow for chains"),t.setLogCmd("color rainbow for chains",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrChain","#"+e.pre+"tool_clrChain"],"click",(function(s){e.icn3d.setOptionCls.setOption("color","chain"),t.setLogCmd("color chain",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrStructure","click",(function(s){e.icn3d.setOptionCls.setOption("color","structure"),t.setLogCmd("color structure",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrdomain","click",(function(s){e.icn3d.setOptionCls.setOption("color","domain"),t.setLogCmd("color domain",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrsets","click",(function(s){e.icn3d.setOptionCls.setOption("color","defined sets"),t.setLogCmd("color defined sets",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrSSGreen","#"+e.pre+"tool_clrSSGreen"],"click",(function(s){let i=e.icn3d;i.sheetcolor="green",i.setOptionCls.setOption("color","secondary structure green"),t.setLogCmd("color secondary structure green",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSSYellow","click",(function(s){let i=e.icn3d;i.sheetcolor="yellow",i.setOptionCls.setOption("color","secondary structure yellow"),t.setLogCmd("color secondary structure yellow",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSSSpectrum","click",(function(s){e.icn3d.setOptionCls.setOption("color","secondary structure spectrum"),t.setLogCmd("color secondary structure spectrum",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrResidue","click",(function(s){e.icn3d.setOptionCls.setOption("color","residue"),t.setLogCmd("color residue",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrResidueCustom","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_rescolorfile","Please input the file on residue colors")})),e.myEventCls.onIds("#"+e.pre+"reload_rescolorfile","click",(function(s){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close");let n=$("#"+e.pre+"rescolorfile")[0].files[0];if(n){e.htmlCls.setHtmlCls.fileSupport();let s=new FileReader;s.onload=function(s){let n=s.target.result.replace(/#/g,"");i.customResidueColors=JSON.parse(n);for(let t in i.customResidueColors)i.customResidueColors[t.toUpperCase()]=e.parasCls.thr("#"+i.customResidueColors[t]);i.setOptionCls.setOption("color","residue custom"),t.setLogCmd("color residue custom | "+n,!0)},s.readAsText(n)}else alert("Please select a file before clicking 'Load'")})),e.myEventCls.onIds("#"+e.pre+"reload_customcolorfile","click",(function(s){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close"),i.startColor=$("#"+e.pre+"startColor").val(),i.midColor=$("#"+e.pre+"midColor").val(),i.endColor=$("#"+e.pre+"endColor").val();let n=t.setLegendHtml();$("#"+e.pre+"dl_legend").html(n),e.htmlCls.dialogCls.openDlg("dl_legend","Color range"),i.addTrackCls.setCustomFile("color",i.startColor,i.midColor,i.endColor)})),e.myEventCls.onIds("#"+e.pre+"mn6_customref","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_customref","Set custom reference numbers")})),e.myEventCls.onIds("#"+e.pre+"reload_customreffile","click",(function(s){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close");let n=$("#"+i.pre+"cstreffile")[0].files[0];if(n){e.utilsCls.checkFileAPI();let s=new FileReader;s.onload=async function(e){let s=e.target.result;await i.refnumCls.parseCustomRefFile(s),s=s.replace(/\r/g,"").replace(/\n/g,"\\n"),t.setLogCmd("custom refnum | "+s,!0)},s.readAsText(n)}else alert("Please select a file before clicking 'Apply'")})),e.myEventCls.onIds("#"+e.pre+"remove_legend","click",(function(s){e.icn3d,$("#"+e.pre+"legend").hide(),t.setLogCmd("remove legend",!0)})),e.myEventCls.onIds("#"+e.pre+"reload_customtubefile","click",(function(t){let s=e.icn3d;e.cfg.notebook||dialog.dialog("close"),s.addTrackCls.setCustomFile("tube")})),e.myEventCls.onIds("#"+e.pre+"mn4_clrCharge","click",(function(s){e.icn3d.setOptionCls.setOption("color","charge"),t.setLogCmd("color charge",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrHydrophobic","click",(function(s){e.icn3d.setOptionCls.setOption("color","hydrophobic"),t.setLogCmd("color hydrophobic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrNormalizedHP","click",(function(s){e.icn3d.setOptionCls.setOption("color","normalized hydrophobic"),t.setLogCmd("color normalized hydrophobic",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrAtom","#"+e.pre+"tool_clrAtom"],"click",(function(s){e.icn3d.setOptionCls.setOption("color","atom"),t.setLogCmd("color atom",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrBfactor","click",(function(s){e.icn3d.setOptionCls.setOption("color","b factor"),t.setLogCmd("color b factor",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrConfidence","click",(function(s){e.icn3d.setOptionCls.setOption("color","confidence"),t.setLogCmd("color confidence",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrIgstrand","click",(function(s){e.icn3d.setOptionCls.setOption("color","ig strand"),t.setLogCmd("color ig strand",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrArea","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_colorbyarea","Color based on residue's solvent accessibility")})),e.myEventCls.onIds("#"+e.pre+"applycolorbyarea","click",(function(s){let i=e.icn3d;i.midpercent=$("#"+e.pre+"midpercent").val(),i.setOptionCls.setOption("color","area"),t.setLogCmd("color area | "+i.midpercent,!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrBfactorNorm","click",(function(s){e.icn3d.setOptionCls.setOption("color","b factor percentile"),t.setLogCmd("color b factor percentile",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrIdentity","click",(function(s){e.icn3d.setOptionCls.setOption("color","identity"),t.setLogCmd("color identity",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrConserved","click",(function(s){e.icn3d.setOptionCls.setOption("color","conservation"),t.setLogCmd("color conservation",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrCustom","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_clr","Color picker")})),$(document).on("click",".icn3d-color-rad-text",(function(s){let i=e.icn3d;s.stopImmediatePropagation(),s.preventDefault();let n=$(this).attr("color");i.setOptionCls.setOption("color",n),t.setLogCmd("color "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSave","click",(function(s){e.icn3d.setOptionCls.saveColor(),t.setLogCmd("save color",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrApplySave","click",(function(s){e.icn3d.setOptionCls.applySavedColor(),t.setLogCmd("apply saved color",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_styleSave","click",(function(s){e.icn3d.setOptionCls.saveStyle(),t.setLogCmd("save style",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_styleApplySave","click",(function(s){e.icn3d.setOptionCls.applySavedStyle(),t.setLogCmd("apply saved style",!0)}))}clickMenu5(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds("#"+e.pre+"mn5_neighborsYes","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.applyMapCls.removeLastSurface(),i.applyMapCls.applySurfaceOptions(),i.bRender&&i.drawCls.render(),t.setLogCmd("set surface neighbors on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_neighborsNo","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.applyMapCls.removeLastSurface(),i.applyMapCls.applySurfaceOptions(),i.bRender&&i.drawCls.render(),t.setLogCmd("set surface neighbors off",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn5_surfaceVDW","#"+e.pre+"tool_surfaceVDW"],"click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.setOptionCls.setOption("surface","Van der Waals surface"),t.setLogCmd("set surface Van der Waals surface",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceSAS","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.setOptionCls.setOption("surface","solvent accessible surface"),t.setLogCmd("set surface solvent accessible surface",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceMolecular","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.setOptionCls.setOption("surface","molecular surface"),t.setLogCmd("set surface molecular surface",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceVDWContext","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.setOptionCls.setOption("surface","Van der Waals surface with context"),t.setLogCmd("set surface Van der Waals surface with context",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceSASContext","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.setOptionCls.setOption("surface","solvent accessible surface with context"),t.setLogCmd("set surface solvent accessible surface with context",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceMolecularContext","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.setOptionCls.setOption("surface","molecular surface with context"),t.setLogCmd("set surface molecular surface with context",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceNo","click",(function(s){e.icn3d.setOptionCls.setOption("surface","nothing"),t.setLogCmd("set surface nothing",!0)})),$(document).on("click","."+e.pre+"mn5_opacity",(function(s){let i=e.icn3d;i.transparentRenderOrder=!1;let n=$(this).attr("v");i.setOptionCls.setOption("opacity",n),t.setLogCmd("set surface opacity "+n,!0)})),$(document).on("click","."+e.pre+"mn5_opacityslow",(function(s){let i=e.icn3d;i.transparentRenderOrder=!0;let n=$(this).attr("v");i.setOptionCls.setOption("opacity",n),t.setLogCmd("set surface2 opacity "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_wireframeYes","click",(function(s){e.icn3d.setOptionCls.setOption("wireframe","yes"),t.setLogCmd("set surface wireframe on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_wireframeNo","click",(function(s){e.icn3d.setOptionCls.setOption("wireframe","no"),t.setLogCmd("set surface wireframe off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_elecmap2fofc","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_elecmap2fofc","2Fo-Fc Electron Density Map")})),e.myEventCls.onIds("#"+e.pre+"mn5_elecmapfofc","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_elecmapfofc","Fo-Fc Electron Density Map")})),e.myEventCls.onIds(["#"+e.pre+"mn5_elecmapNo","#"+e.pre+"elecmapNo2","#"+e.pre+"elecmapNo3","#"+e.pre+"elecmapNo4","#"+e.pre+"elecmapNo5"],"click",(function(s){e.icn3d.setOptionCls.setOption("map","nothing"),t.setLogCmd("setoption map nothing",!0)})),e.myEventCls.onIds(["#"+e.pre+"delphimapNo","#"+e.pre+"phimapNo","#"+e.pre+"phiurlmapNo","#"+e.pre+"mn1_phimapNo"],"click",(function(s){e.icn3d.setOptionCls.setOption("phimap","nothing"),t.setLogCmd("setoption phimap nothing",!0)})),e.myEventCls.onIds(["#"+e.pre+"delphimapNo2","#"+e.pre+"phimapNo2","#"+e.pre+"phiurlmapNo2"],"click",(function(s){e.icn3d.setOptionCls.setOption("phisurface","nothing"),t.setLogCmd("setoption phisurface nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"applymap2fofc","click",(function(s){let i=e.icn3d,n=parseFloat($("#"+e.pre+"sigma2fofc").val());i.dsn6ParserCls.dsn6Parser(i.inputid,"2fofc",n),t.setLogCmd("set map 2fofc sigma "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"applymapfofc","click",(function(s){let i=e.icn3d,n=parseFloat($("#"+e.pre+"sigmafofc").val());i.dsn6ParserCls.dsn6Parser(i.inputid,"fofc",n),t.setLogCmd("set map fofc sigma "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_mapwireframeYes","click",(function(s){e.icn3d.setOptionCls.setOption("mapwireframe","yes"),t.setLogCmd("set map wireframe on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_mapwireframeNo","click",(function(s){e.icn3d.setOptionCls.setOption("mapwireframe","no"),t.setLogCmd("set map wireframe off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_emmap","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_emmap","EM Density Map")})),e.myEventCls.onIds(["#"+e.pre+"mn5_emmapNo","#"+e.pre+"emmapNo2"],"click",(function(s){e.icn3d.setOptionCls.setOption("emmap","nothing"),t.setLogCmd("setoption emmap nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"applyemmap","click",(function(s){let i=e.icn3d,n=parseFloat($("#"+e.pre+"empercentage").val());i.densityCifParserCls.densityCifParser(i.inputid,"em",n,i.emd),t.setLogCmd("set emmap percentage "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_emmapwireframeYes","click",(function(s){e.icn3d.setOptionCls.setOption("emmapwireframe","yes"),t.setLogCmd("set emmap wireframe on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_emmapwireframeNo","click",(function(s){e.icn3d.setOptionCls.setOption("emmapwireframe","no"),t.setLogCmd("set emmap wireframe off",!0)}))}clickMenu6(){let e=this.icn3dui,t=e.icn3d;if(e.bNode)return;let s=this;e.myEventCls.onIds("#"+e.pre+"mn6_assemblyYes","click",(function(t){let i=e.icn3d;i.bAssembly=!0,s.setLogCmd("set assembly on",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_assemblyNo","click",(function(t){let i=e.icn3d;i.bAssembly=!1,s.setLogCmd("set assembly off",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_igrefYes","click",(async function(t){let i=e.icn3d;s.setLogCmd("ig refnum on",!0),await i.refnumCls.showIgRefNum()})),e.myEventCls.onIds("#"+e.pre+"mn6_igrefNo","click",(async function(t){let i=e.icn3d;s.setLogCmd("ig refnum off",!0),await i.refnumCls.hideIgRefNum()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelAtoms","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addAtomLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add atom labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelElements","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addAtomLabels(i.hAtoms,!0),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add element labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelResidues","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addResidueLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add residue labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelResnum","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addResidueLabels(i.hAtoms,void 0,void 0,!0),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add residue number labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelChains","click",(function(t){let i=e.icn3d;i.analysisCls.addChainLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add chain labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelTermini","click",(function(t){let i=e.icn3d;i.analysisCls.addTerminiLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add terminal labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelYes","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_addlabel","Add custom labels by selection"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelSelection","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_addlabelselection","Add custom labels by the selected")})),e.myEventCls.onIds("#"+e.pre+"mn6_labelColor","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_labelColor","Change color for all labels")})),e.myEventCls.onIds(["#"+e.pre+"mn2_saveselection","#"+e.pre+"tool_saveselection"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_saveselection","Save the selected")})),e.myEventCls.onIds(["#"+e.pre+"mn6_addlabelNo","#"+e.pre+"removeLabels"],"click",(function(t){let i=e.icn3d;i.labelcolor=void 0,i.pickpair=!1;s.setLogCmd("set labels off",!0);for(let e in i.labels)i.labels[e]=[];i.drawCls.draw()})),$(document).on("click","."+e.pre+"mn6_labelscale",(function(t){let i=e.icn3d,n=$(this).attr("v");i.labelScale=n,i.drawCls.draw(),s.setLogCmd("set label scale "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_distanceYes","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_distance","Measure the distance of atoms"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0,s.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_distTwoSets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_disttwosets","Measure the distance between two sets"),s.setSetsMenus("atomsCustomDist"),i.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_distManySets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_distmanysets","Measure the pairwise distance among many sets"),s.setSetsMenus("atomsCustomDistTable"),i.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_distanceNo","click",(function(t){let i=e.icn3d;i.pickpair=!1;s.setLogCmd("set lines off",!0),i.labels.distance=[],i.lines.distance=[],i.distPnts=[],i.pk=2,i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn5_cartoonshape","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_cartoonshape","Draw cartoon for a set");s.setSetsMenus("cartoonshape",!0),i.bCartoonshape=!0})),e.myEventCls.onIds("#"+e.pre+"mn5_linebtwsets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_linebtwsets","Draw a line between two sets"),s.setSetsMenus("linebtwsets"),i.bLinebtwsets=!0})),e.myEventCls.onIds(["#"+e.pre+"mn2_selectedcenter","#"+e.pre+"zoomin_selection","#"+e.pre+"tool_selectedcenter"],"click",(function(t){let i=e.icn3d;i.transformCls.zoominSelection(),i.drawCls.draw(),s.setLogCmd("zoom selection",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_center","click",(function(t){let i=e.icn3d;i.applyCenterCls.centerSelection(),i.drawCls.draw(),s.setLogCmd("center selection",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_resetOrientation","#"+e.pre+"resetOrientation","#"+e.pre+"tool_resetOrientation"],"click",(function(t){let i=e.icn3d;i.transformCls.resetOrientation(),i.drawCls.draw(),s.setLogCmd("reset orientation",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_chemicalbindingshow","#"+e.pre+"chemicalbindingshow"],"click",(function(t){e.icn3d.setOptionCls.setOption("chemicalbinding","show"),s.setLogCmd("set chemicalbinding show",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_chemicalbindinghide","#"+e.pre+"chemicalbindinghide"],"click",(function(t){e.icn3d.setOptionCls.setOption("chemicalbinding","hide"),s.setLogCmd("set chemicalbinding hide",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_sidebyside","click",(function(t){let i=e.icn3d;if(i.bInputfile)return void alert("Side-by-Side does NOT work when the input is from a local file.");let n=i.shareLinkCls.shareLinkUrl(void 0);n=n.replace("full.html","full2.html"),n+="&closepopup=1";let l=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(n,l),s.setLogCmd("side by side | "+n,!0)})),$(document).on("click","."+e.pre+"mn6_rotate",(function(t){let i=e.icn3d,n=$(this).attr("v").toLowerCase(),l=n.split(" ")[1];s.setLogCmd(n,!0),i.bStopRotate=!1,i.transformCls.rotateCount=0,i.transformCls.rotateCountMax=6e3,i.ROT_DIR=l,i.resizeCanvasCls.rotStruc(l)})),$(document).on("click","."+e.pre+"mn6_rotate90",(function(t){let i,n=e.icn3d,l=$(this).attr("v").toLowerCase(),r=l.split("-")[0];s.setLogCmd(l,!0),"x"==r?i=new THREE.Vector3(1,0,0):"y"==r?i=new THREE.Vector3(0,1,0):"z"==r&&(i=new THREE.Vector3(0,0,1));let o=.5*Math.PI;n.transformCls.setRotation(i,o)})),e.myEventCls.onIds("#"+e.pre+"mn6_cameraPers","click",(function(t){e.icn3d.setOptionCls.setOption("camera","perspective"),s.setLogCmd("set camera perspective",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_cameraOrth","click",(function(t){e.icn3d.setOptionCls.setOption("camera","orthographic"),s.setLogCmd("set camera orthographic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_bkgdBlack","click",(function(t){e.icn3d.setStyleCls.setBackground("black")})),e.myEventCls.onIds("#"+e.pre+"tool_bkgd","click",(function(t){let s=e.icn3d;"black"==s.opts.background?s.setStyleCls.setBackground("white"):s.setStyleCls.setBackground("black")})),e.myEventCls.onIds("#"+e.pre+"mn6_bkgdGrey","click",(function(t){e.icn3d.setStyleCls.setBackground("grey")})),e.myEventCls.onIds(["#"+e.pre+"mn6_bkgdWhite","#"+e.pre+"tool_bkgdWhite"],"click",(function(t){e.icn3d.setStyleCls.setBackground("white")})),e.myEventCls.onIds("#"+e.pre+"mn6_bkgdTransparent","click",(function(t){e.icn3d.setStyleCls.setBackground("transparent")})),e.myEventCls.onIds("#"+e.pre+"mn6_showfogYes","click",(function(t){let i=e.icn3d;i.opts.fog="yes",i.fogCls.setFog(!0),i.drawCls.draw(),s.setLogCmd("set fog on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showfogNo","click",(function(t){let i=e.icn3d;i.opts.fog="no",i.fogCls.setFog(!0),i.drawCls.draw(),s.setLogCmd("set fog off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showslabYes","click",(function(t){e.icn3d.setOptionCls.setOption("slab","yes"),s.setLogCmd("set slab on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showslabNo","click",(function(t){e.icn3d.setOptionCls.setOption("slab","no"),s.setLogCmd("set slab off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showaxisYes","click",(function(t){e.icn3d.setOptionCls.setOption("axis","yes"),s.setLogCmd("set axis on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showaxisSel","click",(function(t){let i=e.icn3d;i.pc1=!0,i.axesCls.setPc1Axes(),s.setLogCmd("set pc1 axis",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showaxisNo","click",(function(t){let i=e.icn3d;i.pc1=!1,i.axes=[],i.setOptionCls.setOption("axis","no"),s.setLogCmd("set axis off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_symmetry","click",(async function(t){let s=e.icn3d;s.bAxisOnly=!1,await s.symdCls.retrieveSymmetry(Object.keys(s.structures)[0])})),e.myEventCls.onIds("#"+e.pre+"mn6_symd","click",(async function(t){let i=e.icn3d;i.bAxisOnly=!1,await i.symdCls.retrieveSymd(),i.bSymd=!0,s.setLogCmd("symd symmetry",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_clear_sym","click",(function(t){let i=e.icn3d;i.symdArray=[],i.drawCls.draw(),s.setLogCmd("clear symd symmetry",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_axes_only","click",(function(t){let i=e.icn3d;i.bAxisOnly=!0,i.drawCls.draw(),s.setLogCmd("show axis",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_area","click",(function(t){e.icn3d.analysisCls.calculateArea(),s.setLogCmd("area",!0)})),e.myEventCls.onIds("#"+e.pre+"applysymmetry","click",(function(t){let i=e.icn3d;i.bAxisOnly=!1;let n=$("#"+e.pre+"selectSymmetry").val();i.symmetrytitle="none"===n?void 0:n,i.drawCls.draw(),s.setLogCmd("symmetry "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"clearsymmetry","click",(function(t){let i=e.icn3d;i.symmetrytitle=void 0,i.drawCls.draw(),s.setLogCmd("symmetry none",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_hbondsYes","#"+e.pre+"hbondsYes"],"click",(function(t){let i=e.icn3d;s.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomHbond").length&&$("#"+e.pre+"atomsCustomHbond").html(" "+n),$("#"+e.pre+"atomsCustomHbond2").length&&$("#"+e.pre+"atomsCustomHbond2").html(" "+n),e.htmlCls.dialogCls.openDlg("dl_hbonds","Hydrogen bonds/interactions between two sets of atoms"),i.bHbondCalc=!1,$("#"+e.pre+"atomsCustomHbond").resizable(),$("#"+e.pre+"atomsCustomHbond2").resizable()})),e.myEventCls.onIds(["#"+e.pre+"mn6_contactmap"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_contact","Set contact map")})),e.myEventCls.onIds("#"+e.pre+"mn6_hbondsNo","click",(function(t){let s=e.icn3d;s.showInterCls.hideHbondsContacts(),s.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerYes","click",(function(t){let i=e.icn3d;i.threeDPrintCls.addStabilizer(),i.threeDPrintCls.prepareFor3Dprint(),s.setLogCmd("stabilizer",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerNo","click",(function(t){let i=e.icn3d;s.setLogCmd("set stabilizer off",!0),i.threeDPrintCls.hideStabilizer(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerOne","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_stabilizer","Add One Stabilizer"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerRmOne","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_stabilizer_rm","Remove One Stabilizer"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0})),e.myEventCls.onIds("#"+e.pre+"mn1_thicknessSet","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_thickness","Set Thickness for 3D Printing")})),e.myEventCls.onIds("#"+e.pre+"mn3_setThickness","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_thickness2","Style Preferences")})),e.myEventCls.onIds("#"+e.pre+"mn6_ssbondsYes","click",(function(t){let i=e.icn3d;s.setLogCmd("disulfide bonds",!0),i.showInterCls.showSsbonds()})),e.myEventCls.onIds("#"+e.pre+"mn6_ssbondsExport","click",(function(t){e.icn3d.viewInterPairsCls.exportSsbondPairs(),s.setLogCmd("export disulfide bond pairs",!1)})),e.myEventCls.onIds("#"+e.pre+"mn6_ssbondsNo","click",(function(t){let i=e.icn3d;i.opts.ssbonds="no";s.setLogCmd("set disulfide bonds off",!0),i.lines.ssbond=[],i.setOptionCls.setStyle("sidec","nothing")})),e.myEventCls.onIds("#"+e.pre+"mn6_clbondsYes","click",(function(t){let i=e.icn3d;s.setLogCmd("cross linkage",!0),i.showInterCls.showClbonds()})),e.myEventCls.onIds("#"+e.pre+"mn6_clbondsExport","click",(function(t){e.icn3d.viewInterPairsCls.exportClbondPairs(),s.setLogCmd("export cross linkage pairs",!1)})),e.myEventCls.onIds("#"+e.pre+"mn6_clbondsNo","click",(function(t){let i=e.icn3d;i.opts.clbonds="no";s.setLogCmd("set cross linkage off",!0),i.lines.clbond=[],i.setOptionCls.setStyle("sidec","nothing")})),$("#"+e.pre+"newvs2").on("submit",(function(){let s=t.saveFileCls.getAtomPDB(t.hAtoms);return $("#"+e.pre+"pdbstr").val(s),!0})),$("#"+e.pre+"fssubmit").on("click",(function(){let e=t.saveFileCls.getAtomPDB(t.hAtoms),s=window.open("","_blank");s.document.body.innerHTML="\n\nLoading Foldseek\n\n\n\n
    Foldseek is loading...
    \n",$.ajax({url:"https://search.foldseek.com/api/ticket",type:"POST",data:{q:e,database:["afdb50","afdb-swissprot","gmgcl_id","pdb100","afdb-proteome","mgnify_esm30"],mode:"3diaa"},dataType:"text",success:function(e){s.location="https://search.foldseek.com/queue/"+JSON.parse(e).id},error:function(e,t,s){console.log("Error in submitting data to Foldseek...")}})}))}setLogCmd(e,t,s){var i=this.icn3dui,n=i.icn3d;if(""===e.trim())return!1;let l=e.indexOf("|||");-1!==l&&(e=e.substr(0,l));let r={};if(r.factor=n._zoomFactor,r.mouseChange=n.mouseChange,r.quaternion={},r.quaternion._x=parseFloat(n.quaternion._x).toPrecision(5),r.quaternion._y=parseFloat(n.quaternion._y).toPrecision(5),r.quaternion._z=parseFloat(n.quaternion._z).toPrecision(5),r.quaternion._w=parseFloat(n.quaternion._w).toPrecision(5),t&&n.bAddCommands)if(n.STATENUMBER "+n.logs.join("\n> ")+"\n> "),$("#"+i.pre+"logtext")[0]&&$("#"+i.pre+"logtext").scrollTop($("#"+i.pre+"logtext")[0].scrollHeight)}n.setStyleCls.adjustIcon()}}class d{constructor(e){this.icn3dui=e}getLink(e,t,s,i){return this.icn3dui.htmlCls.setHtmlCls.getLink(e,t,s,i)}getMenuText(e,t,s,i,n){return this.icn3dui.htmlCls.setHtmlCls.getMenuText(e,t,s,i,n)}getMenuUrl(e,t,s,i,n){return this.icn3dui.htmlCls.setHtmlCls.getMenuUrl(e,t,s,i,n)}getMenuSep(){return this.icn3dui.htmlCls.setHtmlCls.getMenuSep()}getLinkWrapper(e,t,s,i,n,l){let r=this.icn3dui;return r.icn3d,r.htmlCls.setHtmlCls.getLinkWrapper(e,t,s,i,n,l)}getLinkWrapper2(e,t,s,i,n){let l=this.icn3dui;return l.icn3d,l.htmlCls.setHtmlCls.getLinkWrapper2(e,t,s,i,n)}getRadio(e,t,s,i,n,l){return this.icn3dui.htmlCls.setHtmlCls.getRadio(e,t,s,i,n,l)}getRadClr(e,t,s,i,n,l,r){return this.icn3dui.htmlCls.setHtmlCls.getRadioColor(e,t,s,i,n,l,r)}setTopMenusHtml(e,t,s){let i=this.icn3dui;if(i.bNode)return"";let n="black"==i.htmlCls.opts.background?i.htmlCls.GREYD:"black",l="";l+="
    ",l+=i.htmlCls.divStr+"popup' class='icn3d-text icn3d-popup'>
    ",l+=this.setReplayHtml(),l+="\x3c!--https://forum.jquery.com/topic/looking-for-a-jquery-horizontal-menu-bar--\x3e",l+=i.htmlCls.divStr+"mnlist' style='position:absolute; z-index:999; float:left; display:table-row; margin-top: -2px;'>",l+="";let r='",l+=r+this.setMenu2()+"",l+=r+this.setMenu2b()+"",l+=r+this.setMenu3()+"",l+=r+this.setMenu4()+"",l+=r+this.setMenu5()+"",l+=r+this.setMenu6()+"",i.htmlCls.shownMenus=i.hashUtilsCls.cloneHash(i.htmlCls.simpleMenus),l+=r+"
    "+t,l+="
    "+s,l+=r+'
    '+i.htmlCls.space2+'Toolbar '+i.htmlCls.space2+'
    ",l+=r+'
    '+i.htmlCls.space2+' ?
    ',l+="
    ",l+="
    ';if(l+=r+this.setMenu1()+"
    ",l+="",l+=this.setTools(),l+=i.htmlCls.divStr+"title' class='icn3d-commandTitle' style='font-size:1.2em; font-weight:normal; position:absolute; z-index:1; float:left; display:table-row; margin: 85px 0px 0px 5px; color:"+n+"; width:"+i.htmlCls.WIDTH+"px'>",l+=i.htmlCls.divStr+"viewer' style='position:relative; width:100%; height:100%; background-color: "+i.htmlCls.GREYD+";'>",l+=i.htmlCls.divStr+"mnLogSection'>",l+="
    ",l+=" ",void 0===i.cfg.mmtfid){let e="top:180px; font-size: 1.8em;";l+=i.htmlCls.divStr+"wait' style='position:absolute; left:50px; "+e+" color: #444444;'>Loading data..."}l+="Your browser does not support WebGL.",(void 0===i.cfg.showcommand||i.cfg.showcommand)&&(l+=this.setLogWindow()),l+="",l+="",l+=i.htmlCls.setDialogCls.setDialogs(),l+=i.htmlCls.setDialogCls.setCustomDialogs(),$("#"+e).html(l),$("accordion").accordion({collapsible:!0,active:!1,heightStyle:"content"}),$("accordion div").removeClass("ui-accordion-content ui-corner-all ui-corner-bottom ui-widget-content"),$(".icn3d-mn-item").menu({position:{my:"left top",at:"right top"}}),$(".icn3d-mn-item").hover((function(){}),(function(){$("accordion").accordion("option","active","none")})),$("#"+i.pre+"accordion1").hover((function(){$("#"+i.pre+"accordion1 div").css("display","block")}),(function(){$("#"+i.pre+"accordion1 div").css("display","none")})),$("#"+i.pre+"accordion2").hover((function(){$("#"+i.pre+"accordion2 div").css("display","block")}),(function(){$("#"+i.pre+"accordion2 div").css("display","none")})),$("#"+i.pre+"accordion2b").hover((function(){$("#"+i.pre+"accordion2b div").css("display","block")}),(function(){$("#"+i.pre+"accordion2b div").css("display","none")})),$("#"+i.pre+"accordion3").hover((function(){$("#"+i.pre+"accordion3 div").css("display","block")}),(function(){$("#"+i.pre+"accordion3 div").css("display","none")})),$("#"+i.pre+"accordion4").hover((function(){$("#"+i.pre+"accordion4 div").css("display","block")}),(function(){$("#"+i.pre+"accordion4 div").css("display","none")})),$("#"+i.pre+"accordion5").hover((function(){$("#"+i.pre+"accordion5 div").css("display","block")}),(function(){$("#"+i.pre+"accordion5 div").css("display","none")})),$("#"+i.pre+"accordion6").hover((function(){$("#"+i.pre+"accordion6 div").css("display","block")}),(function(){$("#"+i.pre+"accordion6 div").css("display","none")}))}setTopMenusHtmlMobile(e,t,s){let i=this.icn3dui;if(i.bNode)return"";let n="black"==i.htmlCls.opts.background?i.htmlCls.GREYD:"black",l="";if(l+="
    ",l+=i.htmlCls.divStr+"popup' class='icn3d-text icn3d-popup'>
    ",l+=this.setReplayHtml(),!i.utilsCls.isMobile()){let e=i.htmlCls.WIDTH-40+5;l+=i.htmlCls.buttonStr+"fullscreen' style='position:absolute; z-index:1999; display:block; padding:0px; margin: 12px 0px 0px "+e+"px; width:30px; height:34px; border-radius:4px; border:none; background-color:#f6f6f6;' title='Full screen'>",l+="",l+="",l+="",l+="",l+=""}l+="\x3c!--https://forum.jquery.com/topic/looking-for-a-jquery-horizontal-menu-bar--\x3e",l+=i.htmlCls.divStr+"mnlist' style='position:absolute; z-index:999; float:left; display:block; margin: 5px 0px 0px 5px;'>",l+="
    ",l+="",i.cfg.notebook?l+="

    ":l+="

    ",l+="
    ";let r="
  • File",l+=this.setMenu1_base(),l+=r+">Select",l+=this.setMenu2_base(),l+=r+">View",l+=this.setMenu2b_base(),l+=r+" id='"+i.pre+"style'>Style",l+=this.setMenu3_base(),l+=r+" id='"+i.pre+"color'>Color",l+=this.setMenu4_base(),l+=r+">Analysis",l+=this.setMenu5_base(),l+=r+">Help",l+=this.setMenu6_base(),i.htmlCls.shownMenus=i.hashUtilsCls.cloneHash(i.htmlCls.simpleMenus),l+="
  • "+t,l+="
    "+s,l+="
  • Alternate",l+="",l+="
  • ",l+="
    ",l+="
    ",l+="",l+=i.htmlCls.divStr+"title' class='icn3d-commandTitle' style='font-size:1.2em; font-weight:normal; position:absolute; z-index:1; float:left; display:block; margin: 12px 0px 0px 40px; color:"+n+"; width:"+(i.htmlCls.WIDTH-40).toString()+"px'>",l+=i.htmlCls.divStr+"viewer' style='position:relative; width:100%; height:100%; background-color: "+i.htmlCls.GREYD+";'>",l+=i.htmlCls.divStr+"mnLogSection'>",l+="
    ",l+="",void 0===i.cfg.mmtfid){let e="top:180px; font-size: 1.8em;";l+=i.htmlCls.divStr+"wait' style='position:absolute; left:50px; "+e+" color: #444444;'>Loading data..."}l+="Your browser does not support WebGL.",(void 0===i.cfg.showcommand||i.cfg.showcommand)&&(l+=this.setLogWindow()),l+="",l+="",l+=i.htmlCls.setDialogCls.setDialogs(),l+=i.htmlCls.setDialogCls.setCustomDialogs(),$("#"+e).html(l),$("accordion").accordion({collapsible:!0,active:!1,heightStyle:"content"}),$("accordion div").removeClass("ui-accordion-content ui-corner-all ui-corner-bottom ui-widget-content"),$(".icn3d-mn-item").menu({position:{my:"left top",at:"right top"}}),$(".icn3d-mn-item").hover((function(){}),(function(){$("accordion").accordion("option","active","none")})),$("#"+i.pre+"accordion0").hover((function(){$("#"+i.pre+"accordion0 div").css("display","block")}),(function(){$("#"+i.pre+"accordion0 div").css("display","none")}))}setReplayHtml(e){let t=this.icn3dui;if(t.bNode)return"";let s="";return s+=t.htmlCls.divStr+"replay' style='display:none; position:absolute; z-index:9999; top:"+parseInt(t.htmlCls.HEIGHT-100).toString()+"px; left:20px;'>",s+="
    ",s+='',s+="",s+='',s+='',s+="",s+="
    ",s+=t.htmlCls.divStr+"replay_menu' style='background-color:#DDDDDD; padding:3px; font-weight:bold;'>",s+=t.htmlCls.divStr+"replay_cmd' style='background-color:#DDDDDD; padding:3px; max-width:250px'>",s+="",s}setTools(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+=e.htmlCls.divStr+"selection' style='display:none;'>
    ",t+="",t+=this.setTools_base(),t+="
    ",t+="
    ",t}setButton(e,t,s,i,n){let l=this.icn3dui;return l.bNode?"":(n=void 0!==n?"color:"+n:"","
    ")}setIcon(e,t,s,i,n,l,r){let o=this.icn3dui;if(o.bNode)return"";let a,d=r?"color:#f8b84e; ":"color:#1c94c4; ",c=" background-color:#EEE; ",h="text"==e?"":"cursor:pointer;";return a=l?'
    '+i+"
    ":'',"link"==e?''+a+"":a}setTools_base(){if(this.icn3dui.bNode)return"";let e="",t="regular",s="",i="";return e+=s+this.setIcon(t,"tool_mmdbafid","Input PDB/MMDB/AlphaFold IDs","id",void 0,!0)+"",e+=s+this.setIcon(t,"tool_pdbfile","Input PDB Files (appendable)","file-alt")+"",e+=s+this.setIcon(t,"tool_sharelink","Get Share Link","link")+"",e+=s+this.setIcon(t,"saveimage","Save iCn3D PNG Image","camera")+"",e+=i+this.setIcon(t,"tool_definedsets","Defined Sets","object-group")+"",e+=s+this.setIcon(t,"tool_aroundsphere","Select by Distance","dot-circle")+"",e+=s+this.setIcon(t,"tool_saveselection","Save Selection as a Set","save")+"",e+=s+this.setIcon(t,"toggleHighlight","Toggle Highlight","highlighter")+"",e+=i+this.setIcon(t,"show_selected","View Selection","eye")+"",e+=s+this.setIcon(t,"tool_selectedcenter","Zoom in Selection","search-plus")+"",e+=s+this.setIcon(t,"alternate","Alternate the Structures by keying the letter 'a'","a",void 0,!0,!0)+"",e+=s+this.setIcon(t,"tool_resetOrientation","Reset Orientation","undo-alt")+"",e+=i+this.setIcon(t,"tool_proteinsRibbon","Style Ribbon for proteins","dna")+"",e+=s+this.setIcon(t,"tool_proteinsSphere","Style Sphere for proteins","volleyball-ball")+"",e+=s+this.setIcon(t,"tool_surfaceVDW","Show Van der Waals Surface","cloud")+"",e+=s+this.setIcon(t,"tool_bkgd","Toggle Background Color","adjust")+"",e+=i+this.setIcon(t,"tool_clrRainbowChain","Color Rainbow for Chains","rainbow")+"",e+=s+this.setIcon(t,"tool_clrSSGreen","Color by Secondary Structures","ring")+"",e+=s+this.setIcon(t,"tool_clrChain","Color by Chains","layer-group")+"",e+=s+this.setIcon(t,"tool_clrAtom","Color by Atoms","atom")+"",e+=i+this.setIcon(t,"tool_selectannotations","Sequences & Annotations","grip-lines")+"",e+=s+this.setIcon(t,"hbondsYes","Interactions","users")+"",e+=s+this.setIcon(t,"tool_delphi","Delphi Potentials","cloud-meatball")+"",e+=s+this.setIcon(t,"removeLabels","Remove Labels","remove-format")+"",e+=i+this.setIcon("link","tool-gallery","Gallery","image","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#gallery")+"",e+=s+this.setIcon("link","tool-video","Videos","file-video","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#videos")+"",e+=s+this.setIcon("link","tool-github","iCn3D GitHub","code","https://github.com/ncbi/icn3d")+"",e+=s+this.setIcon("link","tool-hints","Transform Hints","info-circle","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#useicn3d")+"",e+="",e}setTheme(e){let t,s,i,n,l,r=this.icn3dui;if(r.bNode)return"";r.htmlCls.themecolor=e,"orange"==e?(t="#e78f08",s="#f6a828",i="ui-bg_gloss-wave_35_f6a828_500x100.png",n="ui-icons_ef8c08_256x240.png",l="#eb8f00"):"black"==e?(t="#333333",s="#333333",i="ui-bg_gloss-wave_25_333333_500x100.png",n="ui-icons_222222_256x240.png",l="#222222"):"blue"==e&&(t="#4297d7",s="#5c9ccc",i="ui-bg_gloss-wave_55_5c9ccc_500x100.png",n="ui-icons_228ef1_256x240.png",l="#444"),$(".ui-widget-header").css({border:"1px solid "+t,background:s+' url("https://www.ncbi.nlm.nih.gov/Structure/icn3d/lib/images/'+i+'") 50% 50% repeat-x',color:"#fff","font-weight":"bold"}),$(".ui-button .ui-icon").css({"background-image":"url(https://www.ncbi.nlm.nih.gov/Structure/icn3d/lib/images/"+n+")"}),$(".ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited").css({color:l,"text-decoration":"none"})}setLogWindow(e,t){let s=this.icn3dui;if(s.bNode)return"";let i,n="",l=s.htmlCls.setHtmlCls.getCookie("cmdwindow");return""!=l?(i=void 0!==t?t:parseInt(l),1==i?(s.htmlCls.LOG_HEIGHT=180,s.htmlCls.CMD_HEIGHT=.8*s.htmlCls.LOG_HEIGHT,e||(n+=s.htmlCls.divStr+"cmdlog' style='float:left; margin-top: 5px; width: 100%;'>"),n+=""):(s.htmlCls.LOG_HEIGHT=65,s.htmlCls.CMD_HEIGHT=.8*s.htmlCls.LOG_HEIGHT,e||(n+=s.htmlCls.divStr+"cmdlog' style='float:left; margin-top: 5px; width: 100%;'>"),n+="")):(i=0,s.htmlCls.LOG_HEIGHT=65,s.htmlCls.CMD_HEIGHT=.8*s.htmlCls.LOG_HEIGHT,e||(n+=s.htmlCls.divStr+"cmdlog' style='float:left; margin-top: 5px; width: 100%;'>"),n+=""),e||(n+=""),e&&(s.htmlCls.clickMenuCls.setLogCmd("set cmdwindow "+i,!0),$("#"+s.pre+"cmdlog").html(n)),n}setMenu1(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
    ",t+="",t+="

    File

    ",t+="
    ",t+=this.setMenu1_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu1_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getMenuUrl("mn1_searchstru","https://www.ncbi.nlm.nih.gov/structure","Search Structure "+e.htmlCls.wifiStr,1,1),t+=this.getMenuText("mn1_searchsimilar","Search Similar",void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_vastplus","NCBI VAST+ (PDB Complex)"+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_vast","NCBI VAST (PDB Chain)"+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_foldseek","Foldseek (PDB & AlphaFold)"+e.htmlCls.wifiStr,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn1_retrievebyid","Retrieve by ID",void 0,1,1),t+="
        ",t+=this.getLink("mn1_mmdbafid","PDB/MMDB/AlphaFold IDs"+e.htmlCls.wifiStr,1,2),t+=this.getLink("mn1_mmdbid","NCBI MMDB ID (annotation) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_mmtfid","RCSB MMTF ID (fast) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_pdbid","RCSB PDB ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getMenuText("mn1_afwrap","AlphaFold Structures",void 0,void 0,2),t+="
          ",t+=this.getLink("mn1_afid","UniProt ID "+e.htmlCls.wifiStr,void 0,3),t+=this.getLink("mn1_refseqid","NCBI Protein Accession "+e.htmlCls.wifiStr,void 0,3),t+="
        ",t+=this.getLink("mn1_opmid","OPM PDB ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_mmcifid","RCSB mmCIF ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_cid","PubChem CID "+e.htmlCls.wifiStr,1,2),t+="
      ",t+="",t+=this.getMenuText("mn1_openfile","Open File",void 0,1,1),t+="
        ",t+=this.getLink("mn1_pdbfile_app","PDB Files (appendable)",1,2),t+=this.getLink("mn1_mmciffile","mmCIF File",void 0,2),t+=this.getLink("mn1_mol2file","Mol2 File",void 0,2),t+=this.getLink("mn1_sdffile","SDF File",void 0,2),t+=this.getLink("mn1_xyzfile","XYZ File",void 0,2),t+=this.getLink("mn1_afmapfile","AlphaFold PAE File",void 0,2),t+=this.getLink("mn1_urlfile","URL(CORS) "+e.htmlCls.wifiStr,void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_pngimage","iCn3D PNG Image",1,2),t+=this.getLink("mn1_state","State/Script File",void 0,2),t+=this.getLink("mn1_fixedversion","Share Link in Archived Ver. "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_selection","Selection File",void 0,2),t+=this.getMenuSep(),t+=this.getMenuText("mn1_dsn6wrap","Electron Density(DSN6)",void 0,void 0,2),t+="
          ",t+=this.getLink("mn1_dsn6","Local File",void 0,3),t+=this.getLink("mn1_dsn6url","URL(CORS) "+e.htmlCls.wifiStr,void 0,3),t+="
        ",t+="
      ",t+="",t+=this.getMenuText("mn1_alignwrap","Align",void 0,1,1),t+="
        ",t+=this.getMenuText("mn1_chainalignwrap","Multiple Chains",void 0,1,2),t+="
          ",t+=this.getRadio("mn1_chainalignRad","mn1_chainalign","by Structure Alignment "+e.htmlCls.wifiStr,void 0,1,3),t+=this.getRadio("mn1_chainalignRad","mn1_chainalign2","by Sequence Alignment "+e.htmlCls.wifiStr,void 0,1,3),t+=this.getRadio("mn1_chainalignRad","mn1_chainalign3","Residue by Residue",void 0,void 0,3),t+="
        ",t+="",t+=this.getMenuText("mn1_aligntwostru","Protein Complexes",void 0,void 0,2),t+="
          ",t+=this.getLink("mn1_align","Two PDB Structures "+e.htmlCls.wifiStr,void 0,3),t+=this.getLink("mn1_alignaf","Two AlphaFold Structures "+e.htmlCls.wifiStr,void 0,3),t+="
        ",t+=this.getLink("mn1_blast_rep_id","Sequence to Structure",void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_realignWrap","Realign Selection",void 0,void 0,1),t+="
        ",t+=this.getMenuText("mn2_chainrealignwrap","Multiple Chains",void 0,void 0,2),t+="
          ",t+=this.getRadio("mn2_realign","mn2_realignonstruct","by Structure Alignment "+e.htmlCls.wifiStr,void 0,void 0,3),t+=this.getRadio("mn2_realign","mn2_realignonseqalign","by Sequence Alignment "+e.htmlCls.wifiStr,void 0,void 0,3),t+=this.getRadio("mn2_realign","mn2_realignresbyres","Residue by Residue",void 0,void 0,3),t+="
        ",t+=this.getLink("mn2_realigntwostru","Protein Complexes",void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn1_3dpprint","3D Printing",void 0,1,1),t+="
        ",void 0===e.cfg.cid?(t+=this.getLink("mn1_exportVrmlStab","WRL/VRML(Color, W/ Stab.)",1,2),t+=this.getLink("mn1_exportStlStab","STL(W/ Stabilizers)",1,2),t+=this.getMenuSep(),t+=this.getLink("mn1_exportVrml","WRL/VRML(Color)",void 0,2),t+=this.getLink("mn1_exportStl","STL",void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_stabilizerYes","Add All Stabilizers",void 0,2),t+=this.getLink("mn1_stabilizerNo","Remove All Stabilizers",void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_stabilizerOne","Add One Stabilizer",void 0,2),t+=this.getLink("mn1_stabilizerRmOne","Remove One Stabilizer",void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_thicknessSet","Set Thickness",void 0,2)):(t+=this.getLink("mn1_exportVrml","VRML(Color)",1,2),t+=this.getLink("mn1_exportStl","STL",1,2)),t+="
      ",t+="",t+=this.getMenuText("mn1_savefile","Save File",void 0,1,1),t+="
        ",t+=this.getMenuText("mn1_savepngimage","iCn3D PNG Image",void 0,1,2),t+="
          ",t+=this.getLink("mn1_exportCanvas","Original Size & HTML",1,3),t+=this.getLink("mn1_exportCanvas1","Original Size",void 0,3),t+=this.getLink("mn1_exportCanvas2","2X Large",void 0,3),t+=this.getLink("mn1_exportCanvas4","4X Large",void 0,3),t+=this.getLink("mn1_exportCanvas8","8X Large",void 0,3),t+="
        ",t+="",t+=this.getLink("mn1_exportState","State File",void 0,2),t+=this.getLink("mn1_exportSelections","Selection File",void 0,2),t+=this.getLink("mn1_exportSelDetails","Selection Details",void 0,2),t+=this.getLink("mn1_exportCounts","Residue Counts",void 0,2),t+=this.getLink("mn1_exportPdbRes","PDB",1,2),t+=this.getLink("profixpdb","PDB with Missing Atoms",void 0,2),t+=this.getLink("profixpdbh","PDB with Hydrogens",void 0,2),void 0===e.cfg.cid&&(t+=this.getLink("mn1_exportSecondary","Secondary Structure",void 0,2)),t+="

      • ",t+="
      ",t+="",t+=this.getLink("mn1_sharelink","Share Link "+e.htmlCls.wifiStr,1,1),t+=this.getLink("mn1_replayon","Replay Each Step",void 0,1),t+=this.getMenuSep(),t+=this.getMenuText("mn1_menuwrap","Customize Menus",void 0,1,1),t+="
        ",t+=this.getLink("mn1_menuall","All Menus",1,2),t+=this.getLink("mn1_menusimple","Simple Menus",1,2),t+=this.getMenuSep(),t+=this.getLink("mn1_menupref","Preferences",1,2),t+=this.getLink("mn1_menuloadpref","Load Preferences",1,2),t+="
      ",t+="",t+="

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

    Select

    ",t+="
    ",t+=this.setMenu2_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu2_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getLink("mn2_definedsets","Defined Sets",1,1),t+=this.getLink("mn2_selectall","All",void 0,1),t+=this.getLink("mn2_selectdisplayed","Displayed Set",void 0,1),t+=this.getLink("mn2_aroundsphere","by Distance",1,1),t+=this.getMenuText("mn2_selbyprop","by Property",void 0,void 0,1),t+="
        ",t+=this.getLink("mn2_propPos","Positive",void 0,2),t+=this.getLink("mn2_propNeg","Negative",void 0,2),t+=this.getLink("mn2_propHydro","Hydrophobic",void 0,2),t+=this.getLink("mn2_propPolar","Polar",void 0,2),t+=this.getLink("mn2_propBfactor","B-factor/pLDDT",void 0,2),t+=this.getLink("mn2_propSolAcc","Solvent Accessibility",void 0,2),t+="
      ",t+="",t+=this.getLink("mn2_selectcomplement","Inverse",void 0,1),t+=this.getLink("mn2_selectmainchains","Main Chains",void 0,1),t+=this.getLink("mn2_selectsidechains","Side Chains",void 0,1),t+=this.getLink("mn2_selectmainsidechains","Main & Side Chains",void 0,1),t+=this.getLink("mn2_command","Advanced",void 0,1),void 0===e.cfg.cid?(t+=this.getMenuText("mn2_selon3d","Select on 3D",void 0,1,1),t+="
        ",t+='
      • "Alt"+Click: start selection
      • ',t+='
      • "Ctrl"+Click: union selection
      • ',t+='
      • "Shift"+Click: range Selection
      • ',t+=this.getMenuSep(),t+=this.getRadio("mn2_pk","mn2_pkChain","Chain",void 0,1,2),void 0===e.cfg.mmdbid&&void 0===e.cfg.gi||(t+=this.getRadio("mn2_pk","mn2_pkDomain","3D Domain",void 0,void 0,2)),t+=this.getRadio("mn2_pk","mn2_pkStrand","Strand/Helix",void 0,void 0,2),t+=this.getRadio("mn2_pk","mn2_pkResidue","Residue",!0,1,2),t+=this.getRadio("mn2_pk","mn2_pkYes","Atom",void 0,1,2),t+=this.getRadio("mn2_pk","mn2_pkNo","None",void 0,void 0,2),t+="
      ",t+=""):e.utilsCls.isMobile()?t+="
    • Touch to pick
    • ":t+='
    • Picking with
      "Alt" + Click
    • ',t+=this.getMenuSep(),t+=this.getLink("mn2_saveselection","Save Selection",1,1),t+=this.getLink("clearall","Clear Selection",void 0,1),t+=this.getLink("mn2_saveresidue","Save Res. in Sel.",1,1),t+=this.getMenuSep(),t+=this.getMenuText("mn2_hlcolor","Highlight Color",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn2_hl_clr","mn2_hl_clrYellow","Yellow",!0,void 0,2),t+=this.getRadio("mn2_hl_clr","mn2_hl_clrGreen","Green",void 0,void 0,2),t+=this.getRadio("mn2_hl_clr","mn2_hl_clrRed","Red",void 0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_hlstyle","Highlight Style",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn2_hl_style","mn2_hl_styleOutline","Outline",!0,void 0,2),t+=this.getRadio("mn2_hl_style","mn2_hl_styleObject","3D Objects",void 0,void 0,2),t+="
      ",t+="",t+=this.getLink("toggleHighlight2","Toggle Highlight",1,1),t+="

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

    View

    ",t+="
    ",t+=this.setMenu2b_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu2b_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getLink("mn2_show_selected","View Selection",1,1),t+=this.getLink("mn2_hide_selected","Hide Selection",1,1),t+=this.getLink("mn2_selectedcenter","Zoom in Selection",1,1),t+=this.getLink("mn6_center","Center Selection",1,1),t+=this.getLink("mn2_fullstru","View Full Structure"),t+=this.getLinkWrapper("mn2_alternate",'Alternate(Key "a")',"mn2_alternateWrap",void 0,1),void 0!==e.cfg.opmid?t+=this.getLinkWrapper("togglemem","Toggle Membrane","togglememli",void 0,1):void 0===e.cfg.cid&&(t+=this.getLinkWrapper("togglemem","Toggle Membrane","togglememli",void 0,1,!0)),void 0!==e.cfg.opmid&&(t+=this.getLinkWrapper("adjustmem","Adjust Membrane","adjustmemli",void 0,1),t+=this.getLinkWrapper("selectplane","Select between
      Two X-Y Planes","selectplaneli",void 0,1)),t+=this.getMenuSep(),t+=this.getMenuText("mn2_vrarhints","VR & AR Hints",void 0,1,1),t+="
        ",t+=this.getMenuUrl("vrhint",e.htmlCls.baseUrl+"icn3d/icn3d.html#vr","VR: VR Headsets",1,2),t+=this.getMenuUrl("arhint",e.htmlCls.baseUrl+"icn3d/icn3d.html#ar","AR: Chrome in Android",1,2),t+="
      ",t+="",t+=this.getLink("mn6_sidebyside","Side by Side",1,1),t+=this.getMenuText("mn2_rotate","Rotate",void 0,1,1),t+="
        ",t+=this.getMenuText("mn2_rotate90","Rotate 90°",void 0,void 0,2),t+="
          ",t+=this.getRadio("mn6_rotate90","mn6_rotatex","X-axis(Shift + Key M)",void 0,void 0,2),t+=this.getRadio("mn6_rotate90","mn6_rotatey","Y-axis(Shift + Key J)",void 0,void 0,2),t+=this.getRadio("mn6_rotate90","mn6_rotatez","Z-axis",void 0,void 0,2),t+="
        ",t+="",t+=this.getMenuText("mn2_rotateauto","Auto Rotation",void 0,1,2),t+="
          ",t+=this.getRadio("mn6_rotate","mn6_rotateleft","Rotate Left",void 0,1,3),t+=this.getRadio("mn6_rotate","mn6_rotateright","Rotate Right",void 0,1,3),t+=this.getRadio("mn6_rotate","mn6_rotateup","Rotate Up",void 0,1,3),t+=this.getRadio("mn6_rotate","mn6_rotatedown","Rotate Down",void 0,1,3),t+="
        ",t+="",t+="
      ",t+="",t+=this.getMenuText("mn2_camera","Camera",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_camera","mn6_cameraPers","Perspective",!0,void 0,2),t+=this.getRadio("mn6_camera","mn6_cameraOrth","Orthographic",void 0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_fog","Fog for Selection",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_showfog","mn6_showfogYes","On",void 0,void 0,2),t+=this.getRadio("mn6_showfog","mn6_showfogNo","Off",!0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_slab","Slab for Selection",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_showslab","mn6_showslabYes","On",void 0,void 0,2),t+=this.getRadio("mn6_showslab","mn6_showslabNo","Off",!0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_axes","XYZ-axes",void 0,1),t+="
        ",t+=this.getRadio("mn6_showaxis","mn6_showaxisYes","Original",void 0,void 0,2),t+=this.getRadio("mn6_showaxis","mn6_showaxisSel","Prin. Axes on Sel.",void 0,void 0,2),t+=this.getRadio("mn6_showaxis","mn6_showaxisNo","Hide",!0,void 0,2),t+="
      ",t+="",t+=this.getMenuSep(),t+=this.getMenuText("mn2_resetwrap","Reset",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_reset","reset","All",void 0,1,2),t+=this.getRadio("mn6_reset","mn6_resetOrientation","Orientation",void 0,1,2),t+="
      ",t+="",t+=this.getLink("mn6_back","Undo",void 0,1),t+=this.getLink("mn6_forward","Redo",void 0,1),t+=this.getLink("mn6_fullscreen","Full Screen",void 0,1),t+="

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

    Style

    ",t+="
    ",t+=this.setMenu3_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu3_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";t+="
      ",void 0===e.cfg.cid&&(t+=this.getMenuText("mn3_proteinwrap","Proteins",void 0,1,1),t+="
        ",void 0!==e.cfg.align||void 0!==e.cfg.chainalign?t+=this.getRadio("mn3_proteins","mn3_proteinsRibbon","Ribbon",void 0,1,2):t+=this.getRadio("mn3_proteins","mn3_proteinsRibbon","Ribbon",!0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsStrand","Strand",void 0,void 0,2),t+=this.getRadio("mn3_proteins","mn3_proteinsCylinder","Cylinder and Plate",void 0,void 0,2),t+=this.getRadio("mn3_proteins","mn3_proteinsSchematic","Schematic",void 0,1,2),void 0!==e.cfg.align||void 0!==e.cfg.chainalign?t+=this.getRadio("mn3_proteins","mn3_proteinsCalpha","C Alpha Trace",!0,1,2):t+=this.getRadio("mn3_proteins","mn3_proteinsCalpha","C Alpha Trace",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsBackbone","Backbone",void 0,void 0,2),t+=this.getRadio("mn3_proteins","mn3_proteinsBfactor","B-factor Tube",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsLines","Lines",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsStick","Stick",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsBallstick","Ball and Stick",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_sidecwrap","Side Chains",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_sidec","mn3_sidecLines","Lines",void 0,1,2),t+=this.getRadio("mn3_sidec","mn3_sidecStick","Stick",void 0,1,2),t+=this.getRadio("mn3_sidec","mn3_sidecBallstick","Ball and Stick",void 0,1,2),t+=this.getRadio("mn3_sidec","mn3_sidecSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_sidec","mn3_sidecNo","Hide",!0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_nuclwrap","Nucleotides",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_nucl","mn3_nuclCartoon","Cartoon",!0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclPhos","O3' Trace",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclBackbone","Backbone",void 0,void 0,2),t+=this.getRadio("mn3_nucl","mn3_nuclSchematic","Schematic",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclLines","Lines",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclStick","Stick",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclBallstick","Ball and Stick",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_ntbasewrap","Nucl. Bases",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_ntbase","mn3_ntbaseLines","Lines",void 0,1,2),t+=this.getRadio("mn3_ntbase","mn3_ntbaseStick","Stick",void 0,1,2),t+=this.getRadio("mn3_ntbase","mn3_ntbaseBallstick","Ball and Stick",void 0,1,2),t+=this.getRadio("mn3_ntbase","mn3_ntbaseSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_ntbase","mn3_ntbaseNo","Hide",!0,1,2),t+="
      ",t+=""),t+=this.getMenuText("mn3_ligwrap","Chemicals",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_lig","mn3_ligLines","Lines",void 0,1,2),void 0===e.cfg.cid?(t+=this.getRadio("mn3_lig","mn3_ligStick","Stick",!0,1,2),t+=this.getRadio("mn3_lig","mn3_ligBallstick","Ball and Stick",void 0,1,2)):(t+=this.getRadio("mn3_lig","mn3_ligStick","Stick",void 0,1,2),t+=this.getRadio("mn3_lig","mn3_ligBallstick","BalHydrogensl and Stick",!0,1,2)),t+=this.getRadio("mn3_lig","mn3_ligSchematic","Schematic",void 0,1,2),t+=this.getRadio("mn3_lig","mn3_ligSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_lig","mn3_ligNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_hydrogenswrap","Hydrogens",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_hydrogens","mn3_hydrogensYes","Show",!0,1,2),t+=this.getRadio("mn3_hydrogens","mn3_hydrogensNo","Hide",void 0,1,2),t+="
      ",t+="",void 0===e.cfg.cid&&(t+=this.getMenuText("mn3_glycanwrap","Glycans",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn3_glycansCart","mn3_glycansCartYes","Show Cartoon",void 0,void 0,2),t+=this.getRadio("mn3_glycansCart","mn3_glycansCartNo","Hide Cartoon",!0,void 0,2),t+="
      ",t+=""),t+=this.getMenuText("mn3_ionswrap","Ions",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_ions","mn3_ionsSphere","Sphere",!0,1,2),t+=this.getRadio("mn3_ions","mn3_ionsDot","Dot",void 0,1,2),t+=this.getRadio("mn3_ions","mn3_ionsNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn3_waterwrap","Water",void 0,1,1),t+="
        ",t+=this.getRadio("mn3_water","mn3_waterSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_water","mn3_waterDot","Dot",void 0,1,2),t+=this.getRadio("mn3_water","mn3_waterNo","Hide",!0,1,2),t+="
      ",t+="",t+=this.getLink("mn3_setThickness","Preferences",void 0,1),t+=this.getMenuSep(),t+=this.getLink("mn3_styleSave","Save Style",void 0,2),t+=this.getLink("mn3_styleApplySave","Apply Saved Style",void 0,2),t+=this.getMenuSep(),t+=this.getMenuText("mn5_surfacewrap","Surface Type",void 0,1,1),t+="
        ",t+=this.getRadio("mn5_surface","mn5_surfaceVDW","Van der Waals",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceVDWContext","VDW with Context",void 0,void 0,2),t+=this.getRadio("mn5_surface","mn5_surfaceMolecular","Molecular Surface",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceMolecularContext","MS with Context",void 0,void 0,2),t+=this.getRadio("mn5_surface","mn5_surfaceSAS","Solvent Accessible",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceSASContext","SA with Context",void 0,void 0,2),t+="
      ",t+="",t+=this.getLink("mn5_surfaceNo","Remove Surface",1,1),t+=this.getMenuText("mn5_surfaceop","Surface Opacity",void 0,1,1),t+="
        ",t+=this.getMenuText("mn5_surfaceopfast","Fast Transparency",void 0,1,2),t+="
          ",t+=this.getRadio("mn5_opacity","mn5_opacity10","1.0",!0,1,3);for(let e=9;e>0;--e)t+=this.getRadio("mn5_opacity","mn5_opacity0"+e,"0."+e,1,3);t+="
        ",t+="",t+=this.getMenuText("mn5_surfaceopslow","Slow Transparency",void 0,void 0,2),t+="
          ",t+=this.getRadio("mn5_opacityslow","mn5_opacityslow10","1.0",!0,void 0,3);for(let e=9;e>0;--e)t+=this.getRadio("mn5_opacityslow","mn5_opacityslow0"+e,"0."+e,void 0,void 0,3);return t+="
        ",t+="",t+="
      ",t+=this.getMenuText("mn5_wireframewrap","Surface Wireframe",void 0,1,1),t+="
        ",t+=this.getRadio("mn5_wireframe","mn5_wireframeYes","Yes",void 0,1,2),t+=this.getRadio("mn5_wireframe","mn5_wireframeNo","No",!0,1,2),t+="
      ",t+="",t+=this.getMenuSep(),t+=this.getLink("mn5_cartoonshape","Cartoon for a Set",void 0,1),t+=this.getLink("mn5_linebtwsets","Line btw. Two Sets",void 0,1),void 0===e.cfg.cid&&void 0===e.cfg.align&&void 0===e.cfg.chainalign&&void 0===e.cfg.mmdbaf&&(t+=this.getMenuSep(),t+=this.getLinkWrapper2("mn5_map","Electron Density","mapWrapper1",void 0,1),t+="
        ",t+=this.getLink("mn5_elecmap2fofc","2Fo-Fc Map",void 0,2),t+=this.getLink("mn5_elecmapfofc","Fo-Fc Map",void 0,2),t+=this.getLinkWrapper("mn5_elecmapNo","Remove Map","mapWrapper2",void 0,2),t+="
      ",t+="",t+=this.getLinkWrapper2("mn5_map3","Map Wireframe","mapWrapper3",void 0,1),t+="
        ",t+=this.getRadio("mn5_mapwireframe","mn5_mapwireframeYes","Yes",!0,void 0,2),t+=this.getRadio("mn5_mapwireframe","mn5_mapwireframeNo","No",void 0,void 0,2),t+="
      ",t+="",void 0===e.cfg.mmtfid&&(t+=this.getLinkWrapper("mn5_emmap","EM Density Map","emmapWrapper1",void 0,1),t+=this.getLinkWrapper("mn5_emmapNo","Remove EM Map","emmapWrapper2",void 0,1),t+=this.getLinkWrapper2("mn5_emmap3","EM Map Wireframe","emmapWrapper3",void 0,1),t+="
        ",t+=this.getRadio("mn5_emmapwireframe","mn5_emmapwireframeYes","Yes",!0,void 0,2),t+=this.getRadio("mn5_emmapwireframe","mn5_emmapwireframeNo","No",void 0,void 0,2),t+="
      ",t+="")),t+=this.getMenuSep(),t+=this.getMenuText("mn6_bkgdwrap","Background",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_bkgd","mn6_bkgdTransparent","Transparent",void 0,1,2),t+=this.getRadio("mn6_bkgd","mn6_bkgdBlack","Black",!0,1,2),t+=this.getRadio("mn6_bkgd","mn6_bkgdGrey","Gray",void 0,1,2),t+=this.getRadio("mn6_bkgd","mn6_bkgdWhite","White",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn6_themewrap","Dialog Color",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_theme","mn6_themeBlue","Blue",!0,void 0,2),t+=this.getRadio("mn6_theme","mn6_themeOrange","Orange",void 0,void 0,2),t+=this.getRadio("mn6_theme","mn6_themeBlack","Black",void 0,void 0,2),t+="
      ",t+="",t+="

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

    Color

    ",t+="
    ",t+=this.setMenu4_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu4_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getMenuText("mn4_clrwrap","Unicolor","icn3d-menupd",1,1),t+="
        ",t+=this.getMenuText("uniclrRedwrap","Red",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrRed1","Red","F00",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed2","Indian Red","CD5C5C",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed3","Light Coral","F08080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed4","Salmon","FA8072",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed5","Dark Salmon","E9967A",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed6","Light Salmon","FFA07A",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed7","Crimson","DC143C",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed8","Fire Brick","B22222",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed9","Dark Red","8B0000",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrPinkwrap","Pink",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrPink1","Pink","FFC0CB",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink2","Light Pink","FFB6C1",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink3","Hot Pink","FF69B4",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink4","Deep Pink","FF1493",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink5","Medium Violet Red","C71585",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink6","Pale Violet Red","DB7093",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrOrangewrap","Orange",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrOran1","Orange","FFA500",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran2","Dark Orange","FF8C00",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran3","Orange Red","FF4500",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran4","Tomato","FF6347",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran5","Coral","FF7F50",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran6","Light Salmon","FFA07A",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrYellowwrap","Yellow",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrYllw1","Yellow","FF0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw2","Gold","FFD700",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw3","Light Yellow","FFFFE0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw4","Lemon Chiffon","FFFACD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw5","Light Golden Rod","FAFAD2",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw6","Papaya Whip","FFEFD5",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw7","Moccasin","FFE4B5",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw8","Peach Puff","FFDAB9",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw9","Pale Golden Rod","EEE8AA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw10","Khaki","F0E68C",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw11","Dark Khaki","BDB76B",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrMagentawrap","Magenta",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrMgnt1","Magenta","F0F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt2","Orchid","DA70D6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt3","Violet","EE82EE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt4","Plum","DDA0DD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt5","Thistle","D8BFD8",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt6","Lavender","E6E6FA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt7","Medium Orchid","BA55D3",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt8","Medium Purple","9370DB",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt9","Rebecca Purple","663399",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt10","Blue Violet","8A2BE2",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt11","Dark Violet","9400D3",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt12","Dark Orchid","9932CC",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt13","Dark Magenta","8B008B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt14","Purple","800080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt15","Indigo","4B0082",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt16","Slat Blue","6A5ACD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt17","Dark Slate Blue","483D8B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt18","Medium Slat Blue","6A5ACD",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrGreenwrap","Green",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrGrn1","Green","0F0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn2","Dark Green","006400",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn3","Yellow Green","9ACD32",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn4","Olive Drab","6B8E23",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn5","Olive","808000",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn6","Dark Olive Green","556B2F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn7","Medium Aquamarine","66CDAA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn8","Dark Sea Green","8FBC8B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn9","Lignt Sea Green","20B2AA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn10","Dark Cyan","008B8B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn11","Teal","008080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn12","Forest Green","228B22",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn13","Sea Green","2E8B57",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn14","Medium Sea Green","3CB371",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn15","Spring Green","00FF7F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn16","Medium Spring","00FA9A",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn17","Light Green","90EE90",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn18","Pale Green","98FB98",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn19","Lime Green","32CD32",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn20","Lawn Green","7CFC00",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn21","Chartreuse","7FFF00",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn22","Green Yellow","ADFF2F",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrCyanwrap","Cyan",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrCyan1","Cyan","0FF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan2","Light Cyan","E0FFFF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan3","Pale Turquoise","AFEEEE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan4","Aquamarine","7FFFD4",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan5","Turquoise","40E0D0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan6","Medium Turquoise","48D1CC",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan7","Dark Turquoise","00CED1",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrBluewrap","Blue",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrBlue1","Blue","00F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue2","Medium Blue","0000CD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue3","Dark Blue","00008B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue4","Navy","000080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue5","Midnight Blue","191970",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue6","Royal Blue","4169E1",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue7","Medium Slate Blue","7B68EE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue8","Corn Flower Blue","6495ED",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue9","Dodger Blue","1E90FF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue10","Deep Sky Blue","00BFFF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue11","Light Sky Blue","87CEFA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue12","Sky Blue","87CEEB",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue13","Light Blue","ADD8E6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue14","Powder Blue","B0E0E6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue15","Light Steel Blue","B0C4DE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue16","Steel Blue","4682B4",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue17","Cadet Blue","5F9EA0",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrBrownwrap","Brown",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrBrown1","Brown","A52A2A",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown2","Maroon","800000",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown3","Sienna","A0522D",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown4","Saddle Brown","8B4513",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown5","Chocolate","D2691E",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown6","Peru","CD853F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown7","Dark Golden Rod","B8860B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown8","Golden Rod","DAA520",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown9","Sandy Brown","F4A460",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown10","Rosy Brown","BC8F8F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown11","Tan","D2B48C",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown12","Burlywood","DEB887",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown13","Wheat","F5DEB3",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown14","Navajo White","FFDEAD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown15","Bisque","FFE4C4",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown16","Blanched Almond","FFEBCD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown17","Corn Silk","FFF8DC",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrWhitewrap","White",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrWhite1","White","FFF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite2","Snow","FFFAFA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite3","Honey Dew","F0FFF0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite4","Mint Cream","F5FFFA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite5","Azure","F0FFFF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite6","Alice Blue","F0F8FF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite7","Ghost White","F8F8FF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite8","White Smoke","F5F5F5",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite9","Sea Shell","FFF5EE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite10","Beige","F5F5DC",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite11","Old Lace","FDF5E6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite12","Floral White","FFFAF0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite13","Ivory","FFFFF0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite14","Antique White","FAEBD7",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite15","Linen","FAF0E6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite16","Lavenderblush","FFF0F5",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite17","Misty Rose","FFE4E1",void 0,1,3),t+="
        ",t+=this.getMenuText("uniclrGraywrap","Gray",void 0,1,2),t+="
          ",t+=this.getRadClr("mn4_clr","uniclrGray1","Gray","808080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray2","Dim Gray","696969",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray3","Light Slate Gray","778899",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray4","Slate Gray","708090",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray5","Dark Slate Gray","2F4F4F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray6","Black","000000",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray7","Dark Gray","A9A9A9",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray8","Silver","C0C0C0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray9","Light Gray","D3D3D3",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray10","Gainsboro","DCDCDC",void 0,1,3),t+="
        ",t+="
      ",t+=this.getRadio("mn4_clr","mn4_clrCustom","Color Picker",void 0,void 0,1),t+=this.getMenuSep(),void 0===e.cfg.cid?(t+=this.getMenuText("mn4_clrRainbowwrap","Rainbow (R-V)","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrRainbow","for Selection",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrRainbowChain","for Chains",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrRainbowSets","for Sets",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrRainbowAcrossSets","across Sets",void 0,void 0,2),t+="
      ",t+=this.getMenuText("mn4_clrSpectrumwrap","Spectrum (V-R)","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrSpectrum","for Selection",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSpectrumChain","for Chains",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSpectrumSets","for Sets",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrSpectrumAcrossSets","across Sets",void 0,void 0,2),t+="
      ",t+=this.getMenuText("mn4_clrSSwrap","Secondary","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrSSGreen","Sheet in Green",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSSYellow","Sheet in Yellow",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSSSpectrum","Spectrum",void 0,void 0,2),t+="
      ",t+=this.getRadio("mn4_clr","mn4_clrCharge","Charge",void 0,1,1),t+=this.getMenuText("mn4_hydrophobicwrap","Hydrophobicity","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrNormalizedHP","Normalized",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrHydrophobic","Wimley-White",void 0,void 0,2),t+="
      ",t+=this.getMenuText("mn4_clrBfactorwrap","B-factor","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrBfactor","Original",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrBfactorNorm","Percentile",void 0,1,2),t+="
      ",t+=this.getRadio("mn4_clr","mn4_clrArea",'Solvent
      Accessibility',void 0,void 0,1),t+=this.getRadio("mn4_clr","mn4_clrStructure","Structure",void 0,1,1),void 0!==e.cfg.align||void 0!==e.cfg.chainalign||void 0!==e.cfg.blast_rep_id?t+=this.getRadio("mn4_clr","mn4_clrChain","Chain",void 0,1,1):t+=this.getRadio("mn4_clr","mn4_clrChain","Chain",!0,1,1),t+=this.getRadio("mn4_clr","mn4_clrdomain","3D Domain",void 0,void 0,1),void 0===e.cfg.cid&&(t+=this.getMenuText("mn4_clrsetswrap","Defined Sets","icn3d-menupd",void 0,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrsets",'Rainbow for Selected Sets
        in "Analysis > Defined Sets"',void 0,void 0,2),t+="
      ",t+=""),t+=this.getMenuText("mn4_clrResiduewrap","Residue","icn3d-menupd",1,1),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrResidue","Default",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrResidueCustom","Custom",void 0,void 0,2),t+="
      ",t+=this.getRadio("mn4_clr","mn4_clrAtom","Atom",void 0,1,1),void 0!==e.cfg.align||void 0!==e.cfg.chainalign?(t+=this.getRadio("mn4_clr","mn4_clrIdentity","Identity",!0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrConserved","Conservation",void 0,void 0,2)):void 0!==e.cfg.blast_rep_id?(t+=this.getRadio("mn4_clr","mn4_clrIdentity","Identity",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrConserved","Conservation",!0,void 0,2)):(t+=this.getRadio("mn4_clr","mn4_clrIdentity","Identity",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrConserved","Conservation",void 0,void 0,2)),t+=this.getRadio("mn4_clr","mn4_clrConfidence",'AlphaFold
      Confidence',void 0,1,1)):t+=this.getRadio("mn4_clr","mn4_clrAtom","Atom",!0,1,1),t+=this.getMenuSep(),t+=this.getLink("mn4_clrSave","Save Color",void 0,1),t+=this.getLink("mn4_clrApplySave","Apply Saved Color",void 0,1),t+="

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

     Analysis

    ",t+="
    ",t+=this.setMenu5_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu5_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";t+="
      ",void 0===e.cfg.cid&&(t+=this.getLink("mn6_selectannotations","Seq. & Annotations "+e.htmlCls.wifiStr,1,1),t+=this.getLink("mn2_alignment","Aligned Seq. "+e.htmlCls.wifiStr,void 0,1),void 0===e.cfg.mmdbid&&void 0===e.cfg.gi&&void 0===e.cfg.blast_rep_id&&void 0===e.cfg.align&&void 0===e.cfg.chainalign||(t+=this.getLink("mn2_2ddgm","2D Diagram "+e.htmlCls.wifiStr,1,1)),t+=this.getMenuText("2dctnwrap","2D Cartoon",void 0,void 0,1),t+="
        ",t+=this.getLink("2dctn_chain","Chain Level",void 0,2),t+=this.getLink("2dctn_domain","Domain Level",void 0,2),t+=this.getLink("2dctn_secondary","Helix/Sheet Level",void 0,2),t+="
      ",t+="",t+=this.getLink("definedsets2","Defined Sets",1,1),t+=this.getMenuSep(),t+=this.getLink("mn6_hbondsYes","Interactions",1,1),t+=this.getMenuText("mn1_window","Bring to Front",void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_window_table","Interaction Table",void 0,2),t+=this.getLink("mn1_window_linegraph","2D Interaction Network",void 0,2),t+=this.getLink("mn1_window_scatterplot","2D Interaction Map",void 0,2),t+=this.getLink("mn1_window_graph","2D Graph(Force-Directed)",void 0,2),t+="
      ",t+="",t+=this.getLink("mn6_contactmap","Contact Map",void 0,1),e.cfg.notebook||(t+=this.getLink("mn1_mutation","Mutation "+e.htmlCls.wifiStr,1,1))),e.cfg.notebook||e.cfg.hidelicense||(t+=this.getMenuText("mn1_delphiwrap","DelPhi Potential",void 0,1,1),t+="
        ",t+=this.getLink("mn1_delphi","DelPhi Potential "+e.htmlCls.licenseStr,1,2),t+=this.getMenuText("mn1_phiwrap","Load PQR/Phi",void 0,void 0,2),t+="
          ",t+=this.getLink("mn1_phi","Local PQR/Phi/Cube File",void 0,3),t+=this.getLink("mn1_phiurl","URL PQR/Phi/Cube File",void 0,3),t+="
        ",t+="",t+=this.getLink("delphipqr","Download PQR",void 0,2),t+="
      ",t+=""),t+=this.getMenuSep(),t+=this.getMenuText("mn6_distancewrap","Distance",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_distance","mn6_distanceYes","between Two Atoms",void 0,1,2),t+=this.getRadio("mn6_distance","mn6_distTwoSets","between Two Sets",void 0,void 0,2),t+=this.getRadio("mn6_distance","mn6_distManySets","Among Many Sets",void 0,void 0,2),t+=this.getRadio("mn6_distance","mn6_distanceNo","Hide",!0,1,2),t+="
      ",t+="",t+=this.getLink("mn6_area","Surface Area",1,1),t+=this.getMenuText("mn6_addlabelwrap","Label",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_addlabel","mn6_addlabelYes","by Picking Atoms",void 0,void 0,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelSelection","per Selection",void 0,void 0,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelAtoms","per Atom",void 0,void 0,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelElements","per Atom Element",void 0,1,2),void 0===e.cfg.cid&&(t+=this.getRadio("mn6_addlabel","mn6_addlabelResidues","per Residue",void 0,1,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelResnum","per Residue & Number",void 0,1,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelChains","per Chain",void 0,void 0,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelTermini","N- & C-Termini",void 0,1,2)),t+=this.getMenuSep(),t+=this.getRadio("mn6_addlabel","mn6_labelColor","Change Label Color",void 0,1,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelNo","Remove",!0,1,2),t+="
      ",t+="",t+=this.getMenuText("labelscalewrap","Label Scale",void 0,1,1),t+="
        ";for(let e=1;e<=4;++e){let s=2*e;t+=this.getRadio("mn6_labelscale","mn6_labelscale0"+s,"0."+s,void 0,1,2)}for(let e=1;e<=5;++e)t+=1==e?this.getRadio("mn6_labelscale","mn6_labelscale"+e+"0",e+".0",!0,1,2):this.getRadio("mn6_labelscale","mn6_labelscale"+e+"0",e+".0",void 0,1,2);if(t+="
      ",t+="",t+=this.getMenuSep(),void 0===e.cfg.cid){t+=this.getMenuText("mn6_chemicalbindingwrap","Chem. Binding",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_chemicalbinding","mn6_chemicalbindingshow","Show",void 0,void 0,2),t+=this.getRadio("mn6_chemicalbinding","mn6_chemicalbindinghide","Hide",!0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn6_ssbondswrap","Disulfide Bonds",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_ssbonds","mn6_ssbondsYes","Show",!0,1,2),t+=this.getRadio("mn6_ssbonds","mn6_ssbondsExport","Export Pairs",void 0,void 0,2),t+=this.getRadio("mn6_ssbonds","mn6_ssbondsNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn6_clbondswrap","Cross-Linkages",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_clbonds","mn6_clbondsYes","Show",!0,void 0,2),t+=this.getRadio("mn6_clbonds","mn6_clbondsExport","Export Pairs",void 0,void 0,2),t+=this.getRadio("mn6_clbonds","mn6_clbondsNo","Hide",void 0,void 0,2),t+="
      ",t+="";let s=void 0!==e.cfg.mmtfid||void 0!==e.cfg.pdbid||void 0!==e.cfg.opmid||void 0!==e.cfg.mmcifid||void 0!==e.cfg.mmdbid||void 0!==e.cfg.mmdbafid||void 0!==e.cfg.gi||void 0!==e.cfg.blast_rep_id;s&&(t+=this.getMenuText("assemblyWrapper","Assembly",void 0,1,1),t+="
        ",e.cfg.bu?(t+=this.getRadio("mn6_assembly","mn6_assemblyYes","Biological Assembly",!0,1,2),t+=this.getRadio("mn6_assembly","mn6_assemblyNo","Asymmetric Unit",void 0,1,2)):(t+=this.getRadio("mn6_assembly","mn6_assemblyYes","Biological Assembly",void 0,1,2),t+=this.getRadio("mn6_assembly","mn6_assemblyNo","Asymmetric Unit",!0,1,2)),t+="
      ",t+=""),t+=this.getMenuText("mn6_symmetrywrap","Symmetry",void 0,void 0,1),t+="
        ",s&&(t+=this.getLink("mn6_symmetry","from PDB(precalculated) "+e.htmlCls.wifiStr,void 0,2)),t+=this.getLink("mn6_symd","from SymD(Dynamic) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn6_clear_sym","Clear SymD Symmetry",void 0,2),t+=this.getLink("mn6_axes_only","Show Axes Only",void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn6_igrefwrap","Ref. Number",void 0,void 0,1),t+="
        ",t+=this.getLink("mn6_customref","Custom Ref. Number",void 0,2),t+="
      ",t+="",t+=this.getMenuSep()}return t+=this.getLink("mn6_yournote","Window Title",void 0,1),void 0!==e.cfg.cid?(t+=this.getMenuText("mn1_linkwrap","Links",void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_link_structure","Compound Summary "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_vast","Similar Compounds "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_bind","Structures Bound "+e.htmlCls.wifiStr,void 0,2),t+="
      ",t+=""):(t+=this.getMenuText("mn1_linkwrap","Links",void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_link_structure","Structure Summary "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_vast","Similar Structures "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_pubmed","Literature "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_protein","Protein "+e.htmlCls.wifiStr,void 0,2),t+="
      ",t+=""),t+="

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

    Help

    ",t+="
    ",t+=this.setMenu6_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu6_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getMenuUrl("abouticn3d",e.htmlCls.baseUrl+"icn3d/icn3d.html#about","About iCn3D "+e.REVISION+"",1,1),t+=this.getMenuUrl("gallery",e.htmlCls.baseUrl+"icn3d/icn3d.html#gallery","Live Gallery "+e.htmlCls.wifiStr,1,1),t+=this.getMenuUrl("video",e.htmlCls.baseUrl+"icn3d/icn3d.html#videos","iCn3D Videos",1,1),t+=this.getMenuText("mn6_faq","FAQ",void 0,1,1),t+="
        ",t+=this.getMenuUrl("faq_viewstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#viewstru","View structure",1,2),t+=this.getMenuUrl("faq_tfstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#tfstru","Transform Structure",1,2),t+=this.getMenuUrl("faq_selsubset",e.htmlCls.baseUrl+"icn3d/icn3d.html#selsubset","Select Subsets",1,2),t+=this.getMenuUrl("faq_stylecolor",e.htmlCls.baseUrl+"icn3d/icn3d.html#changestylecolor","Change Style/Color",1,2),t+=this.getMenuUrl("faq_savework",e.htmlCls.baseUrl+"icn3d/icn3d.html#saveview","Save Work",1,2),t+=this.getMenuUrl("faq_showanno",e.htmlCls.baseUrl+"icn3d/icn3d.html#showanno","Show Annotations",1,2),t+=this.getMenuUrl("faq_exportanno",e.htmlCls.baseUrl+"icn3d/icn3d.html#exportanno","Export Annotations",1,2),t+=this.getMenuUrl("faq_interanal",e.htmlCls.baseUrl+"icn3d/icn3d.html#interanalysis","Interaction Analysis",1,2),t+=this.getMenuUrl("faq_mutanal",e.htmlCls.baseUrl+"icn3d/icn3d.html#mutationanalysis","Mutation Analysis",1,2),t+=this.getMenuUrl("faq_elecpot",e.htmlCls.baseUrl+"icn3d/icn3d.html#elecpot","Electrostatic Pot.",1,2),t+=this.getMenuUrl("faq_simipdb",e.htmlCls.baseUrl+"icn3d/icn3d.html#simivast","Similar PDB",1,2),t+=this.getMenuUrl("faq_simialphapdb",e.htmlCls.baseUrl+"icn3d/icn3d.html#simifoldseek","Similar AlphaFold/PDB",1,2),t+=this.getMenuUrl("faq_alnstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#alignmul","Align Multiple Structures",1,2),t+=this.getMenuUrl("faq_batchanal",e.htmlCls.baseUrl+"icn3d/icn3d.html#batchanalysis","Batch Analysis",1,2),t+=this.getMenuUrl("faq_embedicn3d",e.htmlCls.baseUrl+"icn3d/icn3d.html#embedicn3d","Embed iCn3D",1,2),t+="
      ",t+="",t+=this.getMenuUrl("citing",e.htmlCls.baseUrl+"icn3d/icn3d.html#citing","Citing iCn3D",void 0,1),t+=this.getMenuText("mn6_source","Source Code",void 0,1,1),t+="
        ",t+=this.getMenuUrl("github","https://github.com/ncbi/icn3d","GitHub (browser) "+e.htmlCls.wifiStr,1,2),t+=this.getMenuUrl("npm","https://www.npmjs.com/package/icn3d","npm (Node.js) "+e.htmlCls.wifiStr,1,2),t+=this.getMenuUrl("notebook","https://pypi.org/project/icn3dpy","Jupyter Notebook "+e.htmlCls.wifiStr,1,2),t+="
      ",t+="",t+=this.getMenuText("mn6_develop","Develop",void 0,void 0,1),t+="
        ",t+=this.getMenuUrl("dev_embedicn3d2",e.htmlCls.baseUrl+"icn3d/icn3d.html#HowToUse","Embed iCn3D",void 0,2),t+=this.getMenuUrl("dev_urlpara",e.htmlCls.baseUrl+"icn3d/icn3d.html#parameters","URL Parameters",void 0,2),t+=this.getMenuUrl("dev_command",e.htmlCls.baseUrl+"icn3d/icn3d.html#commands","Commands",void 0,2),t+=this.getMenuUrl("dev_datastru",e.htmlCls.baseUrl+"icn3d/icn3d.html#datastructure","Data Structure",void 0,2),t+=this.getMenuUrl("dev_classstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#classstructure","Class Structure",void 0,2),t+=this.getMenuUrl("dev_addclass",e.htmlCls.baseUrl+"icn3d/icn3d.html#addclass","Add New Classes",void 0,2),t+=this.getMenuUrl("dev_modfunc",e.htmlCls.baseUrl+"icn3d/icn3d.html#modifyfunction","Modify Functions",void 0,2),t+=this.getMenuUrl("dev_restful",e.htmlCls.baseUrl+"icn3d/icn3d.html#restfulapi","RESTful APIs",void 0,2),t+=this.getMenuUrl("dev_contributor",e.htmlCls.baseUrl+"icn3d/icn3d.html#contributors","iCn3D Contributors",void 0,2),t+="
      ",t+="",t+=this.getMenuUrl("helpdoc",e.htmlCls.baseUrl+"icn3d/docs/icn3d_help.html","Help Doc "+e.htmlCls.wifiStr,1,1),t+=this.getMenuSep(),t+=this.getMenuText("mn6_tfhint","Transform Hints",void 0,1,1),t+="
        ",t+=this.getMenuText("mn6_rotate","Rotate",void 0,1,2),t+="
          ",t+="
        • Left Mouse (Click & Drag)
        • ",t+="
        • Key l: Left
        • ",t+="
        • Key j: Right
        • ",t+="
        • Key i: Up
        • ",t+="
        • Key m: Down
        • ",t+="
        • Shift + Key l: Left 90°
        • ",t+="
        • Shift + Key j: Right 90°
        • ",t+="
        • Shift + Key i: Up 90°
        • ",t+="
        • Shift + Key m: Down 90°
        • ",t+="
        ",t+="",t+=this.getMenuText("mn6_zoom","Zoom",void 0,1,2),t+="
          ",t+="
        • Middle Mouse
          (Pinch & Spread)
        • ",t+="
        • Key z: Zoom in
        • ",t+="
        • Key x: Zoom out
        • ",t+="
        ",t+="",t+=this.getMenuText("mn6_translate","Translate",void 0,1,2),t+="
          ",t+="
        • Right Mouse
          (Two Finger Click & Drag)
        • ",t+="
        ",t+="",t+="
      ",t+="",t+=this.getMenuUrl("selhints",e.htmlCls.baseUrl+"icn3d/icn3d.html#selsubset","Selection Hints",void 0,1),t+=this.getMenuUrl("helpdesk","https://support.nlm.nih.gov/support/create-case/","Write to Help Desk",1,1),t+="

    • ",t+="
    ",t}hideMenu(){let e=this.icn3dui;e.bNode||(void 0!==$("#"+e.pre+"mnlist")[0]&&($("#"+e.pre+"mnlist")[0].style.display="none"),void 0!==$("#"+e.pre+"mnLogSection")[0]&&($("#"+e.pre+"mnLogSection")[0].style.display="none"),void 0!==$("#"+e.pre+"cmdlog")[0]&&($("#"+e.pre+"cmdlog")[0].style.display="none"),$("#"+e.pre+"title")[0].style.margin="10px 0 0 10px")}showMenu(){let e=this.icn3dui;e.bNode||(void 0!==$("#"+e.pre+"mnlist")[0]&&($("#"+e.pre+"mnlist")[0].style.display="block"),void 0!==$("#"+e.pre+"mnLogSection")[0]&&($("#"+e.pre+"mnLogSection")[0].style.display="block"),void 0!==$("#"+e.pre+"cmdlog")[0]&&($("#"+e.pre+"cmdlog")[0].style.display="block"))}}class c{constructor(e){this.icn3dui=e}openDlg(e,t){let s=this.icn3dui;s.icn3d,s.bNode||(e=s.pre+e,s.cfg.notebook?this.openDlgNotebook(e,t):this.openDlgRegular(e,t),s.htmlCls.themecolor||(s.htmlCls.themecolor="blue"),s.htmlCls.setMenuCls.setTheme(s.htmlCls.themecolor))}addSaveButton(e){let t=this.icn3dui;t.icn3d,t.bNode||void 0!==this.dialogHashSave&&this.dialogHashSave.hasOwnProperty(e)||($("#"+e).parent().children(".ui-dialog-titlebar").append("
    "),void 0===this.dialogHashSave&&(this.dialogHashSave={}),this.dialogHashSave[e]=1)}addHideButton(e){let t=this.icn3dui;t.icn3d,t.bNode||void 0!==this.dialogHashHide&&this.dialogHashHide.hasOwnProperty(e)||($("#"+e).parent().children(".ui-dialog-titlebar").append("
    "),void 0===this.dialogHashHide&&(this.dialogHashHide={}),this.dialogHashHide[e]=1)}getDialogStatus(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t={},s={},i=$("#"+e.pre+"dl_selectannotations").hasClass("ui-dialog-content"),n=$("#"+e.pre+"dl_graph").hasClass("ui-dialog-content"),l=$("#"+e.pre+"dl_linegraph").hasClass("ui-dialog-content"),r=$("#"+e.pre+"dl_scatterplot").hasClass("ui-dialog-content"),o=$("#"+e.pre+"dl_contactmap").hasClass("ui-dialog-content"),a=$("#"+e.pre+"dl_alignerrormap").hasClass("ui-dialog-content"),d=$("#"+e.pre+"dl_interactionsorted").hasClass("ui-dialog-content"),c=$("#"+e.pre+"dl_alignment").hasClass("ui-dialog-content"),h=$("#"+e.pre+"dl_2ddgm").hasClass("ui-dialog-content"),p=$("#"+e.pre+"dl_2dctn").hasClass("ui-dialog-content"),m=$("#"+e.pre+"dl_definedsets").hasClass("ui-dialog-content");return t.bSelectannotationsInit2=!1,t.bGraph2=!1,t.bLineGraph2=!1,t.bScatterplot2=!1,t.bTable2=!1,t.bAlignmentInit2=!1,t.bTwoddgmInit2=!1,t.bTwodctnInit2=!1,t.bSetsInit2=!1,s.dl_selectannotations="bSelectannotationsInit2",s.dl_graph="bGraph2",s.dl_linegraph="bLineGraph2",s.dl_scatterplot="bScatterplot2",s.dl_contactmap="bContactmap2",s.dl_alignerrormap="bAlignerrormap2",s.dl_interactionsorted="bTable2",s.dl_alignment="bAlignmentInit2",s.dl_2ddgm="bTwoddgmInit2",s.dl_2dctn="bTwodctnInit2",s.dl_definedsets="bSetsInit2",i&&(t.bSelectannotationsInit2=$("#"+e.pre+"dl_selectannotations").dialog("isOpen")),n&&(t.bGraph2=$("#"+e.pre+"dl_graph").dialog("isOpen")),l&&(t.bLineGraph2=$("#"+e.pre+"dl_linegraph").dialog("isOpen")),r&&(t.bScatterplot2=$("#"+e.pre+"dl_scatterplot").dialog("isOpen")),o&&(t.bContactmap2=$("#"+e.pre+"dl_contactmap").dialog("isOpen")),a&&(t.bAlignerror2=$("#"+e.pre+"dl_alignerrormap").dialog("isOpen")),d&&(t.bTable2=$("#"+e.pre+"dl_interactionsorted").dialog("isOpen")),c&&(t.bAlignmentInit2=$("#"+e.pre+"dl_alignment").dialog("isOpen")),h&&(t.bTwoddgmInit2=$("#"+e.pre+"dl_2ddgm").dialog("isOpen")),p&&(t.bTwodctnInit2=$("#"+e.pre+"dl_2dctn").dialog("isOpen")),m&&(t.bSetsInit2=$("#"+e.pre+"dl_definedsets").dialog("isOpen")),{status:t,id2flag:s}}openDlgHalfWindow(e,t,s,i){let n=this.icn3dui,l=n.icn3d;if(n.bNode)return;let r=this,o=n.htmlCls.width2d+20;l.resizeCanvasCls.resizeCanvas(n.htmlCls.WIDTH-s,n.htmlCls.HEIGHT,i);let a,d=n.htmlCls.HEIGHT,c=s;a=!n.cfg.showmenu||n.utilsCls.isMobile()||n.cfg.mobilemenu?{my:"left top",at:"right top",of:"#"+n.pre+"viewer",collision:"none"}:{my:"left top",at:"right top+40",of:"#"+n.pre+"viewer",collision:"none"},n.cfg.resize=!1,window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:d,width:c,modal:!1,position:a,close:function(t){let s=r.getDialogStatus(),i=s.status,a=s.id2flag,d=!1;for(let t in a){let s=e===n.pre+t;for(let e in i)i.hasOwnProperty(e)||(s=s&&!i[e]);d=d||s}if(d)if(i.bTwoddgmInit2||i.bTwodctnInit2||i.bSetsInit2){let e=n.utilsCls.isMobile()?n.htmlCls.WIDTH:n.htmlCls.WIDTH-o;l.resizeCanvasCls.resizeCanvas(e,n.htmlCls.HEIGHT,!0),i.bTwoddgmInit2&&r.openDlg2Ddgm(n.pre+"dl_2ddgm",void 0,i.bSetsInit2),i.bTwodctnInit2&&r.openDlg2Ddgm(n.pre+"dl_2dctn",void 0,i.bSetsInit2),i.bSetsInit2&&r.openDlg2Ddgm(n.pre+"dl_definedsets")}else l.resizeCanvasCls.resizeCanvas(n.htmlCls.WIDTH,n.htmlCls.HEIGHT,!0)},resize:function(t){if(e==n.pre+"dl_selectannotations")l.annotationCls.hideFixedTitle();else if(e==n.pre+"dl_graph"){let t=$("#"+e).width(),s=$("#"+e).height();d3.select("#"+n.svgid).attr("width",t).attr("height",s)}else if(e==n.pre+"dl_linegraph"||e==n.pre+"dl_scatterplot"||e==n.pre+"dl_contactmap"||e==n.pre+"dl_alignerrormap"){let t=status.bTwoddgmInit2||status.bSetsInit2?(n.htmlCls.WIDTH-o)/2:n.htmlCls.WIDTH/2,s=$("#"+e).width()/t;if(e==n.pre+"dl_linegraph"){let e=l.linegraphWidth*s;$("#"+n.linegraphid).attr("width",e)}else if(e==n.pre+"dl_scatterplot"){let e=l.scatterplotWidth*s;$("#"+n.scatterplotid).attr("width",e)}else if(e==n.pre+"dl_contactmap"){let e=l.contactmapWidth*s;$("#"+n.contactmapid).attr("width",e)}else if(e==n.pre+"dl_alignerrormap"){let e=l.alignerrormapWidth*s;$("#"+n.alignerrormapid).attr("width",e)}}}}),this.addSaveButton(e),this.addHideButton(e)}openDlg2Ddgm(e,t,s){let i=this.icn3dui,n=i.icn3d;if(i.bNode)return;let l,r,o=this,a=i.htmlCls.width2d+20;e===i.pre+"dl_definedsets"?(l="right top",r="Select sets"):e!==i.pre+"dl_2ddgm"&&e!==i.pre+"dl_2dctn"||(l=s?"right top+240":"right top",r=e===i.pre+"dl_2ddgm"?"2D Diagram":"2D Cartoon");let d={my:"left top+"+i.htmlCls.MENU_HEIGHT,at:l,of:"#"+i.pre+"viewer",collision:"none"};window.dialog=$("#"+e).dialog({autoOpen:!0,title:r,height:"auto",width:a,modal:!1,position:d,close:function(e){let t=o.getDialogStatus().status;t.bSelectannotationsInit2||t.bGraph2||t.bLineGraph2||t.bScatterplot2||t.bTable2||t.bAlignmentInit2||n.resizeCanvasCls.resizeCanvas(i.htmlCls.WIDTH,i.htmlCls.HEIGHT,!0)},resize:function(t,s){e==i.pre+"dl_2dctn"&&(n.resizeRatioX=s.size.width/i.htmlCls.width2d,n.resizeRatioY=s.size.height/(i.htmlCls.width2d+70))},resizeStop:function(e,t){n.resizeRatioX=t.size.width/i.htmlCls.width2d,n.resizeRatioY=t.size.height/(i.htmlCls.width2d+70)}}),this.addSaveButton(e),this.addHideButton(e)}openDlgRegular(e,t){let s=this.icn3dui,i=s.icn3d;if(s.bNode)return;let n=400,l=150,r=s.htmlCls.width2d+20,o=this.getDialogStatus().status;if(e===s.pre+"dl_selectannotations"||e===s.pre+"dl_graph"||e===s.pre+"dl_linegraph"||e===s.pre+"dl_scatterplot"||e===s.pre+"dl_contactmap"||e===s.pre+"dl_alignerrormap"||e===s.pre+"dl_interactionsorted"||e===s.pre+"dl_alignment"){let a=.5*s.htmlCls.WIDTH-.5*r;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)this.openDlgHalfWindow(e,t,a,!0),(o.bTwoddgmInit2||o.bTwodctnInit2||o.bSetsInit2)&&(i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-a-r,s.htmlCls.HEIGHT,!0),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,o.bSetsInit2),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,o.bSetsInit2),o.bSetsInit2&&this.openDlg2Ddgm(s.pre+"dl_definedsets"));else{i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH,.5*s.htmlCls.HEIGHT,!0),l=.5*s.htmlCls.HEIGHT,n=s.htmlCls.WIDTH;let a={my:"left top",at:"left bottom+32",of:"#"+s.pre+"canvas",collision:"none"};window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:l,width:n,modal:!1,position:a,close:function(t){if(!((e!==s.pre+"dl_selectannotations"||o.bAlignmentInit2||o.bGraph2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_graph"||o.bSelectannotationsInit2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_alignment"||o.bSelectannotationsInit2||o.bGraph2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_interactionsorted"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_linegraph"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_scatterplot"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_contactmap"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bAlignerrormap2)&&(e!==s.pre+"dl_alignerrormap"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2)))if(o.bTwoddgmInit2||o.bTwodctnInit2||o.bSetsInit2){let e=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(e,s.htmlCls.HEIGHT,!0),o.bTwoddgmInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,o.bSetsInit2),o.bTwodctnInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,o.bSetsInit2),o.bSetsInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_definedsets")}else i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH,s.htmlCls.HEIGHT,!0)},resize:function(t){if(e==s.pre+"dl_selectannotations")i.annotationCls.hideFixedTitle();else if(e==s.pre+"dl_graph"){let t=$("#"+e).width(),i=$("#"+e).height();d3.select("#"+s.svgid).attr("width",t).attr("height",i)}else if(e==s.pre+"dl_linegraph"||e==s.pre+"dl_scatterplot"||e==s.pre+"dl_contactmap"||e==s.pre+"dl_alignerrormap"){let t=o.bTwoddgmInit2||o.bSetsInit2?(s.htmlCls.WIDTH-r)/2:s.htmlCls.WIDTH/2,n=$("#"+e).width()/t;if(e==s.pre+"dl_linegraph"){let e=i.linegraphWidth*n;$("#"+s.linegraphid).attr("width",e)}else if(e==s.pre+"dl_scatterplot"){let e=i.scatterplotWidth*n;$("#"+s.scatterplotid).attr("width",e)}else if(e==s.pre+"dl_contactmap"){let e=i.contactmapWidth*n;$("#"+s.contactmapid).attr("width",e)}else if(e==s.pre+"dl_alignerrormap"){let e=i.alignerrormapWidth*n;$("#"+s.alignerrormapid).attr("width",e)}}}}),this.addSaveButton(e),this.addHideButton(e)}}else if(e===s.pre+"dl_2ddgm"||e===s.pre+"dl_2dctn"){let t=0;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)(o.bSelectannotationsInit2||o.bGraph2||o.bLineGraph2||o.bScatterplot2||o.bTable2||o.bAlignmentInit2)&&(t=.5*s.htmlCls.WIDTH-.5*r),i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-t-r,s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,void 0,o.bSetsInit2);else{let t=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(t,.5*s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT,o.bSetsInit2)}}else{let a;if(l="auto",n="auto",e===s.pre+"dl_addtrack"?n="50%":e===s.pre+"dl_menupref"&&(n=600,l=500),e===s.pre+"dl_definedsets"){let t=0;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)(o.bSelectannotationsInit2||o.bGraph2||o.bLineGraph2||o.bScatterplot2||o.bTable2||o.bAlignmentInit2)&&(t=.5*s.htmlCls.WIDTH-.5*r),i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-t-r,s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,!0),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,!0);else{let t=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(t,.5*s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",.5*s.htmlCls.HEIGHT,!0),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",.5*s.htmlCls.HEIGHT,!0)}}else s.utilsCls.isMobile()?a={my:"left top",at:"left bottom-50",of:"#"+s.pre+"canvas",collision:"none"}:e===s.pre+"dl_allinteraction"||e===s.pre+"dl_buriedarea"?(a={my:"right top",at:"right top+50",of:"#"+i.divid,collision:"none"},n=700,l=500):a=e===s.pre+"dl_rmsd"||e===s.pre+"dl_legend"?{my:"left bottom",at:"left+20 bottom-20",of:"#"+s.pre+"canvas",collision:"none"}:e===s.pre+"dl_symd"?{my:"left top",at:"right-200 bottom-200",of:"#"+s.pre+"canvas",collision:"none"}:s.cfg.align?{my:"left top",at:"left top+90",of:"#"+s.pre+"canvas",collision:"none"}:{my:"left top",at:"left top+50",of:"#"+s.pre+"canvas",collision:"none"},window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:l,width:n,modal:!1,position:a}),this.addSaveButton(e),this.addHideButton(e)}$(".ui-dialog .ui-button span").removeClass("ui-icon-closethick").addClass("ui-icon-close")}openDlgNotebook(e,t){let s=this.icn3dui,i=s.icn3d;if(s.bNode)return;let n=400,l=150,r=s.htmlCls.width2d+20;e===s.pre+"dl_selectannotations"||e===s.pre+"dl_graph"||e===s.pre+"dl_linegraph"||e===s.pre+"dl_scatterplot"||e===s.pre+"dl_contactmap"||e===s.pre+"dl_alignerrormap"||e===s.pre+"dl_interactionsorted"||e===s.pre+"dl_alignment"?($("#"+e).show(),l=.5*s.htmlCls.HEIGHT,n=s.htmlCls.WIDTH,$("#"+e).width(n),$("#"+e).height(l),$("#"+e).resize((function(t){let n=s.htmlCls.WIDTH/2,l=$("#"+e).width()/n;if(e==s.pre+"dl_selectannotations")i.annotationCls.hideFixedTitle();else if(e==s.pre+"dl_graph"){let t=$("#"+e).width(),i=$("#"+e).height();d3.select("#"+s.svgid).attr("width",t).attr("height",i)}else if(e==s.pre+"dl_linegraph"){let e=i.linegraphWidth*l;$("#"+s.linegraphid).attr("width",e)}else if(e==s.pre+"dl_scatterplot"){let e=i.scatterplotWidth*l;$("#"+s.scatterplotid).attr("width",e)}else if(e==s.pre+"dl_contactmap"){let e=i.contactmapWidth*l;$("#"+s.contactmapid).attr("width",e)}else if(e==s.pre+"dl_alignerrormap"){let e=i.alignerrormapWidth*l;$("#"+s.alignerrormapid).attr("width",e)}}))):(i.bRender&&$("#"+e).show(),l="auto",n="auto",e===s.pre+"dl_addtrack"?n="50%":e===s.pre+"dl_2ddgm"||e===s.pre+"dl_2dctn"||e===s.pre+"dl_definedsets"?n=r:e!==s.pre+"dl_allinteraction"&&e!==s.pre+"dl_buriedarea"||(n=700,l=500),$("#"+e).width(n),$("#"+e).height(l))}}class h{constructor(e){this.icn3dui=e}setCustomDialogs(){let e=this.icn3dui;if(e.icn3d,e.bNode)return"";return""}getHtmlAlignResidueByResidue(e,t,s){let i=this.icn3dui;i.icn3d;let n="";return n+="All chains will be aligned to the first chain in the comma-separated chain IDs. Each chain ID has the form of PDBID_chain (e.g., 1HHO_A, case sensitive) or UniprotID (e.g., P69905 for AlphaFold structures).

    ",n+="Chain IDs: "+i.htmlCls.inputTextStr+"id='"+i.pre+e+"' value='P69905,P01942,1HHO_A' size=50>

    ",n+='Each alignment is defined as " | "-separated residue lists in one line. "10-50" means a range of residues from 10 to 50.

    ",n+=i.htmlCls.buttonStr+s+"'>Align Residue by Residue
    ",n}setDialogs(){let e=this.icn3dui,t=e.icn3d;if(e.bNode)return"";let s="";e.htmlCls.optionStr="":s.htmlCls.optionStr+"'"+l+"'>"+l+""}return i}setColorHints(){let e=this.icn3dui;e.icn3d;let t="";return t+=e.htmlCls.divNowrapStr+'Green: H-Bonds; ',t+='Cyan: Salt Bridge/Ionic; ',t+='Grey: contacts',t+=e.htmlCls.divNowrapStr+'Magenta: Halogen Bonds; ',t+='Red: π-Cation; ',t+='Blue: π-Stacking',t}setThicknessHtml(e){let t=this.icn3dui,s=t.icn3d,i="",n="3dprint"==e?"1":"0.1",l="3dprint"==e?"1.2":"0.3",r="3dprint"==e?"0.8":"0.4",o="3dprint"==e?"0.8":"0.4",a="3dprint"==e?"1":"0.4",d="3dprint"==e?"0.6":"0.3",c="3dprint"==e?"1":"0.2",h="3dprint"==e?"2":"1.3",p="3dprint"==e?"1.4":"0.8",m=40,u=.6,g=.4,f=.2,b=0,C=1,y=0;if("style"==e){if(""!=this.getCookie("shininess")&&(m=parseFloat(this.getCookie("shininess"))),""!=this.getCookie("light1")&&(u=parseFloat(this.getCookie("light1")),g=parseFloat(this.getCookie("light2")),f=parseFloat(this.getCookie("light3"))),""!=this.getCookie("lineRadius")){n=parseFloat(this.getCookie("lineRadius")),l=parseFloat(this.getCookie("coilWidth")),r=parseFloat(this.getCookie("cylinderRadius"));let e=this.getCookie("crosslinkRadius");o=isNaN(e)?s.crosslinkRadius:parseFloat(e),a=parseFloat(this.getCookie("traceRadius")),d=parseFloat(this.getCookie("dotSphereScale")),c=parseFloat(this.getCookie("ribbonthickness")),h=parseFloat(this.getCookie("helixSheetWidth")),p=parseFloat(this.getCookie("nucleicAcidWidth"))}""!=this.getCookie("glycan")&&(b=parseFloat(this.getCookie("glycan"))),""!=this.getCookie("membrane")&&(C=parseFloat(this.getCookie("membrane"))),""!=this.getCookie("cmdwindow")&&(y=parseFloat(this.getCookie("cmdwindow"))),i+="Note: The following parameters will be saved in cache. You just need to set them once.

    ",i+="1. Shininess: "+t.htmlCls.inputTextStr+"id='"+t.pre+"shininess' value='"+m+"' size=4>"+t.htmlCls.space3+"(for the shininess of the 3D objects, default 40)

    ",i+="2. Three directional lights:
    ",i+="Key Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light1' value='"+u+"' size=4>"+t.htmlCls.space3+"(for the light strength of the key light, default 0.6)
    ",i+="Fill Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light2' value='"+g+"' size=4>"+t.htmlCls.space3+"(for the light strength of the fill light, default 0.4)
    ",i+="Back Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light3' value='"+f+"' size=4>"+t.htmlCls.space3+"(for the light strength of the back light, default 0.2)

    ",i+="3. Thickness:
    "}return i+="Line Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"linerad_"+e+"' value='"+n+"' size=4>"+t.htmlCls.space3+"(for stabilizers, hydrogen bonds, distance lines, default 0.1)
    ",i+="Coil Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"coilrad_"+e+"' value='"+l+"' size=4>"+t.htmlCls.space3+"(for coils, default 0.3)
    ",i+="Stick Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"stickrad_"+e+"' value='"+r+"' size=4>"+t.htmlCls.space3+"(for sticks, default 0.4)
    ",i+="Cross-Linkage Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"crosslinkrad_"+e+"' value='"+o+"' size=4>"+t.htmlCls.space3+"(for cross-linkages, default 0.4)
    ",i+="Trace Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"tracerad_"+e+"' value='"+a+"' size=4>"+t.htmlCls.space3+"(for C alpha trace, O3' trace, default 0.4)
    ",i+="Ribbon Thickness: "+t.htmlCls.inputTextStr+"id='"+t.pre+"ribbonthick_"+e+"' value='"+c+"' size=4>"+t.htmlCls.space3+"(for helix and sheet ribbons, nucleotide ribbons, default 0.2)
    ",i+="Protein Ribbon Width: "+t.htmlCls.inputTextStr+"id='"+t.pre+"prtribbonwidth_"+e+"' value='"+h+"' size=4>"+t.htmlCls.space3+"(for helix and sheet ribbons, default 1.3)
    ",i+="Nucleotide Ribbon Width: "+t.htmlCls.inputTextStr+"id='"+t.pre+"nucleotideribbonwidth_"+e+"' value='"+p+"' size=4>"+t.htmlCls.space3+"(for nucleotide ribbons, default 0.8)
    ",i+="Ball Scale: "+t.htmlCls.inputTextStr+"id='"+t.pre+"ballscale_"+e+"' value='"+d+"' size=4>"+t.htmlCls.space3+"(for styles 'Ball and Stick' and 'Dot', default 0.3)
    ","style"==e&&(i+="
    4. Show Glycan Cartoon: "+t.htmlCls.inputTextStr+"id='"+t.pre+"glycan' value='"+b+"' size=4>"+t.htmlCls.space3+"(0: hide, 1: show, default 0)
    ",i+="
    5. Show Membrane: "+t.htmlCls.inputTextStr+"id='"+t.pre+"membrane' value='"+C+"' size=4>"+t.htmlCls.space3+"(0: hide, 1: show, default 1)
    ",i+="
    6. Enlarge Command Window: "+t.htmlCls.inputTextStr+"id='"+t.pre+"cmdwindow' value='"+y+"' size=4>"+t.htmlCls.space3+"(0: Regular, 1: Large, default 0)

    "),i+=t.htmlCls.spanNowrapStr+""+t.htmlCls.buttonStr+"apply_thickness_"+e+"'>Apply   ",i+=t.htmlCls.spanNowrapStr+""+t.htmlCls.buttonStr+"reset_thickness_"+e+"'>Reset",i}getCookie(e){let t=e+"=",s=decodeURIComponent(document.cookie).split(";");for(let e=0;e":(n+='
    ',n+="
    Selection: Name: "+s.htmlCls.inputTextStr+"id='"+s.pre+"seq_command_name"+e+"' value='seq_"+l+"' size='5'> "+s.htmlCls.space2+"

    ",n+=s.htmlCls.divStr+"seqguide"+e+"' style='display:none; white-space:normal;' class='icn3d-box'>"),n+=this.getSelectionHints();return n+="Residue labeling: standard residue with coordinates: UPPER case letter; nonstandard residue with coordinates: the first UPPER case letter plus a period except that water residue uses the letter 'O'; residue missing coordinates: lower case letter."+(s.utilsCls.isMac()&&!s.utilsCls.isMobile()?"

    Turn on scroll bar: System preferences -> General -> show scroll bars -> check Always":"")+"
    ",n}setAlignSequenceGuide(e,t){let s=this.icn3dui,i=s.icn3d,n="";let l=i&&i.defNames2Atoms?Object.keys(i.defNames2Atoms).length:1;n+='
    ',n+="
    Selection: Name: "+s.htmlCls.inputTextStr+"id='"+s.pre+"alignseq_command_name' value='alseq_"+l+"' size='10'> "+s.htmlCls.space2+"

    ",n+=s.htmlCls.divStr+"alignseqguide' style='display:none; white-space:normal;' class='icn3d-box'>",n+=this.getSelectionHints();return n+="Residue labeling: aligned residue with coordinates: UPPER case letter; non-aligned residue with coordinates: lower case letter which can be highlighted; residue missing coordinates: lower case letter which can NOT be highlighted."+(s.utilsCls.isMac()&&!s.utilsCls.isMobile()?"

    Turn on scroll bar: System preferences -> General -> show scroll bars -> check Always":"")+"
    ",n}getSelectionHints(){let e=this.icn3dui;e.icn3d;let t="";if(e.utilsCls.isMobile())t+='Select Aligned Sequences: touch to select, touch again to deselect, multiple selection is allowed without Ctrl key, click "Save Selection" to save the current selection.
    ';else{t+='Select on 1D sequences: drag to select, drag again to deselect, multiple selection is allowed without Ctrl key, click "Save Selection" to save the current selection.

    ',t+="Select on 2D interaction diagram: click on the nodes or lines. The nodes are chains and can be united with the Ctrl key. The lines are interactions and can NOT be united. Each click on the lines selects half of the lines, i.e., select the interacting residues in one of the two chains.

    ",t+="Select on 3D structures: "+(e.utilsCls.isMobile()?"use finger to pick":'hold "Alt" and use mouse to pick')+', click the second time to deselect, hold "Ctrl" to union selection, hold "Shift" to select a range, press the up/down arrow to switch among atom/residue/strand/chain/structure, click "Save Selection" to save the current selection.

    ',t+='Save the current selection(either on 3D structure, 2D interactions, or 1D sequence): open the menu "Select -> Save Selection", specify the name and description for the selection, and click "Save".

    '}return t}addGsizeSalt(e){let t=this.icn3dui;t.icn3d;let s="";s+="Grid Size: ",s+="Salt Concentration: M
    ",s}getFootHtml(e,t){let s=this.icn3dui;s.icn3d;let i="
    ";return"delphi"==e?s.cfg.cid?i+="Note: Partial charges(MMFF94) are from PubChem Compound SDF files.

    ":(i+="Note: Only the selected residues are used for DelPhi potential calculation by solving linear Poisson-Boltzmann equation.",i+='

    ',i+=s.htmlCls.divStr+t+"' style='display:none;'>",i+="
    The hydrogens and partial charges of proteins and nucleotides are added using DelPhiPKa with the Amber charge and size files. The hydrogens of ligands are added using Open Babel. The partial charges of ligands are calculated using Antechamber with the Gasteiger charge method. All partial charges are calculated at pH 7.

    ",i+='Lipids are treated as ligands. Please use "HETATM" instead of "ATOM " for each lipid atom in your PDB file. Each phosphate in lipids is assigned with a charge of -1. You can download PQR and modify it, or prepare your PQR file using other tools. Then load the PQR file at the menu "Analysis > Load PQR/Potential".

    ',i+="
    "):(i+="Note: Always load a PDB file before loading a PQR or DelPhi potential file.",i+='

    ',i+=s.htmlCls.divStr+t+"' style='display:none;'>",i+='The PDB file can be loaded in the URL with "pdbid=" or at "File > Open File". The PQR file can be prepared at the menu "Analysis > Download PQR" with your modification or using other tools. The DelPhi potential file can be calculated at DelPhi Web Server and be exported as a Cube file. ',"url"==e&&(i+="The PQR or potential file can be accessed in a URL if it is located in the same host as iCn3D."),i+="

    ",i+=""),i+="",i}getPotentialHtml(e,t){let s=this.icn3dui;s.icn3d;let i,n,l,r,o,a="";r="Equipotential Map",o="Surface with Potential","delphi"==e?n="delphi":"local"==e?(i="pqr",n="phi",l="cube"):"url"==e&&(i="pqrurl",n="phiurl",l="cubeurl"),a+=s.htmlCls.divStr+"dl_"+n+"' class='"+t+"'>",a+=s.htmlCls.divStr+"dl_"+n+"_tabs' style='border:0px;'>",a+="",a+=s.htmlCls.divStr+n+"tab1'>","delphi"==e&&(a+=this.addGsizeSalt(n)+"
    "),a+="Potential contour at: kT/e(25.6mV at 298K)

    ","delphi"==e?(a+=s.htmlCls.buttonStr+"reload_"+n+"file' style='margin-top: 6px;'>Equipotential Map",a+=s.htmlCls.buttonStr+n+"mapNo' style='margin-left:30px;'>Remove Map
    "):"local"==e?(a+=s.htmlCls.divStr+n+"tab1_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo'>Remove Map",a+=s.htmlCls.divStr+n+"tab1_"+i+"'>",a+=this.addGsizeSalt(i)+"
    ",a+="PQR File: "+s.htmlCls.inputFileStr+"id='"+s.pre+i+"file'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+n+"'>",a+="Phi File: "+s.htmlCls.inputFileStr+"id='"+s.pre+n+"file'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+l+"'>",a+="Cube File: "+s.htmlCls.inputFileStr+"id='"+s.pre+l+"file'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=""):"url"==e&&(a+=s.htmlCls.divStr+n+"tab1_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo'>Remove Map",a+=s.htmlCls.divStr+n+"tab1_"+i+"2'>",a+=this.addGsizeSalt(i)+"
    ",a+="PQR URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+i+"file'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+n+"2'>",a+="Phi URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+n+"file'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+l+"2'>",a+="Cube URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+l+"file'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=""),a+="
    "+this.getFootHtml(e,n+"tab1_foot"),a+="",a+=s.htmlCls.divStr+n+"tab2'>","delphi"==e&&(a+=this.addGsizeSalt(n)+"
    "),a+="Surface with max potential at: kT/e(25.6mV at 298K)

    ",a+="Surface: ",a+="Opacity: ",a+="Wireframe:
    ",a+="
    ","delphi"==e?(a+=s.htmlCls.buttonStr+"reload_"+n+"file2' style='margin-top: 6px;'>Surface with Potential",a+=s.htmlCls.buttonStr+n+"mapNo2' style='margin-left:30px;'>Remove Surface
    "):"local"==e?(a+=s.htmlCls.divStr+n+"tab2_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo2'>Remove Surface",a+=s.htmlCls.divStr+n+"tab2_"+i+"'>",a+=this.addGsizeSalt(i+"2")+"
    ",a+="PQR File: "+s.htmlCls.inputFileStr+"id='"+s.pre+i+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+n+"'>",a+="Phi File: "+s.htmlCls.inputFileStr+"id='"+s.pre+n+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+l+"'>",a+="Cube File: "+s.htmlCls.inputFileStr+"id='"+s.pre+l+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=""):"url"==e&&(a+=s.htmlCls.divStr+n+"tab2_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo2'>Remove Surface",a+=s.htmlCls.divStr+n+"tab2_"+i+"2'>",a+=this.addGsizeSalt(i+"2")+"
    ",a+="PQR URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+i+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+n+"2'>",a+="Phi URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+n+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+l+"2'>",a+="Cube URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+l+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=""),a+="
    "+this.getFootHtml(e,n+"tab2_foot"),a+="",a+="",a+="",a}async exportPqr(e){let t=this.icn3dui,s=t.icn3d,i={},n={},l=t.hashUtilsCls.intHash(s.dAtoms,s.hAtoms);for(let e in l)s.atoms[e],s.ions.hasOwnProperty(e)?i[e]=1:n[e]=1;let r=e?"pdb":"pqr";if(t.cfg.cid){let t="",l=!e;t+=s.saveFileCls.getAtomPDB(n,l)+s.saveFileCls.getAtomPDB(i,l);let o=s.inputid?s.inputid:"custom";s.saveFileCls.saveFile(o+"_icn3d."+r,"text",[t])}else{if(t.utilsCls.isCalphaPhosOnly(t.hashUtilsCls.hash2Atoms(n,s.atoms)))return void alert("The potential will not be shown because the side chains are missing in the structure...");let l="";l+=s.saveFileCls.getAtomPDB(n),l+=s.saveFileCls.getAtomPDB(i,!0,void 0,!0);let o="https://www.ncbi.nlm.nih.gov/Structure/delphi/delphi.fcgi",a={pdb2pqr:l,pdbid:t.cfg.cid?t.cfg.cid:Object.keys(s.structures).toString()},d=await t.getAjaxPostPromise(o,a,!0,void 0,void 0,!0,"text");if(e){let e=d.split("\n"),s="";for(let i=0,n=e.length;i PNG Image" in the Data menu...');else if(-1!=l){let t=e.substr(l+n.length);s.htmlCls.clickMenuCls.setLogCmd("load iCn3D PNG image "+$("#"+s.pre+"pngimage").val(),!1),window.open(t,"_self")}else if(-1!=o){let n="Start of data file======\n",l=e.indexOf(n);i.bInputfile=-1!=l;let a,d=t?t.replace(/;/g,"\n"):"";if(i.bInputfile){let t=e.indexOf("End of data file======\n"),s=e.substr(l+n.length,t-l-n.length);i.InputfileData=i.InputfileData?i.InputfileData+"\nENDMDL\n"+s:s;let c="Start of type file======\n",h=e.indexOf(c),p=e.indexOf("End of type file======\n"),m=e.substr(h+c.length,p-h-c.length-1);i.InputfileType=m;let u=e.indexOf("End of state file======\n");a=e.substr(o+r.length,u-o-r.length),a=decodeURIComponent(a+"\n"+d),"pdb"===m?(await i.pdbParserCls.loadPdbData(s),i.commands=[],i.optsHistory=[]):("mol2"===m?await i.mol2ParserCls.loadMol2Data(s):"sdf"===m?await i.sdfParserCls.loadSdfData(s):"xyz"===m?await i.xyzParserCls.loadXyzData(s):"mmcif"===m&&await i.mmcifParserCls.loadMmcifData(s),i.commands=[],i.optsHistory=[])}else{let t=e.indexOf("End of state file======\n");a=e.substr(o+r.length,t-o-r.length),a=decodeURIComponent(a+"\n"+d),i.commands=[],i.optsHistory=[]}await i.loadScriptCls.loadScript(a,!0),s.htmlCls.clickMenuCls.setLogCmd("load iCn3D PNG image "+$("#"+s.pre+"pngimage").val(),!1)}}fileSupport(){window.File&&window.FileReader&&window.FileList&&window.Blob||alert("The File APIs are not fully supported in this browser.")}getLinkColor(){let e="";return e+=", linkmap: {\n",e+='3: {"type": "peptidebond", "c":""},\n',e+='4: {"type": "ssbond", "c":"FFA500"},\n',e+='5: {"type": "ionic", "c":"0FF"},\n',e+='6: {"type": "ionicInside", "c":"FFF"},\n',e+='11: {"type": "contact", "c":"888"},\n',e+='12: {"type": "contactInside", "c":"FFF"},\n',e+='13: {"type": "hbond", "c":"0F0"},\n',e+='14: {"type": "hbondInside", "c":"FFF"},\n',e+='15: {"type": "clbond", "c":"006400"},\n',e+='17: {"type": "halogen", "c":"F0F"},\n',e+='18: {"type": "halogenInside", "c":"FFF"},\n',e+='19: {"type": "pication", "c":"F00"},\n',e+='20: {"type": "picationInside", "c":"FFF"},\n',e+='21: {"type": "pistacking", "c":"00F"},\n',e+='22: {"type": "pistackingInside", "c":"FFF"}\n',e+="}}\n",', linkmap: {\n3: {"type": "peptidebond", "c":""},\n4: {"type": "ssbond", "c":"FFA500"},\n5: {"type": "ionic", "c":"0FF"},\n6: {"type": "ionicInside", "c":"FFF"},\n11: {"type": "contact", "c":"888"},\n12: {"type": "contactInside", "c":"FFF"},\n13: {"type": "hbond", "c":"0F0"},\n14: {"type": "hbondInside", "c":"FFF"},\n15: {"type": "clbond", "c":"006400"},\n17: {"type": "halogen", "c":"F0F"},\n18: {"type": "halogenInside", "c":"FFF"},\n19: {"type": "pication", "c":"F00"},\n20: {"type": "picationInside", "c":"FFF"},\n21: {"type": "pistacking", "c":"00F"},\n22: {"type": "pistackingInside", "c":"FFF"}\n}}\n'}setCookieForThickness(){let e=this.icn3dui,t=e.icn3d;if(!e.bNode){let e=3650;this.setCookie("lineRadius",t.lineRadius,e),this.setCookie("coilWidth",t.coilWidth,e),this.setCookie("cylinderRadius",t.cylinderRadius,e),this.setCookie("crosslinkRadius",t.crosslinkRadius,e),this.setCookie("traceRadius",t.traceRadius,e),this.setCookie("dotSphereScale",t.dotSphereScale,e),this.setCookie("ribbonthickness",t.ribbonthickness,e),this.setCookie("helixSheetWidth",t.helixSheetWidth,e),this.setCookie("nucleicAcidWidth",t.nucleicAcidWidth,e)}}setLineThickness(e,t){let s=this.icn3dui,i=s.icn3d;if(i.bSetThickness=!0,"style"==e&&(t&&($("#"+s.pre+"shininess").val("40"),$("#"+s.pre+"light1").val("0.6"),$("#"+s.pre+"light2").val("0.4"),$("#"+s.pre+"light3").val("0.2"),$("#"+s.pre+"glycan").val("0"),$("#"+s.pre+"membrane").val("1"),$("#"+s.pre+"cmdwindow").val("0")),i.shininess=parseFloat($("#"+s.pre+"shininess").val()),i.light1=parseFloat($("#"+s.pre+"light1").val()),i.light2=parseFloat($("#"+s.pre+"light2").val()),i.light3=parseFloat($("#"+s.pre+"light3").val()),i.bGlycansCartoon=parseInt($("#"+s.pre+"glycan").val()),i.bMembrane=parseInt($("#"+s.pre+"membrane").val()),i.bCmdWindow=parseInt($("#"+s.pre+"cmdwindow").val())),t&&($("#"+s.pre+"linerad_"+e).val(.1),$("#"+s.pre+"coilrad_"+e).val(.3),$("#"+s.pre+"stickrad_"+e).val(.4),$("#"+s.pre+"crosslinkrad_"+e).val(.4),$("#"+s.pre+"tracerad_"+e).val(.4),$("#"+s.pre+"ballscale_"+e).val(.3),$("#"+s.pre+"ribbonthick_"+e).val(.2),$("#"+s.pre+"prtribbonwidth_"+e).val(1.3),$("#"+s.pre+"nucleotideribbonwidth_"+e).val(.8)),i.lineRadius=parseFloat($("#"+s.pre+"linerad_"+e).val()),i.coilWidth=parseFloat($("#"+s.pre+"coilrad_"+e).val()),i.cylinderRadius=parseFloat($("#"+s.pre+"stickrad_"+e).val()),i.crosslinkRadius=parseFloat($("#"+s.pre+"crosslinkrad_"+e).val()),i.traceRadius=parseFloat($("#"+s.pre+"tracerad_"+e).val()),i.dotSphereScale=parseFloat($("#"+s.pre+"ballscale_"+e).val()),i.ribbonthickness=parseFloat($("#"+s.pre+"ribbonthick_"+e).val()),i.helixSheetWidth=parseFloat($("#"+s.pre+"prtribbonwidth_"+e).val()),i.nucleicAcidWidth=parseFloat($("#"+s.pre+"nucleotideribbonwidth_"+e).val()),!s.bNode){let e=3650;this.setCookie("shininess",i.shininess,e),this.setCookie("light1",i.light1,e),this.setCookie("light2",i.light2,e),this.setCookie("light3",i.light3,e),this.setCookie("glycan",i.bGlycansCartoon,e),this.setCookie("membrane",i.bMembrane,e),this.setCookie("cmdwindow",i.bCmdWindow,e)}if(this.setCookieForThickness(),e=t){let e="reset thickness";s.htmlCls.clickMenuCls.setLogCmd(e,!0),i.bSetThickness=!1,i.threeDPrintCls.resetAfter3Dprint()}else s.htmlCls.clickMenuCls.setLogCmd("set thickness | linerad "+i.lineRadius+" | coilrad "+i.coilWidth+" | stickrad "+i.cylinderRadius+" | crosslinkrad "+i.crosslinkRadius+" | tracerad "+i.traceRadius+" | ribbonthick "+i.ribbonthickness+" | proteinwidth "+i.helixSheetWidth+" | nucleotidewidth "+i.nucleicAcidWidth+" | ballscale "+i.dotSphereScale,!0),s.htmlCls.clickMenuCls.setLogCmd("set glycan "+i.bGlycansCartoon,!0),s.htmlCls.clickMenuCls.setLogCmd("set membrane "+i.bMembrane,!0),s.htmlCls.clickMenuCls.setLogCmd("set cmdwindow "+i.bCmdWindow,!0);i.drawCls.draw()}setCookie(e,t,s){let i=new Date;i.setTime(i.getTime()+24*s*60*60*1e3);let n="expires="+i.toUTCString();document.cookie=e+"="+t+";"+n+";path=/"}updateSurfPara(e){let t=this.icn3dui,s=t.icn3d;s.phisurftype=$("#"+t.pre+e+"surftype").val(),s.phisurfop=$("#"+t.pre+e+"surfop").val(),s.phisurfwf=$("#"+t.pre+e+"surfwf").val()}exportPdb(){let e=this.icn3dui,t=e.icn3d,s="",i=e.hashUtilsCls.intHash(t.dAtoms,t.hAtoms);if(s+=t.saveFileCls.getAtomPDB(i),!e.bNode){let e=t.inputid?t.inputid:"custom";t.saveFileCls.saveFile(e+"_icn3d.pdb","text",[s])}return s}exportSecondary(){let e=this.icn3dui,t=e.icn3d,s="",i=e.hashUtilsCls.intHash(t.dAtoms,t.hAtoms);if(s+=t.saveFileCls.getSecondary(i),!e.bNode){let e=t.inputid?t.inputid:"custom";t.saveFileCls.saveFile(e+"_icn3d_ss.txt","text",[s])}return s}}class g{constructor(e){let t=e;this.icn3dui=e,this.cfg=this.icn3dui.cfg,this.opts={},this.opts.background="black",this.allMenus={},this.allMenusSel={},this.simpleMenus={},this.shownMenus={},this.WIDTH=400,this.HEIGHT=400,this.RESIDUE_WIDTH=10,t.utilsCls.isMobile()||this.cfg.mobilemenu?this.MENU_HEIGHT=0:this.MENU_HEIGHT=40,this.LOG_HEIGHT=65,this.MENU_WIDTH=750,this.LESSWIDTH=20,this.LESSWIDTH_RESIZE=20,this.LESSHEIGHT=20,this.width2d=200,this.CMD_HEIGHT=.8*this.LOG_HEIGHT,this.EXTRAHEIGHT=this.MENU_HEIGHT+this.CMD_HEIGHT,null!=this.cfg.showmenu&&0==this.cfg.showmenu&&(this.EXTRAHEIGHT-=this.MENU_HEIGHT),null!=this.cfg.showcommand&&0==this.cfg.showcommand&&(this.EXTRAHEIGHT-=this.CMD_HEIGHT),this.GREY8="#AAAAAA",this.GREYB="#CCCCCC",this.GREYC="#DDDDDD",this.GREYD="#EEEEEE",this.ORANGE="#FFA500",this.themecolor="blue",this.defaultValue=1,this.ssValue=3,this.coilValue=3,this.contactValue=11,this.contactInsideValue=12,this.hbondValue=13,this.hbondInsideValue=14,this.ssbondValue=4,this.ionicValue=5,this.ionicInsideValue=6,this.clbondValue=15,this.halogenValue=17,this.halogenInsideValue=18,this.picationValue=19,this.picationInsideValue=20,this.pistackingValue=21,this.pistackingInsideValue=22,this.contactColor="888",this.contactInsideColor="FFF",this.hbondColor="0F0",this.hbondInsideColor="FFF",this.ssbondColor="FFA500",this.ionicColor="0FF",this.ionicInsideColor="FFF",this.clbondColor="006400",this.halogenColor="F0F",this.halogenInsideColor="FFF",this.picationColor="F00",this.picationInsideColor="FFF",this.pistackingColor="00F",this.pistackingInsideColor="FFF",this.hideedges=1,this.force=4,this.simulation=void 0,this.baseUrl=window&&window.location&&"structure.ncbi.nlm.nih.gov"==window.location.hostname?"https://structure.ncbi.nlm.nih.gov/Structure/":"https://www.ncbi.nlm.nih.gov/Structure/",this.divStr="
    ",this.spanNowrapStr="",this.inputTextStr="=2.0 are supported.")));const a=new pe(o,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});a.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===r[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}a.setExtensions(l),a.setPlugins(r),a.parse(s,i)}parseAsync(e,t){const s=this;return new Promise((function(i,n){s.parse(e,t,i,n)}))}}function b(){let e={};return{get:function(t){return e[t]},add:function(t,s){e[t]=s},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const C={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class y{constructor(e){this.parser=e,this.name=C.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,i=t.length;s=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,n.source,l)}}class R{constructor(e){this.parser=e,this.name=C.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,i=s.json,n=i.textures[e];if(!n.extensions||!n.extensions[t])return null;const l=n.extensions[t],r=i.images[l.source];let o=s.textureLoader;if(r.uri){const e=s.options.manager.getHandler(r.uri);null!==e&&(o=e)}return this.detectSupport().then((function(n){if(n)return s.loadTextureImage(e,l.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class E{constructor(e){this.name=C.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const e=s.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),n=this.parser.options.meshoptDecoder;if(!n||!n.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([i,n.ready]).then((function(t){const s=e.byteOffset||0,i=e.byteLength||0,l=e.count,r=e.byteStride,o=new ArrayBuffer(l*r),a=new Uint8Array(t[0],s,i);return n.decodeGltfBuffer(new Uint8Array(o),l,r,a,e.mode,e.filter),o}))}return null}}const I="glTF",T=1313821514,M=5130562;class P{constructor(e){this.name=C.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:THREE.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==I)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-12,i=new DataView(e,12);let n=0;for(;n",t).replace("#include ",s).replace("#include ",i).replace("#include ",n).replace("#include ",l)},Object.defineProperties(this,{specular:{get:function(){return r.specular.value},set:function(e){r.specular.value=e}},specularMap:{get:function(){return r.specularMap.value},set:function(e){r.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return r.glossiness.value},set:function(e){r.glossiness.value=e}},glossinessMap:{get:function(){return r.glossinessMap.value},set:function(e){r.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class L{constructor(){this.name=C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity"]}getMaterialType(){return F}extendParams(e,t,s){const i=t.extensions[this.name];e.color=new Color(1,1,1),e.opacity=1;const n=[];if(Array.isArray(i.diffuseFactor)){const t=i.diffuseFactor;e.color.fromArray(t),e.opacity=t[3]}if(void 0!==i.diffuseTexture&&n.push(s.assignTexture(e,"map",i.diffuseTexture,sRGBEncoding)),e.emissive=new Color(0,0,0),e.glossiness=void 0!==i.glossinessFactor?i.glossinessFactor:1,e.specular=new Color(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),void 0!==i.specularGlossinessTexture){const t=i.specularGlossinessTexture;n.push(s.assignTexture(e,"glossinessMap",t)),n.push(s.assignTexture(e,"specularMap",t,sRGBEncoding))}return Promise.all(n)}createMaterial(e){const t=new F(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=TangentSpaceNormalMap,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t}}class N{constructor(){this.name=C.KHR_MESH_QUANTIZATION}}class U extends THREE.Interpolant{constructor(e,t,s,i){super(e,t,s,i)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,i=this.valueSize,n=e*i*3+i;for(let e=0;e!==i;e++)t[e]=s[n+e];return t}}U.prototype.beforeStart_=U.prototype.copySampleValue_,U.prototype.afterEnd_=U.prototype.copySampleValue_,U.prototype.interpolate_=function(e,t,s,i){const n=this.resultBuffer,l=this.sampleValues,r=this.valueSize,o=2*r,a=3*r,d=i-t,c=(s-t)/d,h=c*c,p=h*c,m=e*a,u=m-a,g=-2*p+3*h,f=p-h,b=1-g,C=f-h+c;for(let e=0;e!==r;e++){const t=l[u+e+r],s=l[u+e+o]*d,i=l[m+e+r],a=l[m+e]*d;n[e]=b*t+C*s+g*i+f*a}return n};const q=new THREE.Quaternion;class j extends U{interpolate_(e,t,s,i){const n=super.interpolate_(e,t,s,i);return q.fromArray(n).normalize().toArray(n),n}}const B=0,z=1,G=2,V=3,W=4,Y=5,X=6,K={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Q={9728:THREE.NearestFilter,9729:THREE.LinearFilter,9984:THREE.NearestMipmapNearestFilter,9985:THREE.LinearMipmapNearestFilter,9986:THREE.NearestMipmapLinearFilter,9987:THREE.LinearMipmapLinearFilter},J={33071:THREE.ClampToEdgeWrapping,33648:THREE.MirroredRepeatWrapping,10497:THREE.RepeatWrapping},Z={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ee={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},te={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},se={CUBICSPLINE:void 0,LINEAR:THREE.InterpolateLinear,STEP:THREE.InterpolateDiscrete},ie="OPAQUE",ne="MASK",le="BLEND";function re(e,t,s){for(const i in s.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=s.extensions[i])}function oe(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function ae(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let s=0,i=t.weights.length;s{const s=this.associations.get(e);null!=s&&this.associations.set(t,s);for(const[s,i]of e.children.entries())n(i,t.children[s])};return n(s,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s=2&&m.setY(t,c[e*l+1]),l>=3&&m.setZ(t,c[e*l+2]),l>=4&&m.setW(t,c[e*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m}))}loadTexture(e){const t=this.json,s=this.options,i=t.textures[e].source,n=t.images[i];let l=this.textureLoader;if(n.uri){const e=s.manager.getHandler(n.uri);null!==e&&(l=e)}return this.loadTextureImage(e,i,l)}loadTextureImage(e,t,s){const i=this,n=this.json,l=n.textures[e],r=n.images[t],o=(r.uri||r.bufferView)+":"+l.sampler;if(this.textureCache[o])return this.textureCache[o];const a=this.loadImageSource(t,s).then((function(t){t.flipY=!1,l.name&&(t.name=l.name);const s=(n.samplers||{})[l.sampler]||{};return t.magFilter=Q[s.magFilter]||LinearFilter,t.minFilter=Q[s.minFilter]||LinearMipmapLinearFilter,t.wrapS=J[s.wrapS]||RepeatWrapping,t.wrapT=J[s.wrapT]||RepeatWrapping,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=a,a}loadImageSource(e,t){const s=this,i=this.json,n=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const l=i.images[e],r=self.URL||self.webkitURL;let o=l.uri||"",a=!1;if(void 0!==l.bufferView)o=s.getDependency("bufferView",l.bufferView).then((function(e){a=!0;const t=new Blob([e],{type:l.mimeType});return o=r.createObjectURL(t),o}));else if(void 0===l.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(o).then((function(e){return new Promise((function(s,i){let l=s;!0===t.isImageBitmapLoader&&(l=function(e){const t=new Texture(e);t.needsUpdate=!0,s(t)}),t.load(THREE.LoaderUtils.resolveURL(e,n.path),l,void 0,i)}))})).then((function(e){var t;return!0===a&&r.revokeObjectURL(o),e.userData.mimeType=l.mimeType||((t=l.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),e}));return this.sourceCache[e]=d,d}assignTexture(e,t,s,i){const n=this;return this.getDependency("texture",s.index).then((function(l){if(void 0===s.texCoord||0==s.texCoord||"aoMap"===t&&1==s.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+s.texCoord+" for texture "+t+" not yet supported."),n.extensions[C.KHR_TEXTURE_TRANSFORM]){const e=void 0!==s.extensions?s.extensions[C.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=n.associations.get(l);l=n.extensions[C.KHR_TEXTURE_TRANSFORM].extendTexture(l,e),n.associations.set(l,t)}}return void 0!==i&&(l.encoding=i),e[t]=l,l}))}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const i=void 0===t.attributes.tangent,n=void 0!==t.attributes.color,l=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new PointsMaterial,Material.prototype.copy.call(t,s),t.color.copy(s.color),t.map=s.map,t.sizeAttenuation=!1,this.cache.add(e,t)),s=t}else if(e.isLine){const e="LineBasicMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new LineBasicMaterial,Material.prototype.copy.call(t,s),t.color.copy(s.color),this.cache.add(e,t)),s=t}if(i||n||l){let e="ClonedMaterial:"+s.uuid+":";s.isGLTFSpecularGlossinessMaterial&&(e+="specular-glossiness:"),i&&(e+="derivative-tangents:"),n&&(e+="vertex-colors:"),l&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=s.clone(),n&&(t.vertexColors=!0),l&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(s))),s=t}s.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),e.material=s}getMaterialType(){return MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,i=this.extensions,n=s.materials[e];let l;const r={},o=n.extensions||{},a=[];if(o[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=i[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];l=e.getMaterialType(),a.push(e.extendParams(r,n,t))}else if(o[C.KHR_MATERIALS_UNLIT]){const e=i[C.KHR_MATERIALS_UNLIT];l=e.getMaterialType(),a.push(e.extendParams(r,n,t))}else{const s=n.pbrMetallicRoughness||{};if(r.color=new Color(1,1,1),r.opacity=1,Array.isArray(s.baseColorFactor)){const e=s.baseColorFactor;r.color.fromArray(e),r.opacity=e[3]}void 0!==s.baseColorTexture&&a.push(t.assignTexture(r,"map",s.baseColorTexture,sRGBEncoding)),r.metalness=void 0!==s.metallicFactor?s.metallicFactor:1,r.roughness=void 0!==s.roughnessFactor?s.roughnessFactor:1,void 0!==s.metallicRoughnessTexture&&(a.push(t.assignTexture(r,"metalnessMap",s.metallicRoughnessTexture)),a.push(t.assignTexture(r,"roughnessMap",s.metallicRoughnessTexture))),l=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),a.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,r)}))))}!0===n.doubleSided&&(r.side=DoubleSide);const d=n.alphaMode||ie;if(d===le?(r.transparent=!0,r.depthWrite=!1):(r.transparent=!1,d===ne&&(r.alphaTest=void 0!==n.alphaCutoff?n.alphaCutoff:.5)),void 0!==n.normalTexture&&l!==MeshBasicMaterial&&(a.push(t.assignTexture(r,"normalMap",n.normalTexture)),r.normalScale=new Vector2(1,1),void 0!==n.normalTexture.scale)){const e=n.normalTexture.scale;r.normalScale.set(e,e)}return void 0!==n.occlusionTexture&&l!==MeshBasicMaterial&&(a.push(t.assignTexture(r,"aoMap",n.occlusionTexture)),void 0!==n.occlusionTexture.strength&&(r.aoMapIntensity=n.occlusionTexture.strength)),void 0!==n.emissiveFactor&&l!==MeshBasicMaterial&&(r.emissive=(new Color).fromArray(n.emissiveFactor)),void 0!==n.emissiveTexture&&l!==MeshBasicMaterial&&a.push(t.assignTexture(r,"emissiveMap",n.emissiveTexture,sRGBEncoding)),Promise.all(a).then((function(){let s;return s=l===F?i[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(r):new l(r),n.name&&(s.name=n.name),oe(s,n),t.associations.set(s,{materials:e}),n.extensions&&re(i,s,n),s}))}createUniqueName(e){const t=PropertyBinding.sanitizeNodeName(e||"");let s=t;for(let e=1;this.nodeNamesUsed[s];++e)s=t+"_"+e;return this.nodeNamesUsed[s]=!0,s}loadGeometries(e){const t=this,s=this.extensions,i=this.primitiveCache;function n(e){return s[C.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(s){return ue(s,e,t)}))}const l=[];for(let s=0,r=e.length;s0&&ae(h,n),h.name=t.createUniqueName(n.name||"mesh_"+e),oe(h,n),c.extensions&&re(i,h,c),t.assignFinalMaterial(h),a.push(h)}for(let s=0,i=a.length;s1?new Group:1===t.length?t[0]:new Object3D,r!==t[0])for(let e=0,s=t.length;e{const t=new Map;for(const[e,s]of n.associations)(e instanceof Material||e instanceof Texture)&&t.set(e,s);return e.traverse((e=>{const s=n.associations.get(e);null!=s&&t.set(e,s)})),t})(l),l}))}}function me(e,t,s,i){const n=s.nodes[e];return i.getDependency("node",e).then((function(e){if(void 0===n.skin)return e;let t;return i.getDependency("skin",n.skin).then((function(e){t=e;const s=[];for(let e=0,n=t.joints.length;e{const s=n[e];return s&&(l={profileId:e,profilePath:`${t}/${s.path}`,deprecated:!!s.deprecated}),!!l})),!l){if(!s)throw new Error("No matching profile name found");const e=n[s];if(!e)throw new Error(`No matching profile name found and default profile "${s}" missing.`);l={profileId:s,profilePath:`${t}/${e.path}`,deprecated:!!e.deprecated}}const r=await be(l.profilePath);let o;if(i){let t;if(t="any"===e.handedness?r.layouts[Object.keys(r.layouts)[0]]:r.layouts[e.handedness],!t)throw new Error(`No matching handedness, ${e.handedness}, in profile ${l.profileId}`);t.assetPath&&(o=l.profilePath.replace("profile.json",t.assetPath))}return{profile:r,assetPath:o}}const ye={xAxis:0,yAxis:0,button:0,state:fe.ComponentState.DEFAULT};class ve{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===fe.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(ye)}updateFromComponent({xAxis:e,yAxis:t,button:s,state:i}){const{normalizedXAxis:n,normalizedYAxis:l}=function(e=0,t=0){let s=e,i=t;if(Math.sqrt(e*e+t*t)>1){const n=Math.atan2(t,e);s=Math.cos(n),i=Math.sin(n)}return{normalizedXAxis:.5*s+.5,normalizedYAxis:.5*i+.5}}(e,t);switch(this.componentProperty){case fe.ComponentProperty.X_AXIS:this.value=this.states.includes(i)?n:.5;break;case fe.ComponentProperty.Y_AXIS:this.value=this.states.includes(i)?l:.5;break;case fe.ComponentProperty.BUTTON:this.value=this.states.includes(i)?s:0;break;case fe.ComponentProperty.STATE:this.valueNodeProperty===fe.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(i):this.value=this.states.includes(i)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}}class we{constructor(e,t){if(!(e&&t&&t.visualResponses&&t.gamepadIndices&&0!==Object.keys(t.gamepadIndices).length))throw new Error("Invalid arguments supplied");this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach((e=>{const s=new ve(t.visualResponses[e]);this.visualResponses[e]=s})),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:fe.ComponentState.DEFAULT,button:void 0!==this.gamepadIndices.button?0:void 0,xAxis:void 0!==this.gamepadIndices.xAxis?0:void 0,yAxis:void 0!==this.gamepadIndices.yAxis?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(e){if(this.values.state=fe.ComponentState.DEFAULT,void 0!==this.gamepadIndices.button&&e.buttons.length>this.gamepadIndices.button){const t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||1===this.values.button?this.values.state=fe.ComponentState.PRESSED:(t.touched||this.values.button>fe.ButtonTouchThreshold)&&(this.values.state=fe.ComponentState.TOUCHED)}void 0!==this.gamepadIndices.xAxis&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===fe.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>fe.AxisTouchThreshold&&(this.values.state=fe.ComponentState.TOUCHED)),void 0!==this.gamepadIndices.yAxis&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===fe.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>fe.AxisTouchThreshold&&(this.values.state=fe.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach((e=>{e.updateFromComponent(this.values)}))}}class _e{constructor(e,t,s){if(!e)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No profile supplied");this.xrInputSource=e,this.assetUrl=s,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach((e=>{const t=this.layoutDescription.components[e];this.components[e]=new we(e,t)})),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const e=[];return Object.values(this.components).forEach((t=>{e.push(t.data)})),e}updateFromGamepad(){Object.values(this.components).forEach((e=>{e.updateFromGamepad(this.xrInputSource.gamepad)}))}}class Se extends THREE.Object3D{constructor(){super(),this.motionController=null,this.envMap=null}setEnvironmentMap(e){return this.envMap==e||(this.envMap=e,this.traverse((e=>{e.isMesh&&(e.material.envMap=this.envMap,e.material.needsUpdate=!0)}))),this}updateMatrixWorld(e){super.updateMatrixWorld(e),this.motionController&&(this.motionController.updateFromGamepad(),Object.values(this.motionController.components).forEach((e=>{Object.values(e.visualResponses).forEach((e=>{const{valueNode:t,minNode:s,maxNode:i,value:n,valueNodeProperty:l}=e;t&&(l===fe.VisualResponseProperty.VISIBILITY?t.visible=n:l===fe.VisualResponseProperty.TRANSFORM&&(t.quaternion.slerpQuaternions(s.quaternion,i.quaternion,n),t.position.lerpVectors(s.position,i.position,n)))}))})))}}function Ae(e,t){!function(e,t){Object.values(e.components).forEach((e=>{const{type:s,touchPointNodeName:i,visualResponses:n}=e;if(s===fe.ComponentType.TOUCHPAD)if(e.touchPointNode=t.getObjectByName(i),e.touchPointNode){const t=new SphereGeometry(.001),s=new MeshBasicMaterial({color:255}),i=new Mesh(t,s);e.touchPointNode.add(i)}else console.warn(`Could not find touch dot, ${e.touchPointNodeName}, in touchpad component ${e.id}`);Object.values(n).forEach((e=>{const{valueNodeName:s,minNodeName:i,maxNodeName:n,valueNodeProperty:l}=e;if(l===fe.VisualResponseProperty.TRANSFORM){if(e.minNode=t.getObjectByName(i),e.maxNode=t.getObjectByName(n),!e.minNode)return void console.warn(`Could not find ${i} in the model`);if(!e.maxNode)return void console.warn(`Could not find ${n} in the model`)}e.valueNode=t.getObjectByName(s),e.valueNode||console.warn(`Could not find ${s} in the model`)}))}))}(e.motionController,t),e.envMap&&t.traverse((t=>{t.isMesh&&(t.material.envMap=e.envMap,t.material.needsUpdate=!0)})),e.add(t)}class xe{constructor(e=null){this.gltfLoader=e,this.path="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",this._assetCache={},this.gltfLoader||(this.gltfLoader=new f)}createControllerModel(e){const t=new Se;let s=null;return e.addEventListener("connected",(e=>{const i=e.data;"tracked-pointer"===i.targetRayMode&&i.gamepad&&Ce(i,this.path,"generic-trigger").then((({profile:e,assetPath:n})=>{t.motionController=new _e(i,e,n);const l=this._assetCache[t.motionController.assetUrl];if(l)s=l.scene.clone(),Ae(t,s);else{if(!this.gltfLoader)throw new Error("GLTFLoader not set.");this.gltfLoader.setPath(""),this.gltfLoader.load(t.motionController.assetUrl,(e=>{this._assetCache[t.motionController.assetUrl]=e,s=e.scene.clone(),Ae(t,s)}),null,(()=>{throw new Error(`Asset ${t.motionController.assetUrl} missing or malformed.`)}))}})).catch((e=>{console.warn(e)}))})),e.addEventListener("disconnected",(()=>{t.motionController=null,t.remove(s),s=null})),t}}class ke extends THREE.EventDispatcher{constructor(e){if(super(),void 0===e)return void console.error("ControllerGestures must be passed a renderer");const t=new THREE.Clock;this.controller1=e.xr.getController(0),this.controller1.userData.gestures={index:0},this.controller1.userData.selectPressed=!1,this.controller1.addEventListener("selectstart",i),this.controller1.addEventListener("selectend",n),this.controller2=e.xr.getController(1),this.controller2.userData.gestures={index:1},this.controller2.userData.selectPressed=!1,this.controller2.addEventListener("selectstart",i),this.controller2.addEventListener("selectend",n),this.doubleClickLimit=.2,this.pressMinimum=.4,this.right=new THREE.Vector3(1,0,0),this.up=new THREE.Vector3(0,1,0),this.type="unknown",this.prevTap="none",this.clock=t;const s=this;function i(){const e=this.userData.gestures;e.startPosition=void 0,e.startTime=t.getElapsedTime(),-1==s.type.indexOf("tap")&&(e.taps=0),s.type="unknown",this.userData.selectPressed=!0}function n(){const e=this.userData.gestures;e.endTime=t.getElapsedTime();e.endTime-e.startTime.05&&(e.startPosition=this.controller1.position.clone())),this.controller2.userData.selectPressed&&void 0===t.startPosition&&(i=s-t.startTime,i>.05&&(t.startPosition=this.controller2.position.clone())),!this.controller1.userData.selectPressed&&"tap"===this.type&&(i=this.clock.getElapsedTime()-e.endTime,i>this.doubleClickLimit)){switch(e.taps){case 1:self.prevTap="tap";break;case 2:this.dispatchEvent({type:"doubletap",position:this.controller1.position,matrixWorld:this.controller1.matrixWorld}),self.prevTap="doubletap"}this.type="unknown",e.taps=0}if("unknown"===this.type&&this.touch)"doubletap"==self.prevTap?(this.type="pinch",this.startDistance=this.controller1.position.distanceTo(this.controller2.position),this.dispatchEvent({type:"pinch",delta:new THREE.Vector3(0,0,0),scale:1,initialise:!0})):(this.type="pan",this.startPosition=this.controller1.position.clone(),this.dispatchEvent({type:"pan",delta:new THREE.Vector3(0,0,0),initialise:!0}));else if(("pinch"===this.type||"pan"===this.type)&&"doubletap"==self.prevTap&&this.controller2.position){const e=this.controller1.position.distanceTo(this.controller2.position)/this.startDistance,t=this.controller1.position.clone().sub(this.startPosition);this.dispatchEvent({type:"pinch",delta:t,scale:e})}}}class Oe{constructor(e,t){this.config=void 0===t?{panelSize:{width:1,height:1},width:512,height:512,opacity:.7,body:{fontFamily:"Arial",fontSize:30,padding:20,backgroundColor:"#000",fontColor:"#fff",borderRadius:6}}:t,void 0===this.config.width&&(this.config.width=512),void 0===this.config.height&&(this.config.height=512),void 0===this.config.body&&(this.config.body={fontFamily:"Arial",size:30,padding:20,backgroundColor:"#000",fontColor:"#fff",borderRadius:6});const s=this.config.body;void 0===s.borderRadius&&(s.borderRadius=6),void 0===s.fontFamily&&(s.fontFamily="Arial"),void 0===s.padding&&(s.padding=20),void 0===s.fontSize&&(s.fontSize=30),void 0===s.backgroundColor&&(s.backgroundColor="#000"),void 0===s.fontColor&&(s.fontColor="#fff"),Object.entries(this.config).forEach((([e,t])=>{if(!("object"!=typeof t||"panelSize"===e||t instanceof THREE.WebGLRenderer||t instanceof THREE.Scene)){const e=void 0!==t.position?t.position:{x:0,y:0};void 0!==e.left&&void 0===e.x&&(e.x=e.left),void 0!==e.top&&void 0===e.y&&(e.y=e.top);const s=void 0!==t.width?t.width:this.config.width,i=void 0!==t.height?t.height:this.config.height;void 0!==e.right&&void 0===e.x&&(e.x=this.config.width-e.right-s),void 0!==e.bottom&&void 0===e.y&&(e.y=this.config.height-e.bottom-i),void 0===e.x&&(e.x=0),void 0===e.y&&(e.y=0),t.position=e,void 0===t.type&&(t.type="text")}}));const i=this.createOffscreenCanvas(this.config.width,this.config.height);this.context=i.getContext("2d"),this.context.save();const n=void 0!==this.config.opacity?this.config.opacity:.7,l=new THREE.MeshBasicMaterial({transparent:!0,opacity:n});this.panelSize=void 0!==this.config.panelSize?this.config.panelSize:{width:1,height:1};const r=new THREE.PlaneGeometry(this.panelSize.width,this.panelSize.height);this.mesh=new THREE.Mesh(r,l),this.texture=new THREE.CanvasTexture(i),this.mesh.material.map=this.texture,this.scene=this.config.scene;if(Object.values(this.config).filter((e=>"input-text"===e.type)).length>0){this.keyboard=new Re(this.panelSize.width,this.config.renderer);this.keyboard.mesh.position.set(0,-.3,.2),this.mesh.add(this.keyboard.mesh)}if(void 0===e)this.content={body:""},this.config.body.type="text";else{this.content=e;Object.values(t).filter((e=>"button"===e.type||"scroll"===e.overflow||"input-text"===e.type)).length>0&&(void 0===t||void 0===t.renderer?console.warn("CanvasUI: button, scroll or input-text in the config but no renderer"):(this.renderer=t.renderer,this.initControllers()))}this.selectedElements=[void 0,void 0],this.selectPressed=[!1,!1],this.scrollData=[void 0,void 0],this.intersects=[void 0,void 0],this.needsUpdate=!0,this.update()}getIntersectY(e){const t=this.config.height||512,s=this.intersects[e];return void 0===s||void 0===s.uv?0:(1-s.uv.y)*t}initControllers(){this.vec3=new THREE.Vector3,this.mat4=new THREE.Matrix4,this.raycaster=new THREE.Raycaster;const e=this;function t(t){const s=t.target===e.controller?0:1,i=e.selectedElements[s];if(void 0!==i)if("button"==i.type)e.select(s);else if("input-text"==i.type&&e.keyboard)if(e.keyboard.visible)e.keyboard.linkedUI=void 0,e.keyboard.linkedText=void 0,e.keyboard.linkedElement=void 0,e.keyboard.visible=!1;else{let t;e.keyboard.linkedUI=e,Object.entries(e.config).forEach((([e,s])=>{s==i&&(t=e)}));const s=(.5-(i.position.y+i.height+e.config.body.padding)/e.config.height)*e.panelSize.height,n=Math.max(e.panelSize.width,e.panelSize.height)/2;e.keyboard.position.set(0,-n/1.5-s,.1),e.keyboard.linkedText=e.content[t],e.keyboard.linkedName=t,e.keyboard.linkedElement=i,e.keyboard.visible=!0}}function s(t){const s=t.target===e.controller?0:1;if(e.selectPressed[s]=!0,void 0!==e.selectedElements[s]&&"scroll"==e.selectedElements[s].overflow){const t=e.selectedElements[s];e.scrollData[s]={scrollY:t.scrollY,rayY:e.getIntersectY(s)}}}function i(t){const s=t.target===e.controller?0:1;e.selectPressed[s]=!1,void 0!==e.selectedElements[s]&&"scroll"==e.selectedElements[s].overflow&&(e.scrollData[s]=void 0)}if(this.controller=this.renderer.xr.getController(0),this.controller.addEventListener("select",t),this.controller.addEventListener("selectstart",s),this.controller.addEventListener("selectend",i),this.controller1=this.renderer.xr.getController(1),this.controller1.addEventListener("select",t),this.controller1.addEventListener("selectstart",s),this.controller1.addEventListener("selectend",i),this.scene){const e=.015,t=new THREE.IcosahedronBufferGeometry(e),s=new THREE.MeshBasicMaterial({color:170}),i=new THREE.Mesh(t,s);i.visible=!1,this.scene.add(i);const n=new THREE.Mesh(t,s);n.visible=!1,this.scene.add(n),this.intersectMesh=[i,n]}}setClip(e){const t=this.context;if(t.restore(),t.save(),void 0!==e.clipPath){const s=new Path2D(e.clipPath);t.clip(s)}else{const s=void 0!==e.position?e.position:{x:0,y:0},i=e.borderRadius||0,n=e.width||this.config.width,l=e.height||this.config.height;if(t.beginPath(),0!==i){const e=Math.PI/2;t.moveTo(s.x+i,s.y),t.arc(s.x+i,s.y+i,i,e,2*e,!0),t.lineTo(s.x,s.y+l-i),t.arc(s.x+i,s.y+l-i,i,0,e,!0),t.lineTo(s.x+n-i,s.y+l),t.arc(s.x+n-i,s.y+l-i,i,3*e,4*e,!0),t.lineTo(s.x+n,s.y+i),t.arc(s.x+n-i,s.y+i,i,2*e,3*e,!0),t.closePath(),t.clip()}else t.rect(s.x,s.y,n,l),t.clip()}}setPosition(e,t,s){void 0!==this.mesh&&this.mesh.position.set(e,t,s)}setRotation(e,t,s){void 0!==this.mesh&&this.mesh.rotation.set(e,t,s)}updateElement(e,t){let s=this.content[e];void 0!==s?("object"==typeof s?s.content=t:s=t,this.content[e]=s,this.needsUpdate=!0):console.warn(`CanvasGUI.updateElement: No ${e} found`)}get panel(){return this.mesh}getElementAtLocation(e,t){const s=this,i=Object.entries(this.config).filter((([i,n])=>{if(!("object"!=typeof n||"panelSize"===i||"body"===i||n instanceof THREE.WebGLRenderer||n instanceof THREE.Scene)){const i=n.position,l=void 0!==n.width?n.width:s.config.width,r=void 0!==n.height?n.height:s.config.height;return e>=i.x&&e=i.y&&t0?(this.hover(t,s[0].uv),this.intersects[t]=s[0],this.scroll(t)):(this.hover(t),this.intersects[t]=void 0,this.scroll(t))}update(){if(void 0===this.mesh)return;if(this.controller&&this.handleController(this.controller,0),this.controller1&&this.handleController(this.controller1,1),this.keyboard&&this.keyboard.visible&&this.keyboard.update(),!this.needsUpdate)return;let e=this.context;e.clearRect(0,0,this.config.width,this.config.height);const t=this.config.body.backgroundColor?this.config.body.backgroundColor:"#000";!this.config.body.fontFamily||this.config.body.fontFamily;const s=this.config.body.fontColor?this.config.body.fontColor:"#fff";!this.config.body.fontSize||this.config.body.fontSize,this.setClip(this.config.body),e.fillStyle=t,e.fillRect(0,0,this.config.width,this.config.height);const i=this;Object.entries(this.content).forEach((([t,n])=>{const l=void 0!==i.config[t]?i.config[t]:i.config.body;if("none"!==(void 0!==l.display?l.display:"block")){const r=void 0!==l.position?l.position:{x:0,y:0},o=void 0!==l.width?l.width:i.config.width,a=void 0!==l.height?l.height:i.config.height;"button"!=l.type||n.toLowerCase().startsWith("")||(void 0===l.borderRadius&&(l.borderRadius=6),void 0===l.textAlign&&(l.textAlign="center")),i.setClip(l);const d=n.toLowerCase().startsWith(""),c=void 0!==i.selectedElements[0]&&this.selectedElements[0]===l||void 0!==i.selectedElements[1]&&this.selectedElements[1]===l;if(void 0!==l.backgroundColor&&(c&&"button"==l.type&&void 0!==l.hover?e.fillStyle=l.hover:e.fillStyle=l.backgroundColor,e.fillRect(r.x,r.y,o,a)),"text"==l.type||"button"==l.type||"input-text"==l.type){let h=!1;if(c?(d||"button"!=l.type?e.fillStyle=void 0!==l.hover?l.hover:void 0!==l.fontColor?l.fontColor:s:e.fillStyle=void 0!==l.fontColor?l.fontColor:s,h=void 0===l.hover):e.fillStyle=void 0!==l.fontColor?l.fontColor:s,d){const t=n.toUpperCase().substring(6,n.length-7);e.save(),e.translate(r.x,r.y);const s=new Path2D(t);e.fill(s),e.restore()}else i.wrapText(t,n);h&&(e.beginPath(),e.strokeStyle="#fff",e.lineWidth=2,e.rect(r.x,r.y,o,a),e.stroke())}else if("img"==l.type)if(void 0===l.img)this.loadImage(n).then((e=>{console.log(`w: ${e.width} | h: ${e.height}`),l.img=e,i.needsUpdate=!0,i.update()})).catch((e=>console.error(e)));else{const t=o/(l.img.width/l.img.height);e.drawImage(l.img,r.x,r.y,o,t)}}})),this.needsUpdate=!1,this.texture.needsUpdate=!0}loadImage(e){return new Promise(((t,s)=>{const i=new THREE.Image;i.addEventListener("load",(()=>t(i))),i.addEventListener("error",(e=>s(e))),i.src=e}))}createOffscreenCanvas(e,t){const s=document.createElement("canvas");return s.width=e,s.height=t,s}fillRoundedRect(e,t,s,i,n){const l=this.context;l.beginPath(),l.moveTo(e+n,t),l.lineTo(e+s-n,t),l.quadraticCurveTo(e+s,t,e+s,t+n),l.lineTo(e+s,t+i-n),l.quadraticCurveTo(e+s,t+i,e+s-n,t+i),l.lineTo(e+n,t+i),l.quadraticCurveTo(e,t+i,e,t+i-n),l.lineTo(e,t+n),l.quadraticCurveTo(e,t,e+n,t),l.closePath(),l.fill()}lookAt(e){void 0!==this.mesh&&(e instanceof Vector3?this.mesh.lookAt(e):console.error("CanvasUI lookAt called parameter not a THREE.Vector3"))}get visible(){return void 0!==this.mesh&&this.mesh.visible}set visible(e){this.mesh&&(this.mesh.visible=e)}get position(){if(void 0!==this.mesh)return this.mesh.position}set position(e){void 0!==this.mesh&&(e instanceof Vector3?this.mesh.position.copy(e):console.error("CanvasUI trying to set the mesh position using a parameter that is not a THREE.Vector3"))}get quaternion(){if(void 0!==this.mesh)return this.mesh.quaternion}set quaternion(e){void 0!==this.mesh&&(e instanceof QUaternion?this.mesh.quaternion.copy(e):console.error("CanvasUI trying to set the mesh quaternion using a parameter that is not a THREE.Quaternion"))}wrapText(e,t){const s=t.split(" ");let i="";const n=[],l=void 0!==this.config[e]?this.config[e]:this.config.body,r=void 0!==l.width?l.width:this.config.width,o=void 0!==l.height?l.height:this.config.height,a=void 0!==l.position?l.position:{x:0,y:0},d=void 0!==l.padding?l.padding:void 0!==this.config.body.padding?this.config.body.padding:10,c=void 0!==l.paddingTop?l.paddingTop:d,h=void 0!==l.paddingLeft?l.paddingLeft:d,p=void 0!==l.paddingBottom?l.paddingBottom:d,m=void 0!==l.paddingRight?l.paddingRight:d,u={x:a.x+h,y:a.y+c,width:r-h-m,height:o-c-p},g=void 0!==l.textAlign?l.textAlign:void 0!==this.config.body.textAlign?this.config.body.textAlign:"left",f=void 0!==l.fontSize?l.fontSize:void 0!==this.config.body.fontSize?this.config.body.fontSize:30,b=void 0!==l.fontFamily?l.fontFamily:void 0!==this.config.body.fontFamily?this.config.body.fontFamily:"Arial",C=f+(void 0!==l.leading?l.leading:void 0!==this.config.body.leading?this.config.body.leading:8),y=this.context;y.textAlign=g,y.font=`${f}px '${b}'`,s.forEach((function(e){let t=s.length>1?`${i}${e} `:e,l=y.measureText(t);if(l.width>u.width&&e.length>1)if(0==i.length&&l.width>u.width){for(;l.width>u.width;){let s=0;do{s++,t=e.substr(0,s),l=y.measureText(t)}while(l.widthu.height&&"scroll"===l.overflow){void 0===l.scrollY&&(l.scrollY=0);const e=void 0!==l.fontColor?l.fontColor:this.config.body.fontColor;y.fillStyle="#aaa",this.fillRoundedRect(a.x+r-12,a.y,12,o,6),y.fillStyle="#666";const t=u.height/v,s=t*o,i=-l.scrollY*t;this.fillRoundedRect(a.x+r-12,a.y+i,12,s,6),y.fillStyle=e,w=l.scrollY,l.minScrollY=u.height-v}let _,S=w+u.y+f/2;switch(g){case"center":_=u.x+u.width/2;break;case"right":_=u.x+u.width;break;default:_=u.x}n.forEach((e=>{S+C>0&&y.fillText(e,_,S),S+=C}))}}class Re{constructor(e,t,s="EN"){const i=this.getConfig(s);i.panelSize={width:e,height:.5*e},i.height=256,i.body={backgroundColor:"#555"},i.renderer=t;const n=this.getContent(s);this.keyboard=new Oe(n,i),this.keyboard.mesh.visible=!1,this.shift=!1}get mesh(){return this.keyboard.mesh}getConfig(e){const t={};let s=10;const i=39.2,n=49,l="#333",r="#000";let o=s,a=s;for(let e=0;e<10;e++){const d={type:"button",position:{x:a,y:o},width:i,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e)};t[`btn${e}`]=d,a+=49.2}o+=59,a=s;for(let e=0;e<10;e++){const d={type:"button",position:{x:a,y:o},width:i,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+10)};t[`btn${e+10}`]=d,a+=49.2}o+=59,a=s;for(let e=0;e<9;e++){const d=0==e||8==e?1.5*i+5:i,c={type:"button",position:{x:a,y:o},width:d,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+20)};t[`btn${e+20}`]=c,a+=d+s}o+=59,a=s;for(let e=0;e<5;e++){const d=0==e||4==e?88.4:2==e?186.8:i,c={type:"button",position:{x:a,y:o},width:d,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+30)};0==e&&(c.fontSize=20),t[`btn${e+30}`]=c,a+=d+s}return t}getContent(e,t=0){let s,i={};switch(this.language=e,this.keyboardIndex=t,t){case 0:s=["q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","@","⇧","z","x","c","v","b","n","m","⇦","","?123",","," ",".","↲"];for(let e=0;e","_","`","~",":",";","⇦","","abc",","," ",".","↲"];for(let e=0;e=0;e--){let s=t.scene.children[e];t.scene.remove(s)}else t.scene=new THREE.Scene;if(void 0!==t.scene_ghost)for(let e=t.scene_ghost.children.length-1;e>=0;e--){let s=t.scene_ghost.children[e];t.scene_ghost.remove(s)}else t.scene_ghost=new THREE.Scene;if(""!=s.htmlCls.setHtmlCls.getCookie("shininess")){let e=parseFloat(s.htmlCls.setHtmlCls.getCookie("shininess"));t.shininess!=e&&s.htmlCls.clickMenuCls.setLogCmd("set shininess "+e,!0),t.shininess=e}if(!s.bNode&&""!=s.htmlCls.setHtmlCls.getCookie("light1")){let e=parseFloat(s.htmlCls.setHtmlCls.getCookie("light1")),i=parseFloat(s.htmlCls.setHtmlCls.getCookie("light2")),n=parseFloat(s.htmlCls.setHtmlCls.getCookie("light3"));t.light1==e&&t.light2==i&&t.light3==n||s.htmlCls.clickMenuCls.setLogCmd("set light | light1 "+e+" | light2 "+i+" | light3 "+n,!0),t.light1=e,t.light2=i,t.light3=n}t.directionalLight=new THREE.DirectionalLight(16777215,t.light1),t.directionalLight2=new THREE.DirectionalLight(16777215,t.light2),t.directionalLight3=new THREE.DirectionalLight(16777215,t.light3),t.cam_z>0?(t.directionalLight.position.set(-1,1,1),t.directionalLight2.position.set(1,1,1),t.directionalLight3.position.set(1,1,-1),t.lightPos=new THREE.Vector3(-1,1,1),t.lightPos2=new THREE.Vector3(1,1,1),t.lightPos3=new THREE.Vector3(1,1,-1)):(t.directionalLight.position.set(-1,1,-1),t.directionalLight2.position.set(1,1,-1),t.directionalLight3.position.set(1,1,1),t.lightPos=new THREE.Vector3(-1,1,-1),t.lightPos2=new THREE.Vector3(1,1,-1),t.lightPos3=new THREE.Vector3(1,1,1));let i=new THREE.AmbientLight(8947848);if(t.scene.add(t.directionalLight),t.scene.add(i),void 0!==t.mdl)for(let e=t.mdl.children.length-1;e>=0;e--){let s=t.mdl.children[e];s.geometry&&s.geometry.dispose(),s.material&&s.material.dispose(),t.mdl.remove(s)}if(void 0!==t.mdlImpostor){for(let e=t.mdlImpostor.children.length-1;e>=0;e--){let s=t.mdlImpostor.children[e];s.geometry&&s.geometry.dispose(),s.material&&s.material.dispose(),t.mdlImpostor.remove(s)}t.mdlImpostor.children.length=0}s.bNode||t.renderer.renderLists.dispose(),t.mdl=new THREE.Object3D,t.mdlImpostor=new THREE.Object3D,t.scene.add(t.mdl),t.scene.add(t.mdlImpostor),t.mdl_ghost=new THREE.Object3D,t.scene_ghost.add(t.mdl_ghost),t.objects=[],t.objects_ghost=[],t.raycaster=new THREE.Raycaster,t.projector=new THREE.Projector,t.mouse=new THREE.Vector2;let n=s.parasCls.backgroundColors[t.opts.background.toLowerCase()];s.bNode||("transparent"===t.opts.background.toLowerCase()?t.renderer.setClearColor(n,0):t.renderer.setClearColor(n,1)),t.perspectiveCamera=new THREE.PerspectiveCamera(20,t.container.whratio,.1,1e4),t.perspectiveCamera.position.set(0,0,t.cam_z),t.perspectiveCamera.lookAt(new THREE.Vector3(0,0,0)),t.orthographicCamera=new THREE.OrthographicCamera,t.orthographicCamera.position.set(0,0,t.cam_z),t.orthographicCamera.lookAt(new THREE.Vector3(0,0,0)),t.cams={perspective:t.perspectiveCamera,orthographic:t.orthographicCamera}}setVrAr(){let e=this.icn3d;e.icn3dui;let t=this;e.bSetVrAr=!0,e.bVr?(e.canvasUI=this.createUI(),e.raycasterVR=new THREE.Raycaster,e.workingMatrix=new THREE.Matrix4,e.workingVector=new THREE.Vector3,e.origin=new THREE.Vector3,e.dolly=new THREE.Object3D,e.dolly.position.z=5,e.dolly.add(e.cam),e.scene.add(e.dolly),e.dollyId=e.dolly.id,e.dummyCam=new THREE.Object3D,e.cam.add(e.dummyCam),e.clock=new THREE.Clock,e.controllers=this.getControllers(),e.controllers.forEach((s=>{s.addEventListener("connected",(function(e){try{const s={},i="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",n="generic-trigger";Ce(e.data,i,n).then((({profile:i,assetPath:n})=>{s.name=i.profileId,s.targetRayMode=e.data.targetRayMode,Object.entries(i.layouts).forEach((([e,t])=>{const i={};Object.values(t.components).forEach((e=>{i[e.rootNodeName]=e.gamepadIndices})),s[e]=i})),t.updateControllers(s)}))}catch(e){}})),s.addEventListener("disconnected",(function(){this.remove(this.children[0]),e.controllers.forEach((e=>{}))}))}))):e.bAr&&(e.gestures=new ke(e.renderer),e.scene.add(e.gestures.controller1),e.scene.add(e.gestures.controller2),e.gestures.addEventListener("doubletap",(e=>{t.positionCenter()})),e.gestures.addEventListener("pinch",(s=>{if(void 0!==s.initialise)t.startPosition=e.mdl.position.clone(),t.startScale=e.mdl.scale.clone();else{let i=1;const n=t.startScale.clone().multiplyScalar(s.scale*i);e.mdl.scale.copy(n)}})))}positionCenter(){let e=this.icn3d;e.icn3dui;const t=e.gestures.controller1;e.mdl.position.set(-.06,0,-.6).applyMatrix4(t.matrixWorld),e.mdl.scale.copy(new THREE.Vector3(.005,.005,.005))}setVrArButtons(){let e=this.icn3d,t=e.icn3dui;e.bSetVrArButtons=!0,t.bNode||($("#"+t.pre+"VRButton").remove(),$("#"+t.pre+"viewer").get(0).appendChild(e.VRButtonCls.createButton(e.renderer)),$("#"+t.pre+"ARButton").remove(),$("#"+t.pre+"viewer").get(0).appendChild(e.ARButtonCls.createButton(e.renderer)))}updateControllers(e){this.icn3d.icn3dui,this.addEventForController(e,"right"),this.addEventForController(e,"left")}addEventForController(e,t){let s=this.icn3d;s.icn3dui;const i="right"==t?s.renderer.xr.getController(0):s.renderer.xr.getController(1),n="right"==t?e.right:e.left;if(void 0!==n){let e=!1,t=!1;Object.keys(n).forEach((i=>{-1!=i.indexOf("trigger")&&(e=!0),-1!=i.indexOf("squeeze")&&(t=!0),-1==i.indexOf("thumbstick")&&-1==i.indexOf("touchpad")||(s.xAxisIndex=n[i].xAxis,s.yAxisIndex=n[i].yAxis)})),e&&(i.addEventListener("selectstart",(function(){this.userData.selectPressed=!0})),i.addEventListener("selectend",(function(){this.userData.selectPressed=!1,this.userData.selected=void 0}))),t&&(i.addEventListener("squeezestart",(function(){this.userData.squeezePressed=!0,s.cam.add(s.canvasUI.mesh)})),i.addEventListener("squeezeend",(function(){this.userData.squeezePressed=!1,s.cam.remove(s.canvasUI.mesh)})))}}createUI(){let e=this.icn3d;e.icn3dui;let t=94,s=50,i=44,n=12,l="#1c94c4",r="#ccc",o="#fbcb09";const a={panelSize:{width:2,height:1.2},height:300,select:{type:"button",position:{top:6,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},residue:{type:"button",position:{top:6,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.pk=2,e.cam.remove(e.canvasUI.mesh)}},secondarySelect:{type:"button",position:{top:6,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.pk=3,e.cam.remove(e.canvasUI.mesh)}},chainSelect:{type:"button",position:{top:6,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.pk=5,e.cam.remove(e.canvasUI.mesh)}},style:{type:"button",position:{top:62,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},ribbon:{type:"button",position:{top:62,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","ribbon"),e.setOptionCls.setStyle("nucleotides","nucleotide cartoon"),e.cam.remove(e.canvasUI.mesh)}},schematic:{type:"button",position:{top:62,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","schematic"),e.setOptionCls.setStyle("nucleotides","schematic"),e.cam.remove(e.canvasUI.mesh)}},stick:{type:"button",position:{top:62,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","stick"),e.setOptionCls.setStyle("nucleotides","stick"),e.cam.remove(e.canvasUI.mesh)}},sphere:{type:"button",position:{top:62,left:406},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","sphere"),e.setOptionCls.setStyle("nucleotides","sphere"),e.cam.remove(e.canvasUI.mesh)}},color:{type:"button",position:{top:118,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},rainbow:{type:"button",position:{top:118,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","rainbow for chains"),e.cam.remove(e.canvasUI.mesh)}},atomColor:{type:"button",position:{top:118,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","atom"),e.cam.remove(e.canvasUI.mesh)}},secondaryColor:{type:"button",position:{top:118,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","secondary structure green"),e.cam.remove(e.canvasUI.mesh)}},AlphaFold:{type:"button",position:{top:118,left:406},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","confidence"),e.cam.remove(e.canvasUI.mesh)}},unicolor:{type:"button",position:{top:174,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},red:{type:"button",position:{top:168,left:100},width:i,height:s,fontColor:"red",hover:o,onSelect:function(){e.setOptionCls.setOption("color","red"),e.cam.remove(e.canvasUI.mesh)}},green:{type:"button",position:{top:168,left:150},width:i,height:s,fontColor:"green",hover:o,onSelect:function(){e.setOptionCls.setOption("color","green"),e.cam.remove(e.canvasUI.mesh)}},blue:{type:"button",position:{top:168,left:200},width:i,height:s,fontColor:"blue",hover:o,onSelect:function(){e.setOptionCls.setOption("color","blue"),e.cam.remove(e.canvasUI.mesh)}},magenta:{type:"button",position:{top:168,left:250},width:i,height:s,fontColor:"magenta",hover:o,onSelect:function(){e.setOptionCls.setOption("color","magenta"),e.cam.remove(e.canvasUI.mesh)}},orange:{type:"button",position:{top:168,left:300},width:i,height:s,fontColor:"orange",hover:o,onSelect:function(){e.setOptionCls.setOption("color","FFA500"),e.cam.remove(e.canvasUI.mesh)}},cyan:{type:"button",position:{top:168,left:350},width:i,height:s,fontColor:"cyan",hover:o,onSelect:function(){e.setOptionCls.setOption("color","cyan"),e.cam.remove(e.canvasUI.mesh)}},gray:{type:"button",position:{top:168,left:400},width:i,height:s,fontColor:"gray",hover:o,onSelect:function(){e.setOptionCls.setOption("color","888888"),e.cam.remove(e.canvasUI.mesh)}},white:{type:"button",position:{top:168,left:450},width:i,height:s,fontColor:"white",hover:o,onSelect:function(){e.setOptionCls.setOption("color","white"),e.cam.remove(e.canvasUI.mesh)}},analysis:{type:"button",position:{top:230,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},interaction:{type:"button",position:{top:230,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){try{e.viewInterPairsCls.viewInteractionPairs(["selected"],["non-selected"],!1,"3d",1,1,1,1,1,1),e.cam.remove(e.canvasUI.mesh)}catch(e){}}},removeLabel:{type:"button",position:{top:230,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){for(let t in e.labels)e.labels[t]=[];e.drawCls.draw(),e.cam.remove(e.canvasUI.mesh)}},reset:{type:"button",position:{top:230,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.selectionCls.resetAll(),e.cam.remove(e.canvasUI.mesh)}},renderer:e.renderer},d=new Oe({select:"Select",residue:"Residue",secondarySelect:"SSE",chainSelect:"Chain",style:"Style",ribbon:"Ribbon",schematic:"Schem.",stick:"Stick",sphere:"Sphere",color:"Color",rainbow:"Rainbow",atomColor:"Atom",secondaryColor:"SSE",AlphaFold:"AlphaFold",unicolor:"UniColor",red:"M 50 15 L 15 15 L 15 50 L 50 50 Z",green:"M 50 15 L 15 15 L 15 50 L 50 50 Z",blue:"M 50 15 L 15 15 L 15 50 L 50 50 Z",magenta:"M 50 15 L 15 15 L 15 50 L 50 50 Z",orange:"M 50 15 L 15 15 L 15 50 L 50 50 Z",cyan:"M 50 15 L 15 15 L 15 50 L 50 50 Z",gray:"M 50 15 L 15 15 L 15 50 L 50 50 Z",white:"M 50 15 L 15 15 L 15 50 L 50 50 Z",analysis:"Analysis",interaction:"Interact",removeLabel:"No Label",reset:"Reset"},a);return d.mesh.position.set(0,0,-3),d}createUILog(){let e=this.icn3d;e.icn3dui;const t={panelSize:{width:2,height:2},height:512,info:{type:"text",overflow:"scroll",position:{top:6,left:6},width:506,height:506,backgroundColor:"#aaa",fontColor:"#000"},renderer:e.renderer},s=new Oe({info:"Debug info"},t);return s.mesh.position.set(0,-1,-2),s}getControllers(){let e=this.icn3d;e.icn3dui;const t=new xe,s=(new THREE.BufferGeometry).setFromPoints([new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,-1)]),i=new THREE.Line(s);i.name="line",i.scale.z=50;const n=[];for(let s=0;s<=1;s++){const l=e.renderer.xr.getController(s);e.dolly.add(l),l.add(i.clone()),l.userData.selectPressed=!1,e.cam.add(l),n.push(l);const r=e.renderer.xr.getControllerGrip(s);r.add(t.createControllerModel(r)),e.scene.add(r)}return n}}class Ie{constructor(e){this.icn3d=e}setCamera(){let e=this.icn3d,t=e.icn3dui;if(e.bControlGl&&!t.bNode){window.cam=e.cams[e.opts.camera.toLowerCase()];let s=e.maxD;if(window.cam===e.perspectiveCamera){let i=void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>e.maxatomcnt;i?window.camMaxDFactor=1:void 0!==window.camMaxDFactorFog?window.camMaxDFactor=window.camMaxDFactorFog:window.camMaxDFactor=3,window.cam_z>0?window.cam.position.z=s*window.camMaxDFactor:window.cam.position.z=-s*window.camMaxDFactor,"yes"===e.opts.slab?i?window.cam.near=.1:void 0!==window.camMaxDFactorFog?window.cam.near=s*window.camMaxDFactorFog-10:window.cam.near=s*window.camMaxDFactor:window.cam.near=.1,window.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.TrackballControls(window.cam,void 0,e):t.bNode?e.controls=new THREE.TrackballControls(e.cam,document,e):e.controls=new THREE.TrackballControls(e.cam,document.getElementById(e.id),e)}else window.cam===e.orthographicCamera&&(void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>10*e.maxatomcnt?window.cam.right=e.maxD/2*1.5:window.cam.right=e.maxD/2*2.5,window.cam.left=-window.cam.right,window.cam.top=window.cam.right/e.container.whratio,window.cam.bottom=-window.cam.right/e.container.whratio,"yes"===e.opts.slab?window.cam.near=2*e.maxD:window.cam.near=0,window.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.OrthographicTrackballControls(window.cam,void 0,e):t.bNode?e.controls=new THREE.OrthographicTrackballControls(e.cam,document,e):e.controls=new THREE.OrthographicTrackballControls(e.cam,document.getElementById(e.id),e));window.cam.updateProjectionMatrix()}e.cam=e.cams[e.opts.camera.toLowerCase()];let s=e.maxD;if(e.cam===e.perspectiveCamera){let i=void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>e.maxatomcnt;i?e.camMaxDFactor=1:void 0!==e.camMaxDFactorFog?e.camMaxDFactor=e.camMaxDFactorFog:e.camMaxDFactor=3,e.cam_z>0?e.cam.position.z=s*e.camMaxDFactor:e.cam.position.z=-s*e.camMaxDFactor,"yes"===e.opts.slab?i?e.cam.near=.1:void 0!==e.camMaxDFactorFog?e.cam.near=s*e.camMaxDFactorFog-10:e.cam.near=s*e.camMaxDFactor:e.cam.near=.1,e.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.TrackballControls(e.cam,void 0,e):t.bNode?e.controls=new THREE.TrackballControls(e.cam,document,e):e.controls=new THREE.TrackballControls(e.cam,document.getElementById(e.id),e)}else e.cam===e.orthographicCamera&&(void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>10*e.maxatomcnt?e.cam.right=e.maxD/2*1.5:e.cam.right=e.maxD/2*2.5,e.cam.left=-e.cam.right,e.cam.top=e.cam.right/e.container.whratio,e.cam.bottom=-e.cam.right/e.container.whratio,"yes"===e.opts.slab?e.cam.near=2*e.maxD:e.cam.near=0,e.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.OrthographicTrackballControls(e.cam,void 0,e):t.bNode?e.controls=new THREE.OrthographicTrackballControls(e.cam,document,e):e.controls=new THREE.OrthographicTrackballControls(e.cam,document.getElementById(e.id),e));e.cam.updateProjectionMatrix()}}class Te{constructor(e){this.icn3d=e}setFog(e){let t=this.icn3d,s=t.icn3dui.parasCls.backgroundColors[t.opts.background.toLowerCase()];if(e){let e=t.applyCenterCls.centerAtoms(t.hAtoms);t.maxD=e.maxD,t.maxD<25&&(t.maxD=25)}let i=void 0!==t.biomtMatrices&&t.biomtMatrices.length*t.cnt>t.maxatomcnt;if("yes"===t.opts.fog)if("perspective"===t.opts.camera)if(i)t.scene.fog=void 0,t.bSetFog=!1;else{let e=t._zoomFactor>1?1*t._zoomFactor:t._zoomFactor;t.scene.fog=new THREE.Fog(s,2.5*t.maxD*e,4*t.maxD*e),t.bSetFog=!0,t.camMaxDFactorFog=3}else"orthographic"===t.opts.camera&&(t.scene.fog=void 0,t.bSetFog=!1);else t.scene.fog=void 0,t.bSetFog=!1}}class Me{constructor(e){this.icn3d=e}createBox(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(o.bNode)return;void 0===t&&(t=.8),void 0===s&&(s=!1),void 0===i&&(i=.8),l?void 0===n&&(n=r.hColor):void 0===n&&(n=e.color);let a=s?t:(o.parasCls.vdwRadii[e.elem.toUpperCase()]||t)*(i||1);this.createBox_base(e.coord,a,n,l)}createBox_base(e,t,s,i,n,l,r){let o,a=this.icn3d;a.icn3dui.bNode||(void 0===r&&(r=l?.5:1),new THREE.BoxGeometry(1,1,1),o=new THREE.Mesh(a.boxGeometry,new THREE.MeshPhongMaterial({transparent:!0,opacity:r,specular:a.frac,shininess:a.shininess,emissive:a.emissive,color:s})),o.scale.x=o.scale.y=o.scale.z=t,o.position.copy(e),a.mdl.add(o),i?a.prevHighlightObjects.push(o):n?a.prevOtherMesh.push(o):a.objects.push(o))}createBoxRepresentation_P_CA(e,t,s){let i=this.icn3d;if(i.icn3dui.bNode)return;let n=this;i.reprSubCls.createRepresentationSub(e,(function(e){"CA"!==e.name&&"O3'"!==e.name&&"O3*"!==e.name||n.createBox(e,void 0,void 0,t,void 0,s)}))}}class Pe{constructor(e){this.icn3d=e}createBrick(e,t,s,i){let n=this.icn3d;if(n.icn3dui.bNode)return;let l=new THREE.CylinderGeometry(1,1,1,4,1),r=new THREE.Mesh(l,new THREE.MeshPhongMaterial({specular:n.frac,shininess:n.shininess,emissive:n.emissive,color:i}));r.position.copy(e).add(t).multiplyScalar(.5),r.matrixAutoUpdate=!1,r.lookAt(t.clone().sub(e)),r.updateMatrix(),r.matrix.multiply((new THREE.Matrix4).makeScale(s,s,e.distanceTo(t))).multiply((new THREE.Matrix4).makeRotationX(.5*Math.PI)),n.mdl.add(r)}}class De{constructor(e){this.icn3d=e}createCurveSubArrow(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u){if(this.icn3d.icn3dui.bNode)return;let g=[],f=[];g.push(e),f.push(o),this.prepareStrand(g,f,t,s,i,void 0,n,l,r,a,d,!1,c,h,p,m,u),g=[],f=[]}createStripArrow(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g){if(this.icn3d.icn3dui.bNode)return;let f=[],b=[];f.push(e),f.push(t),b.push(o),b.push(a),this.prepareStrand(f,b,void 0,s,i,n,l,void 0,r,d,c,!0,h,p,m,u,g),f=[],b=[]}prepareStrand(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g,f){let b=this.icn3d,C=b.icn3dui;if(1===d.length)return;let y=i,v=!u,w=[];w.push(i[i.length-2]),w.push(i[i.length-1]),n=n||b.axisDIV;let _,S,A,x,k=2/(a-1),O={};for(let e=0,s=t.length;e1)if(void 0!==d){let i,n,l=[];for(let r=0,o=p.length;r0&&i.tubeCls.createTube(a,"CA",i.coilWidth,s),Object.keys(d).length>0&&i.strandCls.createStrand(d,void 0,void 0,!0,0,i.helixSheetWidth,!1,2*i.ribbonthickness,s)):(Object.keys(a).length>0&&i.tubeCls.createTube(a,"CA",i.coilWidth),Object.keys(d).length>0&&i.strandCls.createStrand(d,void 0,void 0,!0,0,i.helixSheetWidth,!1,2*i.ribbonthickness))}createCylinderCurve(e,t,s,i,n){let l=this.icn3d;if(l.icn3dui.bNode)return;let r,o,a,d,c,h,p=null;for(a in e)if(d=e[a],!d.het&&(c=d.structure+"_"+d.chain,h=d.structure+"_"+r,-1!=t.indexOf(d.name))){if(null!==p&&r===d.chain&&l.ParserUtilsCls.getResiNCBI(h,o)+1===l.ParserUtilsCls.getResiNCBI(c,d.resi)&&Math.abs(p.coord.x-d.coord.x)<8&&Math.abs(p.coord.y-d.coord.y)<8&&Math.abs(p.coord.z-d.coord.z)<8){let e=p.coord.clone().add(d.coord).multiplyScalar(.5);if(n)1===n&&(this.createCylinder(p.coord,e,s,p.color,n),this.createCylinder(e,d.coord,s,d.color,n),l.sphereCls.createSphere(d,s,!0,1,n));else if(i){let t=l.lineCls.createSingleLine(p.coord,e,p.color,!1);l.mdl.add(t),l.objects.push(t),t=l.lineCls.createSingleLine(e,d.coord,d.color,!1),l.mdl.add(t),l.objects.push(t)}else this.createCylinder(p.coord,e,s,p.color),this.createCylinder(e,d.coord,s,d.color),l.sphereCls.createSphere(d,s,!0,1,n)}p=d,r=d.chain,o=d.resi,l.sphereCls.createSphere(d,s,!0,1,n),2===n&&l.boxCls.createBox(d,void 0,void 0,void 0,void 0,n)}if(null!==p&&r===d.chain&&l.ParserUtilsCls.getResiNCBI(h,o)+1===l.ParserUtilsCls.getResiNCBI(c,d.resi)&&Math.abs(p.coord.x-d.coord.x)<8&&Math.abs(p.coord.y-d.coord.y)<8&&Math.abs(p.coord.z-d.coord.z)<8){let e=p.coord.add(d.coord).multiplyScalar(.5);if(n)1===n&&(this.createCylinder(p.coord,e,s,p.color,n),this.createCylinder(e,d.coord,s,d.color,n),l.sphereCls.createSphere(d,s,!0,1,n));else if(i){let t=l.lineCls.createSingleLine(p.coord,e,p.color,!1);l.mdl.add(t),l.objects.push(t),t=l.lineCls.createSingleLine(e,d.coord,d.color,!1),l.mdl.add(t),l.objects.push(t)}else this.createCylinder(p.coord,e,s,p.color),this.createCylinder(e,d.coord,s,d.color)}}}class Le{constructor(e){this.icn3d=e}createLineRepresentation(e,t){let s=this.icn3d;if(s.icn3dui.bNode)return;let i=new THREE.BufferGeometry,n=[],l=[],r=0,o=0;s.reprSubCls.createRepresentationSub(e,void 0,(function(e,t){if(e.color===t.color)n[r++]=e.coord.x,n[r++]=e.coord.y,n[r++]=e.coord.z,n[r++]=t.coord.x,n[r++]=t.coord.y,n[r++]=t.coord.z,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b;else{let s=e.coord.clone().add(t.coord).multiplyScalar(.5);n[r++]=e.coord.x,n[r++]=e.coord.y,n[r++]=e.coord.z,n[r++]=s.x,n[r++]=s.y,n[r++]=s.z,n[r++]=t.coord.x,n[r++]=t.coord.y,n[r++]=t.coord.z,n[r++]=s.x,n[r++]=s.y,n[r++]=s.z,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b}}));if(i.setAttribute("position",new THREE.BufferAttribute(new Float32Array(n),3)),i.setAttribute("color",new THREE.BufferAttribute(new Float32Array(l),3)),2!==t){let e;1===t||(e=new THREE.LineSegments(i,new THREE.LineBasicMaterial({linewidth:s.linewidth,vertexColors:!0})),s.mdl.add(e)),1===t?s.prevHighlightObjects.push(e):s.objects.push(e)}else 2===t&&s.boxCls.createBoxRepresentation_P_CA(e,.8,t)}createConnCalphSidechain(e,t){let s=this.icn3d;if(s.icn3dui.bNode)return;let i={};for(let s in e){let n=e[s];if(!n.het&&n.style2===t){i[n.structure+"_"+n.chain+"_"+n.resi]=1}}let n=[],l=[];for(let e in i){let t=s.firstAtomObjCls.getFirstAtomObjByName(s.residues[e],"CA");if(void 0!==t)for(let e=0,i=t.bonds.length;e=t.bonds.length&&e.bonds.length>1)s=e.serial,l=e.bonds[0],d=e.bonds[1];else{if(!(t.bonds.length>=e.bonds.length&&t.bonds.length>1))return void console.log("Double bond was not drawn due to the undefined cross plane");s=t.serial,l=t.bonds[0],d=t.bonds[1]}let i=r.atoms[s].coord.clone();i.sub(r.atoms[l].coord);let n=r.atoms[s].coord.clone();n.sub(r.atoms[d].coord),i.cross(n),0==parseInt(1e4*i.length())&&(i=new THREE.Vector3(.2,.3,.5)),c=t.coord.clone(),c.sub(e.coord),c.cross(i).normalize().multiplyScalar(.2*o),0==parseInt(1e4*c.length())&&(i=new THREE.Vector3(.5,.3,.2),c.cross(i).normalize().multiplyScalar(.2*o))}e.color===t.color?r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),t.coord.clone().add(c),a,e.color,n),r.cylinderCls.createCylinder(e.coord.clone().sub(c),t.coord.clone().sub(c),a,e.color,n)):r.bImpo?r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),t.coord.clone().add(c),a,e.color,n,t.color),r.cylinderCls.createCylinder(e.coord.clone().sub(c),t.coord.clone().sub(c),a,e.color,n,t.color)):r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),i.clone().add(c),a,e.color,n),r.cylinderCls.createCylinder(t.coord.clone().add(c),i.clone().add(c),a,t.color,n),r.cylinderCls.createCylinder(e.coord.clone().sub(c),i.clone().sub(c),a,e.color,n),r.cylinderCls.createCylinder(t.coord.clone().sub(c),i.clone().sub(c),a,t.color,n))}else if(r.aromaticbonds.hasOwnProperty(l)){let s,l,d;if(e.bonds.length>t.bonds.length&&e.bonds.length>1)s=e.serial,l=e.bonds[0],d=e.bonds[1];else{if(!(t.bonds.length>1))return;s=t.serial,l=t.bonds[0],d=t.bonds[1]}let c=r.atoms[s].coord.clone();c.sub(r.atoms[l].coord);let h=r.atoms[s].coord.clone();h.sub(r.atoms[d].coord),c.cross(h);let p=t.coord.clone();p.sub(e.coord),p.cross(c).normalize().multiplyScalar(.2*o);let m=0;for(let s=0,i=e.bondOrder.length;so+1?(s=k.clone(),i=d.atoms[G[G.length-1-o-1]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random()))):d.bCalphaOnly&&"CA"===b.name&&(G.length>o+1?(s=k.clone(),i=d.atoms[G[G.length-1-o-1]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random())),s.normalize(),s.multiplyScalar(f),null!==E&&s.dot(E)<0&&s.negate(),E=s;for(let e=0,s=2/(t-1);e6||c&&Math.abs(S.y-c.y)>6||c&&Math.abs(S.z-c.z)>6;if((u!==b.chain||b.ssbegin||b.ssend||B===j-1||p)&&m[0].length>0){let c="CA",u=[],g=[];if(isNaN(d.atoms[P].resi))u=[];else{let e=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)-1).toString(),t=d.firstAtomObjCls.getAtomCoordFromResi(e,c);u=void 0!==t?[t]:[]}if(!isNaN(d.atoms[P].resi)){let e=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)+1).toString(),t=d.firstAtomObjCls.getAtomCoordFromResi(e,c);void 0!==t&&g.push(t);let s=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)+2).toString(),i=d.firstAtomObjCls.getAtomCoordFromResi(s,c);void 0!==i&&g.push(i)}if(!p){1===a||2===a?_.push(d.hColor):_.push(R),f=b.ssend&&"sheet"===b.ss?0:"coil"===I&&b.ssbegin||T&&b.ssbegin||"coil"===b.ss?n:l;let s,i,o=4;"O"===b.name?(s=A.clone(),s.sub(S)):d.bCalphaOnly&&"CA"===b.name&&(G.length>o?(s=S.clone(),i=d.atoms[G[G.length-1-o]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random())),s.normalize(),s.multiplyScalar(f),null!==E&&s.dot(E)<0&&s.negate(),E=s;for(let e=0,s=2/(t-1);e0){let e="CA",n=[],l=[];if(isNaN(d.atoms[P].resi))n=[];else{let t=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)-1).toString();d.firstAtomObjCls.getAtomCoordFromResi(t,e)}for(let e=0;!i&&e0;--e){let t=a.structure+"_"+a.chain+"_"+e;if(!c.residues.hasOwnProperty(t))break;let s=c.firstAtomObjCls.getFirstCalphaAtomObj(c.residues[t]);if(s.ss===a.ss&&s.ssbegin){g=s.resi;break}}for(let e=g;e0&&(o!==c.chain||Math.abs(c.coord.x-h.coord.x)>6||Math.abs(c.coord.y-h.coord.y)>6||Math.abs(c.coord.z-h.coord.z)>6||r.ParserUtilsCls.getResiNCBI(c.structure+"_"+o,a)+13||Math.abs(c.coord.y-h.coord.y)>3||Math.abs(c.coord.z-h.coord.z)>3))){if(2!==i){if(!isNaN(d.resi)&&!isNaN(h.resi)){let e=d.structure+"_"+d.chain+"_"+(parseInt(d.resi)-1).toString(),i=r.firstAtomObjCls.getAtomCoordFromResi(e,t);g=void 0!==i?[i]:[];let l=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+1).toString(),o=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+2).toString(),a=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+3).toString();if(r.residues.hasOwnProperty(l)){let e=r.firstAtomObjCls.getAtomFromResi(l,t);void 0!==e&&e.ssbegin&&(l=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+2).toString(),o=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+3).toString(),p.push(e.coord),n?u.push(this.getCustomtubesize(l)):u.push(this.getRadius(s,e)),m.push(e.color))}if(1==p.length&&r.residues.hasOwnProperty(l)){let e=r.firstAtomObjCls.getAtomFromResi(l,t);if(e){p.push(e.coord),m.push(e.color);let t=this.getRadius(s,c);u.push(t),l=o,o=a}}let b=r.firstAtomObjCls.getAtomCoordFromResi(l,t);void 0!==b&&f.push(b);let C=r.firstAtomObjCls.getAtomCoordFromResi(o,t);void 0!==C&&f.push(C)}C.push({pnts:p,colors:m,radii:u,prevone:g,nexttwo:f})}p=[],m=[],u=[],g=[],f=[],d=c,b=0}if(0==p.length&&!isNaN(c.resi)){let e=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)-1).toString();r.residues.hasOwnProperty(e)&&(h=r.firstAtomObjCls.getAtomFromResi(e,t),void 0!==h&&h.ssend&&(p.push(h.coord),n?u.push(this.getCustomtubesize(e)):u.push(this.getRadius(s,h)),m.push(h.color)))}let e;p.push(c.coord),e=n?this.getCustomtubesize(c.structure+"_"+c.chain+"_"+c.resi):this.getRadius(s,c),u.push(e),m.push(c.color),1===b&&(m[m.length-2]=c.color),o=c.chain,a=c.resi;let l=1.2;2!==i||c.ssbegin||r.boxCls.createBox(c,void 0,void 0,l,void 0,i),++b,h=c}if(2!==i){if(g=[],void 0!==d&&!isNaN(d.resi)){let e=d.structure+"_"+d.chain+"_"+(parseInt(d.resi)-1).toString(),s=r.firstAtomObjCls.getAtomCoordFromResi(e,t);g=void 0!==s?[s]:[]}if(f=[],void 0!==c&&!isNaN(c.resi)){let e=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+1).toString(),i=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+2).toString(),n=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+3).toString();if(1==p.length&&r.residues.hasOwnProperty(e)){let l=r.firstAtomObjCls.getAtomFromResi(e,t);if(l){p.push(l.coord),m.push(l.color);let t=this.getRadius(s,c);u.push(t),e=i,i=n}}let l=r.firstAtomObjCls.getAtomCoordFromResi(e,t);void 0!==l&&f.push(l);let o=r.firstAtomObjCls.getAtomCoordFromResi(i,t);void 0!==o&&f.push(o)}C.push({pnts:p,colors:m,radii:u,prevone:g,nexttwo:f})}for(let e=0,t=C.length;e1?a.parasCls.thr(t[t.length-2]):a.parasCls.thr(t[e]),f[y++]=d.r,f[y++]=d.g,f[y++]=d.b}}let x,k=0;for(let e=0,t=_.length-1;er&&(l=r,e=1);for(let t=0;t0&&t.b<=100?.01*t.b:t.b>100?1:s.coilWidth),i}}class ze{constructor(e){this.icn3d=e}drawCartoonNucleicAcid(e,t,s,i){this.drawStrandNucleicAcid(e,2,t,!0,void 0,s,i)}drawStrandNucleicAcid(e,t,s,i,n,l,r){let o,a,d,c=this.icn3d;if(c.icn3dui.bNode)return;2===r&&(t=void 0,l=void 0),n=n||c.nucleicAcidWidth,s=s||c.axisDIV,t=t||c.nucleicAcidStrandDIV;let h=[];for(d=0;dy?y=C:C=y);let v=.8*b/y;if(g.width=C,g.height=y,f.clearRect(0,0,C,y),h)if(f.fillStyle="rgba("+n.r+","+n.g+","+n.b+","+n.a+")",f.strokeStyle="rgba("+l.r+","+l.g+","+l.b+","+l.a+")",f.lineWidth=r,p){let e=.4*C;this.circle(f,0,0,C,y,e)}else{let e=0;this.roundRect(f,0,0,C,y,e)}f.font="Bold "+a+"px "+o,f.textAlign="center",f.textBaseline="middle",f.fillStyle="rgba("+u.r+", "+u.g+", "+u.b+", 1.0)",f.strokeStyle="rgba("+u.r+", "+u.g+", "+u.b+", 1.0)",f.fillText(e,.5*C,.5*y);let w=new THREE.Texture(g);w.needsUpdate=!0;let _=new THREE.SpriteMaterial({map:w,depthTest:!1,depthWrite:!1});_.map.minFilter=THREE.LinearFilter;let S=new THREE.Sprite(_);return p?S.scale.set(.3*d,.3*d,1):S.scale.set(v*d,d,1),S}roundRect(e,t,s,i,n,l){e.beginPath(),e.moveTo(t+l,s),e.lineTo(t+i-l,s),e.quadraticCurveTo(t+i,s,t+i,s+l),e.lineTo(t+i,s+n-l),e.quadraticCurveTo(t+i,s+n,t+i-l,s+n),e.lineTo(t+l,s+n),e.quadraticCurveTo(t,s+n,t,s+n-l),e.lineTo(t,s+l),e.quadraticCurveTo(t,s,t+l,s),e.closePath(),e.fill(),e.stroke()}circle(e,t,s,i,n,l){e.beginPath(),e.arc(t+i/2,.9*(s+n/2),l,0,2*Math.PI,!0),e.closePath(),e.fill(),e.stroke()}}class Ve{constructor(e){this.icn3d=e,this.textSpriteCls=new Ge(e)}createLabelRepresentation(e){let t=this.icn3d;t.icn3dui;let s=t.oriMaxD/100;s<.4&&(s=.4);let i=3*s*t.labelScale;for(let s in e){let n=void 0!==e[s]?e[s]:[],l="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd;for(let e=0,r=n.length;e.99999)h.set(0,0,0,1);else if(e.y<-.99999)h.set(1,0,0,0);else{let t=new THREE.Vector3;t.set(e.z,0,-e.x).normalize();let s=Math.acos(e.y);h.setFromAxisAngle(t,s)}return c.applyQuaternion(h),c.scale.set(l,n,l),c.position.copy(t),c}setPc1Axes(){let e=this.icn3d,t=e.icn3dui;if(t.bNode)return;let s=t.hashUtilsCls.intHash(e.hAtoms,e.dAtoms),i=[],n=Object.keys(s).length<100;for(let t in s){let s=e.atoms[t],l=s.structure+"_"+s.chain+"_"+s.resi;(n||""!=l)&&i.push(s.coord.clone())}let l=t.rmsdSuprCls.getEigenForSelection(i,i.length),r=new THREE.Vector3(l.h1[0],l.h1[1],l.h1[2]);if(0==l.k&&e.bRender)return void alert("Can't determine the first principal component. Please select a subset and try it again.");let o=e.applyCenterCls.centerAtoms(s),a=o.maxD,d=o.center,c=d.clone().add(r.normalize().multiplyScalar(.4*a)),h=new THREE.Vector3(l.h2[0],l.h2[1],l.h2[2]),p=d.clone().add(h.normalize().multiplyScalar(.3*a)),m=new THREE.Vector3(l.h3[0],l.h3[1],l.h3[2]),u=d.clone().add(m.normalize().multiplyScalar(.3*a));this.buildAxes(void 0,d,c,p,u,!0);let g=[d,c,p,u];return e.axes.push(g),e.drawCls.draw(),g}}class Ye{constructor(e){this.icn3d=e}showGlycans(){let e=this.icn3d,t=e.icn3dui;if(t.bNode)return;let s={},i=e.dAtoms;for(let n in i){let i=e.atoms[n];i.het&&-1!=t.parasCls.glycanHash.hasOwnProperty(i.resn)&&(void 0===s[i.resn]&&(s[i.resn]={}),"Misc"!=i.chain&&(s[i.resn][i.structure+"_"+i.chain+"_"+i.resi]=1))}let n=Object.keys(s);for(let i=0,l=n.length;i>2))+i+((2&t)>>1))*c+n+(1&t)]&this.ISDONE)<=3&&(t.push(t[i]),i=t.length-1,t.push(t[n]),n=t.length-1,t.push(t[l]),l=t.length-1),s.push(i),s.push(n),s.push(l)}}},Xe.prototype.laplacianSmooth=function(e,t,s){let i,n,l,r,o,a=new Array(t.length);for(i=0,n=t.length;ithis.origextent[1][0])&&(!(tthis.origextent[1][1])&&!(sthis.origextent[1][2]))},Ke.prototype.getFacesAndVertices=function(){let e,t,s=this.verts;for(e=0,t=s.length;eh&&(h=this.pmaxy-this.pminy),this.pmaxz-this.pminz>h&&(h=this.pmaxz-this.pminz),this.scaleFactor=(c-1)/h,this.scaleFactor=this.defaultScaleFactor,(this.bCalcArea||this.defaultScaleFactor*h>this.threshbox)&&(c=Math.floor(this.threshbox),this.scaleFactor=(this.threshbox-1)/h),this.pLength=Math.ceil(this.scaleFactor*(this.pmaxx-this.pminx))+1,this.pWidth=Math.ceil(this.scaleFactor*(this.pmaxy-this.pminy))+1,this.pHeight=Math.ceil(this.scaleFactor*(this.pmaxz-this.pminz))+1,this.finalScaleFactor.x=(this.pLength-1)/(this.pmaxx-this.pminx),this.finalScaleFactor.y=(this.pWidth-1)/(this.pmaxy-this.pminy),this.finalScaleFactor.z=(this.pHeight-1)/(this.pmaxz-this.pminz),this.boundingatom(t),this.cutRadius=this.probeRadius*this.scaleFactor,this.vpBits=new Uint8Array(this.pLength*this.pWidth*this.pHeight),this.vpDistance=new Float64Array(this.pLength*this.pWidth*this.pHeight),this.vpAtomID=new Int32Array(this.pLength*this.pWidth*this.pHeight),this.vpColor=[],this.vpPot=[]},Ke.prototype.boundingatom=function(e){let t,s,i,n,l=[];for(let r in this.vdwRadii){if(!this.vdwRadii.hasOwnProperty(r))continue;let o=this.vdwRadii[r];l[r]=e?(o+this.probeRadius)*this.scaleFactor+.5:o*this.scaleFactor+.5,i=l[r]*l[r],this.widxz[r]=Math.floor(l[r])+1,this.depty[r]=new Int32Array(this.widxz[r]*this.widxz[r]),n=0;for(let e=0;ei?this.depty[r][n]=-1:(s=Math.sqrt(i-t),this.depty[r][n]=Math.floor(s)),n++}},Ke.prototype.fillvoxels=function(e,t){let s,i,n,l;for(s=0,l=this.vpBits.length;sc&&(a=c),C>h&&(C=h),v>p&&(v=p);let w,_=g[o*m+d*u+y],S=g[a*m+d*u+y],A=g[o*m+C*u+y],x=g[o*m+d*u+v],k=g[a*m+C*u+y],O=g[o*m+C*u+v],R=g[a*m+d*u+v],E=g[a*m+C*u+v],I=r.x-o,T=r.y-d,M=r.z-y,P=((_*(1-I)+S*I)*(1-T)+(A*(1-I)+k*I)*T)*(1-M)+((x*(1-I)+R*I)*(1-T)+(O*(1-I)+E*I)*T)*M,D=s*f+i*b+n;this.vpPot[D]=P,P>this.isovalue&&(P=this.isovalue),P<-this.isovalue&&(P=-this.isovalue),P>0?(P/=1*this.isovalue,w=new THREE.Color(1-P,1-P,1)):(P/=-1*this.isovalue,w=new THREE.Color(1,1-P,1-P)),this.vpColor[D]=w}}for(s=0,l=this.vpBits.length;s=this.pLength||g>=this.pWidth||f>=this.pHeight)continue;let h=u*S+g*this.pHeight+f;if(this.vpBits[h]&this.INOUT){let p=t[this.vpAtomID[h]];p.serial!=e.serial&&(l=s+a-Math.floor(.5+this.scaleFactor*(p.x+this.ptranx)),r=i+d-Math.floor(.5+this.scaleFactor*(p.y+this.ptrany)),o=n+c-Math.floor(.5+this.scaleFactor*(p.z+this.ptranz)),a*a+d*d+c*c=this.pLength||p>=this.pWidth||m>=this.pHeight)continue;let u=h*S+p*this.pHeight+m;if(this.vpBits[u]&this.ISDONE){let h=t[this.vpAtomID[u]];h.serial!=e.serial&&(l=s+a-Math.floor(.5+this.scaleFactor*(h.x+this.ptranx)),r=i+d-Math.floor(.5+this.scaleFactor*(h.y+this.ptrany)),o=n+c-Math.floor(.5+this.scaleFactor*(h.z+this.ptranz)),a*a+d*d+c*c-1&&r-1&&a-1&&o=h)||(this.vpBits[n]|=this.ISBOUND))},Ke.prototype.fastoneshell=function(e,t){let s,i,n,l,r,o,a,d,c,h,p,m,u=[];if(0===e.length)return u;let g={ix:-1,iy:-1,iz:-1},f=this.pWidth*this.pHeight;for(a=0,c=e.length;a-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,h-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,h-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,hm&&(m=this.pmaxy-this.pminy),this.pmaxz-this.pminz>m&&(m=this.pmaxz-this.pminz),this.scaleFactor=1,this.pLength=Math.floor(.5+this.scaleFactor*(this.pmaxx-this.pminx))+1,this.pWidth=Math.floor(.5+this.scaleFactor*(this.pmaxy-this.pminy))+1,this.pHeight=Math.floor(.5+this.scaleFactor*(this.pmaxz-this.pminz))+1,this.cutRadius=this.probeRadius*this.scaleFactor,this.vpBits=new Uint8Array(this.pLength*this.pWidth*this.pHeight),this.vpAtomID=new Uint8Array(this.pLength*this.pWidth*this.pHeight)},Qe.prototype.transformMemPro=function(e,t,s,i){let n=e.clone();n.sub(s);let l=n.x*t[0]+n.y*t[1]+n.z*t[2]+i.x,r=n.x*t[3]+n.y*t[4]+n.z*t[5]+i.y,o=n.x*t[6]+n.y*t[7]+n.z*t[8]+i.z;return n.x=l,n.y=r,n.z=o,n},Qe.prototype.fillvoxels=function(e,t){let s,i,n,l,r,o;for(s=0,l=this.vpBits.length;sthis.pLength&&(o=this.pLength),p>this.pWidth&&(p=this.pWidth),b>this.pHeight&&(b=this.pHeight);let C,y=l[r*a+h*d+f],v=l[o*a+h*d+f],w=l[r*a+p*d+f],_=l[r*a+h*d+b],S=l[o*a+p*d+f],A=l[r*a+p*d+b],x=l[o*a+h*d+b],k=l[o*a+p*d+b],O=n.x-r,R=n.y-h,E=n.z-f,I=((y*(1-O)+v*O)*(1-R)+(w*(1-O)+S*O)*R)*(1-E)+((_*(1-O)+x*O)*(1-R)+(A*(1-O)+k*O)*R)*E;I>this.isovalue&&(I=this.isovalue),I<-this.isovalue&&(I=-this.isovalue),I>0?(I/=1*this.isovalue,C=new THREE.Color(1-I,1-I,1)):(I/=-1*this.isovalue,C=new THREE.Color(1,1-I,1-I)),this.icn3d.atoms[t[s]].color=C,this.icn3d.atomPrevColors[t[s]]=C}}else{for(let p in t){let f,b=e[t[p]];if("DUM"!==b.resn){if(void 0!==this.rmsd_supr&&void 0!==this.rmsd_supr.rot){f=this.transformMemPro(b.coord,g,u,m).applyMatrix4(c)}else f=b.coord.clone().applyMatrix4(c);for(s=Math.floor(f.x)-this.maxdist,l=Math.ceil(f.x)+this.maxdist;s<=l;++s)if(!(s<0||s>this.header.xExtent*this.scaleFactor-1))for(i=Math.floor(f.y)-this.maxdist,r=Math.ceil(f.y)+this.maxdist;i<=r;++i)if(!(i<0||i>this.header.yExtent*this.scaleFactor-1))for(n=Math.floor(f.z)-this.maxdist,o=Math.ceil(f.z)+this.maxdist;n<=o;++n){if(n<0||n>this.header.zExtent*this.scaleFactor-1)continue;let e=s*a+i*d+n;h.push(e)}}}for(s=0,l=h.length;s=this.isovalue?1:0:"fofc"==this.type?(this.vpBits[e]=this.dataArray[e]>=this.isovalue||this.dataArray[e]<=-this.isovalue?1:0,this.vpAtomID[e]=this.dataArray[e]>=0?1:0):"em"==this.type&&(this.vpBits[e]=this.dataArray[e]>=this.isovalue?1:0)}}}else for(s=0;s=this.isovalue||this.dataArray[e]<=-this.isovalue?1:0,this.vpAtomID[t]=this.dataArray[e]>=0?1:0)}for(s=0,l=this.vpBits.length;s-1&&r-1&&a-1&&o1?"Structure":"",a=Object.keys(i).length>1?"Chain":"";n+=""+o+a+"ResidueNumberSASA (Å2)Percent OutIn/Out";for(let e in l.resid2area){let d=e.lastIndexOf("_"),c=e.substr(d+1),h=r.utilsCls.getIdArray(e.substr(0,d));o=Object.keys(s).length>1?""+h[0]+"":"",a=Object.keys(i).length>1?""+h[1]+"":"";let p="",m="";l.resid2area[e]=(l.resid2area[e]/t).toFixed(2),r.parasCls.residueArea.hasOwnProperty(c)&&(m=parseInt(l.resid2area[e]/r.parasCls.residueArea[c]*100),m>100&&(m=100),m>=50&&(p="out"),m<20&&(p="in")),n+=''+o+a+""+c+''+h[2]+''+l.resid2area[e]+''+m+"%"+p+""}return n+="",void(l.areahtml=n)}let p,m,u,g=c.vertices,f=c.faces,b=r.parasCls.thr("#00FFFF"),C=r.parasCls.thr("#00FF00"),y=r.parasCls.thr("#ff0000"),v=r.parasCls.thr("#00FFFF"),w=r.parasCls.thr("#0000FF"),_=r.parasCls.thr("#FF0000");11!=t&&12!=t&&13!=t&&14!=t||void 0===l.rmsd_supr||void 0===l.rmsd_supr.rot||(p=l.rmsd_supr.rot,m=l.rmsd_supr.trans1,u=l.rmsd_supr.trans2);let S=(11==t||12==t||13==t||14==t&&"delphi"!=l.loadPhiFrom)&&void 0!==l.rmsd_supr&&void 0!==l.rmsd_supr.rot;n=new THREE.BufferGeometry;let A,x=[],k=[],O=[],R=0;for(let e=0,s=g.length;e0?-parseInt(C.z):parseInt(C.z),y.onBeforeRender=function(e,t,s,i,n,o){let a,d=new THREE.Vector3(0,0,0),c=i.getAttribute("position").array;for(let e=0,t=c.length;e0?-parseInt(a.z):parseInt(a.z)},l.mdl.add(y),11==t||12==t?l.prevMaps.push(y):13==t?l.prevEmmaps.push(y):14==t?l.prevPhimaps.push(y):l.prevSurfaces.push(y)}}else{let e=new THREE.Mesh(n,new THREE.MeshPhongMaterial({specular:l.frac,shininess:20,emissive:l.emissive,vertexColors:THREE.VertexColors,wireframe:s,opacity:i,transparent:!0,depthWrite:10==parseInt(10*i),side:THREE.DoubleSide}));e.renderOrder=-2,l.mdl.add(e),11==t||12==t?l.prevMaps.push(e):13==t?l.prevEmmaps.push(e):14==t?l.prevPhimaps.push(e):l.prevSurfaces.push(e)}c=null,g=null,f=null,n=null}transformMemPro(e,t,s,i,n){this.icn3d.icn3dui;let l=e.clone();l.sub(s),n&&console.log("sub coord: "+JSON.stringify(l));let r=l.x*t[0]+l.y*t[1]+l.z*t[2]+i.x,o=l.x*t[3]+l.y*t[4]+l.z*t[5]+i.y,a=l.x*t[6]+l.y*t[7]+l.z*t[8]+i.z;return l.x=r,l.y=o,l.z=a,n&&console.log("out coord: "+JSON.stringify(l)),l}SetupSurface(e){let t=this.icn3d;t.icn3dui;let s=e.threshbox,i=new Ke(t,s);i.initparm(e.extent,1!==e.type,e.bCalcArea,e.atomsToShow,e.header,e.data,e.matrix,e.isovalue,e.loadPhiFrom),i.fillvoxels(e.allatoms,e.extendedAtoms),i.buildboundary(),2===e.type&&(i.fastdistancemap(),i.boundingatom(!1),i.fillvoxelswaals(e.allatoms,e.extendedAtoms));let n=i.marchingcube();i.vpBits=null,i.vpDistance=null,i.vpAtomID=null;let l=i.getFacesAndVertices(e.atomsToShow);return l.area=n.area,l.serial2area=n.serial2area,l.scaleFactor=n.scaleFactor,i.faces=null,i.verts=null,l}SetupMap(e){let t=this.icn3d;t.icn3dui;let s,i=new Qe(t);return i.initparm(e.header,e.data,e.matrix,e.isovalue,e.center,e.maxdist,e.pmin,e.pmax,e.water,e.type,e.rmsd_supr,e.loadPhiFrom,e.icn3d),i.fillvoxels(e.allatoms,e.extendedAtoms),e.header.bSurface||i.buildboundary(),e.header.bSurface||i.marchingcube(),i.vpBits=null,i.vpAtomID=null,e.header.bSurface||(s=i.getFacesAndVertices(e.allatoms,e.atomsToShow)),i.faces=null,i.verts=null,s}}class Ze{constructor(e){this.icn3d=e}applyCenterOptions(e){let t,s=this.icn3d;switch(s.icn3dui,void 0===e&&(e=s.opts),e.rotationcenter.toLowerCase()){case"molecule center":void 0!==s.center&&this.setRotationCenter(s.center);break;case"pick center":void 0!==s.pAtom&&this.setRotationCenter(s.pAtom.coord);break;case"display center":t=this.centerAtoms(s.dAtoms).center,this.setRotationCenter(t);break;case"highlight center":t=this.centerAtoms(s.hAtoms).center,this.setRotationCenter(t)}}setRotationCenter(e){this.icn3d.icn3dui,this.setCenter(e)}setCenter(e){let t=this.icn3d;t.icn3dui,t.mdl.position.set(0,0,0),t.mdlImpostor.position.set(0,0,0),t.mdl_ghost.position.set(0,0,0),t.mdl.position.sub(e),t.mdlImpostor.position.sub(e),t.mdl_ghost.position.sub(e)}centerSelection(e,t){let s=this.icn3d,i=s.icn3dui;if(s.opts.rotationcenter="highlight center",void 0===e&&(e=i.hashUtilsCls.hash2Atoms(s.hAtoms,s.atoms)),t||(s._zoomFactor=1,s.mouseChange=new THREE.Vector2(0,0),s.quaternion=new THREE.Quaternion(0,0,0,1)),Object.keys(e).length>1){let t=this.centerAtoms(e);s.center=t.center,this.setCenter(s.center),s.cameraCls.setCamera()}}centerAtoms(e){let t=this.icn3d;t.icn3dui;let s=new THREE.Vector3(9999,9999,9999),i=new THREE.Vector3(-9999,-9999,-9999),n=new THREE.Vector3;for(let l in e){let e=t.atoms[l].coord;n.add(e),s.min(e),i.max(e)}let l=t.ParserUtilsCls.getGeoCenter(s,i);return{center:l,maxD:t.ParserUtilsCls.getStructureSize(e,s,i,l),pmin:s,pmax:i}}setWidthHeight(e,t){let s=this.icn3d;s.icn3dui,void 0===s.scaleFactor&&(s.scaleFactor=1),s.renderer.setSize(e*s.scaleFactor,t*s.scaleFactor),s.renderer.domElement.style.width=e*s.scaleFactor+"px",s.renderer.domElement.style.height=t*s.scaleFactor+"px",s.renderer.domElement.width=e*s.scaleFactor,s.renderer.domElement.height=t*s.scaleFactor,s.container.whratio=e/t}}class et{constructor(e){this.icn3d=e}applyClbondsOptions(e){let t=this.icn3d,s=t.icn3dui;if(void 0===e&&(e=t.opts),t.bCalcCrossLink||(t.clbondpnts={},t.clbondResid2serial={},this.applyClbondsOptions_base("chemical"),this.applyClbondsOptions_base("all"),t.bCalcCrossLink=!0),"yes"===e.clbonds.toLowerCase()&&"nothing"!==e.chemicals){let e="#006400",i=s.parasCls.thr(25600);if(t.lines.clbond=[],t.residuesHashClbonds={},t.structures){let n=Object.keys(t.structures);for(let l=0,r=n.length;l1&&"sphere"!==a[Object.keys(a)[0]].style&&"dot"!==a[Object.keys(a)[0]].style){if(void 0===i.bCid||!i.bCid)for(let e in a){let t=a[e],n=1;i.boxCls.createBox(t,void 0,void 0,n,void 0,s)}}else for(let e in o){let l=i.firstAtomObjCls.getFirstCalphaAtomObj(i.residues[e]),r=l,o=r.structure+"_"+r.chain+"_"+(parseInt(r.resi)-1).toString(),a=r.structure+"_"+r.chain+"_"+(parseInt(r.resi)+1).toString();if("cylinder and plate"===r.style&&"helix"===r.ss)for(let t in i.residues[e]){let e=i.atoms[t],n=1;i.boxCls.createBox(e,void 0,void 0,n,void 0,s)}else if("ribbon"===r.style&&"coil"===r.ss||"strand"===r.style&&"coil"===r.ss||"o3 trace"===r.style||"schematic"===r.style||"c alpha trace"===r.style||"b factor tube"===r.style||"cylinder and plate"===r.style&&"helix"!==r.ss){if(void 0!==l&&void 0!==l.style2&&"nothing"!==l.style2)continue;let e=!1;if(!isNaN(r.resi)&&!e&&i.residues.hasOwnProperty(a)){let s=Object.keys(i.residues[a])[0],l=n.hashUtilsCls.hash2Atoms(i.residues[a],i.atoms)[s];if(r.style===l.style&&!l.ssbegin||l.ssbegin){let s=i.residues[a];if(t=n.hashUtilsCls.unionHash(t,s),e=!0,l.ssbegin)for(let e in s)i.atoms[e].notshow=!0}}if(!isNaN(r.resi)&&!e&&i.residues.hasOwnProperty(o)){let s=Object.keys(i.residues[o])[0],l=n.hashUtilsCls.hash2Atoms(i.residues[o],i.atoms)[s];r.style===l.style&&(t=n.hashUtilsCls.unionHash(t,i.residues[o]),e=!0)}}else if("ribbon"===r.style&&"coil"!==r.ss&&r.ssend||"strand"===r.style&&"coil"!==r.ss&&r.ssend){if(void 0!==l&&void 0!==l.style2&&"nothing"!==l.style2)continue;let e=!1;if(!isNaN(r.resi)&&!e&&i.residues.hasOwnProperty(a)){let s=Object.keys(i.residues[a])[0];n.hashUtilsCls.hash2Atoms(i.residues[a],i.atoms)[s],t=n.hashUtilsCls.unionHash(t,i.residues[a]),e=!0}}}a={}}if(i.bInitial){if(""!=n.htmlCls.setHtmlCls.getCookie("membrane")){let e=parseInt(n.htmlCls.setHtmlCls.getCookie("membrane"));i.bMembrane!=e&&n.htmlCls.clickMenuCls.setLogCmd("set membrane "+e,!0),i.bMembrane=isNaN(e)?0:parseInt(e)}i.bMembrane?i.selectionCls.toggleMembrane(!0):i.selectionCls.toggleMembrane(!1)}i.setStyleCls.setStyle2Atoms(t);let d=.5*i.cylinderRadius;void 0!==i.labels&&delete i.labels.schematic;for(let e in i.style2atoms){let t=i.style2atoms[e],l=n.hashUtilsCls.intHash(t,i.nucleotides),r=n.utilsCls.isCalphaPhosOnly(n.hashUtilsCls.hash2Atoms(l,i.atoms));if("ribbon"===e)i.strandCls.createStrand(n.hashUtilsCls.hash2Atoms(t,i.atoms),2,void 0,!0,void 0,void 0,!1,i.ribbonthickness,s);else if("strand"===e)i.strandCls.createStrand(n.hashUtilsCls.hash2Atoms(t,i.atoms),null,null,null,null,null,!1,void 0,s);else if("cylinder and plate"===e)i.cylinderCls.createCylinderHelix(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderHelixRadius,s);else if("nucleotide cartoon"===e)r?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["P"],i.traceRadius,!1,s):(i.cartoonNuclCls.drawCartoonNucleicAcid(n.hashUtilsCls.hash2Atoms(t,i.atoms),null,i.ribbonthickness,s),2!==s&&i.cartoonNuclCls.drawNucleicAcidStick(n.hashUtilsCls.hash2Atoms(t,i.atoms),s));else if("o3 trace"===e)r?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["P"],i.traceRadius,!1,s):i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["O3'","O3*"],i.traceRadius,!1,s);else if("schematic"===e){let e=i.firstAtomObjCls.getFirstAtomObj(t);if(i.chemicals.hasOwnProperty(e.serial)){i.residueLabelsCls.addNonCarbonAtomLabels(n.hashUtilsCls.hash2Atoms(t,i.atoms));let e=!0;i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),d,d,void 0,s,e)}else i.residueLabelsCls.addResidueLabels(n.hashUtilsCls.hash2Atoms(t,i.atoms),!0),r?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["P"],i.traceRadius,!1,s):i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["O3'","O3*"],i.traceRadius,!1,s),i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["CA"],i.traceRadius,!1,s)}else"c alpha trace"===e?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["CA"],i.traceRadius,!1,s):"b factor tube"===e?i.tubeCls.createTube(n.hashUtilsCls.hash2Atoms(t,i.atoms),"CA",null,s,!1,!0):"custom tube"===e?i.tubeCls.createTube(n.hashUtilsCls.hash2Atoms(t,i.atoms),"CA",null,s,!0,!0):"lines"===e||"lines2"===e?(1===s?i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.hlLineRadius,i.hlLineRadius,void 0,s):i.lineCls.createLineRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),s),i.lineCls.createConnCalphSidechain(n.hashUtilsCls.hash2Atoms(t,i.atoms),e)):"stick"===e||"stick2"===e?(i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderRadius,i.cylinderRadius,void 0,s,void 0),i.lineCls.createConnCalphSidechain(n.hashUtilsCls.hash2Atoms(t,i.atoms),e)):"backbone"===e?(t=this.selectMainChainSubset(t),i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderRadius,i.cylinderRadius,void 0,s,void 0)):"ball and stick"===e||"ball and stick2"===e?(i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderRadius,.5*i.cylinderRadius,i.dotSphereScale,s,void 0),i.lineCls.createConnCalphSidechain(n.hashUtilsCls.hash2Atoms(t,i.atoms),e)):"sphere"===e||"sphere2"===e?i.sphereCls.createSphereRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.sphereRadius,void 0,void 0,s):"dot"===e&&i.sphereCls.createSphereRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.sphereRadius,!1,i.dotSphereScale,s)}if(i.cnt>i.maxmaxatomcnt&&i.init_base(),void 0!==i.labels&&Object.keys(i.labels).length>0){i.labelCls.hideLabels();for(let e in i.labels)"schematic"!=e&&this.changeLabelColor(i.labels[e]);i.labelCls.createLabelRepresentation(i.labels)}}changeLabelColor(e){let t=this.icn3d;if(t.icn3dui,e)for(let s=0,i=e.length;s0){this.updateStabilizer();let e="#FFFFFF",s=t.stabilizerpnts;t.lines.stabilizer=[];for(let i=0,n=Math.floor(s.length/2);i0)for(let e=0,s=t.distPnts.length;e0&&t.applySymdCls.applySymd(),void 0!==t.prevOtherMesh)for(let e=0,s=t.prevOtherMesh.length;e0&&(e=s.hashUtilsCls.hash2Atoms(t.chemicals,t.atoms));let i=4;if(void 0!==e){let n=t.contactCls.getAtomsWithinAtom(t.atoms,e,i),l=3.5;t.opts.hbonds="yes",Object.keys(n).length>0&&t.hBondCls.calculateChemicalHbonds(e,n,parseFloat(l)),t.bSetFog||t.transformCls.zoominSelection(s.hashUtilsCls.unionHash(e,n))}}else"hide"===e.chemicalbinding&&(t.hBondCls.hideHbonds(),t.bSetFog||t.transformCls.zoominSelection(t.atoms))}updateStabilizer(){let e=this.icn3d;if(e.icn3dui,e.stabilizerpnts=[],void 0!==e.pairArray)for(let t=0,s=e.pairArray.length;t=0;i--){let r=t.ssbondpnts[e][2*i],o=t.ssbondpnts[e][2*i+1],a={};a.color=n,a.dashed=!0;let d=[],c=[],h=[],p=[],m=!1,u=!1;for(let e in t.residues[r])"SG"===t.atoms[e].name&&(h.push(t.atoms[e].coord),d.push(t.atoms[e].serial),m=!0);if(!m)for(let e in t.residues[r])if("CA"===t.atoms[e].name){h.push(t.atoms[e].coord),d.push(t.atoms[e].serial),m=!0,u=!0;break}m=!1;for(let e in t.residues[o])"SG"===t.atoms[e].name&&(p.push(t.atoms[e].coord),c.push(t.atoms[e].serial),m=!0);if(!m)for(let e in t.residues[o])if("CA"===t.atoms[e].name){p.push(t.atoms[e].coord),c.push(t.atoms[e].serial),m=!0,u=!0;break}let g=u?7:3,f=!1;for(let e=0,t=h.length;e1&&(l=!0)}if(t)if(l){let t=Object.keys(r)[0];e=i.chains[t]}else{0==Object.keys(i.hAtoms).length&&(i.hAtoms=n.hashUtilsCls.cloneHash(i.dAtoms));let t,s=parseInt(Object.keys(i.hAtoms).length/u),l=0;for(let n in i.hAtoms)if(e[n]=1,t=n,++l,l>s)break;let r=i.atoms[t].structure+"_"+i.atoms[t].chain+"_"+i.atoms[t].resi;e=n.hashUtilsCls.unionHash(e,i.residues[r])}else{let t=Object.keys(i.structures)[0]+"_"+g;if(i.chains.hasOwnProperty(t)||(t=Object.keys(i.structures)[0]+"_"+g.toLowerCase()),!i.chains.hasOwnProperty(t)){t=Object.keys(i.chains)[0];for(let e in i.chains){let s=Object.keys(i.chains[e])[0];if(i.proteins.hasOwnProperty(s)){t=e;break}}}e=i.chains[t]}let a=s.clone().add(h).multiplyScalar(.5),c=new THREE.Vector3,p=0,f=h.clone().sub(s).normalize(),b=new THREE.Vector3(0,0,1),C=new THREE.Quaternion;C.setFromUnitVectors(f,b);let y=-9999;for(let t in e){let e=i.atoms[t].coord.clone();c.add(e),e.sub(a).applyQuaternion(C);let s=e.x*e.x+e.y*e.y;s>y&&(y=s),++p}let v=i.ParserUtilsCls.getMassCenter(c,p),w=new THREE.Line3(s,h),_=new THREE.Vector3;w.closestPointToPoint(v,!0,_);let S,A,x,k,O=Math.sqrt(y),R=v.clone().sub(_).normalize().multiplyScalar(O),E=a.clone().add(s.clone().sub(a).multiplyScalar(.83)).add(R),I=a.clone().add(h.clone().sub(a).multiplyScalar(.83)).add(R),T=2*Math.PI/o;for(let e=0;et&&(i.sphereCls.createSphereBase(r,colorPolygon,d,1,0),i.cylinderCls.createCylinder(e,r,d,colorPolygon,0),i.cylinderCls.createCylinder(s,r,d,colorPolygon,0),void 0!==n&&i.cylinderCls.createCylinder(c[n],r,d,colorPolygon,0),n=l)}}else if("O"==r)for(let e=0,t=c.length;e0&&(e.mdl.remove(e.prevSurfaces[e.prevSurfaces.length-1]),e.prevSurfaces.slice(e.prevSurfaces.length-1,1))}removeMaps(){let e=this.icn3d;e.icn3dui;for(let t=0,s=e.prevMaps.length;t0&&(e.mdl.remove(e.prevMaps[e.prevMaps.length-1]),e.prevMaps.slice(e.prevMaps.length-1,1))}removeLastEmmap(){let e=this.icn3d;e.icn3dui,e.prevEmmaps.length>0&&(e.mdl.remove(e.prevEmmaps[e.prevEmmaps.length-1]),e.prevEmmaps.slice(e.prevEmmaps.length-1,1))}removeLastPhimap(){let e=this.icn3d;e.icn3dui,e.prevPhimaps.length>0&&(e.mdl.remove(e.prevPhimaps[e.prevPhimaps.length-1]),e.prevPhimaps.slice(e.prevPhimaps.length-1,1))}}class rt{constructor(e){this.icn3d=e}addResidueLabels(e,t,s,i){let n=this.icn3d,l=n.icn3dui;if(l.bNode)return;let r=l.hashUtilsCls.intHash(n.hAtoms,e);t?void 0===n.labels.schematic&&(n.labels.schematic=[]):void 0===n.labels.residue&&(n.labels.residue=[]);let o="";for(let e in r){let s=n.atoms[e],r={},a=s.structure+"_"+s.chain+"_"+s.resi;if(!s.het&&("CA"===s.name||"O3'"===s.name||"O3*"===s.name)||n.water.hasOwnProperty(s.serial)||n.ions.hasOwnProperty(s.serial)||n.chemicals.hasOwnProperty(s.serial)&&a!==o){r.position=s.coord,r.bSchematic=0,t&&(r.bSchematic=1),r.text=l.utilsCls.residueName2Abbr(s.resn),i&&(r.text+=s.resi),r.size=18,r.factor=.3;let e=s.color.getHexString().toUpperCase();r.color=i?"black"!=n.opts.background?n.colorWhitebkgd:n.colorBlackbkgd:"CCCCCC"===e||"C8C8C8"===e?"#888888":"#"+e,r.background="#FFFFFF",t?n.labels.schematic.push(r):n.labels.residue.push(r)}o=a}n.hlObjectsCls.removeHlObjects()}addNonCarbonAtomLabels(e){let t=this.icn3d,s=t.icn3dui;if(s.bNode)return;let i=s.hashUtilsCls.intHash(t.hAtoms,e);void 0===t.labels.schematic&&(t.labels.schematic=[]);for(let e in i){let s=t.atoms[e];if(!t.residues.hasOwnProperty(s.structure+"_"+s.chain+"_"+s.resi))continue;if("C"===s.elem)continue;let i={};i.position=s.coord,i.bSchematic=1,i.text=s.elem,i.size=18,i.color="black"!=t.opts.background?t.colorWhitebkgd:s.color.getHexString(),i.background="#FFFFFF",t.labels.schematic.push(i)}t.hlObjectsCls.removeHlObjects()}addAtomLabels(e,t){let s=this.icn3d,i=s.icn3dui;if(i.bNode)return;let n=i.hashUtilsCls.intHash(s.hAtoms,e);n=i.hashUtilsCls.intHash(s.dAtoms,n),void 0===s.labels.residue&&(s.labels.residue=[]);for(let e in n){let i=s.atoms[e],n={};n.position=i.coord,n.bSchematic=0,n.text=t?i.elem:i.name.padEnd(2," "),n.size=18,t&&(n.bSchematic=!0);let l=i.color.getHexString().toUpperCase();n.color="black"!=s.opts.background?s.colorWhitebkgd:s.colorBlackbkgd,t&&(n.color="CCCCCC"===l||"C8C8C8"===l?"#888888":"#"+l),n.background="#FFFFFF",s.labels.residue.push(n)}s.hlObjectsCls.removeHlObjects()}}class ot{constructor(e){this.icn3d=e}onBeforeRender(e,t,s,i,n,l){let r=n.uniforms,o=[];if(r.objectId&&(r.objectId.value=SupportsReadPixelsFloat?this.id:this.id/255,o.push("objectId")),(r.modelViewMatrixInverse||r.modelViewMatrixInverseTranspose||r.modelViewProjectionMatrix||r.modelViewProjectionMatrixInverse)&&this.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,this.matrixWorld),r.modelViewMatrixInverse&&(r.modelViewMatrixInverse.value.copy(this.modelViewMatrix).invert(),o.push("modelViewMatrixInverse")),r.modelViewMatrixInverseTranspose&&(r.modelViewMatrixInverse?r.modelViewMatrixInverseTranspose.value.copy(r.modelViewMatrixInverse.value).transpose():r.modelViewMatrixInverseTranspose.value.copy(this.modelViewMatrix).invert().transpose(),o.push("modelViewMatrixInverseTranspose")),r.modelViewProjectionMatrix&&(s.updateProjectionMatrix(),r.modelViewProjectionMatrix.value.multiplyMatrices(s.projectionMatrix,this.modelViewMatrix),o.push("modelViewProjectionMatrix")),r.modelViewProjectionMatrixInverse){let e=new THREE.Matrix4;r.modelViewProjectionMatrix?(e.copy(r.modelViewProjectionMatrix.value),r.modelViewProjectionMatrixInverse.value.copy(e).invert()):(s.updateProjectionMatrix(),e.multiplyMatrices(s.projectionMatrix,this.modelViewMatrix),r.modelViewProjectionMatrixInverse.value.copy(e).invert()),o.push("modelViewProjectionMatrixInverse")}if(r.projectionMatrix&&(s.updateProjectionMatrix(),r.projectionMatrix.value.copy(s.projectionMatrix),o.push("projectionMatrix")),r.projectionMatrixInverse&&(s.updateProjectionMatrix(),r.projectionMatrixInverse.value.copy(s.projectionMatrix).invert(),o.push("projectionMatrixInverse")),o.length){let t=e.properties.get(n);if(t.program){let s=e.getContext(),i=t.program;s.useProgram(i.program);let n=i.getUniforms();o.forEach((function(e){n.setValue(s,e,r[e].value)}))}}}setParametersForShader(e){let t,s=this.icn3d,i=s.icn3dui.parasCls.backgroundColors[s.opts.background.toLowerCase()],n=2.5*s.maxD,l=4*s.maxD,r=void 0!==s.biomtMatrices&&s.biomtMatrices.length*s.cnt>s.maxatomcnt;"yes"===s.opts.slab?r?t=.1:void 0!==s.camMaxDFactorFog?(t=s.maxD*s.camMaxDFactorFog-10,n=2.5*s.maxD-t<0?0:2.5*s.maxD-t,l=4*s.maxD-t):t=s.maxD*s.camMaxDFactor:t=.1;let o=void 0!==e?e:1,a=s.shininess/100*.5;s.uniforms=THREE.UniformsUtils.merge([THREE.UniformsLib.common,{modelViewMatrix:{value:new THREE.Matrix4},modelViewMatrixInverse:{value:new THREE.Matrix4},modelViewMatrixInverseTranspose:{value:new THREE.Matrix4},modelViewProjectionMatrix:{value:new THREE.Matrix4},modelViewProjectionMatrixInverse:{value:new THREE.Matrix4},projectionMatrix:{value:new THREE.Matrix4},projectionMatrixInverse:{value:new THREE.Matrix4},diffuse:{type:"v3",value:[1,1,1]},emissive:{type:"v3",value:[.06,.06,.06]},roughness:{type:"f",value:.5},metalness:{type:"f",value:a},opacity:{type:"f",value:o},nearClip:{type:"f",value:t},ortho:{type:"f",value:0},shrink:{type:"f",value:.13},fogColor:{type:"v3",value:[i.r,i.g,i.b]},fogNear:{type:"f",value:n},fogFar:{type:"f",value:l},fogDensity:{type:"f",value:2}},THREE.UniformsLib.ambient,THREE.UniformsLib.lights]),s.defines={USE_COLOR:1,NEAR_CLIP:1,CAP:1},"yes"!==s.opts.fog||r||(s.defines.USE_FOG=1,"orthographic"===s.opts.camera&&(s.defines.FOG_EXP2=1)),s.bExtFragDepth&&(s.defines.USE_LOGDEPTHBUF_EXT=1)}drawImpostorShader(){this.icn3d.icn3dui.bNode||(this.setParametersForShader(),this.createImpostorShaderSphere("SphereImpostor"),this.createImpostorShaderCylinder("CylinderImpostor"))}getShader(e){this.icn3d.icn3dui;let t=$NGL_shaderTextHash[e];return t=t.replace(/#include\s+(\S+)/gim,(function(e,t){let s;return THREE.ShaderChunk.hasOwnProperty(t)&&(s=THREE.ShaderChunk[t]),s||""})),t}createImpostorShaderBase(e,t,s,i,n,l,r,o,a){let d=this.icn3d;d.icn3dui;let c=new THREE.ShaderMaterial({defines:d.defines,uniforms:d.uniforms,vertexShader:this.getShader(e+".vert"),fragmentShader:this.getShader(e+".frag"),depthTest:!0,depthWrite:!0,lights:!0});c.extensions.fragDepth=!0,"CylinderImpostor"==e?d.CylinderImpostorMaterial=c:"SphereImpostor"==e&&(d.SphereImpostorMaterial=c);let h,p,m=l*r,u=l*o,g=new(m>65535?Uint32Array:Uint16Array)(u);for(let e=0;e=0;t--){let s=a.children[t];s.onBeforeRender=e.impostorCls.onBeforeRender,s.frustumCulled=!1}l.add(a)}void 0!==e.mdl_ghost&&(a=e.mdl_ghost.clone(),this.applyMat(a,d),r.add(a));let c=e.center.clone();this.applyMat(c,d,!0),s.add(c),++t}e.mdl.add(n),e.mdlImpostor.add(l),e.mdl_ghost.add(r),void 0!==e.bSetInstancing&&e.bSetInstancing?(e.maxD=e.maxDAssembly,e.center=e.centerAssembly.clone(),e.applyCenterCls.setCenter(e.center),e.cameraCls.setCamera()):(e.maxD*=Math.sqrt(t),e.center=e.ParserUtilsCls.getMassCenter(s,t),e.maxDAssembly=e.maxD,e.centerAssembly=e.center.clone(),e.applyCenterCls.setCenter(e.center),e.cameraCls.setCamera()),e.bSetInstancing=!0}createInstancedGeometry(e){let t=this.icn3d,s=t.icn3dui,i=e.geometry,n=new THREE.InstancedBufferGeometry,l=[],r=[],o=[],a=[],d=[],c=[],h=[],p=[];if(t.bImpo&&"Cylinder"==e.type){t.instancedMaterial=this.getInstancedMaterial("CylinderInstancing");let e=s.hashUtilsCls.hashvalue2array(i.attributes.position1.array),r=s.hashUtilsCls.hashvalue2array(i.attributes.color.array),m=s.hashUtilsCls.hashvalue2array(i.attributes.position2.array),u=s.hashUtilsCls.hashvalue2array(i.attributes.color2.array),g=s.hashUtilsCls.hashvalue2array(i.index.array),f=s.hashUtilsCls.hashvalue2array(i.attributes.radius.array),b=s.hashUtilsCls.hashvalue2array(i.attributes.mapping.array);l=l.concat(e),o=o.concat(r),h=h.concat(m),p=p.concat(u),a=a.concat(g),d=d.concat(f),c=c.concat(b),n.setAttribute("position1",new THREE.BufferAttribute(new Float32Array(l),3)),n.setAttribute("color",new THREE.BufferAttribute(new Float32Array(o),3)),n.setAttribute("position2",new THREE.BufferAttribute(new Float32Array(h),3)),n.setAttribute("color2",new THREE.BufferAttribute(new Float32Array(p),3)),n.setAttribute("radius",new THREE.BufferAttribute(new Float32Array(d),1)),n.setAttribute("mapping",new THREE.BufferAttribute(new Float32Array(c),3)),n.setIndex(new THREE.BufferAttribute(new Uint32Array(a),1)),e=null,r=null,m=null,u=null,g=null,f=null,b=null}else if(t.bImpo&&"Sphere"==e.type){t.instancedMaterial=this.getInstancedMaterial("SphereInstancing");let e=s.hashUtilsCls.hashvalue2array(i.attributes.position.array),r=s.hashUtilsCls.hashvalue2array(i.attributes.color.array),h=s.hashUtilsCls.hashvalue2array(i.index.array),p=s.hashUtilsCls.hashvalue2array(i.attributes.radius.array),m=s.hashUtilsCls.hashvalue2array(i.attributes.mapping.array);l=l.concat(e),o=o.concat(r),a=a.concat(h),d=d.concat(p),c=c.concat(m),n.setAttribute("position",new THREE.BufferAttribute(new Float32Array(l),3)),n.setAttribute("color",new THREE.BufferAttribute(new Float32Array(o),3)),n.setAttribute("radius",new THREE.BufferAttribute(new Float32Array(d),1)),n.setAttribute("mapping",new THREE.BufferAttribute(new Float32Array(c),2)),n.setIndex(new THREE.BufferAttribute(new Uint32Array(a),1)),e=null,r=null,h=null,p=null,m=null}else{t.instancedMaterial=this.getInstancedMaterial("Instancing");let e=i.attributes.position?s.hashUtilsCls.hashvalue2array(i.attributes.position.array):[],d=i.attributes.normal?s.hashUtilsCls.hashvalue2array(i.attributes.normal.array):[],c=i.attributes.color?s.hashUtilsCls.hashvalue2array(i.attributes.color.array):[],h=i.index?s.hashUtilsCls.hashvalue2array(i.index.array):[];l=l.concat(e),r=r.concat(d),o=o.concat(c),a=a.concat(h);let p=[],m="CylinderGeometry"==i.type?1:0;for(let e=0,t=l.length/3;e0&&(e.dAtoms=t.hashUtilsCls.cloneHash(s)),e.bShowHighlight=!1}e.applyMapCls.removeSurfaces(),e.applyMapCls.applySurfaceOptions(),e.applyMapCls.removeMaps(),e.applyMapCls.applyMapOptions(),e.applyMapCls.removeEmmaps(),e.applyMapCls.applyEmmapOptions(),e.applyMapCls.removePhimaps(),e.axes=[],e.pc1&&e.axesCls.setPc1Axes(),e.drawCls.draw(),e.bShowHighlight=!0,e.opts.rotationcenter="molecule center"}alternateWrapper(){let e=this.icn3d;e.icn3dui,e.bAlternate=!0,this.alternateStructures(),e.bAlternate=!1}}class ct{constructor(e){this.icn3d=e}draw(e){let t=this.icn3d,s=t.icn3dui;if(!t.bRender||t.hAtoms&&0!=Object.keys(t.hAtoms)||(t.hAtoms=s.hashUtilsCls.cloneHash(t.atoms)),t.sceneCls.rebuildScene(),t.bImpo&&t.impostorCls.drawImpostorShader(),t.setColorCls.applyPrevColor(),void 0!==t.biomtMatrices&&t.biomtMatrices.length>1)if(t.bAssembly&&1==Object.keys(t.structures).length&&(void 0===s.cfg.mmdbid&&1==s.cfg.bu||void 0!==s.cfg.mmdbid&&1==s.cfg.bu&&Object.keys(t.atoms).length*t.biomtMatrices.length>t.maxatomcnt))t.instancingCls.drawSymmetryMates();else{let e=!0;t.applyCenterCls.centerSelection(void 0,e)}let i=void 0!==t.hAtoms?Object.keys(t.hAtoms).length:0;if(i>0&&i0){e.children[0].scale.z=t[0].distance,t[0].point.sub(r.mdl.position);let s=r.rayThreshold,i=r.rayCls.getAtomsFromPosition(t[0].point,s);for(;!i&&s<10;)s+=.5,i=r.rayCls.getAtomsFromPosition(t[0].point,s);i&&(r.pAtom=i,this.showPickingVr(r.pk,i))}}}}catch(e){}}showPickingVr(e,t){let s=this.icn3d;if(s.icn3dui,e||(e=2),1===e)s.hAtoms[t.serial]=1;else if(2===e){let e=t.structure+"_"+t.chain+"_"+t.resi;s.hAtoms=s.residues[e]}else if(3===e)s.hAtoms=s.pickingCls.selectStrandHelixFromAtom(t);else if(4===e)s.hAtoms=s.pickingCls.select3ddomainFromAtom(t);else if(5===e){let e=t.structure+"_"+t.chain;s.hAtoms=s.chains[e]}2===e?s.residueLabelsCls.addResidueLabels(s.hAtoms,void 0,void 0,!0):1===e&&s.residueLabelsCls.addAtomLabels(atoms),s.setOptionCls.setStyle("proteins",t.style)}render_base(){let e=this.icn3d,t=e.icn3dui,s=this;if(t.bNode)return;let i=e.bControlGl&&!t.bNode?window.cam:e.cam;if(e.directionalLight){let t=new THREE.Quaternion;t.setFromUnitVectors(new THREE.Vector3(0,0,e.cam_z).normalize(),i.position.clone().normalize()),e.directionalLight.position.copy(e.lightPos.clone().applyQuaternion(t).normalize()),e.directionalLight2.position.copy(e.lightPos2.clone().applyQuaternion(t).normalize()),e.directionalLight3.position.copy(e.lightPos3.clone().applyQuaternion(t).normalize())}if(e.bVr||e.renderer.setPixelRatio(window.devicePixelRatio),e.bVr){let t=.04;if(e.controllers){let i=this.updateGamepadState();for(let n=0,l=e.controllers.length;n{const i=e.gamepad.axes;let r=parseInt(1e3*i[t]),o=parseInt(-1e3*i[s]);n.push(r),l.push(o)})),{xArray:n,yArray:l}}return{xArray:[0,0],yArray:[0,0]}}}class ht{constructor(e){this.icn3d=e}getAtomsWithinAtom(e,t,s,i,n,l,r){let o=this.icn3d;o.icn3dui;let a=this.getNeighboringAtoms(e,t,s,r);i&&(o.resid2Residhash={});let d={};for(let e in t){let c,h,p=o.atoms[e],m=p.structure+"_"+p.chain+"_"+p.resi;for(let e in o.residues[m])if(o.atoms[e]&&("CA"===o.atoms[e].name&&"C"===o.atoms[e].elem||"O3'"===o.atoms[e].name||"O3*"===o.atoms[e].name)){c=o.atoms[e];break}void 0===c&&(c=p),i&&(h=p.resn+" $"+p.structure+"."+p.chain+":"+p.resi,void 0===o.resid2Residhash[h]&&(o.resid2Residhash[h]={}));let u=p.structure+"_"+p.chain+"_"+p.resi;for(let e in a){let m=a[e];if(!o.crossstrucinter&&p.structure!=m.structure)continue;if(!r&&m.serial in t)continue;if(o.bOpm&&"DUM"===m.resn)continue;let g=m.coord.distanceTo(p.coord);if(go?r:o,d=Math.sqrt(a),c=(d+s)*(d+s),h={};for(let r in e){let e=n.atoms[r];!i&&t.hasOwnProperty(e.serial)||(this.bOpm&&"DUM"===e.resn||e.coord.xl[1][0]+s||e.coord.yl[1][1]+s||e.coord.zl[1][2]+s||(e.coord.x-l[2][0])*(e.coord.x-l[2][0])+(e.coord.y-l[2][1])*(e.coord.y-l[2][1])+(e.coord.z-l[2][2])*(e.coord.z-l[2][2])e.coord.x?n:e.coord.x,l=l>e.coord.y?l:e.coord.y,r=r>e.coord.z?r:e.coord.z}return[[t,s,i],[n,l,r],[o/c,a/c,d/c]]}hideContact(){let e=this.icn3d;e.icn3dui,e.opts.contact="no",void 0===e.lines&&(e.lines={}),e.lines.contact=[],e.contactpnts=[];for(let t in e.atoms)e.atoms[t].style2="nothing";for(let t in e.sidec)e.hAtoms.hasOwnProperty(t)&&(e.atoms[t].style2=e.opts.sidec);for(let t in e.water)e.hAtoms.hasOwnProperty(t)&&(e.atoms[t].style=e.opts.water)}}class pt{constructor(e){this.icn3d=e}isHbondDonorAcceptor(e){let t=this.icn3d;if(t.icn3dui,"N"==e.name&&!e.het||"N"==e.elem&&"Arg"==e.resn||"N"==e.elem&&"Asn"==e.resn||"N"==e.elem&&"Gln"==e.resn||"N"==e.elem&&"Lys"==e.resn||"N"==e.elem&&"Trp"==e.resn)return"donor";if("O"==e.name&&!e.het||"S"==e.elem&&"Met"==e.resn||"O"==e.elem&&"Asn"==e.resn||"O"==e.elem&&"Asp"==e.resn||"O"==e.elem&&"Gln"==e.resn||"O"==e.elem&&"Glu"==e.resn)return"acceptor";if("S"==e.elem&&"Cys"==e.resn||"N"==e.elem&&"His"==e.resn||"O"==e.elem&&"Ser"==e.resn||"O"==e.elem&&"Thr"==e.resn||"O"==e.elem&&"Tyr"==e.resn)return"both";if("Pro"==e.resn)return"none";if("N"==e.elem){if("Asn"==e.resn||"Gln"==e.resn)return"both";let s=0,i=0;for(let i=0,n=e.bonds.length;i1?"ring":"donor":"none"}if("O"==e.elem&&1==e.bonds.length){if("Asn"==e.resn||"Gln"==e.resn)return"both";for(let s=0,i=e.bonds.length;s=2?"acceptor":"both"}if("O"==e.elem&&2==e.bonds.length){for(let s=0,i=e.bonds.length;s1);++t)"H"!=s.atoms[e.bonds[t]].elem&&(i=s.atoms[e.bonds[t]],l[r++].subVectors(s.atoms[e.bonds[t]].coord,e.coord));if(1===r)for(let t=0,n=i.bonds.length;t1);++t)"H"!=s.atoms[i.bonds[t]].elem&&s.atoms[i.bonds[t]].serial!=e.serial&&l[r++].subVectors(s.atoms[i.bonds[t]].coord,e.coord);if(2!==r)return;let o=l[0].cross(l[1]);return Math.abs(Math.PI/2-o.angleTo(n))}isValidHbond(e,t,s){let i=this.icn3d;i.icn3dui;let n,l,r=this.isHbondDonorAcceptor(e),o=this.isHbondDonorAcceptor(t),a=50*Math.PI/180,d=50*Math.PI/180,c=90*Math.PI/180,h=30*Math.PI/180;if("donor"==r&&("acceptor"==o||"both"==o||"ring"==o)||"acceptor"==o&&("donor"==r||"both"==r||"ring"==r))n=e,l=t;else if("acceptor"==r&&("donor"==o||"both"==o||"ring"==o)||"donor"==o&&("acceptor"==r||"both"==r||"ring"==r))l=e,n=t;else{if("both"!=r&&"ring"!=r||"both"!=o&&"ring"!=o)return!1;n=e,l=t,i.nucleotides.hasOwnProperty(e.serial)&&i.nucleotides.hasOwnProperty(t.serial)&&("ring"==r||"ring"==o)||(e.het||t.het)&&"ring"==r&&"ring"==o||(h=90*Math.PI/180)}let p=this.calcAngles(n,l),m=90*Math.PI/180;for(let e=0,t=p.length;ed)return!1;let u=this.calcPlaneAngle(n,l);if(void 0!==u&&u>h)return!1;let g=this.calcAngles(l,n),f=90*Math.PI/180;for(let e=0,t=g.length;ea)return!1;let b=this.calcPlaneAngle(l,n);return!(void 0!==b&&b>c)}calculateChemicalHbonds(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(0===Object.keys(e).length||0===Object.keys(t).length)return;r.resid2Residhash={};let a,d,c={},h=s*s;for(let t in e){let s=e[t],n=i?"LYS"===s.resn&&"N"===s.elem&&"N"!==s.name||"ARG"===s.resn&&("NH1"===s.name||"NH2"===s.name)||("GLU"===s.resn||"ASP"===s.resn)&&"O"===s.elem&&"O"!==s.name||s.het&&("N"===s.elem||"O"===s.elem||"S"===s.elem):"N"===s.elem||"O"===s.elem||"S"===s.elem&&(s.het||"Cys"===s.resn||"Met"===s.resn);n=r.bOpm?n&&"DUM"!==s.resn:n,n&&(a=s.structure+"_"+s.chain+"_"+s.resi,d=a+"_"+s.name,c[d]=s)}let p={},m={},u=.5,g=-27.888,f={};for(let e in t){let b=t[e],C=i?"LYS"===b.resn&&"N"===b.elem&&"N"!==b.name||"ARG"===b.resn&&("NH1"===b.name||"NH2"===b.name)||("GLU"===b.resn||"ASP"===b.resn)&&"O"===b.elem&&"O"!==b.name||b.het&&("N"===b.elem||"O"===b.elem||"S"===b.elem):"N"===b.elem||"O"===b.elem||"S"===b.elem&&(b.het||"Cys"===b.resn||"Met"===b.resn);if(C=r.bOpm?C&&"DUM"!==b.resn:C,C){a=b.structure+"_"+b.chain+"_"+b.resi,d=a+"_"+b.name;let e=b.resn+" $"+b.structure+"."+b.chain+":"+b.resi+"@"+b.name;void 0===r.resid2Residhash[e]&&(r.resid2Residhash[e]={});for(let t in c){if(i&&!(("LYS"!==b.resn&&"ARG"!==b.resn||"LYS"!==c[t].resn&&"ARG"!==c[t].resn)&&("GLU"!==b.resn&&"ASP"!==b.resn||"GLU"!==c[t].resn&&"ASP"!==c[t].resn)))continue;if(!r.crossstrucinter&&b.structure!=c[t].structure)continue;if(a==t.substr(0,t.lastIndexOf("_")))continue;let d=Math.abs(b.coord.x-c[t].coord.x);if(d>s)continue;let C=Math.abs(b.coord.y-c[t].coord.y);if(C>s)continue;let y=Math.abs(b.coord.z-c[t].coord.z);if(y>s)continue;let v=d*d+C*C+y*y;if(v>h)continue;if(!r.proteins.hasOwnProperty(b.serial)||!r.proteins.hasOwnProperty(c[t].serial)||"N"!==b.name&&"O"!==b.name||"O"!==c[t].name&&"N"!==c[t].name){if(!this.isValidHbond(b,c[t],s))continue}else{if(b.name===c[t].name)continue;if(b.structure==c[t].structure&&b.chain==c[t].chain&&Math.abs(b.resi-c[t].resi)<=1)continue;let e,i="N"===b.name?b:c[t],n="O"===b.name?b:c[t];if("Pro"===i.resn)continue;if(void 0===i.hcoord){if(!this.isValidHbond(b,c[t],s))continue}else{let s,l=i.hcoord,o=i.coord,a=n.structure+"_"+n.chain+"_"+n.resi;for(let e in r.residues[a])if("C"===r.atoms[e].name){s=r.atoms[e];break}if(!s)continue;let d=s.coord,h=n.coord,p=l.distanceTo(h),m=l.distanceTo(d),f=o.distanceTo(d),C=o.distanceTo(h);e=p2||f[c[t].serial]>2)continue;void 0===f[b.serial]?f[b.serial]=1:++f[b.serial],void 0===f[c[t].serial]?f[c[t].serial]=1:++f[c[t].serial],"graph"!==n&&(i?(r.saltbridgepnts.push({serial:b.serial,coord:b.coord}),r.saltbridgepnts.push({serial:c[t].serial,coord:c[t].coord})):(r.hbondpnts.push({serial:b.serial,coord:b.coord}),r.hbondpnts.push({serial:c[t].serial,coord:c[t].coord})));let w=c[t].structure+"_"+c[t].chain+"_"+c[t].resi;p=o.hashUtilsCls.unionHash(p,r.residues[a]),p=o.hashUtilsCls.unionHash(p,r.residues[w]),m[a]=1,m[w]=1;let _=c[t].resn+" $"+c[t].structure+"."+c[t].chain+":"+c[t].resi+"@"+c[t].name,S=a+"_"+b.resn+","+w+"_"+c[t].resn;void 0!==r.resids2interAll[S]&&void 0!==r.resids2interAll[S].ionic&&r.resids2interAll[S].ionic.hasOwnProperty(e+","+_)||(r.resid2Residhash[e][_]=v.toFixed(1),l||(void 0===r.resids2inter[S]&&(r.resids2inter[S]={}),void 0===r.resids2inter[S].hbond&&(r.resids2inter[S].hbond={}),r.resids2inter[S].hbond[e+","+_]=v.toFixed(1)),void 0===r.resids2interAll[S]&&(r.resids2interAll[S]={}),void 0===r.resids2interAll[S].hbond&&(r.resids2interAll[S].hbond={}),r.resids2interAll[S].hbond[e+","+_]=v.toFixed(1))}}}let b=Object.keys(m);if("graph"!==n)for(let e=0,t=b.length;en)return!1;let c=Math.abs(e.coord.y-t.coord.y);if(c>n)return!1;let h=Math.abs(e.coord.z-t.coord.z);if(h>n)return!1;let p=d*d+c*c+h*h;if(p>l)return!1;"graph"!==s&&("halogen"==i?(a.halogenpnts.push({serial:e.serial,coord:e.coord}),a.halogenpnts.push({serial:t.serial,coord:t.coord})):"pi-cation"==i?(a.picationpnts.push({serial:e.serial,coord:e.coord}),a.picationpnts.push({serial:t.serial,coord:t.coord})):"pi-stacking"==i&&(a.pistackingpnts.push({serial:e.serial,coord:e.coord}),a.pistackingpnts.push({serial:t.serial,coord:t.coord})));let m=t.resn+" $"+t.structure+"."+t.chain+":"+t.resi+"@"+t.name;a.resid2Residhash[r][m]=p.toFixed(1);let u=e.structure+"_"+e.chain+"_"+e.resi+"_"+e.resn+","+t.structure+"_"+t.chain+"_"+t.resi+"_"+t.resn;return o||(void 0===a.resids2inter[u]&&(a.resids2inter[u]={}),void 0===a.resids2inter[u][i]&&(a.resids2inter[u][i]={}),a.resids2inter[u][i][r+","+m]=p.toFixed(1)),void 0===a.resids2interAll[u]&&(a.resids2interAll[u]={}),void 0===a.resids2interAll[u][i]&&(a.resids2interAll[u][i]={}),a.resids2interAll[u][i][r+","+m]=p.toFixed(1),!0}getRingNormal(e){if(this.icn3d.icn3dui,e.length<3)return;let t=e[0].clone().sub(e[1]),s=e[1].clone().sub(e[2]);return t.cross(s).normalize()}getAromaticRings(e,t,s){let i=this.icn3d;i.icn3dui;let n=[],l=[],r=[],o=[];if("nucleotide"==s){let s=new THREE.Vector3,a=new THREE.Vector3;if("A"==e.trim().toUpperCase()||"DA"==e.trim().toUpperCase()||"G"==e.trim().toUpperCase()||"DG"==e.trim().toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"N1"==t.name||"C2"==t.name||"N3"==t.name||"C6"==t.name?(s.add(t.coord),r.push(t.coord)):"C4"==t.name||"C5"==t.name?(s.add(t.coord),a.add(t.coord),r.push(t.coord),o.push(t.coord)):"N7"!=t.name&&"C8"!=t.name&&"N9"!=t.name||(a.add(t.coord),o.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r))),5==o.length&&(a.multiplyScalar(.2),n.push(a),l.push(this.getRingNormal(o)))}else if("C"==e.trim().toUpperCase()||"DC"==e.trim().toUpperCase()||"T"==e.trim().toUpperCase()||"DT"==e.trim().toUpperCase()||"U"==e.trim().toUpperCase()||"DU"==e.trim().toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"N1"==t.name||"C2"==t.name||"N3"==t.name||"C6"==t.name?(s.add(t.coord),r.push(t.coord)):"C4"!=t.name&&"C5"!=t.name||(s.add(t.coord),r.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r)))}}else if("protein"==s){let s=new THREE.Vector3,a=new THREE.Vector3;if("PHE"==e.toUpperCase()||"TYR"==e.toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"CG"!=t.name&&"CD1"!=t.name&&"CE1"!=t.name&&"CZ"!=t.name&&"CE2"!=t.name&&"CD2"!=t.name||(s.add(t.coord),r.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r)))}else if("HIS"==e.toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"CG"!=t.name&&"ND1"!=t.name&&"CE1"!=t.name&&"NE2"!=t.name&&"CD2"!=t.name||(s.add(t.coord),r.push(t.coord))}5==r.length&&(s.multiplyScalar(.2),n.push(s),l.push(this.getRingNormal(r)))}else if("TRP"==e.toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"CZ2"==t.name||"CH2"==t.name||"CZ3"==t.name||"CE3"==t.name?(s.add(t.coord),r.push(t.coord)):"CD2"==t.name||"CE2"==t.name?(s.add(t.coord),a.add(t.coord),r.push(t.coord),o.push(t.coord)):"CG"!=t.name&&"CD1"!=t.name&&"NE1"!=t.name||(a.add(t.coord),o.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r))),5==o.length&&(a.multiplyScalar(.2),n.push(a),l.push(this.getRingNormal(o)))}}return{piPosArray:n,normalArray:l}}dfs_cycle(e,t,s){let i=this.icn3d;if(i.icn3dui,2==i.ring_color[e])return s;if(1==i.ring_color[e]){s++;let n=t;for(i.ring_mark[n]=s;n!=e;)n=i.ring_par[n],i.ring_mark[n]=s;return s}if(i.ring_par[e]=t,i.ring_color[e]=1,void 0!==i.atoms[e])for(let t=0,n=i.atoms[e].bonds.length;t=3&&o<=6&&a[0]&&a[1]&&a[2]&&a[3]){let i=a[0].clone().sub(a[1]).normalize(),r=a[1].clone().sub(a[2]).normalize(),d=a[2].clone().sub(a[3]).normalize(),c=i.cross(r).normalize(),h=c.dot(d);if(Math.abs(h)<.052){l.multiplyScalar(1/o);let i=t.atoms[n];s[e+"_pi"+n]={resn:i.resn,name:"pi"+n,coord:l,serial:i.serial,structure:i.structure,chain:i.chain,resi:i.resi,normal:c}}}}return s}hideHalogenPi(){let e=this.icn3d;e.icn3dui,e.opts.halogen="no",e.opts["pi-cation"]="no",e.opts["pi-stacking"]="no",void 0===e.lines&&(e.lines={}),e.lines.halogen=[],e.lines["pi-cation"]=[],e.lines["pi-stacking"]=[],e.halogenpnts=[],e.picationpnts=[],e.pistackingpnts=[];for(let t in e.atoms)e.atoms[t].style2="nothing";for(let t in e.sidec)e.hAtoms.hasOwnProperty(t)&&(e.atoms[t].style2=e.opts.sidec);for(let t in e.water)e.hAtoms.hasOwnProperty(t)&&(e.atoms[t].style=e.opts.water)}}class ut{constructor(e){this.icn3d=e}calculateIonicInteractions(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(0===Object.keys(e).length||0===Object.keys(t).length)return;r.resid2Residhash={};let a,d,c={},h={},p=s*s;for(let t in e){let s=e[t];if("ARG"===s.resn&&"NH2"===s.name||"GLU"===s.resn&&"OE2"===s.name||"ASP"===s.resn&&"OD2"===s.name)continue;let i=("LYS"===s.resn||"HIS"===s.resn)&&"N"===s.elem&&"N"!==s.name||"ARG"===s.resn&&("NH1"===s.name||"NH2"===s.name)||s.het&&-1!==o.parasCls.cationsTrimArray.indexOf(s.elem)||s.het&&"N"===s.elem&&1==s.bonds.length,n=this.isAnion(s);i=r.bOpm?i&&"DUM"!==s.resn:i,n=r.bOpm?n&&"DUM"!==s.resn:n,(i||n)&&(a=s.structure+"_"+s.chain+"_"+s.resi,d=a+"_"+s.name,i&&(c[d]=s),n&&(h[d]=s))}let m={},u={};for(let e in t){let i=t[e];if("ARG"===i.resn&&"NH2"===i.name||"GLU"===i.resn&&"OE2"===i.name||"ASP"===i.resn&&"OD2"===i.name)continue;let g=("LYS"===i.resn||"HIS"===i.resn)&&"N"===i.elem&&"N"!==i.name||"ARG"===i.resn&&("NH1"===i.name||"NH2"===i.name)||i.het&&-1!==o.parasCls.cationsTrimArray.indexOf(i.elem),f=this.isAnion(i);if(g=r.bOpm?g&&"DUM"!==i.resn:g,f=r.bOpm?f&&"DUM"!==i.resn:f,g||f){a=i.structure+"_"+i.chain+"_"+i.resi,d=a+"_"+i.name;let e=i.resn+" $"+i.structure+"."+i.chain+":"+i.resi+"@"+i.name;void 0===r.resid2Residhash[e]&&(r.resid2Residhash[e]={});let t={};g?t=h:f&&(t=c);let b,C=i.structure+"_"+i.chain+"_"+i.resi;g&&"ARG"===i.resn&&"NH1"===i.name?b=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[C],"NH2"):f&&"GLU"===i.resn&&"OE1"===i.name?b=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[C],"OE2"):f&&"ASP"===i.resn&&"OD1"===i.name&&(b=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[C],"OD2"));let y=void 0===b?i.coord:i.coord.clone().add(b.coord).multiplyScalar(.5);for(let d in t){if(a==d.substr(0,d.lastIndexOf("_")))continue;if(!r.crossstrucinter&&i.structure!=t[d].structure)continue;let c,h=t[d].structure+"_"+t[d].chain+"_"+t[d].resi;f&&"ARG"===t[d].resn&&"NH1"===t[d].name?c=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[h],"NH2"):g&&"GLU"===t[d].resn&&"OE1"===t[d].name?c=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[h],"OE2"):g&&"ASP"===t[d].resn&&"OD1"===t[d].name&&(c=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[h],"OD2"));let b=void 0===c?t[d].coord:t[d].coord.clone().add(c.coord).multiplyScalar(.5),C=Math.abs(y.x-b.x);if(C>s)continue;let v=Math.abs(y.y-b.y);if(v>s)continue;let w=Math.abs(y.z-b.z);if(w>s)continue;let _=C*C+v*v+w*w;if(_>p)continue;"graph"!==n&&(r.saltbridgepnts.push({serial:i.serial,coord:y}),r.saltbridgepnts.push({serial:t[d].serial,coord:b}));let S=t[d].structure+"_"+t[d].chain+"_"+t[d].resi;m=o.hashUtilsCls.unionHash(m,r.residues[a]),m=o.hashUtilsCls.unionHash(m,r.residues[S]),u[a]=1,u[S]=1;let A=t[d].resn+" $"+t[d].structure+"."+t[d].chain+":"+t[d].resi+"@"+t[d].name;r.resid2Residhash[e][A]=_.toFixed(1);let x=a+"_"+i.resn+","+S+"_"+t[d].resn;l||(void 0===r.resids2inter[x]&&(r.resids2inter[x]={}),void 0===r.resids2inter[x].ionic&&(r.resids2inter[x].ionic={}),r.resids2inter[x].ionic[e+","+A]=_.toFixed(1)),void 0===r.resids2interAll[x]&&(r.resids2interAll[x]={}),void 0===r.resids2interAll[x].ionic&&(r.resids2interAll[x].ionic={}),r.resids2interAll[x].ionic[e+","+A]=_.toFixed(1)}}}let g=Object.keys(u);if("graph"!==n)for(let e=0,t=g.length;e1?1/(n-1):1;for(let n in e){let e=t.atoms[n];e.color=e.het?s.parasCls.atomColors[e.elem]||s.parasCls.defaultAtomColor:s.parasCls.thr().setHSL(3/4*(1-i++*l),1,.45),t.atomPrevColors[n]=e.color}}colorRainbow(e){let t=this.icn3d,s=t.icn3dui,i=0,n=0;e=s.hashUtilsCls.intHash(e,t.hAtoms);for(let s in e){t.atoms[s].het||++n}let l=n>1?1/(n-1):1;for(let n in e){let e=t.atoms[n];e.color=e.het?s.parasCls.atomColors[e.elem]||s.parasCls.defaultAtomColor:s.parasCls.thr().setHSL(3/4*i++*l,1,.45),t.atomPrevColors[n]=e.color}}setColorAcrossSets(e,t){let s=this.icn3d,i=s.icn3dui,n=0,l=e.length,r=l>1?1/(l-1):1;for(let l=0,o=e.length;l0)this.setMmdbChainColor();else{let e=-1,s="",l=n.parasCls.stdChainColors.length;for(let r in t){let t=i.atoms[r];t.chain!=s&&(++e,e%=l),t.het?(t.color=n.parasCls.atomColors[t.elem],i.atomPrevColors[r]=t.color):(t.color=n.parasCls.stdChainColors[e],Object.keys(i.chainsColor).length>0&&this.updateChainsColor(t),i.atomPrevColors[r]=t.color),s=t.chain}}break;case"domain":s=0,l=0;let m=Object.keys(i.tddomains);l=m.length,r=l>1?1/(l-1):1;for(let e=0,t=m.length;e1?1/(l-1):1;for(let e=0;e Defined Sets", and try it again.');break;case"secondary structure green":i.sheetcolor="green";for(let e in t){let t=i.atoms[e];t.color=t.het?n.parasCls.atomColors[t.elem]||n.parasCls.defaultAtomColor:n.parasCls.ssColors[t.ss]||n.parasCls.thr(16711935),i.atomPrevColors[e]=t.color}break;case"secondary structure yellow":case"secondary structure":i.sheetcolor="yellow";for(let e in t){let t=i.atoms[e];t.color=t.het?n.parasCls.atomColors[t.elem]||n.parasCls.defaultAtomColor:n.parasCls.ssColors2[t.ss]||n.parasCls.thr(16711935),i.atomPrevColors[e]=t.color}break;case"secondary structure spectrum":s=0,l=0;let u,g,f=[],b=-9999;for(let e in t){if(!i.proteins.hasOwnProperty(e))continue;let t=i.atoms[e];-9999==b&&(u=parseInt(e)),-9999!=b&&(t.ss!=g.ss||Math.abs(t.resi-g.resi)>1||t.ssbegin&&g.ssend)&&("coil"==g.ss||f.push([u,b]),u=e),b=parseInt(e),g=t}"coil"==g.ss||f.push([u,b]),l=f.length,r=l>1?1/(l-1):1;for(let e=0,t=f.length;e100&&(e=100);let r=(i.middB-e)*i.spanBinv1,o=(e-i.middB)*i.spanBinv2;e=90?t.color=n.parasCls.thr().setRGB(0,.325,.839):e>=70&&e<90?t.color=n.parasCls.thr().setRGB(.396,.572,.953):e>=50&&e<70?t.color=n.parasCls.thr().setRGB(1,.859,.075):e<50&&(t.color=n.parasCls.thr().setRGB(1,.49,.271))}i.atomPrevColors[e]=t.color}break;case"b factor":i.middB=50,i.spanBinv1=.02,i.spanBinv2=.02;for(let e in t){let t=i.atoms[e];if(void 0===t.b||isNaN(t.b)||0==parseInt(1e3*t.b))t.color=n.parasCls.thr().setRGB(0,1,0);else{let e=t.b;e>100&&(e=100),e=t.structure.substr(0,4)!=i.defaultPdbId&&t.structure.length>5?100-e:e;let s=(i.middB-e)*i.spanBinv1,l=(e-i.middB)*i.spanBinv2;t.color=et.b&&(o=t.b),a5?100-t.b:t.b,s=i.bfactorArray.indexOf(e)/C;t.color=s<.5?n.parasCls.thr().setRGB(2*s,2*s,1):n.parasCls.thr().setRGB(1,2*(1-s),2*(1-s))}i.atomPrevColors[e]=t.color}break;case"area":if(void 0===i.resid2area){let e=n.hashUtilsCls.cloneHash(i.hAtoms);i.hAtoms=n.hashUtilsCls.cloneHash(i.atoms),i.bCalcArea=!0,i.opts.surface="solvent accessible surface",i.applyMapCls.applySurfaceOptions(),i.bCalcArea=!1,i.hAtoms=n.hashUtilsCls.cloneHash(e)}let y=void 0!==i.midpercent?i.midpercent:35;i.spanBinv1=.02,i.spanBinv2=.02;for(let e in t){let t=i.atoms[e],s=t.structure+"_"+t.chain+"_"+t.resi+"_"+t.resn,l=n.parasCls.residueArea.hasOwnProperty(t.resn)?i.resid2area[s]/n.parasCls.residueArea[t.resn]*100:y;l>100&&(l=100);let r=(y-l)*i.spanBinv1,o=(l-y)*i.spanBinv2;t.color=l

    ";if("atom"==e){let e=["proteins","nucleotides","chemicals","ions","water"];for(let i=0,n=e.length;i[e,s.parasCls.hydrophobicValues[e]]));r.sort(((e,t)=>parseFloat(e[1])-parseFloat(t[1])));var o=r.map((e=>[e[0],Object.keys(n[e[0]])[0]]));l+="
    ","normalized hydrophobic"==e?(l+="Dark green (W, F, Y, L, I, C, M): Hydrophobic
    ",l+="Light green (G, V, S, T, A, N, P, Q): Polar
    ",l+="Grey: Charged, not hydrophobic

    "):(l+="Green (W, F, Y, L, I, C, M): Hydrophobic
    ",l+="Yellow (G, V, S, T, A, N, P, Q): Polar
    ",l+="Red: Negatively Charged
    ",l+="Blue: Positively Charged

    ");let a=0;for(let e of o)s.parasCls.residueAbbrev[e[0]]&&(l+="
    ",l+="
    ",l+=s.parasCls.residueAbbrev[e[0]]+"
    ",a%4==3&&(l+="
    "),++a);l+="
    "}else"b factor"==e?(l+="
    B factor quantitates the uncertainty for each atom. A high B factor reflects that the position is less certain.

    ",l+=s.htmlCls.clickMenuCls.setLegendHtml()):"confidence"==e?l+=s.htmlCls.clickMenuCls.setLegendHtml(!0):(l="",i=!0);$("#"+s.pre+"dl_legend").html(l),s.htmlCls.dialogCls.openDlg("dl_legend","Color Legend"),i&&window.dialog&&window.dialog.dialog("close")}getColorLegendForElem(e,t){let s=this.icn3d,i=s.icn3dui,n="",l={};for(let e in t){let t=s.atoms[e],i=void 0===t||void 0===t.color||"FFFFFF"===t.color.getHexString().toUpperCase()?"DDDDDD":t.color.getHexString();void 0===l[t.elem]&&(l[t.elem]={}),l[t.elem][i]=1}if(Object.keys(l).length>0){n+=""+e+"
    ";let t=Object.keys(l).sort();for(let e=0,s=t.length;e";for(let e in l[s])n+="
    ";n+=i.parasCls.atomnames[s.toUpperCase()]+"

    "}n+="
    "}return n}getRes2color(e,t){let s=this.icn3d,i=s.icn3dui,n={},l=s.firstAtomObjCls.getResiduesFromAtoms(e);for(let e in l){let l=s.residues[e],r=s.firstAtomObjCls.getFirstAtomObj(l),o=t?r.resn:i.parasCls.residueAbbrev[r.resn],a=void 0===r||void 0===r.color||"FFFFFF"===r.color.getHexString().toUpperCase()?"DDDDDD":r.color.getHexString();null!=o&&(void 0===n[o]&&(n[o]={}),n[o][a]=1)}return n}getColorLegendForResidue(e){this.icn3d.icn3dui;let t="",s=this.getRes2color(e);if(Object.keys(s).length>0){t+="
    ";let e=Object.keys(s).sort(),i="",n=0;for(let l=0,r=e.length;l";for(let e in s[o])r+="
    ";r+=o+"
    ",n%4==3&&(r+="
    "),-1!=o.indexOf("(")?(t+=r,++n):i+=r}i&&(t+="
    "+i),t+="
    "}return t}getColorLegendForCharge(e){let t=this.icn3d;t.icn3dui;let s="",i=t.firstAtomObjCls.getResiduesFromAtoms(e),n={};for(let e in i){let s=t.residues[e],i=t.firstAtomObjCls.getFirstAtomObj(s);"ARG"==i.resn||"LYS"==i.resn?n.Positive=1:"HIS"==i.resn?n["Partial-Positive"]=1:"ASP"==i.resn||"GLU"==i.resn||t.nucleotides[i.serial]?n.Negative=1:n.Neutral=1}const l={Positive:"0000ff","Partial-Positive":"8080ff",Negative:"ff0000",Neutral:"888888"};let r=["Positive","Partial-Positive","Negative","Neutral"];s+="
    ";for(let e=0,t=r.length;e",s+="
    ",s+=t,s+="
    ")}return s+="
    (Charges are at pH 7)",s+="
    ",s}getColorLegendForIgstrand(e){this.icn3d.icn3dui;let t="";const s={"A^ Strand":"FF00FF","A Strand":"663399","A* Strand":"FFC0CB","A Strand":"9370db","B Strand":"ba55d3","C Strand":"0000FF","C' Strand":"6495ED","C'' Strand":"006400","D Strand":"00FF00","E Strand":"FFFF00","F Strand":"FFA500","G Strand":"FF0000","G* Strand":"8B0000",Loop:"CCCCCC"};t+="
    ";for(let e in s){t+="",t+="
    ",t+=e,t+="

    "}return t+="
    ",t}}class yt{constructor(e){this.icn3d=e}async showCddSiteAll(){let e=this.icn3d,t=e.icn3dui,s=this;e.chainid2pssmid={};let i=$.map(e.protein_chainid,(function(e){return e})),n=Object.keys(e.protein_chainid),l="https://www.ncbi.nlm.nih.gov/Structure/cdannots/cdannots.fcgi?fmt&frclive&live=lcl&queries="+i;if(1==Object.keys(e.structures).length&&(t.cfg.mmtfid||t.cfg.pdbid||t.cfg.opmid||t.cfg.mmdbid||t.cfg.gi||t.cfg.uniprotid||t.cfg.blast_rep_id||t.cfg.cid||t.cfg.mmcifid)||2==Object.keys(e.structures).length&&t.cfg.align){let e={};try{e.value=await t.getAjaxPromise(l,"jsonp"),s.parseCddData([e],n)}catch(e){return void s.getNoCdd(i)}}else{let i=[];for(let s=0,r=n.length;s',p=h,m=h,u=d.doms;n.bNode&&!i.resid2cdd[c]&&(i.resid2cdd[c]=[]);let g=l.setDomainFeature(u,c,!0,h,p,m);i.chainid2pssmid[c]={pssmid2name:g.pssmid2name,pssmid2fromArray:g.pssmid2fromArray,pssmid2toArray:g.pssmid2toArray};let f=g.acc2domain;h=g.html+"",p=g.html2+"",m=g.html3+"",$("#"+i.pre+"dt_cdd_"+c).html(h),$("#"+i.pre+"ov_cdd_"+c).html(p),$("#"+i.pre+"tt_cdd_"+c).html(m),h='
    ',p=h,m=h;let b=d.motifs;n.bNode&&!i.resid2site[c]&&(i.resid2site[c]=[]),g=l.setDomainFeature(b,c,!1,h,p,m,f),h=g.html,p=g.html2,m=g.html3;let C=a.data[e].sites,y=void 0!==C?C.length:0;for(let e=0;e17&&(s=s.substr(0,17)+"...");let l,r=C[e].title,o=[];for(let t=0,s=C[e].locs.length;t'+s+"
    ",u=''+t.toString()+" Res",g='';m+=d+u+"
    ",h+=d+u+g,p+=d+u+g;let f="site"+e.toString(),b=0,y=0,v=1;for(let t=0,s=i.giSeq[c].length;t1&&(l=s[0]+"..");let r=i.ParserUtilsCls.getResi(c,t);if(h+=''+s+"",n.bNode){let t={};t[c+"_"+r]="site: "+C[e].title,i.resid2site[c].push(t)}p+=i.showSeqCls.insertGapOverview(c,t);let o=n.cfg.blast_rep_id==c?Math.round(i.seqAnnWidth*t/(i.maxAnnoLength+i.nTotalGap)-b-y):Math.round(i.seqAnnWidth*t/i.maxAnnoLength-b-y);o>=0&&(p+='
     
    ',p+='
     
    ',b+=o,y+=v)}else h+="-";g=' '+t.toString()+" Residues",g+="
    ",g+="
    ",h+=g,p+=g}h+="",p+="",m+="",$("#"+i.pre+"dt_site_"+c).html(h),$("#"+i.pre+"ov_site_"+c).html(p),$("#"+i.pre+"tt_site_"+c).html(m)}}for(let e in i.protein_chainid)r.hasOwnProperty(e)||($("#"+i.pre+"dt_cdd_"+e).html(""),$("#"+i.pre+"ov_cdd_"+e).html(""),$("#"+i.pre+"tt_cdd_"+e).html(""),$("#"+i.pre+"dt_site_"+e).html(""),$("#"+i.pre+"ov_site_"+e).html(""),$("#"+i.pre+"tt_site_"+e).html(""));i.showAnnoCls.enableHlSeq(),i.bAjaxCddSite=!0}getNoCdd(e){let t=this.icn3d;t.icn3dui,console.log("No CDD data were found for the protein "+e+"...");for(let e in t.protein_chainid)$("#"+t.pre+"dt_cdd_"+e).html(""),$("#"+t.pre+"ov_cdd_"+e).html(""),$("#"+t.pre+"tt_cdd_"+e).html(""),$("#"+t.pre+"dt_site_"+e).html(""),$("#"+t.pre+"ov_site_"+e).html(""),$("#"+t.pre+"tt_site_"+e).html("");t.showAnnoCls.enableHlSeq(),t.bAjaxCddSite=!0}setDomainFeature(e,t,s,i,n,l,r){let o,a,d,c=this.icn3d,h=c.icn3dui;s&&(r={},o={},a={},d={});let p=void 0!==e?e.length:0,m=s?14:19,u=s?100:120;for(let g=0;gm&&(v=v.substr(0,m)+"...");let w=b+": "+C;s&&(o[p]=C);let _=e[g].locs;if(_)for(let e=0,r=_.length;e'+v+" ",E=''+S.toString()+" Res";l+=R+E+"
    ";let I='';i+=R+E+I,s&&(n+='
    '),n+='
    '+v+"
    ",n+=E+I;let T=b+g.toString();for(let e=0,n=c.giSeq[t].length;e1&&(l=n[0]+"..");let r=c.ParserUtilsCls.getResi(t,e);if(i+=''+n+"",h.bNode){let e={};e[t+"_"+r]=w,s?c.resid2cdd[t].push(e):c.resid2site[t].push(e)}}else i+="-";let M=c.firstAtomObjCls.getFirstCalphaAtomObj(c.chains[t]),P=void 0===M.color||"FFFFFF"===M.color.getHexString()?"DDDDDD":M.color.getHexString(),D=void 0!==M.color?P:"CCCCCC";if(h.cfg.blast_rep_id!=t)for(let s=0,i=r.length;s ',n+='
    '+C+"
    "}else{let s=[],i=[];for(let e=0,t=r.length;e ',n+='
    '+C+"
    "}}I=' '+S.toString()+" Residues",I+="
    ",I+="
    ",i+=I,n+=I,s&&(n+='')}}return{html:i,html2:n,html3:l,acc2domain:r,pssmid2name:o,pssmid2fromArray:a,pssmid2toArray:d}}showAnnoType(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui,a='
    ',d=a,c=a;if(0==n.length)return $("#"+r.pre+"dt_"+s+"_"+e).html(""),$("#"+r.pre+"ov_"+s+"_"+e).html(""),void $("#"+r.pre+"tt_"+s+"_"+e).html("");let h=i;i.length>17&&(i=i.substr(0,17)+"...");let p=[];for(let e=0,t=n.length;e'+i+"
    ",f=''+m.toString()+" Res";c+=g+f+"
    ";let b='';a+=g+f+b,d+=g+f+b;let C=s,y=0,v=0;for(let t=0,i=r.giSeq[e].length;t1&&(c=n[0]+"..");let h=i,p=e+"_"+i,m=n+i;if("ssbond"==s){m="Residue "+p+" has disulfide bond with";let t="";if(void 0!==l[p])for(let e=0,s=l[p].length;e'+c+"",d+=r.showSeqCls.insertGapOverview(e,t);let u=o.cfg.blast_rep_id==e?Math.round(r.seqAnnWidth*t/(r.maxAnnoLength+r.nTotalGap)-y-v):Math.round(r.seqAnnWidth*t/r.maxAnnoLength-y-v);u>=0&&(d+='
     
    ',d+='
     
    ',y+=u,v+=1)}else a+="-"}b=' '+m.toString()+" Residues",b+="",b+="
    ",a+=b,d+=b,a+="",d+="",c+="",$("#"+r.pre+"dt_"+s+"_"+e).html(a),$("#"+r.pre+"ov_"+s+"_"+e).html(d),$("#"+r.pre+"tt_"+s+"_"+e).html(c)}setToolTip(){let e=this.icn3d;e.icn3dui,$("[id^="+e.pre+"snp]").add("[id^="+e.pre+"clinvar]").add("[id^="+e.pre+"ssbond]").add("[id^="+e.pre+"crosslink]").tooltip({content:function(){return $(this).prop("title")},show:null,close:function(e,t){t.tooltip.hover((function(){$(this).stop(!0).fadeTo(400,1)}),(function(){$(this).fadeOut("400",(function(){$(this).remove()}))}))}})}}class vt{constructor(e){this.icn3d=e}showInteraction(e,t){this.icn3d.icn3dui,this.showInteraction_base(e,t)}showInteraction_base(e,t){let s=this.icn3d,i=s.icn3dui;i.bNode&&(s.resid2contact||(s.resid2contact={}),s.resid2contact[e]||(s.resid2contact[e]=[])),void 0===s.chainname2residues&&(s.chainname2residues={});let n=Object.keys(s.chains),l=e,r=Math.round(l.indexOf("_"));if(s.firstAtomObjCls.getFirstCalphaAtomObj(s.chains[l]),void 0===s.chainname2residues[l]){s.chainname2residues[l]={};let t=n.length;if(t>100&&void 0===i.cfg.mmdbid&&void 0===i.cfg.gi&&void 0===i.cfg.blast_rep_id&&void 0===i.cfg.align&&void 0===i.cfg.chainalign)return $("#"+s.pre+"dt_interaction_"+e).html(""),void $("#"+s.pre+"ov_interaction_"+e).html("");for(let e=0;e4)continue;let o,a=s.firstAtomObjCls.getFirstCalphaAtomObj(s.chains[t]);s.chemicals.hasOwnProperty(a.serial)?o="chemical":s.nucleotides.hasOwnProperty(a.serial)?o="nucleotide":s.ions.hasOwnProperty(a.serial)?o="ion":s.proteins.hasOwnProperty(a.serial)?o="protein":s.water.hasOwnProperty(a.serial)&&(o="water");let d=s.contactCls.getAtomsWithinAtom(i.hashUtilsCls.hash2Atoms(s.chains[l],s.atoms),i.hashUtilsCls.hash2Atoms(s.chains[t],s.atoms),4);if(0==Object.keys(d).length)continue;let c={};for(let e in d){let t=s.atoms[e];c[t.structure+"_"+t.chain+"_"+t.resi]=1}let h=t.substr(t.indexOf("_")+1)+"("+o+")";s.chainname2residues[l][h]=Object.keys(c)}}let o='
    ',a=o,d=o,c=0;for(let t in s.chainname2residues[e]){let n=s.chainname2residues[e][t];if(!n)continue;let l="Interact ."+t;l.length>17&&(l=l.substr(0,17)+"...");let r="Interact ."+t,h=[];for(let e=0,t=n.length;e'+l+"
    ",g=''+p.toString()+" Res";d+=u+g+"
    ";let f='';o+=u+g+f,a+=u+g+f;let b="inter"+c.toString(),C=0,y=0,v=1;for(let t=0,n=s.giSeq[e].length;t1&&(d=l[0]+"..");let c=n;if(o+=''+d+"",i.bNode){let t={};t[e+"_"+c]=r,s.resid2contact[e].push(t)}a+=s.showSeqCls.insertGapOverview(e,t);let h=i.cfg.blast_rep_id==e?Math.round(s.seqAnnWidth*t/(s.maxAnnoLength+s.nTotalGap)-C-y):Math.round(s.seqAnnWidth*t/s.maxAnnoLength-C-y);h>=0&&(a+='
     
    ',a+='
     
    ',C+=h,y+=v)}else o+="-"}f=' '+p.toString()+" Residues",f+="
    ",f+="
    ",o+=f,a+=f,++c}o+="",a+="",d+="",$("#"+s.pre+"dt_interaction_"+e).html(o),$("#"+s.pre+"ov_interaction_"+e).html(a),$("#"+s.pre+"tt_interaction_"+e).html(d),i.utilsCls.isMobile()?(s.hlSeqCls.selectSequenceMobile(),s.hlSeqCls.selectChainMobile()):s.hlSeqCls.selectSequenceNonMobile()}}class wt{constructor(e){this.icn3d=e}async showPTM(e,t,s,i,n){let l=this.icn3d,r=l.icn3dui,o=this,a=e.substr(0,e.indexOf("_")),d=e.substr(e.indexOf("_")+1);if("afmem"==s){let t={Transmembrane:[{begin:i,end:n}]};this.setAnnoPtmTransmem("transmem",t,e)}else if(a.length>5){let t,i="https://www.ebi.ac.uk/proteins/api/features/"+a;try{t=await r.getAjaxPromise(i,"json"),o.parsePTM(t,e,s)}catch{return void o.getNoPTM(e,s)}}else{let t,i=a.substr(0,4).toLowerCase(),n="https://www.ebi.ac.uk/pdbe/api/mappings/uniprot/"+i;try{t=await r.getAjaxPromise(n,"json");let a="";l.UPResi2ResiPosPerChain||(l.UPResi2ResiPosPerChain={}),l.UPResi2ResiPosPerChain[e]={};let c=t[i].UniProt,h=!1;for(let t in c){let s=c[t].mappings;for(let i=0,n=s.length;i',o+=r,a+=r;let d=s.substr(0,s.indexOf("_"));for(let c in t){let h=t[c],p=[],m=!1;for(let e=0,t=h.length;e5?p.push(e-1):i.UPResi2ResiPosPerChain&&i.UPResi2ResiPosPerChain[s][e]&&p.push(i.UPResi2ResiPosPerChain[s][e]),!m&&i.residues.hasOwnProperty(s+"_"+e)&&(m=!0)}if(0==p.length)continue;let u=p.length,g="ptm"==e?"PTM: "+c:"Transmembrane";g.length>17&&(g=g.substr(0,17)+"...");let f=c,b='
    '+g+"
    ",C=''+u.toString()+" Res",y='';a+=b+C+"
    ",r+=b+C+y,o+=b+C+y;let v=e+l.toString(),w=0,_=0,S=1;for(let e=0,t=i.giSeq[s].length;e1&&(l=t[0]+"..");let a=i.ParserUtilsCls.getResi(s,e);if(r+=''+t+"",n.bNode){let e={};e[s+"_"+a]=g,i.resid2ptm[s].push(e)}o+=i.showSeqCls.insertGapOverview(s,e);let d=n.cfg.blast_rep_id==s?Math.round(i.seqAnnWidth*e/(i.maxAnnoLength+i.nTotalGap)-w-_):Math.round(i.seqAnnWidth*e/i.maxAnnoLength-w-_);d>=0&&(o+='
     
    ',o+='
     
    ',w+=d,_+=S)}else r+="-";y=' '+u.toString()+" Residues",y+="
    ",y+="
    ",r+=y,o+=y,++l}r+="",o+="",a+="",$("#"+i.pre+"dt_"+e+"_"+s).html(r),$("#"+i.pre+"ov_"+e+"_"+s).html(o),$("#"+i.pre+"tt_"+e+"_"+s).html(a)}getNoPTM(e,t){let s=this.icn3d;s.icn3dui,console.log("No PTM data were found for the chain "+e+"...");let i="ptm"==t?"ptm":"transmem";$("#"+s.pre+"dt_"+i+"_"+e).html(""),$("#"+s.pre+"ov_"+i+"_"+e).html(""),$("#"+s.pre+"tt_"+i+"_"+e).html(""),s.showAnnoCls.enableHlSeq(),s.bAjaxPTM=!0}}class _t{constructor(e){this.icn3d=e}showCrosslink(e,t){let s=this.icn3d;s.icn3dui;let i=this;void 0===s.clbondpnts?setTimeout((function(){i.showCrosslink_base(e,t)}),1e3):this.showCrosslink_base(e,t)}showCrosslink_base(e,t){let s=this.icn3d;s.icn3dui.bNode&&(s.resid2crosslink||(s.resid2crosslink={}),s.resid2crosslink[e]||(s.resid2crosslink[e]=[]));let i=t,n={},l=i.substr(0,i.indexOf("_")),r=s.clbondpnts[l];if(void 0===r)return $("#"+s.pre+"dt_crosslink_"+e).html(""),$("#"+s.pre+"ov_crosslink_"+e).html(""),void $("#"+s.pre+"tt_crosslink_"+e).html("");for(let e=0,t=r.length;e',a=o,d=o,c=e.indexOf("_"),h=e.substr(c+1);if(s)n=e,i=t.domains[e]?t.domains[e].domains:[];else{let e,s=t.moleculeInfor;for(let t in s)if(s[t].chain===h){e=t,n=s[t].name;break}void 0!==e&&void 0!==t.domains[e]&&(i=t.domains[e].domains),void 0===i&&(i=[])}for(let t=0,s=i.length;t17?s.substr(0,17)+"...":s,h=i[t].intervals,p={},m={},u=[],g=[],f={},b=0;for(let e=0,t=h.length;e'+c+" ",y=''+b.toString()+" Res";d+=C+y+"
    ";let v='';o+=C+y+v,a+=C+y+v;let w="domain3d"+t.toString();for(let t=0,s=l.giSeq[e].length;t1&&(n=i[0]+"..");let r=s;o+=''+i+""}else o+="-"}let _=l.firstAtomObjCls.getFirstCalphaAtomObj(l.chains[e]),S=void 0===_.color||"FFFFFF"===_.color.getHexString()?"DDDDDD":_.color.getHexString(),A=void 0!==_.color?S:"CCCCCC";if(r.cfg.blast_rep_id!=e)for(let i=0,n=u.length;i ',a+='"}else{let i=[],n=[];for(let e=0,t=u.length;e ',a+='"}}v=' '+b.toString()+" Residues",v+="",v+="
    ",o+=v,a+=v}o+="",a+="",d+="",$("#"+l.pre+"dt_domain_"+e).html(o),$("#"+l.pre+"ov_domain_"+e).html(a),$("#"+l.pre+"tt_domain_"+e).html(d)}}class At{constructor(e){this.icn3d=e}async showSnp(e,t){this.icn3d.icn3dui,await this.showSnpClinvar(e,t,!0)}async showClinvar(e,t){this.icn3d.icn3dui,await this.showSnpClinvar(e,t,!1)}async showSnpClinvar(e,t,s){let i=this.icn3d.icn3dui,n=this,l=i.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainid="+t;try{let r=await i.getAjaxPromise(l,"jsonp"),o=r.snpgi,a=r.gi;if(s)await n.showSnpPart2(e,t,o);else{let s=o;[6137708,1942289,224510717,2624886,253723219,2554905,75765331,3660278,312207882,319443632,342350956,1827805,109157826,1065265,40889086,6730307,163931185,494469,163931091,60594093,55669745,18655489,17942684,6980537,166235465,6435586,4139398,4389047,364506122,78101667,262118402,20664221,2624640,158430173,494395,28948777,34810587,13399647,3660342,261278854,342350965,384482350,378792570,15988303,213424334,4558333,2098365,10835631,3318817,374074330,332639529,122919696,4389286,319443573,2781341,67464020,194709238,210061039,364506106,28949044,40889076,161172338,17943181,4557976,62738484,365813173,6137343,350610552,17942703,576308,223674070,15826518,1310997,93279697,4139395,255311799,157837067,361132363,357380836,146387678,383280379,1127268,299856826,13786789,1311054,46015217,3402130,381353319,30750059,218766885,340707375,27065817,355333104,2624634,62738384,241913553,304446010].includes(a)&&(s=a),await n.showClinvarPart2(e,t,s)}}catch(t){return void(s?n.processNoSnp(e):n.processNoClinvar(e))}}navClinVar(e){let t=this.icn3d;t.icn3dui;let s=this;t.currClin[e]=-1,$(document).on("click","#"+t.pre+e+"_prevclin",(function(t){let i=s.icn3d;t.stopImmediatePropagation();let n=void 0!==i.resi2disease_nonempty[e]?Object.keys(i.resi2disease_nonempty[e]).length:0;--i.currClin[e],i.currClin[e]<0&&(i.currClin[e]=n-1),s.showClinVarLabelOn3D(e)})),$(document).on("click","#"+t.pre+e+"_nextclin",(function(t){let i=s.icn3d;t.stopImmediatePropagation();let n=void 0!==i.resi2disease_nonempty[e]?Object.keys(i.resi2disease_nonempty[e]).length:0;++i.currClin[e],i.currClin[e]>n-1&&(i.currClin[e]=0),s.showClinVarLabelOn3D(e)}))}showClinVarLabelOn3D(e){let t,s,i=this.icn3d,n=i.icn3dui,l=Object.keys(i.resi2disease_nonempty[e]);t=e,s=t+"_"+(parseInt(l[i.currClin[e]])+i.baseResi[e]).toString();let r="",o=i.resi2disease_nonempty[e][l[i.currClin[e]]];for(let e=0,t=o.length;e0?o[0]:"N/A");let a=i.applyCenterCls.centerAtoms(n.hashUtilsCls.hash2Atoms(i.residues[s],i.atoms));r.length>30&&(r=r.substr(0,30)+"..."),i.selectionCls.removeSelection(),null==i.labels&&(i.labels={}),i.labels.clinvar=[];let d=i.LABELSIZE,c="black"!=i.opts.background?i.colorWhitebkgd:i.colorBlackbkgd;i.analysisCls.addLabel(r,a.center.x+1,a.center.y+1,a.center.z+1,d,c,void 0,"clinvar"),i.hAtoms={};for(let e in i.residues[s])i.hAtoms[e]=1;$("#clinvar_"+i.pre+s).addClass("icn3d-highlightSeq"),void 0===$("#"+i.pre+"modeswitch")[0]||$("#"+i.pre+"modeswitch")[0].checked||i.definedSetsCls.setMode("selection"),i.drawCls.draw()}getSnpLine(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g){let f=this.icn3d,b=f.icn3dui,C="",y=m?"clinvar":"snp",v=!1;for(let e in i){for(let t=0,s=i[e].length;t(from human)",i=" (based on human sequences and mapped to this structure by sequence similarity)"),C+=m?'":'"}else if(2==e&&m){let e=b.utilsCls.isMobile()?"none":"button";C+='
    ',C+='
    '}else C+='
    ';let w=y,_=0,S=0,A={},x={};for(let t=1,i=f.giSeq[h].length;t<=i;++t)if(void 0!==r[t]){++_;let i="";for(let n=0,r=s[t].length;n'+k+" Res":'',u)return C+"
    ";C+='';let O="",R=0,E=0;for(let t=1,a=f.giSeq[h].length;t<=a;++t)if(p){if(void 0!==r[t]){let e=f.giSeq[h][t-1],i=e;e.length>1&&(i=e[0]+"..");let n=f.ParserUtilsCls.getResi(h,t-1)+i+">";for(let e=0,i=s[t].length;e=0&&(C+='
     
    ',C+='
     
    ',R+=r,E+=1):r>0&&(C+='
     
    ',C+='
     
    ',R+=r,E+=1)}}else if(C+=f.showSeqCls.insertGap(h,t-1,"-"),void 0!==r[t])if(m||1!=e){let r=f.giSeq[h][t-1],a=r;r.length>1&&(a=r[0]+"..");let d,c=f.ParserUtilsCls.getResi(h,t-1),p="",u="
    ",y=s[t].length,v=0,_=0;if(2==e&&(v=0,_=y),m){d=1;let r=0;for(let e=v;e0?_+="; ":0!==e&&1!==e||(O='disease="'+v[t]+'"'),_+=v[t]+"("+w[t]+")",++S;""!=_&&(r"+s[t][e],u+=": "+_,C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(m,"snpin3d","3D with scap","SNP in 3D with scap",70,g)+"  ",u+=f.showAnnoCls.addSnpButton(m,"snpinter","Interactions","SNP Interactions in 3D",70,g)+"  ",u+=f.showAnnoCls.addSnpButton(m,"snppdb","PDB","Download SNP PDB",35,g)),u+="
    Links: ClinVar, dbSNP(rs"+i[t][e]+")",e
    "),++r)}r>d&&2==e&&(p+="..")}else{d=1;for(let e=v;e"+s[t][e],g)C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),0!=i[t][e]&&(u+="
    Link: dbSNP(rs"+i[t][e]+")"),e
    ");else{let s=l[t][e].split("; "),a=o[t][e].split("; "),d="",c=0;for(let t=0,i=s.length;t0?d+="; ":0!==e&&1!==e||(O='disease="'+s[t]+'"'),d+=s[t]+"("+a[t]+")",++c;""!=d?(u+=": "+d,C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),u+="
    Links: ClinVar, dbSNP(rs"+i[t][e]+")"):(C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),u+="
    Link: dbSNP(rs"+i[t][e]+")"),e
    ")}}y>d&&2==e&&(p+="..")}u+="
    ",m?"icn3d-clinvar"==A[t]||"icn3d-clinvar-path"==A[t]?C+=1==e?"":""==p||" "==p?"-":''+p+"":C+="-":C+=""==p||" "==p?"-":g?''+p+"":''+p+""}else C+="";else C+="-";return C+=1==e?' '+k+" Residues":'',C+="
    ",C+="
    ",C}processSnpClinvar(e,t,s,i,n){let l=this.icn3d,r=l.icn3dui,o='
    ',a=o,d=o,c='
    ',h=c,p=c,m=!i||n?e.data:e.split("\n"),u={},g={},f={};void 0===l.resi2disease_nonempty[t]&&(l.resi2disease_nonempty[t]={});let b={},C={},y={},v={},w={},_="";r.bNode&&(i?(l.resid2snp||(l.resid2snp={}),l.resid2snp[t]||(l.resid2snp[t]=[])):(l.resid2clinvar||(l.resid2clinvar={}),l.resid2clinvar[t]||(l.resid2clinvar[t]=[])));for(let e=0,s=m.length;e")+1),h=s[4],p=i?"":s[5],S=i?"":s[6],A=i?"":s[7],x=l.ParserUtilsCls.getResi(t,d-1);v[x]=1,""!=S&&(w[x]=1),g[d]=e+1,void 0===u[d]&&(u[d]=[]),u[d].push(c),void 0===C[d]&&(C[d]=[]),C[d].push(h),void 0===y[d]&&(y[d]=[]),y[d].push(p),void 0===f[d]&&(f[d]=[]),f[d].push(S),""!=S&&(void 0===l.resi2disease_nonempty[t][d]&&(l.resi2disease_nonempty[t][d]=[]),l.resi2disease_nonempty[t][d].push(S)),void 0===b[d]&&(b[d]=[]),b[d].push(A)}let S=Object.keys(v),A=Object.keys(w);if(i){let e=!1;o+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,void 0,i),o+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,void 0,i),d+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,!0,i),d+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,!0,i),a+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!0,e,void 0,i),o+="
    ",a+="
    ",d+="",$("#"+l.pre+"dt_snp_"+t).html(o),$("#"+l.pre+"ov_snp_"+t).html(a),$("#"+l.pre+"tt_snp_"+t).html(d)}else{let e=!0;c+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,void 0,i),c+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,void 0,i),p+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,!0,i),p+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,!0,i),h+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!0,e,void 0,i),c+="",h+="",p+="",$("#"+l.pre+"dt_clinvar_"+t).html(c),$("#"+l.pre+"ov_clinvar_"+t).html(h),$("#"+l.pre+"tt_clinvar_"+t).html(p),this.navClinVar(t,s)}l.showAnnoCls.enableHlSeq(),i?l.bAjaxSnp=!0:l.bAjaxClinvar=!0}async showClinvarPart2(e,t,s){let i=this.icn3d,n=i.icn3dui,l=this,r=n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainid_clinvar="+t;i.chainsGene[e]&&i.chainsGene[e].geneSymbol&&(r+="&gene="+i.chainsGene[e].geneSymbol);try{let s=await n.getAjaxPromise(r,"jsonp");if(s&&s.data&&s.data.length>0){let i=!1,n=s;l.processSnpClinvar(n,e,t,i)}else l.processNoClinvar(e)}catch(t){return void l.processNoClinvar(e)}}async showSnpPart2(e,t,s){let i=this.icn3d,n=i.icn3dui,l=this;if(void 0!==s){let s=n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainid_snp="+t;i.chainsGene[e]&&i.chainsGene[e].geneSymbol&&(s+="&gene="+i.chainsGene[e].geneSymbol);try{let i=await n.getAjaxPromise(s,"jsonp");if(i&&i.data&&i.data.length>0){let s=!0,n=!0;l.processSnpClinvar(i,e,t,s,n)}else l.processNoSnp(e)}catch(t){return void l.processNoSnp(e)}}else this.processNoSnp(e),console.log("No gi was found for the chain "+t+"...")}processNoClinvar(e){let t=this.icn3d;t.icn3dui,console.log("No ClinVar data were found for the protein "+e+"..."),$("#"+t.pre+"dt_clinvar_"+e).html(""),$("#"+t.pre+"ov_clinvar_"+e).html(""),t.showAnnoCls.enableHlSeq(),t.bAjaxClinvar=!0}processNoSnp(e){let t=this.icn3d;t.icn3dui,console.log("No SNP data were found for the protein "+e+"..."),$("#"+t.pre+"dt_snp_"+e).html(""),$("#"+t.pre+"ov_snp_"+e).html(""),t.showAnnoCls.enableHlSeq(),t.bAjaxSnp=!0}}class xt{constructor(e){this.icn3d=e}showSsbond(e,t){let s=this.icn3d;s.icn3dui;let i=this;void 0===s.ssbondpnts?setTimeout((function(){i.showSsbond_base(e,t)}),1e3):this.showSsbond_base(e,t)}showSsbond_base(e,t){let s=this.icn3d;s.icn3dui.bNode&&(s.resid2ssbond||(s.resid2ssbond={}),s.resid2ssbond[e]||(s.resid2ssbond[e]=[]));let i=t,n={},l=i.substr(0,i.indexOf("_")),r=s.ssbondpnts[l];if(void 0===r)return $("#"+s.pre+"dt_ssbond_"+e).html(""),$("#"+s.pre+"ov_ssbond_"+e).html(""),void $("#"+s.pre+"tt_ssbond_"+e).html("");for(let e=0,t=r.length;e-s.halfBilayerSize){i[t.structure+"_"+t.chain+"_"+t.resi]=1}}let n=Object.keys(i);s.annoCddSiteCls.showAnnoType(e,t,"transmem","Transmembrane",n)}}class Ot{constructor(e){this.icn3d=e,this.dcut=7,this.MAX_SSE=512,this.ctc_cnt=[];for(let e=0;e=this.curr_ratio+.01||f>this.split_ratio)return e;if(f>this.curr_ratio-.01&&Math.min(m,u)=0&&l[i]==t-e+i;i--);if(i<0)break;for(l[i]++,s=i+1;s-1;i++);for(l=Math.min(i-1,this.max_csz),this.curr_ne0=this.curr_ne1=0,this.curr_ratio=100,s=1;s<=l;s++)this.cut_size(s,i);if(this.top--,0==this.curr_ne0){for(n=this.stack[this.top],e=n;e-1;e++)this.parts[this.np++]=this.elements[e];this.parts[this.np++]=-1,this.n_doms++}else{if(this.save_ratios[this.saved++]=this.curr_ratio,this.curr_ne0>this.min_sse){for(n=this.stack[this.top],e=0;ethis.min_sse){for(n=this.stack[this.top],e=0;e0;)this.process_set()}output(e){let t,s;this.icn3d.icn3dui;let i=[];for(t=0;t<2*e;t++)i.push(0);for(t=s=0;st+n)break;let p=(t-a)*(t-a);p+=(s-c)*(s-c),p+=(i-h)*(i-h);let m=Math.sqrt(p);if(m>n)continue;let u={},g={};parseInt(e.rnum)this.MAX_SSE)return{subdomains:a,substruct:o};let g=h.length,f=r[g-1],b=this.c2b_AlphaContacts(g,i,n,l,t,r),C=[];for(let e=0;e0&&this.elt_size[s.sse-1]>=6&&0!=s.adj_strand2&&e++}for(let e=0;e0)for(let e=0;e0){let e=0;for(let t=0;t<=E;t++){let t=[];for(;e<2*u;){let s=this.parts[e++];if(0==s){I.push(t);break}t.push(s)}}}I.sort((function(e,t){return e[0]-t[0]}));for(let e=0,t=I.length;e=o.length)return{subdomains:a,substruct:o};let n=o[i],l=n.From,r=n.To;for(let e=l;e<=r;e++)s[e]=1;if(0==i&&l>1)for(let e=1;e0){let e=o[i-1].To,t=parseInt(.5*(l-e-1));if(t>0)for(let e=l-t;e<=l-1;e++)s[e]=1}if(i0)for(let e=r+1;e<=r+t;e++)s[e]=1}}let i,n=!1,l=[];for(let e=0;e0&&(d+=", "),d+='{"ss": [';let i=0;for(let s=0,r=n[e].length;s=r&&c<=o&&(i>0&&(d+=", "),d+="["+s+","+n+","+c+","+l[e].x1.toFixed(2)+","+l[e].y1.toFixed(2)+","+l[e].z1.toFixed(2)+","+l[e].x2.toFixed(2)+","+l[e].y2.toFixed(2)+","+l[e].z2.toFixed(2)+"]",++i))}}d+="]",d+=', "domain": [';let r=0;for(let i=0,l=n[e].length;i=l&&n<=a&&(r>0&&(d+=", "),d+="["+n+","+h+","+c.coord.x.toFixed(2)+","+c.coord.y.toFixed(2)+","+c.coord.z.toFixed(2)+"]",++r)}}d+="]}"}return d+="]}",d}}class Rt{constructor(e){this.icn3d=e}clickAddTrackButton(){let e=this.icn3d,t=e.icn3dui,s=this;t.myEventCls.onIds("#"+e.pre+"addtrack_button1","click",(async function(e){let i=s.icn3d;e.stopImmediatePropagation(),dialog.dialog("close");let n=$("#"+i.pre+"track_chainid").val(),l=$("#"+i.pre+"track_gi").val(),r=isNaN(l)?"Acc "+l:"gi "+l,o=t.htmlCls.baseUrl+"pwaln/pwaln.fcgi?from=track",a={targets:n,queries:l},d=await t.getAjaxPostPromise(o,a);s.alignSequenceToStructure(n,d,r)})),t.myEventCls.onIds("#"+e.pre+"addtrack_button2","click",(async function(e){let i=s.icn3d;e.stopImmediatePropagation(),dialog.dialog("close");let n=$("#"+i.pre+"track_chainid").val(),l=$("#"+i.pre+"track_fasta").val(),r=$("#"+i.pre+"fasta_title").val(),o=n.substr(0,n.indexOf("_")),a=n;if(5==o.length)a=a.substr(0,4);else if(o.length>5){a="";for(let e=0,t=i.chainsSeq[n].length;e"),a=o[1].indexOf("\n");o[1].substr(0,a);let d,c=o[1].substr(a+1).replace(/\n/g,""),h=[],p=[];for(let e=2,t=o.length;e0&&(u=f,i.targetGapHash[m+d]={from:m+d,to:u+C-1+d}),g=c[e],f=b,"-"!=c[e]?(++b,w=e,y||(v=e,y=!0)):++C;await i.annotationCls.resetAnnoAll();let _="",S=0;for(let e in i.targetGapHash)S>0&&(_+=" "),_+=e+"_"+i.targetGapHash[e].from+"_"+i.targetGapHash[e].to,++S;t.htmlCls.clickMenuCls.setLogCmd("msa | "+_,!0);let A={};for(let e=0,o=p.length;e0){void 0===i.queryresi2score&&(i.queryresi2score={}),void 0===i.queryresi2score[n]&&(i.queryresi2score[n]={});let e=p.length;for(let t in A){let s=parseInt(A[t]/e*100);i.queryresi2score[n][t]=s}let s=Object.keys(A),l=Math.min.apply(null,s),r=Math.max.apply(null,s),o="";for(let t=l;t<=r;++t)A.hasOwnProperty(t)?o+=Math.round(A[t]/e*9):o+="_";i.opts.color="align custom",i.setColorCls.setColorByOptions(i.opts,i.hAtoms),i.hlUpdateCls.updateHlAll(),i.drawCls.draw(),t.htmlCls.clickMenuCls.setLogCmd("color align custom | "+n+" | range "+l+"_"+r+" | "+o,!0)}})),t.myEventCls.onIds("#"+e.pre+"addtrack_button3","click",(function(e){let i=s.icn3d;e.stopImmediatePropagation(),dialog.dialog("close");let n=$("#"+i.pre+"track_chainid").val(),l=$("#"+i.pre+"track_bed")[0].files[0];if(l){window.File&&window.FileReader&&window.FileList&&window.Blob||alert("The File APIs are not fully supported in this browser.");let e=new FileReader;e.onload=function(e){let l,r=e.target.result.split("\n"),o=!1,a=!1;for(let e=0,d=r.length;e8||d.length<6)&&(a=!1),d.length<9&&(o=!1),d[0];let c,h,p=d[1],m=d[2],u=d[3];d.length,d.length>5&&(c=d[5]),d.length,d.length,d.length>8&&(h=d[8]),d.length,d.length,d.length;let g=u,f="51,51,51";o?f=h:a&&("+"==c&&l.length>0?f=l[0]:"-"==c&&l.length>1?f=l[1]:"."==c&&l.length>2&&(f=l[2]));let b="",C=[];for(let e=0,t=m;e1&&(s=t[0]);let l=i.ParserUtilsCls.getResi(n,e);if(a.hasOwnProperty(n+"_"+l)){let e=i.firstAtomObjCls.getFirstCalphaAtomObj(i.residues[n+"_"+l]),t=void 0===e.color||"FFFFFF"===e.color.getHexString().toUpperCase()?"DDDDDD":e.color.getHexString(),o=void 0!==e.color?t:"CCCCCC";r+=s,d.push("#"+o)}else r+="-",d.push("")}s.showNewTrack(n,l,r,d,void 0,"selection",void 0),t.htmlCls.clickMenuCls.setLogCmd("add track | chainid "+n+" | title "+l+" | text "+s.simplifyText(r)+" | type selection",!0)}))}showNewTrack(e,t,s,i,n,l,r,o,a,d){let c=this.icn3d,h=c.icn3dui,p=!1;"cannot be aligned"==s&&(p=!0);let m=s.replace(/-/g,"").length;if(!o)if(s.length>c.giSeq[e].length)s=s.substr(0,c.giSeq[e].length);else if(s.length20&&(u=u.substr(0,20));let g=h.htmlCls.RESIDUE_WIDTH*s.length+200;$("#"+c.pre+"dt_custom_"+e).append("
    "),$("#"+c.pre+"dt_custom_"+e+"_"+u).width(g),$("#"+c.pre+"ov_custom_"+e).append("
    "),$("#"+c.pre+"ov_custom_"+e+"_"+u).width(g),$("#"+c.pre+"tt_custom_"+e).append("
    "),$("#"+c.pre+"tt_custom_"+e+"_"+u).width(g);let f='
    ',b=f,C=f,y=parseInt(10*Math.random()),v='",w=''+m.toString()+" Pos";C+=v+w+"
    ";let _='';f+=v+w+_,b+=v+w+_;let S=e.indexOf("_"),A="cst"+e.substr(S+1),x=0,k=0,O=(void 0===l||"seq"===l||"custom"===l)&&-1==s.indexOf("cannot-be-aligned")&&-1==s.indexOf("cannot be aligned"),R="identity"===l&&-1==s.indexOf("cannot-be-aligned")&&-1==s.indexOf("cannot be aligned"),E={},I=0,T=1;v="";for(let t=0,a=s.length;t"+d+"",v+=c.showSeqCls.insertGapOverview(e,t);let g=h.cfg.blast_rep_id==e?Math.round(c.seqAnnWidth*t/(c.maxAnnoLength+c.nTotalGap)-x-k):Math.round(c.seqAnnWidth*t/c.maxAnnoLength-x-k);g<0&&(g=0),v+='
     
    ',s=void 0!==i&&""!=i[t]?i[t]:r?"rgb("+r+")":O?"#"+p:"#333",v+='
     
    ',x+=g,k+=1,++T}else f+=p?""+d+"":"-"}if(void 0!==a){v="";let s=[],i=[];for(let e=0,t=a.length;e 
    ',v+='"}}_=''+m.toString()+" Pos",_+="",_+="
    ",_+="",f+=_,b+=v+_,C+="",$("#"+c.pre+"dt_custom_"+e+"_"+u).html(f),$("#"+c.pre+"ov_custom_"+e+"_"+u).html(b),$("#"+c.pre+"tt_custom_"+e+"_"+u).html(C)}alignSequenceToStructure(e,t,s){let i,n,l,r=this.icn3d,o=r.icn3dui;void 0!==t.data&&(i=t.data[0].query,l=Object.keys(t.data[0].targets)[0],n=t.data[0].targets[l],n=n.hsps[0]);let a="",d=[],c={};if(void 0!==i&&void 0!==n){let h=n.scores.e_value.toPrecision(2);h>1e-200&&(h=parseFloat(h).toExponential()),n.scores.bit_score;let p=t.targets[l].seqdata,m=i.seqdata,u=n.segs;for(let e=0,t=u.length;e0&&(l=n+"H"+d+")","coil"==t&&(s.selectionCls.selectResidueList(r,l,l,o,a),o||(o=!0)),r={})),n=e+"_H"+d,r[p]=1,i.ssend&&(h=e+"_C(H"+d,"helix"==t&&(s.selectionCls.selectResidueList(r,n,n,o,a),o||(o=!0)),r={})):"E"==m?(i.ssbegin&&(++c,Object.keys(r).length>0&&(l=n+"S"+c+")","coil"==t&&(s.selectionCls.selectResidueList(r,l,l,o,a),o||(o=!0)),r={})),n=e+"_S"+c,r[p]=1,i.ssend&&(h=e+"_C(S"+c,"sheet"==t&&(s.selectionCls.selectResidueList(r,n,n,o,a),o||(o=!0)),r={})):(n=h+"-",r[p]=1)}}Object.keys(r).length>0&&(l=n+"Cterm)","coil"==t&&s.selectionCls.selectResidueList(r,l,l,o,a))}simplifyText(e){this.icn3d.icn3dui;let t,s,i="",n=!1,l=-1;for(t=0,s=(e=e.replace(/undefined/g," ")).length;t20)return!1;if(void 0!==o.giSeq&&void 0!==o.giSeq[e]){let r=this.getFullText(s);return s=r.text,this.showNewTrack(e,t,s,void 0,void 0,i,n,l),!1}setTimeout((function(){a.checkGiSeq(e,t,s,i,n,l,r+1)}),100)}getFullText(e){this.icn3d.icn3dui;let t="",s=[],i=[],n=e.split(","),l=-1;for(let e=0,r=n.length;ep?t+=c.substr(0,p):t+=c;for(let e=0;e0&&($("#"+e.pre+"anno_cdd")[0].checked?(this.setAnnoTabCdd(),t.htmlCls.clickMenuCls.setLogCmd("set annotation cdd",!0)):(this.hideAnnoTabCdd(),t.htmlCls.clickMenuCls.setLogCmd("hide annotation cdd",!0)))}showAnnoSelectedChains(){let e=this.icn3d,t=e.icn3dui,s={};for(let t in e.hAtoms){let i=e.atoms[t];s[i.structure+"_"+i.chain]=1}$("#"+e.pre+"dl_annotations > .icn3d-annotation").hide();for(let i in s){$("#"+e.pre+"anno_"+i).length&&$("#"+e.pre+"anno_"+i).show();let s=e.firstAtomObjCls.getFirstCalphaAtomObj(e.chains[i]);if(void 0!==s.resn){let i=t.utilsCls.residueName2Abbr(s.resn.substr(0,3));$("#"+e.pre+"anno_"+i).show()}}}showAnnoAllChains(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"dl_annotations > .icn3d-annotation").show()}setAnnoView(e){let t=this.icn3d;t.icn3dui.bNode||("detailed view"===e?(t.view="detailed view",$("#"+t.pre+"dl_anno_view_tabs").tabs("option","active",1)):(t.view="overview",$("#"+t.pre+"dl_anno_view_tabs").tabs("option","active",0)))}setAnnoDisplay(e,t){let s=this.icn3d;s.icn3dui;let i=["giseq","custom","site","ptm","snp","clinvar","cdd","domain","interaction","ssbond","crosslink","transmem"];for(let n in i){let l=i[n];$("[id^="+s.pre+t+"_"+l+"]").attr("style",e)}}showFixedTitle(){this.icn3d.icn3dui;this.setAnnoDisplay("display:block;","tt")}hideFixedTitle(){this.icn3d.icn3dui;this.setAnnoDisplay("display:none!important;","tt")}setAnnoViewAndDisplay(e){let t=this.icn3d;if(t.icn3dui,"detailed view"===e){this.setAnnoView("detailed view");let e="display:block;";this.setAnnoDisplay(e,"dt"),$("#"+t.pre+"seqguide_wrapper").attr("style",e),e="display:none;",this.setAnnoDisplay(e,"ov")}else{this.setAnnoView("overview"),this.hideFixedTitle();let e="display:none;";this.setAnnoDisplay(e,"dt"),$("#"+t.pre+"seqguide_wrapper").attr("style",e),e="display:block;",this.setAnnoDisplay(e,"ov")}}async updateClinvar(){let e=this.icn3d;if(e.icn3dui,void 0===e.bClinvarShown||!e.bClinvarShown)for(let t in e.protein_chainid){let s=e.protein_chainid[t];await e.annoSnpClinVarCls.showClinvar(t,s)}e.bClinvarShown=!0}async updateSnp(){let e=this.icn3d;if(e.icn3dui,void 0===e.bSnpShown||!e.bSnpShown)for(let t in e.protein_chainid){let s=e.protein_chainid[t];await e.annoSnpClinVarCls.showSnp(t,s)}e.bSnpShown=!0}updateDomain(){let e=this.icn3d;e.icn3dui,void 0!==e.bDomainShown&&e.bDomainShown||e.annoDomainCls.showDomainAll(),e.bDomainShown=!0}updateInteraction(){let e=this.icn3d;if(e.icn3dui,void 0===e.bInteractionShown||!e.bInteractionShown)for(let t in e.interactChainbase){let s=e.interactChainbase[t];e.annoContactCls.showInteraction(t,s)}e.bInteractionShown=!0}async updatePTM(){let e=this.icn3d;if(e.icn3dui,void 0===e.bPTMShown||!e.bPTMShown)for(let t in e.PTMChainbase){let s=e.PTMChainbase[t];await e.annoPTMCls.showPTM(t,s,"ptm")}e.bPTMShown=!0}updateSsbond(){let e=this.icn3d;if(e.icn3dui,void 0===e.bSSbondShown||!e.bSSbondShown)for(let t in e.ssbondChainbase){let s=e.ssbondChainbase[t];e.annoSsbondCls.showSsbond(t,s)}e.bSSbondShown=!0}updateCrosslink(){let e=this.icn3d;if(e.icn3dui,void 0===e.bCrosslinkShown||!e.bCrosslinkShown)for(let t in e.crosslinkChainbase){let s=e.crosslinkChainbase[t];e.annoCrossLinkCls.showCrosslink(t,s)}e.bCrosslinkShown=!0}async updateTransmem(){let e=this.icn3d,t=e.icn3dui;if(void 0===e.bTranememShown||!e.bTranememShown)for(let s in e.protein_chainid){let i=e.protein_chainid[s];if(void 0!==t.cfg.opmid)e.annoTransMemCls.showTransmem(s,i);else if(e.bAfMem&&e.afmem_start_end){let t=e.afmem_start_end[0],n=e.afmem_start_end[1];await e.annoPTMCls.showPTM(s,i,"afmem",t,n)}else await e.annoPTMCls.showPTM(s,i,"transmem")}e.bTranememShown=!0}}class It{constructor(e){this.icn3d=e}showAnnotations_part1(){let e=this.icn3d,t=e.icn3dui;if(t.htmlCls.dialogCls.openDlg("dl_selectannotations","Sequences and Annotations"),(void 0===e.bAssemblyNote||!e.bAssemblyNote)&&void 0!==e.asuCnt){let t="
    Assembly Tips: Only the asymmetric unit is shown in the sequence window.
    Click \"Assembly\" in the menu \"View\" to switch between asymmetric unit and biological assembly("+e.asuCnt+" asymmetric unit).
    ";$("#"+e.pre+"dl_annotations_tabs").append(t),e.bAssemblyNote=!0}e.bResetAnno&&(e.giSeq={},e.currClin={},e.resi2disease_nonempty={},e.baseResi={},e.matchedPos={},$("#"+t.pre+"dl_annotations").empty(),e.annotationCls.setAnnoView("overview"));let s={},i={},n={};if(void 0===e.bAnnoShown||!e.bAnnoShown||e.bResetAnno){e.protein_chainid={};let l,r=Object.keys(e.chains);void 0===e.giSeq&&(e.giSeq={}),void 0===e.currClin&&(e.currClin={}),void 0===e.resi2disease_nonempty&&(e.resi2disease_nonempty={}),void 0===e.baseResi&&(e.baseResi={}),void 0===e.matchedPos&&(e.matchedPos={}),l=t.bNode?500:t.cfg.notebook?t.htmlCls.WIDTH/2:$("#"+e.pre+"dl_selectannotations").dialog("option","width"),e.seqAnnWidth=l-120-60-50;for(let l=0,o=r.length;l1)e.protein_chainid[r[l]]=a;else if(e.nucleotides.hasOwnProperty(o.serial)&&e.chainsSeq[r[l]].length>1)s[r[l]]=a;else if(e.chainsSeq[r[l]].length>1)i[r[l]]=a;else{let t=e.chainsSeq[r[l]][0].name,s=r[l]+"_"+e.chainsSeq[r[l]][0].resi;void 0===n[t]&&(n[t]=[]),n[t].push(s)}if((void 0!==t.cfg.pdbid||void 0!==t.cfg.opmid||void 0!==t.cfg.mmcifid||void 0!==t.cfg.mmtfid)&&(e.proteins.hasOwnProperty(o.serial)||e.nucleotides.hasOwnProperty(o.serial)))for(let t=0,s=e.chainsSeq[r[l]].length;te.maxAnnoLength&&(e.protein_chainid.hasOwnProperty(t)||s.hasOwnProperty(t))&&(e.maxAnnoLength=e.chainsSeq[t].length)}return{nucleotide_chainid:s,chemical_chainid:i,chemical_set:n}}async showAnnotations(){let e=this.icn3d,t=e.icn3dui,s=this,i=this.showAnnotations_part1(),n=i.nucleotide_chainid,l=i.chemical_chainid,r=i.chemical_set;if(void 0===e.bAnnoShown||!e.bAnnoShown||e.bResetAnno)if(void 0===t.cfg.blast_rep_id){if(e.bFullUi){if(void 0!==t.cfg.mmtfid){let t=Object.keys(e.structures)[0];await e.mmcifParserCls.downloadMmcifSymmetry(t,"mmtfid")}await this.showAnnoSeqData(n,l,r)}}else if(void 0===t.cfg.blast_rep_id||e.bSmithwm||e.bLocalSmithwm){if(void 0!==t.cfg.blast_rep_id&&(e.bSmithwm||e.bLocalSmithwm)){let i,o,a=[t.cfg.blast_rep_id];if(-1!=t.cfg.query_id.indexOf(">")?o=t.cfg.query_id.substr(t.cfg.query_id.indexOf("\n")+1):!/\d/.test(t.cfg.query_id)||t.cfg.query_id.length>50?o=t.cfg.query_id:a.push(t.cfg.query_id),e.blastAcxn){let s=t.cfg.afid+"_A",n="";for(let t=0,i=e.chainsSeq[s].length;tProteins:

    ":"",a=e.chainsGene[s]&&e.chainsGene[s].geneId?"(Gene: "+e.chainsGene[s].geneSymbol+")":"",d=s.substr(0,s.indexOf("_")),c=d.length>5?''+s+"":s,h="
    "+o+"Annotations of "+c+": "+r+""+a+"   "+this.addButton(s,"icn3d-addtrack","Add Track","Add a custom track",60,i)+"   ";h+=this.addButton(s,"icn3d-customcolor","Custom Color/Tube","Use a custom file to define the colors or tubes in 3D structure",110,i)+"   ",h+=this.addButton(s,"icn3d-helixsets","Helix Sets",'Define sets for each helix in this chain and add them to the menu of "Defined Sets"',60,i)+" "+this.addButton(s,"icn3d-sheetsets","Sheet Sets",'Define sets for each sheet in this chain and add them to the menu of "Defined Sets"',60,i)+" "+this.addButton(s,"icn3d-coilsets","Coil Sets",'Define sets for each coil in this chain and add them to the menu of "Defined Sets"',60,i),$("#"+e.pre+"dl_annotations").append(h);let p=["giseq","cdd","clinvar","snp","site","ptm","ssbond","crosslink","transmem","domain","custom","interaction"];for(let t in p){let i=p[t];$("#"+e.pre+"anno_"+s).append(this.getAnDiv(s,i))}$("#"+e.pre+"anno_"+s).append("


    "),++n}if(t.bNode||e.annoCddSiteCls.setToolTip(),void 0!==e.chainid_seq)await this.processSeqData(e.chainid_seq);else try{let n=[],l=[];for(let e=0,t=i.length;e=6?l.push(i[e]):n.push(i[e]);if(n.length>0){let s=t.htmlCls.baseUrl+"/vastdyn/vastdyn.cgi?chainlist="+n;e.chainid_seq=await t.getAjaxPromise(s,"jsonp")}else e.chainid_seq={};for(let t=0,s=l.length;t40&&(r=r.substr(0,40)+"...");let o="";0==i&&("protein"==s?o="Proteins:

    ":"nucleotide"==s?o="Nucleotides:

    ":"chemical"==s&&(o="Chemicals/Ions/Water:

    ")),$("#"+n.pre+"dl_annotations").append("
    "+o+""+e+": "+r+"
    "),$("#"+n.pre+"anno_"+e).append(this.getAnDiv(e,"giseq")),$("#"+n.pre+"anno_"+e).append(this.getAnDiv(e,"interaction")),$("#"+n.pre+"anno_"+e).append("


    "),n.giSeq[e]=[];for(let t=0;tChemicals/Ions/Water:

    ":"",o=t[0].lastIndexOf("_"),a=t[0].substr(0,o),d=void 0!==l.cfg.mmdbid&&void 0!==n.chainid2sid?n.chainid2sid[a]:void 0;i=void 0!==d?""+e+" ":""+e+"",$("#"+n.pre+"dl_annotations").append("
    "+r+i+"
    "),$("#"+n.pre+"anno_"+e).append("
    "),$("#"+n.pre+"anno_"+e).append("


    ");let c='
    ';c+='",c+='Count: '+t.length+"",c+='';let h=c,p=c;for(let s=0,i=t.length;s3&&(l=i.substr(0,3)),s'+l+""}let m=l.htmlCls.GREY8,u=Math.round(n.seqAnnWidth*t.length/n.maxAnnoLength);u<1&&(u=1),p+='
     
    ',c="",c+="
    ",c+="
    ",h+=c,p+=c,$("#"+n.pre+"dt_giseq_"+e).html(h),$("#"+n.pre+"ov_giseq_"+e).html(p)}async processSeqData(e){let t=this.icn3d,s=t.icn3dui;for(let i in t.protein_chainid){let n=t.protein_chainid[i];if(e.hasOwnProperty(n)){let s=e[n];t.giSeq[i]=s;let l="";for(let e=0;e<10&&e14?"Query: "+o.substr(0,6)+"...":isNaN(s.cfg.query_id)?"Query: "+o:"Query: gi "+o;let a="cannot be aligned";t.queryStart="",t.queryEnd="",t.bRender&&alert("The sequence can NOT be aligned to the structure"),t.showSeqCls.showSeq(i,n,void 0,e,l,a,r)}else if(s.cfg.blast_rep_id==i&&(void 0!==t.seqStructAlignData||void 0!==t.seqStructAlignDataSmithwm)){let e,l,r,o,a,d=s.cfg.oriQuery_id?s.cfg.oriQuery_id:s.cfg.query_id;if(e=d.length>14?"Query: "+d.substr(0,6)+"...":isNaN(s.cfg.query_id)?"Query: "+d:"Query: gi "+d,void 0!==t.seqStructAlignData){let e,s,i=t.seqStructAlignData;if(void 0!==i.data){e=i.data[0].query;let t=Object.keys(i.data[0].targets);s=i.data[0].targets[t[0]],s=void 0!==s&&s.hsps.length>0?s.hsps[0]:void 0}if(void 0!==e&&void 0!==s){l=s.scores.e_value.toPrecision(2),l>1e-200&&(l=parseFloat(l).toExponential()),s.scores.bit_score;let t=Object.keys(i.targets);r=i.targets[t[0]].seqdata,o=e.seqdata,a=s.segs}}else{let e=t.seqStructAlignDataSmithwm;l=e.score,r=e.target.replace(/-/g,""),o=e.query.replace(/-/g,""),a=[];let s=-1,i=-1,n=!1,d={};for(let t=0,l=e.target.length;t0)if(i.orifrom-ni.from-l)for(let t=n+1;t
    "+i+"
    "}addButton(e,t,s,i,n,l){return this.icn3d.icn3dui,"
    "}addSnpButton(e,t,s,i,n,l){let r=this.icn3d;return r.icn3dui,"
    "}conservativeReplacement(e,t){let s=this.icn3d.icn3dui,i=-1!==s.parasCls.b62ResArray.indexOf(e)?s.parasCls.b62ResArray.indexOf(e):s.parasCls.b62ResArray.length-1,n=-1!==s.parasCls.b62ResArray.indexOf(t)?s.parasCls.b62ResArray.indexOf(t):s.parasCls.b62ResArray.length-1;return s.parasCls.b62Matrix[i][n]>0}getColorhexFromBlosum62(e,t){let s=this.icn3d.icn3dui;e=e.toUpperCase(),t=t.toUpperCase();let i=-1!==s.parasCls.b62ResArray.indexOf(e)?s.parasCls.b62ResArray.indexOf(e):s.parasCls.b62ResArray.length-1,n=-1!==s.parasCls.b62ResArray.indexOf(t)?s.parasCls.b62ResArray.indexOf(t):s.parasCls.b62ResArray.length-1,l=s.parasCls.b62Matrix[i][n];if(void 0===l)return"333333";let r="333333";if(l>0){let e=221-parseInt(l/11*221),t=e<10?"0"+e.toString(16):e.toString(16);r="DD"+t+t}else{let e=221-parseInt(-1*l/4*221),t=e<10?"0"+e.toString(16):e.toString(16);r=t+t+"DD"}return r}}class Tt{constructor(e){this.icn3d=e}showSeq(e,t,s,i,n,l,r){let o,a=this.icn3d,d=a.icn3dui,c=!1;if(void 0===d.cfg.mmdbid&&void 0===d.cfg.gi&&void 0===d.cfg.blast_rep_id&&void 0===d.cfg.align&&void 0===d.cfg.chainalign&&void 0===d.cfg.mmdbafid){c=!0,o=[];for(let t=0;t10){u='
    ';let t=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]);void 0===d.cfg.mmdbid&&void 0===d.cfg.gi&&void 0===d.cfg.blast_rep_id&&void 0===d.cfg.align&&void 0===d.cfg.chainalign&&void 0===d.cfg.mmdbafid||void 0===t.resi_ori||t.resi_ori==t.resi||-1!=e.indexOf("Misc")?u+='
    ':u+='
    NCBI Residue Numbers
    ',u+='',b+=u+"
    ",g+=u+'';let s=0,i=0,n="";for(let t=0,l=o.length;t",l%10==0&&(g+=l);let r=e+"_"+l,o=l%10!=0&&l%10!=1&&l%10!=9;if(a.residues.hasOwnProperty(r)){let e=a.firstAtomObjCls.getFirstCalphaAtomObj(a.residues[r]);"H"==a.secondaries[r]&&e.ssbegin?(++s,n='H'+s+"",o&&(g+=n,n="")):"E"==a.secondaries[r]&&e.ssbegin?(++i,"green"==a.sheetcolor?n='S'+i+"":"yellow"==a.sheetcolor&&(n='S'+i+""),o&&(g+=n,n="")):e.ssend&&(n=""),""!=n&&o&&(g+=n,n="")}g+=""}g+='',g+="",g+="
    ",g+="
    ",b+=""}u='
    ',u+='
    ',u+='',b+=u+"
    ",g+=u+'';for(let t=0,s=o.length;t':'',g+=" ";else if("E"==a.secondaries[s]){a.firstAtomObjCls.getFirstCalphaAtomObj(a.residues[s]).ssend?"green"==a.sheetcolor?g+='':"yellow"==a.sheetcolor&&(g+=''):"green"==a.sheetcolor?g+='':"yellow"==a.sheetcolor&&(g+=''),g+=" "}else"c"==a.secondaries[s]?g+=' ':"o"==a.secondaries[s]&&(g+=' ');else g+="-"}g+='',g+="",g+="
    ",g+="
    ",g+="",b+="",u=d.cfg.blast_rep_id===e?'
    ':'
    ';let C="Protein",y="Protein";void 0!==s&&("nucleotide"==s?(C="Nucl.",y="Nucleotide"):"chemical"==s&&(C="Chem.",y="Chemical")),u+='",u+=''+(a.baseResi[e]+1).toString()+"",b+=u+"
    ";let v='';g+=u+v,f+=u+v;let w,_=0;for(let t=0,s=o.length;t1&&(i=s[0]+".."),w=a.ParserUtilsCls.getResi(e,t),a.residues.hasOwnProperty(e+"_"+w)){let n="333333";if(d.cfg.blast_rep_id==e&&void 0!==a.fullpos2ConsTargetpos&&void 0!==a.fullpos2ConsTargetpos[t+_])n=a.fullpos2ConsTargetpos[t+_].color;else{let t=a.firstAtomObjCls.getFirstCalphaAtomObj(a.residues[e+"_"+w]),s=void 0===t.color||"FFFFFF"===t.color.getHexString()?"DDDDDD":t.color.getHexString();n=void 0!==t.color?s:"CCCCCC"}g+=''+i+""}else i=i.toLowerCase(),g+=''+i+""}d.cfg.blast_rep_id==e&&(a.opts.color=a.blastAcxn?"confidence":"conservation",a.setColorCls.setColorByOptions(a.opts,a.atoms));let S=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]),A=S.color?S.color.getHexString():"CCCCCC",x=Math.round(a.seqAnnWidth*o.length/a.maxAnnoLength);if(x<1&&(x=1),d.cfg.blast_rep_id!=e)f+='";else{let t=[],s=[];t.push(0);for(let e=0,i=o.length;e';for(let i=0,n=t.length;i'+e+"
    ";f+="
    "}if(u=''+w+"",u+="",u+="
    ",g+=u,f+=u,d.cfg.blast_rep_id==e){if(void 0!==r&&""!==r){u='",u+='',b+=u+"
    ";let t='';g+=u+t,f+=u+t;let s=0,i=0,l=1;a.queryStart;for(let t=0,n=r.length;t-";else if(" "==n)g+=" ";else{let r=a.fullpos2ConsTargetpos[t].pos;if(a.residues.hasOwnProperty(e+"_"+r)){let s=a.fullpos2ConsTargetpos[t].color;g+=''+n+""}else n=n.toLowerCase(),g+=''+n+"";f+=this.insertGapOverview(e,t);let o=Math.round(a.seqAnnWidth*t/(a.maxAnnoLength+a.nTotalGap)-s-i);o>=0&&(f+='
     
    ',f+='
     
    ',s+=o,i+=l)}}u='',u+="",u+="
    ",g+=u,f+=u}u='
    '+i+"
    ",u+=''+a.queryStart+"",b+=u+"
    ";let t='';g+=u+t,f+=u+t;let s=a.queryStart;for(let t=0,i=l.length;t-":(void 0===a.fullpos2ConsTargetpos||void 0===a.fullpos2ConsTargetpos[t]||a.residues.hasOwnProperty(e+"_"+a.fullpos2ConsTargetpos[t].pos)||(i=i.toLowerCase()),g+=''+i+"",++s)}let o=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]),d=void 0===o.color||"FFFFFF"===o.color.getHexString()?"DDDDDD":o.color.getHexString(),c=void 0!==o.color?d:"CCCCCC",h=[],p=[],m="-";for(let e=0,t=l.length;e ',f+='
    '+i+"
    "}u=''+a.queryEnd+"",u+="",u+="
    ",g+=u,f+=u}if(g+="",f+="",b+="",a.giSeq[e].length>10){let t=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]);if(void 0===d.cfg.mmdbid&&void 0===d.cfg.gi&&void 0===d.cfg.blast_rep_id&&void 0===d.cfg.align&&void 0===d.cfg.chainalign&&void 0===d.cfg.mmdbafid||void 0===t.resi_ori||t.resi_ori==t.resi||-1!=e.indexOf("Misc")){if(a.bShowRefnum&&a.chainid2index.hasOwnProperty(e)){let t=this.showRefNum(o,e);g+=t.html,b+=t.html3;let s=1;t=this.showRefNum(o,e,s),g+=t.html,b+=t.html3,s=2,t=this.showRefNum(o,e,s),g+=t.html,b+=t.html3}else if(a.bShowCustomRefnum&&a.chainsMapping.hasOwnProperty(e)){let t=!0,s=this.showRefNum(o,e,void 0,t);g+=s.html,b+=s.html3}}else{u='
    ',u+='
    ',u+='
    PDB Residue Numbers
    ',u+='',b+=u+"
    ",g+=u+'';for(let t=0,s=o.length;t",e%10==0&&(g+=e+" "),g+=""}else g+=""}g+='',g+="",g+="
    ",g+="
    ",g+="
    ",b+=""}}a.bShowRefnum&&(a.hAtoms=a.hAtomsRefnum,a.hlUpdateCls.updateHlAll()),$("#"+a.pre+"dt_giseq_"+e).html(g),$("#"+a.pre+"ov_giseq_"+e).html(f),$("#"+a.pre+"tt_giseq_"+e).html(b)}showRefNum(e,t,s,i){let n=this.icn3d;n.icn3dui;let l="",r="",o="";for(let e=0,s=n.chainid2index[t].length;eCustom Ref. No.':1==s?'
    Kabat Ref. No.
    ':2==s?'
    IMGT Ref. No.
    ':'
    IgStRAnD Ref. No.
    ',d+='',r+=d+"
    ",l+=d+'';let c=!1;for(let s=0,l=e.length;s0){c=!0;break}}if(1==s&&!c)return{html:"",html3:""};let h=!1;for(let s=0,l=e.length;s0){h=!0;break}}if(2==s&&!h)return{html:"",html3:""};let p,m,u,g,f,b,C,y,v,w=!1,_="",S="",A="",x=1,k={},O=1,R="",E=!1;for(let l=0,r=e.length;l1e3&&"9"!=u.substr(1,1)&&(x=1,E&&R&&(delete k[R],R="")),S&&" "!=_&&f>1e3&&"9"==u.substr(1,1)&&(1==x&&(k.hasOwnProperty(_+g)&&++O,g=u.replace(f.toString(),"")+"_"+O,k[_+g]={},k[_+g].start=b,k[_+g].chainid=t),u=(1e3*parseInt(A)+900+x).toString(),p=_+u,++x))):!S||" "==_||i||s||(1==x&&(k.hasOwnProperty(_+g)?(++O,g=u.replace(f.toString(),"")+"_"+O,k[_+g]={}):k[_+g]={},k[_+g].start=b,k[_+g].chainid=t,R=_+g,E=!0),u=(1e3*parseInt(A)+900+x).toString(),p=_+u,++x),b=u,y=f,C=g,S=_}k[S+C]&&(k[S+C].len=x-1,k[S+C].end=b),O=1,R="",E=!1;let I,T={},M=!0;for(let r=0,o=e.length;r1e3&&"9"!=u.substr(1,1)&&(x=1,E&&R&&(--O,R="")),S&&f>1e3&&"9"==u.substr(1,1)){w=!0,1==x&&(T.hasOwnProperty(I+g)&&(++O,g=u.replace(f.toString(),"")+"_"+O),T[I+g]=1);let e=this.getAdjustedRefnum(k,I,x,A,g,y);f=e.refnum,M=e.bShowRefnum,u=e.refnumStr,p=e.refnumLabel,v=e.refnumLabelNoPostfix,a=e.bHidelabel,_=p.replace(new RegExp(u,"g"),""),++x}y=f}if(i)if(u){l+=parseInt(u)%2==0?''+u+"":' '}else l+="";else if(1==s||2==s)if(u){let e=parseInt(u).toString(),t='style="color:'+this.getRefnumColor(_)+'"';l+=parseInt(e.substr(e.length-2,2))%2==0?"'+u+"":" '}else l+="";else M&&" "!=_?(l+=this.getRefnumHtml(e,u,m,p,_,w,a),w&&(n.residIgLoop[e]=1)):l+=""}else{let t=n.firstAtomObjCls.getFirstAtomObj(n.residues[e]);if(t&&!n.proteins.hasOwnProperty(t.serial)||!S||i||s||I&&"G"==I.substr(0,1))l+="";else{w=!0,1==x&&(T.hasOwnProperty(I+g)&&++O,g=u.replace(f.toString(),"")+"_"+O,T[I+g]=1,E=!0,R=I+g);let t=this.getAdjustedRefnum(k,I,x,A,g,y);f=t.refnum,M=t.bShowRefnum,u=t.refnumStr,p=t.refnumLabel,v=t.refnumLabelNoPostfix,y=f,a=t.bHidelabel,_=p.replace(new RegExp(u,"g"),""),++x,M&&" "!=_?(l+=this.getRefnumHtml(e,u,m,p,_,w,a),w&&(n.residIgLoop[e]=1)):l+=""}}n.resid2refnum[e]=p,n.refnum2residArray.hasOwnProperty(u)?n.refnum2residArray[u].push(e):n.refnum2residArray[u]=[e],n.chainsMapping.hasOwnProperty(t)||(n.chainsMapping[t]={}),n.chainsMapping[t][e]=v,S=I}return l+='',l+="",l+="
    ",l+="",l+="",r+="",{html:l,html3:r}}getAdjustedRefnum(e,t,s,i,n,l){let r,o,a,d;this.icn3d.icn3dui;let c=!1,h=!0;if(e[t+n]){let i=parseInt(e[t+n].start),p=parseInt(e[t+n].end),m=e[t+n].start.replace(i.toString(),""),u=e[t+n].end.replace(p.toString(),""),g=e[t+n].len;s<=(e[t+n].nextStrand?parseInt(g/2+.5):g)?(r=i+s,o=r+m,a=t+o):(r=p-(g+1-s),o=r+u,a=void 0!==e[t+n].nextStrand?e[t+n].nextStrand+o:" "+o),d=t+r,1!=s&&s!=p-1||(c=!0),1==s&&i!=l&&(h=!1,r=0,o="",a="",d="")}else r=0,o="",a="",d="",c=!0;return{refnum:r,refnumStr:o,refnumLabel:a,refnumLabelNoPostfix:d,bHidelabel:c,bShowRefnum:h}}getRefnumHtml(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui,d=parseInt(t).toString(),c=this.getRefnumColor(n),h=l?'style="color:'+c+'"':'style="color:'+c+'; text-decoration: underline overline;"',p=parseInt(d.substr(d.length-2,2));parseInt(d.substr(d.length-3,3));let m="";if(50!=p||l)if(p%2!=0||52==p||r)m+=" ';else{m+="'+(isNaN(t)?p+t.substr(t.length-1,1):p)+""}else o.hAtomsRefnum=a.hashUtilsCls.unionHash(o.hAtomsRefnum,o.residues[e]),m+="'+i.substr(0,1)+""+i.substr(1)+"";return m}getRefnumColor(e){let t=this.icn3d.icn3dui;return"A^"==e?"#FF00FF":"A"==e?"#663399":"A*"==e?"#FFC0CB":"A'"==e?"#9370db":"B"==e?"#ba55d3":"C"==e?"#0000FF":"C'"==e?"#6495ED":"C''"==e?"#006400":"D"==e?"#00FF00":"E"==e?"#FFFF00":"F"==e?"#FFA500":"G"==e?"#FF0000":"G*"==e?"#8B0000":t.htmlCls.GREYB}insertGap(e,t,s,i){let n=this.icn3d;n.icn3dui;let l="";if(void 0!==n.targetGapHash&&n.targetGapHash.hasOwnProperty(t))for(let e=0;e"+s+"";return l}insertGapOverview(e,t){let s=this.icn3d,i="";if(s.icn3dui.cfg.blast_rep_id==e&&void 0!==s.targetGapHash&&s.targetGapHash.hasOwnProperty(t)){i+='
     
    '}return i}setAlternativeSeq(e,t){let s=this.icn3d;s.icn3dui;let i=s.chainsSeq[e];s.giSeq[e]=[];for(let t=0,n=i.length;t1&&s.htmlCls.clickMenuCls.setLogCmd("select sets "+e,!0)}else{let o={};if(void 0!==$(e).attr("domain")||void 0!==$(e).attr("feat")||void 0!==$(e).attr("3ddomain")||void 0!==$(e).attr("custom")){t.hlUpdateCls.hlSummaryDomain3ddomain(e);let a,d,c,h=$(e).attr("from").split(","),p=$(e).attr("to").split(",");r.substr(0,r.indexOf("_"));for(let s=0,i=h.length;s1&&s.htmlCls.clickMenuCls.setLogCmd("select sets "+c,!0)}}else{t.bCtrl||t.bShift?(t.currSelectedSets.push(i),t.selectionCls.selectAChain(r,i,!0,!0)):(t.currSelectedSets=[i],t.selectionCls.selectAChain(r,i,t.bAlignSeq)),t.bAlignSeq?s.htmlCls.clickMenuCls.setLogCmd("select alignChain "+r,!0):s.htmlCls.clickMenuCls.setLogCmd("select chain "+r,!0);let e=t.currSelectedSets.join(" or ");t.currSelectedSets.length>1&&s.htmlCls.clickMenuCls.setLogCmd("select sets "+e,!0)}else t.hlObjectsCls.removeHlObjects(),t.hlUpdateCls.removeHl2D(),$("#"+t.pre+"atomsCustom").val("")}}selectResidues(e,t){let s=this.icn3d,i=s.icn3dui;if(!i.bNode&&(!1!==s.bSelectResidue||s.bShift||s.bCtrl||s.selectionCls.removeSelection(),void 0!==e&&""!==e)){e=e.substr(e.indexOf("_")+1),s.bSelectResidue=!0,$(t).toggleClass("icn3d-highlightSeq");let n=e.substr(e.indexOf("_")+1);if(s.residues.hasOwnProperty(n))if($(t).hasClass("icn3d-highlightSeq")){for(let e in s.residues[n])s.hAtoms[e]=1;if(s.selectedResidues[n]=1,s.bAnnotations&&void 0!==$(t).attr("disease")){let e=$(t).attr("disease"),l=s.applyCenterCls.centerAtoms(i.hashUtilsCls.hash2Atoms(s.residues[n],s.atoms)),r=15;e.length>r&&(e=e.substr(0,r)+"...");let o=s.LABELSIZE,a=i.htmlCls.GREYD;s.analysisCls.addLabel(e,l.center.x,l.center.y,l.center.z,o,a,void 0,"custom")}}else{for(let e in s.residues[n])delete s.hAtoms[e];delete s.selectedResidues[n],s.hlObjectsCls.removeHlObjects()}}}}class Pt{constructor(e){this.icn3d=e}update2DdgmContent(){let e=this.icn3d,t=e.icn3dui,s="";void 0!==t.cfg.mmdbid||void 0!==t.cfg.gi?(s+=e.diagram2dCls.draw2Ddgm(e.interactionData,e.inputid,void 0,!0),s+=e.diagram2dCls.set2DdgmNote(),$("#"+e.pre+"dl_2ddgm").html(s)):e.mmdbidArray&&(void 0!==t.cfg.align||void 0!==t.cfg.chainalign||e.bRealign)&&(s+=e.diagram2dCls.draw2Ddgm(e.interactionData1,e.mmdbidArray[0].toUpperCase(),0,!0),void 0!==e.mmdbid_q&&e.mmdbid_q===e.mmdbid_t?s+=e.diagram2dCls.draw2Ddgm(e.interactionData2,e.mmdbidArray[0].toUpperCase(),1,!0):s+=e.diagram2dCls.draw2Ddgm(e.interactionData2,e.mmdbidArray[1].toUpperCase(),1,!0),s+=e.diagram2dCls.set2DdgmNote(!0),$("#"+e.pre+"dl_2ddgm").html(s))}changeSeqColor(e){let t=this.icn3d,s=t.icn3dui;for(let i=0,n=e.length;i0&&($("#"+e.pre+"dl_2ddgm svg line").attr("stroke","#000000"),$("#"+e.pre+"dl_2ddgm line").attr("stroke-width",1))}removeHlMenus(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"atomsCustom").val(""),$("#"+e.pre+"atomsCustom")[0].blur()}updateHlAll(e,t,s,i){let n=this.icn3d,l=n.icn3dui;n.prevHighlightAtoms=l.hashUtilsCls.cloneHash(n.hAtoms),this.updateHlObjects(i),void 0!==e?this.updateHlSeqInChain(e,s):this.updateHlSeq(void 0,void 0,s),this.updateHl2D(),(void 0===t||t)&&this.updateHlMenus(e)}updateHlObjects(e){let t=this.icn3d;t.icn3dui,t.hlObjectsCls.removeHlObjects(),(t.hAtoms&&t.atoms&&Object.keys(t.hAtoms).length0&&(e=s.defNames2Residues[i]);let t={};if(void 0!==s.defNames2Atoms[i]&&s.defNames2Atoms[i].length>0){for(let e=0,n=s.defNames2Atoms[i].length;e0&&(r=t.firstAtomObjCls.getFirstCalphaAtomObj(l))}let o=void 0!==r&&void 0!==r.color?"#"+r.color.getHexString():"#FFFFFF",a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] rect[class='icn3d-hlnode']"),d=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] rect[class='icn3d-basenode']");void 0!==a&&(t.diagram2dCls.highlightNode("rect",a,d,l),$(a).attr("fill",o)),a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] circle[class='icn3d-hlnode']"),d=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] circle[class='icn3d-basenode']"),void 0!==a&&(t.diagram2dCls.highlightNode("circle",a,d,l),$(a).attr("fill",o)),a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] ellipse[class='icn3d-hlnode']"),void 0!==a&&t.diagram2dCls.highlightNode("ellipse",a,void 0,l),a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] polygon[class='icn3d-hlnode']"),d=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] polygon[class='icn3d-basenode']"),void 0!==a&&(t.diagram2dCls.highlightNode("polygon",a,d,l),$(a).attr("fill",o))}if(void 0!==t.lineArray2d)for(let e=0,i=t.lineArray2d.length;e1){let e={},l=[],o=[],a=[],c=[],h=[],m=[],u=[],g=[],f=[],b=[],C=[],y=[],v={};for(let t=0,s=p.length;t0&&(E=1,t=i.getGraphCls.getNodeTopBottom(c[e],d,void 0,E,g[e]),h[e]=t.nodeArray1,m[e]=t.nodeArray2,d=n.hashUtilsCls.unionHash(d,t.name2node),E=2,t=i.getGraphCls.getNodeTopBottom(c[e],d,void 0,E,y[e]),f[e]=t.nodeArray1,b[e]=t.nodeArray2,d=n.hashUtilsCls.unionHash(d,t.name2node)),x[e]=l[e].length,k[e]=o[e].length,O=Math.max(O,k[e]),R.push(p[e])}let I,T,M,P,D,H=1,F=3*H,L=7*H,N=10,U=10,q=30,$=20;t?(M=(n.utilsCls.sumArray(x)+2*R.length)*(F+L)+4*U+2*q+$*R.length,T=(O+2)*(F+L)+2*N+q):(I=110+$,M=I*R.length,T=(O+2)*(F+L)+2*N),Object.keys(i.chainsMapping).length>0&&(M*=3),t?(i.scatterplotWidth=2*T,D=i.scatterplotWidth,P=n.scatterplotid):(i.linegraphWidth=2*T,D=i.linegraphWidth,P=n.linegraphid),s=0==R.length?"No interactions found for each structure

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

    ",s+="";let j,B=0;E=0,j=this.drawGraphPerType(E,p,t,l,o,a,d,B,I,$,x,F,L,U),B=j.heightFinal,s+=j.html,Object.keys(i.chainsMapping).length>0&&(E=1,j=this.drawGraphPerType(E,p,t,h,m,u,d,B,I,$,x,F,L,U),B=j.heightFinal,s+=j.html,E=2,j=this.drawGraphPerType(E,p,t,f,b,C,d,B,I,$,x,F,L,U),B=j.heightFinal,s+=j.html),s+=""}else if(t){let e,t,l,c,h=p[0],m=o.length,u=a.length,g=1,f=3*g,b=7*g,C=30;t=(m+2)*(f+b)+2*10+C,e=(u+2)*(f+b)+2*10+C,i.scatterplotWidth=2*e,c=i.scatterplotWidth,l=n.scatterplotid,s=r.length>0?"":"No interactions found for these two sets

    ",s+="",s+=this.drawScatterplot_base(o,a,r,d,0),i.lineGraphStr+=i.getGraphCls.updateGraphJson(h,1,o,a,r),s+=""}else{let e=p[0],t=o.length,l=a.length,c=1,h=3*c,m=7*c,u=110,g=10,f=t>l?t*(h+m)+2*g:l*(h+m)+2*g;i.linegraphWidth=2*f,s=r.length>0?"":"No interactions found for these two sets

    ",s+="",s+=this.drawLineGraph_base(o,a,r,d,0),i.lineGraphStr+=i.getGraphCls.updateGraphJson(e,1,o,a,r),s+=""}return i.lineGraphStr+="}\n",i.scatterplotStr=i.lineGraphStr,t?$("#"+i.pre+"scatterplotDiv").html(s):$("#"+i.pre+"linegraphDiv").html(s),s}drawGraphPerType(e,t,s,i,n,l,r,o,a,d,c,h,p,m){let u=this.icn3d;u.icn3dui;let g,f,b="",C=2==t.length&&"2"==t[1].replace(t[0],"");0==e?(g="Interactions in ",f=""):1==e?(g="Common interactions in ",f="_common"):2==e&&(g="Different interactions in ",f="_diff");for(let y=0,v=t.length;y0&&(u.lineGraphStr+=", \n"):u.lineGraphStr+=", \n",u.lineGraphStr+=u.getGraphCls.updateGraphJson(t[y],y+f,i[y],n[y],l[y])}return{heightFinal:o,html:b}}getIdArrayFromNode(e){let t=this.icn3d.icn3dui,s=[];s.push(""),s.push("");let i=e.r.substr(4);return s=s.concat(t.utilsCls.getIdArray(i)),s}drawLineGraph_base(e,t,s,i,n,l,r){let o,a,d=this.icn3d,c=d.icn3dui,h="",p=e.length,m=t.length;p>m?(o=10,a=10*Math.abs(p-m)*.5+10):(a=10,o=10*Math.abs(p-m)*.5+10),l&&(h+=""+l+"");let u=30+n,g=80+n,f="",b={},C={};for(let t=0;t",h+="Interaction of residue "+n.id+" with residue "+l.id+"",h+="")}return h+=f,h}drawScatterplot_base(e,t,s,i,n,l,r,o,a){let d=this.icn3d;d.icn3dui;let c="",h=e.length,p=t.length,m=l?3:7,u=(h+1)*(3+m)+30+40;r&&(c+=""+r+"");let g=n+u-(50+(3+m)),f=40+(3+m),b="",C={},y={};for(let t=0;t"):(h+="",h+="Interaction of residue "+t.id+" with residue "+s.id+"",h+=l?"":"",h+=""))),h}copyStylesInline(e,t){this.icn3d.icn3dui;let s=["svg","g"];for(let i=0;i";return b+=""+e.id+"",o?(b+="",b+=""+g+""):(b+="",b+=""+g+""),b+="",b}getNodeTopBottom(e,t,s,i,n){let l=this.icn3d.icn3dui,r=this,o=[],a=[],d={};for(let s in e){let e=t[s];if(e){if(1==i||2==i){if(e=l.hashUtilsCls.cloneHash(e),1==i){let t=n[s]?n[s]:"-";e.id+="=>"+t}else{let t=n[s]?n[s]:"--";e.id+="==>"+t}d[e.id]=e}"a"==e.s?o.push(e):"b"==e.s?a.push(e):"ab"==e.s&&(o.push(e),a.push(e))}}return o.sort((function(e,t){return r.compNode(e,t)})),a.sort((function(e,t){return r.compNode(e,t,s)})),{nodeArray1:o,nodeArray2:a,name2node:d}}updateGraphJson(e,t,s,i,n){let l=this.icn3d.icn3dui,r="";return r+='"structure'+t+'": {"id": "'+e+'", "nodes1":[',r+=l.utilsCls.getJSONFromArray(s),r+='], \n"nodes2":[',r+=l.utilsCls.getJSONFromArray(i),r+='], \n"links":[',r+=l.utilsCls.getJSONFromArray(n),r+="]}",r}updateGraphColor(){let e=this.icn3d,t=e.icn3dui;if(void 0!==e.graphStr){let s=JSON.parse(e.graphStr),i={};for(let t in e.residues){let s=e.firstAtomObjCls.getFirstAtomObj(e.residues[t]);i[t]=s.color.getHexString().toUpperCase()}let n={};for(let e=0,l=s.nodes.length;e0&&c==e.chain&&(n.resid2ncbi[e.resi]==n.resid2ncbi[p]+1||n.resid2ncbi[e.resi]==n.resid2ncbi[p])&&(o.push('{"source": "'+h+'", "target": "'+u+'", "v": '+d+', "c": "'+f+'"}'),e.ssbegin&&(d=l.htmlCls.ssValue),e.ssend&&(d=l.htmlCls.coilValue)),c=e.chain,h=u,p=e.resi,++a}}return{node:r,link:o}}getHbondLinksForSet(e,t){let s=this.icn3d,i=s.icn3dui,n={},l=parseFloat($("#"+s.pre+"hbondthreshold").val()),r=e,o=r;if(Object.keys(o).length>0&&Object.keys(r).length>0){let e=!1;s.hBondCls.calculateChemicalHbonds(i.hashUtilsCls.intHash2Atoms(s.dAtoms,o,s.atoms),i.hashUtilsCls.intHash2Atoms(s.dAtoms,r,s.atoms),parseFloat(l),e,"graph",!0),n=i.hashUtilsCls.cloneHash(s.resid2Residhash)}return this.getGraphLinks(n,n,i.htmlCls.hbondInsideColor,t,i.htmlCls.hbondValuehbondInsideValue)}getIonicLinksForSet(e,t){let s=this.icn3d,i=s.icn3dui,n={},l=parseFloat($("#"+s.pre+"saltbridgethreshold").val()),r=e,o=r;if(Object.keys(o).length>0&&Object.keys(r).length>0){let e=!1;s.saltbridgeCls.calculateIonicInteractions(i.hashUtilsCls.intHash2Atoms(s.dAtoms,o,s.atoms),i.hashUtilsCls.intHash2Atoms(s.dAtoms,r,s.atoms),parseFloat(l),e,"graph",!0),n=i.hashUtilsCls.cloneHash(s.resid2Residhash)}return this.getGraphLinks(n,n,i.htmlCls.ionicInsideColor,t,i.htmlCls.ionicInsideValue)}getHalogenPiLinksForSet(e,t){let s,i=this.icn3d,n=i.icn3dui,l={},r=e,o=r,a="";return s=parseFloat($("#"+i.pre+"halogenthreshold").val()),Object.keys(o).length>0&&Object.keys(r).length>0&&(i.piHalogenCls.calculateHalogenPiInteractions(n.hashUtilsCls.intHash2Atoms(i.dAtoms,r,i.atoms),n.hashUtilsCls.intHash2Atoms(i.dAtoms,o,i.atoms),parseFloat(s),"graph","halogen",!0),l=n.hashUtilsCls.cloneHash(i.resid2Residhash)),a+=this.getGraphLinks(l,l,n.htmlCls.halogenInsideColor,t,n.htmlCls.halogenInsideValue),s=parseFloat($("#"+i.pre+"picationthreshold").val()),Object.keys(o).length>0&&Object.keys(r).length>0&&(i.piHalogenCls.calculateHalogenPiInteractions(n.hashUtilsCls.intHash2Atoms(i.dAtoms,r,i.atoms),n.hashUtilsCls.intHash2Atoms(i.dAtoms,o,i.atoms),parseFloat(s),"graph","pi-cation",!0),l=n.hashUtilsCls.cloneHash(i.resid2Residhash)),a+=this.getGraphLinks(l,l,n.htmlCls.picationInsideColor,t,n.htmlCls.picationInsideValue),s=parseFloat($("#"+i.pre+"pistackingthreshold").val()),Object.keys(o).length>0&&Object.keys(r).length>0&&(i.piHalogenCls.calculateHalogenPiInteractions(n.hashUtilsCls.intHash2Atoms(i.dAtoms,r,i.atoms),n.hashUtilsCls.intHash2Atoms(i.dAtoms,o,i.atoms),parseFloat(s),"graph","pi-stacking",!0),l=n.hashUtilsCls.cloneHash(i.resid2Residhash)),a+=this.getGraphLinks(l,l,n.htmlCls.pistackingInsideColor,t,n.htmlCls.pistackingInsideValue),a}getContactLinksForSet(e,t,s){let i=this.icn3d;i.icn3dui;let n=[],l="",r="",o={};for(let t in e){let e=i.atoms[t];e.ss==l&&e.chain==r||(Object.keys(o).length>0&&n.push(o),o={}),o[e.serial]=1,l=e.ss,r=e.chain}Object.keys(o).length>0&&n.push(o);let a=n.length,d="";for(let e=0;ed?s?-1:1:ah?1:c0&&Object.keys(a).length>0)){let t,s=c.hBondCls.calculateChemicalHbonds(h.hashUtilsCls.intHash2Atoms(c.dAtoms,d,c.atoms),h.hashUtilsCls.intHash2Atoms(c.dAtoms,a,c.atoms),parseFloat(e),n);n?(c.resid2ResidhashSaltbridge=h.hashUtilsCls.cloneHash(c.resid2Residhash),t="all atoms that have salt bridges with the selected atoms"):(c.resid2ResidhashHbond=h.hashUtilsCls.cloneHash(c.resid2Residhash),t="all atoms that are hydrogen-bonded with the selected atoms");let i={};for(let e in s){i[c.atoms[e].structure+"_"+c.atoms[e].chain+"_"+c.atoms[e].resi]=1}c.hAtoms={};for(let e in i)for(let t in c.residues[e])c.hAtoms[t]=1,c.atoms[t].style2="stick";let l=r+"_auto";c.selectionCls.addCustomSelection(Object.keys(i),l,t,o,!0),c.selectionCls.saveSelectionIfSelected(),c.drawCls.draw()}}showHydrogens(){let e=this.icn3d;if(void 0!==e.icn3dui.cfg.cid)for(let t in e.hAtoms){let s=e.atoms[t];if("H"!==s.elem.substr(0,1)){e.atoms[s.serial].bonds=e.atoms[s.serial].bonds2.concat(),e.atoms[s.serial].bondOrder=e.atoms[s.serial].bondOrder2.concat();for(let t=0,i=e.atoms[s.serial].bonds.length;t0){let i=e.atoms[t].bonds[0];e.atoms[i].bonds.push(s.serial),e.atoms[i].bondOrder&&e.atoms[i].bondOrder.push(1)}e.dAtoms[t]=1}}e.bShowHighlight=!1}hideHydrogens(){let e=this.icn3d;e.icn3dui;for(let t in e.hAtoms){let s=e.atoms[t];if("H"===s.elem.substr(0,1)){if(e.atoms[s.serial].bonds.length>0){let t=e.atoms[s.serial].bonds[0],i=e.atoms[t].bonds?e.atoms[t].bonds.indexOf(s.serial):-1;-1!==i&&(e.atoms[t].bonds.splice(i,1),e.atoms[t].bondOrder&&e.atoms[t].bondOrder.splice(i,1))}delete e.dAtoms[s.serial],delete e.hAtoms[s.serial]}}}hideHbondsContacts(){let e=this.icn3d,t=e.icn3dui,s="set hbonds off";t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.hBondCls.hideHbonds(),s="set salt bridge off",t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.saltbridgeCls.hideSaltbridge(),s="set contact off",t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.contactCls.hideContact(),s="set halogen pi off",t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.piHalogenCls.hideHalogenPi()}showIonicInteractions(e,t,s,i,n,l){let r,o,a,d,c=this.icn3d,h=c.icn3dui;if(!i&&(r="saltbridge",o="salt bridge "+e+" | sets "+t+" "+s+" | "+i,c.opts.saltbridge="yes",a=c.definedSetsCls.getAtomsFromNameArray(t),d=c.definedSetsCls.getAtomsFromNameArray(s),c.firstAtomObjCls.getFirstAtomObj(a),Object.keys(d).length>0&&Object.keys(a).length>0)){let t,s=c.saltbridgeCls.calculateIonicInteractions(h.hashUtilsCls.intHash2Atoms(c.dAtoms,d,c.atoms),h.hashUtilsCls.intHash2Atoms(c.dAtoms,a,c.atoms),parseFloat(e),n);c.resid2ResidhashSaltbridge=h.hashUtilsCls.cloneHash(c.resid2Residhash),t="all atoms that have ionic interactions with the selected atoms";let i={};for(let e in s){i[c.atoms[e].structure+"_"+c.atoms[e].chain+"_"+c.atoms[e].resi]=1}c.hAtoms={};for(let e in i)for(let t in c.residues[e])c.hAtoms[t]=1,c.atoms[t].style2="stick",c.ions.hasOwnProperty(t)&&(c.atoms[t].style2="sphere");let l="saltbridge_auto";c.selectionCls.addCustomSelection(Object.keys(i),l,t,o,!0),c.selectionCls.saveSelectionIfSelected(),c.drawCls.draw()}}showHalogenPi(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(i)return;let a,d,c=l+" "+e+" | sets "+t+" "+s+" | "+i;if(r.opts[l]="yes",a=r.definedSetsCls.getAtomsFromNameArray(t),d=r.definedSetsCls.getAtomsFromNameArray(s),r.firstAtomObjCls.getFirstAtomObj(a),Object.keys(d).length>0&&Object.keys(a).length>0){let t,s=r.piHalogenCls.calculateHalogenPiInteractions(o.hashUtilsCls.intHash2Atoms(r.dAtoms,a,r.atoms),o.hashUtilsCls.intHash2Atoms(r.dAtoms,d,r.atoms),parseFloat(e),n,l);"halogen"==l?(r.resid2ResidhashHalogen=o.hashUtilsCls.cloneHash(r.resid2Residhash),t="all atoms that have halogen bonds with the selected atoms"):"pi-cation"==l?(r.resid2ResidhashPication=o.hashUtilsCls.cloneHash(r.resid2Residhash),t="all atoms that have pi-cation interactions with the selected atoms"):"pi-stacking"==l&&(r.resid2ResidhashPistacking=o.hashUtilsCls.cloneHash(r.resid2Residhash),t="all atoms that have pi-stacking with the selected atoms");let i={};for(let e in s){i[r.atoms[e].structure+"_"+r.atoms[e].chain+"_"+r.atoms[e].resi]=1}r.hAtoms={};for(let e in i)for(let t in r.residues[e])r.hAtoms[t]=1,r.atoms[t].style2="stick",r.ions.hasOwnProperty(t)&&(r.atoms[t].style2="sphere");let h=l+"_auto";r.selectionCls.addCustomSelection(Object.keys(i),h,t,c,!0),r.selectionCls.saveSelectionIfSelected(),r.drawCls.draw()}}showClbonds(){let e=this.icn3d,t=e.icn3dui;e.opts.clbonds="yes";let s=e.applyClbondsCls.applyClbondsOptions();for(let i in s)e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.residues[i]);if(Object.keys(s).length>0){let t="clbonds",i="all atoms that have cross-linkages";e.selectionCls.addCustomSelection(Object.keys(s),t,i,"cross linkage",!0),e.selectionCls.saveSelectionIfSelected(),e.drawCls.draw()}}showSsbonds(){let e=this.icn3d,t=e.icn3dui;e.opts.ssbonds="yes";let s={},i=Object.keys(e.structures);for(let n=0,l=i.length;n0){let t="ssbonds",i="all atoms that have disulfide bonds";e.selectionCls.addCustomSelection(Object.keys(s),t,i,"disulfide bonds",!0),e.selectionCls.saveSelectionIfSelected(),e.drawCls.draw()}}pickCustomSphere(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(i)return;let a,d,c="select zone cutoff "+e+" | sets "+t+" "+s+" | "+i;n&&(c="interactions "+e+" | sets "+t+" "+s+" | "+i,r.opts.contact="yes"),a=r.definedSetsCls.getAtomsFromNameArray(t),d=r.definedSetsCls.getAtomsFromNameArray(s);let h,p,m=this.pickCustomSphere_base(e,a,d,i,n,l,c,!0),u=Object.keys(m.residues);r.hAtoms={};for(let e=0,t=u.length;e1?"structure":v>1?"chain":"residue";let _=[];if(n&&_.push("hbonds"),l&&_.push("salt bridge"),r&&_.push("interactions"),o&&_.push("halogen"),a&&_.push("pi-cation"),d&&_.push("pi-stacking"),s||(p.resids2inter={},p.resids2interAll={}),l){let n=parseFloat($("#"+p.pre+"saltbridgethreshold").val());n&&!isNaN(n)||(n=p.tsIonic),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showIonicInteractions(n,e,t,s,!0,i)),g=m.hashUtilsCls.unionHash(g,p.hAtoms)}if(n){let n=parseFloat($("#"+p.pre+"hbondthreshold").val());n&&!isNaN(n)||(n=p.tsHbond),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHbonds(n,e,t,s,void 0,i)),g=m.hashUtilsCls.unionHash(g,p.hAtoms)}let S,A,x,k,O="";if(n&&(O+=this.exportHbondPairs(i,u)),l&&(O+=this.exportSaltbridgePairs(i,u)),o){let n=parseFloat($("#"+p.pre+"halogenthreshold").val());n&&!isNaN(n)||(n=p.tsHalogen),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHalogenPi(n,e,t,s,i,"halogen")),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportHalogenPiPairs(i,u,"halogen")}if(a){let n=parseFloat($("#"+p.pre+"picationthreshold").val());n&&!isNaN(n)||(n=p.tsPication),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHalogenPi(n,e,t,s,i,"pi-cation")),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportHalogenPiPairs(i,u,"pi-cation")}if(d){let n=parseFloat($("#"+p.pre+"pistackingthreshold").val());n&&!isNaN(n)||(n=p.tsPistacking),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHalogenPi(n,e,t,s,i,"pi-stacking")),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportHalogenPiPairs(i,u,"pi-stacking")}if(r){let n=b?c:parseFloat($("#"+p.pre+"contactthreshold").val());if(n&&!isNaN(n)||(n=p.tsContact),1!=e.length||1!=t.length||e[0]!=t[0])s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.pickCustomSphere(n,e,t,s,!0,i)),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportSpherePairs(!0,i,u);else{if(!s){let l={},o={};if(b){let e=!0,t=p.showInterCls.pickCustomSphere_base(n,C,y,s,!0,void 0,void 0,!0,e);l=m.hashUtilsCls.unionHash(l,t.residues);for(let e in t.resid2Residhash)o[e]=m.hashUtilsCls.unionHash(o[e],t.resid2Residhash[e])}else{let r=[],a="",d="",c={};for(let e in C){let t=p.atoms[e];t.ss==a&&t.chain==d||(Object.keys(c).length>0&&r.push(c),c={}),c[t.serial]=1,a=t.ss,d=t.chain}Object.keys(c).length>0&&r.push(c);let h=r.length;A="interactions "+n+" | sets "+e+" "+t+" | true",p.opts.contact="yes";for(let e=0;e
    ",T=p.resid2specCls.atoms2residues(Object.keys(C)),M=p.resid2specCls.atoms2residues(Object.keys(y)),P="select "+p.resid2specCls.residueids2spec(T),D="select "+p.resid2specCls.residueids2spec(M);I+="Set 1: "+e+'
    ',I+="Set 2: "+t+'

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

    ',I+='
    Note: Each checkbox below selects the corresponding residue. You can click "Save Selection" in the "Select" menu to save the selection and click on "Highlight" button to clear the checkboxes.

    ';let U=I;if(("graph"==i||"linegraph"==i||"scatterplot"==i||b)&&(I=""),I+=O,"save1"==i||"save2"==i){I=U;let e="";"save1"==i?e="Set 1":"save2"==i&&(e="Set 2"),I+='

    Interactions Sorted on '+e+':
    ';let t=this.getAllInteractionTable(i);I+=t.html,h=t.bondCnt,$("#"+p.pre+"dl_interactionsorted").html(I),m.htmlCls.dialogCls.openDlg("dl_interactionsorted","Show sorted interactions")}else if("view"==i)$("#"+p.pre+"dl_allinteraction").html(I),m.htmlCls.dialogCls.openDlg("dl_allinteraction","Show interactions");else if("linegraph"==i){m.htmlCls.dialogCls.openDlg("dl_linegraph","Show interactions between two lines of residue nodes"),p.graphStr=p.getGraphCls.getGraphData(C,y,e,t,I,u),p.bLinegraph=!0;let s=p.lineGraphCls.drawLineGraph(p.graphStr);$("#"+p.pre+"linegraphDiv").html(s)}else if("scatterplot"==i){m.htmlCls.dialogCls.openDlg("dl_scatterplot","Show interactions as scatterplot"),p.graphStr=p.getGraphCls.getGraphData(C,y,e,t,I,u),p.bScatterplot=!0;let s=p.lineGraphCls.drawLineGraph(p.graphStr,!0);$("#"+p.pre+"scatterplotDiv").html(s)}else if(b){m.htmlCls.dialogCls.openDlg("dl_contactmap","Show contact map");let s=!0,i=p.getGraphCls.getGraphData(C,y,e,t,I,u,s);p.bContactMap=!0;let n=p.contactMapCls.drawContactMap(i);$("#"+p.pre+"contactmapDiv").html(n)}else if("graph"==i)if(p.graphStr=p.getGraphCls.getGraphData(C,y,e,t,I,u),p.bGraph=!0,Object.keys(y).length+Object.keys(C).length>Object.keys(p.dAtoms).length&&(p.graphStr=p.selectionCls.getGraphDataForDisplayed()),void 0===p.bD3){await m.getAjaxPromise("https://www.ncbi.nlm.nih.gov/Structure/icn3d/script/d3v4-force-all.min.js","script"),p.bD3=!0,$("#"+m.svgid).empty(),m.htmlCls.dialogCls.openDlg("dl_graph","Force-directed graph"),p.drawGraphCls.drawGraph(p.graphStr,p.pre+"dl_graph")}else $("#"+m.svgid).empty(),m.htmlCls.dialogCls.openDlg("dl_graph","Force-directed graph"),p.drawGraphCls.drawGraph(p.graphStr,p.pre+"dl_graph");return{interactionTypes:_.toString(),bondCnt:h}}clearInteractions(){let e=this.icn3d;e.icn3dui,e.lines.hbond=[],e.hbondpnts=[],e.lines.saltbridge=[],e.saltbridgepnts=[],e.lines.contact=[],e.contactpnts=[],e.lines.halogen=[],e.lines["pi-cation"]=[],e.lines["pi-stacking"]=[],e.halogenpnts=[],e.picationpnts=[],e.pistackingpnts=[]}resetInteractionPairs(){let e=this.icn3d;e.icn3dui,e.bHbondCalc=!1,e.showInterCls.hideHbondsContacts(),e.hlUpdateCls.clearHighlight(),e.resids2inter={},e.resids2interAll={}}async retrieveInteractionData(){let e=this.icn3d,t=e.icn3dui;if(!e.b2DShown)if(void 0!==t.cfg.align){let s=Object.keys(e.structures);if(2==t.cfg.atype){let t=!0;await e.alignParserCls.downloadAlignment(s[0]+","+s[1],t)}await e.ParserUtilsCls.set2DDiagramsForAlign(s[0].toUpperCase(),s[1].toUpperCase())}else void 0!==t.cfg.chainalign?(Object.keys(e.structures),await e.ParserUtilsCls.set2DDiagramsForChainalign(e.chainidArray)):e.ParserUtilsCls.download2Ddgm(e.inputid.toUpperCase())}getAllInteractionTable(e){let t=this.icn3d,s=t.icn3dui,i=[],n=Object.keys(t.resids2inter);("save1"==e||"save2"==e)&&n.sort((function(t,i){return s.utilsCls.compResid(t,i,e)}));let l,r,o="",a="",d="",c="",h="",p="",m="",u="",g="",f=0,b=0,C=0,y=0,v=0,w=0,_="";for(let s=0,S=n.length;s0&&l!=a&&(i.push({res1:a,res2:_,cntHbond:f,cntIonic:b,cntContact:C,cntHalegen:y,cntPication:v,cntPistacking:w}),o+=this.getInteractionPerResidue(d,c,h,p,m,u,g,f,b,C,y,v,w),c="",h="",p="",m="",u="",g="",f=0,b=0,C=0,y=0,v=0,w=0,_=""),x=t.resids2inter[S].hbond,k=this.getInteractionPairDetails(x,e,"hbond"),c+=k.html,f+=k.cnt,k.cnt>0&&(_+=r+":hbond_"+k.cnt+" "),x=t.resids2inter[S].ionic,k=this.getInteractionPairDetails(x,e,"ionic"),h+=k.html,b+=k.cnt,k.cnt>0&&(_+=r+":ionic_"+k.cnt+" "),x=t.resids2inter[S].contact,k=this.getContactPairDetails(x,e,"contact"),p+=k.html,C+=k.cnt,k.cnt>0&&(_+=r+":contact_"+k.cnt+" "),x=t.resids2inter[S].halogen,k=this.getInteractionPairDetails(x,e,"halogen"),m+=k.html,y+=k.cnt,k.cnt>0&&(_+=r+":halogen_"+k.cnt+" "),x=t.resids2inter[S]["pi-cation"],k=this.getInteractionPairDetails(x,e,"pi-cation"),u+=k.html,v+=k.cnt,k.cnt>0&&(_+=r+":pi-cation_"+k.cnt+" "),x=t.resids2inter[S]["pi-stacking"],k=this.getInteractionPairDetails(x,e,"pi-stacking"),g+=k.html,w+=k.cnt,k.cnt>0&&(_+=r+":pi-stacking_"+k.cnt+" "),a=l,d=O}i.push({res1:a,res2:_,cntHbond:f,cntIonic:b,cntContact:C,cntHalegen:y,cntPication:v,cntPistacking:w}),o+=this.getInteractionPerResidue(d,c,h,p,m,u,g,f,b,C,y,v,w);let S="";if(n.length>0){S+='
    ',S+="",S+="",S+="",S+="",S+="";let e='';S+=e,S+=e,S+='',S+=e,S+=e,S+=e,S+="",S+="",S+=o,S+="
    Residue# Hydrogen
    Bond
    # Salt Bridge
    /Ionic Interaction
    # Contact# Halogen
    Bond
    # π-Cation# π-StackingHydrogen Bond (backbone atoms: @CA, @N, @C, @O)Salt Bridge/Ionic InteractionContactHalogen Bondπ-Cationπ-Stacking
    Atom1Atom2Distance(Å)Highlight in 3D
    Atom1Atom2# ContactsMin Distance(Å)C-alpha Distance(Å)Highlight in 3D

    "}return{html:S,bondCnt:i}}getInteractionPerResidue(e,t,s,i,n,l,r,o,a,d,c,h,p){this.icn3d.icn3dui;let m="";m+=''+e[3]+e[2]+""+o+""+a+""+d+""+c+""+h+""+p+"";let u=[t,s,i,n,l,r];for(let e in u){m+=''+u[e]+"
    "}return m+="",m}getInteractionPairDetails(e,t,s){let i=this.icn3d;i.icn3dui;let n="",l=0,r='    ';if(void 0!==e)for(let a in e){let d=a.split(","),c="save1"==t?d[0]:d[1],h="save1"==t?d[1]:d[0],p=i.getGraphCls.convertLabel2Resid(c),m=i.firstAtomObjCls.getFirstAtomObj(i.residues[p]),u=m.color?m.color.getHexString():"",g=i.getGraphCls.convertLabel2Resid(h),f=i.firstAtomObjCls.getFirstAtomObj(i.residues[g]),b=f.color?f.color.getHexString():"",C=Math.sqrt(e[a]).toFixed(1);n+=' '+c+r+u+o+' '+h+r+b+o+''+C+"",n+='',n+="",++l}return{html:n,cnt:l}}getContactPairDetails(e,t){let s=this.icn3d;s.icn3dui;let i="",n=0,l='    ';if(void 0!==e)for(let o in e){let a=o.split(","),d="save1"==t?a[0]:a[1],c="save1"==t?a[1]:a[0],h=s.getGraphCls.convertLabel2Resid(d),p=s.firstAtomObjCls.getFirstAtomObj(s.residues[h]),m=p.color?p.color.getHexString():"",u=s.getGraphCls.convertLabel2Resid(c),g=s.firstAtomObjCls.getFirstAtomObj(s.residues[u]),f=g.color?g.color.getHexString():"",b=e[o].split("_"),C=b[0],y=b[1],v=b[2],w=b[3],_=b[4];i+=' '+d+"@"+v+l+m+r+' '+c+"@"+w+l+f+r+''+_+''+C+''+y+"",i+='',i+="",n+=parseInt(_)}return{html:i,cnt:n}}exportInteractions(){var e=this.icn3d;e.icn3dui;let t='

    Interacting residues:
    ';for(let s in e.chainname2residues)for(let i in e.chainname2residues[s]){let n=s.substr(0,s.indexOf("_"))+"_"+i.substr(0,i.indexOf(" "));t+=""}t+="
    Base Chain: ResiduesInteracting Chain
    "+s+": ",t+=e.resid2specCls.residueids2spec(e.chainname2residues[s][i]),t+=""+n+"

    ";let s=e.inputid?e.inputid:"custom";e.saveFileCls.saveFile(s+"_interactions.html","html",t)}exportSsbondPairs(){var e=this.icn3d;e.icn3dui;let t="",s=0;for(let i in e.structures){let n=e.ssbondpnts[i];if(void 0===n)break;for(let e=0,i=n.length;e"+n[e]+" Cys"+n[e+1]+" Cys",++s}}let i='

    '+s+" disulfide pairs:

    ";i+=t,i+="
    Residue ID 1Residue ID 2

    ";let n=e.inputid?e.inputid:"custom";e.saveFileCls.saveFile(n+"_disulfide_pairs.html","html",i)}exportClbondPairs(){var e=this.icn3d;e.icn3dui;let t="",s=0,i={};for(let n in e.structures){let l=e.clbondpnts[n];if(void 0===l)break;for(let n=0,r=l.length;n"+r+" "+i.resn+""+o+" "+n.resn+"",++s}i[r+"_"+o]=1,i[o+"_"+r]=1}}let n='

    '+s+" cross-linkage pairs:

    ";n+=t,n+="
    Residue ID 1Residue ID 2

    ";let l=e.inputid?e.inputid:"custom";e.saveFileCls.saveFile(l+"_crosslinkage_pairs.html","html",n)}exportHbondPairs(e,t){var s=this.icn3d,i=s.icn3dui;let n="",l=0,r='    ';for(let t in s.resid2ResidhashHbond){let i=s.getGraphCls.convertLabel2Resid(t),a=s.firstAtomObjCls.getFirstAtomObj(s.residues[i]),d=a.color?a.color.getHexString():"";for(let i in s.resid2ResidhashHbond[t]){let a=s.getGraphCls.convertLabel2Resid(i),c=s.firstAtomObjCls.getFirstAtomObj(s.residues[a]),h=c.color?c.color.getHexString():"",p=Math.sqrt(s.resid2ResidhashHbond[t][i]).toFixed(1);n+=' '+t+r+d+o+' '+i+r+h+o+''+p+"","view"==e&&(n+=''),n+="",++l}}let a='

    '+l+" hydrogen bond pairs (backbone atoms: @CA, @N, @C, @O):

    ";if(l>0&&(a+="
    ","view"==e&&(a+=''),a+="",a+=n,a+="
    Atom 1Atom 2Distance(Å)Highlight in 3D

    "),"graph"==e||"linegraph"==e||"scatterplot"==e){return s.getGraphCls.getGraphLinks(s.resid2ResidhashHbond,s.resid2ResidhashHbond,i.htmlCls.hbondColor,t,i.htmlCls.hbondValue)}return a}exportSaltbridgePairs(e,t){var s=this.icn3d,i=s.icn3dui;let n="",l=0,r='    ';for(let t in s.resid2ResidhashSaltbridge){let i=s.getGraphCls.convertLabel2Resid(t),a=s.firstAtomObjCls.getFirstAtomObj(s.residues[i]),d=a.color?a.color.getHexString():"";for(let i in s.resid2ResidhashSaltbridge[t]){let a=s.getGraphCls.convertLabel2Resid(i),c=s.firstAtomObjCls.getFirstAtomObj(s.residues[a]),h=c.color?c.color.getHexString():"",p=Math.sqrt(s.resid2ResidhashSaltbridge[t][i]).toFixed(1);n+=' '+t+r+d+o+' '+i+r+h+o+''+p+"","view"==e&&(n+=''),n+="",++l}}let a='

    '+l+" salt bridge/ionic interaction pairs:

    ";if(l>0&&(a+="
    ","view"==e&&(a+=''),a+="",a+=n,a+="
    Atom 1Atom 2Distance(Å)Highlight in 3D

    "),"graph"==e||"linegraph"==e||"scatterplot"==e){return s.getGraphCls.getGraphLinks(s.resid2ResidhashSaltbridge,s.resid2ResidhashSaltbridge,i.htmlCls.ionicColor,t,i.htmlCls.ionicValue)}return a}exportHalogenPiPairs(e,t,s){var i=this.icn3d,n=i.icn3dui;let l,r,o,a="",d=0,c='    ';"halogen"==s?(l=i.resid2ResidhashHalogen,r=n.htmlCls.halogenColor,o=n.htmlCls.halogenValue):"pi-cation"==s?(l=i.resid2ResidhashPication,r=n.htmlCls.picationColor,o=n.htmlCls.picationValue):"pi-stacking"==s&&(l=i.resid2ResidhashPistacking,r=n.htmlCls.pistackingColor,o=n.htmlCls.pistackingValue);for(let t in l){let n=i.getGraphCls.convertLabel2Resid(t),r=i.firstAtomObjCls.getFirstAtomObj(i.residues[n]),o=r.color?r.color.getHexString():"";for(let n in l[t]){let r=i.getGraphCls.convertLabel2Resid(n),p=i.firstAtomObjCls.getFirstAtomObj(i.residues[r]),m=p.color?p.color.getHexString():"",u=Math.sqrt(l[t][n]).toFixed(1);a+=' '+t+c+o+h+' '+n+c+m+h+''+u+"","view"==e&&(a+=''),a+="",++d}}let p='

    '+d+" "+s+" pairs:

    ";if(d>0&&(p+="
    ","view"==e&&(p+=''),p+="",p+=a,p+="
    Atom 1Atom 2Distance(Å)Highlight in 3D

    "),"graph"==e||"linegraph"==e||"scatterplot"==e){return i.getGraphCls.getGraphLinks(l,l,r,t,o)}return p}exportSpherePairs(e,t,s){var i=this.icn3d,n=i.icn3dui;let l="",r=0,o=e?i.resid2ResidhashInteractions:i.resid2ResidhashSphere,a='    ';for(let s in o){let n=i.getGraphCls.convertLabel2Resid(s),c=i.firstAtomObjCls.getFirstAtomObj(i.residues[n]),h=c.color?c.color.getHexString():"";for(let n in o[s]){let p=i.getGraphCls.convertLabel2Resid(n),m=i.firstAtomObjCls.getFirstAtomObj(i.residues[p]),u=m.color?m.color.getHexString():"",g=o[s][n].split("_"),f=g[0],b=g[1];c=g[2],m=g[3];let C=g[4];e?(l+=' '+s+"@"+c+a+h+d+' '+n+"@"+m+a+u+d+''+C+''+f+''+b+"","view"==t&&(l+=''),l+=""):l+=""+s+""+n+''+C+''+f+''+b+"",++r}}let c='

    '+r+" residue pairs in "+(e?"the contacts":"sphere")+":

    ";if(r>0&&(e?(c+='
    ',"view"==t&&(c+=''),c+=""):c+='
    Residue 1Residue 2Num ContactsMin Distance(Å)C-alpha Distance(Å)Highlight in 3D
    ',c+=l,c+="
    Residue 1Residue 2Num ContactsMin Distance(Å)C-alpha Distance(Å)

    "),"graph"==t||"linegraph"==t||"scatterplot"==t||"calpha"==t||"cbeta"==t||"heavyatoms"==t){return i.getGraphCls.getGraphLinks(o,o,n.htmlCls.contactColor,s,n.htmlCls.contactValue)}return c}}class Ut{constructor(e){this.icn3d=e}drawGraph(e,t){var s=this.icn3d,i=s.icn3dui;if(void 0===n)var n=d3;var l=JSON.parse(e),r=$("#"+t).width(),o=$("#"+t).height(),a=isNaN(r)?300:1*r,d=isNaN(o)?300:1*o,c=r,h=o,p=d3.select("#"+i.svgid).attr("width",r).attr("height",o).attr("viewBox","0,0,"+a+","+d);p.selectAll(".g-main").remove();var m=p.append("g").classed("g-main",!0),u=m.append("rect").attr("width",c).attr("height",h).style("fill","#FFF"),g=m.append("g"),f=n.zoom().on("zoom",(function(){g.attr("transform",n.event.transform)}));if(m.call(f),l.links){for(var b=[],C={},y=0,v=l.nodes.length;y0?n.structures[0]:n.defaultPdbId;p=10*(a.length+2)+20+30,h=10*(d.length+2)+20+30,t?(n.alignerrormapWidth=2*h,u=n.alignerrormapWidth,m=l.alignerrormapid):(n.contactmapWidth=2*h,u=n.contactmapWidth,m=l.contactmapid),i=o.length>0?"":"No interactions found for these two sets

    ",i+="";if(t){n.hex2id={};let e=29/s;n.hex2skip={};let t=1e3;for(let s=0;se&&(n.hex2skip[d]=c)}}if(i+=n.lineGraphCls.drawScatterplot_base(a,d,o,c,0,!0,void 0,void 0,t),g+=n.getGraphCls.updateGraphJson(f,1,a,d,o),i+="",g+="}\n",t){n.alignerrormapStr=g,$("#"+n.pre+"alignerrormapDiv").html(i);let e=$("#"+l.alignerrormapid+"_scale").val();$("#"+l.alignerrormapid).attr("width",(n.alignerrormapWidth*parseFloat(e)).toString()+"px")}else n.contactmapStr=g,$("#"+n.pre+"contactmapDiv").html(i);return i}}class $t{constructor(e){this.icn3d=e}async downloadAlignment(e,t){let s=this.icn3d,i=s.icn3dui,n=this;s.opts.proteins="c alpha trace";let l=e.split(","),r="ids="+e,o=i.htmlCls.baseUrl+"vastplus/vastplus.cgi?v=3&cmd=c&b=1&s=1&w3d&"+r;void 0!==i.cfg.inpara&&(o+=i.cfg.inpara),s.pdbid_chain2title={},void 0===s.chainids2resids&&(s.chainids2resids={});let a={},d="These two MMDB IDs "+l+' do not have 3D alignment data in the VAST+ database. You can try the VAST alignment by visiting the VAST+ page https://www.ncbi.nlm.nih.gov/Structure/vastplus/vastplus.cgi?uid=[PDB ID] (e.g., uid=1KQ2), and clicking "Original VAST"',c=await i.getAjaxPromise(o,"jsonp",!0,d);if(a=c.seqalign,void 0===a)return alert(d),!1;s.pdbid_molid2chain={},s.chainsColor={};for(let e=0,t=2;e5){let t=!1,s=!0;d=await r.pdbParserCls.loadPdbData(e,n,!1,t,"target",h,s)}else{let t=!0;d=await r.mmdbParserCls.parseMmdbData(e,"target",i[0],0,h,t)}for(let e=0,s=t.length;e5){let s=!0,i=!0;c=await r.pdbParserCls.loadPdbData(t[e],l,!1,s,"query",h,i)}else{let s=!0;c=await r.mmdbParserCls.parseMmdbData(t[e],"query",i[e+1],e,h,s)}d=o.hashUtilsCls.unionHash(d,c)}if(o.cfg.resnum)await r.realignParserCls.realignChainOnSeqAlign(s,i);else if(o.cfg.resdef)await r.realignParserCls.realignChainOnSeqAlign(s,i,void 0,!0);else{await r.pdbParserCls.applyCommandDssp(!0);for(let e in r.pdbChainIndexHash){let t=r.pdbChainIndexHash[e].split("_");l=t[0],t[1],n=t[2],t[3],a.transformStructure(l,e-1,"query")}let e=[],t=[],c=[],h=o.htmlCls.baseUrl+"vastdyn/vastdyn.cgi",p=o.htmlCls.baseUrl+"tmalign/tmalign.cgi";for(let s in r.afChainIndexHash){let i=r.afChainIndexHash[s].split("_");l=i[0];let a=i[1];n=i[2];let d,m=i[3];if("tmalign"!=o.cfg.aligntool){let e={domains1:r.domain3dCls.getDomainJsonForAlign(r.chains[l+"_"+a]),domains2:r.domain3dCls.getDomainJsonForAlign(r.chains[n+"_"+m])};d=o.getAjaxPostPromise(h,e)}else{let e={pdb_query:r.saveFileCls.getAtomPDB(r.chains[l+"_"+a]),pdb_target:r.saveFileCls.getAtomPDB(r.chains[n+"_"+m])};d=o.getAjaxPostPromise(p,e)}e.push(d),t.push(s-1),c.push(l)}let m=Promise.allSettled(e);try{let e=await m;await a.downloadChainalignmentPart2b(s,i,d,e,t,n,c)}catch(e){r.bRender&&alert("These structures can NOT be aligned to each other...")}}}async downloadChainalignmentPart2b(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui;for(let e=0,t=i.length;ed&&(d=n[t[0]],o=t[0]),n[t[1]]>d&&(d=n[t[1]],o=t[1])}let c={},h={},p={},m={};for(let e in l){let t,s,i=e.split("_"),n=l[e].split(","),r=n[2];o==i[0]?(t=i[0],s=i[1]):o==i[1]?(t=i[1],s=i[0]):(t=i[0],s=i[1]),p[t]=1,p.hasOwnProperty(s)||(p[s]=1,m[e]=l[e],a="target",this.transformStructure(t,r,a),a="query",this.transformStructure(s,r,a),c[n[0]]=1,c[n[1]]=1)}for(let e in m)if(void 0!==s.q_rotation){let t=m[e].split(","),n=[t[1],t[0],t[2]],l=s.setSeqAlignCls.setSeqAlignChain(void 0,void 0,n);h=i.hashUtilsCls.unionHash(h,l);let r=!1,o=i.htmlCls.alignSeqCls.getAlignSequencesAnnotations(Object.keys(s.alnChains),void 0,void 0,!1,void 0,r),a=$("#"+s.pre+"dl_sequence2").html();$("#"+s.pre+"dl_sequence2").html(a+o.sequencesHtml),$("#"+s.pre+"dl_sequence2").width(i.htmlCls.RESIDUE_WIDTH*o.maxSeqCnt+200)}s.dAtoms=i.hashUtilsCls.cloneHash(h),s.hAtoms=i.hashUtilsCls.cloneHash(h);let u="protein_aligned";s.selectionCls.saveSelection(u,u),s.opts.color="identity",s.setColorCls.setColorByOptions(s.opts,s.hAtoms),i.htmlCls.dialogCls.openDlg("dl_alignment","Select residues in aligned sequences"),s.drawCls.draw(),s.transformCls.zoominSelection(),s.hlUpdateCls.updateHlAll()}transformStructure(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=n.structures[e];for(let e=0,o=r.length;e2){let e=i.firstAtomObjCls.getResiduesFromAtoms(s),t="protein_aligned",n="protein aligned",l="select "+i.resid2specCls.residueids2spec(Object.keys(e));i.selectionCls.addCustomSelection(Object.keys(e),t,n,l,!0)}i.hlUpdateCls.updateHlAll(),void 0!==n.cfg.rotate&&i.resizeCanvasCls.rotStruc(n.cfg.rotate,!0),i.html2ddgm="",n.cfg.show2d&&i.bFullUi&&(n.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions"),i.bFullUi&&(i.bChainAlign?await i.ParserUtilsCls.set2DDiagramsForChainalign(t):i.ParserUtilsCls.download2Ddgm(i.inputid.toUpperCase())))}addPostfixForChainids(e){let t=this.icn3d;t.icn3dui;let s={};for(let i=0,n=e.length;i5?(c="https://alphafold.ebi.ac.uk/files/AF-"+i.mmdbid_t+"-F1-model_"+i.AFUniprotVersion+".pdb",d=n.getAjaxPromise(c,"text")):(c=n.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+n.cfg.bu+"&uid="+i.mmdbid_t,void 0!==n.cfg.inpara&&(c+=n.cfg.inpara),d=n.getAjaxPromise(c,"jsonp")),h.push(d),i.ParserUtilsCls.setYourNote(e.toUpperCase()+" in iCn3D"),i.pdbid_chain2title={},void 0===i.chainids2resids&&(i.chainids2resids={}),i.afChainIndexHash={},i.pdbChainIndexHash={};for(let e=1,t=r.length;e5?(t="https://alphafold.ebi.ac.uk/files/AF-"+i.mmdbid_q+"-F1-model_"+i.AFUniprotVersion+".pdb",s=n.getAjaxPromise(t,"text")):(t=n.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+n.cfg.bu+"&uid="+i.mmdbid_q,void 0!==n.cfg.inpara&&(t+=n.cfg.inpara),s=n.getAjaxPromise(t,"jsonp")),h.push(s)}for(let e=1,t=r.length;e0?o[e]+","+o[0]:void 0;if("tmalign"!=n.cfg.aligntool&&4==i.mmdbid_t.length&&4==i.mmdbid_q.length){let r;r=o.length>0?n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?domainpairs="+l:n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainpairs="+t;let a=n.getAjaxPromise(r,"jsonp");h.push(a),i.pdbChainIndexHash[e]=s+"_"+i.chain_q+"_"+i.mmdbid_t+"_"+i.chain_t}else i.afChainIndexHash[e]=i.mmdbid_q+"_"+i.chain_q+"_"+i.mmdbid_t+"_"+i.chain_t}}let p=Promise.allSettled(h);try{let e=await p;await l.parseChainAlignData(e,r,i.mmdbid_t,i.chain_t)}catch(e){let t="tmalign"==n.cfg.aligntool?"TM-align":"VAST";i.bRender&&alert("These chains can not be aligned by "+t+". You can specify the residue range and try it again...")}}async parseChainAlignData(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=e[0].value,o="HEADER "+s+"\n";isNaN(s)&&s.length>5&&(r=o+r),n.t_trans_add=[],n.q_trans_sub=[],"tmalign"==l.cfg.aligntool&&(n.q_trans_add=[]),n.q_rotation=[],n.qt_start_end=[],n.mmdbidArray=[],n.mmdbidArray.push(s);let a=[];for(let s=1,i=t.length;s5&&(i=o+i),void 0===i||-1!==JSON.stringify(i).indexOf("Oops there was a problem"))return void alert("The coordinate data can NOT be retrieved for the structure "+r+"...");n.mmdbidArray.push(r),a.push(i)}let d=0;for(let r=1,o=t.length;r";"tmalign"==o.cfg.aligntool&&(n+="TM-score: "+e[0].score.toPrecision(4)+"

    "),$("#"+r.pre+"dl_rmsd").html(n),o.cfg.bSidebyside||o.htmlCls.dialogCls.openDlg("dl_rmsd","RMSD of alignment"),a=!0}return a}async loadOpmDataForChainalign(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=this;if(l.cfg.resnum||l.cfg.resdef)n.bCommandLoad||n.init(),await this.downloadChainalignmentPart2(e,t,void 0,s);else{let o=l.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?mmdbids2opm="+i.join("','");try{let i=(await l.getAjaxPromise(o,"jsonp")).mmdbid;if(n.selectedPdbid=i,i){let o="https://opm-assets.storage.googleapis.com/pdb/"+i.toLowerCase()+".pdb";try{let a=await l.getAjaxPromise(o,"text");n.bOpm=!0;let d=!0,c=n.loadPDBCls.loadPDB(a,i,n.bOpm,d);$("#"+n.pre+"selectplane_z1").val(n.halfBilayerSize),$("#"+n.pre+"selectplane_z2").val(-n.halfBilayerSize),$("#"+n.pre+"extra_mem_z").val(n.halfBilayerSize),$("#"+n.pre+"intra_mem_z").val(-n.halfBilayerSize),n.bCommandLoad||n.init(),await r.downloadChainalignmentPart2(e,t,c,s)}catch(i){return n.bCommandLoad||n.init(),void await r.downloadChainalignmentPart2(e,t,void 0,s)}}else n.bCommandLoad||n.init(),await r.downloadChainalignmentPart2(e,t,void 0,s)}catch(i){return n.bCommandLoad||n.init(),void await r.downloadChainalignmentPart2(e,t,void 0,s)}}}async downloadMmdbAf(e,t,s){let i=this.icn3d,n=i.icn3dui,l=this;i.structArray=i.structures?Object.keys(i.structures):[],0==i.structArray.length?i.init():(i.resetConfig(),i.bResetAnno=!0,i.bResetSets=!0);let r=e.split(","),o=[];for(let e=0,t=r.length;e5?(t="https://alphafold.ebi.ac.uk/files/AF-"+l+"-F1-model_"+i.AFUniprotVersion+".pdb",s=n.getAjaxPromise(t,"text")):(t=n.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+n.cfg.bu+"&uid="+l,void 0!==n.cfg.inpara&&(t+=n.cfg.inpara),s=n.getAjaxPromise(t,"jsonp")),a.push(s)}i.ParserUtilsCls.setYourNote(i.structArray+" in iCn3D"),i.ParserUtilsCls.showLoading();let d=Promise.allSettled(a);try{let e=await d;await l.parseMMdbAfData(e,o,t,s),void 0===s&&i.ParserUtilsCls.hideLoading()}catch(e){alert("There are some problems in retrieving the coordinates...")}}async parseMMdbAfData(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=[];for(let s=0,i=t.length;s5&&(i=n+i),void 0===i||-1!==JSON.stringify(i).indexOf("Oops there was a problem"))return void alert("The coordinate data can NOT be retrieved for the structure "+t[s]+"...");r.push(i)}let o={},a={},d=!1;n.opts.color=n.structArray.length>1?"structure":t[0].length>5?"confidence":"chain";for(let e=0,i=t.length;e5){let s=!1;a=await n.pdbParserCls.loadPdbData(r[e],t[e],!1,c,i,d,s)}else{let t=!0;a=await n.mmdbParserCls.parseMmdbData(r[e],i,void 0,void 0,d,t)}o=l.hashUtilsCls.unionHash(o,a)}if(n.structArray.length>1&&(n.opts.color="structure"),n.setColorCls.setColorByOptions(n.opts,n.atoms),await n.ParserUtilsCls.renderStructure(),void 0!==l.cfg.rotate&&n.resizeCanvasCls.rotStruc(l.cfg.rotate,!0),s&&l.cfg.matchedchains){let e=!0,t=!0;await n.realignParserCls.realignChainOnSeqAlign(void 0,n.chainidArray,e,t),$("#"+n.pre+"dl_annotations").html(""),n.bAnnoShown=!1,$("#"+n.pre+"dl_selectannotations").dialog("isOpen")&&$("#"+n.pre+"dl_selectannotations").dialog("close")}else if(void 0!==i){let e=Object.keys(n.structures);await n.vastplusCls.vastplusAlign(e,i)}}}class Bt{constructor(e){this.icn3d=e}dsn6Parser(e,t,s){this.icn3d.icn3dui;let i="https://edmaps.rcsb.org/maps/"+e.toLowerCase()+"_"+t+".dsn6";this.dsn6ParserBase(i,t,s)}dsn6ParserBase(e,t,s){let i=this.icn3d;i.icn3dui;let n=this;if("2fofc"==t&&i.bAjax2fofc)i.mapData.sigma2=s,i.setOptionCls.setOption("map",t);else if("fofc"==t&&i.bAjaxfofc)i.mapData.sigma=s,i.setOptionCls.setOption("map",t);else{let l=new XMLHttpRequest;l.open("GET",e,!0),l.responseType="arraybuffer",l.onreadystatechange=function(){if(4==this.readyState)if(200==this.status){let e=l.response;n.loadDsn6Data(e,t,s),"2fofc"==t?i.bAjax2fofc=!0:"fofc"==t&&(i.bAjaxfofc=!0),i.setOptionCls.setOption("map",t)}else alert("RCSB server has no corresponding eletron density map for this structure.");else i.ParserUtilsCls.showLoading()},l.send()}}loadDsn6Data(e,t,s){let i=this.icn3d;i.icn3dui;let n,l,r={},o=e.buffer&&e.buffer instanceof ArrayBuffer?e.buffer:e,a=new Int16Array(o),d=new Uint8Array(o),c=String.fromCharCode.apply(null,d.subarray(0,512));if(0==c.indexOf(":-)"))r.xStart=parseInt(c.substr(10,5)),r.yStart=parseInt(c.substr(15,5)),r.zStart=parseInt(c.substr(20,5)),r.xExtent=parseInt(c.substr(32,5)),r.yExtent=parseInt(c.substr(38,5)),r.zExtent=parseInt(c.substr(42,5)),r.xRate=parseInt(c.substr(52,5)),r.yRate=parseInt(c.substr(58,5)),r.zRate=parseInt(c.substr(62,5)),r.xlen=1*parseFloat(c.substr(73,10)),r.ylen=1*parseFloat(c.substr(83,10)),r.zlen=1*parseFloat(c.substr(93,10)),r.alpha=parseFloat(c.substr(103,10)),r.beta=parseFloat(c.substr(113,10)),r.gamma=parseFloat(c.substr(123,10)),n=parseFloat(c.substr(138,12))/100,l=parseInt(c.substr(155,8)),r.sigma=100*parseFloat(c.substr(170,12));else{if(100!==a[18])for(let e=0,t=a.length;e>8&255}r.zStart=a[2],r.xStart=a[0],r.yStart=a[1],r.xExtent=a[3],r.yExtent=a[4],r.zExtent=a[5],r.xRate=a[6],r.yRate=a[7],r.zRate=a[8];let e=1/a[17],t=1*e;r.xlen=a[9]*t,r.ylen=a[10]*t,r.zlen=a[11]*t,r.alpha=a[12]*e,r.beta=a[13]*e,r.gamma=a[14]*e,n=a[15]/a[18],l=a[16]}let h=new Float32Array(r.xExtent*r.yExtent*r.zExtent),p=512,m=Math.ceil(r.xExtent/8),u=Math.ceil(r.yExtent/8),g=Math.ceil(r.zExtent/8);for(let e=0;es.maxatomcnt&&(s.bAssembly=!0)}if("mmtfid"===t&&void 0!==o.missingseq){let t=0,n="";for(let l=0,r=o.missingseq.length;lt)&&(s.chainMissingResidueArray[c].push(h),t=d,n=a)}s.loadPDBCls.adjustSeq(s.chainMissingResidueArray)}}async loadMmcifData(e,t){let s=this.icn3d;if(s.icn3dui,t||(t=e.mmcif),t||(t=s.defaultPdbId),void 0===e.atoms)return!1;s.init(),void 0!==e.emd&&(s.emd=e.emd),void 0!==e.organism&&(s.organism=e.organism),void 0!==s.emd?($("#"+s.pre+"mapWrapper1").hide(),$("#"+s.pre+"mapWrapper2").hide(),$("#"+s.pre+"mapWrapper3").hide()):($("#"+s.pre+"emmapWrapper1").hide(),$("#"+s.pre+"emmapWrapper2").hide(),$("#"+s.pre+"emmapWrapper3").hide()),await s.opmParserCls.loadOpmData(e,t,void 0,"mmcif")}}class Gt{constructor(e){this.icn3d=e}async downloadMmdb(e,t){let s,i=this.icn3d,n=i.icn3dui;try{if(s=await this.loadMmdbPrms(e,t),!s||s.error)return void this.getNoData(e,t)}catch(s){return void this.getNoData(e,t)}if(0!=Object.keys(s.atoms).length)if(n.utilsCls.isCalphaPhosOnly(s.atoms)||s.atomCount<=i.maxatomcnt)await this.parseMmdbData(s);else{let s;try{s=await this.loadMmdbPrms(e,t,!0)}catch(s){return void this.getNoData(e,t)}await this.parseMmdbData(s)}else{let e=s.pdbId;i.mmtfParserCls.downloadMmtf(e)}}async downloadGi(e){let t=this.icn3d;t.icn3dui,t.bCid=void 0;await this.downloadMmdb(e,!0)}async downloadBlast_rep_id(e){let t=this.icn3d,s=t.icn3dui,i=e.split(",");s.cfg.query_id=i[0],s.cfg.blast_rep_id=i[1];let n=s.cfg.blast_rep_id.split("_")[0];4==n.length?await this.downloadMmdb(n):(t.blastAcxn=s.cfg.blast_rep_id.split(".")[0],await this.downloadRefseq(t.blastAcxn,!0))}async downloadRefseq(e,t){let s=this.icn3d,i=s.icn3dui,n=i.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?refseq2uniprot="+e;i.cfg.refseqid=e;let l=await i.getAjaxPromise(n,"jsonp",!1,"The protein accession "+e+" can not be mapped to AlphaFold UniProt ID...");if(!l||!l.uniprot)return void alert("The accession "+e+" can not be mapped to AlphaFold UniProt ID. It will be treated as a UniProt ID instead.");i.cfg.afid=l.uniprot,t&&(i.cfg.blast_rep_id=i.cfg.afid+"_A");await s.pdbParserCls.downloadPdb(i.cfg.afid,!0)}getNoData(e,t){let s=this.icn3d.icn3dui;t?alert("This gi "+e+" has no corresponding 3D structure..."):alert("This mmdbid "+e+" with the parameters "+s.cfg.inpara+" may not have 3D structure data. Please visit the summary page for details: "+s.htmlCls.baseUrl+"pdb/"+e)}async parseMmdbData(e,t,s,i,n,l){let r,o=this.icn3d,a=o.icn3dui,d=void 0!==e.pdbId?e.pdbId:e.mmdbId;this.parseMmdbDataPart1(e,t),void 0===t?(void 0!==e.opm&&void 0!==e.opm.rot&&(o.bOpm=!0,o.opmParserCls.setOpmData(e)),r=o.loadAtomDataCls.loadAtomDataIn(e,d,"mmdbid",void 0,t)):(s&&(d=s.substr(0,s.indexOf("_"))),r=o.loadAtomDataCls.loadAtomDataIn(e,d,"mmdbid",void 0,t,s,i,n,l));let c=e.pdbId;void 0===t&&o.ParserUtilsCls.setYourNote(c.toUpperCase()+"(MMDB) in iCn3D");for(let t in e.domains){let s=e.domains[t].chain,i=c+"_"+s,n=e.domains[t].domains;for(let e=0,t=n.length;et.maxatomcnt){let i=!1;if(0==Object.keys(s).length)return void alert("This PDB structure is not found at RCSB...");await t.opmParserCls.loadOpmData(s,e,i,"mmtf")}else s=null,MMTF.fetch(e,(async function(s){0!=Object.keys(s).length?await t.opmParserCls.loadOpmData(s,e,!0,"mmtf"):alert("This PDB structure is not found at RCSB...")}),(function(e){}))}),(function(e){}))}async parseMmtfData(e,t,s){let i=this.icn3d,n=i.icn3dui;e.numAtoms,i.init();let l=new THREE.Vector3(9999,9999,9999),r=new THREE.Vector3(-9999,-9999,-9999),o=new THREE.Vector3,a=e.structureId;if(i.molTitle=e.title,void 0!==e.bioAssemblyList&&void 0!==e.bioAssemblyList[0]&&e.bioAssemblyList[0].transformList.length>1){i.biomtMatrices=[];for(let t=0,s=e.bioAssemblyList[0].transformList.length;t1&&($("#"+i.pre+"assemblyWrapper").show(),i.asuCnt=i.biomtMatrices.length);let d,c,h,p,m,u,g,f,b,C,y,v,w,_,S,A,x,k,O,R={},E=[],I="coil",T="",M=0,P=0,D={onModel:function(e){d=0===e.modelIndex?a:a+(e.modelIndex+1).toString()},onChain:function(e){c=e.chainName;let t=d+"_"+c;void 0===i.structures[d]&&(i.structures[d]=[]),i.structures[d].push(t)},onGroup:function(e){h=e.groupName,p=e.groupId;let t=d+"_"+c+"_"+p;m=0===e.secStruct||2===e.secStruct||4===e.secStruct?"helix":3===e.secStruct?"sheet":-1===e.secStruct?"other":"coil";let s=!1;if(c!==T){if(x=void 0,O=void 0,"coil"!==m&&"other"!==m?(u=!0,g=!1):(u=!1,g=!1),"coil"!==I&&"other"!==I){let e=d+"_"+T+"_"+M.toString();for(let t in i.residues[e])i.atoms[t].ssbegin=!1,i.atoms[t].ssend=!0}}else x=A,O=k,m!==I?"coil"===I||"other"===I?(u=!0,g=!1):"coil"===m||"other"===m?(s=!0,u=!1,g=!1):("sheet"===I&&"helix"===m||"helix"===I&&"sheet"===m)&&(s=!0,u=!0,g=!1):(u=!1,g=!1);if(s&&!isNaN(p)){let e=d+"_"+c+"_"+(p-1).toString();for(let t in i.residues[e])i.atoms[t].ssbegin=!1,i.atoms[t].ssend=!0}I=m,T=c,M=p,f=!1,b=!1,C=!1,"non-polymer"===e.chemCompType.toLowerCase()||"other"===e.chemCompType.toLowerCase()||-1!==e.chemCompType.toLowerCase().indexOf("saccharide")?f=!0:-1!==e.chemCompType.toLowerCase().indexOf("peptide")?b=!0:-1!==e.chemCompType.toLowerCase().indexOf("dna")||-1!==e.chemCompType.toLowerCase().indexOf("rna")?C=!0:b=!0;let l=d+"_"+c,r={};r.resi=p,r.name=n.utilsCls.residueName2Abbr(h),i.residueId2Name[t]=r.name,r.resi%10==0&&r.resi.toString();let o="-";"helix"===m?o="H":"sheet"===m?o="E":"coil"===m?o="c":"other"===m&&(o="o"),void 0===i.chainsSeq[l]&&(i.chainsSeq[l]=[]),i.bFullUi&&i.chainsSeq[l].push(r),i.secondaries[t]=o},onAtom:function(e){if(y=e.element,v=e.atomName,w=new THREE.Vector3(e.xCoord,e.yCoord,e.zCoord),_=e.bFactor,S=e.altLoc,"\0"===e.altLoc&&(S=""),""===S||"A"===S){++P,"SG"===v&&E.push(P),R[e.atomIndex]=P;let t={het:f,serial:P,name:v,alt:S,resn:h,structure:d,chain:c,resi:p,coord:w,b:_,elem:y,bonds:[],bondOrder:[],ss:m,ssbegin:u,ssend:g};if(t.het||"C"!==t.name||(A=P),t.het||"O"!==t.name||(k=P),!t.het&&"N"===t.name&&void 0!==x&&void 0!==O){let e=i.atoms[x].coord.distanceTo(i.atoms[O].coord),s=t.coord.x+(i.atoms[x].coord.x-i.atoms[O].coord.x)/e,n=t.coord.y+(i.atoms[x].coord.y-i.atoms[O].coord.y)/e,l=t.coord.z+(i.atoms[x].coord.z-i.atoms[O].coord.z)/e;t.hcoord=new THREE.Vector3(s,n,l)}i.atoms[P]=t,l.min(w),r.max(w),o.add(w);let a=d+"_"+c,I=a+"_"+p;void 0===i.chains[a]&&(i.chains[a]={}),i.chains[a][P]=1,void 0===i.residues[I]&&(i.residues[I]={}),i.residues[I][P]=1,b?(i.proteins[P]=1,"CA"===v&&(i.calphas[P]=1),"N"!==v&&"H"!==v&&"CA"!==v&&"HA"!==v&&"C"!==v&&"O"!==v&&(i.sidec[P]=1)):C?(i.nucleotides[P]=1,(!s||"O3'"!=v&&"O3*"!=v)&&(s||"P"!=v)||(i.nucleotidesO3[P]=1),-1===n.parasCls.nuclMainArray.indexOf(v)&&(i.ntbase[P]=1)):y.toLowerCase()===h.toLowerCase()?i.ions[P]=1:"HOH"===h||"WAT"===h||"SQL"===h||"H2O"===h||"W"===h||"DOD"===h||"D3O"===h?i.water[P]=1:i.chemicals[P]=1,i.dAtoms[P]=1,i.hAtoms[P]=1}},onBond:function(e){let t=R[e.atomIndex1],s=R[e.atomIndex2];if(R.hasOwnProperty(e.atomIndex1)&&R.hasOwnProperty(e.atomIndex2)&&(i.atoms[t].bonds.push(s),i.atoms[s].bonds.push(t),f)){let n=e.bondOrder;i.atoms[t].bondOrder.push(n),i.atoms[s].bondOrder.push(n),2===n?(i.doublebonds[t+"_"+s]=1,i.doublebonds[s+"_"+t]=1):3===n&&(i.triplebonds[t+"_"+s]=1,i.triplebonds[s+"_"+t]=1)}}};MMTF.traverse(e,D),i.loadPDBCls.setResidMapping();for(let e=0,t=E.length;ei.maxatomcnt||void 0!==i.biomtMatrices&&i.biomtMatrices.length*i.cnt>10*i.maxatomcnt)&&(i.opts.proteins="c alpha trace",i.opts.nucleotides="o3 trace"),i.pmin=l,i.pmax=r,i.center=i.ParserUtilsCls.getGeoCenter(i.pmin,i.pmax),i.maxD=i.ParserUtilsCls.getStructureSize(i.atoms,i.pmin,i.pmax,i.center),i.maxD<5&&(i.maxD=5),i.oriMaxD=i.maxD,i.oriCenter=i.center.clone(),i.ParserUtilsCls.transformToOpmOri(t),void 0===n.cfg.align&&1==Object.keys(i.structures).length&&$("#"+i.pre+"alternateWrapper").hide(),i.setStyleCls.setAtomStyleByOptions(i.opts),i.setColorCls.setColorByOptions(i.opts,i.atoms),await i.ParserUtilsCls.renderStructure(),i.saveFileCls.showTitle(),void 0!==n.cfg.rotate&&i.resizeCanvasCls.rotStruc(n.cfg.rotate,!0)}}class Wt{constructor(e){this.icn3d=e}async loadMol2Data(e){let t=this.icn3d,s=t.icn3dui,i=this.loadMol2AtomData(e);void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),i?(t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.atoms),await t.ParserUtilsCls.renderStructure(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0)):alert("The Mol2 file has the wrong format...")}loadMol2AtomData(e){let t=this.icn3d;t.icn3dui;let s=e.split(/\r?\n|\r/);if(s.length<4)return!1;t.init();let i,n,l="LIG",r={},o="1_A",a=0,d=0,c=1,h=!1,p=!1,m={},u={};for(let e=0,o=s.length;eMOLECULE"==o){t.molTitle=s[e+1].trim();let l=s[e+2].trim().replace(/\s+/g," ").split(" ");i=l[0],n=l[1],e+=4}else"@ATOM"==o?(c=1,h=!0,++e):"@BOND"==o?(p=!0,h=!1,++e):"@SUBSTRUCTURE"==o&&(p=!1,++e);if(o=s[e].trim(),""!==o&&"#"!==o.substr(0,1)){if(h&&a1&&($("#"+l.pre+"assemblyWrapper").show(),l.asuCnt=l.biomtMatrices.length),l.setStyleCls.setAtomStyleByOptions(l.opts),l.setColorCls.setColorByOptions(l.opts,l.atoms),await l.ParserUtilsCls.renderStructure(),void 0!==r.cfg.rotate&&l.resizeCanvasCls.rotStruc(r.cfg.rotate,!0)}else"pdb"===i?await l.pdbParserCls.loadPdbData(e,t):"align"===i&&(l.bOpm?await l.alignParserCls.downloadAlignmentPart2(t):void 0!==n?await this.loadOpmData(e,n,s,i):await l.alignParserCls.downloadAlignmentPart2(t))}}class Xt{constructor(e){this.icn3d=e}async downloadPdb(e,t){let s,i=this.icn3d,n=i.icn3dui;t?(s="https://alphafold.ebi.ac.uk/files/AF-"+e+"-F1-model_"+i.AFUniprotVersion+".pdb",n.cfg.refseqid?i.ParserUtilsCls.setYourNote(n.cfg.refseqid.toUpperCase()+"(NCBI Protein Acc.) in iCn3D"):i.ParserUtilsCls.setYourNote(e.toUpperCase()+"(AlphaFold) in iCn3D")):(s="https://files.rcsb.org/view/"+e+".pdb",i.ParserUtilsCls.setYourNote(e.toUpperCase()+"(PDB) in iCn3D"));let l=await n.getAjaxPromise(s,"text",!0,"The ID "+e+" can not be found in the server "+s+"...");if(t){l="HEADER "+e+"\n"+l,await i.opmParserCls.parseAtomData(l,e,void 0,"pdb",void 0)}else await i.opmParserCls.loadOpmData(l,e,void 0,"pdb")}async downloadUrl(e,t,s){let i=this.icn3d,n=i.icn3dui,l=e.lastIndexOf("/");if(-1!=l){let t=e.lastIndexOf(".");i.filename=e.substr(l+1,t-l-1)}else{let t=e.lastIndexOf(".");i.filename=e.substr(0,t)}let r=await n.getAjaxPromise(e,"text",!0);if(i.InputfileData=i.InputfileData?i.InputfileData+"\nENDMDL\n"+r:r,i.InputfileType=t,"pdb"===t)await this.loadPdbData(r);else if("mmcif"===t){let e=n.htmlCls.baseUrl+"mmcifparser/mmcifparser.cgi",t={mmciffile:r},s=await n.getAjaxPostPromise(e,t,!0);await i.mmcifParserCls.loadMmcifData(s,void 0)}else if("mol2"===t)await i.mol2ParserCls.loadMol2Data(r);else if("sdf"===t)await i.sdfParserCls.loadSdfData(r);else if("xyz"===t)await i.xyzParserCls.loadXyzData(r);else if("mmcif"===t)await i.mmcifParserCls.loadMmcifData(r);else if("icn3dpng"===t)await n.htmlCls.setHtmlCls.loadPng(r,s);else if("pae"===t){n.htmlCls.dialogCls.openDlg("dl_alignerrormap","Show Predicted Aligned Error (PAE) map");let e=!0;i.contactMapCls.processAfErrorMap(JSON.parse(r),e)}}async loadPdbData(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui;if(!i&&(void 0===n||"target"===n)){let e=!!o.bCommandLoad;o.bStatefile||o.init(e)}let d=o.loadPDBCls.loadPDB(e,t,s,void 0,void 0,i,n,l);void 0===a.cfg.opmid&&o.ParserUtilsCls.transformToOpmOri(t),void 0!==o.biomtMatrices&&o.biomtMatrices.length>1&&(a.bNode||$("#"+o.pre+"assemblyWrapper").show(),o.asuCnt=o.biomtMatrices.length),a.bNode||(void 0!==o.emd?($("#"+o.pre+"mapWrapper1").hide(),$("#"+o.pre+"mapWrapper2").hide(),$("#"+o.pre+"mapWrapper3").hide()):($("#"+o.pre+"emmapWrapper1").hide(),$("#"+o.pre+"emmapWrapper2").hide(),$("#"+o.pre+"emmapWrapper3").hide()));let c=!1;return o.bSecondaryStructure&&1==Object.keys(o.structures).length?c=!1:a.cfg.mmtfid||a.cfg.pdbid||a.cfg.opmid||a.cfg.mmdbid||a.cfg.gi||a.cfg.uniprotid||a.cfg.blast_rep_id||a.cfg.cid||a.cfg.mmcifid||a.cfg.align||a.cfg.chainalign||(c=!0),(!o.bSecondaryStructure||c)&&Object.keys(o.proteins).length>0&&!r?await this.applyCommandDssp(i):(await this.loadPdbDataRender(i),a.bNode||await o.ParserUtilsCls.checkMemProteinAndRotate()),d}async applyCommandDssp(e){let t=this.icn3d,s=t.icn3dui,i=s.utilsCls.isCalphaPhosOnly(s.hashUtilsCls.hash2Atoms(t.proteins,t.atoms));await t.dsspCls.applyDssp(i,e)}async loadPdbDataRender(e){let t=this.icn3d,s=t.icn3dui;void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),s.cfg.afid&&!t.bAfMem&&(t.opts.color="confidence"),t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.hAtoms),await t.ParserUtilsCls.renderStructure(),t.saveFileCls.showTitle(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0),e&&t.definedSetsCls.setModeAndDisplay("all")}}class Kt{constructor(e){this.icn3d=e}async downloadCid(e){let t=this.icn3d,s=t.icn3dui;t.ParserUtilsCls.setYourNote("PubChem CID "+e+" in iCn3D"),t.bCid=!0;let i="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/"+t.inputid+"/cids/JSONP?cids_type=parent",n="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/"+(await s.getAjaxPromise(i,"jsonp",!0,"Can not retrieve the parant CID...")).IdentifierList.CID[0]+"/record/SDF/?record_type=3d&response_type=display",l=await s.getAjaxPromise(n,"text",!0,"This CID may not have 3D structure..."),r=this.loadSdfAtomData(l,e);void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),r?(t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.atoms),await t.ParserUtilsCls.renderStructure(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0)):alert("The SDF of CID "+e+" has the wrong format...")}async loadSdfData(e){let t=this.icn3d,s=t.icn3dui,i=this.loadSdfAtomData(e);void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),i?(t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.atoms),await t.ParserUtilsCls.renderStructure(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0)):alert("The SDF file has the wrong format...")}loadSdfAtomData(e,t){let s=this.icn3d;s.icn3dui;let i=e.split(/\r?\n|\r/);if(i.length<4)return!1;s.init();let n=t||1,l="LIG",r=n,o=n+"_A",a=o+"_1",d=parseInt(i[3].substr(0,3));if(isNaN(d)||d<=0)return!1;let c=parseInt(i[3].substr(3,3)),h=4;if(i.lengthr||(Math.abs(t.coord.y-i.coord.y)>r||Math.abs(t.coord.z-i.coord.z)>r||l.utilsCls.hasCovalentBond(t,i)&&(n.atoms[o[e]].bonds.push(o[s]),n.atoms[o[s]].bonds.push(o[e])))}}}loadXyzAtomData(e){let t=this.icn3d;t.icn3dui;let s=e.split(/\r?\n|\r/);if(s.length<3)return!1;t.init();let i,n,l,r={},o=0,a=1;t.molTitle="";for(let e=0,d=s.length;e1&&(t.molTitle+="; "),t.molTitle+=s[e+1].trim(),e+=2),d=s[e].trim(),""===d)continue;let c=d.replace(/,/," ").replace(/\s+/g," ").split(" "),h=c[0],p=parseFloat(c[1]),m=parseFloat(c[2]),u=parseFloat(c[3]),g={het:!0,serial:a,name:h,resn:"LIG",structure:l,chain:"A",resi:1,coord:new THREE.Vector3(p,m,u),b:0,elem:h,bonds:[],ss:"coil",ssbegin:!1,ssend:!1,bondOrder:[]};t.atoms[a]=g,r[a]=1,++a}return this.setXyzAtomSeq(r,o,i,n),t.ParserUtilsCls.setMaxD(),t.saveFileCls.showTitle(),!0}}class Jt{constructor(e){this.icn3d=e}realign(){let e=this.icn3d,t=e.icn3dui;e.selectionCls.saveSelectionPrep();let s="alseq_"+Object.keys(e.defNames2Atoms).length;e.selectionCls.saveSelection(s,s),t.htmlCls.clickMenuCls.setLogCmd("realign",!0);let i={},n={};e.realignResid={};let l="";for(let s in e.hAtoms){let r=e.atoms[s],o=r.structure+"_"+r.chain;if(e.proteins.hasOwnProperty(s)&&"CA"==r.name||e.nucleotides.hasOwnProperty(s)&&("O3'"==r.name||"O3*"==r.name)){if(r.structure+"_"+r.resi==l)continue;i.hasOwnProperty(r.structure)||(i[r.structure]=[]),i[r.structure].push(r.coord.clone()),e.realignResid.hasOwnProperty(o)||(e.realignResid[o]=[]),e.realignResid[o].push({resid:o+"_"+r.resi,resn:t.utilsCls.residueName2Abbr(r.resn.substr(0,3)).substr(0,1)}),n[r.structure]=r.structure+"_"+r.chain,l=r.structure+"_"+r.resi}}let r=Object.keys(i),o=r[0],a=[];e.qt_start_end=[],a.push(n[o]);for(let t=1,s=r.length;t5){let e=r.cfg.chainalign.split(",");e.length>0&&(l.hAtoms=l.definedSetsCls.getAtomsFromNameArray(e)),r.cfg.aligntool="tmalign",await l.realignParserCls.realignOnStructAlign()}else l.hAtoms=l.chainalignParserCls.setMsa(e),l.transformCls.zoominSelection(),await l.chainalignParserCls.downloadChainalignmentPart3(void 0,e,l.hAtoms)}async parseChainRealignData(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui,d=s[0].substr(0,s[0].indexOf("_"));r||(d=d.toUpperCase());let c={};o.realignResid={},o.opts.color="grey",o.setColorCls.setColorByOptions(o.opts,o.dAtoms),o.qt_start_end=[];for(let t=0,h=e.length;t=6&&C.length>=6&&!a.cfg.command&&o.bRender&&alert("These sequences can not be aligned to each other")):o.bRender&&alert("Please do not align residues in the same structure")}if(r){o.hAtoms=o.chainalignParserCls.setMsa(s);let e="protein_aligned";if(o.selectionCls.saveSelection(e,e),o.bAfMem?(o.selectionCls.selectAll_base(),o.opts.chemicals="stick",o.opts.color="confidence",o.setColorCls.setColorByOptions(o.opts,o.atoms)):(o.transformCls.zoominSelection(),o.dAtoms=a.hashUtilsCls.cloneHash(o.hAtoms),o.opts.color="identity",o.setColorCls.setColorByOptions(o.opts,o.hAtoms)),o.drawCls.draw(),o.hlUpdateCls.updateHlAll(),o.bAfMem){let e=new THREE.Vector3(1,0,0),t=-.5*Math.PI;o.transformCls.setRotation(e,t)}}else o.hAtoms=o.chainalignParserCls.setMsa(s),o.transformCls.zoominSelection(),await o.chainalignParserCls.downloadChainalignmentPart3(t,s,o.hAtoms)}async realignOnSeqAlign(e){let t=this.icn3d;t.icn3dui;let s=t.firstAtomObjCls.getChainsFromAtoms(t.hAtoms),i=Object.keys(s),n=[],l="";for(let e=0,t=i.length;ef&&(f=s)}}}return{data:n,min:g,max:f}}(e.getCategory("_volume_data_3d").getColumn("values"),o,n.sampleCount,l);return{name:n.name,spacegroup:function(e,t,s){let i=Math.PI/180*s[0],n=Math.PI/180*s[1],l=Math.PI/180*s[2],r=t[0],o=t[1],a=t[2],d=Math.cos(n),c=(Math.cos(i)-Math.cos(n)*Math.cos(l))/Math.sin(l),h=Math.sqrt(1-d*d-c*c);return{number:e,size:t,angles:s,basis:{x:[r,0,0],y:[Math.cos(l)*o,Math.sin(l)*o,0],z:[d*a,c*a,h*a]}}}(n.spacegroupNumber,n.cellSize,n.cellAngles),box:{origin:r(n.origin),dimensions:r(n.dimensions),sampleCount:o},data:a.data,valuesInfo:{min:a.min,max:a.max,mean:n.mean,sigma:n.sigma}}}BinaryParse(e){this.icn3d.icn3dui;let t=new Uint8Array(e),s=this.MessagePackParse({buffer:t,offset:0,dataView:new DataView(t.buffer)}),i=function(){function e(e){this.additionalData={},this.header=e.header,this.categoryList=e.categories.map((function(e){return new n(e)})),this.categoryMap=new Map;for(let e=0,t=this.categoryList;e=0;s--)t=c(t,e.encoding[s]);return t}function p(e){if(!e.data.data)return _UndefinedColumn;let t,s=h(e.data);return e.mask&&(t=h(e.mask)),s.buffer&&s.byteLength&&s.BYTES_PER_ELEMENT?t?new f(s,t):new g(s):t?new C(s,t):new b(s)}function m(e,t,s){let i=0,n=1;for(45===e.charCodeAt(t)&&(n=-1,t++);t9||s<0)return n*i|0;i=10*i+s|0}return n*i}function u(e,t,s){let i=1,n=0,l=0,r=1;for(45===e.charCodeAt(t)&&(i=-1,++t);t=0&&o<10)){if(-2===o){for(++t;t=0&&o<10))return 53===o||21===o?parseScientific(i*(n+l/r),e,t+1,s):i*(n+l/r);l=10*l+o,r*=10,++t}return i*(n+l/r)}if(53===o||21===o)return parseScientific(i*n,e,t+1,s);break}n=10*n+o,++t}return i*n}let g=function(){function e(e){this.data=e,this.isDefined=!0}return e.prototype.getString=function(e){return""+this.data[e]},e.prototype.getInteger=function(e){return 0|this.data[e]},e.prototype.getFloat=function(e){return 1*this.data[e]},e.prototype.stringEquals=function(e,t){return this.data[e]===u(t,0,t.length)},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return 0},e}(),f=function(){function e(e,t){this.data=e,this.mask=t,this.isDefined=!0}return e.prototype.getString=function(e){return 0===this.mask[e]?""+this.data[e]:null},e.prototype.getInteger=function(e){return 0===this.mask[e]?this.data[e]:0},e.prototype.getFloat=function(e){return 0===this.mask[e]?this.data[e]:0},e.prototype.stringEquals=function(e,t){return 0===this.mask[e]?this.data[e]===u(t,0,t.length):null==t},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return this.mask[e]},e}(),b=function(){function e(e){this.data=e,this.isDefined=!0}return e.prototype.getString=function(e){return this.data[e]},e.prototype.getInteger=function(e){let t=this.data[e];return m(t,0,t.length)},e.prototype.getFloat=function(e){let t=this.data[e];return u(t,0,t.length)},e.prototype.stringEquals=function(e,t){return this.data[e]===t},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return 0},e}(),C=function(){function e(e,t){this.data=e,this.mask=t,this.isDefined=!0}return e.prototype.getString=function(e){return 0===this.mask[e]?this.data[e]:null},e.prototype.getInteger=function(e){if(0!==this.mask[e])return 0;let t=this.data[e];return m(t||"",0,(t||"").length)},e.prototype.getFloat=function(e){if(0!==this.mask[e])return 0;let t=this.data[e];return u(t||"",0,(t||"").length)},e.prototype.stringEquals=function(e,t){return this.data[e]===t},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return this.mask[e]},e}(),y=function(){function e(e){this.dataBlocks=e.dataBlocks.map((function(e){return new i(e)}))}return e.prototype.toJSON=function(){return this.dataBlocks.map((function(e){return e.toJSON()}))},e}();return new y(s)}MessagePackParse(e){this.icn3d.icn3dui;let t=this;function s(e,s){let i={};for(let n=0;n0&&(i[i.length]=l.slice(0,a).join(""));return i.join("")}(e.buffer,e.offset,t);return e.offset+=t,s}let r=function(){let e=[];for(let t=0;t<1024;t++)e[t]=String.fromCharCode(t);return e}();let o,a,d=e.buffer[e.offset];if(0==(128&d))return e.offset++,d;if(128==(240&d))return a=15&d,e.offset++,s(e,a);if(144==(240&d))return a=15&d,e.offset++,n(e,a);if(160==(224&d))return a=31&d,e.offset++,l(e,a);if(224==(224&d))return o=e.dataView.getInt8(e.offset),e.offset++,o;switch(d){case 192:return e.offset++,null;case 194:return e.offset++,!1;case 195:return e.offset++,!0;case 196:return a=e.dataView.getUint8(e.offset+1),e.offset+=2,i(e,a);case 197:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,i(e,a);case 198:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,i(e,a);case 202:return o=e.dataView.getFloat32(e.offset+1),e.offset+=5,o;case 203:return o=e.dataView.getFloat64(e.offset+1),e.offset+=9,o;case 204:return o=e.buffer[e.offset+1],e.offset+=2,o;case 205:return o=e.dataView.getUint16(e.offset+1),e.offset+=3,o;case 206:return o=e.dataView.getUint32(e.offset+1),e.offset+=5,o;case 208:return o=e.dataView.getInt8(e.offset+1),e.offset+=2,o;case 209:return o=e.dataView.getInt16(e.offset+1),e.offset+=3,o;case 210:return o=e.dataView.getInt32(e.offset+1),e.offset+=5,o;case 217:return a=e.dataView.getUint8(e.offset+1),e.offset+=2,l(e,a);case 218:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,l(e,a);case 219:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,l(e,a);case 220:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,n(e,a);case 221:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,n(e,a);case 222:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,s(e,a);case 223:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,s(e,a)}}}class es{constructor(e){this.icn3d=e}alignCoords(e,t,s,i,n,l,r,o){let a,d=this.icn3d,c=d.icn3dui,h=e.length=4&&(d.rmsd_suprTmp=c.rmsdSuprCls.getRmsdSuprCls(e,t,h),void 0!==d.rmsd_suprTmp.rot)){let e=d.rmsd_suprTmp.rot;null===e[0]&&alert("Please select more residues in each structure...");let t=d.rmsd_suprTmp.trans1,i=d.rmsd_suprTmp.trans2;if(a=d.rmsd_suprTmp.rmsd,a){c.htmlCls.clickMenuCls.setLogCmd("realignment RMSD: "+a.toPrecision(4),!1);let e="
    Realignment RMSD: "+a.toPrecision(4)+" Å

    ";d.bAfMem&&(e+=c.utilsCls.getMemDesc()),$("#"+d.pre+"dl_rmsd").html(e),c.cfg.bSidebyside||c.htmlCls.dialogCls.openDlg("dl_rmsd","Realignment RMSD")}let r={};for(let n=0,l=d.structures[s].length;n"+s.diagram2dCls.set2DdgmNote(!0),$("#"+s.pre+"dl_2ddgm").html(s.html2ddgm),s.b2DShown=!0}async set2DDiagramsForChainalign(e){let t=this.icn3d.icn3dui,s=this;t.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions");let i=[];for(let s=0,n=e.length;s"+s.diagram2dCls.set2DdgmNote(!0),s.b2DShown=!0,$("#"+s.pre+"dl_2ddgm").html(s.html2ddgm),i.cfg.show2d&&i.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions")}download2Ddgm(e,t){this.set2DDiagrams(e)}set2DDiagrams(e){let t=this.icn3d;t.icn3dui.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions"),void 0!==t.b2DShown&&t.b2DShown||(t.html2ddgm="",t.diagram2dCls.draw2Ddgm(t.interactionData,e),t.html2ddgm+="
    "+t.diagram2dCls.set2DdgmNote(),$("#"+t.pre+"dl_2ddgm").html(t.html2ddgm)),t.b2DShown=!0}showLoading(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"wait")&&$("#"+e.pre+"wait").show(),$("#"+e.pre+"canvas")&&$("#"+e.pre+"canvas").hide(),$("#"+e.pre+"cmdlog")&&$("#"+e.pre+"cmdlog").hide()}hideLoading(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"wait")&&$("#"+e.pre+"wait").hide(),$("#"+e.pre+"canvas")&&$("#"+e.pre+"canvas").show(),$("#"+e.pre+"cmdlog")&&$("#"+e.pre+"cmdlog").show()}setYourNote(e){let t=this.icn3d,s=t.icn3dui;t.yournote=e,$("#"+t.pre+"yournote").val(t.yournote),s.cfg.shownote&&(document.title=t.yournote)}transformToOpmOri(e){let t=this.icn3d;if(t.icn3dui,void 0!==t.rmsd_supr&&void 0!==t.rmsd_supr.rot){let s=t.rmsd_supr.rot,i=t.rmsd_supr.trans1,n=t.rmsd_supr.trans2;t.rmsd_supr.rmsd;let l=0;for(let e in t.atoms){let r=t.atoms[e];r.coord=t.surfaceCls.transformMemPro(r.coord,s,i,n);let o=r.coord.x*r.coord.x+r.coord.y*r.coord.y;Math.abs(r.coord.z)<=25&&o>l&&(l=o)}this.addMemAtoms(t.halfBilayerSize,e,Math.sqrt(l)),t.bStopRotate=!0,t.bOpm=!0,$("#"+t.pre+"togglememli").show(),$("#"+t.pre+"adjustmemli").show(),$("#"+t.pre+"selectplaneli").show()}else t.bOpm=!1}transformToOpmOriForAlign(e,t,s){let i=this.icn3d,n=i.icn3dui;if(void 0!==t){let l=i.loadPDBCls.getChainCalpha(i.chains,i.atoms,s,e),r=1==Object.keys(l.chainresiCalphaHash).length||1==Object.keys(t.chainresiCalphaHash).length,o=[],a=[];for(let e in l.chainresiCalphaHash)if(t.chainresiCalphaHash.hasOwnProperty(e)){let s=l.chainresiCalphaHash[e],i=t.chainresiCalphaHash[e];if((s.length==i.length||r)&&(o=o.concat(s),a=a.concat(i)),o.length>500)break}let d=o.length=4)if(i.rmsd_supr=n.rmsdSuprCls.getRmsdSuprCls(o,a,d),void 0!==i.rmsd_supr.rot&&i.rmsd_supr.rmsd<.1){let s=i.rmsd_supr.rot,l=i.rmsd_supr.trans1,r=i.rmsd_supr.trans2,o=i.rmsd_supr.rmsd;n.htmlCls.clickMenuCls.setLogCmd("RMSD of alignment to OPM: "+o.toPrecision(4),!1);let a=0;for(let e in i.atoms){let t=i.atoms[e];t.coord=i.surfaceCls.transformMemPro(t.coord,s,l,r);let n=t.coord.x*t.coord.x+t.coord.y*t.coord.y;Math.abs(t.coord.z)<=25&&n>a&&(a=n)}i.center=t.center,i.oriCenter=i.center.clone(),this.addMemAtoms(i.halfBilayerSize,e,Math.sqrt(a)),i.bStopRotate=!0,i.bOpm=!0,$("#"+i.pre+"togglememli").show(),$("#"+i.pre+"adjustmemli").show(),$("#"+i.pre+"selectplaneli").show()}else i.bOpm=!1;else i.bOpm=!1}}addOneDumAtom(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui,a={het:!0,serial:++l,name:t,alt:void 0,resn:"DUM",structure:e,chain:"MEM",resi:1,coord:new THREE.Vector3(s,i,n),b:void 0,elem:t,bonds:[],ss:"",ssbegin:!1,ssend:!1,color:o.parasCls.atomColors[t]};return r.atoms[l]=a,r.chains[e+"_MEM"][l]=1,r.residues[e+"_MEM_1"][l]=1,r.chemicals[l]=1,r.dAtoms[l]=1,r.hAtoms[l]=1,l}addMemAtoms(e,t,s){let i=this.icn3d;if(i.icn3dui,!t)return;t=t?t.toUpperCase():i.defaultPdbId,i.structures[t].push(t+"_MEM"),i.chains[t+"_MEM"]={},i.residues[t+"_MEM_1"]={},i.chainsSeq[t+"_MEM"]=[{name:"DUM",resi:1}];let n=Object.keys(i.atoms).length;for(let e=0;e<1e3;++e)if(!i.atoms.hasOwnProperty(n+e)){n=n+e-1;break}for(let i=0;i<81;++i)for(let l=0;l<81;++l){let r=2*i-80,o=2*l-80;if(Math.sqrt(r*r+o*o)=2?$("#"+e.pre+"mn2_alternateWrap").show():$("#"+e.pre+"mn2_alternateWrap").hide(),setTimeout((async function(){if(e.bInitial){if(void 0!==t.cfg.align||void 0!==t.cfg.chainalign){let s=e.pre+"selection";if($("#"+s).show(),$("#"+s+"_expand").hide(),$("#"+s+"_shrink").show(),void 0!==t.cfg.align&&2!=t.cfg.atype){let s=!1,i=t.htmlCls.alignSeqCls.getAlignSequencesAnnotations(Object.keys(e.alnChains),void 0,void 0,s);$("#"+e.pre+"dl_sequence2").html(i.sequencesHtml),$("#"+e.pre+"dl_sequence2").width(t.htmlCls.RESIDUE_WIDTH*i.maxSeqCnt+200)}}if(t.cfg.showanno){let s="view annotations";t.htmlCls.clickMenuCls.setLogCmd(s,!0),await e.showAnnoCls.showAnnotations()}t.cfg.closepopup&&e.resizeCanvasCls.closeDialogs()}else e.hlUpdateCls.updateHlAll();$("#"+e.pre+"atomsCustom").length>0&&$("#"+e.pre+"atomsCustom")[0].blur(),e.bInitial=!1}),0)}processCommand(){let e=this.icn3d,t=e.icn3dui;if(1==Object.keys(e.structures).length){let s=Object.keys(e.structures)[0];t.cfg.command=t.cfg.command.replace(new RegExp("!","g"),s+"_")}}getMassCenter(e,t){return this.icn3d.icn3dui,e.multiplyScalar(1/t)}getGeoCenter(e,t){return this.icn3d.icn3dui,e.clone().add(t).multiplyScalar(.5)}getStructureSize(e,t,s,i){let n=this.icn3d;n.icn3dui;let l=0;for(let r in e){let e=n.atoms[r].coord;if(Math.round(t.x)==Math.round(e.x)||Math.round(t.y)==Math.round(e.y)||Math.round(t.z)==Math.round(e.z)||Math.round(s.x)==Math.round(e.x)||Math.round(s.y)==Math.round(e.y)||Math.round(s.z)==Math.round(e.z)){let t=2*e.distanceTo(i);t>l&&(l=t)}}return l}async checkMemProteinAndRotate(){let e=this.icn3d,t=e.icn3dui;if(!e.bCheckMemProtein){e.bCheckMemProtein=!0;let s=t.cfg.afid?t.cfg.afid:t.cfg.mmdbafid;if(await e.ParserUtilsCls.checkMemProtein(s),t.cfg.url&&-1!=t.cfg.url.indexOf("membranome")){let t=new THREE.Vector3(1,0,0),s=-.5*Math.PI;e.transformCls.setRotation(t,s)}}}async checkMemProtein(e){let t=this.icn3d,s=t.icn3dui;try{let i=s.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?afid2mem="+e,n=await s.getAjaxPromise(i,"jsonp");if(n&&n.pdbid){let e='This is a single-spanning (bitopic) transmembrane protein according to the Membranome database. Do you want to align the protein with the model from Membranome? If you click "OK", you can press the letter "a" to alternate the structures.';if("off"==s.cfg.afmem);else if("on"==s.cfg.afmem||confirm(e))try{let e="https://storage.googleapis.com/membranome-assets/pdb_files/proteins/"+n.pdbid+".pdb",i=await s.getAjaxPromise(e,"text");t.bAfMem=!0,s.bNode||$("#"+s.pre+"togglememli").show();let l=n.pdbid.substr(0,n.pdbid.indexOf("_")),r=!0,o=!0;await t.pdbParserCls.loadPdbData(i,l,r,o),o&&(t.bSetChainsAdvancedMenu&&t.definedSetsCls.showSets(),t.bAnnoShown&&await t.showAnnoCls.showAnnotations());let a=n.segment.replace(/ /gi,"").split("(")[0];t.afmem_start_end=a.split("-"),t.hAtoms={},t.dAtoms={};for(let e in t.atoms)t.atoms[e].structure!=l&&(t.hAtoms[e]=1),t.dAtoms[e]=1;for(let e=parseInt(t.afmem_start_end[0]);e<=parseInt(t.afmem_start_end[1]);++e)t.hAtoms=s.hashUtilsCls.unionHash(t.hAtoms,t.residues[l+"_A_"+e]);await t.realignParserCls.realignOnSeqAlign(l)}catch(e){return void console.log("Error in retrieving matched PDB from Membranome...")}}}catch(e){return void console.log("Error in finding matched PDB in Membranome...")}}getResi(e,t){let s=this.icn3d;s.icn3dui;let i=s.ncbi2resid[e+"_"+(t+1).toString()];return i?i.substr(i.lastIndexOf("_")+1):""}getResiNCBI(e,t){let s=this.icn3d;s.icn3dui;let i=s.resid2ncbi[e+"_"+t];return i?parseInt(i.substr(i.lastIndexOf("_")+1)):0}}class ts{constructor(e){this.icn3d=e}loadAtomDataIn(e,t,s,i,n,l,r,o,a){let d=this.icn3d,c=d.icn3dui;d.pmin=new THREE.Vector3(9999,9999,9999),d.pmax=new THREE.Vector3(-9999,-9999,-9999),d.psum=new THREE.Vector3;let h=e.atoms,p=d.atoms?Object.keys(d.atoms).length:0,m={},u={};d.pmid=e.pubmedId,void 0===d.chainid2title&&(d.chainid2title={}),void 0===d.chainid2sid&&(d.chainid2sid={});let g={},f={};if("align"===s){d.pmid="",d.molTitle="",c.cfg.inpara&&-1!==c.cfg.inpara.indexOf("atype=1")?d.molTitle="Invariant Core Structure Alignment (VAST) of ":c.cfg.inpara&&-1!==c.cfg.inpara.indexOf("atype=2")?d.molTitle="Structure Alignment (TM-align) of ":d.molTitle="Structure Alignment (VAST) of ";let t=!1;for(let s=0,i=e.alignedStructures[0].length;s'+i.pdbId.toUpperCase()+"",void 0!==i.descr&&(d.pmid+=i.descr.pubmedid),0===s&&(d.molTitle+=" and ",void 0!==i.descr&&(d.pmid+="_")),t=!0}d.molTitle+=" from VAST+",t||(d.molTitle="")}else if(void 0!==e.descr&&(d.molTitle+=e.descr.name),"mmdbid"===s){let s=isNaN(t)?t:e.pdbId,i={};void 0===d.alignmolid2color&&(d.alignmolid2color=[]);let n=1;for(let t in e.moleculeInfor){if(0===Object.keys(e.moleculeInfor[t]).length)continue;let l=e.moleculeInfor[t].chain.trim(),r=s+"_"+l;i.hasOwnProperty(l)?(++i[l],r+=i[l]):i[l]=1,void 0!==d.mmdbid_q&&(d.mmdbid_q,d.mmdbid_t);let o=e.moleculeInfor[t].kind,a=e.moleculeInfor[t].color,c=e.moleculeInfor[t].sid;if(g[r]=o,f[r]=a,"protein"==o&&(d.organism=e.moleculeInfor[t].taxonomyName.toLowerCase()),void 0!==c&&(d.chainid2sid[r]=c),void 0===d.pdbid_chain2title&&(d.pdbid_chain2title={}),d.pdbid_chain2title[r]=e.moleculeInfor[t].name,l==r.substr(r.lastIndexOf("_"))){let e={};e[t]=n.toString(),d.alignmolid2color.push(e)}++n}}let b,C,y,v,w,_={},S="",A="",x="",k="",O="",R="",E=0,I=0,T="",M=!0,P=!1,D="",H=c.utilsCls.isCalphaPhosOnly(h),F=0,L={};for(let e in h){++p,_[e]=p;let i,n=h[e];n.serial=p,"mmdbid"===s||"mmcifid"===s?i=t:"align"===s&&(i=m[p]);let l=!1;if(void 0!==n.chain||"mmdbid"!==s&&"align"!==s)n.chain=""===n.chain?"Misc":n.chain;else if("mmdbid"===s)if(b=n.ids.m,void 0!==d.molid2chain[b]){let e=d.molid2chain[b].indexOf("_");n.chain=d.molid2chain[b].substr(e+1)}else{let e="Misc";("protein"===g[O]&&"nucleotide"===g[O]&&n.resi!=I||"protein"!==g[O]&&"nucleotide"!==g[O]&&(n.resn.substr(0,3)!=T.substr(0,3)||n.resi!=I||"solvent"===g[O]||"HOH"===n.resn))&&++F,n.resi_ori=n.resi,n.resi=F,l=!0,n.chain=e}else if("align"===s)if(b=n.ids.m,void 0!==d.pdbid_molid2chain[i+"_"+b])n.chain=d.pdbid_molid2chain[i+"_"+b];else{let e="Misc";("protein"===g[O]&&"nucleotide"===g[O]&&n.resi!=I||"protein"!==g[O]&&"nucleotide"!==g[O]&&(n.resn.substr(0,3)!=T.substr(0,3)||n.resi!=I||"solvent"===g[O]||"HOH"===n.resn))&&(++F,n.resi_ori=n.resi,n.resi=F,l=!0),n.chain=e}if(n.chain=n.chain.trim(),"mmdbid"!==s&&"align"!==s||(n.structure=i,"mmdbid"===s&&void 0!==d.mmdbid_q&&(d.mmdbid_q,d.mmdbid_t)),k=n.structure,O=k+"_"+n.chain,"mmdbid"===s||"align"===s){l||(n.resi_ori=n.resi,d.bUsePdbNum?n.resi=n.resi_ori:n.resi=n.ids.r);let e=n.resn.indexOf(" ");-1!==e&&0!=e&&(n.resn=n.resn.substr(0,e))}O!==A&&(E=0),n.resi!==E&&(O!==A?(y=void 0,w=void 0):(y=C,w=v)),n.coord="mmdbid"===s?new THREE.Vector3(n.coord[0],n.coord[1],n.coord[2]):new THREE.Vector3(n.coord.x,n.coord.y,n.coord.z);let r=c.utilsCls.residueName2Abbr(n.resn.substr(0,3));"mmdbid"!==s&&"align"!==s||!d.bFullUi||(void 0===d.mmdbMolidResid2mmdbChainResi&&(d.mmdbMolidResid2mmdbChainResi={}),d.mmdbMolidResid2mmdbChainResi[i+"_"+n.ids.m+"_"+n.ids.r]=i+"_"+n.chain+"_"+n.resi),d.pmin.min(n.coord),d.pmax.max(n.coord),d.psum.add(n.coord);let o=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"protein"===g[O]:"p"===n.mt,a=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"nucleotide"===g[O]:"n"===n.mt,u=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"solvent"===g[O]:"s"===n.mt,N=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"ligand"===g[O]||void 0!==g[O]&&-1!==g[O].indexOf("other")||void 0===g[O]:"l"===n.mt;if("Misc"!==n.chain&&"other"!==g[O]||"protein"===L[O]||"nucleotide"===L[O]||("CA"===n.name&&"C"===n.elem?L[O]="protein":"P"===n.name&&"P"===n.elem?L[O]="nucleotide":L[O]="chemical"),o||a?(o?(d.proteins[p]=1,"CA"===n.name&&(d.calphas[p]=1),"N"!==n.name&&"H"!==n.name&&"CA"!==n.name&&"HA"!==n.name&&"C"!==n.name&&"O"!==n.name&&(d.sidec[p]=1)):a&&(d.nucleotides[p]=1,("O3'"==n.name||"O3*"==n.name||H&&"P"==n.name)&&(d.nucleotidesO3[p]=1),-1===c.parasCls.nuclMainArray.indexOf(n.name)&&(d.ntbase[p]=1)),n.het=!1):u?(d.water[p]=1,n.het=!0):N&&("HOH"===n.resn||"O"===n.resn?d.water[p]=1:n.elem===n.resn?d.ions[p]=1:d.chemicals[p]=1,n.het=!0),"mmdbid"===s?n.het?n.color=c.parasCls.atomColors[n.elem]||c.parasCls.defaultAtomColor:n.color=void 0!==f[O]?c.parasCls.thr(f[O]):c.parasCls.chargeColors[n.resn]:void 0!==n.color&&(n.color=c.parasCls.thr(n.color))," "!==n.resn.charAt(0)&&" "===n.resn.charAt(1)&&(n.resn=n.resn.charAt(0)),n.het||"C"!==n.name||(C=p),n.het||"O"!==n.name||(v=p),!n.het&&"N"===n.name&&void 0!==y&&void 0!==w){let e=d.atoms[y].coord.distanceTo(d.atoms[w].coord),t=n.coord.x+(d.atoms[y].coord.x-d.atoms[w].coord.x)/e,s=n.coord.y+(d.atoms[y].coord.y-d.atoms[w].coord.y)/e,i=n.coord.z+(d.atoms[y].coord.z-d.atoms[w].coord.z)/e;n.hcoord=new THREE.Vector3(t,s,i)}"HOH"==n.resn&&(d.water[p]=1),d.atoms[p]=n,d.dAtoms[p]=1,d.hAtoms[p]=1;let U=n.structure+"_"+n.chain;void 0===d.chains[U]&&(d.chains[U]={}),d.chains[U][p]=1;let q=U+"_"+n.resi;void 0===d.residues[q]&&(d.residues[q]={}),d.residues[q][p]=1,R=O+"_"+n.resi,R!==x&&O!==A&&(M=!0,""!==S&&(void 0===d.structures[S]&&(d.structures[S]=[]),d.structures[S].push(A))),d.residueId2Name[q]=r;let $="-";if("helix"===n.ss?$="H":"sheet"===n.ss?$="E":n.het||a?$="o":(!n.het&&c.parasCls.residueColors.hasOwnProperty(n.resn.toUpperCase())||"coil"===n.ss)&&($="c"),d.secondaries[n.structure+"_"+n.chain+"_"+n.resi]=$,(n.resi!=E||b!=D)&&d.bFullUi&&(void 0===d.chainsSeq[U]&&(d.chainsSeq[U]=[],M=!1),!isNaN(n.resi)))if(M&&!P&&void 0!==d.chainsSeq[U][n.resi-1])d.chainsSeq[U][n.resi-1].name=r;else if(!M||!d.chainsSeq[U].hasOwnProperty(n.resi-1)){let e={};e.resi=n.resi,e.name=r,n.resi%10==0&&n.resi.toString(),d.chainsSeq[U].push(e),P=!0}E=n.resi,I=n.resi_ori,T=n.resn,S=k,A=O,x=R,D=b}for(let e in d.chemicals){let t=d.atoms[e];if("P"==t.elem&&t.bonds.length>=4)for(let e=t.bonds.length-1;e>=0;--e){"P"==d.atoms[t.bonds[e]].elem&&t.bonds.splice(e,1)}}for(let e in L)if(!(Object.keys(d.chains[e]).length<10)&&"chemical"!==L[e])for(let t in d.chains[e]){let s=d.atoms[t];delete d.chemicals[t],s.het=!1,"protein"===L[e]?(d.proteins[t]=1,"CA"===s.name&&(d.calphas[t]=1),"N"!==s.name&&"H"!==s.name&&"CA"!==s.name&&"HA"!==s.name&&"C"!==s.name&&"O"!==s.name&&(d.sidec[t]=1)):"nucleotide"===L[e]&&(d.nucleotides[t]=1,("O3'"==s.name||"O3*"==s.name||H&&"P"==s.name)&&(d.nucleotidesO3[t]=1),-1===c.parasCls.nuclMainArray.indexOf(s.name)&&(d.ntbase[t]=1))}if(void 0===d.structures[k]&&(d.structures[k]=[]),d.structures[k].push(O),d.bFullUi)if("mmdbid"===s||"mmcifid"===s)for(let i in e.sequences){let n=e.sequences[i],l=t+"_"+i;void 0!==d.mmdbid_q&&(d.mmdbid_q,d.mmdbid_t),d.ParserUtilsCls.getMissingResidues(n,s,l)}else if("align"===s)for(let e in d.chainid2seq){let t=d.chainid2seq[e];d.ParserUtilsCls.getMissingResidues(t,s,e)}if(d.loadPDBCls.setResidMapping(),"mmcifid"!==s)for(let e in h){let t=_[e],s=void 0===d.atoms[t].bonds?0:d.atoms[t].bonds.length;for(let e=0;ed.maxatomcnt||void 0!==d.biomtMatrices&&d.biomtMatrices.length*d.cnt>10*d.maxatomcnt)&&(d.opts.proteins="c alpha trace",d.opts.nucleotides="o3 trace"),d.center=d.ParserUtilsCls.getGeoCenter(d.pmin,d.pmax),d.maxD=d.ParserUtilsCls.getStructureSize(d.atoms,d.pmin,d.pmax,d.center),d.maxD<5&&(d.maxD=5),d.oriMaxD=d.maxD,("align"===s||o)&&(d.ssbondpnts={},d.loadPDBCls.setSsbond()),"mmdbid"===s&&1==Object.keys(d.structures).length){let t=e.disulfides;if(void 0!==t)for(let e=0,s=t.length;ep&&(p=e)),c[e]={resi:t,resn:i,aligned:n}}r=e[t][1];let u=r.moleculeId,g=s.pdbid_molid2chain[l+"_"+u],f=l+"_"+g;void 0===s.alnChainsAnTtl[d]&&(s.alnChainsAnTtl[d]=[]),void 0===s.alnChainsAnTtl[d][0]&&(s.alnChainsAnTtl[d][0]=[]),void 0===s.alnChainsAnTtl[d][1]&&(s.alnChainsAnTtl[d][1]=[]),void 0===s.alnChainsAnTtl[d][2]&&(s.alnChainsAnTtl[d][2]=[]),void 0===s.alnChainsAnTtl[d][3]&&(s.alnChainsAnTtl[d][3]=[]),void 0===s.alnChainsAnTtl[d][4]&&(s.alnChainsAnTtl[d][4]=[]),void 0===s.alnChainsAnTtl[d][5]&&(s.alnChainsAnTtl[d][5]=[]),void 0===s.alnChainsAnTtl[d][6]&&(s.alnChainsAnTtl[d][6]=[]),s.alnChainsAnTtl[d][0].push(f),s.alnChainsAnTtl[d][1].push(d),s.alnChainsAnTtl[d][2].push(""),s.alnChainsAnTtl[d][3].push(""),s.alnChainsAnTtl[d][4].push(f),s.alnChainsAnTtl[d][5].push(d),s.alnChainsAnTtl[d][6].push("");let b=1;s.chainsMapping[d]||(s.chainsMapping[d]={}),s.chainsMapping[f]||(s.chainsMapping[f]={});for(let e=h;e<=p;++e){let t,o,p,m=s.bUsePdbNum?s.ParserUtilsCls.getResi(f,r.sequence[e][0]-1):r.sequence[e][0],u="~"===r.sequence[e][2]?"-":r.sequence[e][2],C=r.sequence[e][3]?1:0,y=c[e].aligned+C;2===y?(c[e].resn===u?(t="#FF0000",p="icn3d-cons",s.consHash1[d+"_"+c[e].resi]=1,s.consHash2[f+"_"+m]=1):(t="#0000FF",p="icn3d-ncons",s.nconsHash1[d+"_"+c[e].resi]=1,s.nconsHash2[f+"_"+m]=1),s.chainsMapping[d][d+"_"+c[e].resi]=c[e].resn+c[e].resi,s.chainsMapping[f][f+"_"+m]=c[e].resn+c[e].resi,o="#"+s.showAnnoCls.getColorhexFromBlosum62(c[e].resn,u)):(t=i.htmlCls.GREY8,p="icn3d-nalign",s.nalignHash1[d+"_"+c[e].resi]=1,s.nalignHash2[f+"_"+m]=1),void 0===s.alnChainsSeq[d]&&(s.alnChainsSeq[d]=[]);let v={};v.mmdbid=n,v.chain=a,v.resi=c[e].resi,v.resn=""===v.resi||"icn3d-nalign"===p?c[e].resn.toLowerCase():c[e].resn,v.aligned=y,v.color=""===v.resi?i.htmlCls.GREYC:t,v.color2=""===v.resi?i.htmlCls.GREYC:o,v.class=p,s.alnChainsSeq[d].push(v),""!==c[e].resi&&(void 0===s.alnChains[d]&&(s.alnChains[d]={}),$.extend(s.alnChains[d],s.residues[d+"_"+c[e].resi])),void 0===s.alnChainsSeq[f]&&(s.alnChainsSeq[f]=[]),v={},v.mmdbid=l,v.chain=g,v.resi=m,v.resn=""===v.resi||"icn3d-nalign"===p?u.toLowerCase():u,v.aligned=y,v.color=""===v.resi?i.htmlCls.GREYC:t,v.color2=""===v.resi?i.htmlCls.GREYC:o,v.class=p,s.alnChainsSeq[f].push(v),""!==v.resi&&(void 0===s.alnChains[f]&&(s.alnChains[f]={}),$.extend(s.alnChains[f],s.residues[f+"_"+m])),void 0===s.alnChainsAnno[d]&&(s.alnChainsAnno[d]=[]),void 0===s.alnChainsAnno[d][0]&&(s.alnChainsAnno[d][0]=[]),void 0===s.alnChainsAnno[d][1]&&(s.alnChainsAnno[d][1]=[]),void 0===s.alnChainsAnno[d][2]&&(s.alnChainsAnno[d][2]=[]),void 0===s.alnChainsAnno[d][3]&&(s.alnChainsAnno[d][3]=[]),e===h&&(void 0===s.alnChainsAnno[d][4]&&(s.alnChainsAnno[d][4]=[]),void 0===s.alnChainsAnno[d][5]&&(s.alnChainsAnno[d][5]=[]),void 0===s.alnChainsAnno[d][6]&&(s.alnChainsAnno[d][6]=[]),s.alnChainsAnno[d][4].push(s.pdbid_chain2title[f]),s.alnChainsAnno[d][5].push(s.pdbid_chain2title[d]),s.alnChainsAnno[d][6].push(""));let w=d+"_"+c[e].resi,_=f+"_"+m,S=s.secondaries[w],A=s.secondaries[_];A?s.alnChainsAnno[d][0].push(A):s.alnChainsAnno[d][0].push("-"),S?s.alnChainsAnno[d][1].push(S):s.alnChainsAnno[d][1].push("-");let x=".";b%5==0&&(x="*"),b%10==0&&(x="|"),s.alnChainsAnno[d][2].push(x);let k="";b%10==0&&(k=b.toString()),s.alnChainsAnno[d][3].push(k),++b}}e={}}getPosFromResi(e,t){let s=this.icn3d;s.icn3dui;let i,n=s.resid2ncbi[e+"_"+t];if(n){i=n.substr(n.lastIndexOf("_")+1)-1}return i}getResnFromResi(e,t){let s=this.icn3d,i=s.icn3dui,n=this.getPosFromResi(e,t);if(!n)return"?";let l=e+"_"+t,r="";return r=void 0===s.residues[l]?s.chainsSeq[e][n]?s.chainsSeq[e][n].name:"?":i.utilsCls.residueName2Abbr(s.firstAtomObjCls.getFirstAtomObj(s.residues[l]).resn.substr(0,3)),r}setSeqAlignChain(e,t,s){let i,n,l,r,o,a,d,c,h,p,m,u=this.icn3d,g=u.icn3dui,f={},b=!!s;if(b){if(o=s[1],a=s[0],t=s[2],d=o.indexOf("_"),c=a.indexOf("_"),i=o.substr(0,d).toUpperCase(),n=a.substr(0,c).toUpperCase(),l=o.substr(d+1),r=a.substr(d+1),i==n&&l==r){let e=u.chainsSeq[n+"_"+r].length;u.qt_start_end[t]={q_start:1,q_end:e,t_start:1,t_end:e}}}else{let d=s[0].indexOf("_"),c=e.indexOf("_");if(i=u.mmdbid_t,n=e.substr(0,c).toUpperCase(),l=s[0].substr(d+1),r=e.substr(c+1),i==n&&l==r){let e=u.chainsSeq[u.mmdbid_q+"_"+u.chain_q].length;u.qt_start_end[t]={q_start:1,q_end:e,t_start:1,t_end:e}}o=i+"_"+l,a=n+"_"+r,void 0!==n&&u.mmdbid_t}u.conservedName1=o+"_cons",u.nonConservedName1=o+"_ncons",u.notAlignedName1=o+"_nalign",u.conservedName2=a+"_cons",u.nonConservedName2=a+"_ncons",u.notAlignedName2=a+"_nalign",u.consHash1={},u.nconsHash1={},u.nalignHash1={},u.consHash2={},u.nconsHash2={},u.nalignHash2={},u.alnChains={},u.alnChainsSeq[o]=[],u.alnChains[o]={},u.alnChainsSeq[a]=[],u.alnChains[a]={},u.alnChainsAnno[o]=[],u.alnChainsAnTtl[o]=[],void 0===u.alnChainsAnTtl[o]&&(u.alnChainsAnTtl[o]=[]);for(let e=0;e<7;++e)void 0===u.alnChainsAnTtl[o][e]&&(u.alnChainsAnTtl[o][e]=[]);u.alnChainsAnTtl[o][0].push(a),u.alnChainsAnTtl[o][1].push(o),u.alnChainsAnTtl[o][2].push(""),u.alnChainsAnTtl[o][3].push(""),u.alnChainsAnTtl[o][4].push(a),u.alnChainsAnTtl[o][5].push(o),u.alnChainsAnTtl[o][6].push("");let C=0,y=0;if(void 0===u.qt_start_end[t])return;let v=1;u.chainsMapping[o]||(u.chainsMapping[o]={}),u.chainsMapping[a]||(u.chainsMapping[a]={});let w={},_={};for(let e=0,s=u.qt_start_end[t].length;e0){let e=v;for(let t=C+1,i=s;tc&&(c=t)}}}"tmalign"==n.cfg.aligntool&&(s=!0);let p=Object.keys(a);p.sort((function(e,t){return parseInt(e)-parseInt(t)}));let m=-999,u=0,g=0,f=[],b=0;for(let e=0,t=p.length;e0&&i.resid2ncbi[t]!=i.resid2ncbi[m]+1&&i.resid2ncbi[t]!=i.resid2ncbi[m]){g=m;for(let e=0,t=f.length;ec)continue;let o={},p=r.indexOf("_");o.mmdbid=r.substr(0,p),o.chain=r.substr(p+1),o.resi=t,o.resn=a[t]?i.chainsSeq[r][e].name.toUpperCase():i.chainsSeq[r][e].name.toLowerCase(),o.aligned=!!a[t],o.color=a[t]?"#FF0000":n.htmlCls.GREYC,o.color2=a[t]?"#FF0000":n.htmlCls.GREYC,o.class=a[t]?"icn3d-align":"icn3d-nalign",i.alnChainsSeq[r].push(o),a[t]&&($.extend(i.alnChains[r],i.residues[r+"_"+o.resi]),l=n.hashUtilsCls.unionHash(l,i.residues[r+"_"+o.resi]))}let C=[0];for(let i=0,r=t.length;in)for(let e=0,t=u-m;e=n)for(let e=0,s=t-n;e0?void 0!==n?p.alnChainsAnno[t][0].push(n):p.alnChainsAnno[t][0].push("-"):console.log("Error: ic.alnChainsAnno[chainid1] is undefined")}}}class is{constructor(e){this.icn3d=e}getStructureId(e,t,s){let i=this.icn3d;i.icn3dui;let n=e;return(e==i.defaultPdbId||s)&&(n=1===t?e:e+t.toString()),n}loadPDB(e,t,s,i,n,l,r,o){let a,d,c=this.icn3d,h=c.icn3dui,p={},m=!1,u=e.split("\n"),g={},f={};c.atoms||(l=!1),n||l?(c.oriNStru=c.structures?Object.keys(c.structures).length:0,d=c.oriNStru+1,a=c.atoms?Object.keys(c.atoms).length:0):(c.init(),d=1,a=0);let b,C,y,v,w,_,S,A=[],x=[],k=[],O=[],R=[],E=[],I="",T="",M="",P={},D=t||c.defaultPdbId,H=D,F="",L=!1;for(let e in u){let r=u[e],o=r.substr(0,6);if("HEADER"!==o||L||t)if("TITLE "===o){let e=r.substr(10).replace(/ALPHAFOLD MONOMER V2.0 PREDICTION FOR /gi,"");c.molTitle+=e.trim()+" "}else if("HELIX "===o){c.bSecondaryStructure=!0;let e=""==r.substr(18,2).trim()?"A":r.substr(18,2).trim(),t=parseInt(r.substr(21,4)),s=parseInt(r.substr(33,4));for(let i=t;i<=s;++i){let n=H+"_"+e+"_"+i;O.push(n),i===t&&R.push(n),i===s&&E.push(n)}}else if("SHEET "===o){void 0!==s&&s||(c.bSecondaryStructure=!0);let e=""==r.substr(20,2).trim()?"A":r.substr(20,2).trim(),t=parseInt(r.substr(22,4)),i=parseInt(r.substr(33,4));for(let s=t;s<=i;++s){let n=H+"_"+e+"_"+s;A.push(n),s===t&&x.push(n),s===i&&k.push(n)}}else if("HBOND "===o)void 0!==s&&s||(c.bSecondaryStructure=!0);else if("SSBOND"===o){c.bSsbondProvided=!0;let e=D+"_"+(" "==r.substr(15,1)?"A":r.substr(15,1))+"_"+r.substr(17,4).trim(),t=D+"_"+(" "==r.substr(29,1)?"A":r.substr(29,1))+"_"+r.substr(31,4).trim();void 0===c.ssbondpnts[D]&&(c.ssbondpnts[D]=[]),c.ssbondpnts[D].push(e),c.ssbondpnts[D].push(t)}else if("REMARK"===o){let e=parseInt(r.substr(7,3));if(-1!==r.indexOf("1/2 of bilayer thickness:"))c.halfBilayerSize=parseFloat(r.substr(r.indexOf(":")+1).trim());else if(210==e)"EXPERIMENT TYPE"==r.substr(11,32).trim()&&"NMR"==r.substr(45).trim()&&(m=!0);else if(350==e&&"BIOMT"==r.substr(13,5)){let e=parseInt(r[18])-1,t=parseInt(r.substr(21,2))-1;null==c.biomtMatrices[t]&&(c.biomtMatrices[t]=(new THREE.Matrix4).identity()),c.biomtMatrices[t].elements[e]=parseFloat(r.substr(24,9)),c.biomtMatrices[t].elements[e+4]=parseFloat(r.substr(34,9)),c.biomtMatrices[t].elements[e+8]=parseFloat(r.substr(44,9)),c.biomtMatrices[t].elements[e+12]=parseFloat(r.substr(54,14))}else if(465==e&&" "==r.substr(18,1)&&" "==r.substr(20,1)&&"S"!=r.substr(21,1)){let e=r.substr(15,3),t=r.substr(18,2).trim(),s=r.substr(21,5).trim(),i=D+"_"+t;void 0===c.chainMissingResidueArray[i]&&(c.chainMissingResidueArray[i]=[]);let n={};n.resi=s,n.name=h.utilsCls.residueName2Abbr(e).toLowerCase(),""!=F&&t==F&&t!=F||(c.chainMissingResidueArray[i].push(n),F=t)}else 900==e&&void 0===c.emd&&"RELATED DB: EMDB"==r.substr(34).trim()&&(c.emd=r.substr(23,11).trim())}else if("SOURCE"===o&&void 0===c.organism&&"ORGANISM_COMMON"==r.substr(11,15).trim())c.organism=r.substr(28).toLowerCase().trim(),c.organism=c.organism.substr(0,c.organism.length-1);else if("ENDMDL"===o)++d,D=c.defaultPdbId,H=this.getStructureId(D,d,n),m||(A=[],x=[],k=[],O=[],R=[],E=[]),L=!1;else if("JRNL "===o)"PMID"===r.substr(12,4)&&(c.pmid=r.substr(19).trim());else if("ATOM "===o||"HETATM"===o){H=this.getStructureId(D,d,n);let e=r.substr(16,1);++a,P[parseInt(r.substr(6,5))]=a;let t=r.substr(76,2).trim();""===t&&(t=r.substr(12,2).trim());let l=r.substr(12,4).trim(),u=r.substr(17,3),F=r.substr(20,2).trim();""===F&&(F="A");let L=r.substr(22,5).trim(),N=L;if(s&&"DUM"===u&&(t=l,F="MEM",N=1,L=1),i&&"DUM"===u)break;b=H+"_"+F,y=b+"_"+L,C=b+"_"+N;let U=parseFloat(r.substr(30,8)),q=parseFloat(r.substr(38,8)),$=parseFloat(r.substr(46,8)),j=new THREE.Vector3(U,q,$),B={het:"H"===o[0],serial:a,name:l,alt:e,resn:u,structure:H,chain:F,resi:N,coord:j,b:parseFloat(r.substr(60,8)),elem:t,bonds:[],ss:"coil",ssbegin:!1,ssend:!1};if(B.het||"C"!==B.name||(v=a),B.het||"O"!==B.name||(_=a),!B.het&&"N"===B.name&&void 0!==w&&void 0!==S){let e=c.atoms[w].coord.distanceTo(c.atoms[S].coord),t=B.coord.x+(c.atoms[w].coord.x-c.atoms[S].coord.x)/e,s=B.coord.y+(c.atoms[w].coord.y-c.atoms[S].coord.y)/e,i=B.coord.z+(c.atoms[w].coord.z-c.atoms[S].coord.z)/e;B.hcoord=new THREE.Vector3(t,s,i)}c.atoms[a]=B,c.dAtoms[a]=1,c.hAtoms[a]=1,p[a]=1,this.isSecondary(C,A,m)?(c.atoms[a].ss="sheet",this.isSecondary(C,x,m)&&(c.atoms[a].ssbegin=!0),this.isSecondary(C,k,m)&&(c.atoms[a].ssend=!0)):this.isSecondary(C,O,m)&&(c.atoms[a].ss="helix",this.isSecondary(C,R,m)&&(c.atoms[a].ssbegin=!0),this.isSecondary(C,E,m)&&(c.atoms[a].ssend=!0));let z="-";if(z="helix"===c.atoms[a].ss?"H":"sheet"===c.atoms[a].ss?"E":!c.atoms[a].het&&h.parasCls.residueColors.hasOwnProperty(c.atoms[a].resn.toUpperCase())?"c":"o",c.secondaries[C]=z,y!==M){let e=h.utilsCls.residueName2Abbr(u);if(c.residueId2Name[C]=e,1!==a&&""!==T&&(c.residues[T]=f),C!==T&&(f={}),b!==I){w=void 0,S=void 0,1!==a&&""!==I&&(void 0===c.chains[I]&&(c.chains[I]={}),c.chains[I]=h.hashUtilsCls.unionHash(c.chains[I],g)),g={},void 0===c.structures[H.toString()]&&(c.structures[H.toString()]=[]),c.structures[H.toString()].includes(b)||c.structures[H.toString()].push(b),void 0===c.chainsSeq[b]&&(c.chainsSeq[b]=[]);let t={};t.resi=N,t.name=e,c.chainsSeq[b].push(t)}else{w=v,S=_;let t={};t.resi=N,t.name=e,c.chainsSeq[b].push(t)}}g[a]=1,f[a]=1,I=b,T=C,M=y}else if("CONECT"===o){let e=parseInt(r.substr(6,5));for(let t=0;t<4;++t){let s=parseInt(r.substr([11,16,21,26][t],5));isNaN(s)||void 0!==c.atoms[P[e]]&&c.atoms[P[e]].bonds.push(P[s])}}else"TER"===o.substr(0,3)&&++a;else D=r.substr(62).trim(),""==D&&(D=l?c.defaultPdbId:c.inputid&&-1==c.inputid.indexOf("/")?c.inputid.substr(0,10):c.defaultPdbId),H=this.getStructureId(D,d,n),c.molTitle="",L=!0}c.residues[C]=f,void 0===c.chains[b]&&(c.chains[b]={}),c.chains[b]=h.hashUtilsCls.unionHash2Atoms(c.chains[b],g,c.atoms),n||this.adjustSeq(c.chainMissingResidueArray);let N=Object.keys(c.structures);for(let e=0,t=N.length;e=l?n:l,o=new Array(s+i),a=0,d=0,c=0,h=!1;for(;ar&&i>r&&(h=!0),s<=r&&i>r?s>i||h?(o[c]=t[d],d++):(o[c]=e[a],a++):s>r&&i<=r?s<=i||h?(o[c]=e[a],a++):(o[c]=t[d],d++):s<=i?(o[c]=e[a],a++):(o[c]=t[d],d++),c++}if(a4||Math.abs(l.y-r.y)>4||Math.abs(l.z-r.z)>4||(l.x-r.x)*(l.x-r.x)+(l.y-r.y)*(l.y-r.y)+(l.z-r.z)*(l.z-r.z)<16&&(void 0===e.ssbondpnts[s]&&(e.ssbondpnts[s]=[]),e.ssbondpnts[s].push(o),e.ssbondpnts[s].push(a)))}}}getChainCalpha(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r={};for(let o in e){if(void 0!==i){if(o.split("_")[0]!==i)continue}let a=Object.keys(e[o]),d=[],c=0,h=0;for(let e=0,i=a.length;e3?i.resn.trim().substr(0,3):i.resn.trim();if(!l.parasCls.chargeColors.hasOwnProperty(e))continue;s?i.resi_ori:i.resi,d.push(i.coord.clone()),++c,h=i.resi}}if(c>0){r[t[a[0]].chain]=d}}return{chainresiCalphaHash:r,center:n.center.clone()}}isSecondary(e,t,s){if(this.icn3d.icn3dui,s){let s=e.substr(e.indexOf("_")+1),i=!1;for(let e=0,n=t.length;e0&&(d=!0);for(let n=0,l=t.length;na&&(a=l),s.push(l)}o.push(s)}if(!d)return void(n.bRender&&alert("These structures can not be aligned..."));a<1e-6&&(a=1);for(let e=0,s=t.length;ep[e]=4&&(n.rmsd_suprTmp=l.rmsdSuprCls.getRmsdSuprCls(c,a,p),void 0!==n.rmsd_suprTmp.rot))){let e=n.rmsd_suprTmp.rot;if(null===e[0])continue;let i=n.rmsd_suprTmp.trans1,r=n.rmsd_suprTmp.trans2,a=n.rmsd_suprTmp.rmsd;if(aRealignment RMSD: "+a.toPrecision(4)+" Å

    "),l.cfg.bSidebyside||l.htmlCls.dialogCls.openDlg("dl_rmsd","Realignment RMSD"),n.q_rotation=[],n.q_trans_sub=[],n.t_trans_add=[],n.q_rotation.push({x1:e[0],y1:e[1],z1:e[2],x2:e[3],y2:e[4],z2:e[5],x3:e[6],y3:e[7],z3:e[8]}),n.q_trans_sub.push(i),n.t_trans_add.push({x:-r.x,y:-r.y,z:-r.z}),l.cfg.aligntool="vast";//!= 'tmalign'; let c=0,h="query",p=o.substr(0,o.indexOf("_")),m=!0;n.chainalignParserCls.transformStructure(p,c,h,m);let u="";for(let e=0,i=s.length;e8)return s;let g=[];g[0]=n[0]*r[0]+n[1]*r[1]+n[2]*r[2],g[1]=n[3]*r[0]+n[4]*r[1]+n[5]*r[2],g[2]=n[6]*r[0]+n[7]*r[1]+n[8]*r[2],g[0]-=n[0]*a[0]+n[1]*a[1]+n[2]*a[2],g[1]-=n[3]*a[0]+n[4]*a[1]+n[5]*a[2],g[2]-=n[6]*a[0]+n[7]*a[1]+n[8]*a[2];let f=0;return f=c[0]*g[0],f+=c[1]*g[1],f+=c[2]*g[2],f/=p*m,f<.866?s:(g[0]=l[0]*r[0]+l[1]*r[1]+l[2]*r[2],g[1]=l[3]*r[0]+l[4]*r[1]+l[5]*r[2],g[2]=l[6]*r[0]+l[7]*r[1]+l[8]*r[2],g[0]-=l[0]*a[0]+l[1]*a[1]+l[2]*a[2],g[1]-=l[3]*a[0]+l[4]*a[1]+l[5]*a[2],g[2]-=l[6]*a[0]+l[7]*a[1]+l[8]*a[2],f=c[0]*g[0],f+=c[1]*g[1],f+=c[2]*g[2],f/=p*m,f<.866?s:(u=0,u+=Math.pow(e.q_rotation.x1-t.q_rotation.x1,2),u+=Math.pow(e.q_rotation.y1-t.q_rotation.y1,2),u+=Math.pow(e.q_rotation.z1-t.q_rotation.z1,2),u+=Math.pow(e.q_rotation.x2-t.q_rotation.x2,2),u+=Math.pow(e.q_rotation.y2-t.q_rotation.y2,2),u+=Math.pow(e.q_rotation.z2-t.q_rotation.z2,2),u+=Math.pow(e.q_rotation.x3-t.q_rotation.x3,2),u+=Math.pow(e.q_rotation.y3-t.q_rotation.y3,2),u+=Math.pow(e.q_rotation.z3-t.q_rotation.z3,2),Math.sqrt(u)))}GetRotMatrix(e,t,s){this.icn3d.icn3dui;let i=[];return i&&(i[0]=e.q_rotation.x1/t,i[1]=e.q_rotation.y1/t,i[2]=e.q_rotation.z1/t,i[3]=e.q_rotation.x2/t,i[4]=e.q_rotation.y2/t,i[5]=e.q_rotation.z2/t,i[6]=e.q_rotation.x3/t,i[7]=e.q_rotation.y3/t,i[8]=e.q_rotation.z3/t,2!=s?(i[9]=e.t_trans_add.x/t,i[10]=e.t_trans_add.y/t,i[11]=e.t_trans_add.z/t,i[12]=-e.q_trans_sub.x/t,i[13]=-e.q_trans_sub.y/t,i[14]=-e.q_trans_sub.z/t):(i[9]=-e.q_trans_add.x/t,i[10]=-e.q_trans_add.y/t,i[11]=-e.q_trans_add.z/t,i[12]=0,i[13]=0,i[14]=0)),i}cbu_dist(e,t,s){return er&&(s.push(e[n].leaves),i.push(e[n].dist));return{clusters:s,scores:i}}}class ls{constructor(e){this.icn3d=e}async applyCommand(e){let t=this.icn3d,s=t.icn3dui;t.bAddCommands=!1;let i=e.split("|||")[0].split("%7C%7C%7C")[0].replace(/\s+/g," ").trim(),n=i.toLowerCase();if("share link"==n)await t.shareLinkCls.shareLink();else if("export state file"==n);else if(0==n.indexOf("export canvas"))setTimeout((async function(){let e=n.substr(13).trim();t.scaleFactor=""===e?1:parseInt(e);let s=""!==e;await t.shareLinkCls.shareLink(!0,s)}),500);else if("export interactions"==n)t.viewInterPairsCls.exportInteractions();else if("export stl file"==n)setTimeout((function(){t.export3DCls.exportStlFile("")}),500);else if("export vrml file"==n)setTimeout((function(){t.export3DCls.exportVrmlFile("")}),500);else if("export stl stabilizer file"==n)setTimeout((function(){t.threeDPrintCls.hideStabilizer(),t.threeDPrintCls.resetAfter3Dprint(),t.threeDPrintCls.addStabilizer(),t.export3DCls.exportStlFile("_stab")}),500);else if("export vrml stabilizer file"==n)setTimeout((function(){t.threeDPrintCls.hideStabilizer(),t.threeDPrintCls.resetAfter3Dprint(),t.threeDPrintCls.addStabilizer(),t.export3DCls.exportVrmlFile("_stab")}),500);else if("export pdb"==n)s.htmlCls.setHtmlCls.exportPdb();else if("export pdb missing atoms"==n)await t.scapCls.exportPdbProfix(!1);else if("export pdb hydrogen"==n)await t.scapCls.exportPdbProfix(!0);else if("export secondary structure"==n)s.htmlCls.setHtmlCls.exportSecondary();else if("select all"==n)t.selectionCls.selectAll();else if("show all"==n)t.selectionCls.showAll();else if("select complement"==n)t.resid2specCls.selectComplement();else if("set pk atom"==n)t.pk=1,t.opts.pk="atom";else if("set pk off"==n)t.pk=0,t.opts.pk="no",t.drawCls.draw(),t.hlObjectsCls.removeHlObjects();else if("set pk residue"==n)t.pk=2,t.opts.pk="residue";else if("set pk strand"==n)t.pk=3,t.opts.pk="strand";else if("set pk domain"==n)t.pk=4,t.opts.pk="domain";else if("set pk chain"==n)t.pk=5,t.opts.pk="chain";else if("set surface wireframe on"==n)t.opts.wireframe="yes",t.applyMapCls.applySurfaceOptions();else if("set surface wireframe off"==n)t.opts.wireframe="no",t.applyMapCls.applySurfaceOptions();else if("set map wireframe on"==n)t.opts.mapwireframe="yes",t.applyMapCls.applyMapOptions();else if("set map wireframe off"==n)t.opts.mapwireframe="no",t.applyMapCls.applyMapOptions();else if("set emmap wireframe on"==n)t.opts.emmapwireframe="yes",t.applyMapCls.applyEmmapOptions();else if("set emmap wireframe off"==n)t.opts.emmapwireframe="no",t.applyMapCls.applyEmmapOptions();else if("set surface neighbors on"==n)t.bConsiderNeighbors=!0,t.applyMapCls.applySurfaceOptions();else if("set surface neighbors off"==n)t.bConsiderNeighbors=!1,t.applyMapCls.applySurfaceOptions();else if("set axis on"==n)t.opts.axis="yes";else if("set pc1 axis"==n)t.pc1=!0,t.axesCls.setPc1Axes();else if("set axis off"==n)t.opts.axis="no",t.pc1=!1;else if("set fog on"==n)t.opts.fog="yes",t.fogCls.setFog(!0);else if("set fog off"==n)t.opts.fog="no",t.fogCls.setFog(!0);else if("set slab on"==n)t.opts.slab="yes";else if("set slab off"==n)t.opts.slab="no";else if("set assembly on"==n)t.bAssembly=!0;else if("set assembly off"==n)t.bAssembly=!1;else if("set chemicalbinding show"==n)t.setOptionCls.setOption("chemicalbinding","show");else if("set chemicalbinding hide"==n)t.setOptionCls.setOption("chemicalbinding","hide");else if("set hbonds off"==n)t.hBondCls.hideHbonds(),t.drawCls.draw();else if("set salt bridge off"==n)t.saltbridgeCls.hideSaltbridge(),t.drawCls.draw();else if("set contact off"==n)t.contactCls.hideContact(),t.drawCls.draw();else if("set halogen pi off"==n)t.piHalogenCls.hideHalogenPi(),t.drawCls.draw();else if("hydrogens"==n)t.showInterCls.showHydrogens(),t.drawCls.draw();else if("set hydrogens off"==n)t.showInterCls.hideHydrogens(),t.drawCls.draw();else if("close popup"==n)t.resizeCanvasCls.closeDialogs();else if("set stabilizer off"==n)t.threeDPrintCls.hideStabilizer(),t.drawCls.draw();else if("set disulfide bonds off"==n)t.opts.ssbonds="no",t.drawCls.draw();else if("set cross linkage off"==n)t.opts.clbonds="no",t.drawCls.draw();else if("set lines off"==n)t.labels.distance=[],t.lines.distance=[],t.drawCls.draw();else if("set labels off"==n){for(let e in t.labels)t.labels[e]=[];t.drawCls.draw()}else if("set mode all"==n)t.definedSetsCls.setModeAndDisplay("all");else if("set mode selection"==n)t.definedSetsCls.setModeAndDisplay("selection");else if("set view detailed view"==n)t.annotationCls.setAnnoViewAndDisplay("detailed view");else if("set view overview"==n)t.annotationCls.setAnnoViewAndDisplay("overview");else if("set annotation custom"==n)t.annotationCls.setAnnoTabCustom();else if("set annotation interaction"==n)t.annotationCls.setAnnoTabInteraction();else if("set annotation ptm"==n)await t.annotationCls.setAnnoTabPTM();else if("set annotation cdd"==n)t.annotationCls.setAnnoTabCdd();else if("set annotation site"==n)t.annotationCls.setAnnoTabSite();else if("set annotation ssbond"==n)t.annotationCls.setAnnoTabSsbond();else if("set annotation crosslink"==n)t.annotationCls.setAnnoTabCrosslink();else if("set annotation transmembrane"==n)await t.annotationCls.setAnnoTabTransmem();else if("highlight level up"==n)t.resid2specCls.switchHighlightLevelUp();else if("highlight level down"==n)t.resid2specCls.switchHighlightLevelDown();else if(0==n.indexOf("hide annotation")){let e=n.lastIndexOf(" "),s=n.substr(e+1);"all"==s?t.annotationCls.hideAnnoTabAll():"custom"==s?t.annotationCls.hideAnnoTabCustom():"clinvar"==s?t.annotationCls.hideAnnoTabClinvar():"snp"==s?t.annotationCls.hideAnnoTabSnp():"cdd"==s?t.annotationCls.hideAnnoTabCdd():"3ddomain"==s?t.annotationCls.hideAnnoTab3ddomain():"site"==s?t.annotationCls.hideAnnoTabSite():"ptm"==s?t.annotationCls.hideAnnoTabPTM():"interaction"==s?t.annotationCls.hideAnnoTabInteraction():"ssbond"==s?t.annotationCls.hideAnnoTabSsbond():"crosslink"==s?t.annotationCls.hideAnnoTabCrosslink():"transmembrane"==s&&t.annotationCls.hideAnnoTabTransmem()}else if("add residue labels"==n)t.residueLabelsCls.addResidueLabels(t.hAtoms),t.drawCls.draw();else if("add residue number labels"==n)t.residueLabelsCls.addResidueLabels(t.hAtoms,void 0,void 0,!0),t.drawCls.draw();else if("add atom labels"==n)t.residueLabelsCls.addAtomLabels(t.hAtoms),t.drawCls.draw();else if("add element labels"==n)t.residueLabelsCls.addAtomLabels(t.hAtoms,!0),t.drawCls.draw();else if("add chain labels"==n)t.analysisCls.addChainLabels(t.hAtoms),t.drawCls.draw();else if("add terminal labels"==n)t.analysisCls.addTerminiLabels(t.hAtoms),t.drawCls.draw();else if("rotate left"==n)t.bStopRotate=!1,t.ROT_DIR="left",t.resizeCanvasCls.rotStruc("left");else if("rotate right"==n)t.bStopRotate=!1,t.ROT_DIR="right",t.resizeCanvasCls.rotStruc("right");else if("rotate up"==n)t.bStopRotate=!1,t.ROT_DIR="up",t.resizeCanvasCls.rotStruc("up");else if("rotate down"==n)t.bStopRotate=!1,t.ROT_DIR="down",t.resizeCanvasCls.rotStruc("down");else if("rotate x"==n){let e=new THREE.Vector3(1,0,0),s=.5*Math.PI;t.transformCls.setRotation(e,s)}else if("rotate y"==n){let e=new THREE.Vector3(0,1,0),s=.5*Math.PI;t.transformCls.setRotation(e,s)}else if("rotate z"==n){let e=new THREE.Vector3(0,0,1),s=.5*Math.PI;t.transformCls.setRotation(e,s)}else if("reset"===n)t.selectionCls.resetAll();else if("reset orientation"===n)t.transformCls.resetOrientation(),t.drawCls.draw();else if("reset thickness"==n)t.threeDPrintCls.resetAfter3Dprint(),t.drawCls.draw();else if("clear selection"==n)t.hlObjectsCls.removeHlObjects(),t.hlUpdateCls.removeHl2D(),t.bShowHighlight=!1,t.bSelectResidue=!1;else if("zoom selection"==n)t.transformCls.zoominSelection(),t.drawCls.draw();else if("center selection"==n)t.applyCenterCls.centerSelection(),t.drawCls.draw();else if("show selection"==n)t.selectionCls.showSelection();else if("hide selection"==n)t.selectionCls.hideSelection();else if("output selection"==n)t.threeDPrintCls.outputSelection();else if("toggle selection"==n)t.selectionCls.toggleSelection();else if("toggle highlight"==n)t.hlUpdateCls.toggleHighlight();else if("stabilizer"==n)t.threeDPrintCls.addStabilizer(),t.threeDPrintCls.prepareFor3Dprint();else if("disulfide bonds"==n)t.showInterCls.showSsbonds();else if("cross linkage"==n)t.showInterCls.showClbonds();else if("back"==n)await t.resizeCanvasCls.back();else if("forward"==n)await t.resizeCanvasCls.forward();else if("clear all"==n)t.selectionCls.selectAll();else if("defined sets"==n)t.definedSetsCls.showSets();else if("delete selected sets"==n)t.definedSetsCls.deleteSelectedSets();else if("view interactions"==n)void 0===s.cfg.mmdbid&&void 0===s.cfg.gi||t.ParserUtilsCls.set2DDiagrams(t.inputid);else if("show annotations all chains"==n)t.annotationCls.showAnnoAllChains();else if("save color"==n)t.setOptionCls.saveColor();else if("apply saved color"==n)t.setOptionCls.applySavedColor();else if("save style"==n)t.setOptionCls.saveStyle();else if("apply saved style"==n)t.setOptionCls.applySavedStyle();else if("select main chains"==n)t.selectionCls.selectMainChains();else if("select side chains"==n)t.selectionCls.selectSideChains();else if("select main side chains"==n)t.selectionCls.selectMainSideChains();else if("realign"==n)t.realignParserCls.realign();else if(-1!=n.indexOf("realign predefined ")){let e="realign predefined ",n=i.substr(e.length),l=n.indexOf(" "),r=n.substr(0,l).split(",");s.cfg.resdef=n.substr(l+1).replace(/:/gi,";"),await t.realignParserCls.realignChainOnSeqAlign(void 0,r,!0,!0)}else if("area"==n)t.analysisCls.calculateArea();else if("table inter count only"==n)$(".icn3d-border").hide();else if("table inter details"==n)$(".icn3d-border").show();else if("setoption map nothing"==n)t.setOptionCls.setOption("map","nothing");else if("setoption emmap nothing"==n)t.setOptionCls.setOption("emmap","nothing");else if("setoption phimap nothing"==n)t.setOptionCls.setOption("phimap","nothing");else if("setoption phisurface nothing"==n)t.setOptionCls.setOption("phisurface","nothing");else if("clear symd symmetry"==n)t.symdArray=[];else if("show axis"==n)t.bAxisOnly=!0;else if(0==i.indexOf("define helix sets")){let e=i.split(" | ")[1].split(" ")[1];t.addTrackCls.defineSecondary(e,"helix")}else if(0==i.indexOf("define sheet sets")){let e=i.split(" | ")[1].split(" ")[1];t.addTrackCls.defineSecondary(e,"sheet")}else if(0==i.indexOf("define coil sets")){let e=i.split(" | ")[1].split(" ")[1];t.addTrackCls.defineSecondary(e,"coil")}else if(0==i.indexOf("select interaction")){let e=i.substr(i.lastIndexOf(" ")+1).split(",");if(null!==e){let s=e[0].split("_")[0];t.b2DShown||t.ParserUtilsCls.download2Ddgm(s.toUpperCase()),t.diagram2dCls.selectInteraction(e[0],e[1])}}else if(0==i.indexOf("select saved atoms")||0==i.indexOf("select sets")){i=i.replace(/aligned_protein/g,"protein_aligned");let e=i.split(" | "),s=e[0].replace(/,/g," or "),n=19;0==i.indexOf("select sets")&&(n=12);let l=s.substr(n),r=l;2==e.length&&(r=e[1].substr(5)),t.definedSetsCls.selectCombinedSets(l,r)}else if(-1!==i.indexOf("select chain")){let e=i.substr(i.lastIndexOf(" ")+1).split(",");for(let s=0,i=e.length;s6?e[6].substr(e[6].lastIndexOf(" ")+1):0,d=e.length>7?e[7].substr(e[7].lastIndexOf(" ")+1):1;t.analysisCls.addLine(parseFloat(s[1]),parseFloat(s[3]),parseFloat(s[5]),parseFloat(i[1]),parseFloat(i[3]),parseFloat(i[5]),l,r,o,parseFloat(a),parseFloat(d)),t.drawCls.draw()}else if(0==n.indexOf("add sphere"))this.addShape(n,"sphere");else if(0==n.indexOf("add cube"))this.addShape(n,"cube");else if(0==n.indexOf("clear shape"))t.shapeCmdHash={};else if(0==n.indexOf("clear line between sets"))t.lines.cylinder=[];else if(0==i.indexOf("add label")){let e,n,l,r,o,a,d,c=i.split(" | "),h=c[0].substr("add label".length+1),p=!1;for(let t=1,s=c.length;t=5&&(e=l[4].substr(5)),l.length>=6&&(s=l[5].substr(6)),l.length>=7&&(n=l[6].substr(4)),$("#"+t.pre+"anno_custom")[0].checked=!0,$("[id^="+t.pre+"custom]").show(),"0"==s&&(s=void 0),t.addTrackCls.checkGiSeq(r,o,a,e,s,n,0)}else if(0==n.indexOf("remove one stabilizer")){let e=n.split(" | ")[1].split(" "),s=[];s.push(parseInt(e[0])),s.push(parseInt(e[1])),t.threeDPrintCls.removeOneStabilizer(s),t.drawCls.draw()}else if(0==n.indexOf("add one stabilizer")){let e=n.split(" | ")[1].split(" ");void 0===t.pairArray&&(t.pairArray=[]),t.pairArray.push(parseInt(e[0])),t.pairArray.push(parseInt(e[1])),t.drawCls.draw()}else if(0==n.indexOf("select planes z-axis")){let e=n.split(" ");if(5==e.length){let s=parseFloat(e[3]),i=parseFloat(e[4]);t.selectionCls.selectBtwPlanes(s,i)}}else if(0==n.indexOf("adjust membrane z-axis")){let e=n.split(" ");if(5==e.length){let s=parseFloat(e[3]),i=parseFloat(e[4]);t.selectionCls.adjustMembrane(s,i)}}else if(0==n.indexOf("toggle membrane"))t.selectionCls.toggleMembrane();else if(0==i.indexOf("calc buried surface")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(" ");if(2==s.length){let e=s[0].split(","),i=s[1].split(",");t.analysisCls.calcBuriedSurface(e,i)}}}else if(0==i.indexOf("dist ")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(" ");if(2==s.length){let e=s[0].split(","),i=s[1].split(",");t.analysisCls.measureDistTwoSets(e,i)}}}else if(0==i.indexOf("disttable")){let e=i.split(" | ");if(2==e.length){let i=e[1].split(" ");if(2==i.length){let e=i[0].split(","),n=i[1].split(",");t.analysisCls.measureDistManySets(e,n),s.htmlCls.dialogCls.openDlg("dl_disttable","Distance among the sets")}}}else if(0==i.indexOf("display interaction 3d")||0==i.indexOf("view interaction pairs")||0==i.indexOf("save1 interaction pairs")||0==i.indexOf("save2 interaction pairs")||0==i.indexOf("line graph interaction pairs")||0==i.indexOf("scatterplot interaction pairs")){let e=i.split(" | ");if(e.length>=3){let s=e[1].split(" ");if(2==s.length){let n,l,r=s[0].split(","),o=s[1].split(","),a=-1!==e[2].indexOf("hbonds"),d=-1!==e[2].indexOf("salt bridge"),c=-1!==e[2].indexOf("interactions"),h=-1!==e[2].indexOf("halogen"),p=-1!==e[2].indexOf("pi-cation"),m=-1!==e[2].indexOf("pi-stacking");if(e.length>=4&&(n="true"==e[3]),e.length>=5){let s=e[4].split(" ");s.length>=4&&($("#"+t.pre+"hbondthreshold").val(s[1]),$("#"+t.pre+"saltbridgethreshold").val(s[2]),$("#"+t.pre+"contactthreshold").val(s[3]),7==s.length&&($("#"+t.pre+"halogenthreshold").val(s[4]),$("#"+t.pre+"picationthreshold").val(s[5]),$("#"+t.pre+"pistackingthreshold").val(s[6])))}0==i.indexOf("display interaction 3d")?l="3d":0==i.indexOf("view interaction pairs")?l="view":0==i.indexOf("save1 interaction pairs")?l="save1":0==i.indexOf("save2 interaction pairs")?l="save2":0==i.indexOf("line graph interaction pairs")?l="linegraph":0==i.indexOf("scatterplot interaction pairs")&&(l="scatterplot"),await t.viewInterPairsCls.viewInteractionPairs(r,o,n,l,a,d,c,h,p,m)}}}else if(0==i.indexOf("export pairs")){let e=i.split(" | ");if(3==e.length){let s=e[1].split(" ");if(2==s.length){let i=s[0].split(","),n=s[1].split(","),l=e[2].split(" ")[1];t.showInterCls.pickCustomSphere(l,i,n,t.bSphereCalc),t.bSphereCalc=!0;let r=t.viewInterPairsCls.exportSpherePairs(),o=t.inputid?t.inputid:"custom";t.saveFileCls.saveFile(o+"_sphere_pairs.html","html",r)}}}else if(0==n.indexOf("graph label")){let e=n.lastIndexOf(" "),t=n.substr(e+1);$("#"+s.svgid+"_label").val(t),$("#"+s.svgid+" text").removeClass(),$("#"+s.svgid+" text").addClass(t)}else if(0==n.indexOf("cartoon label")){let e=n.lastIndexOf(" "),t=n.substr(e+1);$("#"+s.svgid_ct+"_label").val(t),$("#"+s.svgid_ct+" text").removeClass(),$("#"+s.svgid_ct+" text").addClass(t)}else if(0==n.indexOf("line graph scale")){let e=n.lastIndexOf(" "),i=n.substr(e+1);$("#"+s.linegraphid+"_scale").val(i),$("#"+s.linegraphid).attr("width",(t.linegraphWidth*parseFloat(i)).toString()+"px")}else if(0==n.indexOf("scatterplot scale")){let e=n.lastIndexOf(" "),i=n.substr(e+1);$("#"+s.scatterplotid+"_scale").val(i),$("#"+s.scatterplotid).attr("width",(t.scatterplotWidth*parseFloat(i)).toString()+"px")}else if(0==n.indexOf("contactmap scale")){let e=n.lastIndexOf(" "),i=n.substr(e+1);$("#"+s.contactmapid+"_scale").val(i),$("#"+s.contactmapid).attr("width",(t.contactmapWidth*parseFloat(i)).toString()+"px")}else if(0==n.indexOf("alignerrormap scale")){let e=n.lastIndexOf(" "),i=n.substr(e+1);$("#"+s.alignerrormapid+"_scale").val(i),$("#"+s.alignerrormapid).attr("width",(t.alignerrormapWidth*parseFloat(i)).toString()+"px")}else if(0==n.indexOf("graph force")){let e=n.lastIndexOf(" ");s.htmlCls.force=parseInt(n.substr(e+1)),$("#"+s.svgid+"_force").val(s.htmlCls.force),t.getGraphCls.handleForce()}else if(0==n.indexOf("hide edges")){let e=n.lastIndexOf(" ");s.htmlCls.hideedges=parseInt(n.substr(e+1)),$("#"+s.svgid+"_hideedges").val(s.htmlCls.hideedges),s.htmlCls.hideedges?(s.htmlCls.contactInsideColor="FFF",s.htmlCls.hbondInsideColor="FFF",s.htmlCls.ionicInsideColor="FFF"):(s.htmlCls.contactInsideColor="DDD",s.htmlCls.hbondInsideColor="AFA",s.htmlCls.ionicInsideColor="8FF"),void 0!==t.graphStr&&t.bRender&&s.htmlCls.force&&t.drawGraphCls.drawGraph(t.graphStr,t.pre+"dl_graph")}else if(0==n.indexOf("reset interaction pairs"))t.viewInterPairsCls.resetInteractionPairs();else if(0==n.indexOf("side by side")){let e=n.split(" | ")[1],t="_blank";window.open(e,t)}else if(0==i.indexOf("your note")){let e=i.split(" | ");t.yournote=e[1],$("#"+t.pre+"yournote").val(t.yournote),s.cfg.shownote&&(document.title=t.yournote)}else if(0==n.indexOf("cross structure interaction"))t.crossstrucinter=parseInt(n.substr(n.lastIndexOf(" ")+1)),$("#"+t.pre+"crossstrucinter").val(t.crossstrucinter);else if("replay on"==n)await t.resizeCanvasCls.replayon();else if("replay off"==n)await t.resizeCanvasCls.replayoff();else if(0==n.indexOf("contact map")){let e=n.split(" | ");if(3===e.length){let s=parseFloat(e[1].split(" ")[1]),i=e[2].split(" ")[1];await t.contactMapCls.contactMap(s,i)}}else if(0==n.indexOf("pickatom")){let e=parseInt(n.substr(n.lastIndexOf(" ")+1));t.pAtom=t.atoms[e],t.pickingCls.showPicking(t.pAtom)}else if(0==i.indexOf("set color spectrum")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(","),i=!0;t.setColorCls.setColorAcrossSets(s,i)}}else if(0==i.indexOf("set residues color spectrum")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(","),i=!0;t.setColorCls.setColorBySets(s,i)}}else if(0==i.indexOf("set color rainbow")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(","),i=!1;t.setColorCls.setColorAcrossSets(s,i)}}else if(0==i.indexOf("set residues color rainbow")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(","),i=!1;t.setColorCls.setColorBySets(s,i)}}else if(0==i.indexOf("color")){let e=i.split(" | "),n=e[0].substr(e[0].indexOf(" ")+1);if(t.opts.color=n,"residue custom"==n&&2==e.length){t.customResidueColors=JSON.parse(e[1]);for(let e in t.customResidueColors)t.customResidueColors[e.toUpperCase()]=s.parasCls.thr("#"+t.customResidueColors[e])}else if("align custom"==n&&3==e.length){let s=e[1],i=e[2].split(", ");t.queryresi2score={},t.queryresi2score[s]={};for(let e=0,n=i.length;e=4?this.setQueryresi2score(e):"area"==n&&2==e.length&&(t.midpercent=e[1],$("#"+t.pre+"midpercent").val(t.midpercent));t.setColorCls.setColorByOptions(t.opts,t.hAtoms),t.hlUpdateCls.updateHlAll(),t.getGraphCls.updateGraphColor()}else if(0==i.indexOf("remove legend"))$("#"+s.pre+"legend").hide();else if(0==i.indexOf("custom tube")){let e=i.split(" | ");this.setQueryresi2score(e),t.setOptionCls.setStyle("proteins","custom tube")}else if(0==n.indexOf("style")){let e=n.substr(n.indexOf(" ")+1),s=e.substr(0,e.indexOf(" ")),i=e.substr(e.indexOf(" ")+1);t.setOptionCls.setStyle(s,i)}else if(0==n.indexOf("window")){let e=n.substr(n.indexOf(" ")+1);setTimeout((function(){"aligned sequences"==e?s.htmlCls.dialogCls.openDlg("dl_alignment","Select residues in aligned sequences"):"interaction table"==e?s.htmlCls.dialogCls.openDlg("dl_allinteraction","Show interactions"):"interaction graph"==e?s.htmlCls.dialogCls.openDlg("dl_linegraph","Show interactions between two lines of residue nodes"):"interaction scatterplot"==e?s.htmlCls.dialogCls.openDlg("dl_scatterplot","Show interactions as scatterplot"):"force-directed graph"==e&&s.htmlCls.dialogCls.openDlg("dl_graph","Force-directed graph")}),1e3)}else if(0==n.indexOf("set theme")){let e=n.substr(n.lastIndexOf(" ")+1);s.htmlCls.setMenuCls.setTheme(e)}else if(0==n.indexOf("set double color")){let e=n.substr(n.lastIndexOf(" ")+1);"on"==e?(t.bDoublecolor=!0,t.setOptionCls.setStyle("proteins","ribbon")):"off"==e&&(t.bDoublecolor=!1)}else if(0==n.indexOf("adjust dialog")){let e=n.substr(n.lastIndexOf(" ")+1);t.scapCls.adjust2DWidth(e)}else if(0==n.indexOf("glycans cartoon")){let e=n.substr(n.lastIndexOf(" ")+1);t.bGlycansCartoon="yes"==e}else if(0==n.indexOf("save html")){let e=n.substr(n.lastIndexOf(" ")+1);s.htmlCls.eventsCls.saveHtml(e)}else if(0==n.indexOf("resdef"))s.cfg.resdef=n.substr(n.indexOf(" ")+1);else if(0==n.indexOf("vast_search_chainid")){t.chainidArray=i.substr(i.indexOf(" ")+1).split(",");let e=!0,s=!0;await t.realignParserCls.realignChainOnSeqAlign(void 0,t.chainidArray,e,s)}else if(0==n.indexOf("ig refnum off"))await t.refnumCls.hideIgRefNum();else if(0==n.indexOf("custom refnum")){let e=i.split(" | ")[1].replace(/\\n/g,"\n");await t.refnumCls.parseCustomRefFile(e)}else if(-1!==n.indexOf("select displayed set"))t.hAtoms=s.hashUtilsCls.cloneHash(t.viewSelectionAtoms),t.hlUpdateCls.updateHlAll();else if(-1!==n.indexOf("select prop")){let e,s,n=i.split(" | "),l=n[0].substr("select prop".length+1);if(2==n.length){let t=n[1].split("_");e=t[0],s=t[1]}t.resid2specCls.selectProperty(l,e,s)}else if(-1!==n.indexOf("select each residue"))t.selectionCls.saveEachResiInSel();else if(0==n.indexOf("select")&&-1!==n.indexOf("name")){let e=i.split(" | "),s="",n="",l="";for(let t=0,i=e.length;t1&&(n=e[1].substr(e[1].indexOf(" ")+1)),e.length>2&&(l=e[2].substr(e[2].indexOf(" ")+1)),-1!==s.indexOf(" or ")?await t.selByCommCls.selectByCommand(s,n,l):await t.selByCommCls.selectBySpec(s,n,l)}s.htmlCls.clickMenuCls.setLogCmd(i,!1),t.bAddCommands=!0}setStrengthPara(e){let t=this.icn3d;if(t.icn3dui,e.length>=5){let s=e[4].split(" ");s.length>=4&&($("#"+t.pre+"hbondthreshold").val(s[1]),$("#"+t.pre+"saltbridgethreshold").val(s[2]),$("#"+t.pre+"contactthreshold").val(s[3]),s.length>=7&&($("#"+t.pre+"halogenthreshold").val(s[4]),$("#"+t.pre+"picationthreshold").val(s[5]),$("#"+t.pre+"pistackingthreshold").val(s[6])))}if(6==e.length){let s=e[5].split(" ");s.length>=6&&($("#"+t.pre+"dist_ss").val(s[0]),$("#"+t.pre+"dist_coil").val(s[1]),$("#"+t.pre+"dist_hbond").val(s[2]),$("#"+t.pre+"dist_inter").val(s[3]),$("#"+t.pre+"dist_ssbond").val(s[4]),$("#"+t.pre+"dist_ionic").val(s[5]),9==s.length&&($("#"+t.pre+"dist_halogen").val(s[6]),$("#"+t.pre+"dist_pication").val(s[7]),$("#"+t.pre+"dist_pistacking").val(s[8])))}}getThresholdNameArrays(e){this.icn3d.icn3dui.htmlCls.clickMenuCls.SetChainsAdvancedMenu();let t,s=e.split(" | "),i=parseFloat(s[0].substr(s[0].lastIndexOf(" ")+1)),n=[],l=[];if(s.length>=2&&s[1].length>4){let e=s[1].split(" ");e.length>1&&(l=e[1].split(",")),e.length>2&&(n=e[2].split(","))}else l=["selected"],n=["non-selected"];return 3==s.length&&(t="true"==s[2]),{threshold:i,nameArray2:l,nameArray:n,bHbondCalc:t}}setQueryresi2score(e){let t=this.icn3d,s=t.icn3dui,i=e[1],n=e[2].split(" ")[1].split("_"),l=e[3];void 0===t.queryresi2score&&(t.queryresi2score={}),t.queryresi2score[i]={};for(let e=parseInt(n[0]),s=0;e<=parseInt(n[1]);++e,++s)"_"!=l[s]&&(t.queryresi2score[i][e]=11.11111111111111*parseInt(l[s]));if(e.length>4){let i=e[4].split(" ");t.startColor=i[1],t.midColor=i[2],t.endColor=i[3];let n=s.htmlCls.clickMenuCls.setLegendHtml();$("#"+s.pre+"dl_legend").html(n),s.htmlCls.dialogCls.openDlg("dl_legend","Color Range")}}addShape(e,t){let s=this.icn3d,i=s.icn3dui;s.shapeCmdHash[e]=1;let n=e.split(" | "),l=n[1].split(" "),r=n[2].substr(n[2].lastIndexOf(" ")+1),o=n[3].substr(n[3].lastIndexOf(" ")+1),a=n[4].substr(n[4].lastIndexOf(" ")+1);r="#"+r.replace(/\#/g,"");let d=i.parasCls.thr(r),c=new THREE.Vector3(parseFloat(l[1]),parseFloat(l[3]),parseFloat(l[5]));"sphere"==t?s.sphereCls.createSphereBase(c,d,parseFloat(a),void 0,void 0,void 0,parseFloat(o)):s.boxCls.createBox_base(c,parseFloat(a),d,void 0,void 0,void 0,parseFloat(o))}getMenuFromCmd(e){this.icn3d.icn3dui;let t="Windows > View Sequences & Annotations",s="Analysis > H-Bonds & Interactions",i=s+" > 2D Graph(Force-Directed)",n="View > Rotate > Auto Rotation > Rotate ",l="View > Rotate > Rotate 90 deg > ",r="Select > Select on 3D > ",o="Analysis > Label > ",a="File > 3D Printing > ";return 0==(e=e.trim()).indexOf("load")?"File > Retrieve by ID, Align":0==e.indexOf("set map")&&-1==e.indexOf("set map wireframe")?"Style > Electron Density":0==e.indexOf("set emmap")&&-1==e.indexOf("set emmap wireframe")?"Style > EM Density Map":0==e.indexOf("set phi")?"Analysis > Load Potential > URL(CORS) Phi/Cube":0==e.indexOf("set delphi")?"Analysis > DelPhi Potential":0==e.indexOf("setoption map")?"Style > Remove Map":0==e.indexOf("setoption emmap")?"Style > Remove EM Map":0==e.indexOf("view annotations")?t:0==e.indexOf("set annotation all")?t+': "All" checkbox':0==e.indexOf("set annotation clinvar")?t+': "ClinVar" checkbox':0==e.indexOf("set annotation snp")?t+': "SNP" checkbox':0==e.indexOf("set annotation 3ddomain")?t+': "3D Domains" checkbox':0==e.indexOf("view interactions")?"Windows > View 2D Diagram":0==e.indexOf("symmetry")?"Analysis > Symmetry":0==e.indexOf("realign on seq align")?"File > Realign Selection > on Sequence Alignment":0==e.indexOf("realign")?"File > Realign Selection > Residue by Residue":0==e.indexOf("graph interaction pairs")?s+" > 2D Graph(Force-Directed)":0==e.indexOf("export canvas")?"File > Save File > iCn3D PNG Image":"export stl file"==e?a+"STL":"export vrml file"==e?a+"VRML(Color)":"export stl stabilizer file"==e?a+"STL W/ Stabilizers":"export vrml stabilizer file"==e?a+"VRML(Color, W/ Stabilizers)":"select all"==e?'Select > All; or Toggle to "All"(next to "Help")':"show all"==e?"View > View Full Structure":"select complement"==e?"Select > Inverse":"set pk atom"==e?r+"Atom":"set pk residue"==e?r+"Residue":"set pk strand"==e?r+"Strand/Helix":"set pk domain"==e?r+"3D Domain":"set pk chain"==e?r+"Chain":"set surface wireframe on"==e?"Style > Surface Wireframe > Yes":"set surface wireframe off"==e?"Style > Surface Wireframe > No":"set map wireframe on"==e?"Style > Map Wireframe > Yes":"set map wireframe off"==e?"Style > Map Wireframe > No":"set emmap wireframe on"==e?"Style > EM Map Wireframe > Yes":"set emmap wireframe off"==e?"Style > EM Map Wireframe > No":"set surface neighbors on"==e?"Style > Surface Type > ... with Context":"set axis on"==e?"View > XYZ-axes > Show":"set axis off"==e?"View > XYZ-axes > Hide":"set fog on"==e?"View > Fog for Selection > On":"set fog off"==e?"View > Fog for Selection > Off":"set slab on"==e?"View > Slab for Selection > On":"set slab off"==e?"View > Slab for Selection > Off":"set assembly on"==e?"Analysis > Assembly > Biological Assembly":"set assembly off"==e?"Analysis > Assembly > Asymmetric Unit":"set chemicalbinding show"==e?"Analysis > Chem. Binding > Show":"set chemicalbinding hide"==e?"Analysis > Chem. Binding > Hide":"set hbonds off"==e||"set salt bridge off"==e||"set contact off"==e||"set halogen pi off"==e?s+" > Reset":"hydrogens"==e?"Style > Hydrogens > Show":"set hydrogens off"==e?"Style > Hydrogens > Hide":"set stabilizer off"==e?"File > 3D Printing > Remove All Stabilizers":"set disulfide bonds off"==e?"Analysis > Disulfide Bonds > Hide":"set cross linkage off"==e?"Analysis > Cross-Linkages > Hide":"set lines off"==e?"Analysis > Distance > Hide":"set labels off"==e?"Analysis > Label > Remove":"set mode all"==e?'Toggle to "All"(next to "Help")':"set mode selection"==e?'Toggle to "Selection"(next to "Help")':"set view detailed view"==e?t+': "Details" tab':"set view overview"==e?t+': "Summary" tab':"set annotation custom"==e?t+': "Custom" checkbox':"set annotation interaction"==e?t+': "Interactions" checkbox':"set annotation ptm"==e?t+': "PTM" checkbox':"set annotation cdd"==e?t+': "Conserved Domains" checkbox':"set annotation site"==e?t+': "Functional Sites" checkbox':"set annotation ssbond"==e?t+': "Disulfide Bonds" checkbox':"set annotation crosslink"==e?t+': "Cross-Linkages" checkbox':"set annotation transmembrane"==e?t+': "Transmembrane" checkbox':"highlight level up"==e?"Keyboard Arrow Up":"highlight level down"==e?"Keyboard Arrow Down":0==e.indexOf("hide annotation")?t+": checkboxes off":"add residue labels"==e?o+"per Residue":"add residue number labels"==e?o+"per Residue & Number":"add atom labels"==e?o+"per Atom":"add chain labels"==e?o+"per Chain":"add terminal labels"==e?o+"N- & C- Termini":"rotate left"==e?n+"Left; or Key l":"rotate right"==e?n+"Right; or Key j":"rotate up"==e?n+"Up; or Key i":"rotate down"==e?n+"Down; or Key m":"rotate x"==e?l+"X-axis":"rotate y"==e?l+"Y-axis":"rotate z"==e?l+"Z-axis":"reset"==e?"View > Reset > All":"reset orientation"==e?"View > Reset > Orientation":"clear selection"==e?"Select > Clear Selection":"zoom selection"==e?"Select > Zoom in Selection":"center selection"==e?"Select > Center Selection":"show selection"==e?"Select > View Only Selection":"hide selection"==e?"Select > Hide Selection":"output selection"==e?"Select > Clear Selection":"toggle highlight"==e?"Select > Toggle Highlight":"stabilizer"==e?"File > 3D Printing > Add all Stabilizers":"disulfide bonds"==e?"Analysis > Disulfide Bonds > Show":"cross linkage"==e?"Analysis > Cross-Linkages > Show":"back"==e?"View > Undo":"forward"==e?"View > Redo":"clear all"==e?"Select > Clear Selection":"defined sets"==e?"Windows > Defined Sets":"delete selected sets"==e?'Windows > Defined Sets: "Delete Selected Sets" button':"view interactions"==e?"Windows > View Interactions":"show annotations all chains"==e?t+': "Show All Chains" button':"save color"==e?"Color > Save Color":"apply saved color"==e?"Color > Apply Saved Color":"save style"==e?"Style > Save Style":"apply saved style"==e?"Style > Apply Saved Style":"select main chains"==e?"Select > Main Chains":"select side chains"==e?"Select > Side Chains":"select main side chains"==e?"Select > Main & Side Chains":"area"==e?"View > Surface Area":"table inter count only"==e?s+': "Set 1" button: "Show Count Only" button':"table inter details"==e?s+': "Set 1" button: "Show Details" button':0==e.indexOf("define helix sets")?t+': "Helix Sets" button':0==e.indexOf("define sheet sets")?t+': "Sheet Sets" button':0==e.indexOf("define coil sets")?t+': "Coil Sets" button':0==e.indexOf("select interaction")?"Windows > View 2D Diagram: click on edges":0==e.indexOf("select saved atoms")||0==e.indexOf("select sets")?"Windows > Defined Sets: select in menu":-1!==e.indexOf("select chain")?t+": click on chain names":-1!==e.indexOf("select alignChain")?"Windows > View Aligned Sequences: click on chain names":0==e.indexOf("select zone cutoff")?"Select > by Distance":0==e.indexOf("set surface opacity")?"Style > Surface Opacity":0==e.indexOf("set label scale")?"View > Label Scale":0==e.indexOf("set surface")?"Style > Surface Type":0==e.indexOf("set camera")?"View > Camera":0==e.indexOf("set background")?"Style > Background":0==e.indexOf("set thickness")?"File > 3D Printing > Set Thickness":0==e.indexOf("set highlight color")?"Select > Highlight Color":0==e.indexOf("set highlight style")?"Select > Highlight Style":0==e.indexOf("add line")||0==e.indexOf("add label")?"Analysis > Distance > between Two Atoms":0==e.indexOf("dist")?"Analysis > Distance > between Two Sets":0==e.indexOf("msa")?t+': "Add Track" button: "FASTA Alignment" button':0==e.indexOf("add track")?t+': "Add Track" button':0==e.indexOf("remove one stabilizer")?"File > 3D Printing > Remove One Stablizer":0==e.indexOf("add one stabilizer")?"File > 3D Printing > Add One Stablizer":0==e.indexOf("select planes z-axis")?"View > Select between Two X-Y Planes":0==e.indexOf("adjust membrane z-axis")?"View > Adjust Membrane":0==e.indexOf("toggle membrane")?"View > Toggle Membrane":0==e.indexOf("calc buried surface")?s+': "Buried Surface Area" button':0==e.indexOf("display interaction 3d")?s+': "3D Display Interactions" button':0==e.indexOf("view interaction pairs")?s+': "Highlight Interactions in Table" button':0==e.indexOf("save1 interaction pairs")?s+': "Set 1" button':0==e.indexOf("save2 interaction pairs")?s+': "Set 2" button':0==e.indexOf("line graph interaction pairs")?s+': "2D Interaction Network" button':0==e.indexOf("scatterplot interaction pairs")?s+': "2D Interaction Map" button':0==e.indexOf("graph label")?i+': "Label Size" menu':0==e.indexOf("graph force")?i+': "Force on Nodes" menu':0==e.indexOf("hide edges")?i+': "Internal Edges" menu':0==e.indexOf("reset interaction pairs")?s+" > Reset":0==e.indexOf("side by side")?"View > Side by Side":0==e.indexOf("your note")?"Windows > Your Notes / Window Title":0==e.indexOf("pickatom")?"Hold Alt key and click on 3D structure":0==e.indexOf("color")?"Color menu":0==e.indexOf("custom tube")?t+': "Custom Color/Tube" button: "Custom Tube" button':0==e.indexOf("style")?"Style menu":-1!==e.indexOf("select displayed set")?"Select > Displayed Set":-1!==e.indexOf("select prop")?"Select > by Property":0==e.indexOf("select")&&-1!==e.indexOf("name")?t+": drag on residues to select":-1!==e.indexOf("select $")||-1!==e.indexOf("select .")||-1!==e.indexOf("select :")||-1!==e.indexOf("select @")?"Select > Advanced; or other selection":-1!==e.indexOf("replay on")?"File > Replay Each Step > On":-1!==e.indexOf("replay off")?"File > Replay Each Step > Off":-1!==e.indexOf("set theme")?"Style > Theme Color":-1!==e.indexOf("set double color")?"Style > Two-color Helix":""}}class rs{constructor(e){this.icn3d=e}setProtNuclLigInMenu(){let e=this.icn3d;if(e.icn3dui,Object.keys(e.proteins).length>0&&(e.defNames2Residues.proteins=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.proteins)),e.defNames2Descr.proteins="proteins",e.defNames2Command.proteins="select :proteins"),Object.keys(e.nucleotides).length>0&&(e.defNames2Residues.nucleotides=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.nucleotides)),e.defNames2Descr.nucleotides="nucleotides",e.defNames2Command.nucleotides="select :nucleotides"),Object.keys(e.chemicals).length>0)if(e.bOpm){let t={},s={};for(let i in e.chemicals){let n=e.atoms[i],l=n.structure+"_"+n.chain+"_"+n.resi;"DUM"===n.resn?s[l]=1:t[l]=1}Object.keys(t).length>0&&(e.defNames2Residues.chemicals=Object.keys(t),e.defNames2Descr.chemicals="chemicals",e.defNames2Command.chemicals="select :chemicals"),Object.keys(s).length>0&&(e.defNames2Residues.membrane=Object.keys(s),e.defNames2Descr.membrane="membrane",e.defNames2Command.membrane="select :membrane")}else e.defNames2Residues.chemicals=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.chemicals)),e.defNames2Descr.chemicals="chemicals",e.defNames2Command.chemicals="select :chemicals";Object.keys(e.ions).length>0&&(e.defNames2Residues.ions=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.ions)),e.defNames2Descr.ions="ions",e.defNames2Command.ions="select :ions"),Object.keys(e.water).length>0&&(e.defNames2Residues.water=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.water)),e.defNames2Descr.water="water",e.defNames2Command.water="select :water"),this.setTransmemInMenu(e.halfBilayerSize,-e.halfBilayerSize)}setPredefinedInMenu(){let e=this.icn3d,t=e.icn3dui;if(this.setChainsInMenu(),this.setProtNuclLigInMenu(),void 0!==t.cfg.mmdbid||void 0!==t.cfg.gi||void 0!==t.cfg.chainalign||void 0!==t.cfg.mmdbafid)for(let t in e.tddomains)e.selectionCls.selectResidueList(e.tddomains[t],t,t,!1,!1);if((void 0!==t.cfg.align||void 0!==t.cfg.chainalign&&2==e.chainidArray.length)&&e.bFullUi){e.selectionCls.selectResidueList(e.consHash1,e.conservedName1,e.conservedName1,!1,!1),e.selectionCls.selectResidueList(e.consHash2,e.conservedName2,e.conservedName2,!1,!1),e.selectionCls.selectResidueList(e.nconsHash1,e.nonConservedName1,e.nonConservedName1,!1,!1),e.selectionCls.selectResidueList(e.nconsHash2,e.nonConservedName2,e.nonConservedName2,!1,!1),e.selectionCls.selectResidueList(e.nalignHash1,e.notAlignedName1,e.notAlignedName1,!1,!1),e.selectionCls.selectResidueList(e.nalignHash2,e.notAlignedName2,e.notAlignedName2,!1,!1);let s={};for(let i in e.alnChains)s=t.hashUtilsCls.unionHash(s,e.alnChains[i]);let i=e.firstAtomObjCls.getResiduesFromAtoms(s),n="protein_aligned",l="aligned protein and nucleotides",r="select "+e.resid2specCls.residueids2spec(Object.keys(i));e.selectionCls.addCustomSelection(Object.keys(i),n,l,r,!0)}}setAtomMenu(e){let t=this.icn3d;t.icn3dui;let s="",i=void 0!==t.defNames2Residues?Object.keys(t.defNames2Residues):[],n=void 0!==t.defNames2Atoms?Object.keys(t.defNames2Atoms):[],l=i.concat(n).sort(),r=[];l.forEach((e=>{-1===$.inArray(e,r)&&r.push(e)}));for(let i=0,n=r.length;i0&&(n=t.atoms[e[0]])}else if(void 0!==t.defNames2Residues&&t.defNames2Residues.hasOwnProperty(o)){let e=t.defNames2Residues[o];e.length>0&&(l=t.residues[e[0]],l&&(n=t.atoms[Object.keys(l)[0]]))}let a=void 0===n||void 0===n.color||"FFFFFF"===n.color.getHexString().toUpperCase()?"DDDDDD":n.color.getHexString(),d=void 0!==n&&void 0!==n.color?a:"000000";-1!=e.indexOf(o)?s+="":s+=""}return s}setChainsInMenu(){let e=this.icn3d;e.icn3dui;for(let t in e.chains)if(e.chainsSeq[t]&&e.chainsSeq[t].length>1){e.defNames2Residues[t]=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.chains[t])),e.defNames2Descr[t]=t;let s=t.indexOf("_"),i=t.substr(0,s),n=t.substr(s+1);e.defNames2Command[t]="select $"+i+"."+n}if(1==Object.keys(e.structures)){let t=Object.keys(e.structures)[0];e.defNames2Residues[t]=Object.keys(e.residues),e.defNames2Descr[t]=t,e.defNames2Command[t]="select $"+t}else{let t=Object.keys(e.residues),s={};for(let e=0,i=t.length;ee?l[a]=1:o.coord.z0&&(i.defNames2Residues["transmembrane"+o]=Object.keys(n),i.defNames2Descr["transmembrane"+o]="transmembrane"+o,i.defNames2Command["transmembrane"+o]="select :transmembrane"+o),Object.keys(l).length>0&&(i.defNames2Residues["extracellular"+o]=Object.keys(l),i.defNames2Descr["extracellular"+o]="extracellular"+o,i.defNames2Command["extracellular"+o]="select :extracellular"+o),Object.keys(r).length>0&&(i.defNames2Residues["intracellular"+o]=Object.keys(r),i.defNames2Descr["intracellular"+o]="intracellular"+o,i.defNames2Command["intracellular"+o]="select :intracellular"+o)}}showSets(){let e=this.icn3d,t=e.icn3dui;t.bNode||(t.htmlCls.dialogCls.openDlg("dl_definedsets","Select sets"),$("#"+e.pre+"dl_setsmenu").show(),$("#"+e.pre+"dl_setoperations").show(),$("#"+e.pre+"dl_command").hide(),$("#"+e.pre+"atomsCustom").resizable());let s=t.hashUtilsCls.cloneHash(e.hAtoms),i=t.hashUtilsCls.cloneHash(e.dAtoms);void 0!==e.bSetChainsAdvancedMenu&&e.bSetChainsAdvancedMenu&&!e.bResetSets||(this.setPredefinedInMenu(),e.bSetChainsAdvancedMenu=!0),e.hAtoms=t.hashUtilsCls.cloneHash(s),e.dAtoms=t.hashUtilsCls.cloneHash(i),e.hlUpdateCls.updateHlMenus()}clickCustomAtoms(){let e=this.icn3d,t=e.icn3dui,s=this;$("#"+e.pre+"atomsCustom").change((function(e){let i=s.icn3d,n=$(this).val();if(i.nameArray=n,null!==n){let e=!1;s.changeCustomAtoms(n,e),t.htmlCls.clickMenuCls.setLogCmd("select sets "+n.join(" "+i.setOperation+" "),!0),i.bSelectResidue=!1}})),t.myEventCls.onIds("#"+e.pre+"atomsCustom","focus",(function(e){let i=s.icn3d;t.utilsCls.isMobile()&&$("#"+i.pre+"atomsCustom").val("")}))}deleteSelectedSets(){let e=this.icn3d;e.icn3dui;let t=$("#"+e.pre+"atomsCustom").val();for(let s=0;s0)for(let n=0,l=t.defNames2Residues[e].length;n0)for(let s=0,n=t.defNames2Atoms[e].length;s0&&(n[0]=i.commands[0]);let l=e.trim().split("\n");i.commands=l;let r=l[0].indexOf("command=");if(t&&-1!=r){let e=l[0].substr(0,r-1);i.commands.splice(0,1,e)}i.STATENUMBER=i.commands.length,i.commands=n.concat(i.commands),i.STATENUMBER=i.commands.length,i.CURRENTNUMBER=0,i.bReplay?await this.replayFirstStep(i.CURRENTNUMBER):await this.execCommands(i.CURRENTNUMBER,i.STATENUMBER-1,i.STATENUMBER,s)}async execCommands(e,t,s,i){let n=this.icn3d;n.icn3dui,n.bRender=!1,i||n.reinitAfterLoad(),await this.execCommandsBase(e,t,s)}getNameArray(e){let t=this.icn3d;t.icn3dui;let s=e.split(" | "),i=[];return 2==s.length&&(i=s[1].split(","),t.hAtoms=t.definedSetsCls.getAtomsFromNameArray(i)),i}async execCommandsBase(e,t,s,i){let n,l=this.icn3d,r=l.icn3dui,o=this;for(n=e;n<=t;++n){let i=n===s-1;if(!l.commands[n].trim())continue;if(!l.atoms&&-1==l.commands[n].indexOf("load"))continue;let a=l.commands[n].split("|||"),d=a[0].trim();if(-1!==d.indexOf("load")){if(0===t&&e===t)return void(l.bNotLoadStructure?(l.hAtoms=r.hashUtilsCls.cloneHash(l.atoms),1===l.commands.length&&(l.bAddCommands=!0),i&&this.renderFinalStep(s)):(await o.applyCommandLoad(l.commands[n]),1===l.commands.length&&(l.bAddCommands=!0),i&&o.renderFinalStep(s)));l.bNotLoadStructure?(l.hAtoms=r.hashUtilsCls.cloneHash(l.atoms),l.backForward&&this.renderFinalStep(1)):(await o.applyCommandLoad(l.commands[n]),l.backForward&&o.renderFinalStep(1))}else if(0==d.indexOf("set map")&&-1==d.indexOf("set map wireframe")){let e=a[0].trim().split(" | ")[0].substr(8).split(" ");3==e.length&&"sigma"==e[1]&&(e[2],e[0],await o.applyCommandMap(a[0].trim()))}else if(0==d.indexOf("set emmap")&&-1==d.indexOf("set emmap wireframe")){let e=a[0].trim().substr(10).split(" ");2==e.length&&"percentage"==e[0]&&(e[1],await o.applyCommandEmmap(a[0].trim()))}else if(0==d.indexOf("set phi"))await l.delphiCls.applyCommandPhi(a[0].trim());else if(0==d.indexOf("set delphi"))await l.delphiCls.applyCommandDelphi(a[0].trim());else if(0==d.indexOf("view annotations"))Object.keys(l.proteins).length>0&&await o.applyCommandAnnotationsAndCddSite(a[0].trim());else if(0==d.indexOf("set annotation clinvar"))Object.keys(l.proteins).length>0&&await o.applyCommandClinvar(a[0].trim());else if(0==d.indexOf("set annotation snp"))Object.keys(l.proteins).length>0&&await o.applyCommandSnp(a[0].trim());else if(0==d.indexOf("set annotation ptm"))Object.keys(l.proteins).length>0&&await o.applyCommandPTM(a[0].trim());else if(0==d.indexOf("ig refnum on"))await l.refnumCls.showIgRefNum();else if(0==d.indexOf("set annotation 3ddomain"))Object.keys(l.proteins).length>0&&o.applyCommand3ddomain(a[0].trim());else if(0==d.indexOf("set annotation all"))Object.keys(l.proteins).length>0&&(await o.applyCommandClinvar(a[0].trim()),await o.applyCommandSnp(a[0].trim()),o.applyCommand3ddomain(a[0].trim())),await l.annotationCls.setAnnoTabAll();else if(0==d.indexOf("view interactions")&&void 0!==r.cfg.align)await o.applyCommandViewinteraction(a[0].trim());else if(0==d.indexOf("symmetry")){l.bAxisOnly=!1;let e=d.substr(d.indexOf(" ")+1);l.symmetrytitle="none"===e?void 0:e,"none"!==e&&await l.symdCls.retrieveSymmetry(Object.keys(l.structures)[0]),l.drawCls.draw()}else if(0==d.indexOf("symd symmetry"))l.bAxisOnly=!1,await l.symdCls.applyCommandSymd(d),l.drawCls.draw();else if(0==d.indexOf("scap"))await l.scapCls.applyCommandScap(d);else if(0==d.indexOf("realign on seq align"))this.getNameArray(d),await o.applyCommandRealign(d);else if(0==d.indexOf("realign on structure align msa")){let e=this.getNameArray(d);r.cfg.aligntool="vast",await l.realignParserCls.realignOnStructAlignMsa(e)}else if(0==d.indexOf("realign on structure align"))this.getNameArray(d),r.cfg.aligntool="vast",await l.realignParserCls.realignOnStructAlign();else if(0==d.indexOf("realign on tmalign msa")){let e=this.getNameArray(d);r.cfg.aligntool="tmalign",await l.realignParserCls.realignOnStructAlignMsa(e)}else if(0==d.indexOf("realign on tmalign"))this.getNameArray(d),r.cfg.aligntool="tmalign",await l.realignParserCls.realignOnStructAlign();else if(0==d.indexOf("realign on vastplus"))o.getHAtoms(l.commands[n]),await l.vastplusCls.realignOnVastplus();else if(0==d.indexOf("graph interaction pairs"))await o.applyCommandGraphinteraction(d);else if(0==d.indexOf("cartoon 2d domain"))await o.applyCommandCartoon2d(d);else if(0==d.indexOf("set half pae map"))await o.applyCommandAfmap(d);else if(0==d.indexOf("set full pae map"))await o.applyCommandAfmap(d,!0);else if(0==d.indexOf("export pqr"))await r.htmlCls.setHtmlCls.exportPqr();else if(0==d.indexOf("cartoon 2d chain")||0==d.indexOf("cartoon 2d secondary")){let e=d.lastIndexOf(" "),t=d.substr(e+1);await l.cartoon2dCls.draw2Dcartoon(t)}else await l.applyCommandCls.applyCommand(l.commands[n])}(n===s||i)&&this.renderFinalStep(n)}pressCommandtext(){let e=this.icn3d,t=e.icn3dui,s=this;$("#"+e.pre+"logtext").keypress((async function(e){let i=s.icn3d;if(i.bAddLogs=!1,13==(e.keyCode?e.keyCode:e.which)){e.preventDefault();let n=$(this).val();i.bRender=!0;let l=n.split("\n"),r=i.logs.length;for(let e=r,n=l.length;e "+i.logs.join("\n> ")+"\n> ").scrollTop($("#"+i.pre+"logtext")[0].scrollHeight)}i.bAddLogs=!0}))}async applyCommandLoad(e){let t=this.icn3d,s=t.icn3dui;t.bAddCommands=!1;let i=e.split("|||")[0].replace(/\s\s/g," ").trim();if(-1!==i.indexOf("load")){let e=i.split(" | "),n=e[0];if(e.length>1){let t=e[e.length-1].indexOf(" ");s.cfg.inpara=e[e.length-1].substr(t+1),"undefined"===s.cfg.inpara&&(s.cfg.inpara="")}let l=n.substr(n.lastIndexOf(" ")+1);if(t.structures.hasOwnProperty(l))return;if(t.inputid=l,-1!==i.indexOf("load mmtf"))s.cfg.mmtfid=l,await t.mmtfParserCls.downloadMmtf(l);else if(-1!==i.indexOf("load pdb"))s.cfg.pdbid=l,await t.pdbParserCls.downloadPdb(l);else if(-1!==i.indexOf("load af"))s.cfg.afid=l,await t.pdbParserCls.downloadPdb(l,!0);else if(-1!==i.indexOf("load opm"))s.cfg.opmid=l,await t.opmParserCls.downloadOpm(l);else if(-1!==i.indexOf("load mmcif"))s.cfg.mmcifid=l,await t.mmcifParserCls.downloadMmcif(l);else if(-1!==i.indexOf("load mmdb ")||-1!==i.indexOf("load mmdb1 "))s.cfg.mmdbid=l,s.cfg.bu=1,await t.mmdbParserCls.downloadMmdb(l);else if(-1!==i.indexOf("load mmdb0"))s.cfg.mmdbid=l,s.cfg.bu=0,await t.mmdbParserCls.downloadMmdb(l);else if(-1!==i.indexOf("load mmdbaf1"))s.cfg.mmdbafid=l,s.cfg.bu=1,await t.chainalignParserCls.downloadMmdbAf(l);else if(-1!==i.indexOf("load mmdbaf0"))s.cfg.mmdbafid=l,s.cfg.bu=0,await t.chainalignParserCls.downloadMmdbAf(l);else if(-1!==i.indexOf("load gi"))s.cfg.gi=l,await t.mmdbParserCls.downloadGi(l);else if(-1!==i.indexOf("load refseq"))s.cfg.refseqid=l,await t.mmdbParserCls.downloadRefseq(l);else if(-1!==i.indexOf("load seq_struct_ids "))t.bSmithwm=!1,t.bLocalSmithwm=!1,await t.mmdbParserCls.downloadBlast_rep_id(l);else if(-1!==i.indexOf("load seq_struct_ids_smithwm "))t.bSmithwm=!0,await t.mmdbParserCls.downloadBlast_rep_id(l);else if(-1!==i.indexOf("load seq_struct_ids_local_smithwm "))t.bLocalSmithwm=!0,await t.mmdbParserCls.downloadBlast_rep_id(l);else if(-1!==i.indexOf("load cid"))s.cfg.cid=l,await t.sdfParserCls.downloadCid(l);else if(-1!==i.indexOf("load alignment"))if(s.cfg.align=l,s.cfg.inpara||-1==s.cfg.inpara.indexOf("atype=2"))await t.alignParserCls.downloadAlignment(s.cfg.align);else{let e=2;await t.chainalignParserCls.downloadMmdbAf(s.cfg.align,void 0,e)}else if(-1!==i.indexOf("load chainalignment")){let e=i.split(" | ");e.length>1&&-1!=e[1].indexOf("resnum")&&(s.cfg.resnum=e[1].substr(e[1].indexOf("resnum")+7)),e.length>2&&-1!=e[2].indexOf("resdef")&&(s.cfg.resdef=e[2].substr(e[1].indexOf("resdef")+7)),e.length>3&&-1!=e[3].indexOf("aligntool")&&(s.cfg.aligntool=e[3].substr(e[1].indexOf("aligntool")+10)),s.cfg.chainalign=l,await t.chainalignParserCls.downloadChainalignment(l,s.cfg.resnum,s.cfg.resdef)}else if(-1!==i.indexOf("load url")){let i=e[1],n=void 0!==i?i.indexOf("type "):-1,r="pdb";-1!==n&&(r=i.substr(n+5)),s.cfg.url=l,await t.pdbParserCls.downloadUrl(l,r)}}t.bAddCommands=!0}applyCommandMap(e){let t=this.icn3d;t.icn3dui;let s=e.split(" | "),i=s[0].substr(8).split(" ");if(3==i.length&&"sigma"==i[1]){let e=i[2],n=i[0];2==s.length?t.dsn6ParserCls.dsn6ParserBase(s[1],n,e):t.dsn6ParserCls.dsn6Parser(t.inputid,n,e)}}applyCommandEmmap(e){let t=this.icn3d;t.icn3dui;let s=e.substr(10).split(" ");if(2==s.length&&"percentage"==s[0]){let e=s[1],i="em";t.densityCifParserCls.densityCifParser(t.inputid,i,e,t.emd)}}async applyCommandRealign(e){let t=this.icn3d;t.icn3dui,await t.realignParserCls.realignOnSeqAlign()}async applyCommandRealignByStruct(e){let t=this.icn3d;t.icn3dui,t.drawCls.draw(),await t.realignParserCls.realignOnStructAlign()}async applyCommandAfmap(e,t){let s=this.icn3d;s.icn3dui;let i=e.substr(e.lastIndexOf(" ")+1);await s.contactMapCls.afErrorMap(i,t)}async applyCommandGraphinteraction(e){let t=this.icn3d;t.icn3dui;let s=e.split(" | ");if(s.length>=3){let e,i=s[1].split(" "),n=i[0].split(","),l=i[1].split(","),r=-1!==s[2].indexOf("hbonds"),o=-1!==s[2].indexOf("salt bridge"),a=-1!==s[2].indexOf("interactions"),d=-1!==s[2].indexOf("halogen"),c=-1!==s[2].indexOf("pi-cation"),h=-1!==s[2].indexOf("pi-stacking");s.length>=4&&(e="true"==s[3]),t.applyCommandCls.setStrengthPara(s),await t.viewInterPairsCls.viewInteractionPairs(n,l,e,"graph",r,o,a,d,c,h)}}async applyCommandCartoon2d(e){let t=this.icn3d;t.icn3dui;let s=e.substr(e.lastIndexOf(" ")+1);await t.cartoon2dCls.draw2Dcartoon(s)}async applyCommandAnnotationsAndCddSite(e){let t=this.icn3d;t.icn3dui,"view annotations"==e&&await t.showAnnoCls.showAnnotations()}async applyCommandClinvar(e){let t=this.icn3d;t.icn3dui;let s=e.lastIndexOf(" ");e.substr(s+1),await t.annotationCls.setAnnoTabClinvar()}async applyCommandSnp(e){let t=this.icn3d;t.icn3dui;let s=e.lastIndexOf(" ");e.substr(s+1),await t.annotationCls.setAnnoTabSnp()}async applyCommandPTM(e){let t=this.icn3d;t.icn3dui;let s=e.lastIndexOf(" ");e.substr(s+1),await t.annotationCls.setAnnoTabPTM()}applyCommand3ddomain(e){let t=this.icn3d;t.icn3dui;let s=e.lastIndexOf(" "),i=e.substr(s+1);"3ddomain"!=i&&"all"!=i||t.annotationCls.setAnnoTab3ddomain()}async applyCommandViewinteraction(e){let t=this.icn3d,s=t.icn3dui;if(void 0!==s.cfg.align||void 0!==s.cfg.chainalign){let e=Object.keys(t.structures);await t.ParserUtilsCls.set2DDiagramsForAlign(e[0].toUpperCase(),e[1].toUpperCase())}}renderFinalStep(e){let t=this.icn3d,s=t.icn3dui;t.bCommandLoad=!1,t.ParserUtilsCls.hideLoading(),e+1===t.commands.length&&(t.bAddCommands=!0),t.bRender=!0;let i=t.commands[e-1]?t.commands[e-1].split("|||"):[];if(2==i.length){let e=JSON.parse(i[1]);t._zoomFactor=e.factor,t.mouseChange.x=e.mouseChange.x,t.mouseChange.y=e.mouseChange.y,t.quaternion._x=e.quaternion._x,t.quaternion._y=e.quaternion._y,t.quaternion._z=e.quaternion._z,t.quaternion._w=e.quaternion._w}if(t.selectionCls.oneStructurePerWindow(),1===e||t.hAtoms&&t.atoms&&Object.keys(t.hAtoms).length===Object.keys(t.atoms).length||void 0!==t.optsHistory[e-1]&&t.optsHistory[e-1].hasOwnProperty("hlatomcount")&&t.optsHistory[e-1].hlatomcount===Object.keys(t.atoms).length)if(t.optsHistory.length>=e){let s=t.optsHistory[e-1].pk;"no"===s?t.pk=0:"atom"===s?t.pk=1:"residue"===s?t.pk=2:"strand"===s&&(t.pk=3),t.hlUpdateCls.updateHlAll(),t.drawCls.draw()}else t.hlUpdateCls.updateHlAll(),t.drawCls.draw();else t.hlUpdateCls.updateHlAll(),t.drawCls.draw();s.cfg.closepopup&&(setTimeout((function(){t.resizeCanvasCls.closeDialogs()}),100),t.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH,s.htmlCls.HEIGHT,!0)),t.bTransparentSurface&&t.bRender&&t.drawCls.render()}async replayFirstStep(e){let t=this.icn3d,s=t.icn3dui;t.reinitAfterLoad(),await this.execCommandsBase(e,e,t.STATENUMBER);let i=t.commands[e],n=t.commands[e].indexOf("|");-1!=n&&(i=t.commands[e].substr(0,n));let l=i.length>20?i.substr(0,20)+"...":i,r=t.applyCommandCls.getMenuFromCmd(i);$("#"+t.pre+"replay_cmd").html("Cmd: "+l),$("#"+t.pre+"replay_menu").html("Menu: "+r),s.htmlCls.clickMenuCls.setLogCmd(i,!0),t.bCommandLoad=!1,t.ParserUtilsCls.hideLoading(),t.bRender=!0,t.drawCls.draw()}getHAtoms(e){let t=this.icn3d;t.icn3dui;let s=e.split("|||")[0].trim().split(" | ");if(2==s.length){let e=s[1].split(",");t.hAtoms=t.definedSetsCls.getAtomsFromNameArray(e)}}}class as{constructor(e){this.icn3d=e}async selectByCommand(e,t,s){let i=this.icn3d,n=i.icn3dui;if(0===e.indexOf("saved atoms")){let s=12,n=e.substr(s);i.definedSetsCls.selectCombinedSets(n,t)}else{let l=e.replace(/ AND /g," and ").replace(/ OR /g," or ").replace(/ or and /g," and ").replace(/ and /g," or and ").replace(/ or not /g," not ").replace(/ not /g," or not "),r=("select"===l.trim().substr(0,6)?l.trim().substr(7):l.trim()).split(" or "),o={};for(let e=0,t=r.length;e1||1==o.length&&"*"!==o[0])&&(h=!1);let C,y,v,w,_=[],S=[];if(_="*"===t?Object.keys(l.structures):t.split(","),"*"===s){let e=Object.keys(l.chains);for(let t=0,s=e.length;t1&&"3"===x[t][0]&&isNaN(x[t][1])&&"-"!==x[t][0]){i=x[t].toUpperCase().substr(1),m=!0}else if(""===x[t]||isNaN(parseInt(x[t]))){if("*"===x[t])h=!0;else if("proteins"!==x[t]&&"nucleotides"!==x[t]&&"chemicals"!==x[t]&&"ions"!==x[t]&&"water"!==x[t]){s=x[t].toUpperCase(),p=!0}}else v=x[t],w=v,n=!0;for(let a=0,u=S.length;a1?e.substr(0,l-1)===n.atoms[i].name.substr(0,l-1)&&(0===s?t[i]=1:t.hasOwnProperty(i)||delete t[i]):"*"!==e&&e!==n.atoms[i].name||(0===s?t[i]=1:t.hasOwnProperty(i)||delete t[i]),t}}class ds{constructor(e){this.icn3d=e}selectAll(){let e=this.icn3d;e.icn3dui,this.selectAll_base(),e.hlObjectsCls.removeHlObjects(),e.hlUpdateCls.removeHl2D(),e.hlUpdateCls.removeHlMenus(),e.bSelectResidue=!1,e.bSelectAlignResidue=!1,e.hlUpdateCls.removeSeqResidueBkgd(),e.hlUpdateCls.update2DdgmContent(),$("#"+e.pre+"dl_annotations > .icn3d-annotation").show(),e.definedSetsCls.setMode("all"),e.saveFileCls.showTitle()}selectAll_base(){let e=this.icn3d,t=e.icn3dui;e.hAtoms={},e.dAtoms={};for(let s in e.chains)e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.chains[s]);e.dAtoms=t.hashUtilsCls.cloneHash(e.hAtoms),e.viewSelectionAtoms=t.hashUtilsCls.cloneHash(e.hAtoms),e.ALTERNATE_STRUCTURE=-1}selectAChain(e,t,s,i){let n=this.icn3d,l=n.icn3dui;t=t.replace(/\s/g,"");let r=void 0!==s||s?"select alignChain "+e:"select chain "+e;void 0!==i&&i?(n.hAtoms=l.hashUtilsCls.unionHash(n.hAtoms,n.chains[e]),void 0===n.nameArray&&(n.nameArray=[])):(n.hAtoms={},n.nameArray=[]),n.nameArray.push(e);let o,a=s?n.alnChainsSeq[e]:n.chainsSeq[e];o=void 0===a?0:a.length;let d={};for(let t=0,s=o;t0){if(void 0!==i&&i?void 0===r.nameArray&&(r.nameArray=[]):(r.hAtoms={},r.nameArray=[]),l)for(let t in e)r.hAtoms[t]=1;else for(let t in e)for(let e in r.residues[t])r.hAtoms[e]=1;let o,a;t=t.replace(/\s/g,""),r.nameArray.push(t),l?(o="select "+r.resid2specCls.atoms2spec(r.hAtoms),a=!1):(o="select "+r.resid2specCls.residueids2spec(Object.keys(e)),a=!0);let d=Object.keys(e);this.addCustomSelection(d,t,s,o,a),(void 0===n||n)&&r.hlUpdateCls.updateHlAll(r.nameArray,void 0,i)}}selectMainChains(){let e=this.icn3d,t=e.icn3dui.hashUtilsCls.cloneHash(e.hAtoms);e.hAtoms=e.applyDisplayCls.selectMainChainSubset(t),e.hlUpdateCls.showHighlight()}selectSideChains(){let e=this.icn3d,t=e.icn3dui,s=t.hashUtilsCls.cloneHash(e.hAtoms);e.hAtoms={};for(let i in s)(e.proteins.hasOwnProperty(i)&&"N"!==e.atoms[i].name&&"H"!==e.atoms[i].name&&"C"!==e.atoms[i].name&&"O"!==e.atoms[i].name&&("CA"!==e.atoms[i].name||"C"!==e.atoms[i].elem)&&"HA"!==e.atoms[i].name||e.nucleotides.hasOwnProperty(i)&&-1===t.parasCls.nuclMainArray.indexOf(e.atoms[i].name))&&(e.hAtoms[i]=1);e.hlUpdateCls.showHighlight()}selectMainSideChains(){let e=this.icn3d,t=e.icn3dui,s=e.firstAtomObjCls.getResiduesFromAtoms(e.hAtoms);e.hAtoms={};for(let i in s)e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.residues[i]),e.dAtoms=t.hashUtilsCls.unionHash(e.dAtoms,e.residues[i]);e.drawCls.draw(),e.hlUpdateCls.showHighlight()}clickShow_selected(){let e=this.icn3d,t=e.icn3dui,s=this;t.myEventCls.onIds(["#"+e.pre+"show_selected","#"+e.pre+"mn2_show_selected"],"click",(function(e){s.icn3d,s.showSelection(),t.htmlCls.clickMenuCls.setLogCmd("show selection",!0)}))}clickHide_selected(){let e=this.icn3d,t=e.icn3dui,s=this;t.myEventCls.onIds("#"+e.pre+"mn2_hide_selected","click",(function(e){s.icn3d,s.hideSelection(),t.htmlCls.clickMenuCls.setLogCmd("hide selection",!0)}))}getGraphDataForDisplayed(){let e=this.icn3d;e.icn3dui;let t=JSON.parse(e.graphStr),s=e.firstAtomObjCls.getResiduesFromAtoms(e.dAtoms),i=[],n=[],l={};for(let e=0,n=t.nodes.length;e0)if(1==s.pk){let n=!0;this.selectResidueList(s.hAtoms,e,t,void 0,void 0,n),this.updateSelectionNameDesc(),i.htmlCls.clickMenuCls.setLogCmd("select "+s.resid2specCls.atoms2spec(s.hAtoms)+" | name "+e,!0)}else this.selectResidueList(s.selectedResidues,e,t),this.updateSelectionNameDesc(),i.htmlCls.clickMenuCls.setLogCmd("select "+s.resid2specCls.residueids2spec(Object.keys(s.selectedResidues))+" | name "+e,!0)}saveSelInCommand(){let e=this.icn3d,t=e.icn3dui;e.selectedResidues=e.firstAtomObjCls.getResiduesFromCalphaAtoms(e.hAtoms),t.htmlCls.clickMenuCls.setLogCmd("select "+e.resid2specCls.residueids2spec(Object.keys(e.selectedResidues)),!0)}saveEachResiInSel(){let e=this.icn3d;e.icn3dui,e.selectionCls.saveSelectionPrep(),e.selectedResidues={},e.selectedResidues=e.firstAtomObjCls.getResiduesFromCalphaAtoms(e.hAtoms);for(let t in e.selectedResidues){let s={};s[t]=1;let i=t+"_"+e.selectedResidues[t];this.selectResidueList(s,i,i)}}removeSelection(){let e=this.icn3d;e.icn3dui,e.bAnnotations||e.hlUpdateCls.removeSeqChainBkgd(),e.bCtrl||e.bShift||(e.hlUpdateCls.removeSeqResidueBkgd(),e.hlUpdateCls.removeSeqChainBkgd()),e.selectedResidues={},e.bSelectResidue=!1,e.hAtoms={},e.hlObjectsCls.removeHlObjects(),e.hlUpdateCls.removeHl2D()}resetAll(){let e=this.icn3d,t=e.icn3dui;e.maxD=e.oriMaxD,e.center=e.oriCenter.clone(),e.opts=t.hashUtilsCls.cloneHash(e.optsOri),e.setOptionCls.setStyle("sidec","nothing"),e.reinitAfterLoad(),e.loadScriptCls.renderFinalStep(1),e.definedSetsCls.setMode("all"),e.selectionCls.selectAll(),t.htmlCls.clickMenuCls.setLogCmd("reset",!0),e.hlUpdateCls.removeSeqChainBkgd(),e.hlUpdateCls.removeSeqResidueBkgd(),e.hlUpdateCls.removeHl2D(),e.hlUpdateCls.removeHlMenus()}async loadSelection(e){let t=this.icn3d,s=t.icn3dui,i=e.trim().split("\n");for(let e=0,n=i.length;e=t&&l.coord.z<=e)){i[l.structure+"_"+l.chain+"_"+l.resi]=1}}let n="z_planes_"+e+"_"+t,l=n;this.selectResidueList(i,n,l,!1)}}class cs{constructor(e){this.icn3d=e}residueids2spec(e){var t=this.icn3d;t.icn3dui;let s="";if(void 0!==e){let i,n,l,r,o,a,d,c=e.sort((function(e,t){if(""!==e&&!isNaN(e))return parseInt(e)-parseInt(t);{let s=e.lastIndexOf("_"),i=t.lastIndexOf("_");if(e.substr(0,s)t.substr(0,i))return 1;if(e.substr(0,s)==t.substr(0,i)){if(parseInt(e.substr(s+1))parseInt(t.substr(i+1)))return 1;if(parseInt(e.substr(s+1))==parseInt(t.substr(i+1)))return 0}}})),h="",p=0,m=1!=Object.keys(t.structures).length;for(let e=0,u=c.length;e0&&(s+=p===d?m?"$"+o+"."+a+":"+d+" or ":"."+a+":"+d+" or ":m?"$"+o+"."+a+":"+d+"-"+p+" or ":"."+a+":"+d+"-"+p+" or "),d=n;else if(h===i){let e=t.ParserUtilsCls.getResiNCBI(h,p);t.ParserUtilsCls.getResiNCBI(i,n)!=e+1&&(s+=p===d?m?"$"+o+"."+a+":"+d+" or ":"."+a+":"+d+" or ":m?"$"+o+"."+a+":"+d+"-"+p+" or ":"."+a+":"+d+"-"+p+" or ",d=n)}h=i,p=n}}r=h.indexOf("_"),o=h.substr(0,r),a=h.substr(r+1),s+=p===d?m?"$"+o+"."+a+":"+d:"."+a+":"+d:m?"$"+o+"."+a+":"+d+"-"+p:"."+a+":"+d+"-"+p}return s}atoms2spec(e){var t=this.icn3d;t.icn3dui;let s,i="",n=0,l={},r={},o={};for(let a in e)s=t.atoms[a],n>0&&(i+=" or "),i+="$"+s.structure+"."+s.chain+":"+s.resi+"@"+s.name,l[s.structure]=1,r[s.structure+"_"+s.chain]=1,o[s.structure+"_"+s.chain+"_"+s.resi]=1,++n;if(1==Object.keys(o).length){let e="\\$"+s.structure+"\\."+s.chain+":"+s.resi;i=i.replace(new RegExp(e,"g"),"")}else if(1==Object.keys(r).length){let e="\\$"+s.structure+"\\."+s.chain;i=i.replace(new RegExp(e,"g"),"")}else if(1==Object.keys(l).length){let e="\\$"+s.structure;i=i.replace(new RegExp(e,"g"),"")}return i}atoms2residues(e){var t=this.icn3d;t.icn3dui;let s={};for(let t=0,i=e.length;t=parseInt(t)&&e.b<=parseInt(s)&&(i.hAtoms=n.hashUtilsCls.unionHash(i.hAtoms,i.residues[e.structure+"_"+e.chain+"_"+e.resi]))}}else if("percent out"==e){i.bCalcArea=!0,i.opts.surface="solvent accessible surface",i.applyMapCls.applySurfaceOptions(),i.bCalcArea=!1,i.hAtoms={};for(let e in i.resid2area){let l=e.lastIndexOf("_"),r=e.substr(l+1);if(n.parasCls.residueArea.hasOwnProperty(r)){let o=parseInt(i.resid2area[e]/n.parasCls.residueArea[r]*100);if(o>=t&&o<=s){let t=e.substr(0,l);i.hAtoms=n.hashUtilsCls.unionHash(i.hAtoms,i.residues[t])}}}}i.hAtoms=n.hashUtilsCls.intHash(i.hAtoms,l),i.drawCls.draw(),i.hlUpdateCls.updateHlAll()}selectComplement(){let e=this.icn3d,t=e.icn3dui,s={};for(let t in e.atoms)e.hAtoms.hasOwnProperty(t)||(s[t]=1);e.hAtoms=t.hashUtilsCls.cloneHash(s),e.hlUpdateCls.updateHlAll()}switchHighlightLevel(){var e=this.icn3d.icn3dui;if(e.bNode)return;let t=this;document.addEventListener("keydown",(function(s){let i=t.icn3d;38===s.keyCode?(s.preventDefault(),0!=Object.keys(i.pickedAtomList).length&&i.hAtoms.hasOwnProperty(i.firstAtomObjCls.getFirstAtomObj(i.pickedAtomList).serial)||(i.pickedAtomList=e.hashUtilsCls.cloneHash(i.hAtoms)),t.switchHighlightLevelUp(),e.htmlCls.clickMenuCls.setLogCmd("highlight level up",!0)):40===s.keyCode&&(s.preventDefault(),0!=Object.keys(i.pickedAtomList).length&&i.hAtoms.hasOwnProperty(i.firstAtomObjCls.getFirstAtomObj(i.pickedAtomList).serial)||(i.pickedAtomList=e.hashUtilsCls.cloneHash(i.hAtoms)),t.switchHighlightLevelDown(),e.htmlCls.clickMenuCls.setLogCmd("highlight level down",!0))}))}switchHighlightLevelUp(){var e=this.icn3d,t=e.icn3dui;if(!t.bNode){if(e.bShift||e.bCtrl||e.hlObjectsCls.removeHlObjects(),void 0!==e.pickedAtomList&&0!==Object.keys(e.pickedAtomList).length||(e.pickedAtomList=t.hashUtilsCls.cloneHash(e.hAtoms)),0===Object.keys(e.pickedAtomList).length&&(e.pickedAtomList=e.dAtoms),1===e.highlightlevel){e.highlightlevel=2;let s=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);e.bShift||e.bCtrl?e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.residues[s.structure+"_"+s.chain+"_"+s.resi]):e.hAtoms=t.hashUtilsCls.cloneHash(e.residues[s.structure+"_"+s.chain+"_"+s.resi])}else if(2===e.highlightlevel){e.highlightlevel=3;let s=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);e.bShift||e.bCtrl?e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.pickingCls.selectStrandHelixFromAtom(s)):e.hAtoms=t.hashUtilsCls.cloneHash(e.pickingCls.selectStrandHelixFromAtom(s))}else if(3===e.highlightlevel){let s;if(void 0!==t.cfg.mmdbid||void 0!==t.cfg.gi){e.highlightlevel=4;let i=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);s=e.pickingCls.select3ddomainFromAtom(i),e.bShift||e.bCtrl?e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,s):e.hAtoms=t.hashUtilsCls.cloneHash(s)}if(void 0===t.cfg.mmdbid&&void 0===t.cfg.gi||0==Object.keys(s).length){e.highlightlevel=5;let s=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);e.bShift||e.bCtrl?e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.chains[s.structure+"_"+s.chain]):e.hAtoms=t.hashUtilsCls.cloneHash(e.chains[s.structure+"_"+s.chain])}}else if(4===e.highlightlevel){e.highlightlevel=5;let s=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);e.bShift||e.bCtrl?e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.chains[s.structure+"_"+s.chain]):e.hAtoms=t.hashUtilsCls.cloneHash(e.chains[s.structure+"_"+s.chain])}else if(5===e.highlightlevel||6===e.highlightlevel){e.highlightlevel=6;let s=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);e.bShift||e.bCtrl||(e.hAtoms={});let i=e.structures[s.structure];for(let s=0,n=i.length;s3e4)return void(e?console.log("The maximum number of allowed atoms is 30,000. Please try it again with selected chains..."):alert("The maximum number of allowed atoms is 30,000. Please try it again with selected chains..."));let o="";return o+=s.cfg.cid?t.saveFileCls.getAtomPDB(n,!0):t.saveFileCls.getAtomPDB(n),o+=t.saveFileCls.getAtomPDB(i,!0,void 0,!0),o}async CalcPhi(e,t,s,i,n){let l=this.icn3d;l.icn3dui;let r=await this.CalcPhiPrms(e,t,s,i,n);this.loadPhiData(r,s,i),l.bAjaxPhi=!0,i?l.setOptionCls.setOption("phisurface","phi"):l.setOptionCls.setOption("phimap","phi")}CalcPhiPrms(e,t,s,i,n){let l=this.icn3d,r=l.icn3dui;l.loadPhiFrom="delphi";let o=r.htmlCls.baseUrl+"delphi/delphi.cgi",a=r.cfg.cid?r.cfg.cid:Object.keys(l.structures).toString(),d={};if(n)d={pqr2phi:n,gsize:e,salt:t,pdbid:a};else{let s=this.getPdbStr();d={pdb2phi:s,gsize:e,salt:t,pdbid:a}}return new Promise((function(e,t){$.ajax({url:o,type:"POST",data:d,dataType:"binary",responseType:"arraybuffer",cache:!0,beforeSend:function(){l.ParserUtilsCls.showLoading()},complete:function(){l.ParserUtilsCls.hideLoading()},success:function(t){e(t)},error:function(e,t,s){}})}))}PhiParser(e,t,s,i){let n=this.icn3d;n.icn3dui;let l=this,r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="phiurl"==t||"phiurl2"==t?"arraybuffer":"text",r.onreadystatechange=function(){if(4==this.readyState)if(200==this.status){let e=r.response;"phiurl"==t||"phiurl2"==t?l.loadPhiData(e,s,i):l.loadCubeData(e,s,i),n.bAjaxPhi=!0,i?n.setOptionCls.setOption("phisurface","phi"):n.setOptionCls.setOption("phimap","phi")}else alert("The potential file is unavailable...");else n.ParserUtilsCls.showLoading()},r.send()}loadPhiData(e,t,s){let i=this.icn3d;i.icn3dui;let n={filetype:"phi"},l=e.buffer&&e.buffer instanceof ArrayBuffer?e.buffer:e,r=new Float32Array(l.slice(l.byteLength-24,l.byteLength-8));n.scale=r[0];let o=r[1],a=r[2],d=r[3];n.n=new Int32Array(l.slice(l.byteLength-8,l.byteLength-4)),n.xExtent=n.yExtent=n.zExtent=n.n;let c=1/n.scale*((n.n-1)/2);n.ori=new THREE.Vector3(o-c,a-c,d-c);let h=new Float32Array(l.slice(110,l.byteLength-56));n.bSurface=s,i.mapData.headerPhi=n,i.mapData.dataPhi=h,i.mapData.contourPhi=t;let p=new THREE.Matrix4;p.identity(),p.multiply((new THREE.Matrix4).makeTranslation(n.ori.x,n.ori.y,n.ori.z)),i.mapData.matrixPhi=p}loadCubeData(e,t,s){let i=this.icn3d;i.icn3dui;let n={filetype:"cube"},l=e.split("\n"),r=[];r.push(parseFloat(l[0].substr(0,10))),r.push(parseFloat(l[0].substr(10,6))),r.push(parseFloat(l[0].substr(16,10))),r.push(parseFloat(l[0].substr(26,10))),r.push(parseFloat(l[0].substr(36,10))),n.scale=r[0];let o=r[2],a=r[3],d=r[4];n.n=r[1],n.xExtent=n.yExtent=n.zExtent=n.n;let c=1/n.scale*((n.n-1)/2);n.ori=new THREE.Vector3(o-c,a-c,d-c);let h=[];for(let e=7,t=l.length;e0)e.bShowRefnum=!0,e.hAtomsRefnum={},await e.showAnnoCls.showAnnotations(),e.annotationCls.setAnnoViewAndDisplay("detailed view");else if(e.refpdbArray=["1bqu_fn3","1cd8_igv","1cdh_cd4","1dr9_cd80","1hnf_cd2","1hxm_d","1hxm_g","1ifr_lamin","1ncn_cd86","1t6v_vnar","1yjd_cd28","2atp_a","2atp_b","2dm3_iset","3kys_tead1","3pv7_ncr","4f9l_cd277","4gos_vtc","4i0k_cd276","4jqi_b","4z18_cd274","4zqk_pd1","4zt1_e","5esv_vh","5esv_vl","6al5_cd19","6jxr_a","6jxr_b","6jxr_d","6jxr_e","6jxr_g","6oil_vista","6rp8_at","6rp8_t","6umt_cd273","6x4g_cd275","6x4g_icos","7xq8_a","7xq8_b","q71h61_ild","q9um44_hhl"],e.pdbDataArray)await s.parseRefPdbData(e.pdbDataArray);else{let i=[];for(let s=0,n=e.refpdbArray.length;sl[d])&&(l[d]=o[0].score,i.bNode||console.log(d+" TM-score: "+l[d]+" matched "+s.refpdbArray[a[1]]),s.domainid2index[d]=a[1],r[d]=o[0].segs,s.domainid2ig2kabat[d]=o[0].ig2kabat,s.domainid2ig2imgt[d]=o[0].ig2imgt))}for(let e in s.domainid2index){let t=e.split("-")[0];s.chainid2index.hasOwnProperty(t)||(s.chainid2index[t]=[]),s.chainid2index[t].push(s.domainid2index[e])}for(let e in r){let t=e.split("-")[0];o[t]||(o[t]=[]),o[t]=o[t].concat(r[e])}s.resid2refnum||(s.resid2refnum={}),s.refnum2residArray||(s.refnum2residArray={}),s.chainsMapping||(s.chainsMapping={});for(let e in o){let t,l=o[e];if(!i.bNode){let t="";for(let i=0,n=s.chainid2index[e].length;i0?(s.bShowRefnum=!0,s.hAtomsRefnum={},await s.showAnnoCls.showAnnotations(),s.annotationCls.setAnnoViewAndDisplay("detailed view")):alert("No Ig reference numbers are assigned based on the reference structures in iCn3D...")}getLabelFromRefnum(e,t,s){this.icn3d.icn3dui;let i=parseInt(e);return i<100?" "+e:i>=100&&i<1e3?s?" "+e:"A^"+e:i>=1e3&&i<1200?"A"+e:i>=1200&&i<1300?"A'"+e:i>=1300&&i<1400?"A*"+e:i>=1400&&i<2e3?"A"==t.substr(0,1)?t+e:"A"+e:i>=2e3&&i<3e3?"B"+e:i>=3e3&&i<4e3?"C"+e:i>=4e3&&i<5e3?"C'"+e:i>=5e3&&i<6e3?"C''"+e:i>=6e3&&i<7e3?"D"+e:i>=7e3&&i<8e3?"E"+e:i>=8e3&&i<9e3?"F"+e:i>=9e3&&i<9400?"G"+e:i>=9400&&i<9500?"G*"+e:i>=9500?"G"+e:void 0}async parseCustomRefFile(e){let t=this.icn3d;t.icn3dui,t.bShowCustomRefnum=!0;let s=e.split("\n");t.resid2refnum||(t.resid2refnum={}),t.refnum2residArray||(t.refnum2residArray={}),t.chainsMapping||(t.chainsMapping={});let i=[];for(let e=0,t=s.length;e1e4)return void alert("The maximum number of allowed atoms is 10,000. Please try it again with smaller sets...");let o="";o+=e.saveFileCls.getAtomPDB(n);let a,d={pdb:o,pdbid:Object.keys(e.structures).toString()};try{a=await t.getAjaxPostPromise(i,d,!0);let n,l,o,c=a.rcsb_struct_symmetry,h="none";if(void 0!==c){let i;void 0!==e.rmsd_supr&&void 0!==e.rmsd_supr.rot&&(n=e.rmsd_supr.rot,l=e.rmsd_supr.trans1,o=e.rmsd_supr.trans2),void 0===e.symdArray&&(e.symdArray=[]);for(let t=0,n=c.length;tThe selected residues have no detected symmetry with a Z score of "+a.zscore+" from the program SymD."),t.htmlCls.dialogCls.openDlg("dl_symd","Dynamically Calculated Symmetry Using SymD");else{let n=a.seqalign.replace(/ /g,"").split(","),l=a.nres,o=a.shift,d=a.rmsd,h=Object.keys(r),p={},m={},u=[],g=[],f=0,b=0,C={};for(let e=0,s=n[0].length;et&&(t=C[s].length,e=s);let s=Object.keys(p),i=Object.keys(m);for(let t=0,n=C[e].length;tSymD. The Z score "+a.zscore+" is greater than the threshold Z score 8. The RMSD is "+d+' angstrom.

    The following sequence alignment shows the residue mapping of the best aligned sets: "symOri" and "symPerm", which are also available in the menu "Analysis > Defined Sets".
    ',$("#"+e.pre+"symd_info").html(A),s.setSeqAlignForSymmetry(w,_,S);let x=!1,k=t.htmlCls.alignSeqCls.getAlignSequencesAnnotations(Object.keys(e.alnChains),void 0,void 0,x,S);A=$("#"+e.pre+"dl_sequence2").html()+k.sequencesHtml,$("#"+e.pre+"dl_sequence2").html(A),$("#"+e.pre+"dl_sequence2").width(t.htmlCls.RESIDUE_WIDTH*k.maxSeqCnt+200),t.htmlCls.dialogCls.openDlg("dl_alignment","Select residues in aligned sequences from SymD");let O=Object.keys(e.defNames2Residues).length+Object.keys(e.defNames2Atoms).length,R="symOri"+O;e.selectionCls.selectResidueList(y,R,R),e.selectionCls.updateSelectionNameDesc(),t.htmlCls.clickMenuCls.setLogCmd("select "+e.resid2specCls.residueids2spec(Object.keys(y))+" | name "+R,!1),R="symPerm"+O,e.selectionCls.selectResidueList(v,R,R),e.selectionCls.updateSelectionNameDesc(),t.htmlCls.clickMenuCls.setLogCmd("select "+e.resid2specCls.residueids2spec(Object.keys(v))+" | name "+R,!1),R="symBoth"+O,y=t.hashUtilsCls.unionHash(y,v),e.selectionCls.selectResidueList(y,R,R),e.selectionCls.updateSelectionNameDesc(),t.htmlCls.clickMenuCls.setLogCmd("select "+e.resid2specCls.residueids2spec(Object.keys(y))+" | name "+R,!1)}}else $("#"+e.pre+"dl_symd").html("
    The selected residues have no detected symmetry with a Z score of "+a.zscore+" from the program SymD."),t.htmlCls.dialogCls.openDlg("dl_symd","Dynamically Calculated Symmetry Using SymD");e.symdtitle="none"===h?void 0:h,e.drawCls.draw()}catch(s){return $("#"+e.pre+"dl_symd").html("
    The web service can not determine the symmetry of the input set."),t.htmlCls.dialogCls.openDlg("dl_symd","Dynamically Calculated Symmetry Using SymD"),void e.ParserUtilsCls.hideLoading()}}getResObj(e){this.icn3d.icn3dui;let t=e.substr(0,e.indexOf(" ")),s=e.indexOf("$"),i=e.indexOf("."),n=e.indexOf(":"),l=e.substr(s+1,i-s-1),r=e.substr(i+1,n-i-1),o=e.substr(n+1);return{resn:t,resid:l+"_"+r+"_"+o,resi:o,aligned:!0}}setSeqAlignForSymmetry(e,t,s){let i=this.icn3d,n=i.icn3dui;i.conservedName1="symOri_cons",i.conservedName2="symPerm_cons",i.consHash1={},i.consHash2={},i.alnChainsAnTtl={},i.alnChainsAnno={},i.alnChainsSeq={},i.alnChains={},i.alnChainsSeq={};let l={};for(let r=0,o=e.length;rThis structure has no symmetry."),void i.htmlCls.dialogCls.openDlg("dl_symmetry","Symmetry")}let r,o,a,d=t.rcsb_struct_symmetry;if(void 0!==d){void 0!==s.rmsd_supr&&void 0!==s.rmsd_supr.rot&&(r=s.rmsd_supr.rot,o=s.rmsd_supr.trans1,a=s.rmsd_supr.trans2),s.symmetryHash={};for(let e=0,t=d.length;eThis structure has no symmetry.");else{let e="",t=0;for(let i in s.symmetryHash){e+="",++t}$("#"+s.pre+"selectSymmetry").html(e)}}else $("#"+s.pre+"dl_symmetry").html("
    This structure has no symmetry.");i.htmlCls.dialogCls.openDlg("dl_symmetry","Symmetry")}getPolygonColor(e){let t=this.icn3d.icn3dui,s=e.substr(0,1);return"C"==s?t.parasCls.thr(16747520):"D"==s?t.parasCls.thr(65535):"T"==s?t.parasCls.thr(15631086):"O"==s?t.parasCls.thr(16753920):"I"==s?t.parasCls.thr(65280):t.parasCls.thr(11119017)}getAxisColor(e,t){let s=this.icn3d.icn3dui,i=e.substr(0,1);return"C"==i?s.parasCls.thr(16711680):"D"==i?2==t?s.parasCls.thr(65535):s.parasCls.thr(16711680):"T"==i?2==t?s.parasCls.thr(65535):s.parasCls.thr(65280):"O"==i||"I"==i?2==t?s.parasCls.thr(65535):3==t?s.parasCls.thr(65280):s.parasCls.thr(16711680):s.parasCls.thr(16711680)}}class bs{constructor(e){this.icn3d=e}alignSW(e,t,s,i,n,l,r){this.icn3d.icn3dui;let o=this.bsa_align(r,e,t,[s,i],[n,l]),a="score: "+o[0]+"\n";a+="start: "+o[1]+"\n",a+="cigar: "+this.bsa_cigar2str(o[2])+"\n\n",a+="alignment:\n\n";let d=this.bsa_cigar2gaps(e,t,o[1],o[2]),c={};return c.score=o[0],c.start=o[1],c.cigar=this.bsa_cigar2str(o[2]),c.target=d[0],c.query=d[1],c}bsg_enc_seq(e,t){if(this.icn3d.icn3dui,null==t)return null;let s=[];s.length=e.length;for(let i=0;i0&&(s=-s),i=0;i=2&&"number"==typeof t[0]&&"number"==typeof t[1]){if(null==s)return null;let e="number"==typeof s?s:s[s.length-1]+1;i=this.bsa_gen_score_matrix(e,t[0],t[1])}else i=t;for(let e=0;eo.length?d:o.length;l=null==l||l<0?c:l;let h,p,m=o.target>d?o.target-d:d-o.target;l=l>m?l:m,"number"==typeof n?(h=0,p=n>0?n:-n):(h=n[0]>0?n[0]:-n[0],p=n[1]>0?n[1]:-n[1]);let u,g=h+p,f=-1073741824,b=[],C=[],y=[],v=0,w=-1,_=-1;if(e)for(let e=0;e<=d;++e)b[e]=C[e]=0;else{b[0]=0,C[0]=-g-g;for(let e=1;e<=d;++e)e>=l?b[e]=C[e]=f:(b[e]=-(g+p*(e-1)),C[e]=-(g+g+p*e))}for(let t=0;tl?t-l:0,u=t+l+10?f:-(g+p*t),n=m>0?f:-(g+g+p*t));for(let t=m;t=o?0:1,a=a>=o?a:o,l=a>=n?l:2,a=a>=n?a:n,l=!e||a>0?l:64,i=a,c=r>a?c:t,r=r>a?r:a,a-=g,a=!e||a>0?a:0,o-=p,l|=o>a?4:0,o=o>a?o:a,C[t]=o,n-=p,l|=n>a?32:0,n=n>a?n:a,s[t]=l}b[u]=i,C[u]=e?0:f,r>v&&(v=r,w=t,_=c)}if(e&&0==v)return null;u=e?v:b[d];let S,A,x,k=[],O=0,R=0;for(e?(A=w,x=_,_!=d-1&&this.push_cigar(k,4,d-1-_)):(A=o.length-1,x=(A+l+1=0&&x>=0&&(S=y[A][x-(A>l?A-l:0)],O=S>>(O<<1)&3,!(0==O&&S>>6));)0==O&&(O=3&S),0==O?(this.push_cigar(k,0,1),--A,--x):1==O?(this.push_cigar(k,2,1),--A):(this.push_cigar(k,1,1),--x);e?(x>=0&&this.push_cigar(k,4,x+1),R=A+1):(A>=0&&this.push_cigar(k,2,A+1),x>=0&&this.push_cigar(k,1,x+1));for(let e=0;e>1;++e)S=k[e],k[e]=k[k.length-1-e],k[k.length-1-e]=S;return[u,R,k]}push_cigar(e,t,s){this.icn3d.icn3dui,0==e.length||t!=(15&e[e.length-1])?e.push(s<<4|t):e[e.length-1]+=s<<4}bsa_cigar2gaps(e,t,s,i){this.icn3d.icn3dui;let n="",l="",r="",o=0,a=s;for(let s=0;s>4;0==r?(n+=t.substr(o,d),l+=e.substr(a,d),o+=d,a+=d):1==r?(n+=t.substr(o,d),l+=Array(d+1).join("-"),o+=d):2==r?(n+=Array(d+1).join("-"),l+=e.substr(a,d),a+=d):4==r&&(o+=d)}let d=l.toUpperCase(),c=n.toUpperCase();for(let e=0;e>4).toString()+"MIDNSHP=XB".charAt(15&e[s]));return t.join("")}}class Cs{constructor(e){this.icn3d=e}calculateArea(){var e=this.icn3d,t=e.icn3dui;e.bCalcArea=!0,e.opts.surface="solvent accessible surface",e.applyMapCls.applySurfaceOptions(),$("#"+e.pre+"areavalue").val(e.areavalue),$("#"+e.pre+"areatable").html(e.areahtml),t.htmlCls.dialogCls.openDlg("dl_area","Surface area calculation"),e.bCalcArea=!1}calcBuriedSurface(e,t){var s=this.icn3d,i=s.icn3dui;if(0==e.length)alert("Please select the first set");else{let n=i.hashUtilsCls.cloneHash(s.hAtoms),l=s.definedSetsCls.getAtomsFromNameArray(e),r=s.definedSetsCls.getAtomsFromNameArray(t);s.bCalcArea=!0,s.opts.surface="solvent accessible surface",s.hAtoms=i.hashUtilsCls.cloneHash(l),s.applyMapCls.applySurfaceOptions();let o=s.areavalue,a=i.hashUtilsCls.cloneHash(s.resid2area);s.hAtoms=i.hashUtilsCls.cloneHash(r),s.applyMapCls.applySurfaceOptions();let d=s.areavalue,c=i.hashUtilsCls.cloneHash(s.resid2area);s.hAtoms=i.hashUtilsCls.unionHash(s.hAtoms,l),s.applyMapCls.applySurfaceOptions();let h=s.areavalue,p=i.hashUtilsCls.cloneHash(s.resid2area),m=0,u=0,g=0,f=0;for(let e in a)p.hasOwnProperty(e)&&(f+=parseFloat(p[e]));u=(o-f).toFixed(2);for(let e in c)p.hasOwnProperty(e)&&(g+=parseFloat(p[e]));m=(d-g).toFixed(2),s.bCalcArea=!1,s.hAtoms=i.hashUtilsCls.cloneHash(n);let b=(parseFloat(d)+parseFloat(o)-parseFloat(h)).toFixed(2),C="
    Calculate solvent accessible surface area in the interface:

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

    ",$("#"+s.pre+"dl_buriedarea").html(C),i.htmlCls.dialogCls.openDlg("dl_buriedarea","Buried solvent accessible surface area in the interface"),i.htmlCls.clickMenuCls.setLogCmd("buried surface "+b,!1)}}measureDistTwoSets(e,t){var s=this.icn3d,i=s.icn3dui;if(0==e.length||0==t.length)alert("Please select two sets");else{let n=i.hashUtilsCls.cloneHash(s.hAtoms),l=s.definedSetsCls.getAtomsFromNameArray(e),r=s.definedSetsCls.getAtomsFromNameArray(t),o=s.contactCls.getExtent(l),a=s.contactCls.getExtent(r),d=new THREE.Vector3(o[2][0],o[2][1],o[2][2]),c=new THREE.Vector3(a[2][0],a[2][1],a[2][2]);s.hAtoms=i.hashUtilsCls.cloneHash(n),void 0===s.distPnts&&(s.distPnts=[]),s.distPnts.push(d),s.distPnts.push(c);let h=$("#"+s.pre+"distancecolor2").val();this.addLine(d.x,d.y,d.z,c.x,c.y,c.z,h,!0,"distance");let p=0,m=0,u=d.clone().add(c).multiplyScalar(.5),g=(parseInt(10*d.distanceTo(c))/10).toString()+" A";this.addLabel(g,u.x,u.y,u.z,p,h,m,"distance"),s.drawCls.draw()}}measureDistManySets(e,t){var s=this.icn3d,i=s.icn3dui;if(0==e.length||0==t.length)alert("Please select sets for distance calculation...");else{let n=i.hashUtilsCls.cloneHash(s.hAtoms),l={};for(let i=0,n=e.length;i"+t[e]+" (Å)"}r+="";for(let s=0,i=e.length;s"+i+" (Å)";for(let e=0,s=t.length;e'+l[i][s]+"":r+="0"}r+=""}r+="

    ",$("#"+i.pre+"dl_disttable").html(r)}}addLine(e,t,s,i,n,l,r,o,a,d,c){var h=this.icn3d;h.icn3dui;let p={};p.position1=new THREE.Vector3(e,t,s),p.position2=new THREE.Vector3(i,n,l),p.color=r,p.dashed=o,p.radius=d,p.opacity=c,void 0===h.lines[a]&&(h.lines[a]=[]),void 0!==a?h.lines[a].push(p):(void 0===h.lines.custom&&(h.lines.custom=[]),h.lines.custom.push(p)),h.hlObjectsCls.removeHlObjects()}addLineFromPicking(e){var t=this.icn3d,s=t.icn3dui;let i=$("#"+t.pre+e+"color").val();t.pAtom.coord.x,t.pAtom2.coord.x,t.pAtom.coord.y,t.pAtom2.coord.y,t.pAtom.coord.z,t.pAtom2.coord.z;let n="stabilizer"!=e;s.htmlCls.clickMenuCls.setLogCmd("add line | x1 "+t.pAtom.coord.x.toPrecision(4)+" y1 "+t.pAtom.coord.y.toPrecision(4)+" z1 "+t.pAtom.coord.z.toPrecision(4)+" | x2 "+t.pAtom2.coord.x.toPrecision(4)+" y2 "+t.pAtom2.coord.y.toPrecision(4)+" z2 "+t.pAtom2.coord.z.toPrecision(4)+" | color "+i+" | dashed "+n+" | type "+e,!0),this.addLine(t.pAtom.coord.x,t.pAtom.coord.y,t.pAtom.coord.z,t.pAtom2.coord.x,t.pAtom2.coord.y,t.pAtom2.coord.z,i,n,e),t.pickpair=!1}addLabel(e,t,s,i,n,l,r,o){var a=this.icn3d;a.icn3dui;let d={};"0"!==n&&""!==n&&"undefined"!==n||(n=void 0),"0"!==l&&""!==l&&"undefined"!==l||(l=void 0),"0"!==r&&""!==r&&"undefined"!==r||(r=void 0);let c=new THREE.Vector3;c.x=t,c.y=s,c.z=i,d.position=c,d.text=e,d.size=n,d.color=l,d.background=r,void 0===a.labels[o]&&(a.labels[o]=[]),void 0!==o?a.labels[o].push(d):(void 0===a.labels.custom&&(a.labels.custom=[]),a.labels.custom.push(d)),a.hlObjectsCls.removeHlObjects()}addChainLabels(e){var t=this.icn3d;let s=t.icn3dui.hashUtilsCls.intHash(t.hAtoms,e);void 0===t.labels.chain&&(t.labels.chain=[]);let i=t.firstAtomObjCls.getChainsFromAtoms(s);for(let e in i){let s={};s.position=t.applyCenterCls.centerAtoms(t.chains[e]).center;let i=e.indexOf("_"),n=e.substr(i+1),l=t.showSeqCls.getProteinName(e);l.length>20&&(l=l.substr(0,20)+"..."),s.text="Chain "+n+": "+l,s.size=18,t.firstAtomObjCls.getFirstCalphaAtomObj(t.chains[e]).color.getHexString().toUpperCase(),s.color="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd,s.background="#FFFFFF",t.labels.chain.push(s)}t.hlObjectsCls.removeHlObjects()}addTerminiLabels(e){var t=this.icn3d,s=t.icn3dui;let i,n="#FFFFFF";i=s.hashUtilsCls.unionHash(i,t.proteins),i=s.hashUtilsCls.unionHash(i,t.nucleotides);let l=s.hashUtilsCls.intHash(t.dAtoms,i),r=s.hashUtilsCls.intHash(l,e);void 0===t.labels.chain&&(t.labels.chain=[]);let o=t.firstAtomObjCls.getChainsFromAtoms(r);for(let e in o){let i=s.hashUtilsCls.intHash(l,t.chains[e]),r=Object.keys(i),o=t.atoms[r[0]],a=t.atoms[r[r.length-1]],d={},c={};d.position=o.coord,c.position=a.coord,d.text="N-",c.text="C-",t.nucleotides.hasOwnProperty(o.serial)&&(d.text="5'",c.text="3'"),d.size=18,c.size=18,o.color.getHexString().toUpperCase(),a.color.getHexString().toUpperCase(),d.color="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd,c.color="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd,d.background=n,c.background=n,t.labels.chain.push(d),t.labels.chain.push(c)}t.hlObjectsCls.removeHlObjects()}}class ys{constructor(e){this.icn3d=e}draw2Ddgm(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=.667,o={},a={},d={},c={},h={};if(void 0===e)return"";for(let s in e.moleculeInfor){let i="#"+("000000"+e.moleculeInfor[s].color.toString(16)).slice(-6),l=e.moleculeInfor[s].chain.trim();void 0===h[l]?h[l]=1:++h[l];let r=t+"_"+(1===h[l]?l:l+h[l].toString());void 0!==n.mmdbid_q&&(n.mmdbid_q,n.mmdbid_t),o[s]=r,a[s]=i,d[s]=e.moleculeInfor[s].name,c[r]=s}if(void 0===i||!i)for(let s=0,i=e.intracResidues.length;s";p+=""+t.toUpperCase()+"
    ",p+="";let m={},u=[],g="",f="",b={};if(i)for(let e in n.dAtoms){let t=n.atoms[e];b[c[t.structure+"_"+t.chain]]=1}let C=Object.keys(e.moleculeInfor),y=Object.keys(e.intrac),v=[];for(let e=0,t=C.length;e0)for(let t in e.intrac){let s=e.intrac[t];for(let e=0,i=s.intrac.length;e0&&(y="#"+n.atoms[e[0]].color.getHexString().toUpperCase())}let S="";n.bInitial&&void 0!==s&&(void 0!==n.alignmolid2color&&n.alignmolid2color[s].hasOwnProperty(l)?(S=n.alignmolid2color[s][l],y="#FF0000"):y="#FFFFFF");let A=d[l],x=" ",k=" ";if(void 0!==c){let e=c.indexOf("_");k=c.substr(e+1),x=k.length>1?k.substr(0,1)+"..":k}else c="Misc";void 0===y&&(y="#FFFFFF");let O=1;if(n.bInitial&&void 0!==n.alnChains[c]){let e=0;for(let t in n.alnChains[c]){let s=n.atoms[t].color.getHexString().toUpperCase();"FF0000"!==s&&"00FF00"!==s||++e}O=1*e/Object.keys(n.chains[c]).length}if(O<.2&&(O=.2),-1===v.indexOf(l)){for(let e=0,t=h.intrac.length;e1){let s=0,i=0;for(let e=0,t=w[l].length;e",p+="Interaction of chain "+c+" with chain "+h+"",p+="",p+="",p+="Interaction of chain "+h+" with chain "+c+"",p+=""}return p+=f+g,p+="",p+="",n.html2ddgm+=p,$("#"+n.pre+"dl_2ddgm").html(n.html2ddgm),p}set2DdgmNote(e){let t="
    Nodes:
    ";return this.icn3d.icn3dui.utilsCls.isMac()?(t+="Protein
    ",t+="Nucleotide
    ",t+="Chemical
    ",t+="Biopolymer
    "):(t+="OProtein
    ",t+="Nucleotide
    ",t+="Chemical
    ",t+="Biopolymer
    "),t+="
    Lines:
    Interactions at 4 Å
    ",e&&(t+="Numbers in red:
    Aligned chains"),t+="

    ",t}highlightNode(e,t,s,i){let n=this.icn3d.icn3dui;i<.2&&(i=.2);if("rect"===e){$(t).attr("stroke",n.htmlCls.ORANGE),$(t).attr("stroke-width",3);let e=Number($(s).attr("x")),l=Number($(s).attr("y")),r=Number($(s).attr("width")),o=Number($(s).attr("height"));$(t).attr("x",e+r/2*(1-i)),$(t).attr("y",l+o/2*(1-i)),$(t).attr("width",r*i),$(t).attr("height",o*i)}else if("circle"===e)$(t).attr("stroke",n.htmlCls.ORANGE),$(t).attr("stroke-width",3),$(t).attr("r",Number($(s).attr("r"))*i);else if("polygon"===e){$(t).attr("stroke",n.htmlCls.ORANGE),$(t).attr("stroke-width",3);let e=Number($(s).attr("x")),l=Number($(s).attr("y")),r=Number($(s).attr("x0d")),o=Number($(s).attr("y0d")),a=Number($(s).attr("x1d")),d=Number($(s).attr("y1d")),c=Number($(s).attr("x2d")),h=Number($(s).attr("y2d")),p=Number($(s).attr("x3d")),m=Number($(s).attr("y3d"));$(t).attr("points",(e+r*i).toString()+", "+(l+o*i).toString()+", "+(e+a*i).toString()+", "+(l+d*i).toString()+", "+(e+c*i).toString()+", "+(l+h*i).toString()+", "+(e+p*i).toString()+", "+(l+m*i).toString())}}removeLineGraphSelection(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"dl_linegraph circle").attr("stroke","#000000"),$("#"+e.pre+"dl_linegraph circle").attr("stroke-width",1),$("#"+e.pre+"dl_linegraph svg line.icn3d-hlline").attr("stroke","#FFF")}removeScatterplotSelection(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"dl_scatterplot circle").attr("stroke","#000000"),$("#"+e.pre+"dl_scatterplot circle").attr("stroke-width",1),$("#"+e.pre+"dl_scatterplot rect").attr("stroke","#000000"),$("#"+e.pre+"dl_scatterplot rect").attr("stroke-width",1)}click2Ddgm(){let e=this.icn3d,t=e.icn3dui,s=this;$(document).on("click","#"+e.pre+"dl_2ddgm .icn3d-node",(function(e){let i=s.icn3d;e.stopImmediatePropagation(),Object.keys(i.hAtoms).length1)s="inter_"+e+"_"+t;else{let i=e.indexOf("_"),n=t.indexOf("_");s="inter_"+e.substr(i+1)+"_"+t.substr(n+1)}i="select the atoms in chain "+e+" interacting with chain "+t+" in a distance of 4 angstrom";let o="select interaction "+e+","+t;n.selectionCls.addCustomSelection(r,s,i,o,!0)}draw2DProtein(e,t,s,i,n,l,r,o,a,d,c){this.icn3d.icn3dui;let h=20*d,p="";return p+="Chain "+i+": "+l+"",p+="",p+="",p+=""+n+"",""!==r&&(p+=""+r+""),p+="",p}draw2DNucleotide(e,t,s,i,n,l,r,o,a,d,c){this.icn3d.icn3dui;let h=30*d,p=30*d,m="";return m+="Chain "+i+": "+l+"",m+="",m+="",m+=""+n+"",""!==r&&(m+=""+r+""),m+="",m}draw2DChemical(e,t,s,i,n,l,r,o,a,d,c,h){this.icn3d.icn3dui;let p,m,u,g,f,b,C,y,v=30*d;if(h){let s=.5*v/Math.sqrt(3),i=.5*v;p=e-s,m=t-i,u=e+3*s,g=t-i,f=e+s,b=t+i,C=e-3*s,y=t+i}else{let s=.5*v,i=.5*v;p=e-s,m=t,u=e,g=t+i,f=e+s,b=t,C=e,y=t-i}let w=p-e,_=m-t,S=u-e,A=g-t,x=f-e,k=b-t,O=C-e,R=y-t,E="";return E+="Chain "+i+": "+l+"",E+="",E+="",E+=""+n+"",""!==r&&(E+=""+r+""),E+="",E}}class vs{constructor(e){this.icn3d=e}async draw2Dcartoon(e,t){let s=this.icn3d,i=s.icn3dui,n=this;if(i.htmlCls.clickMenuCls.setLogCmd("cartoon 2d "+e,!0),s.cartoon2dType=e,t){let t=n.getCartoonSvg(e,s.graphStr);$("#"+i.svgid_ct).html(t)}else{await this.getNodesLinksForSetCartoon(e),s.graphStr=n.getCartoonData(e,s.node_link);let t=n.getCartoonSvg(e,s.graphStr);$("#"+i.svgid_ct).html(t),n.setEventsForCartoon2d(),i.htmlCls.dialogCls.openDlg("dl_2dctn","2D Cartoon")}}getCartoonSvg(e,t){let s=this.icn3d,i=s.icn3dui,n="",l="",r=JSON.parse(t);s.ctnNodeHash={};for(let t=0,i=r.nodes.length;t":"domain"==e?n+="":"secondary"==e&&(a=s.ctnNodeHash[l].x2,d=i.htmlCls.width2d-s.ctnNodeHash[l].y2,c=s.ctnNodeHash[o].x1,h=i.htmlCls.width2d-s.ctnNodeHash[o].y1,n+="");let p=l+"--"+o;n+="Interaction of "+e+" "+this.getLabelFromId(l,e)+" with "+e+" "+this.getLabelFromId(o,e)+"",n+="",s.nodeid2lineid.hasOwnProperty(l)||(s.nodeid2lineid[l]=[]),s.nodeid2lineid.hasOwnProperty(o)||(s.nodeid2lineid[o]=[]),s.nodeid2lineid[l].push(p),s.nodeid2lineid[o].push(p)}return n+=l,n}setEventsForCartoon2d(){let e=this.icn3d,t=e.icn3dui;$("#"+t.svgid_ct+" .icn3d-ctnode").draggable({start:function(e,t){let s=parseFloat(e.target.getAttribute("cx")),i=parseFloat(e.target.getAttribute("cy"));e.target.setAttribute("cx",s),e.target.setAttribute("cy",i);let n=e.target.getAttribute("ang");if(n)e.target.setAttribute("transform","rotate("+n+","+s+","+i+")");else{let t=parseFloat(e.target.getAttribute("x1")),s=parseFloat(e.target.getAttribute("y1")),i=parseFloat(e.target.getAttribute("x2")),n=parseFloat(e.target.getAttribute("y2"));e.target.setAttribute("x1",t),e.target.setAttribute("y1",s),e.target.setAttribute("x2",i),e.target.setAttribute("y2",n)}},drag:function(s,i){let n=$("#"+t.svgid_ct).offset().left,l=$("#"+t.svgid_ct).offset().top,r=s.target.getAttribute("id"),o=s.target.getAttribute("ang"),a=s.clientX-n,d=s.clientY-l,c=parseFloat(s.target.getAttribute("cx")),h=parseFloat(s.target.getAttribute("cy")),p=(a-c)/e.resizeRatioX,m=(d-h)/e.resizeRatioY,u=parseFloat($("#"+r+"_text").attr("x")),g=parseFloat($("#"+r+"_text").attr("y"));if($("#"+r+"_text").attr("x",u+p),$("#"+r+"_text").attr("y",g+m),s.target.setAttribute("cx",a),s.target.setAttribute("cy",d),o)s.target.setAttribute("transform","rotate("+o+","+a+","+d+")");else{let e=parseFloat(s.target.getAttribute("x1")),t=parseFloat(s.target.getAttribute("y1")),i=parseFloat(s.target.getAttribute("x2")),n=parseFloat(s.target.getAttribute("y2"));if(s.target.setAttribute("x1",e+p),s.target.setAttribute("y1",t+m),s.target.setAttribute("x2",i+p),s.target.setAttribute("y2",n+m),"S"==r.substr(0,1)){let e=parseFloat($("#"+r+"_box").attr("x1")),t=parseFloat($("#"+r+"_box").attr("y1")),s=parseFloat($("#"+r+"_box").attr("x2")),i=parseFloat($("#"+r+"_box").attr("y2"));$("#"+r+"_box").attr("x1",e+p),$("#"+r+"_box").attr("y1",t+m),$("#"+r+"_box").attr("x2",s+p),$("#"+r+"_box").attr("y2",i+m)}}if(e.nodeid2lineid[r])for(let t=0,s=e.nodeid2lineid[r].length;t";return u+=""+e+" "+m+"","H"==t.substr(0,1)?u+="":(u+="",u+=""),u+=""+m+"",u+="",u}drawOval(e,t,s,i,n,l,r,o,a,d){let c=this.icn3d.icn3dui,h=this.getLabelFromId(t,e);i=c.htmlCls.width2d-i,r=180-r;let p="chain"==e?"":"";return p+=""+e+" "+h+"",p+="",p+="",p+=" ",p+=" ",p+="",p+="",p+="":" from='"+a+"' to='"+d+"' />",p+=""+h+"",p+="",p}getCartoonData(e,t){let s=this.icn3d;s.icn3dui;let i,n,l=[],r=[];l=t.node;let o=[],a={},d=0;for(let e=0,t=l.length;e0?n.y=s.htmlCls.width2d-n.y:n.y=-n.y,n}async getNodesLinksForSetCartoon(e){let t,s,i,n,l,r=this.icn3d,o=r.icn3dui,a=this,d=[],c=[],h=0,p=o.htmlCls.defaultValue,m="",u="",g="",f=!1,b=!0;if("chain"==e){let e={};for(let t in r.hAtoms){let s=r.atoms[t];if("DUM"==s.chain)continue;let i=s.structure+"_"+s.chain;(r.proteins.hasOwnProperty(t)||r.nucleotides.hasOwnProperty(t))&&(e.hasOwnProperty(i)||(e[i]={}),e[i][s.serial]=s)}let t=r.contactCls.getExtent(r.atoms),s=9999,i=9999,n=-9999,a=-9999,h=-9999,p=[];for(let d in e){r.hAtom={},r.hAtoms=o.hashUtilsCls.cloneHash(r.chains[d]);let e=r.axesCls.setPc1Axes(),c=e[0],m=e[1].distanceTo(e[0]),u=e[2].distanceTo(e[0]),g=180*new THREE.Vector2(e[1].x-e[0].x,e[1].y-e[0].y).angle()/Math.PI;g>180&&(g-=180);let f=Object.keys(r.hAtoms)[0],b=r.atoms[f];l=d,c=this.projectTo2d(c);let C=c.x,y=c.y;Cn&&(n=C),ya&&(a=y);let v=.5;m=v*o.htmlCls.width2d*m/(t[1][0]-t[0][0]),u=v*o.htmlCls.width2d*u/(t[1][1]-t[0][1]),m>h&&(h=m),u>h&&(h=u),p.push({id:d,r:l,x:C,y:y,rx:m,ry:u,ang:g,c:b.color.getHexString()})}let m=h+2,u=n-s,g=a-i;for(let e=0,t=p.length;e1&&(e+="__"+S.structure),a.push(e)),g==S.chain&&f&&S.ssend){let o=this.projectTo2d(t.coord.clone()),d=o.x,g=o.y,x=this.projectTo2d(S.coord.clone()),k=x.x,O=x.y;s=.5*(d+k),i=.5*(g+O),d=.5*(s+d),g=.5*(i+g),k=.5*(s+k),O=.5*(i+O),dw&&(w=d),g_&&(_=g),kw&&(w=k),O_&&(_=O),f=!1,b=!0,n+="-"+S.resi,l+="-"+S.resi,n+="__"+S.chain,Object.keys(r.structures).length>1&&(n+="__"+S.structure);for(let t=0,s=a.length;t0&&m==S.chain&&c.push('{"source": "'+u+'", "target": "'+n+'", "v": '+p+', "c": "'+t.color.getHexString().toUpperCase()+'"}'),A.push({id:n,r:l,ss:C,x:s,y:i,x1:d,y1:g,x2:k,y2:O,c:S.color.getHexString()}),m=S.chain,u=n,++h}}}let x=S+2,k=w-y,O=_-v;for(let e=0,t=A.length;e1&&(v+="__"+i.substr(0,i.indexOf("_")));let w=g[b],_=f[b];t.hAtoms={};for(let e=0,n=w.length;e180&&(O-=180);let R=Object.keys(t.hAtoms)[0],E=t.atoms[R];A=this.projectTo2d(A);let I=A.x,T=A.y;Ic&&(c=I),Th&&(h=T);let M=.5;x=M*s.htmlCls.width2d*x/(o[1][0]-o[0][0]),k=M*s.htmlCls.width2d*k/(o[1][1]-o[0][1]),x>p&&(p=x),k>p&&(p=k),void 0!==C&&n.push('{"source": "'+C+'", "target": "'+v+'", "v": '+l+', "c": "'+y.color.getHexString().toUpperCase()+'"}'),m.push({id:v,from:w+"",to:_+"",x:I,y:T,rx:x,ry:k,ang:O,c:E.color.getHexString()}),C=v,y=E}}let g=p+2,f=c-a,b=h-d;for(let e=0,t=m.length;e=2?d+"_"+e[1]:Object.keys(i.chains)[0];for(let e=0,t=o.length;es.transformCls.rotateCountMax)return s.transformCls.resetOrientation(),!1;if(++s.transformCls.rotateCount,t)if("left"===e)s.ROT_DIR="left";else if("right"===e)s.ROT_DIR="right";else if("up"===e)s.ROT_DIR="up";else{if("down"!==e)return!1;s.ROT_DIR="down"}if("left"===e&&"left"===s.ROT_DIR)s.transformCls.rotateLeft(1);else if("right"===e&&"right"===s.ROT_DIR)s.transformCls.rotateRight(1);else if("up"===e&&"up"===s.ROT_DIR)s.transformCls.rotateUp(1);else{if("down"!==e||"down"!==s.ROT_DIR)return!1;s.transformCls.rotateDown(1)}setTimeout((function(){i.rotStruc(e)}),100)}async back(){var e=this.icn3d;e.icn3dui,e.backForward=!0,e.STATENUMBER--,e.bAddCommands=!1,e.bAddLogs=!1,e.bNotLoadStructure=!0,e.STATENUMBER<1?e.STATENUMBER=1:await e.loadScriptCls.execCommands(0,e.STATENUMBER-1,e.STATENUMBER,!0),e.setStyleCls.adjustIcon(),e.bAddCommands=!0,e.bAddLogs=!0}async forward(){var e=this.icn3d;e.icn3dui,e.backForward=!0,e.STATENUMBER++,e.bAddCommands=!1,e.bAddLogs=!1,e.bNotLoadStructure=!0,e.STATENUMBER>e.commands.length?e.STATENUMBER=e.commands.length:await e.loadScriptCls.execCommands(0,e.STATENUMBER-1,e.STATENUMBER,!0),e.setStyleCls.adjustIcon(),e.bAddCommands=!0,e.bAddLogs=!0}async replayon(){var e=this.icn3d;e.icn3dui,e.CURRENTNUMBER=0,e.bReplay=1,$("#"+e.pre+"replay").show(),e.commands.length>0&&await e.loadScriptCls.replayFirstStep(e.CURRENTNUMBER)}async replayoff(){var e=this.icn3d;e.icn3dui,e.bReplay=0,$("#"+e.pre+"replay").hide(),++e.CURRENTNUMBER,await e.loadScriptCls.execCommands(e.CURRENTNUMBER,e.STATENUMBER-1,e.STATENUMBER)}closeDialogs(){var e=this.icn3d,t=e.icn3dui;let s=["dl_2ddgm","dl_2dctn","dl_alignment","dl_sequence2","dl_definedsets","dl_setsmenu","dl_command","dl_setoperations","dl_vast","dl_foldseek","dl_mmtfid","dl_pdbid","dl_afid","dl_opmid","dl_pdbfile","dl_pdbfile_app","dl_rescolorfile","dl_customcolor","dl_align","dl_alignaf","dl_chainalign","dl_chainalign2","dl_chainalign3","dl_mutation","dl_mol2file","dl_sdffile","dl_xyzfile","dl_afmapfile","dl_urlfile","dl_mmciffile","dl_mmcifid","dl_mmdbid","dl_mmdbafid","dl_blast_rep_id","dl_yournote","dl_gi","dl_refseqid","dl_cid","dl_pngimage","dl_state","dl_fixedversion","dl_selection","dl_dsn6","dl_dsn6url","dl_clr","dl_symmetry","dl_symd","dl_contact","dl_hbonds","dl_realign","dl_realignbystruct","dl_allinteracton","dl_interactionsorted","dl_linegraph","dl_linegraphcolor","dl_scatterplot","dl_scatterploitcolor","dl_contactmap","dl_alignerrormap","dl_elecmap2fofc","dl_elecmapfofc","dl_emmap","dl_aroundsphere","dl_adjustmem","dl_selectplane","dl_addlabel","dl_addlabelselection","dl_labelColor","dl_distance","dl_stabilizer","dl_disttwosets","dl_distmanysets","dl_stabilizer_rm","dl_thickness","dl_thickness2","dl_addtrack","dl_addtrack_tabs","dl_saveselection","dl_copyurl","dl_selectannotations","dl_annotations_tabs","dl_anno_view_tabs","dl_annotations","dl_graph","dl_svgcolor","dl_area","dl_colorbyarea","dl_rmsd","dl_buriedarea","dl_propbypercentout","dl_propbybfactor","dl_legend","dl_disttable"];for(let i in s){let n=s[i];t.cfg.notebook?$("#"+e.pre+n).hide():$("#"+e.pre+n).hasClass("ui-dialog-content")&&$("#"+e.pre+n).dialog("isOpen")&&$("#"+e.pre+n).dialog("close").remove()}t.cfg.notebook||this.resizeCanvas(t.htmlCls.WIDTH,t.htmlCls.HEIGHT,!0)}}class _s{constructor(e){this.icn3d=e}resetOrientation(){let e=this.icn3d;e.icn3dui;let t=!1;if(e.commands.length>0){let s=e.commands[0].split("|||");if(2==s.length){let i=JSON.parse(s[1]);e._zoomFactor=i.factor,e.mouseChange.x=i.mouseChange.x,e.mouseChange.y=i.mouseChange.y,e.quaternion._x=i.quaternion._x,e.quaternion._y=i.quaternion._y,e.quaternion._z=i.quaternion._z,e.quaternion._w=i.quaternion._w,t=!0}}t||(e._zoomFactor=1,e.mouseChange=new THREE.Vector2(0,0),e.quaternion=new THREE.Quaternion(0,0,0,1)),e.maxD=e.oriMaxD,e.center=e.oriCenter.clone(),"show"==e.ori_chemicalbinding?e.bSkipChemicalbinding=!1:"hide"==e.ori_chemicalbinding&&(e.bSkipChemicalbinding=!0)}rotateLeft(e){let t=this.icn3d,s=t.icn3dui,i=new THREE.Vector3(0,1,0),n=-e/180*Math.PI;t.bControlGl&&!s.bNode?i.applyQuaternion(window.cam.quaternion).normalize():i.applyQuaternion(t.cam.quaternion).normalize();let l=new THREE.Quaternion;l.setFromAxisAngle(i,-n);let r={};r.quaternion=l,r.update=!0,t.bControlGl&&!s.bNode?window.controls.update(r):t.controls.update(r),t.bRender&&t.drawCls.render()}rotateRight(e){let t=this.icn3d,s=t.icn3dui,i=new THREE.Vector3(0,1,0),n=e/180*Math.PI;t.bControlGl&&!s.bNode?i.applyQuaternion(window.cam.quaternion).normalize():i.applyQuaternion(t.cam.quaternion).normalize();let l=new THREE.Quaternion;l.setFromAxisAngle(i,-n);let r={};r.quaternion=l,r.update=!0,t.bControlGl&&!s.bNode?window.controls.update(r):t.controls.update(r),t.bRender&&t.drawCls.render()}rotateUp(e){this.icn3d.icn3dui,this.rotate_base(-e)}rotateDown(e){this.icn3d.icn3dui,this.rotate_base(e)}rotate_base(e){let t=this.icn3d,s=t.icn3dui,i=new THREE.Vector3(1,0,0),n=e/180*Math.PI;t.bControlGl&&!s.bNode?i.applyQuaternion(window.cam.quaternion).normalize():i.applyQuaternion(t.cam.quaternion).normalize();let l=new THREE.Quaternion;l.setFromAxisAngle(i,-n);let r={};r.quaternion=l,r.update=!0,t.bControlGl&&!s.bNode?window.controls.update(r):t.controls.update(r),t.bRender&&t.drawCls.render()}setRotation(e,t){let s=this.icn3d,i=s.icn3dui;s.bControlGl&&!i.bNode&&window.cam?e.applyQuaternion(window.cam.quaternion).normalize():s.cam&&e.applyQuaternion(s.cam.quaternion).normalize();let n=new THREE.Quaternion;n.setFromAxisAngle(e,-t);let l={};l.quaternion=n,l.update=!0,s.bControlGl&&!i.bNode&&window.controls?window.controls.update(l):s.controls&&s.controls.update(l),s.bRender&&s.drawCls.render()}translateLeft(e){this.icn3d.icn3dui,this.translate_base(-e,0)}translateRight(e){this.icn3d.icn3dui,this.translate_base(e,0)}translateUp(e){this.icn3d.icn3dui,this.translate_base(0,-e)}translateDown(e){this.icn3d.icn3dui,this.translate_base(0,e)}translate_base(e,t){let s=this.icn3d,i=s.icn3dui,n=new THREE.Vector2(0,0);n.x+=e/100,n.y+=t/100;let l={};l.mouseChange=n,l.update=!0,s.bControlGl&&!i.bNode?window.controls.update(l):s.controls.update(l),s.bRender&&s.drawCls.render()}zoominSelection(e){let t=this.icn3d,s=t.icn3dui,i={};if(i._zoomFactor=1/t._zoomFactor,i.update=!0,t.bControlGl&&!s.bNode?window.controls&&window.controls.update(i):t.controls&&t.controls.update(i),void 0===e&&(e=s.hashUtilsCls.hash2Atoms(t.hAtoms,t.atoms)),Object.keys(e).length>1){let s=t.applyCenterCls.centerAtoms(e);t.maxD=s.maxD,t.maxD<5&&(t.maxD=5),t.center=s.center,t.applyCenterCls.setCenter(t.center),t.cameraCls.setCamera()}}getTransformationStr(e){this.icn3d.icn3dui;let t={factor:1,mouseChange:{x:0,y:0},quaternion:{_x:0,_y:0,_z:0,_w:1}};return t.factor=parseFloat(e.factor).toPrecision(4),t.mouseChange.x=parseFloat(e.mouseChange.x).toPrecision(4),t.mouseChange.y=parseFloat(e.mouseChange.y).toPrecision(4),t.quaternion._x=parseFloat(e.quaternion._x).toPrecision(4),t.quaternion._y=parseFloat(e.quaternion._y).toPrecision(4),t.quaternion._z=parseFloat(e.quaternion._z).toPrecision(4),t.quaternion._w=parseFloat(e.quaternion._w).toPrecision(4),"1.0000"==t.factor&&(t.factor=1),"0.0000"==t.mouseChange.x&&(t.mouseChange.x=0),"0.0000"==t.mouseChange.y&&(t.mouseChange.y=0),"0.0000"==t.quaternion._x&&(t.quaternion._x=0),"0.0000"==t.quaternion._y&&(t.quaternion._y=0),"0.0000"==t.quaternion._z&&(t.quaternion._z=0),"1.0000"==t.quaternion._w&&(t.quaternion._w=1),JSON.stringify(t)}}class Ss{constructor(e){this.icn3d=e}saveFile(e,t,s){let i,n=this.icn3d,l=n.icn3dui;if("command"===t){let e=n.loadCmd?n.loadCmd+"\n":"";for(let t=0,s=n.commands.length;t'+""+document.getElementById(e).innerHTML+""}savePng(e,t,s){let i=this.icn3d,n=i.icn3dui;if(n.bNode)return"";let l=$("#"+e).width(),r=$("#"+e).height();s&&(r=l);let o=document.getElementById(e),a=o.getBBox(),d=o.cloneNode(!0);i.lineGraphCls.copyStylesInline(d,o);let c=document.createElement("CANVAS");c.width=l,c.height=r;let h=c.getContext("2d");h.clearRect(0,0,a.width,a.height);let p=this.getSvgXml(e,l,r,s),m=window.URL||window.webkitURL||window,u=new Blob([p],{type:"image/svg+xml;charset=utf-8"}),g=new Image;g.src=m.createObjectURL(u),g.onload=function(){if(h.drawImage(g,0,0),m.revokeObjectURL(this.src),n.utilsCls.isIE()){let e=c.msToBlob();e&&(saveAs(e,t),c.remove())}else c.toBlob((function(e){e&&(saveAs(e,t),c.remove())}))}}exportCustomAtoms(e){var t=this.icn3d;t.icn3dui;let s="",i=void 0!==t.defNames2Residues?Object.keys(t.defNames2Residues).sort():[];for(let n=0,l=i.length;n0)if(s){let s={};for(let e=0,l=t.length;e1,_=1,S="",A="",x={};for(let h in e){let e=r.atoms[h];if(s&&e.het)continue;if(e.structure!=S){a+=v,v="",_>1&&(a+="\nENDMDL\n"),w&&(a+="MODEL "+_+"\n");let t=n?"Mutated chain_residue "+Object.keys(n)+"; ":"";i||(a+=this.getPDBHeader(_-1,y,t,l)),S=e.structure,++_}else e.chain!=A&&(A&&(a+="TER\n"),A=e.chain);let p=e.chain+"_"+e.resi;if(n&&n.hasOwnProperty(p)){x.hasOwnProperty(p)||(a+=n[p],x[p]=1);continue}let m="";m+=e.het?"HETATM":"ATOM ",m+=h.toString().padStart(5," "),m+=" ";let u=e.name.trim();isNaN(u.substr(0,1))||(u=u.substr(1)+u.substr(0,1)),4==u.length?m+=u:(m+=" ",u=u.replace(/\*/g,"'"),"O1P"==u?u="OP1":"O2P"==u?u="OP2":"C5M"==u&&(u="C7 "),m+=u.padEnd(3," ")),m+=" ";let g=e.resn;if(m+=g.length<=3?g.padStart(3," "):g.substr(0,3),e.chain.length>=2){m+=e.chain.replace(/_/gi,"").substr(0,2)}else 1==e.chain.length?m+=" "+e.chain.substr(0,1):0==e.chain.length&&(m+=" A");let f=e.resi;!isNaN(f)&&e.chain.length>3&&!isNaN(e.chain.substr(3))&&(f=f-1+parseInt(e.chain.substr(3)));let b=parseInt(f);m+=b.toString().length<=4?b.toString().padStart(4," "):b.toString().substr(0,4);let C=e.resi.toString().substr(e.resi.toString().length-1,1);if(isNaN(C)?m+=C:m+=" ",m+=" ".padStart(3," "),m+=e.coord.x.toFixed(3).toString().padStart(8," "),m+=e.coord.y.toFixed(3).toString().padStart(8," "),m+=e.coord.z.toFixed(3).toString().padStart(8," "),t&&e.het){let t=1.5,s=0;"C"==e.elem?t=1.908:"N"==e.elem?t=1.824:"O"==e.elem?t=1.6612:"H"==e.elem?t=1.25:"S"==e.elem?t=2:"P"==e.elem?t=2.1:o.parasCls.vdwRadii.hasOwnProperty(e.elem)&&(t=o.parasCls.vdwRadii[e.elem]),void 0!==o.cfg.cid&&void 0!==e.crg?s=e.crg:d.hasOwnProperty(h)?s=1.38:c.hasOwnProperty(h)?s=-.595:o.parasCls.ionCharges.hasOwnProperty(e.elem)&&(s=o.parasCls.ionCharges[e.elem]),m+=s.toFixed(4).toString().padStart(8," "),m+=t.toFixed(4).toString().padStart(7," ")}else m+="1.00".padStart(6," "),m+=e.b?parseFloat(e.b).toFixed(2).toString().padStart(6," "):" ".padStart(6," "),m+=" ".padStart(10," "),m+=e.elem.padStart(2," "),m+=" ".padStart(2," ");if(e.het&&e.bonds.length>0){v+="CONECT"+h.toString().padStart(5," ");let t={};for(let s=0,i=e.bonds.length;s50?n.molTitle.substr(0,47)+"...":n.molTitle;-1!=e.indexOf('"')&&(e=""),s&&(e=s+e),l+="TITLE "+e+"\n"}return t&&t[r]&&(l+=t[r]),l}showTitle(){var e=this.icn3d,t=e.icn3dui;if(void 0!==e.molTitle&&""!==e.molTitle){let s=e.molTitle,i="black"==e.opts.background?t.htmlCls.GREYD:"black";if(void 0===e.inputid)e.molTitle.length>40&&(s=e.molTitle.substr(0,40)+"..."),$("#"+e.pre+"title").html(s);else if(void 0!==t.cfg.cid){let t=this.getLinkToStructureSummary();$("#"+e.pre+"title").html("PubChem CID "+e.inputid.toUpperCase()+": "+s)}else if(void 0!==t.cfg.align)s="VAST+ alignment of "+Object.keys(e.structures),$("#"+e.pre+"title").html(s);else if(void 0!==t.cfg.chainalign){s="Dynamic Structure Alignment of Chains: "+t.cfg.chainalign.split(","),$("#"+e.pre+"title").html(s)}else if(void 0!==t.cfg.mmdbafid){let t=Object.keys(e.structures);if(t.length>1)s="Multiple structures: "+t,$("#"+e.pre+"title").html(s);else if(1==t.length){let e=this.getLinkToStructureSummary();this.setStructureTitle(e,s,i)}}else{let e=this.getLinkToStructureSummary();this.setStructureTitle(e,s,i)}}else $("#"+e.pre+"title").html("")}setStructureTitle(e,t,s){var i=this.icn3d,n=i.icn3dui;i.molTitle.length>40&&(t=i.molTitle.substr(0,40)+"...");let l=i.inputid.toUpperCase(),r=isNaN(i.inputid)&&i.inputid.length>5?"AlphaFold ID":"PDB ID";if(-1!=i.inputid.indexOf("http")&&(r="Data from",e=i.inputid,l=i.inputid),n.cfg.refseqid&&(r="NCBI Protein Acc."),i.inputid&&i.inputid.substr(0,4)!=i.defaultPdbId)if(n.cfg.blast_rep_id){let e=n.cfg.oriQuery_id?n.cfg.oriQuery_id:n.cfg.query_id,s=n.cfg.oriBlast_rep_id?n.cfg.oriBlast_rep_id:n.cfg.blast_rep_id;e.length>20&&(e=e.substr(0,17)+"..."),l="Query: "+e+"; target: "+s,$("#"+i.pre+"title").html(l+", "+t)}else $("#"+i.pre+"title").html(r+" "+l+": "+t);else $("#"+i.pre+"title").html(t)}getLinkToStructureSummary(e){var t=this.icn3d,s=t.icn3dui;let i="https://www.ncbi.nlm.nih.gov/structure/?term=";if(i=void 0!==s.cfg.cid?"https://www.ncbi.nlm.nih.gov/pccompound/?term=":void 0!==s.cfg.refseqid?"https://www.ncbi.nlm.nih.gov/protein/":void 0!==s.cfg.afid?"https://alphafold.ebi.ac.uk/search/text/":Object.keys(t.structures).length>1?"https://www.ncbi.nlm.nih.gov/structure/?term=":s.htmlCls.baseUrl+"pdb/",void 0===t.inputid)i="https://www.ncbi.nlm.nih.gov/pccompound/?term="+t.molTitle;else{let n=t.inputid.split("_");1===n.length?(i+=t.inputid,e&&s.htmlCls.clickMenuCls.setLogCmd("link to "+t.inputid+": "+i,!1)):2===n.length&&(s.cfg.afid?i+=n[0]+" "+n[1]:i+=n[0]+" OR "+n[1],e&&s.htmlCls.clickMenuCls.setLogCmd("link to structures "+n[0]+" and "+n[1]+": "+i,!1))}return i}setEntrezLinks(e){var t=this.icn3d,s=t.icn3dui;let i,n=Object.keys(t.structures);if(1===n.length){i="https://www.ncbi.nlm.nih.gov/"+e+"/?term="+n[0],s.htmlCls.clickMenuCls.setLogCmd("Entrez "+e+" about PDB "+n[0]+": "+i,!1);let l=t.structures&&Object.keys(t.structures).length>0?"_blank":"_self";window.open(i,l)}else if(2===n.length){i="https://www.ncbi.nlm.nih.gov/"+e+"/?term="+n[0]+" OR "+n[1],s.htmlCls.clickMenuCls.setLogCmd("Entrez "+e+" about PDB "+n[0]+" OR "+n[1]+": "+i,!1);let l=t.structures&&Object.keys(t.structures).length>0?"_blank":"_self";window.open(i,l)}}}class As{constructor(e){this.icn3d=e}async shareLink(e,t){let s=this.icn3d,i=s.icn3dui,n=this.shareLinkUrl(),l=n.length>4e3||0!==n.indexOf("http");e&&(n+="&random="+parseInt(1e3*Math.random()));let r=Object.keys(s.structures).join("_");if(r==s.defaultPdbId&&(s.filename?r=s.filename:s.inputid&&(r=s.inputid)),e){if(t||s.bInputfile||l)return void s.saveFileCls.saveFile(r+"_icn3d_loadable.png","png")}else{if(s.bInputfile&&!s.bInputUrlfile)return void alert("Share Link does NOT work when the data are from custom files. Please save 'iCn3D PNG Image' in the File menu and open it in iCn3D.");if(l)return void alert("The url is more than 4000 characters and may not work. Please save 'iCn3D PNG Image' or 'State File' and open them in iCn3D.");i.htmlCls.clickMenuCls.setLogCmd("share link: "+n,!1)}let o=await this.getShareLinkPrms(n,e),a="Problem in getting shortened URL";if(void 0!==o.shortLink&&(a=o.shortLink,e)){let e=a.split("/"),t=e[e.length-1];s.saveFileCls.saveFile(r+"-"+t+".png","png");let i='\n\n",s.saveFileCls.saveFile(r+"-"+t+".html","html",i)}e&&void 0===o.shortLink&&s.saveFileCls.saveFile(r+"_icn3d_loadable.png","png");let d=a.split("page.link/");2==d.length&&(a="https://structure.ncbi.nlm.nih.gov/icn3d/share.html?"+d[1]),$("#"+s.pre+"ori_url").val(n),$("#"+s.pre+"short_url").val(a),$("#"+s.pre+"short_url_title").val(a+"&t="+s.yournote),e||i.htmlCls.dialogCls.openDlg("dl_copyurl","Copy a Share Link URL")}getShareLinkPrms(e,t){let s=this.icn3d,i=s.icn3dui;return new Promise((function(n,l){$.ajax({url:"https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=AIzaSyBxl9CgM0dY5lagHL4UOhEpLWE1fuwdnvc",type:"POST",data:{longDynamicLink:"https://icn3d.page.link/?link="+encodeURIComponent(e)},dataType:"json",success:function(e){n(e)},error:function(n,l,r){let o="Problem in getting shortened URL";$("#"+s.pre+"ori_url").val(e),$("#"+s.pre+"short_url").val(o),$("#"+s.pre+"short_url_title").val(o+"&t="+s.yournote),t||i.htmlCls.dialogCls.openDlg("dl_copyurl","Copy a Share Link URL")}})}))}shareLinkUrl(e){let t=this.icn3d,s=t.icn3dui,i=s.htmlCls.baseUrl+"icn3d/full.html?";if(s.cfg.bSidebyside&&(i=s.htmlCls.baseUrl+"icn3d/full2.html?"),t.bInputUrlfile){i=window.location.href.split("?")[0]+"?"+t.inputurl+"&"}let n,l={};for(let e in t.cfg){let s=t.cfg[e];"inpara"!==e&&"command"!==e&&"usepdbnum"!==e&&"date"!==e&&"v"!==e&&void 0!==s&&("width"===e&&"100%"===s||"height"===e&&"100%"===s||"resize"===e&&!0===s||"showmenu"===e&&!0===s||"showtitle"===e&&!0===s||"showcommand"===e&&!0===s||"mobilemenu"===e&&!1===s||"showanno"===e&&!1===s||"showseq"===e&&!1===s||"showalignseq"===e&&!1===s||"show2d"===e&&!1===s||"showsets"===e&&!1===s||"rotate"===e&&"right"===s||"command"!==e&&("options"===e?Object.keys(s).length>0&&(l[e]=JSON.stringify(s)):!0===s?l[e]=1:!1===s?l[e]=0:""!==s&&(l[e]=s)))}t.bAfMem?l.afmem="on":(s.cfg.afid||1==Object.keys(t.structures).length&&Object.keys(t.structures)[0].length>5)&&(l.afmem="off");let r=-1;void 0!==s.cfg.inpara&&(r=s.cfg.inpara.indexOf("&command=")),n=-1!==r?s.cfg.inpara.substr(0,r):s.cfg.inpara;let o=!1;if(!t.bInputUrlfile){let e=n&&n.substr(1)?n.substr(1).split("&"):[];for(let t=0,s=e.length;tp){u=t.commands[p].split("|||")[0].split("&command=")[0].trim(),-1!==u.indexOf(f)&&++b}let C,y=p+1,v="";for(let e=t.commands.length;y0&&b%2==0&&u!==f&&(i+=f+"; "),i+=u+"|||"+t.transformCls.getTransformationStr(m),g+=u+"|||"+t.transformCls.getTransformationStr(m)+"\n"),g=g.replace(/!/g,Object.keys(t.structures)[0]+"_"),(t.bInputfile&&!t.bInputUrlfile||t.bInputUrlfile&&t.bAppend||i.length>4e3)&&(i=g),void 0!==t.structures&&1==Object.keys(t.structures).length&&void 0!==t.inputid&&(C=Object.keys(t.structures)[0],i=i.replace(new RegExp(C+"_","g"),"!")),void 0!==s.cfg.blast_rep_id&&(i=i.replace(new RegExp("blast_rep_id=!","g"),"blast_rep_id="+C+"_")),i}getPngText(){let e,t=this.icn3d;t.icn3dui;let s="";if(t.bInputfile)e=this.shareLinkUrl(true),"http"==e.substr(0,4)?s+="\nShare Link: "+e:(s+="\nStart of type file======\n",s+=t.InputfileType+"\n",s+="End of type file======\n",s+="Start of data file======\n",s+=t.saveFileCls.getAtomPDB(t.atoms),s+="End of data file======\n",s+="Start of state file======\n",s+=e+"\n",s+="End of state file======\n");else{e=this.shareLinkUrl(),e.length>4e3||0!==e.indexOf("http")?(e=this.shareLinkUrl(true),s+="\nStart of state file======\n",s+=e+"\n",s+="End of state file======\n"):s+="\nShare Link: "+e}return s=s.replace(/!/g,Object.keys(t.structures)[0]+"_"),s}}class xs{constructor(e){this.icn3d=e}setThichknessFor3Dprint(){let e=this.icn3d,t=e.icn3dui;e.lineRadius=1,e.coilWidth=1.2,e.cylinderRadius=.8,e.crosslinkRadius=.8,e.traceRadius=1,e.dotSphereScale=.6,e.sphereRadius=1.5,e.ribbonthickness=1,e.helixSheetWidth=2,e.nucleicAcidWidth=1.4,t.htmlCls.setHtmlCls.setCookieForThickness()}prepareFor3Dprint(){let e=this.icn3d,t=e.icn3dui;if(e.bShowHighlight=!1,e.hlObjectsCls.removeHlObjects(),e.bDashedLines=!1,e.bSetThickness||void 0!==t.cfg.cid||this.setThichknessFor3Dprint(),void 0!==e.lines.hbond)for(let t=0,s=e.lines.hbond.length;tt.substr(0,s))return 1;if(e.substr(0,s)==t.substr(0,s)){if(parseInt(e.substr(s+1))parseInt(t.substr(i+1)))return 1;if(parseInt(e.substr(s+1))==parseInt(t.substr(i+1)))return 0}}})),i="";for(let e=0,t=s.length;e"}let n=e.inputid?e.inputid:"custom";e.saveFileCls.saveFile(n+"_residues.txt","html",i)}addStabilizer(){let e=this.icn3d,t=e.icn3dui,s=3.5;if(Object.keys(e.dAtoms).length>0){let i,n={},l=12.25,r=3.2*3.2;for(let t in e.dAtoms){let s=e.atoms[t];!e.nucleotides.hasOwnProperty(s.serial)||"N1"!==s.name&&"N2"!==s.name&&"N3"!==s.name&&"N4"!==s.name&&"N6"!==s.name&&"O2"!==s.name&&"O6"!==s.name||(i=s.structure+"_"+s.chain+"_"+s.resi+"_"+s.name,n[i]=s)}let o=Object.keys(n),a=o.length;void 0===e.pairArray&&(e.pairArray=[]);for(let t=0;ts)continue;let h=Math.abs(n[a].coord.y-n[d].coord.y);if(h>s)continue;let p=Math.abs(n[a].coord.z-n[d].coord.z);if(p>s)continue;let m=c*c+h*h+p*p;m>l||ms+1||rs+2||rs+4||r0&&o.length>0)if(a){let t=parseInt((r.length+.5)/2);e.pairArray.push(o[0]),e.pairArray.push(r[t])}else{let t=10,s=parseInt(r.length/(t+1));for(let i=0,n=o.length;i1&&t.bAssembly&&(t.threshbox=180/Math.pow(t.biomtMatrices.length,.33),t.applyMapCls.removeSurfaces(),t.applyMapCls.applySurfaceOptions(),t.applyMapCls.removeMaps(),t.applyMapCls.applyMapOptions(),t.applyMapCls.removeEmmaps(),t.applyMapCls.applyEmmapOptions());let s=this.saveStlFile(),i=t.inputid?t.inputid:"custom";if(t.saveFileCls.saveFile(i+e+".stl","binary",s),void 0!==t.biomtMatrices&&t.biomtMatrices.length>1&&t.bAssembly&&Object.keys(t.dAtoms).length*t.biomtMatrices.length>t.maxAtoms3DMultiFile){alert(t.biomtMatrices.length+" files will be generated for this assembly. Please merge these files using some software and 3D print the merged file.");let n=new THREE.Matrix4;n.identity();let l=1;for(let r=0;r1&&t.bAssembly&&(t.threshbox=180/Math.pow(t.biomtMatrices.length,.33),t.applyMapCls.removeSurfaces(),t.applyMapCls.applySurfaceOptions(),t.applyMapCls.removeMaps(),t.applyMapCls.applyMapOptions(),t.applyMapCls.removeEmmaps(),t.applyMapCls.applyEmmapOptions());let s=this.saveVrmlFile(),i=t.inputid?t.inputid:"custom";if(t.saveFileCls.saveFile(i+e+".wrl","text",s),void 0!==t.biomtMatrices&&t.biomtMatrices.length>1&&t.bAssembly&&Object.keys(t.dAtoms).length*t.biomtMatrices.length>t.maxAtoms3DMultiFile){alert(t.biomtMatrices.length+" files will be generated for this assembly. Please merge these files using some software and 3D print the merged file.");let i=new THREE.Matrix4;i.identity();let n=1;for(let l=0;l7e4)return alert("Please display a subset of the structure to export 3D files. Then merge the files for 3D printing..."),[""];t.threeDPrintCls.prepareFor3Dprint();let i=0;i+=this.getFaceCnt(t.mdl),i+=this.getFaceCnt(t.mdl_ghost);let n=[],l=new Uint8Array(84),r="STL file for the structure(s) ",o=Object.keys(t.structures);for(let e=0,t=o.length;e80&&(r=r.substr(0,80));for(let e=0;e<80;++e)e1&&t.bAssembly&&Object.keys(t.dAtoms).length*t.biomtMatrices.length<=t.maxAtoms3DMultiFile?this.updateArray(l,s.convertTypeCls.passInt32([i*t.biomtMatrices.length]),80):this.updateArray(l,s.convertTypeCls.passInt32([i]),80),n.push(new Blob([l],{type:"application/octet-stream"})),n=this.processStlMeshGroup(t.mdl,n,e),n=this.processStlMeshGroup(t.mdl_ghost,n,e),void 0!==t.biomtMatrices&&t.biomtMatrices.length>1&&t.bAssembly&&Object.keys(t.dAtoms).length*t.biomtMatrices.length<=t.maxAtoms3DMultiFile){let e=new THREE.Matrix4;e.identity();for(let s=0;s5e4)return alert("Please display a subset of the structure to export 3D files. Then merge the files for 3D printing..."),[""];t.threeDPrintCls.prepareFor3Dprint();let s=[];s.push("#VRML V2.0 utf8\n");let i=0,n=this.processVrmlMeshGroup(t.mdl,s,i,e);if(s=n.vrmlStrArray,i=n.vertexCnt,n=this.processVrmlMeshGroup(t.mdl_ghost,s,i,e),s=n.vrmlStrArray,i=n.vertexCnt,void 0!==t.biomtMatrices&&t.biomtMatrices.length>1&&t.bAssembly&&Object.keys(t.dAtoms).length*t.biomtMatrices.length<=t.maxAtoms3DMultiFile){let e=new THREE.Matrix4;e.identity();for(let l=0;l0?h.z=-1:h.z=1,s.cam===s.perspectiveCamera?(s.cam_z>0?h.z=-1:h.z=1,h.unproject(s.cam),s.raycaster.set(s.cam.position,h.sub(s.cam.position).normalize())):s.cam===s.orthographicCamera&&(s.cam_z>0?h.z=1:h.z=-1,h.unproject(s.cam),s.raycaster.set(h,new THREE.Vector3(0,0,-1).transformDirection(s.cam.matrixWorld)));let p=this.isIntersect(s.objects,s.mdl,t,d,c);p||(p=this.isIntersect(s.objects_ghost,s.mdl_ghost,t,d,c))}isIntersect(e,t,s,i,n){let l=this.icn3d;l.icn3dui;let r=l.raycaster.intersectObjects(e),o=!1,a=t.position;if(r.length>0){r[0].point.sub(a);let e=l.rayThreshold,t=this.getAtomsFromPosition(r[0].point,e);for(;!t&&e<10;)e+=.5,t=this.getAtomsFromPosition(r[0].point,e);t?(o=!0,l.pickpair?s&&(l.pAtomNum%2==0?l.pAtom=t:l.pAtom2=t,++l.pAtomNum):l.pAtom=t,s?l.pickingCls.showPicking(t):l.pickingCls.showPicking(t,i,n)):console.log("No atoms were found in 10 andstrom range")}return o}getAtomsFromPosition(e,t){let s,i=this.icn3d,n=i.icn3dui;for(s in null==t&&(t=1),i.dAtoms){let l=i.atoms[s];if(i.ions.hasOwnProperty(s)&&"sphere"===i.opts.ions){let s=n.parasCls.vdwRadii[l.elem.toUpperCase()];if(Math.abs(l.coord.x-e.x)-s>t)continue;if(Math.abs(l.coord.y-e.y)-s>t)continue;if(Math.abs(l.coord.z-e.z)-s>t)continue}else{if(l.coord.xe.x+t)continue;if(l.coord.ye.y+t)continue;if(l.coord.ze.z+t)continue}return l}return null}}class Rs{constructor(e){this.icn3d=e}setControl(){let e=this.icn3d,t=e.icn3dui;if(t.bNode)return;let s=this;e.WIDTH=e.container.width(),e.HEIGHT=e.container.height(),e.applyCenterCls.setWidthHeight(e.WIDTH,e.HEIGHT),e._zoomFactor=1,e.mouseChange=new THREE.Vector2(0,0),e.quaternion=new THREE.Quaternion(0,0,0,1),e.container.bind("contextmenu",(function(e){e.preventDefault()})),e.typetext=!1,$(document).bind("keyup",(function(t){16===t.keyCode&&(e.bShift=!1),17!==t.keyCode&&224!==t.keyCode&&91!==t.keyCode||(e.bCtrl=!1)})),$("input[type=text], textarea").focus((function(){e.typetext=!0})),$("input[type=text], textarea").blur((function(){e.typetext=!1})),$(document).bind("keydown",(function(s){if((s.shiftKey||16===s.keyCode)&&(e.bShift=!0),(s.ctrlKey||17===s.keyCode||224===s.keyCode||91===s.keyCode)&&(e.bCtrl=!0),!e.bControlGl&&!e.controls||e.bControlGl&&!window.controls)return;e.bStopRotate=!0;let i=e.bShift?90:5;if(!e.typetext)if(90===s.keyCode){let s={};e.bControlGl&&!t.bNode?window.cam===e.perspectiveCamera?s._zoomFactor=.9:window.cam===e.orthographicCamera&&(e._zoomFactor<.1?e._zoomFactor=.1:e._zoomFactor>1&&(e._zoomFactor=1),s._zoomFactor=.8*e._zoomFactor,s._zoomFactor<.1&&(s._zoomFactor=.1)):e.cam===e.perspectiveCamera?s._zoomFactor=.9:e.cam===e.orthographicCamera&&(e._zoomFactor<.1?e._zoomFactor=.1:e._zoomFactor>1&&(e._zoomFactor=1),s._zoomFactor=.8*e._zoomFactor,s._zoomFactor<.1&&(s._zoomFactor=.1)),s.update=!0,e.bControlGl&&!t.bNode?window.controls.update(s):e.controls.update(s),e.bRender&&e.drawCls.render()}else if(88===s.keyCode){let s={};e.bControlGl&&!t.bNode?window.cam===e.perspectiveCamera?s._zoomFactor=1.03:window.cam===e.orthographicCamera&&(e._zoomFactor>10?e._zoomFactor=10:e._zoomFactor<1&&(e._zoomFactor=1),s._zoomFactor=1.01*e._zoomFactor,s._zoomFactor>10&&(s._zoomFactor=10)):e.cam===e.perspectiveCamera?s._zoomFactor=1.03:e.cam===e.orthographicCamera&&(e._zoomFactor>10?e._zoomFactor=10:e._zoomFactor<1&&(e._zoomFactor=1),s._zoomFactor=1.01*e._zoomFactor,s._zoomFactor>10&&(s._zoomFactor=10)),s.update=!0,e.bControlGl&&!t.bNode?window.controls.update(s):e.controls.update(s),e.bRender&&e.drawCls.render()}else if(76===s.keyCode){let t=new THREE.Vector3(0,1,0),s=-i/180*Math.PI;e.transformCls.setRotation(t,s)}else if(74===s.keyCode){let t=new THREE.Vector3(0,1,0),s=i/180*Math.PI;e.transformCls.setRotation(t,s)}else if(73===s.keyCode){let t=new THREE.Vector3(1,0,0),s=-i/180*Math.PI;e.transformCls.setRotation(t,s)}else if(77===s.keyCode){let t=new THREE.Vector3(1,0,0),s=i/180*Math.PI;e.transformCls.setRotation(t,s)}else 65===s.keyCode&&Object.keys(e.structures).length>1&&e.alternateCls.alternateWrapper()})),e.container.bind("mouseup",(function(t){e.isDragging=!1})),e.container.bind("touchend",(function(t){e.isDragging=!1})),e.container.bind("mousedown",(function(s){if(e.isDragging=!0,e.scene){if(e.bStopRotate=!0,e.pk&&(s.altKey||s.ctrlKey||s.shiftKey||18===s.keyCode||16===s.keyCode||17===s.keyCode||224===s.keyCode||91===s.keyCode)){e.highlightlevel=e.pk;let t=!0;e.rayCls.rayCaster(s,t)}e.bControlGl&&!t.bNode?(window.controls.handleResize(),window.controls.update()):(e.controls.handleResize(),e.controls.update()),e.bRender&&e.drawCls.render()}})),e.container.bind("touchstart",(function(s){if(s.preventDefault(),e.isDragging=!0,!e.scene)return;e.bStopRotate=!0,$("#"+e.pre+"popup").hide();e.rayCls.rayCaster(s,!0),e.bControlGl&&!t.bNode?(window.controls.handleResize(),window.controls.update()):(e.controls.handleResize(),e.controls.update()),e.bRender&&e.drawCls.render()})),e.container.bind("mousemove touchmove",(function(e){s.mouseMove(e)})),e.container.bind("mousewheel",(function(s){s.preventDefault(),e.scene&&(e.bStopRotate=!0,e.bControlGl&&!t.bNode?(window.controls.handleResize(),window.controls.update()):(e.controls.handleResize(),e.controls.update()),e.bRender&&e.drawCls.render())})),e.container.bind("DOMMouseScroll",(function(s){s.preventDefault(),e.scene&&(e.bStopRotate=!0,e.bControlGl&&!t.bNode?(window.controls.handleResize(),window.controls.update()):(e.controls.handleResize(),e.controls.update()),e.bRender&&e.drawCls.render())}))}mouseMove(e){let t=this.icn3d,s=t.icn3dui;if(s.bNode)return;if(e.preventDefault(),!t.scene)return;$("#"+t.pre+"popup").hide();if(t.rayCls.rayCaster(e,!1),t.bControlGl&&!s.bNode){window.controls.handleResize(),window.controls.update();for(let e in window.icn3duiHash){let t=window.icn3duiHash[e].icn3d;t.bRender&&t.drawCls.render()}}else t.controls.handleResize(),t.controls.update(),t.bRender&&t.drawCls.render()}}class Es{constructor(e){this.icn3d=e}showPicking(e,t,s){let i=this.icn3d,n=i.icn3dui;if(void 0!==n.cfg.cid&&0!=i.pk&&(i.pk=1),i.highlightlevel=i.pk,this.showPickingBase(e,t,s),0!=i.pk)if(void 0!==t&&void 0!==s){null!=n.cfg.showmenu&&1==n.cfg.showmenu&&(s+=n.htmlCls.MENU_HEIGHT);let l=1==i.pk?e.resn+e.resi+"@"+e.name:e.resn+e.resi;void 0!==i.structures&&Object.keys(i.structures).length>1?(l=e.structure+"_"+e.chain+" "+l,$("#"+i.pre+"popup").css("width","160px")):$("#"+i.pre+"popup").css("width","80px"),$("#"+i.pre+"popup").html(l),$("#"+i.pre+"popup").css("top",s).css("left",t+20).show()}else{i.hlUpdateCls.updateHlAll();let t={};t.factor=i._zoomFactor,t.mouseChange=i.mouseChange,t.quaternion={},t.quaternion._x=parseFloat(i.quaternion._x).toPrecision(5),t.quaternion._y=parseFloat(i.quaternion._y).toPrecision(5),t.quaternion._z=parseFloat(i.quaternion._z).toPrecision(5),t.quaternion._w=parseFloat(i.quaternion._w).toPrecision(5),n.htmlCls.clickMenuCls.setLogCmd("pickatom "+e.serial,!0),i.selectionCls.saveSelInCommand(),i.bSphereCalc=!1,i.bHbondCalc=!1}}showPickingBase(e,t,s){this.icn3d.icn3dui,void 0===t&&void 0===s&&this.showPickingHilight(e)}showPickingHilight(e){let t=this.icn3d,s=t.icn3dui;if(t.bShift||t.bCtrl||t.hlObjectsCls.removeHlObjects(),t.pickedAtomList={},1===t.pk)t.pickedAtomList[e.serial]=1;else if(2===t.pk){let s=e.structure+"_"+e.chain+"_"+e.resi;t.pickedAtomList=t.residues[s]}else if(3===t.pk)t.pickedAtomList=this.selectStrandHelixFromAtom(e);else if(4===t.pk)t.pickedAtomList=this.select3ddomainFromAtom(e);else if(5===t.pk){let s=e.structure+"_"+e.chain;t.pickedAtomList=t.chains[s]}0===t.pk?t.bShowHighlight=!1:t.bShowHighlight=!0;let i=Object.keys(t.hAtoms).length==Object.keys(t.atoms).length?{}:s.hashUtilsCls.intHash(t.hAtoms,t.pickedAtomList),n=Object.keys(i).length;if(t.bShift||t.bCtrl)if(t.bShift){if(void 0===t.prevPickedAtomList)t.hAtoms=s.hashUtilsCls.unionHash(t.hAtoms,t.pickedAtomList);else{let e=t.firstAtomObjCls.getFirstAtomObj(t.prevPickedAtomList),i=t.firstAtomObjCls.getFirstAtomObj(t.pickedAtomList);if(e.structure+"_"+e.chain!=i.structure+"_"+i.chain)t.hAtoms=s.hashUtilsCls.unionHash(t.hAtoms,t.pickedAtomList);else{let e;e=s.hashUtilsCls.unionHash(e,t.prevPickedAtomList),e=s.hashUtilsCls.unionHash(e,t.pickedAtomList);let i=t.firstAtomObjCls.getFirstAtomObj(e),n=t.firstAtomObjCls.getLastAtomObj(e);for(let e=i.serial;e<=n.serial;++e)t.hAtoms[e]=1}}t.prevPickedAtomList=s.hashUtilsCls.cloneHash(t.pickedAtomList)}else t.bCtrl&&(t.hAtoms=n>0?s.hashUtilsCls.exclHash(t.hAtoms,t.pickedAtomList):s.hashUtilsCls.unionHash(t.hAtoms,t.pickedAtomList));else t.hAtoms=s.hashUtilsCls.cloneHash(t.pickedAtomList);t.hlObjectsCls.removeHlObjects(),t.hlObjectsCls.addHlObjects()}select3ddomainFromAtom(e){let t,s=this.icn3d,i=s.icn3dui,n=e.structure+"_"+e.chain,l=n+"_"+e.resi;for(let e in s.tddomains){let i=e.indexOf("_3d_domain");if(e.substr(0,i)==n&&-1!==Object.keys(s.tddomains[e]).indexOf(l)){t=e;break}}let r={};for(let e in s.tddomains[t])r=i.hashUtilsCls.unionHash(r,s.residues[e]);return r}selectStrandHelixFromAtom(e){let t=this.icn3d,s=t.icn3dui,i=e,n=e,l={},r=i.resi;if(!i.ssbegin&&!isNaN(i.resi)){for(let e=i.resi-1;e>0;--e){let s=i.structure+"_"+i.chain+"_"+e;if(!t.residues.hasOwnProperty(s))break;let n=t.firstAtomObjCls.getFirstCalphaAtomObj(t.residues[s]);if(r=n.resi,"coil"!==i.ss&&n.ss===i.ss&&n.ssbegin||"coil"===i.ss&&n.ss!==i.ss){"coil"===i.ss&&n.ss!==i.ss&&(r=parseInt(n.resi)+1);break}}for(let e=r;e<=i.resi;++e){let n=i.structure+"_"+i.chain+"_"+e;l=s.hashUtilsCls.unionHash(l,s.hashUtilsCls.hash2Atoms(t.residues[n],t.atoms))}}let o=n.resi,a=t.firstAtomObjCls.getLastAtomObj(t.chains[n.structure+"_"+n.chain]).resi;for(let e=parseInt(n.resi)+1;e<=parseInt(a);++e){let s=n.structure+"_"+n.chain+"_"+e;if(!t.residues.hasOwnProperty(s))break;let i=t.firstAtomObjCls.getFirstCalphaAtomObj(t.residues[s]);if(o=i.resi,"coil"!==n.ss&&i.ss===n.ss&&i.ssend||"coil"===n.ss&&i.ss!==n.ss){"coil"!==n.ss||i.ss===n.ss||isNaN(i.resi)||(o=i.resi-1);break}}for(let e=parseInt(n.resi)+1;e<=parseInt(o);++e){let i=n.structure+"_"+n.chain+"_"+e;l=s.hashUtilsCls.unionHash(l,s.hashUtilsCls.hash2Atoms(t.residues[i],t.atoms))}return l}}class Is{constructor(e){this.icn3d=e,this.xrSessionIsGranted=!1}createButton(e,t){let s=this.icn3d,i=s.icn3dui;t&&console.error('THREE.VRButton: The "options" parameter has been removed. Please set the reference space type via renderer.xr.setReferenceSpaceType() instead.');const n=document.createElement("button");function l(){n.style.display="",n.style.cursor="auto",n.style.left="calc(33% - 75px)",n.style.width="150px",n.onmouseenter=null,n.onmouseleave=null,n.onclick=null}let r=this;if("xr"in navigator)return n.id=i.pre+"VRButton",n.style.display="none",(o=n).style.position="absolute",o.style.bottom="20px",o.style.padding="12px 6px",o.style.border="1px solid #fff",o.style.borderRadius="4px",o.style.background="#000",o.style.color="#f8b84e",o.style.font="bold 13px sans-serif",o.style.textAlign="center",o.style.opacity="0.8",o.style.outline="none",o.style.zIndex="999",navigator.xr.isSessionSupported("immersive-vr").then((function(t){t?function(){let t=null;async function i(s){s.addEventListener("end",l),await e.xr.setSession(s),n.textContent="EXIT VR",t=s}function l(){s.transformCls.resetOrientation(),s.bVr=!1,s.drawCls.draw(),t.removeEventListener("end",l),n.textContent="ENTER VR",t=null}n.style.display="",n.style.cursor="pointer",n.style.left="calc(33% - 50px)",n.style.width="100px",n.textContent="ENTER VR",n.onmouseenter=function(){n.style.opacity="1.0"},n.onmouseleave=function(){n.style.opacity="0.8"},n.onclick=function(){if(s.bImpo=!1,s.bVr=!0,s.drawCls.draw(s.bVr),null===t){const e={optionalFeatures:["local-floor","bounded-floor","hand-tracking","layers"]};navigator.xr.requestSession("immersive-vr",e).then(i)}else t.end()}}():(l(),n.style.display="none"),t&&r.xrSessionIsGranted&&n.click()})).catch((function(e){l(),console.warn("Exception when trying to call xr.isSessionSupported",e),n.style.display="none"})),n;return document.createElement("span");var o}registerSessionGrantedListener(){"xr"in navigator&&navigator.xr.addEventListener("sessiongranted",(()=>{this.xrSessionIsGranted=!0}))}}class Ts{constructor(e){this.icn3d=e,this.xrSessionIsGranted=!1}createButton(e,t={}){let s=this.icn3d,i=s.icn3dui;const n=document.createElement("button");function l(){n.style.display="",n.style.cursor="auto",n.style.left="calc(66% - 50px)",n.style.width="150px",n.onmouseenter=null,n.onmouseleave=null,n.onclick=null}function r(e){e.style.position="absolute",e.style.bottom="20px",e.style.padding="12px 6px",e.style.border="1px solid #fff",e.style.borderRadius="4px",e.style.background="#000",e.style.color="#f8b84e",e.style.font="bold 13px sans-serif",e.style.textAlign="center",e.style.opacity="0.8",e.style.outline="none",e.style.zIndex="999"}if(i.utilsCls.isAndroid()&&i.utilsCls.isChrome()){if("xr"in navigator)return n.id=i.pre+"ARButton",n.style.display="none",r(n),navigator.xr.isSessionSupported("immersive-ar").then((function(i){i?function(){if(void 0===t.domOverlay){const e=document.createElement("div");e.style.display="none",document.body.appendChild(e);const s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("width",38),s.setAttribute("height",38),s.style.position="absolute",s.style.right="20px",s.style.top="20px",s.addEventListener("click",(function(){i.end()})),e.appendChild(s);const n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d","M 12,12 L 28,28 M 28,12 12,28"),n.setAttribute("stroke","#fff"),n.setAttribute("stroke-width",2),s.appendChild(n),void 0===t.optionalFeatures&&(t.optionalFeatures=[]),t.optionalFeatures.push("dom-overlay"),t.domOverlay={root:e}}let i=null;async function l(s){s.addEventListener("end",r),e.xr.setReferenceSpaceType("local"),await e.xr.setSession(s),n.textContent="STOP AR",t.domOverlay.root.style.display="",i=s}function r(){s.transformCls.resetOrientation(),s.bAr=!1,s.drawCls.draw(),i.removeEventListener("end",r),n.textContent="START AR",t.domOverlay.root.style.display="none",i=null}n.style.display="",n.style.cursor="pointer",n.style.left="calc(66% - 50px)",n.style.width="100px",n.textContent="START AR",n.onmouseenter=function(){n.style.opacity="1.0"},n.onmouseleave=function(){n.style.opacity="0.8"},n.onclick=function(){s.bImpo=!1,s.opts.background="transparent",s.bAr=!0,s.drawCls.draw(s.bAr),null===i?navigator.xr.requestSession("immersive-ar",t).then(l):i.end()}}():(l(),n.style.display="none")})).catch((function(e){l(),console.warn("Exception when trying to call xr.isSessionSupported",e),n.style.display="none"})),n;return document.createElement("span")}return n.id=i.pre+"ARButton",n.style.display="none",r(n),l(),n.style.display="none",n}}class Ms{constructor(e){let t,s,i,n=e;if(this.icn3dui=e,this.id=this.icn3dui.pre+"canvas",this.pre=this.icn3dui.pre,this.container=$("#"+this.id),this.oriContainer=$("#"+this.id),this.bControlGl=!1,this.maxatomcnt=1e5,this.overdraw=0,this.bDrawn=!1,this.bOpm=!1,this.crossstrucinter=0,this.bSecondaryStructure=!1,this.bHighlight=1,this.renderOrderPicking=-1,this.bInitial=!0,this.bDoublecolor=!1,this.originSize=1,this.ALTERNATE_STRUCTURE=-1,this.bUsePdbNum=!0,!this.icn3dui.bNode){let e=document.createElement("canvas");t=!(!window.WebGLRenderingContext||!e.getContext("webgl")&&!e.getContext("experimental-webgl")),e.remove(),e=document.createElement("canvas"),s=!(!window.WebGLRenderingContext||!e.getContext("webgl2")),e.remove(),i="xr"in navigator,t?(s&&i?(this.renderer=new THREE.WebGLRenderer({canvas:this.oriContainer.get(0),antialias:!0,preserveDrawingBuffer:!0,sortObjects:!1,alpha:!0}),this.renderer.xr.enabled=!0):this.renderer=new THREE.WebGL1Renderer({canvas:this.oriContainer.get(0),antialias:!0,preserveDrawingBuffer:!0,sortObjects:!1,alpha:!0}),this.overdraw=0):alert("Currently your web browser has a problem on WebGL. If you are using Chrome, open a new tab for the same URL and WebGL may work again.")}this.frac=new THREE.Color(.1,.1,.1),this.shininess=40,this.emissive=1118481,this.light1=.6,this.light2=.4,this.light3=.2,this.lineRadius=.1,this.coilWidth=.3,this.cylinderRadius=.4,this.crosslinkRadius=.4,this.traceRadius=.4,this.dotSphereScale=.3,this.sphereRadius=1.5,this.cylinderHelixRadius=1.6,this.ribbonthickness=.2,this.helixSheetWidth=1.3,this.nucleicAcidWidth=.8,this.scaleFactor=1,this.labelScale=1,this.resizeRatioX=1,this.resizeRatioY=1,this.bImpo=!0,this.bInstanced=!0,this.chainMissingResidueArray={},this._zoomFactor=1,this.transparentRenderOrder=!1,this.AFUniprotVersion="v4",this.defaultPdbId="stru",this.icn3dui.bNode||(s&&i?(this.bExtFragDepth=!0,this.bImpo=!0,this.bInstanced=!0):(this.bExtFragDepth=this.renderer.extensions.get("EXT_frag_depth"),this.bExtFragDepth?console.log("EXT_frag_depth is supported. All spheres and cylinders are drawn using shaders."):(this.bImpo=!1,console.log("EXT_frag_depth is NOT supported. All spheres and cylinders are drawn using geometry.")),this.bInstanced=this.renderer.extensions.get("ANGLE_instanced_arrays"),this.bInstanced?console.log("ANGLE_instanced_arrays is supported. Assembly is drawn with one copy of the asymmetric unit using hardware instancing."):console.log("ANGLE_instanced_arrays is NOT supported. Assembly is drawn by making copies of the asymmetric unit."))),this.posArray=new Array,this.colorArray=new Array,this.pos2Array=new Array,this.color2Array=new Array,this.radiusArray=new Array,this.posArraySphere=new Array,this.colorArraySphere=new Array,this.radiusArraySphere=new Array,this.axis=!1,this.pk=1,this.highlightlevel=1,this.pickpair=!1,this.pAtomNum=0,this.pAtom=void 0,this.pAtom2=void 0,this.bCtrl=!1,this.bShift=!1,this.bStopRotate=!1,this.bCalphaOnly=!1,this.bConsiderNeighbors=!1,this.bShowCrossResidueBond=!0,this.bExtrude=!0,this.effects={none:this.renderer},this.maxD=500,this.oriMaxD=this.maxD,this.cam_z=2*this.maxD,this.commands=[],this.optsHistory=[],this.logs=[],this.bRender=!0,this.hColor=new THREE.Color(16777011),this.sphereGeometry=new THREE.SphereGeometry(1,32,32),this.boxGeometry=new THREE.BoxGeometry(1,1,1),this.cylinderGeometry=new THREE.CylinderGeometry(1,1,1,32,1),this.cylinderGeometryOutline=new THREE.CylinderGeometry(1,1,1,32,1,!0),this.axisDIV=15,this.strandDIV=6,this.tubeDIV=8,this.nucleicAcidStrandDIV=6,this.linewidth=1,this.hlLineRadius=.1,this.threshbox=180,this.maxAtoms3DMultiFile=4e4,this.tsHbond=3.8,this.tsIonic=6,this.tsContact=4,this.tsHalogen=3.8,this.tsPication=6,this.tsPistacking=5.5,this.LABELSIZE=30,this.rayThreshold=.5,this.colorBlackbkgd="#ffff00",this.colorWhitebkgd="#000000",this.optsOri={},this.optsOri.camera="perspective",this.optsOri.background="black",this.optsOri.color="chain",this.optsOri.proteins="ribbon",this.optsOri.sidec="nothing",this.optsOri.nucleotides="nucleotide cartoon",this.optsOri.ntbase="nothing",this.optsOri.surface="nothing",this.optsOri.opacity="1.0",this.optsOri.wireframe="no",this.optsOri.map="nothing",this.optsOri.mapwireframe="yes",this.optsOri.emmap="nothing",this.optsOri.emmapwireframe="yes",this.optsOri.phimap="nothing",this.optsOri.phimapwireframe="yes",this.optsOri.phisurface="nothing",this.optsOri.phisurftype="nothing",this.optsOri.phisurfop="1.0",this.optsOri.phisurfwf="yes",this.optsOri.chemicals="stick",this.optsOri.water="nothing",this.optsOri.ions="sphere",this.optsOri.hbonds="no",this.optsOri.saltbridge="no",this.optsOri.contact="no",this.optsOri.halogen="no",this.optsOri["pi-cation"]="no",this.optsOri["pi-stacking"]="no",this.optsOri.ssbonds="yes",this.optsOri.clbonds="yes",this.optsOri.rotationcenter="molecule center",this.optsOri.axis="no",this.optsOri.fog="no",this.optsOri.slab="no",this.optsOri.pk="residue",this.optsOri.chemicalbinding="hide",this.opts=n.hashUtilsCls.cloneHash(this.optsOri),this.sheetcolor="green",this.bShowHighlight=!0,this.mapData={},this.bFullUi=!0,this.divid=this.icn3dui.cfg.divid,this.inputid="",this.setOperation="or",this.ROT_DIR="right",this.currSelectedSets=[],this.selectedResidues={},this.ncbi2resid={},this.resid2ncbi={},this.shapeCmdHash={},this.bHideSelection=!0,this.bSelectResidue=!1,this.bSelectAlignResidue=!1,this.bAnnoShown=!1,this.bSetChainsAdvancedMenu=!1,this.b2DShown=!1,this.bCrashed=!1,this.bAddCommands=!0,this.bAddLogs=!0,this.bNotLoadStructure=!1,this.InputfileData="",this.bVr=!1,this.bAr=!1,this.startColor="blue",this.midColor="white",this.endColor="red",this.startValue=0,this.midValue=50,this.endValue=100,this.crosslinkRadius=.4,this.sceneCls=new Ee(this),this.cameraCls=new Ie(this),this.fogCls=new Te(this),this.boxCls=new Me(this),this.brickCls=new Pe(this),this.curveStripArrowCls=new De(this),this.curveCls=new He(this),this.cylinderCls=new Fe(this),this.lineCls=new Le(this),this.reprSubCls=new Ne(this),this.sphereCls=new Ue(this),this.stickCls=new qe(this),this.strandCls=new $e(this),this.stripCls=new je(this),this.tubeCls=new Be(this),this.cartoonNuclCls=new ze(this),this.surfaceCls=new Je(this),this.labelCls=new Ve(this),this.axesCls=new We(this),this.glycanCls=new Ye(this),this.applyCenterCls=new Ze(this),this.applyClbondsCls=new et(this),this.applyDisplayCls=new tt(this),this.applyMapCls=new lt(this),this.applyOtherCls=new st(this),this.applySsbondsCls=new it(this),this.applySymdCls=new nt(this),this.hlObjectsCls=new Dt(this),this.residueLabelsCls=new rt(this),this.alternateCls=new dt(this),this.drawCls=new ct(this),this.firstAtomObjCls=new hs(this),this.impostorCls=new ot(this),this.instancingCls=new at(this),this.contactCls=new ht(this),this.hBondCls=new pt(this),this.piHalogenCls=new mt(this),this.saltbridgeCls=new ut(this),this.loadPDBCls=new is(this),this.vastplusCls=new ns(this),this.transformCls=new _s(this),this.setStyleCls=new gt(this),this.setColorCls=new ft(this),this.threeDPrintCls=new xs(this),this.export3DCls=new ks(this),this.annoCddSiteCls=new yt(this),this.annoContactCls=new vt(this),this.annoPTMCls=new wt(this),this.annoCrossLinkCls=new _t(this),this.annoDomainCls=new St(this),this.annoSnpClinVarCls=new At(this),this.annoSsbondCls=new xt(this),this.annoTransMemCls=new kt(this),this.domain3dCls=new Ot(this),this.addTrackCls=new Rt(this),this.annotationCls=new Et(this),this.showAnnoCls=new It(this),this.showSeqCls=new Tt(this),this.hlSeqCls=new Mt(this),this.hlUpdateCls=new Pt(this),this.lineGraphCls=new Ht(this),this.getGraphCls=new Ft(this),this.showInterCls=new Lt(this),this.viewInterPairsCls=new Nt(this),this.drawGraphCls=new Ut(this),this.contactMapCls=new qt(this),this.alignParserCls=new $t(this),this.chainalignParserCls=new jt(this),this.dsn6ParserCls=new Bt(this),this.mmcifParserCls=new zt(this),this.mmdbParserCls=new Gt(this),this.mmtfParserCls=new Vt(this),this.mol2ParserCls=new Wt(this),this.opmParserCls=new Yt(this),this.pdbParserCls=new Xt(this),this.sdfParserCls=new Kt(this),this.xyzParserCls=new Qt(this),this.realignParserCls=new Jt(this),this.densityCifParserCls=new Zt(this),this.ParserUtilsCls=new es(this),this.loadAtomDataCls=new ts(this),this.setSeqAlignCls=new ss(this),this.applyCommandCls=new ls(this),this.definedSetsCls=new rs(this),this.legendTableCls=new Ct(this),this.loadScriptCls=new os(this),this.selByCommCls=new as(this),this.selectionCls=new ds(this),this.resid2specCls=new cs(this),this.delphiCls=new ps(this),this.dsspCls=new ms(this),this.refnumCls=new us(this),this.scapCls=new gs(this),this.symdCls=new fs(this),this.alignSWCls=new bs(this),this.analysisCls=new Cs(this),this.resizeCanvasCls=new ws(this),this.saveFileCls=new Ss(this),this.setOptionCls=new bt(this),this.shareLinkCls=new As(this),this.diagram2dCls=new ys(this),this.cartoon2dCls=new vs(this),this.rayCls=new Os(this),this.controlCls=new Rs(this),this.pickingCls=new Es(this),this.VRButtonCls=new Is(this),this.ARButtonCls=new Ts(this),this.matShader=this.setColorCls.setOutlineColor("yellow")}}Ms.prototype.init=function(e){this.init_base(),this.molTitle="",this.ssbondpnts={},this.clbondpnts={},this.biomtMatrices=[],this.bAssembly=!0,this.bDrawn=!1,this.bSecondaryStructure=!1,this.bHighlight=1,this.axes=[]},Ms.prototype.init_base=function(e){this.resetConfig(),this.structures={},this.chains={},this.tddomains={},this.residues={},this.secondaries={},this.alnChains={},this.chainsSeq={},this.chainsColor={},this.chainsGene={},this.chainsAn={},this.chainsAnTitle={},this.chainsMapping={},this.resid2refnum={},this.residIgLoop={},this.refnum2residArray={},this.bShowRefnum=!1,this.alnChainsSeq={},this.alnChainsAnno={},this.alnChainsAnTtl={},this.pickedAtomList={},this.prevHighlightObjects=[],this.prevHighlightObjects_ghost=[],this.prevSurfaces=[],this.prevMaps=[],this.prevEmmaps=[],this.prevPhimaps=[],this.prevOtherMesh=[],this.defNames2Residues={},this.defNames2Atoms={},this.defNames2Descr={},this.defNames2Command={},this.residueId2Name={},this.atoms={},this.dAtoms={},this.hAtoms={},this.proteins={},this.sidec={},this.ntbase={},this.nucleotides={},this.nucleotidesO3={},this.chemicals={},this.ions={},this.water={},this.calphas={},this.hbondpnts=[],this.saltbridgepnts=[],this.contactpnts=[],this.stabilizerpnts=[],this.halogenpnts=[],this.picationpnts=[],this.pistackingpnts=[],this.distPnts=[],this.doublebonds={},this.triplebonds={},this.aromaticbonds={},this.atomPrevColors={},this.style2atoms={},this.labels={},this.lines={},this.resids2inter={},this.resids2interAll={},this.transformCls.rotateCount=0,this.transformCls.rotateCountMax=20,e&&(this.commands=[]),this.axes=[],this.bGlycansCartoon=0,this.bMembrane=1,this.bCmdWindow=0,this.chainMissingResidueArray={},this.nTotalGap=0},Ms.prototype.reinitAfterLoad=function(){let e=this,t=e.icn3dui;e.resetConfig(),e.setStyleCls.setAtomStyleByOptions(),e.setColorCls.setColorByOptions(e.opts,e.atoms),e.dAtoms=t.hashUtilsCls.cloneHash(e.atoms),e.hAtoms=t.hashUtilsCls.cloneHash(e.atoms),e.prevHighlightObjects=[],e.prevHighlightObjects_ghost=[],e.prevSurfaces=[],e.prevMaps=[],e.prevEmmaps=[],e.prevPhimaps=[],e.prevOtherMesh=[],e.labels={},e.lines={},e.shapeCmdHash={},e.bAssembly=!0},Ms.prototype.resetConfig=function(){let e=this,t=e.icn3dui;if(this.opts=t.hashUtilsCls.cloneHash(this.optsOri),void 0===t.cfg.align&&void 0===t.cfg.chainalign||(this.opts.color="identity",this.opts.proteins="c alpha trace",this.opts.nucleotides="o3 trace"),void 0!==t.cfg.cid&&(this.opts.color="atom",this.opts.pk="atom",this.opts.chemicals="ball and stick"),void 0!==t.cfg.afid&&(this.opts.color="confidence"),void 0!==t.cfg.blast_rep_id&&(this.opts.color="conservation"),void 0!==t.cfg.mmdbafid){let s=t.cfg.mmdbafid.split(",");if(s.length>1)e.opts.color="structure";else if(1==s.length){let t=s[0];isNaN(t)&&t.length>5?this.opts.color="confidence":e.opts.color="chain"}}void 0!==t.cfg.options&&$.extend(this.opts,t.cfg.options)};class Ps{constructor(e){this.cfg=e,this.pre=this.cfg.divid+"_",this.REVISION="3.23.2",this.bNode=Object.keys(window).length<2,void 0===this.cfg.command&&(this.cfg.command=""),void 0===this.cfg.width&&(this.cfg.width="100%"),void 0===this.cfg.height&&(this.cfg.height="100%"),void 0===this.cfg.resize&&(this.cfg.resize=!0),void 0===this.cfg.showmenu&&(this.cfg.showmenu=!0),void 0===this.cfg.showtitle&&(this.cfg.showtitle=!0),void 0===this.cfg.showcommand&&(this.cfg.showcommand=!0),void 0===this.cfg.mobilemenu&&(this.cfg.mobilemenu=!1),void 0===this.cfg.closepopup&&(this.cfg.closepopup=!1),void 0===this.cfg.showanno&&(this.cfg.showanno=!1),void 0===this.cfg.showseq&&(this.cfg.showseq=!1),void 0===this.cfg.showalignseq&&(this.cfg.showalignseq=!1),void 0===this.cfg.show2d&&(this.cfg.show2d=!1),void 0===this.cfg.showsets&&(this.cfg.showsets=!1),void 0===this.cfg.rotate&&(this.cfg.rotate="right"),void 0===this.cfg.hidelicense&&(this.cfg.hidelicense=!1),this.hashUtilsCls=new t(this),this.utilsCls=new s(this),this.parasCls=new i(this),this.myEventCls=new n(this),this.rmsdSuprCls=new l(this),this.subdivideCls=new r(this),this.convertTypeCls=new o(this),this.htmlCls=new g(this)}allCustomEvents(){}}Ps.prototype.show3DStructure=async function(e){let t=this;t.cfg.menuicon?(t.htmlCls.wifiStr=' ',t.htmlCls.licenseStr=' '):(t.htmlCls.wifiStr="",t.htmlCls.licenseStr=""),t.setIcn3d();let s=t.icn3d;t.utilsCls.isSessionStorageSupported()&&s.setStyleCls.getCommandsBeforeCrash();let i=t.htmlCls.WIDTH,n=t.htmlCls.HEIGHT;t.oriWidth=i,t.oriHeight=n,t.htmlCls.eventsCls.allEventFunctions(),this.allCustomEvents();let l=0;if((null==t.cfg.showmenu||t.cfg.showmenu)&&(l+=t.htmlCls.MENU_HEIGHT),(null==t.cfg.showcommand||t.cfg.showcommand)&&(l+=t.htmlCls.CMD_HEIGHT),null!=t.cfg.showmenu&&0==t.cfg.showmenu?t.htmlCls.setMenuCls.hideMenu():t.htmlCls.setMenuCls.showMenu(),null!=t.cfg.showtitle&&0==t.cfg.showtitle?$("#"+s.pre+"title").hide():$("#"+s.pre+"title").show(),$("#"+s.pre+"viewer").width(i).height(parseInt(n)+l),$("#"+s.pre+"canvas").width(i).height(parseInt(n)),$("#"+s.pre+"canvas").resizable({resize:function(e,i){t.htmlCls.WIDTH=i.size.width,t.htmlCls.HEIGHT=i.size.height,void 0===s||t.icn3d.bFullscreen||s.resizeCanvasCls.resizeCanvas(t.htmlCls.WIDTH,t.htmlCls.HEIGHT,!0)}}),void 0!==t.cfg.usepdbnum?t.icn3d.bUsePdbNum=t.cfg.usepdbnum:void 0!==t.cfg.date?t.icn3d.bUsePdbNum=parseInt(t.cfg.date)>=20201222:"1tup"==t.cfg.mmdbid&&1==t.cfg.showanno&&1==t.cfg.show2d&&1==t.cfg.showsets||"118496"==t.cfg.mmdbid&&0==t.cfg.showanno&&-1!=t.cfg.inpara.indexOf("bu=1")||"163605,1,91105,1,1,1"==t.cfg.align&&-1!=t.cfg.inpara.indexOf("atype=1")?t.icn3d.bUsePdbNum=!1:t.icn3d.bUsePdbNum=!0,t.cfg.replay?(s.bReplay=1,$("#"+s.pre+"replay").show()):(s.bReplay=0,$("#"+s.pre+"replay").hide()),t.utilsCls.isMobile()&&(s.threshbox=60),t.cfg.controlGl&&(s.bControlGl=!0,s.container=s.bControlGl&&!t.bNode?$(document):$("#"+s.id)),s.setStyleCls.handleContextLost(),s.applyCenterCls.setWidthHeight(i,n),s.ori_chemicalbinding=s.opts.chemicalbinding,void 0!==t.cfg.bCalphaOnly&&(s.bCalphaOnly=t.cfg.bCalphaOnly),s.opts=t.hashUtilsCls.cloneHash(s.opts),s.STATENUMBER=s.commands.length,t.utilsCls.isSessionStorageSupported()&&s.bCrashed){s.bCrashed=!1;let e=s.commandsBeforeCrash.split("|||")[0],i=e.substr(e.lastIndexOf(" ")+1);if(i===t.cfg.mmtfid||i===t.cfg.pdbid||i===t.cfg.opmid||i===t.cfg.mmdbid||i===t.cfg.gi||i===t.cfg.blast_rep_id||i===t.cfg.cid||i===t.cfg.mmcifid||i===t.cfg.align||i===t.cfg.chainalign||i===t.cfg.mmdbafid)return void await s.loadScriptCls.loadScript(s.commandsBeforeCrash,!0)}if(s.molTitle="",s.loadCmd,t.htmlCls.clickMenuCls.getHiddenMenusFromCache(),t.htmlCls.clickMenuCls.applyShownMenus(),e){if(s.init(),s.bInputfile=!0,s.InputfileType="pdb",s.InputfileData=s.InputfileData?s.InputfileData+"\nENDMDL\n"+e:e,await s.pdbParserCls.loadPdbData(e),void 0!==t.cfg.resdef&&void 0!==t.cfg.chains){let e=Object.keys(s.structures),i=t.cfg.chains.split(" | "),n=[];if(e.length==i.length){for(let t=0,s=e.length;t0&&(l+=","),l+=n[e].substr(0,n[e].indexOf("_"));s.chainidArray=[e].concat(n),s.chainidArray=s.chainalignParserCls.addPostfixForChainids(s.chainidArray),t.htmlCls.clickMenuCls.setLogCmd("resdef "+t.cfg.resdef,!0),s.loadCmd="vast_search_chainid "+s.chainidArray,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),s.bMmdbafid=!0;let r=!0;await s.chainalignParserCls.downloadMmdbAf(l,r)}}else if(void 0!==t.cfg.url){s.bInputUrlfile=!0;let e=t.cfg.url.split("|"),i=e[0],n=e[1];s.molTitle="",s.inputid=n,s.inputurl="type="+i+"&url="+encodeURIComponent(n),s.loadCmd="load url "+n+" | type "+i,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.pdbParserCls.downloadUrl(n,i,t.cfg.command)}else if(void 0!==t.cfg.mmtfid)s.inputid=t.cfg.mmtfid,s.loadCmd="load mmtf "+t.cfg.mmtfid,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.mmtfParserCls.downloadMmtf(t.cfg.mmtfid);else if(void 0!==t.cfg.pdbid)s.inputid=t.cfg.pdbid,s.loadCmd="load pdb "+t.cfg.pdbid,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.pdbParserCls.downloadPdb(t.cfg.pdbid);else if(void 0!==t.cfg.afid){s.inputid=t.cfg.afid,s.loadCmd="load af "+t.cfg.afid,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0);let e=!0;await s.pdbParserCls.downloadPdb(t.cfg.afid,e)}else if(void 0!==t.cfg.opmid)s.inputid=t.cfg.opmid,s.loadCmd="load opm "+t.cfg.opmid,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.opmParserCls.downloadOpm(t.cfg.opmid);else if(void 0!==t.cfg.mmdbid)s.inputid=t.cfg.mmdbid,s.loadCmd="load mmdb "+t.cfg.mmdbid+" | parameters "+t.cfg.inpara,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.mmdbParserCls.downloadMmdb(t.cfg.mmdbid);else if(void 0!==t.cfg.gi)s.loadCmd="load gi "+t.cfg.gi,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.mmdbParserCls.downloadGi(t.cfg.gi);else if(void 0!==t.cfg.refseqid)s.inputid=t.cfg.refseqid,s.loadCmd="load refseq "+t.cfg.refseqid,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.mmdbParserCls.downloadRefseq(t.cfg.refseqid);else if(void 0!==t.cfg.blast_rep_id)if(s.inputid=t.cfg.query_id+","+t.cfg.blast_rep_id,t.cfg.oriQuery_id=t.cfg.query_id,t.cfg.oriBlast_rep_id=t.cfg.blast_rep_id,"Query"!==t.cfg.query_id.substr(0,5)&&void 0===t.cfg.rid)"icn3d"==t.cfg.from&&"1TSR_A"==t.cfg.blast_rep_id&&"NP_001108451.1"==t.cfg.query_id&&(t.cfg.command="view annotations; set annotation cdd; set annotation site; set view detailed view; select chain 1TSR_A; show selection"),"smithwm"==t.cfg.alg?(s.loadCmd="load seq_struct_ids_smithwm "+t.cfg.query_id+","+t.cfg.blast_rep_id,s.bSmithwm=!0):"local_smithwm"==t.cfg.alg?(s.loadCmd="load seq_struct_ids_local_smithwm "+t.cfg.query_id+","+t.cfg.blast_rep_id,s.bLocalSmithwm=!0):(s.loadCmd="load seq_struct_ids "+t.cfg.query_id+","+t.cfg.blast_rep_id,s.bSmithwm=!1,s.bLocalSmithwm=!1),t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.mmdbParserCls.downloadBlast_rep_id(t.cfg.query_id+","+t.cfg.blast_rep_id);else if(void 0!==t.cfg.rid){let e="https://blast.ncbi.nlm.nih.gov/Blast.cgi?RESULTS_FILE=on&FORMAT_TYPE=JSON2_S&FORMAT_OBJECT=Alignment&CMD=Get&RID="+t.cfg.rid,i=await t.getAjaxPromise(e,"json",!1,"The RID "+t.cfg.rid+" may have expired...");for(let e=0,n=i.BlastOutput2.length;e
    ",s="All atoms  ";e.utilsCls.setViewerWidthHeight(e),e.utilsCls.isMobile()||e.cfg.mobilemenu?e.htmlCls.setMenuCls.setTopMenusHtmlMobile(e.cfg.divid,t,s):e.htmlCls.setMenuCls.setTopMenusHtml(e.cfg.divid,t,s),e.icn3d=new Ms(e),e.icn3d.controlCls.setControl(),e.setDialogAjax()},Ps.prototype.getAjaxPromise=function(e,t,s,i,n,l){let r=this;return new Promise((function(o,a){$.ajax({url:e,dataType:t,cache:!0,beforeSend:function(){s&&r.icn3d.ParserUtilsCls.showLoading()},complete:function(){l&&r.icn3d.ParserUtilsCls.hideLoading()},success:function(e){o(e)},error:function(){i&&alert(i),n&&console.log(n),a("error")}})}))},Ps.prototype.getAjaxPostPromise=function(e,t,s,i,n,l,r){let o=this;return r=r||"json",new Promise((function(a,d){$.ajax({url:e,type:"POST",data:t,dataType:r,cache:!0,beforeSend:function(){s&&o.icn3d.ParserUtilsCls.showLoading()},complete:function(){l&&o.icn3d.ParserUtilsCls.hideLoading()},success:function(e){a(e)},error:function(){i&&alert(i),n&&console.log(n),d("error")}})}))},Ps.prototype.setDialogAjax=function(){this.bNode||$.ui.dialog.prototype._makeDraggableBase||($.ui.dialog.prototype._makeDraggableBase=$.ui.dialog.prototype._makeDraggable,$.ui.dialog.prototype._makeDraggable=function(){this._makeDraggableBase(),this.uiDialog.draggable("option","containment",!1)}),$.ajaxTransport("+binary",(function(e,t,s){if(window.FormData&&(e.dataType&&"binary"==e.dataType||e.data&&(window.ArrayBuffer&&e.data instanceof ArrayBuffer||window.Blob&&e.data instanceof Blob)))return{send:function(t,s){let i=new XMLHttpRequest,n=e.url,l=e.type,r=e.async||!0,o=e.responseType||"blob",a=e.data||null;i.addEventListener("load",(function(){let t={};t[e.dataType]=i.response,s(i.status,i.statusText,t,i.getAllResponseHeaders())})),i.open(l,n,r);for(let e in t)i.setRequestHeader(e,t[e]);i.responseType=o,i.send(a)},abort:function(){s.abort()}}}))};return e.ARButton=Ts,e.AddTrack=Rt,e.AlignParser=$t,e.AlignSW=bs,e.AlignSeq=m,e.Alternate=dt,e.Analysis=Cs,e.AnnoCddSite=yt,e.AnnoContact=vt,e.AnnoCrossLink=_t,e.AnnoDomain=St,e.AnnoSnpClinVar=At,e.AnnoSsbond=xt,e.AnnoTransMem=kt,e.Annotation=Et,e.ApplyCenter=Ze,e.ApplyClbonds=et,e.ApplyCommand=ls,e.ApplyDisplay=tt,e.ApplyMap=lt,e.ApplyOther=st,e.ApplySsbonds=it,e.ApplySymd=nt,e.Axes=We,e.Box=Me,e.Brick=Pe,e.Camera=Ie,e.CartoonNucl=ze,e.ChainalignParser=jt,e.ClickMenu=a,e.Contact=ht,e.Control=Rs,e.ConvertTypeCls=o,e.Curve=He,e.CurveStripArrow=De,e.Cylinder=Fe,e.DefinedSets=rs,e.Delphi=ps,e.DensityCifParser=Zt,e.Diagram2d=ys,e.Dialog=c,e.Domain3d=Ot,e.Draw=ct,e.DrawGraph=Ut,e.Dsn6Parser=Bt,e.Dssp=ms,e.ElectronMap=Qe,e.Events=p,e.Export3D=ks,e.FirstAtomObj=hs,e.Fog=Te,e.GetGraph=Ft,e.Glycan=Ye,e.HBond=pt,e.HashUtilsCls=t,e.HlObjects=Dt,e.HlSeq=Mt,e.HlUpdate=Pt,e.Html=g,e.Impostor=ot,e.Instancing=at,e.Label=Ve,e.Line=Le,e.LineGraph=Ht,e.LoadAtomData=ts,e.LoadPDB=is,e.LoadScript=os,e.MarchingCube=Xe,e.MmcifParser=zt,e.MmdbParser=Gt,e.MmtfParser=Vt,e.Mol2Parser=Wt,e.MyEventCls=n,e.OpmParser=Yt,e.ParasCls=i,e.ParserUtils=es,e.PdbParser=Xt,e.PiHalogen=mt,e.Picking=Es,e.ProteinSurface=Ke,e.Ray=Os,e.RealignParser=Jt,e.Refnum=us,e.ReprSub=Ne,e.Resid2spec=cs,e.ResidueLabels=rt,e.ResizeCanvas=ws,e.RmsdSuprCls=l,e.Saltbridge=ut,e.SaveFile=Ss,e.Scap=gs,e.Scene=Ee,e.SdfParser=Kt,e.SelectByCommand=as,e.Selection=ds,e.SetColor=ft,e.SetDialog=h,e.SetHtml=u,e.SetMenu=d,e.SetOption=bt,e.SetSeqAlign=ss,e.SetStyle=gt,e.ShareLink=As,e.ShowAnno=It,e.ShowInter=Lt,e.ShowSeq=Tt,e.Sphere=Ue,e.Stick=qe,e.Strand=$e,e.Strip=je,e.SubdivideCls=r,e.Surface=Je,e.Symd=fs,e.ThreeDPrint=xs,e.Transform=_s,e.Tube=Be,e.UtilsCls=s,e.VRButton=Is,e.Vastplus=ns,e.ViewInterPairs=Nt,e.XyzParser=Qt,e.iCn3D=Ms,e.iCn3DUI=Ps,e.printMsg=class{constructor(){console.log("This is a message from the icn3d package")}},Object.defineProperty(e,"__esModule",{value:!0}),e}({}); diff --git a/src/html/setDialog.js b/src/html/setDialog.js index 6db318f3..afd532b3 100644 --- a/src/html/setDialog.js +++ b/src/html/setDialog.js @@ -355,7 +355,7 @@ class SetDialog { html += me.htmlCls.divStr + "dl_mmdbafid' class='" + dialogClass + "' style='max-width:600px'>"; html += "List of PDB, MMDB, or AlphaFold UniProt structures: " + me.htmlCls.inputTextStr + "id='" + me.pre + "mmdbafid' placeholder='e.g., 1HHO,4N7N,P69905,P01942' size=30>

    "; html += "
    " + me.htmlCls.buttonStr + "reload_mmdbaf' style='width:150px'>Load Biological Unit" + me.htmlCls.buttonStr + "reload_mmdbaf_asym' style='margin-left:30px; width:250px'>Load Asymmetric Unit (All Chains)" + "

    "; - html += "
    or
    " + me.htmlCls.buttonStr + "reload_mmdbaf_append' style='width:150px'>Append Biological Unit" + me.htmlCls.buttonStr + "reload_mmdbaf_asym_append' style='margin-left:30px; width:250px'>Append Asymmetric ; Unit (All Chains)" + "

    "; + html += "
    or
    " + me.htmlCls.buttonStr + "reload_mmdbaf_append' style='width:150px'>Append Biological Unit" + me.htmlCls.buttonStr + "reload_mmdbaf_asym_append' style='margin-left:30px; width:250px'>Append Asymmetric Unit (All Chains)" + "

    "; html += 'Note: The "biological unit" is the biochemically active form of a biomolecule,
    StructureChainResidue Number
    "+s[e].substr(0,t)+""+s[e].substr(t+1,n-t-1)+""+s[e].substr(n+1)+"