Browse Source

wip, interactions, features in invariant space

Alexander Rose 5 years ago
parent
commit
0f4d0ff986

+ 4 - 4
src/mol-model-props/computed/interactions/features.ts

@@ -13,11 +13,11 @@ import { FeatureGroup, FeatureType } from './common';
 export { Features }
 
 interface Features {
-    /** center x coordinate */
+    /** center x coordinate, in invariant coordinate space */
     readonly x: ArrayLike<number>
-    /** center y coordinate */
+    /** center y coordinate, in invariant coordinate space */
     readonly y: ArrayLike<number>
-    /** center z coordinate */
+    /** center z coordinate, in invariant coordinate space */
     readonly z: ArrayLike<number>
     /** number of features */
     readonly count: number
@@ -26,7 +26,7 @@ interface Features {
     readonly offsets: ArrayLike<number>
     /** elements of this feature, range for feature i is offsets[i] to offsets[i + 1] */
     readonly members: ArrayLike<StructureElement.UnitIndex>
-    /** lookup3d based on center coordinates */
+    /** lookup3d based on center coordinates, in invariant coordinate space */
     readonly lookup3d: GridLookup3D
 }
 

+ 9 - 9
src/mol-model-props/computed/interactions/hydrogen-bonds.ts

@@ -54,8 +54,8 @@ function getUnitValenceModel(structure: Structure, unit: Unit.Atomic) {
  */
 export function addUnitHydrogenDonors(structure: Structure, unit: Unit.Atomic, builder: FeaturesBuilder) {
     const { totalH } = getUnitValenceModel(structure, unit)
-    const { elements, conformation } = unit
-    const { x, y, z } = conformation
+    const { elements } = unit
+    const { x, y, z } = unit.model.atomicConformation
 
     for (let i = 0 as StructureElement.UnitIndex, il = elements.length; i < il; ++i) {
         const element = typeSymbol(unit, i)
@@ -68,7 +68,7 @@ export function addUnitHydrogenDonors(structure: Structure, unit: Unit.Atomic, b
                 (element === Elements.N || element === Elements.O || element === Elements.S)
             )
         ) {
-            builder.addOne(FeatureType.HydrogenDonor, FeatureGroup.None, x(elements[i]), y(elements[i]), z(elements[i]), i)
+            builder.addOne(FeatureType.HydrogenDonor, FeatureGroup.None, x[elements[i]], y[elements[i]], z[elements[i]], i)
         }
     }
 }
@@ -78,8 +78,8 @@ export function addUnitHydrogenDonors(structure: Structure, unit: Unit.Atomic, b
  */
 export function addUnitWeakHydrogenDonors(structure: Structure, unit: Unit.Atomic, builder: FeaturesBuilder) {
     const { totalH } = getUnitValenceModel(structure, unit)
-    const { elements, conformation } = unit
-    const { x, y, z } = conformation
+    const { elements } = unit
+    const { x, y, z } = unit.model.atomicConformation
 
     for (let i = 0 as StructureElement.UnitIndex, il = elements.length; i < il; ++i) {
         if (
@@ -91,7 +91,7 @@ export function addUnitWeakHydrogenDonors(structure: Structure, unit: Unit.Atomi
                 inAromaticRingWithElectronNegativeElement(structure, unit, i)
             )
         ) {
-            builder.addOne(FeatureType.WeakHydrogenDonor, FeatureGroup.None, x(elements[i]), y(elements[i]), z(elements[i]), i)
+            builder.addOne(FeatureType.WeakHydrogenDonor, FeatureGroup.None, x[elements[i]], y[elements[i]], z[elements[i]], i)
         }
     }
 }
@@ -124,11 +124,11 @@ function inAromaticRingWithElectronNegativeElement(structure: Structure, unit: U
  */
 export function addUnitHydrogenAcceptors(structure: Structure, unit: Unit.Atomic, builder: FeaturesBuilder) {
     const { charge, implicitH, idealGeometry } = getUnitValenceModel(structure, unit)
-    const { elements, conformation } = unit
-    const { x, y, z } = conformation
+    const { elements } = unit
+    const { x, y, z } = unit.model.atomicConformation
 
     function add(i: StructureElement.UnitIndex) {
-        builder.addOne(FeatureType.HydrogenAcceptor, FeatureGroup.None, x(elements[i]), y(elements[i]), z(elements[i]), i)
+        builder.addOne(FeatureType.HydrogenAcceptor, FeatureGroup.None, x[elements[i]], y[elements[i]], z[elements[i]], i)
     }
 
     for (let i = 0 as StructureElement.UnitIndex, il = elements.length; i < il; ++i) {

+ 8 - 5
src/mol-model-props/computed/interactions/interactions.ts

@@ -134,11 +134,14 @@ export async function computeInteractions(runtime: RuntimeContext, structure: St
     const unitsFeatures = IntMap.Mutable<Features>()
     const unitsLinks = IntMap.Mutable<InteractionsIntraLinks>()
 
-    for (let i = 0, il = structure.units.length; i < il; ++i) {
-        const u = structure.units[i]
-        const d = findIntraUnitLinksAndFeatures(structure, u, p)
-        unitsFeatures.set(u.id, d.features)
-        unitsLinks.set(u.id, d.links)
+    for (let i = 0, il = structure.unitSymmetryGroups.length; i < il; ++i) {
+        const group = structure.unitSymmetryGroups[i]
+        const d = findIntraUnitLinksAndFeatures(structure, group.units[0], p)
+        for (let j = 0, jl = group.units.length; j < jl; ++j) {
+            const u = group.units[j]
+            unitsFeatures.set(u.id, d.features)
+            unitsLinks.set(u.id, d.links)
+        }
     }
 
     const links = findInterUnitLinks(structure, unitsFeatures, p)

+ 2 - 0
src/mol-repr/structure/visual/interactions-inter-unit-cylinder.ts

@@ -40,7 +40,9 @@ function createInterUnitInteractionCylinderMesh(ctx: VisualContext, structure: S
             const fA = unitsFeatures.get(unitA.id)
             const fB = unitsFeatures.get(unitB.id)
             Vec3.set(posA, fA.x[indexA], fA.y[indexA], fA.z[indexA])
+            Vec3.transformMat4(posA, posA, unitA.conformation.operator.matrix)
             Vec3.set(posB, fB.x[indexB], fB.y[indexB], fB.z[indexB])
+            Vec3.transformMat4(posB, posB, unitB.conformation.operator.matrix)
         },
         order: (edgeIndex: number) => 1,
         flags: (edgeIndex: number) => BondType.Flag.MetallicCoordination, // TODO

+ 3 - 0
src/mol-repr/structure/visual/interactions-intra-unit-cylinder.ts

@@ -31,6 +31,7 @@ async function createIntraUnitInteractionsCylinderMesh(ctx: VisualContext, unit:
     const { x, y, z } = features
     const { edgeCount, a, b } = links
     const { sizeFactor } = props
+    const { matrix } = unit.conformation.operator
 
     if (!edgeCount) return Mesh.createEmpty(mesh)
 
@@ -39,7 +40,9 @@ async function createIntraUnitInteractionsCylinderMesh(ctx: VisualContext, unit:
         referencePosition: () => null,
         position: (posA: Vec3, posB: Vec3, edgeIndex: number) => {
             Vec3.set(posA, x[a[edgeIndex]], y[a[edgeIndex]], z[a[edgeIndex]])
+            Vec3.transformMat4(posA, posA, matrix)
             Vec3.set(posB, x[b[edgeIndex]], y[b[edgeIndex]], z[b[edgeIndex]])
+            Vec3.transformMat4(posB, posB, matrix)
         },
         order: (edgeIndex: number) => 1,
         flags: (edgeIndex: number) => BondType.Flag.MetallicCoordination, // TODO

+ 0 - 1
src/mol-theme/color/interaction-type.ts

@@ -87,7 +87,6 @@ export function InteractionTypeColorTheme(ctx: ThemeDataContext, props: PD.Value
                     return typeColor(links.edgeProps.type[idx])
                 } else {
                     const idx = interactions.links.getEdgeIndex(indexA, unitA, indexB, unitB)
-                    console.log({ idx, indexA, unitA, indexB, unitB })
                     return typeColor(interactions.links.edges[idx].props.type)
                 }
             }