From e8df2a6555e3a7850823ea154dcf0066e85e41d6 Mon Sep 17 00:00:00 2001 From: David Sehnal <david.sehnal@gmail.com> Date: Wed, 11 Jul 2018 12:32:56 +0200 Subject: [PATCH] Coarse hierarchy refactor --- src/mol-geo/representation/structure/visual/util/polymer.ts | 4 ++-- src/mol-model/structure/model/formats/mmcif/ihm.ts | 6 +++--- .../structure/model/properties/coarse/hierarchy.ts | 4 ++-- .../structure/model/properties/utils/coarse-keys.ts | 6 +++--- src/mol-model/structure/structure/structure.ts | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/mol-geo/representation/structure/visual/util/polymer.ts b/src/mol-geo/representation/structure/visual/util/polymer.ts index 6234a27cd..4c80e9466 100644 --- a/src/mol-geo/representation/structure/visual/util/polymer.ts +++ b/src/mol-geo/representation/structure/visual/util/polymer.ts @@ -215,10 +215,10 @@ export class CoarsePolymerBackboneIterator<T extends number = number> implements } constructor(unit: Unit.Spheres | Unit.Gaussians) { - const { polymerSegments } = Unit.isSpheres(unit) + const { polymerElementSegments } = Unit.isSpheres(unit) ? unit.model.coarseHierarchy.spheres : unit.model.coarseHierarchy.gaussians - this.polymerIt = Segmentation.transientSegments(polymerSegments, unit.elements); + this.polymerIt = Segmentation.transientSegments(polymerElementSegments, unit.elements); this.pos = unit.conformation.invariantPosition this.value = createPolymerBackbonePair(unit) diff --git a/src/mol-model/structure/model/formats/mmcif/ihm.ts b/src/mol-model/structure/model/formats/mmcif/ihm.ts index 35d307a4e..04a5b2ec7 100644 --- a/src/mol-model/structure/model/formats/mmcif/ihm.ts +++ b/src/mol-model/structure/model/formats/mmcif/ihm.ts @@ -12,7 +12,7 @@ import { getCoarseKeys } from '../../properties/utils/coarse-keys'; import { UUID } from 'mol-util'; import { Segmentation, Interval } from 'mol-data/int'; import { Mat3, Tensor } from 'mol-math/linear-algebra'; -import { ElementIndex } from '../../indexing'; +import { ElementIndex, ChainIndex } from '../../indexing'; export interface IHMData { model_id: number, @@ -92,8 +92,8 @@ function getSegments(asym_id: Column<string>, seq_id_begin: Column<number>, seq_ } return { - chainSegments: Segmentation.ofOffsets(chainOffsets, Interval.ofBounds(0, asym_id.rowCount)), - polymerSegments: Segmentation.ofOffsets(polymerOffsets, Interval.ofBounds(0, asym_id.rowCount)) + chainElementSegments: Segmentation.ofOffsets<ElementIndex, ChainIndex>(chainOffsets, Interval.ofBounds(0, asym_id.rowCount)), + polymerElementSegments: Segmentation.ofOffsets(polymerOffsets, Interval.ofBounds(0, asym_id.rowCount)) } } diff --git a/src/mol-model/structure/model/properties/coarse/hierarchy.ts b/src/mol-model/structure/model/properties/coarse/hierarchy.ts index 89e74fcba..f06d3d57a 100644 --- a/src/mol-model/structure/model/properties/coarse/hierarchy.ts +++ b/src/mol-model/structure/model/properties/coarse/hierarchy.ts @@ -27,12 +27,12 @@ export interface CoarseElementData { seq_id_begin: Column<number>, seq_id_end: Column<number>, - chainSegments: Segmentation<ElementIndex>, + chainElementSegments: Segmentation<ElementIndex, ChainIndex>, /** * bonded/connected stretches of polymer chains, i.e. a chain will be * broken into multiple polymer segments if there are missing residues */ - polymerSegments: Segmentation<ElementIndex> + polymerElementSegments: Segmentation<ElementIndex> } export type CoarseElements = CoarsedElementKeys & CoarseElementData diff --git a/src/mol-model/structure/model/properties/utils/coarse-keys.ts b/src/mol-model/structure/model/properties/utils/coarse-keys.ts index ac3b75edf..a20d723bf 100644 --- a/src/mol-model/structure/model/properties/utils/coarse-keys.ts +++ b/src/mol-model/structure/model/properties/utils/coarse-keys.ts @@ -52,7 +52,7 @@ function missingEntity(k: string) { } export function getCoarseKeys(data: CoarseElementData, entities: Entities): CoarsedElementKeys { - const { entity_id, asym_id, seq_id_begin, seq_id_end, count, chainSegments } = data; + const { entity_id, asym_id, seq_id_begin, seq_id_end, count, chainElementSegments } = data; const seqMaps = new Map<number, Map<number, number>>(); const chainMaps = new Map<number, Map<string, number>>(), chainCounter = { index: 0 }; @@ -65,8 +65,8 @@ export function getCoarseKeys(data: CoarseElementData, entities: Entities): Coar if (entityKey[i] < 0) missingEntity(entity_id.value(i)); } - for (let cI = 0; cI < chainSegments.count; cI++) { - const start = chainSegments.offsets[cI], end = chainSegments.offsets[cI + 1]; + for (let cI = 0; cI < chainElementSegments.count; cI++) { + const start = chainElementSegments.offsets[cI], end = chainElementSegments.offsets[cI + 1]; const map = getElementSubstructureKeyMap(chainMaps, entityKey[start]); const key = getElementKey(map, asym_id.value(start), chainCounter); for (let i = start; i < end; i++) chainKey[i] = key; diff --git a/src/mol-model/structure/structure/structure.ts b/src/mol-model/structure/structure/structure.ts index 1be5f7ff6..1e806d8d8 100644 --- a/src/mol-model/structure/structure/structure.ts +++ b/src/mol-model/structure/structure/structure.ts @@ -149,9 +149,9 @@ namespace Structure { } function addCoarseUnits(builder: StructureBuilder, model: Model, elements: CoarseElements, kind: Unit.Kind) { - const { chainSegments } = elements; - for (let cI = 0; cI < chainSegments.count; cI++) { - const elements = SortedArray.ofBounds<ElementIndex>(chainSegments.offsets[cI], chainSegments.offsets[cI + 1]); + const { chainElementSegments } = elements; + for (let cI = 0; cI < chainElementSegments.count; cI++) { + const elements = SortedArray.ofBounds<ElementIndex>(chainElementSegments.offsets[cI], chainElementSegments.offsets[cI + 1]); builder.addUnit(kind, model, SymmetryOperator.Default, elements); } } -- GitLab