ソースを参照

fix ellipsoid repr and support includeParent

- switch off adjustCylinderLength
- handle structure with child
Alexander Rose 4 年 前
コミット
0bb376706d

+ 1 - 0
docs/interesting-pdb-entries.md

@@ -27,3 +27,4 @@
     * DNA (5D3G)
 * Multiple models with different sets of ligands or missing ligands (1J6T, 1VRC, 2ICY, 1O2F)
 * Long linear sugar chain (4HG6)
+* Anisotropic B-factors/Ellipsoids (1EJG)

+ 7 - 2
src/mol-repr/structure/representation/ellipsoid.ts

@@ -26,7 +26,6 @@ export const EllipsoidParams = {
     ...IntraUnitBondCylinderParams,
     ...InterUnitBondCylinderParams,
     adjustCylinderLength: PD.Boolean(false, { isHidden: true }), // not useful here
-    includeParent: PD.Boolean(false, { isHidden: true }), // not yet supported here
     unitKinds: getUnitKindsParam(['atomic']),
     sizeFactor: PD.Numeric(1, { min: 0.01, max: 10, step: 0.01 }),
     sizeAspectRatio: PD.Numeric(0.1, { min: 0.01, max: 3, step: 0.01 }),
@@ -52,5 +51,11 @@ export const EllipsoidRepresentationProvider = StructureRepresentationProvider({
     defaultValues: PD.getDefaultValues(EllipsoidParams),
     defaultColorTheme: { name: 'element-symbol' },
     defaultSizeTheme: { name: 'uniform' },
-    isApplicable: (structure: Structure) => structure.elementCount > 0 && structure.models.some(m => AtomSiteAnisotrop.Provider.isApplicable(m))
+    isApplicable: (structure: Structure) => structure.elementCount > 0 && structure.models.some(m => AtomSiteAnisotrop.Provider.isApplicable(m)),
+    getData: (structure: Structure, props: PD.Values<EllipsoidParams>) => {
+        return props.includeParent ? Structure.WithChild.fromStructure(structure) : structure;
+    },
+    mustRecreate: (oldProps: PD.Values<EllipsoidParams>, newProps: PD.Values<EllipsoidParams>) => {
+        return oldProps.includeParent !== newProps.includeParent;
+    }
 });

+ 10 - 4
src/mol-repr/structure/visual/ellipsoid-mesh.ts

@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ * Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
@@ -22,6 +22,7 @@ import { equalEps } from '../../../mol-math/linear-algebra/3d/common';
 import { addSphere } from '../../../mol-geo/geometry/mesh/builder/sphere';
 import { Sphere3D } from '../../../mol-math/geometry';
 import { BaseGeometry } from '../../../mol-geo/geometry/base';
+import { SortedArray } from '../../../mol-data/int/sorted-array';
 
 export const EllipsoidMeshParams = {
     ...UnitsMeshParams,
@@ -57,7 +58,11 @@ export interface EllipsoidMeshProps {
 }
 
 export function createEllipsoidMesh(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: EllipsoidMeshProps, mesh?: Mesh): Mesh {
-    const { detail, sizeFactor } = props;
+    const child = Structure.WithChild.getChild(structure);
+    const childUnit = child?.unitMap.get(unit.id);
+    if (child && !childUnit) return Mesh.createEmpty(mesh);
+
+    const { detail, sizeFactor, ignoreHydrogens } = props;
 
     const { elements, model } = unit;
     const { atomicNumber } = unit.model.atomicHierarchy.derived.atom;
@@ -84,7 +89,8 @@ export function createEllipsoidMesh(ctx: VisualContext, unit: Unit, structure: S
         const ei = elements[i];
         const ai = elementToAnsiotrop[ei];
         if (ai === -1) continue;
-        if (props.ignoreHydrogens && isH(atomicNumber, ei)) continue;
+        if (((!!childUnit && !SortedArray.has(childUnit.elements, ei))) ||
+            (ignoreHydrogens && isH(atomicNumber, ei))) continue;
 
         l.element = ei;
         pos(ei, v);
@@ -111,7 +117,7 @@ export function createEllipsoidMesh(ctx: VisualContext, unit: Unit, structure: S
 
     const m = MeshBuilder.getMesh(builderState);
 
-    const sphere = Sphere3D.expand(Sphere3D(), unit.boundary.sphere, 1 * sizeFactor);
+    const sphere = Sphere3D.expand(Sphere3D(), (childUnit || unit).boundary.sphere, 1 * sizeFactor);
     m.setBoundingSphere(sphere);
 
     return m;