Browse Source

remove Model.customData

David Sehnal 4 years ago
parent
commit
90ddb3dc34

+ 2 - 2
src/extensions/g3d/format.ts

@@ -15,7 +15,7 @@ import { StateAction, StateObjectRef } from '../../mol-state';
 import { Task } from '../../mol-task';
 import { ParamDefinition } from '../../mol-util/param-definition';
 import { G3dHeader, getG3dDataBlock, getG3dHeader } from './data';
-import { g3dHaplotypeQuery, G3dLabelProvider, trajectoryFromG3D, G3dSymbols, getG3dInfoData } from './model';
+import { g3dHaplotypeQuery, G3dLabelProvider, trajectoryFromG3D, G3dSymbols, G3dInfoDataProperty } from './model';
 import { StateTransforms } from '../../mol-plugin-state/transforms';
 import { createStructureRepresentationParams } from '../../mol-plugin-state/helpers/structure-representation-params';
 import { stringToWords } from '../../mol-util/string';
@@ -45,7 +45,7 @@ async function defaultStructure(plugin: PluginContext, data: { trajectory: State
     if (!model) return;
     const structure = await builder.createStructure(model);
 
-    const info = getG3dInfoData(model.data!);
+    const info = G3dInfoDataProperty.get(model.data!);
     if (!info) return;
 
     const components = plugin.build().to(structure);

+ 8 - 13
src/extensions/g3d/model.ts

@@ -11,7 +11,7 @@ import { createModels } from '../../mol-model-formats/structure/basic/parser';
 import { BasicSchema, createBasic } from '../../mol-model-formats/structure/basic/schema';
 import { EntityBuilder } from '../../mol-model-formats/structure/common/entity';
 import { Loci } from '../../mol-model/loci';
-import { Model, Trajectory, Unit } from '../../mol-model/structure';
+import { Trajectory, Unit } from '../../mol-model/structure';
 import { MoleculeType } from '../../mol-model/structure/model/types';
 import { LociLabelProvider } from '../../mol-plugin-state/manager/loci-label';
 import { MolScriptBuilder as MS } from '../../mol-script/language/builder';
@@ -21,6 +21,7 @@ import { QuerySymbolRuntime } from '../../mol-script/runtime/query/base';
 import { RuntimeContext, Task } from '../../mol-task';
 import { objectForEach } from '../../mol-util/object';
 import { G3dDataBlock } from './data';
+import { FormatPropertyProvider } from '../../mol-model-formats/structure/common/property';
 
 interface NormalizedData {
     entity_id: string[],
@@ -148,12 +149,12 @@ async function getTraj(ctx: RuntimeContext, data: G3dDataBlock) {
 
     const models = await createModels(basic, { kind: 'g3d', name: 'G3D', data }, ctx);
 
-    models.representative.customData.g3dInfo = {
+    G3dInfoDataProperty.set(models.representative, {
         haplotypes: Object.keys(data.data),
         haplotype: normalized.haplotype,
         resolution: data.resolution,
         start: normalized.start
-    } as G3dInfoData;
+    });
 
     return models;
 }
@@ -168,7 +169,7 @@ export const G3dSymbols = {
     haplotype: QuerySymbolRuntime.Dynamic(CustomPropSymbol('g3d', 'haplotype', Type.Str),
         ctx => {
             if (Unit.isAtomic(ctx.element.unit)) return '';
-            const info =  getG3dInfoData(ctx.element.unit.model);
+            const info = (G3dInfoDataProperty as any).get(ctx.element.unit.model);
             if (!info) return '';
             const seqId = ctx.element.unit.model.coarseHierarchy.spheres.seq_id_begin.value(ctx.element.element);
             return info.haplotype[seqId] || '';
@@ -176,6 +177,8 @@ export const G3dSymbols = {
     )
 };
 
+export const G3dInfoDataProperty = FormatPropertyProvider.create<G3dInfoData>({ name: 'g3d_info' });
+
 export function g3dHaplotypeQuery(haplotype: string) {
     return MS.struct.generator.atomGroups({
         'chain-test': MS.core.rel.eq([G3dSymbols.haplotype.symbol(), haplotype]),
@@ -189,21 +192,13 @@ export interface G3dInfoData {
     resolution: number
 };
 
-export function setG3dInfoData(model: Model, data: G3dInfoData) {
-    model.customData.g3dInfo = data;
-}
-
-export function getG3dInfoData(model: Model): G3dInfoData | undefined {
-    return model.customData.g3dInfo;
-}
-
 export const G3dLabelProvider: LociLabelProvider = {
     label: (e: Loci): string | undefined => {
         if (e.kind !== 'element-loci' || Loci.isEmpty(e)) return;
 
         const first = e.elements[0];
         if (e.elements.length !== 1 || Unit.isAtomic(first.unit)) return;
-        const info = getG3dInfoData(first.unit.model);
+        const info = G3dInfoDataProperty.get(first.unit.model);
         if (!info) return;
 
         const eI = first.unit.elements[OrderedSet.getAt(first.indices, 0)];

+ 0 - 2
src/mol-model-formats/structure/basic/parser.ts

@@ -79,7 +79,6 @@ function createStandardModel(data: BasicData, atom_site: AtomSite, sourceIndex:
         coarseHierarchy: coarse.hierarchy,
         coarseConformation: coarse.conformation,
         properties,
-        customData: Object.create(null),
         customProperties: new CustomProperties(),
         _staticPropertyData: Object.create(null),
         _dynamicPropertyData: Object.create(null)
@@ -119,7 +118,6 @@ function createIntegrativeModel(data: BasicData, ihm: CoarseData, properties: Mo
         coarseHierarchy: coarse.hierarchy,
         coarseConformation: coarse.conformation,
         properties,
-        customData: Object.create(null),
         customProperties: new CustomProperties(),
         _staticPropertyData: Object.create(null),
         _dynamicPropertyData: Object.create(null)

+ 0 - 6
src/mol-model/structure/model/model.ts

@@ -72,12 +72,6 @@ export interface Model extends Readonly<{
         readonly structAsymMap: StructAsymMap
     },
 
-    /**
-     * Object that allows to store any custom related to the model,
-     * This is different from the custom properties to bypass having to store the data
-     * in the CustomProperty props.
-     */
-    customData: { [key: string]: any },
     customProperties: CustomProperties,
 
     /**