Jelajahi Sumber

operators in IndexPairBonds as directed property

Alexander Rose 1 tahun lalu
induk
melakukan
781824c961

+ 2 - 0
CHANGELOG.md

@@ -6,6 +6,8 @@ Note that since we don't clearly distinguish between a public and private interf
 
 ## [Unreleased]
 
+- Make operators in `IndexPairBonds` a directed property
+
 ## [v3.35.0] - 2023-05-14
 
 - Enable odd dash count (1,3,5)

+ 8 - 1
src/mol-math/graph/int-adjacency-graph.ts

@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ * Copyright (c) 2018-2023 mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
  * @author David Sehnal <david.sehnal@gmail.com>
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
@@ -176,6 +176,13 @@ export namespace IntAdjacencyGraph {
             prop[this.curB] = value;
         }
 
+        assignDirectedProperty<T>(propA: { [i: number]: T }, valueA: T, propB: { [i: number]: T }, valueB: T) {
+            propA[this.curA] = valueA;
+            propA[this.curB] = valueB;
+            propB[this.curB] = valueA;
+            propB[this.curA] = valueB;
+        }
+
         constructor(public vertexCount: number, public xs: ArrayLike<VertexIndex>, public ys: ArrayLike<VertexIndex>) {
             this.edgeCount = xs.length;
             this.offsets = new Int32Array(this.vertexCount + 1);

+ 5 - 3
src/mol-model-formats/structure/property/bonds/index-pair.ts

@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2019-2022 Mol* contributors, licensed under MIT, See LICENSE file for more info.
+ * Copyright (c) 2019-2023 Mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  * @author David Sehnal <david.sehnal@gmail.com>
@@ -34,8 +34,10 @@ function getGraph(indexA: ArrayLike<ElementIndex>, indexB: ArrayLike<ElementInde
     for (let i = 0, _i = builder.edgeCount; i < _i; i++) {
         builder.addNextEdge();
         builder.assignProperty(key, props.key ? props.key[i] : -1);
-        builder.assignProperty(operatorA, props.operatorA ? props.operatorA[i] : -1);
-        builder.assignProperty(operatorB, props.operatorB ? props.operatorB[i] : -1);
+        builder.assignDirectedProperty(
+            operatorA, props.operatorA ? props.operatorA[i] : -1,
+            operatorB, props.operatorB ? props.operatorB[i] : -1
+        );
         builder.assignProperty(order, props.order ? props.order[i] : 1);
         builder.assignProperty(distance, props.distance ? props.distance[i] : -1);
         builder.assignProperty(flag, props.flag ? props.flag[i] : BondType.Flag.Covalent);