diff --git a/CHANGELOG.md b/CHANGELOG.md index 82c807e707b582f94f6a81fe3db30b971b48c9db..7cd972e722db61d82e2c96afd1052da04c358560 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,17 +8,18 @@ Note that since we don't clearly distinguish between a public and private interf - Make `PluginContext.initContainer` checkered canvas background optional - Store URL of downloaded assets to detect zip/gzip based on extension +- Add optional `operator.key`; can be referenced in `IndexPairBonds` ## [v3.23.0] - 2022-10-19 - Add `PluginContext.initContainer/mount/unmount` methods; these should make it easier to reuse a plugin context with both custom and built-in UI - Add `PluginContext.canvas3dInitialized` - `createPluginUI` now resolves after the 3d canvas has been initialized -- Change EM Volume Streaming default from `Whote Structure` to `Auto` +- Change EM Volume Streaming default from `Whole Structure` to `Auto` ## [v3.22.0] - 2022-10-17 -- Replace `VolumeIsosurfaceParams.pickingGranularity` param with `Volume.PickingGranuality` +- Replace `VolumeIsosurfaceParams.pickingGranularity` param with `Volume.PickingGranuality` ## [v3.21.0] - 2022-10-17 diff --git a/src/mol-model-formats/structure/property/bonds/index-pair.ts b/src/mol-model-formats/structure/property/bonds/index-pair.ts index 99eb988e7e185d8297d2c71f66e4733dbdec5075..96e0945e91f7491d0743645e48dc5fee9f59c6ea 100644 --- a/src/mol-model-formats/structure/property/bonds/index-pair.ts +++ b/src/mol-model-formats/structure/property/bonds/index-pair.ts @@ -14,8 +14,8 @@ import { ElementIndex } from '../../../../mol-model/structure'; export type IndexPairsProps = { readonly key: ArrayLike<number> - /** Sorted contor-paired operator keys */ - readonly operator: ArrayLike<number> + readonly operatorA: ArrayLike<number> + readonly operatorB: ArrayLike<number> readonly order: ArrayLike<number> readonly distance: ArrayLike<number> readonly flag: ArrayLike<BondType.Flag> @@ -26,20 +26,22 @@ export type IndexPairBonds = { bonds: IndexPairs, maxDistance: number } function getGraph(indexA: ArrayLike<ElementIndex>, indexB: ArrayLike<ElementIndex>, props: Partial<IndexPairsProps>, count: number): IndexPairs { const builder = new IntAdjacencyGraph.EdgeBuilder(count, indexA, indexB); const key = new Int32Array(builder.slotCount); - const operator = new Array(builder.slotCount); + const operatorA = new Array(builder.slotCount); + const operatorB = new Array(builder.slotCount); const order = new Int8Array(builder.slotCount); const distance = new Array(builder.slotCount); const flag = new Array(builder.slotCount); for (let i = 0, _i = builder.edgeCount; i < _i; i++) { builder.addNextEdge(); builder.assignProperty(key, props.key ? props.key[i] : -1); - builder.assignProperty(operator, props.operator ? props.operator[i] : -1); + builder.assignProperty(operatorA, props.operatorA ? props.operatorA[i] : -1); + builder.assignProperty(operatorB, props.operatorB ? props.operatorB[i] : -1); builder.assignProperty(order, props.order ? props.order[i] : 1); builder.assignProperty(distance, props.distance ? props.distance[i] : -1); builder.assignProperty(flag, props.flag ? props.flag[i] : BondType.Flag.Covalent); } - return builder.createGraph({ key, operator, order, distance, flag }); + return builder.createGraph({ key, operatorA, operatorB, order, distance, flag }); } export namespace IndexPairBonds { @@ -54,10 +56,10 @@ export namespace IndexPairBonds { indexA: Column<number>, indexB: Column<number>, key?: Column<number>, - /** - * Sorted contor-paired operator keys. Used in bond computation. - */ - operator?: Column<number>, + /** Operator key for indexA. Used in bond computation. */ + operatorA?: Column<number>, + /** Operator key for indexB. Used in bond computation. */ + operatorB?: Column<number>, order?: Column<number>, /** * Useful for bonds in periodic cells. That is, only bonds within the given @@ -91,12 +93,13 @@ export namespace IndexPairBonds { const indexA = pairs.indexA.toArray() as ArrayLike<ElementIndex>; const indexB = pairs.indexB.toArray() as ArrayLike<ElementIndex>; const key = pairs.key && pairs.key.toArray(); - const operator = pairs.operator && pairs.operator.toArray(); + const operatorA = pairs.operatorA && pairs.operatorA.toArray(); + const operatorB = pairs.operatorB && pairs.operatorB.toArray(); const order = pairs.order && pairs.order.toArray(); const distance = pairs.distance && pairs.distance.toArray(); const flag = pairs.flag && pairs.flag.toArray(); return { - bonds: getGraph(indexA, indexB, { key, operator, order, distance, flag }, count), + bonds: getGraph(indexA, indexB, { key, operatorA, operatorB, order, distance, flag }, count), maxDistance: p.maxDistance }; } diff --git a/src/mol-model/structure/structure/unit/bonds/inter-compute.ts b/src/mol-model/structure/structure/unit/bonds/inter-compute.ts index 2585e4c850423cf0558aeba61d46ce7956e30b80..c8d34230db378656cc0aa60007a77be463292b83 100644 --- a/src/mol-model/structure/structure/unit/bonds/inter-compute.ts +++ b/src/mol-model/structure/structure/unit/bonds/inter-compute.ts @@ -20,7 +20,6 @@ import { InterUnitGraph } from '../../../../../mol-math/graph/inter-unit-graph'; import { StructConn } from '../../../../../mol-model-formats/structure/property/bonds/struct_conn'; import { equalEps } from '../../../../../mol-math/linear-algebra/3d/common'; import { Model } from '../../../model'; -import { sortedCantorPairing } from '../../../../../mol-data/util'; // avoiding namespace lookup improved performance in Chrome (Aug 2020) const v3distance = Vec3.distance; @@ -72,7 +71,8 @@ function findPairBonds(unitA: Unit.Atomic, unitB: Unit.Atomic, props: BondComput const testDistanceSq = (bRadius + maxRadius) * (bRadius + maxRadius); builder.startUnitPair(unitA.id, unitB.id); - const opPairKey = sortedCantorPairing(unitA.conformation.operator.key, unitB.conformation.operator.key); + const opKeyA = unitA.conformation.operator.key; + const opKeyB = unitB.conformation.operator.key; for (let _aI = 0 as StructureElement.UnitIndex; _aI < atomCount; _aI++) { const aI = atomsA[_aI]; @@ -82,7 +82,7 @@ function findPairBonds(unitA: Unit.Atomic, unitB: Unit.Atomic, props: BondComput if (!props.forceCompute && indexPairs) { const { maxDistance } = indexPairs; - const { offset, b, edgeProps: { order, distance, flag, key, operator } } = indexPairs.bonds; + const { offset, b, edgeProps: { order, distance, flag, key, operatorA, operatorB } } = indexPairs.bonds; const srcA = sourceIndex.value(aI); const aeI = getElementIdx(type_symbolA.value(aI)); @@ -92,8 +92,9 @@ function findPairBonds(unitA: Unit.Atomic, unitB: Unit.Atomic, props: BondComput const _bI = SortedArray.indexOf(unitB.elements, bI) as StructureElement.UnitIndex; if (_bI < 0) continue; - const op = operator[i]; - if (op >= 0 && opPairKey !== op) continue; + const opA = operatorA[i]; + const opB = operatorB[i]; + if ((opA >= 0 && opA !== opKeyA) || (opB >= 0 && opB !== opKeyB)) continue; const beI = getElementIdx(type_symbolA.value(bI)); diff --git a/src/mol-model/structure/structure/unit/bonds/intra-compute.ts b/src/mol-model/structure/structure/unit/bonds/intra-compute.ts index 67d89caac6753787379ea4bb84b6fe1860634f29..71bef526e5b8e7c850c46e1c84f180fe907ea976 100644 --- a/src/mol-model/structure/structure/unit/bonds/intra-compute.ts +++ b/src/mol-model/structure/structure/unit/bonds/intra-compute.ts @@ -20,7 +20,6 @@ import { Vec3 } from '../../../../../mol-math/linear-algebra'; import { ElementIndex } from '../../../model/indexing'; import { equalEps } from '../../../../../mol-math/linear-algebra/3d/common'; import { Model } from '../../../model/model'; -import { sortedCantorPairing } from '../../../../../mol-data/util'; // avoiding namespace lookup improved performance in Chrome (Aug 2020) const v3distance = Vec3.distance; @@ -56,7 +55,7 @@ function findIndexPairBonds(unit: Unit.Atomic) { const { type_symbol } = unit.model.atomicHierarchy.atoms; const atomCount = unit.elements.length; const { maxDistance } = indexPairs; - const { offset, b, edgeProps: { order, distance, flag, key, operator } } = indexPairs.bonds; + const { offset, b, edgeProps: { order, distance, flag, key, operatorA, operatorB } } = indexPairs.bonds; const { atomSourceIndex: sourceIndex } = unit.model.atomicHierarchy; const { invertedIndex } = Model.getInvertedAtomSourceIndex(unit.model); @@ -67,7 +66,7 @@ function findIndexPairBonds(unit: Unit.Atomic) { const orders: number[] = []; const keys: number[] = []; - const opPairKey = sortedCantorPairing(unit.conformation.operator.key, unit.conformation.operator.key); + const opKey = unit.conformation.operator.key; for (let _aI = 0 as StructureElement.UnitIndex; _aI < atomCount; _aI++) { const aI = atoms[_aI]; @@ -83,8 +82,9 @@ function findIndexPairBonds(unit: Unit.Atomic) { const _bI = SortedArray.indexOf(unit.elements, bI) as StructureElement.UnitIndex; if (_bI < 0) continue; - const op = operator[i]; - if (op >= 0 && opPairKey !== op) continue; + const opA = operatorA[i]; + const opB = operatorB[i]; + if ((opA >= 0 && opA !== opKey) || (opB >= 0 && opB !== opKey)) continue; const beI = getElementIdx(type_symbol.value(bI));