From e42c664a8c14fd1b44e23e85c6a6d82763534a73 Mon Sep 17 00:00:00 2001 From: Alexander Rose <alex.rose@rcsb.org> Date: Fri, 21 Jun 2019 10:56:06 -0700 Subject: [PATCH] fixes: StructureElement.Loci.union, Structure.parent --- src/mol-model/structure/structure/element.ts | 5 +++++ src/mol-model/structure/structure/structure.ts | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mol-model/structure/structure/element.ts b/src/mol-model/structure/structure/element.ts index b3801b3a1..8ac7af0c1 100644 --- a/src/mol-model/structure/structure/element.ts +++ b/src/mol-model/structure/structure/element.ts @@ -157,11 +157,16 @@ namespace StructureElement { for (const e of ys.elements) { if (map.has(e.unit.id)) { elements[elements.length] = { unit: e.unit, indices: OrderedSet.union(map.get(e.unit.id)!, e.indices) }; + map.delete(e.unit.id) } else { elements[elements.length] = e; } } + map.forEach((indices, id) => { + elements[elements.length] = { unit: xs.structure.unitMap.get(id)!, indices }; + }); + return Loci(xs.structure, elements); } diff --git a/src/mol-model/structure/structure/structure.ts b/src/mol-model/structure/structure/structure.ts index ed9b314f7..03569e40a 100644 --- a/src/mol-model/structure/structure/structure.ts +++ b/src/mol-model/structure/structure/structure.ts @@ -141,6 +141,7 @@ class Structure { return new Structure.ElementLocationIterator(this); } + /** the root/top-most parent or `undefined` in case this is the root */ get parent() { return this._props.parent; } @@ -240,7 +241,7 @@ class Structure { constructor(units: ArrayLike<Unit>, parent: Structure | undefined, coordinateSystem?: SymmetryOperator) { this.unitMap = this.initUnits(units); this.units = units as ReadonlyArray<Unit>; - if (parent) this._props.parent = parent; + if (parent) this._props.parent = parent.parent || parent; if (coordinateSystem) this._props.coordinateSystem = coordinateSystem; else if (parent) this._props.coordinateSystem = parent.coordinateSystem; } -- GitLab