diff --git a/src/mol-model/structure/structure/element/query.ts b/src/mol-model/structure/structure/element/bundle.ts similarity index 88% rename from src/mol-model/structure/structure/element/query.ts rename to src/mol-model/structure/structure/element/bundle.ts index 7093ff9f0d1e8c51d4b693d50a7e08ef75d27f82..81d42342a14bf1d23a48c8ec20b280db1438c729 100644 --- a/src/mol-model/structure/structure/element/query.ts +++ b/src/mol-model/structure/structure/element/bundle.ts @@ -13,7 +13,7 @@ import SortedRanges from '../../../../mol-data/int/sorted-ranges'; import { UnitIndex } from './element'; import { Loci } from './loci'; -interface QueryElement { +interface BundleElement { /** * Array (sorted by first element in sub-array) of * arrays of `Unit.id`s that share the same `Unit.invariantId` @@ -23,17 +23,17 @@ interface QueryElement { ranges: SortedRanges<UnitIndex> } -export interface Query { - /** Hash of the structure to which the query can be applied */ +export interface Bundle { + /** Hash of the structure with which the bundle is compatible */ readonly hash: number - /** Query elements */ - readonly elements: ReadonlyArray<Readonly<QueryElement>> + /** Bundle elements */ + readonly elements: ReadonlyArray<Readonly<BundleElement>> } -export namespace Query { - export const Empty: Query = { hash: -1, elements: [] } +export namespace Bundle { + export const Empty: Bundle = { hash: -1, elements: [] } - export function fromLoci(loci: Loci): Query { + export function fromLoci(loci: Loci): Bundle { const _elements: { unit: Unit set: SortedArray<UnitIndex> @@ -98,7 +98,7 @@ export namespace Query { } } - const elements: QueryElement[] = [] + const elements: BundleElement[] = [] elementGroups.forEach(e => { const groupedUnits: SortedArray<number>[] = [] e.groupedUnits.forEach(g => groupedUnits.push(SortedArray.ofUnsortedArray(g))) @@ -118,12 +118,12 @@ export namespace Query { return units } - export function toLoci(query: Query, parent: Structure): Loci { - if (query.hash !== -1 && query.hash !== parent.root.hashCode) { - new Error('Query not compatible with given structure') + export function toLoci(bundle: Bundle, parent: Structure): Loci { + if (bundle.hash !== -1 && bundle.hash !== parent.root.hashCode) { + new Error('Bundle not compatible with given structure') } const elements: Loci['elements'][0][] = [] - for (const e of query.elements) { + for (const e of bundle.elements) { for (const g of e.groupedUnits) { const units = getUnitsFromIds(g, parent) if (units.length === 0) continue @@ -155,12 +155,12 @@ export namespace Query { return Loci(parent, elements) } - export function toStructure(query: Query, parent: Structure): Structure { - if (query.hash !== -1 && query.hash !== parent.root.hashCode) { - new Error('Query not compatible with given structure') + export function toStructure(bundle: Bundle, parent: Structure): Structure { + if (bundle.hash !== -1 && bundle.hash !== parent.root.hashCode) { + new Error('Bundle not compatible with given structure') } const units: Unit[] = [] - for (const e of query.elements) { + for (const e of bundle.elements) { for (const g of e.groupedUnits) { const _units = getUnitsFromIds(g, parent) if (_units.length === 0) continue @@ -192,7 +192,7 @@ export namespace Query { return Structure.create(units, { parent }) } - export function areEqual(a: Query, b: Query) { + export function areEqual(a: Bundle, b: Bundle) { if (a.elements.length !== b.elements.length) return false for (let i = 0, il = a.elements.length; i < il; ++i) { const elementA = a.elements[i], elementB = b.elements[i] diff --git a/src/mol-model/structure/structure/element/index.ts b/src/mol-model/structure/structure/element/index.ts index d59dfce564dff194e4843e7b1c24c44d8d3188f0..722e195332a2a8d105a1ac57fca5ffb887d5c75e 100644 --- a/src/mol-model/structure/structure/element/index.ts +++ b/src/mol-model/structure/structure/element/index.ts @@ -7,6 +7,6 @@ export * from './location' export * from './loci' -export * from './query' +export * from './bundle' export * from './stats' export * from './element' \ No newline at end of file diff --git a/src/mol-plugin/state/transforms/model.ts b/src/mol-plugin/state/transforms/model.ts index 3ac616e7251f07fd39165cbdf67a731239d931a3..bb7e497b72c439d7999ccbe0124aac4a1fe3cc64 100644 --- a/src/mol-plugin/state/transforms/model.ts +++ b/src/mol-plugin/state/transforms/model.ts @@ -41,7 +41,7 @@ export { TransformStructureConformation }; export { TransformStructureConformationByMatrix }; export { StructureSelection }; export { UserStructureSelection }; -export { LociStructureSelection }; +export { BundleStructureSelection as LociStructureSelection }; export { StructureComplexElement }; export { CustomModelProperties }; export { CustomStructureProperties }; @@ -435,39 +435,39 @@ function updateStructureFromQuery(query: QueryFn<Sel>, src: Structure, obj: SO.M return true; } -type LociStructureSelection = typeof LociStructureSelection -const LociStructureSelection = PluginStateTransform.BuiltIn({ - name: 'loci-structure-selection', - display: { name: 'Structure Selection', description: 'Create a molecular structure from the specified structure-element query.' }, +type BundleStructureSelection = typeof BundleStructureSelection +const BundleStructureSelection = PluginStateTransform.BuiltIn({ + name: 'bundle-structure-selection', + display: { name: 'Structure Selection', description: 'Create a molecular structure from the specified structure-element bundle.' }, from: SO.Molecule.Structure, to: SO.Molecule.Structure, params: { - query: PD.Value<StructureElement.Query>(StructureElement.Query.Empty, { isHidden: true }), + bundle: PD.Value<StructureElement.Bundle>(StructureElement.Bundle.Empty, { isHidden: true }), label: PD.Optional(PD.Text('', { isHidden: true })) } })({ apply({ a, params, cache }) { - if (params.query.hash !== a.data.hashCode) { - // Query not compatible with given structure, set to empty query - params.query = StructureElement.Query.Empty + if (params.bundle.hash !== a.data.hashCode) { + // Bundle not compatible with given structure, set to empty bundle + params.bundle = StructureElement.Bundle.Empty } (cache as { source: Structure }).source = a.data; - const s = StructureElement.Query.toStructure(params.query, a.data); + const s = StructureElement.Bundle.toStructure(params.bundle, a.data); if (s.elementCount === 0) return StateObject.Null; const props = { label: `${params.label || 'Selection'}`, description: structureDesc(s) }; return new SO.Molecule.Structure(s, props); }, update: ({ a, b, oldParams, newParams, cache }) => { - if (!StructureElement.Query.areEqual(oldParams.query, newParams.query)) { + if (!StructureElement.Bundle.areEqual(oldParams.bundle, newParams.bundle)) { return StateTransformer.UpdateResult.Recreate; } - if (newParams.query.hash !== a.data.hashCode) { - // Query not compatible with given structure, set to empty query - newParams.query = StructureElement.Query.Empty + if (newParams.bundle.hash !== a.data.hashCode) { + // Bundle not compatible with given structure, set to empty bundle + newParams.bundle = StructureElement.Bundle.Empty } if ((cache as { source: Structure }).source === a.data) { @@ -475,7 +475,7 @@ const LociStructureSelection = PluginStateTransform.BuiltIn({ } (cache as { source: Structure }).source = a.data; - const s = StructureElement.Query.toStructure(newParams.query, a.data); + const s = StructureElement.Bundle.toStructure(newParams.bundle, a.data); if (s.elementCount === 0) return StateTransformer.UpdateResult.Null; b.label = `${newParams.label || 'Selection'}`; diff --git a/src/mol-plugin/util/structure-representation-helper.ts b/src/mol-plugin/util/structure-representation-helper.ts index 3f73b7d75b3d7b64859c1e439c77cff58f7eaf6b..9ede0cd4237d2da6695240270abd4cc3b3ce5bf8 100644 --- a/src/mol-plugin/util/structure-representation-helper.ts +++ b/src/mol-plugin/util/structure-representation-helper.ts @@ -57,12 +57,12 @@ export class StructureRepresentationHelper { const reprStructure = this.getRepresentationStructure(structure.transform.ref, type) if (reprStructure) { - const currentLoci = StructureElement.Query.toLoci(reprStructure.params!.values.query, s) + const currentLoci = StructureElement.Bundle.toLoci(reprStructure.params!.values.bundle, s) const combinedLoci = getCombinedLoci(modifier, loci, currentLoci) update.to(reprStructure).update({ ...reprStructure.params!.values, - query: StructureElement.Query.fromLoci(combinedLoci) + bundle: StructureElement.Bundle.fromLoci(combinedLoci) }) } else { const combinedLoci = getCombinedLoci(modifier, loci, StructureElement.Loci(s, [])) @@ -76,7 +76,7 @@ export class StructureRepresentationHelper { update.to(structure.transform.ref) .apply( StateTransforms.Model.LociStructureSelection, - { query: StructureElement.Query.fromLoci(combinedLoci), label: type }, + { bundle: StructureElement.Bundle.fromLoci(combinedLoci), label: type }, { tags: [ RepresentationManagerTag, getRepresentationManagerTag(type) ] } ) .apply( StateTransforms.Representation.StructureRepresentation3D, params) @@ -109,14 +109,14 @@ export class StructureRepresentationHelper { const state = this.plugin.state.dataState; const update = state.build() const structures = state.select(StateSelection.Generators.rootsOfType(PSO.Molecule.Structure)) - const query = StructureElement.Query.Empty + const bundle = StructureElement.Bundle.Empty for (const structure of structures) { for (let i = 0, il = registry.types.length; i < il; ++i) { const type = registry.types[i][0] const reprStructure = this.getRepresentationStructure(structure.transform.ref, type) if (reprStructure) { - update.to(reprStructure).update({ ...reprStructure.params!.values, query }) + update.to(reprStructure).update({ ...reprStructure.params!.values, bundle }) } } } diff --git a/src/mol-script/script/mol-script/symbols.ts b/src/mol-script/script/mol-script/symbols.ts index 42218fb8da9e702daa01e02923b944c441d7e32c..173e7b2df43c587f298215b12b05abc05440e603 100644 --- a/src/mol-script/script/mol-script/symbols.ts +++ b/src/mol-script/script/mol-script/symbols.ts @@ -232,6 +232,7 @@ export const SymbolTable = [ Alias(MolScript.structureQuery.atomProperty.macromolecular.occupancy, 'atom.occupancy'), Alias(MolScript.structureQuery.atomProperty.macromolecular.B_iso_or_equiv, 'atom.B_iso_or_equiv', 'atom.bfactor'), Alias(MolScript.structureQuery.atomProperty.macromolecular.entityType, 'atom.entity-type'), + Alias(MolScript.structureQuery.atomProperty.macromolecular.entitySubtype, 'atom.entity-subtype'), Alias(MolScript.structureQuery.atomProperty.macromolecular.objectPrimitive, 'atom.object-primitive'), Alias(MolScript.structureQuery.atomProperty.macromolecular.chemCompType, 'atom.chem-comp-type'),