Skip to content
Snippets Groups Projects
Commit e8df2a65 authored by David Sehnal's avatar David Sehnal
Browse files

Coarse hierarchy refactor

parent 8cce7a8a
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
......@@ -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))
}
}
......
......@@ -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
......
......@@ -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;
......
......@@ -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);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment