Browse Source

improve bonds assignment of coarse grained models

- check for IndexPairBonds and exhaustive StructConn
Alexander Rose 3 years ago
parent
commit
4d97ccdfb3

+ 1 - 0
CHANGELOG.md

@@ -8,6 +8,7 @@ Note that since we don't clearly distinguish between a public and private interf
 
 - Check that model and coordinates have same element count when creating a trajectory
 - Fix aromatic rings assignment: do not mix flags and planarity test
+- Improve bonds assignment of coarse grained models: check for IndexPairBonds and exhaustive StructConn
 
 ## [v3.5.0] - 2022-03-25
 

+ 2 - 4
src/mol-model/structure/structure/unit/bonds/inter-compute.ts

@@ -205,11 +205,9 @@ const DefaultInterBondComputationProps = {
 function findBonds(structure: Structure, props: InterBondComputationProps) {
     const builder = new InterUnitGraph.Builder<number, StructureElement.UnitIndex, InterUnitEdgeProps>();
     const hasIndexPairBonds = structure.models.some(m => IndexPairBonds.Provider.get(m));
+    const hasExhaustiveStructConn = structure.models.some(m => StructConn.isExhaustive(m));
 
-    if (props.noCompute || (structure.isCoarseGrained && !hasIndexPairBonds)) {
-        // TODO add function that only adds bonds defined in structConn and avoids using
-        //      structure.lookup and unit.lookup (expensive for large structure and not
-        //      needed for archival files or files with an MD topology)
+    if (props.noCompute || (structure.isCoarseGrained && !hasIndexPairBonds && !hasExhaustiveStructConn)) {
         return new InterUnitBonds(builder.getMap());
     }
 

+ 1 - 3
src/mol-model/structure/structure/unit/bonds/intra-compute.ts

@@ -255,9 +255,7 @@ function findBonds(unit: Unit.Atomic, props: BondComputationProps): IntraUnitBon
 
 function computeIntraUnitBonds(unit: Unit.Atomic, props?: Partial<BondComputationProps>) {
     const p = { ...DefaultBondComputationProps, ...props };
-    if (p.noCompute || Model.isCoarseGrained(unit.model)) {
-        // TODO add function that only adds bonds defined in structConn of chemCompBond
-        //      and avoid using unit.lookup
+    if (p.noCompute || (Model.isCoarseGrained(unit.model) && !IndexPairBonds.Provider.get(unit.model) && !StructConn.isExhaustive(unit.model))) {
         return IntraUnitBonds.Empty;
     }