Bladeren bron

Element => ElementIndex, Element.Location => StructureElement

David Sehnal 6 jaren geleden
bovenliggende
commit
8cce7a8a79

+ 2 - 2
src/apps/structure-info/model.ts

@@ -9,7 +9,7 @@ import * as argparse from 'argparse'
 require('util.promisify').shim();
 
 import { CifFrame } from 'mol-io/reader/cif'
-import { Model, Structure, Element, Unit, Format, StructureProperties } from 'mol-model/structure'
+import { Model, Structure, StructureElement, Unit, Format, StructureProperties } from 'mol-model/structure'
 // import { Run, Progress } from 'mol-task'
 import { OrderedSet } from 'mol-data/int';
 import { openCif, downloadCif } from './helpers';
@@ -146,7 +146,7 @@ export function printRings(structure: Structure) {
 
 export function printUnits(structure: Structure) {
     console.log('\nUnits\n=============');
-    const l = Element.Location();
+    const l = StructureElement.create();
 
     for (const unit of structure.units) {
         l.unit = unit;

+ 3 - 3
src/mol-geo/representation/structure/visual/polymer-trace-mesh.ts

@@ -7,7 +7,7 @@
 import { ValueCell } from 'mol-util/value-cell'
 
 import { createMeshRenderObject, MeshRenderObject } from 'mol-gl/render-object'
-import { Unit, Element } from 'mol-model/structure';
+import { Unit, StructureElement } from 'mol-model/structure';
 import { DefaultStructureProps, UnitsVisual } from '../index';
 import { RuntimeContext } from 'mol-task'
 import { createTransforms, createColors } from './util/common';
@@ -134,8 +134,8 @@ export function PolymerTraceVisual(): UnitsVisual<PolymerTraceProps> {
             const { objectId, instanceId, elementId } = pickingId
             if (renderObject.id === objectId) {
                 const unit = currentGroup.units[instanceId]
-                const indices = OrderedSet.ofSingleton(elementId as Element.Index);
-                return Element.Loci([{ unit, indices }])
+                const indices = OrderedSet.ofSingleton(elementId as StructureElement.Index);
+                return StructureElement.Loci([{ unit, indices }])
             }
             return EmptyLoci
         },

+ 7 - 7
src/mol-geo/representation/structure/visual/util/element.ts

@@ -5,7 +5,7 @@
  */
 
 import { Vec3 } from 'mol-math/linear-algebra';
-import { Unit, Element } from 'mol-model/structure';
+import { Unit, StructureElement } from 'mol-model/structure';
 import { SizeTheme } from '../../../../theme';
 import { RuntimeContext } from 'mol-task';
 import { icosahedronVertexCount } from '../../../../primitive/icosahedron';
@@ -19,7 +19,7 @@ import { Interval, OrderedSet } from 'mol-data/int';
 import { getPhysicalRadius } from '../../../../theme/structure/size/physical';
 import { PickingId } from '../../../../util/picking';
 
-export function getElementRadius(unit: Unit, props: SizeTheme): Element.Property<number> {
+export function getElementRadius(unit: Unit, props: SizeTheme): StructureElement.Property<number> {
     switch (props.name) {
         case 'uniform':
             return () => props.value
@@ -30,7 +30,7 @@ export function getElementRadius(unit: Unit, props: SizeTheme): Element.Property
     }
 }
 
-export async function createElementSphereMesh(ctx: RuntimeContext, unit: Unit, radius: Element.Property<number>, detail: number, mesh?: Mesh) {
+export async function createElementSphereMesh(ctx: RuntimeContext, unit: Unit, radius: StructureElement.Property<number>, detail: number, mesh?: Mesh) {
     const { elements } = unit;
     const elementCount = elements.length;
     const vertexCount = elementCount * icosahedronVertexCount(detail)
@@ -38,7 +38,7 @@ export async function createElementSphereMesh(ctx: RuntimeContext, unit: Unit, r
 
     const v = Vec3.zero()
     const pos = unit.conformation.invariantPosition
-    const l = Element.Location()
+    const l = StructureElement.create()
     l.unit = unit
 
     for (let i = 0; i < elementCount; i++) {
@@ -64,7 +64,7 @@ export function markElement(tMarker: ValueCell<TextureImage>, group: Unit.Symmet
     if (isEveryLoci(loci)) {
         applyMarkerAction(array, 0, elementCount * instanceCount, action)
         changed = true
-    } else if (Element.isLoci(loci)) {
+    } else if (StructureElement.isLoci(loci)) {
         for (const e of loci.elements) {
             const unitIdx = Unit.findUnitById(e.unit.id, group.units)
             if (unitIdx !== -1) {
@@ -96,8 +96,8 @@ export function getElementLoci(id: number, group: Unit.SymmetryGroup, pickingId:
     const { objectId, instanceId, elementId } = pickingId
     if (id === objectId) {
         const unit = group.units[instanceId]
-        const indices = OrderedSet.ofSingleton(elementId as Element.Index);
-        return Element.Loci([{ unit, indices }])
+        const indices = OrderedSet.ofSingleton(elementId as StructureElement.Index);
+        return StructureElement.Loci([{ unit, indices }])
     }
     return EmptyLoci
 }

+ 10 - 10
src/mol-geo/representation/structure/visual/util/polymer.ts

@@ -4,7 +4,7 @@
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
 
-import { Unit, Element, StructureProperties, ElementIndex } from 'mol-model/structure';
+import { Unit, StructureElement, StructureProperties, ElementIndex } from 'mol-model/structure';
 import { Segmentation } from 'mol-data/int';
 import { MoleculeType } from 'mol-model/structure/model/types';
 import Iterator from 'mol-data/iterator';
@@ -15,7 +15,7 @@ import { SymmetryOperator } from 'mol-math/geometry';
 export function getPolymerElementCount(unit: Unit) {
     let count = 0
     const { elements } = unit
-    const l = Element.Location(unit)
+    const l = StructureElement.create(unit)
     if (Unit.isAtomic(unit)) {
         const { polymerAtomSegments, residueAtomSegments } = unit.model.atomicHierarchy
         const polymerIt = Segmentation.transientSegments(polymerAtomSegments, elements);
@@ -36,7 +36,7 @@ export function getPolymerElementCount(unit: Unit) {
     return count
 }
 
-function getTraceName(l: Element.Location) {
+function getTraceName(l: StructureElement) {
     const compId = StructureProperties.residue.label_comp_id(l)
     const chemCompMap = l.unit.model.properties.chemicalComponentMap
     const cc = chemCompMap.get(compId)
@@ -50,7 +50,7 @@ function getTraceName(l: Element.Location) {
     return traceName
 }
 
-function setTraceElement(l: Element.Location, residueSegment: Segmentation.Segment<ElementIndex>) {
+function setTraceElement(l: StructureElement, residueSegment: Segmentation.Segment<ElementIndex>) {
     const elements = l.unit.elements
     l.element = elements[residueSegment.start]
     const traceName = getTraceName(l)
@@ -73,8 +73,8 @@ export function PolymerBackboneIterator(unit: Unit): Iterator<PolymerBackbonePai
 }
 
 interface PolymerBackbonePair {
-    centerA: Element.Location
-    centerB: Element.Location
+    centerA: StructureElement
+    centerB: StructureElement
     indexA: number
     indexB: number
     posA: Vec3
@@ -83,8 +83,8 @@ interface PolymerBackbonePair {
 
 function createPolymerBackbonePair (unit: Unit) {
     return {
-        centerA: Element.Location(unit),
-        centerB: Element.Location(unit),
+        centerA: StructureElement.create(unit),
+        centerB: StructureElement.create(unit),
         indexA: 0,
         indexB: 0,
         posA: Vec3.zero(),
@@ -244,7 +244,7 @@ export function PolymerTraceIterator(unit: Unit): Iterator<PolymerTraceElement>
 }
 
 interface PolymerTraceElement {
-    center: Element.Location
+    center: StructureElement
     index: number
     pos: Vec3
     posPrev: Vec3
@@ -254,7 +254,7 @@ interface PolymerTraceElement {
 
 function createPolymerTraceElement (unit: Unit) {
     return {
-        center: Element.Location(unit),
+        center: StructureElement.create(unit),
         index: 0,
         pos: Vec3.zero(),
         posPrev: Vec3.zero(),

+ 7 - 7
src/mol-geo/theme/structure/color/chain-id.ts

@@ -4,13 +4,13 @@
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
 
-import { Unit, StructureProperties, Element } from 'mol-model/structure';
+import { Unit, StructureProperties, StructureElement } from 'mol-model/structure';
 
 import { StructureColorDataProps } from '.';
 import { ColorData, createElementColor, createUniformColor } from '../../../util/color-data';
 import { ColorScale } from 'mol-util/color';
 
-function getAsymId(unit: Unit): Element.Property<string> {
+function getAsymId(unit: Unit): StructureElement.Property<string> {
     switch (unit.kind) {
         case Unit.Kind.Atomic:
             return StructureProperties.chain.label_asym_id
@@ -21,7 +21,7 @@ function getAsymId(unit: Unit): Element.Property<string> {
     throw new Error('unhandled unit kind')
 }
 
-export function chainIdColorData(props: StructureColorDataProps, locationFn: (l: Element.Location, renderElementIdx: number) => void, colorData?: ColorData) {
+export function chainIdColorData(props: StructureColorDataProps, locationFn: (l: StructureElement, renderElementIdx: number) => void, colorData?: ColorData) {
     const { group: { units }, elementCount } = props
     const unit = units[0]
 
@@ -32,7 +32,7 @@ export function chainIdColorData(props: StructureColorDataProps, locationFn: (l:
     const scale = ColorScale.create({ domain })
     const asym_id = getAsymId(unit)
 
-    const l = Element.Location()
+    const l = StructureElement.create()
     l.unit = unit
 
     return createElementColor({
@@ -46,7 +46,7 @@ export function chainIdColorData(props: StructureColorDataProps, locationFn: (l:
 
 export function chainIdElementColorData(props: StructureColorDataProps, colorData?: ColorData) {
     const elements = props.group.units[0].elements
-    function locationFn(l: Element.Location, renderElementIdx: number) {
+    function locationFn(l: StructureElement, renderElementIdx: number) {
         l.element = elements[renderElementIdx]
     }
     return chainIdColorData(props, locationFn, colorData)
@@ -55,11 +55,11 @@ export function chainIdElementColorData(props: StructureColorDataProps, colorDat
 export function chainIdLinkColorData(props: StructureColorDataProps, colorData?: ColorData): ColorData {
     const unit = props.group.units[0]
     const elements = unit.elements
-    let locationFn: (l: Element.Location, renderElementIdx: number) => void
+    let locationFn: (l: StructureElement, renderElementIdx: number) => void
     switch (unit.kind) {
         case Unit.Kind.Atomic:
             const { a } = unit.links
-            locationFn = (l: Element.Location, renderElementIdx: number) => {
+            locationFn = (l: StructureElement, renderElementIdx: number) => {
                 l.element = elements[a[renderElementIdx]]
             }
             return chainIdColorData(props, locationFn, colorData)

+ 3 - 3
src/mol-geo/theme/structure/size/physical.ts

@@ -4,11 +4,11 @@
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
 
-import { Element, Unit, StructureProperties } from 'mol-model/structure';
+import { StructureElement, Unit, StructureProperties } from 'mol-model/structure';
 import { StructureSizeDataProps } from '.';
 import { createAttributeSize } from '../../../util/size-data';
 
-export function getPhysicalRadius(unit: Unit): Element.Property<number> {
+export function getPhysicalRadius(unit: Unit): StructureElement.Property<number> {
     if (Unit.isAtomic(unit)) {
         return StructureProperties.atom.vdw_radius
     } else if (Unit.isSpheres(unit)) {
@@ -27,7 +27,7 @@ export function physicalSizeData(factor: number, props: StructureSizeDataProps)
     const unit = group.units[0]
     const elements = group.elements;
     const radius = getPhysicalRadius(unit)
-    const l = Element.Location()
+    const l = StructureElement.create()
     l.unit = unit
     return createAttributeSize({
         sizeFn: (elementIdx: number) => {

+ 2 - 2
src/mol-model/loci.ts

@@ -4,7 +4,7 @@
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
 
-import { Element } from './structure'
+import { StructureElement } from './structure'
 import { Link } from './structure/structure/unit/links'
 
 /** A Loci that includes every loci */
@@ -21,4 +21,4 @@ export function isEmptyLoci(x: any): x is EmptyLoci {
     return !!x && x.kind === 'empty-loci';
 }
 
-export type Loci =  Element.Loci | Link.Loci | EveryLoci | EmptyLoci
+export type Loci =  StructureElement.Loci | Link.Loci | EveryLoci | EmptyLoci

+ 3 - 3
src/mol-model/structure/export/categories/atom_site.ts

@@ -6,13 +6,13 @@
  */
 
 import { CifWriter } from 'mol-io/writer/cif';
-import { Element, Structure, StructureProperties as P } from '../../structure';
+import { StructureElement, Structure, StructureProperties as P } from '../../structure';
 import { CifExportContext } from '../mmcif';
 import CifField = CifWriter.Field
 import CifCategory = CifWriter.Category
 import E = CifWriter.Encodings
 
-const atom_site_fields: CifField<Element.Location>[] = [
+const atom_site_fields: CifField<StructureElement>[] = [
     CifField.str('group_PDB', P.residue.group_PDB),
     CifField.index('id'),
     CifField.str('type_symbol', P.atom.type_symbol as any),
@@ -38,7 +38,7 @@ const atom_site_fields: CifField<Element.Location>[] = [
     CifField.str('auth_asym_id', P.chain.auth_asym_id),
 
     CifField.int('pdbx_PDB_model_num', P.unit.model_num, { encoder: E.deltaRLE }),
-    CifField.str<Element.Location, Structure>('operator_name', P.unit.operator_name, {
+    CifField.str<StructureElement, Structure>('operator_name', P.unit.operator_name, {
         shouldInclude: structure => structure.units.some(u => !u.conformation.operator.isIdentity)
     })
 ];

+ 6 - 6
src/mol-model/structure/export/categories/secondary-structure.ts

@@ -7,7 +7,7 @@
 import { Segmentation } from 'mol-data/int';
 import { CifWriter } from 'mol-io/writer/cif';
 import { SecondaryStructure } from '../../model/properties/seconday-structure';
-import { Element, Unit, StructureProperties as P } from '../../structure';
+import { StructureElement, Unit, StructureProperties as P } from '../../structure';
 import { CifExportContext } from '../mmcif';
 
 import CifField = CifWriter.Field
@@ -60,7 +60,7 @@ const struct_sheet_range_fields: CifField[] = [
     CifField.str('symmetry', (i, data) => '', { valueKind: (i, d) => Column.ValueKind.Unknown })
 ];
 
-function residueIdFields(prefix: string, loc: (e: SSElement<any>) => Element.Location): CifField<number, SSElement<SecondaryStructure.Helix>[]>[] {
+function residueIdFields(prefix: string, loc: (e: SSElement<any>) => StructureElement): CifField<number, SSElement<SecondaryStructure.Helix>[]>[] {
     return [
         CifField.str(`${prefix}label_comp_id`, (i, d) => P.residue.label_comp_id(loc(d[i]))),
         CifField.int(`${prefix}label_seq_id`, (i, d) => P.residue.label_seq_id(loc(d[i]))),
@@ -74,8 +74,8 @@ function residueIdFields(prefix: string, loc: (e: SSElement<any>) => Element.Loc
 }
 
 interface SSElement<T extends SecondaryStructure.Element> {
-    start: Element.Location,
-    end: Element.Location,
+    start: StructureElement,
+    end: StructureElement,
     length: number,
     element: T
 }
@@ -111,8 +111,8 @@ function findElements<T extends SecondaryStructure.Element>(ctx: CifExportContex
                 if (startIdx !== key[current.index]) {
                     move = false;
                     ssElements[ssElements.length] = {
-                        start: Element.Location(unit, segs.offsets[start]),
-                        end: Element.Location(unit, segs.offsets[prev]),
+                        start: StructureElement.create(unit, segs.offsets[start]),
+                        end: StructureElement.create(unit, segs.offsets[prev]),
                         length: prev - start + 1,
                         element
                     }

+ 2 - 2
src/mol-model/structure/model/formats/mmcif/bonds/comp.ts

@@ -9,7 +9,7 @@ import { Model } from '../../../model'
 import { LinkType } from '../../../types'
 import { ModelPropertyDescriptor } from '../../../properties/custom';
 import { mmCIF_Database } from 'mol-io/reader/cif/schema/mmcif';
-import { Structure, Unit, StructureProperties, Element } from '../../../../structure';
+import { Structure, Unit, StructureProperties, StructureElement } from '../../../../structure';
 import { Segmentation } from 'mol-data/int';
 import { CifWriter } from 'mol-io/writer/cif'
 
@@ -134,7 +134,7 @@ export namespace ComponentBond {
     function getUniqueResidueNames(s: Structure) {
         const prop = StructureProperties.residue.label_comp_id;
         const names = new Set<string>();
-        const loc = Element.Location();
+        const loc = StructureElement.create();
         for (const unit of s.units) {
             if (!Unit.isAtomic(unit)) continue;
             const residues = Segmentation.transientSegments(unit.model.atomicHierarchy.residueAtomSegments, unit.elements);

+ 11 - 11
src/mol-model/structure/query/generators.ts

@@ -6,22 +6,22 @@
 
 import Query from './query'
 import Selection from './selection'
-import { Element, Unit, StructureProperties as P } from '../structure'
+import { StructureElement, Unit, StructureProperties as P } from '../structure'
 import { OrderedSet, Segmentation } from 'mol-data/int'
 import { LinearGroupingBuilder } from './utils/builders';
 
 export const all: Query.Provider = async (s, ctx) => Selection.Singletons(s, s);
 
 export interface AtomQueryParams {
-    entityTest: Element.Predicate,
-    chainTest: Element.Predicate,
-    residueTest: Element.Predicate,
-    atomTest: Element.Predicate,
-    groupBy: Element.Property<any>
+    entityTest: StructureElement.Predicate,
+    chainTest: StructureElement.Predicate,
+    residueTest: StructureElement.Predicate,
+    atomTest: StructureElement.Predicate,
+    groupBy: StructureElement.Property<any>
 }
 
 export interface AtomGroupsQueryParams extends AtomQueryParams {
-    groupBy: Element.Property<any>
+    groupBy: StructureElement.Property<any>
 }
 
 export function residues(params?: Partial<AtomQueryParams>) { return atoms({ ...params, groupBy: P.residue.key }); }
@@ -43,10 +43,10 @@ export function atoms(params?: Partial<AtomGroupsQueryParams>): Query.Provider {
     return atomGroupsGrouped(normalized);
 }
 
-function atomGroupsLinear(atomTest: Element.Predicate): Query.Provider {
+function atomGroupsLinear(atomTest: StructureElement.Predicate): Query.Provider {
     return async (structure, ctx) => {
         const { units } = structure;
-        const l = Element.Location();
+        const l = StructureElement.create();
         const builder = structure.subsetBuilder(true);
 
         let progress = 0;
@@ -72,7 +72,7 @@ function atomGroupsLinear(atomTest: Element.Predicate): Query.Provider {
 function atomGroupsSegmented({ entityTest, chainTest, residueTest, atomTest }: AtomGroupsQueryParams): Query.Provider {
     return async (structure, ctx) => {
         const { units } = structure;
-        const l = Element.Location();
+        const l = StructureElement.create();
         const builder = structure.subsetBuilder(true);
 
         let progress = 0;
@@ -120,7 +120,7 @@ function atomGroupsSegmented({ entityTest, chainTest, residueTest, atomTest }: A
 function atomGroupsGrouped({ entityTest, chainTest, residueTest, atomTest, groupBy }: AtomGroupsQueryParams): Query.Provider {
     return async (structure, ctx) => {
         const { units } = structure;
-        const l = Element.Location();
+        const l = StructureElement.create();
         const builder = new LinearGroupingBuilder(structure);
 
         let progress = 0;

+ 9 - 9
src/mol-model/structure/query/predicates.ts

@@ -4,19 +4,19 @@
  * @author David Sehnal <david.sehnal@gmail.com>
  */
 
-import { Element, StructureProperties as P } from '../structure'
+import { StructureElement, StructureProperties as P } from '../structure'
 
 namespace Predicates {
     export interface SetLike<A> { has(v: A): boolean }
     function isSetLike<A>(x: any): x is SetLike<A> { return !!x && !!x.has }
 
-    export function eq<A>(p: Element.Property<A>, value: A): Element.Predicate { return l => p(l) === value; }
-    export function lt<A>(p: Element.Property<A>, value: A): Element.Predicate { return l => p(l) < value; }
-    export function lte<A>(p: Element.Property<A>, value: A): Element.Predicate { return l => p(l) <= value; }
-    export function gt<A>(p: Element.Property<A>, value: A): Element.Predicate { return l => p(l) > value; }
-    export function gte<A>(p: Element.Property<A>, value: A): Element.Predicate { return l => p(l) >= value; }
+    export function eq<A>(p: StructureElement.Property<A>, value: A): StructureElement.Predicate { return l => p(l) === value; }
+    export function lt<A>(p: StructureElement.Property<A>, value: A): StructureElement.Predicate { return l => p(l) < value; }
+    export function lte<A>(p: StructureElement.Property<A>, value: A): StructureElement.Predicate { return l => p(l) <= value; }
+    export function gt<A>(p: StructureElement.Property<A>, value: A): StructureElement.Predicate { return l => p(l) > value; }
+    export function gte<A>(p: StructureElement.Property<A>, value: A): StructureElement.Predicate { return l => p(l) >= value; }
 
-    export function inSet<A>(p: Element.Property<A>, values: SetLike<A> | ArrayLike<A>): Element.Predicate {
+    export function inSet<A>(p: StructureElement.Property<A>, values: SetLike<A> | ArrayLike<A>): StructureElement.Predicate {
         if (isSetLike(values)) {
             return l => values.has(p(l));
         } else {
@@ -27,7 +27,7 @@ namespace Predicates {
         }
     }
 
-    export function and(...ps: Element.Predicate[]): Element.Predicate {
+    export function and(...ps: StructureElement.Predicate[]): StructureElement.Predicate {
         switch (ps.length) {
             case 0: return P.constant.true;
             case 1: return ps[0];
@@ -61,7 +61,7 @@ namespace Predicates {
         }
     }
 
-    export function or(...ps: Element.Predicate[]): Element.Predicate {
+    export function or(...ps: StructureElement.Predicate[]): StructureElement.Predicate {
         switch (ps.length) {
             case 0: return P.constant.false;
             case 1: return ps[0];

+ 5 - 5
src/mol-model/structure/query/selection.ts

@@ -5,7 +5,7 @@
  */
 
 import { HashSet } from 'mol-data/generic'
-import { Structure, Element, Unit } from '../structure'
+import { Structure, StructureElement, Unit } from '../structure'
 import { structureUnion } from './utils/structure';
 import { OrderedSet, SortedArray } from 'mol-data/int';
 
@@ -35,13 +35,13 @@ namespace Selection {
         return structureUnion(sel.source, sel.structures);
     }
 
-    export function toLoci(sel: Selection): Element.Loci {
-        const loci: { unit: Unit, indices: OrderedSet<Element.Index> }[] = [];
+    export function toLoci(sel: Selection): StructureElement.Loci {
+        const loci: { unit: Unit, indices: OrderedSet<StructureElement.Index> }[] = [];
         const { unitMap } = sel.source;
 
         for (const unit of unionStructure(sel).units) {
             if (unit === unitMap.get(unit.id)) {
-                loci[loci.length] = { unit, indices: OrderedSet.ofBounds(0 as Element.Index, unit.elements.length as Element.Index) };
+                loci[loci.length] = { unit, indices: OrderedSet.ofBounds(0 as StructureElement.Index, unit.elements.length as StructureElement.Index) };
             } else {
                 loci[loci.length] = {
                     unit,
@@ -50,7 +50,7 @@ namespace Selection {
             }
         }
 
-        return Element.Loci(loci);
+        return StructureElement.Loci(loci);
     }
 
     export interface Builder {

+ 2 - 2
src/mol-model/structure/query/utils/builders.ts

@@ -4,7 +4,7 @@
  * @author David Sehnal <david.sehnal@gmail.com>
  */
 
-import { Element, Structure } from '../../structure';
+import { StructureElement, Structure } from '../../structure';
 import Selection from '../selection';
 import { HashSet } from 'mol-data/generic';
 import { structureUnion } from './structure';
@@ -56,7 +56,7 @@ export class LinearGroupingBuilder {
 
     private singletonSelection(): Selection {
         const builder = this.source.subsetBuilder(true);
-        const loc = Element.Location();
+        const loc = StructureElement.create();
         for (let i = 0, _i = this.builders.length; i < _i; i++) {
             this.builders[i].setSingletonLocation(loc);
             builder.addToUnit(loc.unit.id, loc.element);

+ 3 - 3
src/mol-model/structure/query/utils/structure.ts

@@ -4,7 +4,7 @@
  * @author David Sehnal <david.sehnal@gmail.com>
  */
 
-import { Structure, Unit, Element } from '../../structure'
+import { Structure, Unit, StructureElement } from '../../structure'
 import { SortedArray } from 'mol-data/int';
 import { StructureSubsetBuilder } from '../../structure/util/subset-builder';
 
@@ -12,7 +12,7 @@ export function structureUnion(source: Structure, structures: Structure[]) {
     if (structures.length === 0) return Structure.Empty;
     if (structures.length === 1) return structures[0];
 
-    const unitMap = new Map<number, Element.Set>();
+    const unitMap = new Map<number, StructureElement.Set>();
     const fullUnits = new Set<number>();
 
     for (const { units } of structures) {
@@ -36,7 +36,7 @@ export function structureUnion(source: Structure, structures: Structure[]) {
     return builder.getStructure();
 }
 
-function buildUnion(this: StructureSubsetBuilder, elements: Element.Set, id: number) {
+function buildUnion(this: StructureSubsetBuilder, elements: StructureElement.Set, id: number) {
     this.setUnit(id, elements);
 }
 

+ 2 - 2
src/mol-model/structure/structure.ts

@@ -4,11 +4,11 @@
  * @author David Sehnal <david.sehnal@gmail.com>
  */
 
-import Element from './structure/element'
+import StructureElement from './structure/element'
 import Structure from './structure/structure'
 import Unit from './structure/unit'
 import StructureSymmetry from './structure/symmetry'
 import { Link } from './structure/unit/links'
 import StructureProperties from './structure/properties'
 
-export { Element, Link, Structure, Unit, StructureSymmetry, StructureProperties }
+export { StructureElement, Link, Structure, Unit, StructureSymmetry, StructureProperties }

+ 14 - 16
src/mol-model/structure/structure/element.ts

@@ -8,34 +8,32 @@ import { OrderedSet, SortedArray } from 'mol-data/int'
 import Unit from './unit'
 import { ElementIndex } from '../model';
 
-/** Element index in Model */
-// type Element = { readonly '@type': 'element' } & number
+interface StructureElement<U = Unit> {
+    unit: U,
+    /** Index into element (atomic/coarse) properties of unit.model */
+    element: ElementIndex
+}
+
+namespace StructureElement {
+    export function create(unit?: Unit, element?: ElementIndex): StructureElement { return { unit: unit as any, element: element || (0 as ElementIndex) }; }
 
-namespace Element {
     export type Set = SortedArray<ElementIndex>
 
     /** Index into Unit.elements */
     export type Index = { readonly '@type': 'element-index' } & number
 
-    /** All the information required to access element properties */
-    export interface Location<U = Unit> {
-        unit: U,
-        /** Index into element (atomic/coarse) properties of unit.model */
-        element: ElementIndex
-    }
-    export function Location(unit?: Unit, element?: ElementIndex): Location { return { unit: unit as any, element: element || (0 as ElementIndex) }; }
-    export interface Property<T> { (location: Location): T }
+    export interface Property<T> { (location: StructureElement): T }
     export interface Predicate extends Property<boolean> { }
 
     export function property<T>(p: Property<T>) { return p; }
 
     function _wrongUnitKind(kind: string) { throw new Error(`Property only available for ${kind} models.`); }
-    export function atomicProperty<T>(p: (location: Location<Unit.Atomic>) => T) {
-        return property(l => Unit.isAtomic(l.unit) ? p(l as Location<Unit.Atomic>) : _wrongUnitKind('atomic') );
+    export function atomicProperty<T>(p: (location: StructureElement<Unit.Atomic>) => T) {
+        return property(l => Unit.isAtomic(l.unit) ? p(l as StructureElement<Unit.Atomic>) : _wrongUnitKind('atomic') );
     }
 
-    export function coarseProperty<T>(p: (location: Location<Unit.Spheres | Unit.Gaussians>) => T) {
-        return property(l => Unit.isCoarse(l.unit) ? p(l as Location<Unit.Spheres | Unit.Gaussians>) : _wrongUnitKind('coarse') );
+    export function coarseProperty<T>(p: (location: StructureElement<Unit.Spheres | Unit.Gaussians>) => T) {
+        return property(l => Unit.isCoarse(l.unit) ? p(l as StructureElement<Unit.Spheres | Unit.Gaussians>) : _wrongUnitKind('coarse') );
     }
 
     /** Represents multiple element index locations */
@@ -61,4 +59,4 @@ namespace Element {
     }
 }
 
-export default Element
+export default StructureElement

+ 51 - 51
src/mol-model/structure/structure/properties.ts

@@ -4,14 +4,14 @@
  * @author David Sehnal <david.sehnal@gmail.com>
  */
 
-import Element from './element'
+import StructureElement from './element'
 import Unit from './unit'
 import { VdwRadius } from '../model/properties/atomic';
 
 const constant = {
-    true: Element.property(l => true),
-    false: Element.property(l => false),
-    zero: Element.property(l => 0)
+    true: StructureElement.property(l => true),
+    false: StructureElement.property(l => false),
+    zero: StructureElement.property(l => 0)
 }
 
 function notAtomic(): never {
@@ -26,70 +26,70 @@ function notCoarse(kind?: string): never {
 // TODO: remove the type checks?
 
 const atom = {
-    key: Element.property(l => l.element),
+    key: StructureElement.property(l => l.element),
 
     // Conformation
-    x: Element.property(l => l.unit.conformation.x(l.element)),
-    y: Element.property(l => l.unit.conformation.y(l.element)),
-    z: Element.property(l => l.unit.conformation.z(l.element)),
-    id: Element.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicConformation.atomId.value(l.element)),
-    occupancy: Element.property(l => !Unit.isAtomic(l.unit) ?  notAtomic() : l.unit.model.atomicConformation.occupancy.value(l.element)),
-    B_iso_or_equiv: Element.property(l => !Unit.isAtomic(l.unit) ?  notAtomic() : l.unit.model.atomicConformation.B_iso_or_equiv.value(l.element)),
+    x: StructureElement.property(l => l.unit.conformation.x(l.element)),
+    y: StructureElement.property(l => l.unit.conformation.y(l.element)),
+    z: StructureElement.property(l => l.unit.conformation.z(l.element)),
+    id: StructureElement.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicConformation.atomId.value(l.element)),
+    occupancy: StructureElement.property(l => !Unit.isAtomic(l.unit) ?  notAtomic() : l.unit.model.atomicConformation.occupancy.value(l.element)),
+    B_iso_or_equiv: StructureElement.property(l => !Unit.isAtomic(l.unit) ?  notAtomic() : l.unit.model.atomicConformation.B_iso_or_equiv.value(l.element)),
 
     // Hierarchy
-    type_symbol: Element.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.atoms.type_symbol.value(l.element)),
-    label_atom_id: Element.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.atoms.label_atom_id.value(l.element)),
-    auth_atom_id: Element.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.atoms.auth_atom_id.value(l.element)),
-    label_alt_id: Element.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.atoms.label_alt_id.value(l.element)),
-    pdbx_formal_charge: Element.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.atoms.pdbx_formal_charge.value(l.element)),
+    type_symbol: StructureElement.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.atoms.type_symbol.value(l.element)),
+    label_atom_id: StructureElement.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.atoms.label_atom_id.value(l.element)),
+    auth_atom_id: StructureElement.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.atoms.auth_atom_id.value(l.element)),
+    label_alt_id: StructureElement.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.atoms.label_alt_id.value(l.element)),
+    pdbx_formal_charge: StructureElement.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.atoms.pdbx_formal_charge.value(l.element)),
 
     // Derived
-    vdw_radius: Element.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : VdwRadius(l.unit.model.atomicHierarchy.atoms.type_symbol.value(l.element))),
+    vdw_radius: StructureElement.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : VdwRadius(l.unit.model.atomicHierarchy.atoms.type_symbol.value(l.element))),
 }
 
 const residue = {
-    key: Element.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.residueIndex[l.element]),
+    key: StructureElement.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.residueIndex[l.element]),
 
-    group_PDB: Element.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.residues.group_PDB.value(l.unit.residueIndex[l.element])),
-    label_comp_id: Element.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.residues.label_comp_id.value(l.unit.residueIndex[l.element])),
-    auth_comp_id: Element.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.residues.auth_comp_id.value(l.unit.residueIndex[l.element])),
-    label_seq_id: Element.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.residues.label_seq_id.value(l.unit.residueIndex[l.element])),
-    auth_seq_id: Element.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.residues.auth_seq_id.value(l.unit.residueIndex[l.element])),
-    pdbx_PDB_ins_code: Element.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(l.unit.residueIndex[l.element])),
+    group_PDB: StructureElement.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.residues.group_PDB.value(l.unit.residueIndex[l.element])),
+    label_comp_id: StructureElement.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.residues.label_comp_id.value(l.unit.residueIndex[l.element])),
+    auth_comp_id: StructureElement.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.residues.auth_comp_id.value(l.unit.residueIndex[l.element])),
+    label_seq_id: StructureElement.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.residues.label_seq_id.value(l.unit.residueIndex[l.element])),
+    auth_seq_id: StructureElement.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.residues.auth_seq_id.value(l.unit.residueIndex[l.element])),
+    pdbx_PDB_ins_code: StructureElement.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(l.unit.residueIndex[l.element])),
 
     // Properties
-    secondary_structure_type: Element.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.properties.secondaryStructure.type[l.unit.residueIndex[l.element]]),
-    secondary_structure_key: Element.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.properties.secondaryStructure.key[l.unit.residueIndex[l.element]]),
+    secondary_structure_type: StructureElement.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.properties.secondaryStructure.type[l.unit.residueIndex[l.element]]),
+    secondary_structure_key: StructureElement.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.properties.secondaryStructure.key[l.unit.residueIndex[l.element]]),
 }
 
 const chain = {
-    key: Element.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.chainIndex[l.element]),
+    key: StructureElement.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.chainIndex[l.element]),
 
-    label_asym_id: Element.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.chains.label_asym_id.value(l.unit.chainIndex[l.element])),
-    auth_asym_id: Element.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.chains.auth_asym_id.value(l.unit.chainIndex[l.element])),
-    label_entity_id: Element.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.chains.label_entity_id.value(l.unit.chainIndex[l.element]))
+    label_asym_id: StructureElement.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.chains.label_asym_id.value(l.unit.chainIndex[l.element])),
+    auth_asym_id: StructureElement.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.chains.auth_asym_id.value(l.unit.chainIndex[l.element])),
+    label_entity_id: StructureElement.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.chains.label_entity_id.value(l.unit.chainIndex[l.element]))
 }
 
 const coarse = {
     key: atom.key,
-    entityKey: Element.property(l => !Unit.isCoarse(l.unit) ? notCoarse() : l.unit.coarseElements.entityKey[l.element]),
+    entityKey: StructureElement.property(l => !Unit.isCoarse(l.unit) ? notCoarse() : l.unit.coarseElements.entityKey[l.element]),
 
     x: atom.x,
     y: atom.y,
     z: atom.z,
 
-    asym_id: Element.property(l => !Unit.isCoarse(l.unit) ? notCoarse() : l.unit.coarseElements.asym_id.value(l.element)),
-    seq_id_begin: Element.property(l => !Unit.isCoarse(l.unit) ? notCoarse() : l.unit.coarseElements.seq_id_begin.value(l.element)),
-    seq_id_end: Element.property(l => !Unit.isCoarse(l.unit) ? notCoarse() : l.unit.coarseElements.seq_id_end.value(l.element)),
+    asym_id: StructureElement.property(l => !Unit.isCoarse(l.unit) ? notCoarse() : l.unit.coarseElements.asym_id.value(l.element)),
+    seq_id_begin: StructureElement.property(l => !Unit.isCoarse(l.unit) ? notCoarse() : l.unit.coarseElements.seq_id_begin.value(l.element)),
+    seq_id_end: StructureElement.property(l => !Unit.isCoarse(l.unit) ? notCoarse() : l.unit.coarseElements.seq_id_end.value(l.element)),
 
-    sphere_radius: Element.property(l => !Unit.isSpheres(l.unit) ? notCoarse('spheres') : l.unit.coarseConformation.radius[l.element]),
-    sphere_rmsf: Element.property(l => !Unit.isSpheres(l.unit) ? notCoarse('spheres') : l.unit.coarseConformation.rmsf[l.element]),
+    sphere_radius: StructureElement.property(l => !Unit.isSpheres(l.unit) ? notCoarse('spheres') : l.unit.coarseConformation.radius[l.element]),
+    sphere_rmsf: StructureElement.property(l => !Unit.isSpheres(l.unit) ? notCoarse('spheres') : l.unit.coarseConformation.rmsf[l.element]),
 
-    gaussian_weight: Element.property(l => !Unit.isGaussians(l.unit) ? notCoarse('gaussians') : l.unit.coarseConformation.weight[l.element]),
-    gaussian_covariance_matrix: Element.property(l => !Unit.isGaussians(l.unit) ? notCoarse('gaussians') : l.unit.coarseConformation.covariance_matrix[l.element])
+    gaussian_weight: StructureElement.property(l => !Unit.isGaussians(l.unit) ? notCoarse('gaussians') : l.unit.coarseConformation.weight[l.element]),
+    gaussian_covariance_matrix: StructureElement.property(l => !Unit.isGaussians(l.unit) ? notCoarse('gaussians') : l.unit.coarseConformation.covariance_matrix[l.element])
 }
 
-function eK(l: Element.Location) {
+function eK(l: StructureElement) {
     switch (l.unit.kind) {
         case Unit.Kind.Atomic:
             return l.unit.model.atomicHierarchy.getEntityKey(l.unit.chainIndex[l.element])
@@ -103,21 +103,21 @@ function eK(l: Element.Location) {
 const entity = {
     key: eK,
 
-    id: Element.property(l => l.unit.model.entities.data.id.value(eK(l))),
-    type: Element.property(l => l.unit.model.entities.data.type.value(eK(l))),
-    src_method: Element.property(l => l.unit.model.entities.data.src_method.value(eK(l))),
-    pdbx_description: Element.property(l => l.unit.model.entities.data.pdbx_description.value(eK(l))),
-    formula_weight: Element.property(l => l.unit.model.entities.data.formula_weight.value(eK(l))),
-    pdbx_number_of_molecules: Element.property(l => l.unit.model.entities.data.pdbx_number_of_molecules.value(eK(l))),
-    details: Element.property(l => l.unit.model.entities.data.details.value(eK(l))),
-    pdbx_mutation: Element.property(l => l.unit.model.entities.data.pdbx_mutation.value(eK(l))),
-    pdbx_fragment: Element.property(l => l.unit.model.entities.data.pdbx_fragment.value(eK(l))),
-    pdbx_ec: Element.property(l => l.unit.model.entities.data.pdbx_ec.value(eK(l)))
+    id: StructureElement.property(l => l.unit.model.entities.data.id.value(eK(l))),
+    type: StructureElement.property(l => l.unit.model.entities.data.type.value(eK(l))),
+    src_method: StructureElement.property(l => l.unit.model.entities.data.src_method.value(eK(l))),
+    pdbx_description: StructureElement.property(l => l.unit.model.entities.data.pdbx_description.value(eK(l))),
+    formula_weight: StructureElement.property(l => l.unit.model.entities.data.formula_weight.value(eK(l))),
+    pdbx_number_of_molecules: StructureElement.property(l => l.unit.model.entities.data.pdbx_number_of_molecules.value(eK(l))),
+    details: StructureElement.property(l => l.unit.model.entities.data.details.value(eK(l))),
+    pdbx_mutation: StructureElement.property(l => l.unit.model.entities.data.pdbx_mutation.value(eK(l))),
+    pdbx_fragment: StructureElement.property(l => l.unit.model.entities.data.pdbx_fragment.value(eK(l))),
+    pdbx_ec: StructureElement.property(l => l.unit.model.entities.data.pdbx_ec.value(eK(l)))
 }
 
 const unit = {
-    operator_name: Element.property(l => l.unit.conformation.operator.name),
-    model_num: Element.property(l => l.unit.model.modelNum)
+    operator_name: StructureElement.property(l => l.unit.conformation.operator.name),
+    model_num: StructureElement.property(l => l.unit.model.modelNum)
 }
 
 const StructureProperties = {

+ 8 - 8
src/mol-model/structure/structure/structure.ts

@@ -9,7 +9,7 @@ import { UniqueArray } from 'mol-data/generic'
 import { SymmetryOperator } from 'mol-math/geometry/symmetry-operator'
 import { Model, ElementIndex } from '../model'
 import { sort, arraySwap, hash1, sortArray } from 'mol-data/util';
-import Element from './element'
+import StructureElement from './element'
 import Unit from './unit'
 import { StructureLookup3D } from './util/lookup3d';
 import { CoarseElements } from '../model/properties/coarse';
@@ -49,7 +49,7 @@ class Structure {
         return hash;
     }
 
-    elementLocations(): Iterator<Element.Location> {
+    elementLocations(): Iterator<StructureElement> {
         return new Structure.ElementLocationIterator(this);
     }
 
@@ -159,7 +159,7 @@ namespace Structure {
     export class StructureBuilder {
         private units: Unit[] = [];
 
-        addUnit(kind: Unit.Kind, model: Model, operator: SymmetryOperator, elements: Element.Set): Unit {
+        addUnit(kind: Unit.Kind, model: Model, operator: SymmetryOperator, elements: StructureElement.Set): Unit {
             const unit = Unit.create(this.units.length, kind, model, operator, elements);
             this.units.push(unit);
             return unit;
@@ -211,15 +211,15 @@ namespace Structure {
         return true;
     }
 
-    export class ElementLocationIterator implements Iterator<Element.Location> {
-        private current = Element.Location();
+    export class ElementLocationIterator implements Iterator<StructureElement> {
+        private current = StructureElement.create();
         private unitIndex = 0;
-        private elements: Element.Set;
+        private elements: StructureElement.Set;
         private maxIdx = 0;
         private idx = -1;
 
         hasNext: boolean;
-        move(): Element.Location {
+        move(): StructureElement {
             this.advance();
             this.current.element = this.elements[this.idx];
             return this.current;
@@ -257,7 +257,7 @@ namespace Structure {
 
     export function getEntityKeys(structure: Structure) {
         const { units } = structure;
-        const l = Element.Location();
+        const l = StructureElement.create();
         const keys = UniqueArray.create<number, number>();
 
         for (const unit of units) {

+ 12 - 12
src/mol-model/structure/structure/unit.ts

@@ -12,7 +12,7 @@ import { IntraUnitLinks, computeIntraUnitBonds } from './unit/links'
 import { CoarseElements, CoarseSphereConformation, CoarseGaussianConformation } from '../model/properties/coarse';
 import { ValueRef } from 'mol-util';
 import { UnitRings } from './unit/rings';
-import Element from './element'
+import StructureElement from './element'
 import { ChainIndex, ResidueIndex } from '../model/indexing';
 
 // A building block of a structure that corresponds to an atomic or a coarse grained representation
@@ -27,7 +27,7 @@ namespace Unit {
     export function isSpheres(u: Unit): u is Spheres { return u.kind === Kind.Spheres; }
     export function isGaussians(u: Unit): u is Gaussians { return u.kind === Kind.Gaussians; }
 
-    export function create(id: number, kind: Kind, model: Model, operator: SymmetryOperator, elements: Element.Set): Unit {
+    export function create(id: number, kind: Kind, model: Model, operator: SymmetryOperator, elements: StructureElement.Set): Unit {
         switch (kind) {
             case Kind.Atomic: return new Atomic(id, unitIdFactory(), model, elements, SymmetryOperator.createMapping(operator, model.atomicConformation), AtomicProperties());
             case Kind.Spheres: return createCoarse(id, unitIdFactory(), model, Kind.Spheres, elements, SymmetryOperator.createMapping(operator, model.coarseConformation.spheres));
@@ -37,7 +37,7 @@ namespace Unit {
 
     /** A group of units that differ only by symmetry operators. */
     export type SymmetryGroup = {
-        readonly elements: Element.Set,
+        readonly elements: StructureElement.Set,
         readonly units: ReadonlyArray<Unit>
         readonly hashCode: number
     }
@@ -54,11 +54,11 @@ namespace Unit {
         readonly id: number,
         // invariant ID stays the same even if the Operator/conformation changes.
         readonly invariantId: number,
-        readonly elements: Element.Set,
+        readonly elements: StructureElement.Set,
         readonly model: Model,
         readonly conformation: SymmetryOperator.ArrayMapping,
 
-        getChild(elements: Element.Set): Unit,
+        getChild(elements: StructureElement.Set): Unit,
         applyOperator(id: number, operator: SymmetryOperator, dontCompose?: boolean /* = false */): Unit,
 
         readonly lookup3d: Lookup3D
@@ -78,7 +78,7 @@ namespace Unit {
 
         readonly id: number;
         readonly invariantId: number;
-        readonly elements: Element.Set;
+        readonly elements: StructureElement.Set;
         readonly model: Model;
         readonly conformation: SymmetryOperator.ArrayMapping;
 
@@ -88,7 +88,7 @@ namespace Unit {
 
         private props: AtomicProperties;
 
-        getChild(elements: Element.Set): Unit {
+        getChild(elements: StructureElement.Set): Unit {
             if (elements.length === this.elements.length) return this;
             return new Atomic(this.id, this.invariantId, this.model, elements, this.conformation, AtomicProperties());
         }
@@ -117,7 +117,7 @@ namespace Unit {
             return this.props.rings.ref;
         }
 
-        constructor(id: number, invariantId: number, model: Model, elements: Element.Set, conformation: SymmetryOperator.ArrayMapping, props: AtomicProperties) {
+        constructor(id: number, invariantId: number, model: Model, elements: StructureElement.Set, conformation: SymmetryOperator.ArrayMapping, props: AtomicProperties) {
             this.id = id;
             this.invariantId = invariantId;
             this.model = model;
@@ -145,14 +145,14 @@ namespace Unit {
 
         readonly id: number;
         readonly invariantId: number;
-        readonly elements: Element.Set;
+        readonly elements: StructureElement.Set;
         readonly model: Model;
         readonly conformation: SymmetryOperator.ArrayMapping;
 
         readonly coarseElements: CoarseElements;
         readonly coarseConformation: C;
 
-        getChild(elements: Element.Set): Unit {
+        getChild(elements: StructureElement.Set): Unit {
             if (elements.length === this.elements.length) return this as any as Unit /** lets call this an ugly temporary hack */;
             return createCoarse(this.id, this.invariantId, this.model, this.kind, elements, this.conformation);
         }
@@ -177,7 +177,7 @@ namespace Unit {
             return this.kind === Kind.Spheres ? this.model.coarseConformation.spheres : this.model.coarseConformation.gaussians;
         }
 
-        constructor(id: number, invariantId: number, model: Model, kind: K, elements: Element.Set, conformation: SymmetryOperator.ArrayMapping) {
+        constructor(id: number, invariantId: number, model: Model, kind: K, elements: StructureElement.Set, conformation: SymmetryOperator.ArrayMapping) {
             this.kind = kind;
             this.id = id;
             this.invariantId = invariantId;
@@ -189,7 +189,7 @@ namespace Unit {
         }
     }
 
-    function createCoarse<K extends Kind.Gaussians | Kind.Spheres>(id: number, invariantId: number, model: Model, kind: K, elements: Element.Set, conformation: SymmetryOperator.ArrayMapping): Unit {
+    function createCoarse<K extends Kind.Gaussians | Kind.Spheres>(id: number, invariantId: number, model: Model, kind: K, elements: StructureElement.Set, conformation: SymmetryOperator.ArrayMapping): Unit {
         return new Coarse(id, invariantId, model, kind, elements, conformation) as any as Unit /** lets call this an ugly temporary hack */;
     }
 

+ 2 - 2
src/mol-model/structure/structure/util/subset-builder.ts

@@ -6,7 +6,7 @@
 
 import { IntMap, SortedArray } from 'mol-data/int';
 import { sortArray } from 'mol-data/util';
-import Element from '../element';
+import StructureElement from '../element';
 import StructureSymmetry from '../symmetry';
 import Unit from '../unit';
 import Structure from '../structure';
@@ -101,7 +101,7 @@ export class StructureSubsetBuilder {
         return this._getStructure(true);
     }
 
-    setSingletonLocation(location: Element.Location) {
+    setSingletonLocation(location: StructureElement) {
         const id = this.ids[0];
         location.unit = this.parent.unitMap.get(id);
         location.element = this.unitMap.get(id)[0];

+ 6 - 6
src/mol-view/label.ts

@@ -5,14 +5,14 @@
  * @author David Sehnal <david.sehnal@gmail.com>
  */
 
-import { Unit, Element, StructureProperties as Props } from 'mol-model/structure';
+import { Unit, StructureElement, StructureProperties as Props } from 'mol-model/structure';
 import { Loci } from 'mol-model/loci';
 import { OrderedSet } from 'mol-data/int';
 
-const elementLocA = Element.Location()
-const elementLocB = Element.Location()
+const elementLocA = StructureElement.create()
+const elementLocB = StructureElement.create()
 
-function setElementLocation(loc: Element.Location, unit: Unit, index: number) {
+function setElementLocation(loc: StructureElement, unit: Unit, index: number) {
     loc.unit = unit
     loc.element = unit.elements[index]
 }
@@ -23,7 +23,7 @@ export function labelFirst(loci: Loci): string {
             const e = loci.elements[0]
             if (e) {
                 const el = e.unit.elements[OrderedSet.getAt(e.indices, 0)];
-                return elementLabel(Element.Location(e.unit, el))
+                return elementLabel(StructureElement.create(e.unit, el))
             } else {
                 return 'Unknown'
             }
@@ -43,7 +43,7 @@ export function labelFirst(loci: Loci): string {
     }
 }
 
-export function elementLabel(loc: Element.Location) {
+export function elementLabel(loc: StructureElement) {
     const model = loc.unit.model.label
     const instance = loc.unit.conformation.operator.name
     let element = ''

+ 3 - 3
src/perf-tests/structure.ts

@@ -11,7 +11,7 @@ import * as fs from 'fs'
 import fetch from 'node-fetch'
 import CIF from 'mol-io/reader/cif'
 
-import { Structure, Model, Queries as Q, Element, Selection, StructureSymmetry, Query, Format, StructureProperties as SP } from 'mol-model/structure'
+import { Structure, Model, Queries as Q, StructureElement, Selection, StructureSymmetry, Query, Format, StructureProperties as SP } from 'mol-model/structure'
 //import { Segmentation, OrderedSet } from 'mol-data/int'
 
 import to_mmCIF from 'mol-model/structure/export/mmcif'
@@ -119,8 +119,8 @@ export namespace PropertyAccess {
         return s;
     }
 
-    function sumProperty(structure: Structure, p: Element.Property<number>) {
-        const l = Element.Location();
+    function sumProperty(structure: Structure, p: StructureElement.Property<number>) {
+        const l = StructureElement.create();
         let s = 0;
 
         for (const unit of structure.units) {

+ 13 - 13
src/servers/model/server/api.ts

@@ -4,7 +4,7 @@
  * @author David Sehnal <david.sehnal@gmail.com>
  */
 
-import { Query, Queries, Structure, Element, StructureSymmetry, StructureProperties as Props } from 'mol-model/structure';
+import { Query, Queries, Structure, StructureElement, StructureSymmetry, StructureProperties as Props } from 'mol-model/structure';
 
 export enum QueryParamType {
     String,
@@ -51,26 +51,26 @@ const AtomSiteParameters = {
 //     return Element.property(l => p(l) === id);
 // }
 
-function entityTest1_555(params: any): Element.Predicate | undefined {
-    if (typeof params.entity_id === 'undefined') return Element.property(l => l.unit.conformation.operator.isIdentity);
+function entityTest1_555(params: any): StructureElement.Predicate | undefined {
+    if (typeof params.entity_id === 'undefined') return StructureElement.property(l => l.unit.conformation.operator.isIdentity);
     const p = Props.entity.id, id = '' + params.entityId;
-    return Element.property(l => l.unit.conformation.operator.isIdentity && p(l) === id);
+    return StructureElement.property(l => l.unit.conformation.operator.isIdentity && p(l) === id);
 }
 
-function chainTest(params: any): Element.Predicate | undefined {
+function chainTest(params: any): StructureElement.Predicate | undefined {
     if (typeof params.label_asym_id !== 'undefined') {
         const p = Props.chain.label_asym_id, id = '' + params.label_asym_id;
-        return Element.property(l => p(l) === id);
+        return StructureElement.property(l => p(l) === id);
     }
     if (typeof params.auth_asym_id !== 'undefined') {
         const p = Props.chain.auth_asym_id, id = '' + params.auth_asym_id;
-        return Element.property(l => p(l) === id);
+        return StructureElement.property(l => p(l) === id);
     }
     return void 0;
 }
 
-function residueTest(params: any): Element.Predicate | undefined {
-    const props: Element.Property<any>[] = [], values: any[] = [];
+function residueTest(params: any): StructureElement.Predicate | undefined {
+    const props: StructureElement.Property<any>[] = [], values: any[] = [];
 
     if (typeof params.label_seq_id !== 'undefined') {
         props.push(Props.residue.label_seq_id);
@@ -99,12 +99,12 @@ function residueTest(params: any): Element.Predicate | undefined {
 
     switch (props.length) {
         case 0: return void 0;
-        case 1: return Element.property(l => props[0](l) === values[0]);
-        case 2: return Element.property(l => props[0](l) === values[0] && props[1](l) === values[1]);
-        case 3: return Element.property(l => props[0](l) === values[0] && props[1](l) === values[1] && props[2](l) === values[2]);
+        case 1: return StructureElement.property(l => props[0](l) === values[0]);
+        case 2: return StructureElement.property(l => props[0](l) === values[0] && props[1](l) === values[1]);
+        case 3: return StructureElement.property(l => props[0](l) === values[0] && props[1](l) === values[1] && props[2](l) === values[2]);
         default: {
             const len = props.length;
-            return Element.property(l => {
+            return StructureElement.property(l => {
                 for (let i = 0; i < len; i++) if (!props[i](l) !== values[i]) return false;
                 return true;
             });