Browse Source

Merge branch 'master' of https://github.com/molstar/molstar

Alexander Rose 5 years ago
parent
commit
f4dbd66496

+ 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);
             }
@@ -411,7 +411,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
     })
@@ -421,6 +421,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()
@@ -591,7 +609,8 @@ export const StructureSelectionQueries = {
     aromaticRing,
     surroundings,
     complement,
-    bonded,
+    covalentlyBonded,
+    covalentlyOrMetallicBonded,
     wholeResidues,
 };
 

+ 16 - 5
src/mol-plugin-ui/state/snapshots.tsx

@@ -211,11 +211,18 @@ export class RemoteStateSnapshots extends PluginUIComponent<
         }, { isFlat: true })
     };
 
+    private _mounted = false;
     componentDidMount() {
         this.refresh();
+        // TODO: solve this by using "PluginComponent" with behaviors intead
+        this._mounted = true;
         // this.subscribe(UploadedEvent, this.refresh);
     }
 
+    componentWillUnmount() {
+        this._mounted = false;
+    }
+
     serverUrl(q?: string) {
         if (!q) return this.state.params.options.serverUrl;
         return urlCombine(this.state.params.options.serverUrl, q);
@@ -242,10 +249,10 @@ export class RemoteStateSnapshots extends PluginUIComponent<
                 });
             }
 
-            this.setState({ entries: entries.asImmutable(), isBusy: false });
+            if (this._mounted) this.setState({ entries: entries.asImmutable(), isBusy: false });
         } catch (e) {
             this.plugin.log.error('Fetching Remote Snapshots: ' + e);
-            this.setState({ entries: OrderedMap(), isBusy: false });
+            if (this._mounted) this.setState({ entries: OrderedMap(), isBusy: false });
         }
     }
 
@@ -260,11 +267,15 @@ export class RemoteStateSnapshots extends PluginUIComponent<
             serverUrl: this.state.params.options.serverUrl
         });
 
-        this.setState({ isBusy: false });
         this.plugin.log.message('Snapshot uploaded.');
-        this.refresh();
+
+        if (this._mounted) {
+            this.setState({ isBusy: false });
+            this.refresh();
+        }
     }
 
+
     fetch = async (e: React.MouseEvent<HTMLElement>) => {
         const id = e.currentTarget.getAttribute('data-id');
         if (!id) return;
@@ -275,7 +286,7 @@ export class RemoteStateSnapshots extends PluginUIComponent<
         try {
             await PluginCommands.State.Snapshots.Fetch(this.plugin, { url: entry.url });
         } finally {
-            this.setState({ isBusy: false });
+            if (this._mounted) this.setState({ isBusy: false });
         }
     }