Browse Source

Remove StructureBuilderTags.Component
+ remove some unused code

David Sehnal 5 years ago
parent
commit
538371ced8

+ 1 - 1
src/mol-model/structure/common/custom-property.ts

@@ -69,6 +69,6 @@ class CustomProperties {
     }
 
     has(desc: CustomPropertyDescriptor<any>): boolean {
-        return this._refs.has(desc);
+        return this._set.has(desc);
     }
 }

+ 1 - 38
src/mol-plugin-state/actions/structure.ts

@@ -6,11 +6,10 @@
  */
 
 import { PluginContext } from '../../mol-plugin/context';
-import { StateAction, StateBuilder, StateSelection, StateTransformer } from '../../mol-state';
+import { StateAction, StateSelection, StateTransformer } from '../../mol-state';
 import { Task } from '../../mol-task';
 import { FileInfo } from '../../mol-util/file-info';
 import { ParamDefinition as PD } from '../../mol-util/param-definition';
-import { TrajectoryFormat } from '../builder/structure';
 import { BuiltInTrajectoryFormat } from '../formats/trajectory';
 import { RootStructureDefinition } from '../helpers/root-structure';
 import { PluginStateObject } from '../objects';
@@ -267,42 +266,6 @@ function getDownloadParams(src: string, url: (id: string) => string, label: (id:
     return ret;
 }
 
-export function createModelTree(b: StateBuilder.To<PluginStateObject.Data.Binary | PluginStateObject.Data.String>, format: TrajectoryFormat = 'cif') {
-    let parsed: StateBuilder.To<PluginStateObject.Molecule.Trajectory>
-    switch (format) {
-        case 'cif':
-            parsed = b.apply(StateTransforms.Data.ParseCif, void 0, { state: { isGhost: true } })
-                .apply(StateTransforms.Model.TrajectoryFromMmCif)
-            break
-        case 'pdb':
-            parsed = b.apply(StateTransforms.Model.TrajectoryFromPDB);
-            break
-        case 'gro':
-            parsed = b.apply(StateTransforms.Model.TrajectoryFromGRO);
-            break
-        case '3dg':
-            parsed = b.apply(StateTransforms.Model.TrajectoryFrom3DG);
-            break
-        default:
-            throw new Error('unsupported format')
-    }
-
-    return parsed.apply(StateTransforms.Model.ModelFromTrajectory, { modelIndex: 0 });
-}
-
-export const Create3DRepresentationPreset = StateAction.build({
-    display: { name: '3D Representation Preset', description: 'Create one of preset 3D representations.' },
-    from: PluginStateObject.Molecule.Structure,
-    isApplicable(a, _, plugin: PluginContext) { return plugin.builders.structure.representation.hasPreset(a); },
-    params(a, plugin: PluginContext) {
-        return {
-            type: plugin.builders.structure.representation.getPresetsWithOptions(a)
-        };
-    }
-})(({ ref, params }, plugin: PluginContext) => {
-    return plugin.builders.structure.representation.applyPreset(ref, params.type.name, params.type.params);
-});
-
 export const UpdateTrajectory = StateAction.build({
     display: { name: 'Update Trajectory' },
     params: {

+ 1 - 8
src/mol-plugin-state/builder/structure.ts

@@ -19,13 +19,6 @@ import { ModelSymmetry } from '../../mol-model-formats/structure/property/symmet
 import { SpacegroupCell } from '../../mol-math/geometry';
 import Expression from '../../mol-script/language/expression';
 
-export type TrajectoryFormat = 'pdb' | 'cif' | 'gro' | '3dg'
-
-export enum StructureBuilderTags {
-    // TODO: this tag might be redundant
-    Component = 'structure-component'
-}
-
 export class StructureBuilder {
     private get dataState() {
         return this.plugin.state.data;
@@ -130,7 +123,7 @@ export class StructureBuilder {
 
         const keyTag = `structure-component-${key}`;
         const component = root.applyOrUpdateTagged(keyTag, StateTransforms.Model.StructureComponent, params, {
-            tags: tags ? [...tags, StructureBuilderTags.Component, keyTag] : [StructureBuilderTags.Component, keyTag]
+            tags: tags ? [...tags, keyTag] : [keyTag]
         });
 
         await this.plugin.updateDataState(component);

+ 3 - 6
src/mol-plugin-state/manager/structure/hierarchy-state.ts

@@ -6,7 +6,6 @@
 
 import { PluginStateObject as SO } from '../../objects';
 import { StateObject, StateTransform, State, StateObjectCell, StateTree, StateTransformer } from '../../../mol-state';
-import { StructureBuilderTags } from '../../builder/structure';
 import { StateTransforms } from '../../transforms';
 import { VolumeStreaming } from '../../../mol-plugin/behavior/dynamic/volume-streaming/behavior';
 import { CreateVolumeStreamingBehavior } from '../../../mol-plugin/behavior/dynamic/volume-streaming/transformers';
@@ -253,10 +252,8 @@ const tagMap: [TestCell, ApplyRef, LeaveRef][] = [
 
     // Component
     [(cell, state) => {
-        if (!state.currentStructure || !SO.Molecule.Structure.is(cell.obj) || cell.transform.transformer.definition.isDecorator) return false;
-        if (StateObject.hasTag(cell.obj!, StructureBuilderTags.Component)) return true;
-        const parent = state.state.cells.get(cell.transform.parent);
-        return SO.Molecule.Structure.is(parent?.obj) && SO.Molecule.Structure.is(cell.obj);
+        if (state.currentComponent || !state.currentStructure || cell.transform.transformer.definition.isDecorator) return false;
+        return SO.Molecule.Structure.is(cell.obj);
     }, (state, cell) => {
         if (state.currentStructure) {
             state.currentComponent = createOrUpdateRefList(state, cell, state.currentStructure.components, StructureComponentRef, cell, state.currentStructure);
@@ -271,7 +268,7 @@ const tagMap: [TestCell, ApplyRef, LeaveRef][] = [
             createOrUpdateRefList(state, cell, state.currentComponent.representations, StructureRepresentationRef, cell, state.currentComponent);
         }
 
-        // Nothing useful down the line;
+        // Nothing useful down the line
         return false;
     }, noop],
 

+ 1 - 1
src/mol-plugin/behavior/dynamic/custom-props/pdbe/structure-quality-report.ts

@@ -31,7 +31,7 @@ export const PDBeStructureQualityReport = PluginBehavior.create<{ autoAttach: bo
                     if (loci.elements.length === 0) return void 0;
                     const e = loci.elements[0];
                     const u = e.unit;
-                    if (!u.model.customProperties.has(StructureQualityReportProvider.descriptor) || !u.model.customProperties.hasReference(StructureQualityReportProvider.descriptor)) return void 0;
+                    if (!u.model.customProperties.hasReference(StructureQualityReportProvider.descriptor)) return void 0;
 
                     const se = StructureElement.Location.create(loci.structure, u, u.elements[OrderedSet.getAt(e.indices, 0)]);
                     const issues = StructureQualityReport.getIssues(se);

+ 3 - 3
src/mol-plugin/index.ts

@@ -25,7 +25,6 @@ export const DefaultPluginSpec: PluginSpec = {
         PluginSpec.Action(StateActions.Structure.AddTrajectory),
         PluginSpec.Action(StateActions.Volume.DownloadDensity),
         PluginSpec.Action(StateActions.DataFormat.OpenFiles),
-        PluginSpec.Action(StateActions.Structure.Create3DRepresentationPreset),
         PluginSpec.Action(StateActions.Structure.EnableModelCustomProps),
         PluginSpec.Action(StateActions.Structure.EnableStructureCustomProps),
 
@@ -75,7 +74,7 @@ export const DefaultPluginSpec: PluginSpec = {
         PluginSpec.Behavior(PluginBehaviors.CustomProps.ValenceModel),
         PluginSpec.Behavior(PluginBehaviors.CustomProps.CrossLinkRestraint),
 
-        PluginSpec.Behavior(PluginBehaviors.CustomProps.PDBeStructureQualityReport, { autoAttach: true, showTooltip: true }),
+        PluginSpec.Behavior(PluginBehaviors.CustomProps.PDBeStructureQualityReport),
         PluginSpec.Behavior(PluginBehaviors.CustomProps.RCSBAssemblySymmetry),
         PluginSpec.Behavior(PluginBehaviors.CustomProps.RCSBValidationReport),
     ],
@@ -89,7 +88,8 @@ export const DefaultPluginSpec: PluginSpec = {
         AnimateStateInterpolation
     ],
     config: new Map([
-        [PluginConfig.State.DefaultServer, 'https://webchem.ncbr.muni.cz/molstar-state']
+        [PluginConfig.State.DefaultServer, 'https://webchem.ncbr.muni.cz/molstar-state'],
+        [PluginConfig.VolumeStreaming.DefaultServer, 'https://ds.litemol.org']
     ])
 }