Browse Source

improve aromatic bonds

 - Don't detect aromatic bonds for rings < 5 atoms based on planarity
- Prefer atoms in aromatic rings as bond reference positions
Alexander Rose 3 years ago
parent
commit
224fd1733f

+ 3 - 0
CHANGELOG.md

@@ -28,6 +28,9 @@ Note that since we don't clearly distinguish between a public and private interf
     - Support ``onBeforeUIRender`` to make sure initial UI works with custom presets and similar features.
 - [Breaking] Removed ``createPlugin`` and ``createPluginAsync`` from ``mol-plugin-ui``
     - Please use ``createPluginUI`` instead
+- Improve aromatic bonds handling
+    - Don't detect aromatic bonds for rings < 5 atoms based on planarity
+    - Prefer atoms in aromatic rings as bond reference positions
 
 ## [v3.0.0-dev.5] - 2021-12-16
 

+ 1 - 0
src/mol-model/structure/structure/unit/rings.ts

@@ -122,6 +122,7 @@ namespace UnitRing {
         }
         if (aromaticBondCount === 2 * ring.length) return true;
         if (!hasAromaticRingElement) return false;
+        if (ring.length < 5) return false;
 
         const ma = PrincipalAxes.calculateMomentsAxes(getPositions(unit, ring));
         return Vec3.magnitude(ma.dirC) < AromaticRingPlanarityThreshold;

+ 2 - 2
src/mol-repr/structure/visual/bond-intra-unit-cylinder.ts

@@ -88,14 +88,14 @@ function getIntraUnitBondCylinderBuilderProps(unit: Unit.Atomic, structure: Stru
             if (aI > bI) [aI, bI] = [bI, aI];
             if (offset[aI + 1] - offset[aI] === 1) [aI, bI] = [bI, aI];
 
-            const aR = elementRingIndices.get(aI);
+            const aR = elementAromaticRingIndices.get(aI) || elementRingIndices.get(aI);
             let maxSize = 0;
 
             for (let i = offset[aI], il = offset[aI + 1]; i < il; ++i) {
                 const _bI = b[i];
                 if (_bI !== bI && _bI !== aI) {
                     if (aR) {
-                        const _bR = elementRingIndices.get(_bI);
+                        const _bR = elementAromaticRingIndices.get(_bI) || elementRingIndices.get(_bI);
                         if (!_bR) continue;
 
                         const size = arrayIntersectionSize(aR, _bR);

+ 2 - 2
src/mol-repr/structure/visual/bond-intra-unit-line.ts

@@ -61,14 +61,14 @@ function createIntraUnitBondLines(ctx: VisualContext, unit: Unit, structure: Str
             if (aI > bI) [aI, bI] = [bI, aI];
             if (offset[aI + 1] - offset[aI] === 1) [aI, bI] = [bI, aI];
 
-            const aR = elementRingIndices.get(aI);
+            const aR = elementAromaticRingIndices.get(aI) || elementRingIndices.get(aI);
             let maxSize = 0;
 
             for (let i = offset[aI], il = offset[aI + 1]; i < il; ++i) {
                 const _bI = b[i];
                 if (_bI !== bI && _bI !== aI) {
                     if (aR) {
-                        const _bR = elementRingIndices.get(_bI);
+                        const _bR = elementAromaticRingIndices.get(_bI) || elementRingIndices.get(_bI);
                         if (!_bR) continue;
 
                         const size = arrayIntersectionSize(aR, _bR);