Browse Source

only extract CrossLinkRestraints when needed

Alexander Rose 5 years ago
parent
commit
6b874786a8

+ 5 - 2
src/mol-model/structure/structure/unit/pair-restraints/extract-cross-links.ts

@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ * Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
@@ -89,6 +89,7 @@ function createCrossLinkRestraint(unitA: Unit, indexA: StructureElement.UnitInde
 
 function extractCrossLinkRestraints(structure: Structure): PairRestraints<CrossLinkRestraint> {
     const pairs: CrossLinkRestraint[] = []
+    if (!structure.models.some(m => IHMCrossLinkRestraint.fromModel(m))) return new PairRestraints(pairs)
 
     const n = structure.units.length
     for (let i = 0; i < n; ++i) {
@@ -96,7 +97,9 @@ function extractCrossLinkRestraints(structure: Structure): PairRestraints<CrossL
         extractIntra(pairs, unitA)
         for (let j = i + 1; j < n; ++j) {
             const unitB = structure.units[j]
-            extractInter(pairs, unitA, unitB)
+            if (unitA.model === unitB.model) {
+                extractInter(pairs, unitA, unitB)
+            }
         }
     }