Browse Source

fixed expandConnected query, added expand to cov/metallic bonds

David Sehnal 5 years ago
parent
commit
c04fa56c6c

+ 0 - 6
src/mol-model/structure/query/queries/modifiers.ts

@@ -340,9 +340,6 @@ function expandConnected(ctx: QueryContext, structure: Structure) {
     const interBonds = inputStructure.interUnitBonds;
     const builder = new StructureUniqueSubsetBuilder(inputStructure);
 
-    // Note: each bond is visited twice so that bond.atom-a and bond.atom-b both get the "swapped values"
-    const visitedSourceUnits = new Set<number>();
-
     const atomicBond = ctx.atomicBond;
 
     // Process intra unit bonds
@@ -394,7 +391,6 @@ function expandConnected(ctx: QueryContext, structure: Structure) {
 
         // Process inter unit bonds
         for (const bondedUnit of interBonds.getConnectedUnits(inputUnitA)) {
-            if (visitedSourceUnits.has(bondedUnit.unitB.id)) continue;
             const currentUnitB = structure.unitMap.get(bondedUnit.unitB.id);
 
             for (const aI of bondedUnit.connectedIndices) {
@@ -422,8 +418,6 @@ function expandConnected(ctx: QueryContext, structure: Structure) {
                 }
             }
         }
-
-        visitedSourceUnits.add(inputUnitA.id);
     }
 
     return builder.getStructure();

+ 22 - 3
src/mol-plugin-state/helpers/structure-selection-query.ts

@@ -74,7 +74,7 @@ function StructureSelectionQuery(label: string, expression: Expression, props: S
         ensureCustomProperties: props.ensureCustomProperties,
         async getSelection(plugin, runtime, structure) {
             const current = plugin.managers.structure.selection.getStructure(structure);
-            const currentSelection = current ? StructureSelection.Singletons(structure, current) : StructureSelection.Empty(structure);
+            const currentSelection = current ? StructureSelection.Sequence(structure, [current]) : StructureSelection.Empty(structure);
             if (props.ensureCustomProperties) {
                 await props.ensureCustomProperties({ runtime, assetManager: plugin.managers.asset }, structure);
             }
@@ -373,7 +373,7 @@ const complement = StructureSelectionQuery('Inverse / Complement of Selection',
     referencesCurrent: true
 });
 
-const bonded = StructureSelectionQuery('Residues Bonded to Selection', MS.struct.modifier.union([
+const covalentlyBonded = StructureSelectionQuery('Residues Covalently Bonded to Selection', MS.struct.modifier.union([
     MS.struct.modifier.includeConnected({
         0: MS.internal.generator.current(), 'layer-count': 1, 'as-whole-residues': true
     })
@@ -383,6 +383,24 @@ const bonded = StructureSelectionQuery('Residues Bonded to Selection', MS.struct
     referencesCurrent: true
 });
 
+const covalentlyOrMetallicBonded = StructureSelectionQuery('Residues with Cov. or Metallic Bond to Selection', MS.struct.modifier.union([
+    MS.struct.modifier.includeConnected({
+        0: MS.internal.generator.current(),
+        'layer-count': 1,
+        'as-whole-residues': true,
+        'bond-test': MS.core.flags.hasAny([
+            MS.struct.bondProperty.flags(),
+            MS.core.type.bitflags([
+                BondType.Flag.Covalent | BondType.Flag.MetallicCoordination
+            ])
+        ])
+    })
+]), {
+    description: 'Select residues covalently bonded to current selection.',
+    category: StructureSelectionCategory.Manipulate,
+    referencesCurrent: true
+});
+
 const wholeResidues = StructureSelectionQuery('Whole Residues of Selection', MS.struct.modifier.union([
     MS.struct.modifier.wholeResidues({
         0: MS.internal.generator.current()
@@ -551,7 +569,8 @@ export const StructureSelectionQueries = {
     aromaticRing,
     surroundings,
     complement,
-    bonded,
+    covalentlyBonded,
+    covalentlyOrMetallicBonded,
     wholeResidues,
 };