From f404d23280acc029ae4c6227848fafcae390c4b5 Mon Sep 17 00:00:00 2001 From: Alexander Rose <alexander.rose@weirdbyte.de> Date: Sat, 4 Sep 2021 14:56:40 -0700 Subject: [PATCH] take include/exclude flags into account when displaying aromatic bonds - this allows to show aromatic rings only when explicitely given --- .../structure/visual/bond-inter-unit-cylinder.ts | 2 +- .../structure/visual/bond-inter-unit-line.ts | 2 +- .../structure/visual/bond-intra-unit-cylinder.ts | 12 ++++++++---- .../structure/visual/bond-intra-unit-line.ts | 14 +++++++++----- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/mol-repr/structure/visual/bond-inter-unit-cylinder.ts b/src/mol-repr/structure/visual/bond-inter-unit-cylinder.ts index a6d46e552..d9bf85548 100644 --- a/src/mol-repr/structure/visual/bond-inter-unit-cylinder.ts +++ b/src/mol-repr/structure/visual/bond-inter-unit-cylinder.ts @@ -133,7 +133,7 @@ function getInterUnitBondCylinderBuilderProps(structure: Structure, theme: Theme const o = edges[edgeIndex].props.order; const f = BitFlags.create(edges[edgeIndex].props.flag); if (BondType.is(f, BondType.Flag.MetallicCoordination) || BondType.is(f, BondType.Flag.HydrogenBond)) { - // show metall coordinations and hydrogen bonds with dashed cylinders + // show metallic coordinations and hydrogen bonds with dashed cylinders return LinkStyle.Dashed; } else if (o === 3) { return LinkStyle.Triple; diff --git a/src/mol-repr/structure/visual/bond-inter-unit-line.ts b/src/mol-repr/structure/visual/bond-inter-unit-line.ts index c78873c88..f31a76652 100644 --- a/src/mol-repr/structure/visual/bond-inter-unit-line.ts +++ b/src/mol-repr/structure/visual/bond-inter-unit-line.ts @@ -71,7 +71,7 @@ function createInterUnitBondLines(ctx: VisualContext, structure: Structure, them const o = edges[edgeIndex].props.order; const f = BitFlags.create(edges[edgeIndex].props.flag); if (BondType.is(f, BondType.Flag.MetallicCoordination) || BondType.is(f, BondType.Flag.HydrogenBond)) { - // show metall coordinations and hydrogen bonds with dashed cylinders + // show metallic coordinations and hydrogen bonds with dashed cylinders return LinkStyle.Dashed; } else if (o === 3) { return LinkStyle.Triple; diff --git a/src/mol-repr/structure/visual/bond-intra-unit-cylinder.ts b/src/mol-repr/structure/visual/bond-intra-unit-cylinder.ts index 7aae65c38..a53098c30 100644 --- a/src/mol-repr/structure/visual/bond-intra-unit-cylinder.ts +++ b/src/mol-repr/structure/visual/bond-intra-unit-cylinder.ts @@ -16,7 +16,7 @@ import { createLinkCylinderImpostors, createLinkCylinderMesh, LinkBuilderProps, import { UnitsMeshParams, UnitsVisual, UnitsMeshVisual, UnitsCylindersParams, UnitsCylindersVisual } from '../units-visual'; import { VisualUpdateState } from '../../util'; import { BondType } from '../../../mol-model/structure/model/types'; -import { BondCylinderParams, BondIterator, eachIntraBond, getIntraBondLoci, makeIntraBondIgnoreTest } from './util/bond'; +import { BondCylinderParams, BondIterator, eachIntraBond, getIntraBondLoci, ignoreBondType, makeIntraBondIgnoreTest } from './util/bond'; import { Sphere3D } from '../../../mol-math/geometry'; import { IntAdjacencyGraph } from '../../../mol-math/graph'; import { WebGLContext } from '../../../mol-gl/webgl/context'; @@ -33,7 +33,11 @@ function getIntraUnitBondCylinderBuilderProps(unit: Unit.Atomic, structure: Stru const bonds = unit.bonds; const { edgeCount, a, b, edgeProps, offset } = bonds; const { order: _order, flags: _flags } = edgeProps; - const { sizeFactor, sizeAspectRatio, adjustCylinderLength, aromaticBonds } = props; + const { sizeFactor, sizeAspectRatio, adjustCylinderLength, aromaticBonds, includeTypes, excludeTypes } = props; + + const include = BondType.fromNames(includeTypes); + const exclude = BondType.fromNames(excludeTypes); + const ignoreComputedAromatic = ignoreBondType(include, exclude, BondType.Flag.Computed); const vRef = Vec3(), delta = Vec3(); const pos = unit.conformation.invariantPosition; @@ -123,7 +127,7 @@ function getIntraUnitBondCylinderBuilderProps(unit: Unit.Atomic, structure: Stru const o = _order[edgeIndex]; const f = _flags[edgeIndex]; if (isBondType(f, BondType.Flag.MetallicCoordination) || isBondType(f, BondType.Flag.HydrogenBond)) { - // show metall coordinations and hydrogen bonds with dashed cylinders + // show metallic coordinations and hydrogen bonds with dashed cylinders return LinkStyle.Dashed; } else if (o === 3) { return LinkStyle.Triple; @@ -133,7 +137,7 @@ function getIntraUnitBondCylinderBuilderProps(unit: Unit.Atomic, structure: Stru const bR = elementAromaticRingIndices.get(bI); const arCount = (aR && bR) ? arrayIntersectionSize(aR, bR) : 0; - if (arCount || isBondType(f, BondType.Flag.Aromatic)) { + if (isBondType(f, BondType.Flag.Aromatic) || (arCount && !ignoreComputedAromatic)) { if (arCount === 2) { return LinkStyle.MirroredAromatic; } else { diff --git a/src/mol-repr/structure/visual/bond-intra-unit-line.ts b/src/mol-repr/structure/visual/bond-intra-unit-line.ts index f55e7eb0d..49e9c1bb2 100644 --- a/src/mol-repr/structure/visual/bond-intra-unit-line.ts +++ b/src/mol-repr/structure/visual/bond-intra-unit-line.ts @@ -14,7 +14,7 @@ import { LinkStyle, createLinkLines, LinkBuilderProps } from './util/link'; import { UnitsVisual, UnitsLinesParams, UnitsLinesVisual } from '../units-visual'; import { VisualUpdateState } from '../../util'; import { BondType } from '../../../mol-model/structure/model/types'; -import { BondIterator, BondLineParams, getIntraBondLoci, eachIntraBond, makeIntraBondIgnoreTest } from './util/bond'; +import { BondIterator, BondLineParams, getIntraBondLoci, eachIntraBond, makeIntraBondIgnoreTest, ignoreBondType } from './util/bond'; import { Sphere3D } from '../../../mol-math/geometry'; import { Lines } from '../../../mol-geo/geometry/lines/lines'; import { IntAdjacencyGraph } from '../../../mol-math/graph'; @@ -36,10 +36,14 @@ function createIntraUnitBondLines(ctx: VisualContext, unit: Unit, structure: Str const elements = unit.elements; const bonds = unit.bonds; const { edgeCount, a, b, edgeProps, offset } = bonds; + if (!edgeCount) return Lines.createEmpty(lines); + const { order: _order, flags: _flags } = edgeProps; - const { sizeFactor, aromaticBonds } = props; + const { sizeFactor, aromaticBonds, includeTypes, excludeTypes } = props; - if (!edgeCount) return Lines.createEmpty(lines); + const include = BondType.fromNames(includeTypes); + const exclude = BondType.fromNames(excludeTypes); + const ignoreComputedAromatic = ignoreBondType(include, exclude, BondType.Flag.Computed); const vRef = Vec3(); const pos = unit.conformation.invariantPosition; @@ -84,7 +88,7 @@ function createIntraUnitBondLines(ctx: VisualContext, unit: Unit, structure: Str const o = _order[edgeIndex]; const f = _flags[edgeIndex]; if (isBondType(f, BondType.Flag.MetallicCoordination) || isBondType(f, BondType.Flag.HydrogenBond)) { - // show metall coordinations and hydrogen bonds with dashed cylinders + // show metallic coordinations and hydrogen bonds with dashed cylinders return LinkStyle.Dashed; } else if (o === 3) { return LinkStyle.Triple; @@ -94,7 +98,7 @@ function createIntraUnitBondLines(ctx: VisualContext, unit: Unit, structure: Str const bR = elementAromaticRingIndices.get(bI); const arCount = (aR && bR) ? arrayIntersectionSize(aR, bR) : 0; - if (arCount || isBondType(f, BondType.Flag.Aromatic)) { + if (isBondType(f, BondType.Flag.Aromatic) || (arCount && !ignoreComputedAromatic)) { if (arCount === 2) { return LinkStyle.MirroredAromatic; } else { -- GitLab