Skip to content
Snippets Groups Projects
Commit 48d3c615 authored by Alexander Rose's avatar Alexander Rose
Browse files

wip, trace iterator opt

parent b6a6a29c
No related branches found
No related tags found
No related merge requests found
...@@ -60,6 +60,7 @@ export class AtomicPolymerTraceIterator implements Iterator<PolymerTraceElement> ...@@ -60,6 +60,7 @@ export class AtomicPolymerTraceIterator implements Iterator<PolymerTraceElement>
private polymerIt: SortedRanges.Iterator<ElementIndex, ResidueIndex> private polymerIt: SortedRanges.Iterator<ElementIndex, ResidueIndex>
private residueIt: Segmentation.SegmentIterator<ResidueIndex> private residueIt: Segmentation.SegmentIterator<ResidueIndex>
private polymerSegment: Segmentation.Segment<ResidueIndex> private polymerSegment: Segmentation.Segment<ResidueIndex>
private cyclicPolymerMap: Map<ResidueIndex, ResidueIndex>
private secondaryStructureType: ArrayLike<SecondaryStructureType> private secondaryStructureType: ArrayLike<SecondaryStructureType>
private residueSegmentMin: ResidueIndex private residueSegmentMin: ResidueIndex
private residueSegmentMax: ResidueIndex private residueSegmentMax: ResidueIndex
...@@ -97,25 +98,28 @@ export class AtomicPolymerTraceIterator implements Iterator<PolymerTraceElement> ...@@ -97,25 +98,28 @@ export class AtomicPolymerTraceIterator implements Iterator<PolymerTraceElement>
this.residueSegmentMax = index[this.unit.elements[polymerSegment.end - 1]] this.residueSegmentMax = index[this.unit.elements[polymerSegment.end - 1]]
} }
private getElementIndex(residueIndex: ResidueIndex, atomRole: AtomRole) { private getResidueIndex(residueIndex: ResidueIndex) {
const { atomicHierarchy } = this.unit.model
if (residueIndex < this.residueSegmentMin) { if (residueIndex < this.residueSegmentMin) {
const cyclicIndex = atomicHierarchy.cyclicPolymerMap.get(this.residueSegmentMin) const cyclicIndex = this.cyclicPolymerMap.get(this.residueSegmentMin)
if (cyclicIndex !== undefined) { if (cyclicIndex !== undefined) {
residueIndex = cyclicIndex - (this.residueSegmentMin - residueIndex - 1) as ResidueIndex residueIndex = cyclicIndex - (this.residueSegmentMin - residueIndex - 1) as ResidueIndex
} else { } else {
residueIndex = this.residueSegmentMin residueIndex = this.residueSegmentMin
} }
} else if (residueIndex > this.residueSegmentMax) { } else if (residueIndex > this.residueSegmentMax) {
const cyclicIndex = atomicHierarchy.cyclicPolymerMap.get(this.residueSegmentMax) const cyclicIndex = this.cyclicPolymerMap.get(this.residueSegmentMax)
if (cyclicIndex !== undefined) { if (cyclicIndex !== undefined) {
residueIndex = cyclicIndex + (residueIndex - this.residueSegmentMax - 1) as ResidueIndex residueIndex = cyclicIndex + (residueIndex - this.residueSegmentMax - 1) as ResidueIndex
} else { } else {
residueIndex = this.residueSegmentMax residueIndex = this.residueSegmentMax
} }
} }
return residueIndex
}
private getElementIndex(residueIndex: ResidueIndex, atomRole: AtomRole) {
const elementIndex = getElementIndexForAtomRole(this.unit.model, residueIndex, atomRole) const elementIndex = getElementIndexForAtomRole(this.unit.model, residueIndex, atomRole)
return elementIndex === -1 ? atomicHierarchy.residueAtomSegments.offsets[residueIndex] : elementIndex return elementIndex === -1 ? this.residueAtomSegments.offsets[residueIndex] : elementIndex
} }
private setControlPoint(out: Vec3, p1: Vec3, p2: Vec3, p3: Vec3, residueIndex: ResidueIndex) { private setControlPoint(out: Vec3, p1: Vec3, p2: Vec3, p3: Vec3, residueIndex: ResidueIndex) {
...@@ -158,18 +162,27 @@ export class AtomicPolymerTraceIterator implements Iterator<PolymerTraceElement> ...@@ -158,18 +162,27 @@ export class AtomicPolymerTraceIterator implements Iterator<PolymerTraceElement>
value.secStrucLast = this.currSecStrucType !== this.nextSecStrucType value.secStrucLast = this.currSecStrucType !== this.nextSecStrucType
value.moleculeType = getAtomicMoleculeType(this.unit.model, residueIndex) value.moleculeType = getAtomicMoleculeType(this.unit.model, residueIndex)
this.pos(this.p0, this.getElementIndex(residueIndex - 3 as ResidueIndex, 'trace')) if (value.first) {
this.pos(this.p1, this.getElementIndex(residueIndex - 2 as ResidueIndex, 'trace')) this.pos(this.p0, this.getElementIndex(this.getResidueIndex(residueIndex - 3 as ResidueIndex), 'trace'))
this.pos(this.p2, this.getElementIndex(residueIndex - 1 as ResidueIndex, 'trace')) this.pos(this.p1, this.getElementIndex(this.getResidueIndex(residueIndex - 2 as ResidueIndex), 'trace'))
this.pos(this.p3, this.getElementIndex(residueIndex, 'trace')) this.pos(this.p2, this.getElementIndex(this.getResidueIndex(residueIndex - 1 as ResidueIndex), 'trace'))
this.pos(this.p4, this.getElementIndex(residueIndex + 1 as ResidueIndex, 'trace')) this.pos(this.p3, value.center.element)
this.pos(this.p5, this.getElementIndex(residueIndex + 2 as ResidueIndex, 'trace')) this.pos(this.p4, this.getElementIndex(this.getResidueIndex(residueIndex + 1 as ResidueIndex), 'trace'))
this.pos(this.p6, this.getElementIndex(residueIndex + 3 as ResidueIndex, 'trace')) this.pos(this.p5, this.getElementIndex(this.getResidueIndex(residueIndex + 2 as ResidueIndex), 'trace'))
// this.pos(this.v01, this.getAtomIndex(residueIndex - 2 as ResidueIndex, 'direction')) this.pos(this.v12, this.getElementIndex(residueIndex - 1 as ResidueIndex, 'direction'))
this.pos(this.v12, this.getElementIndex(residueIndex - 1 as ResidueIndex, 'direction')) } else {
Vec3.copy(this.p0, this.p1)
Vec3.copy(this.p1, this.p2)
Vec3.copy(this.p2, this.p3)
Vec3.copy(this.p3, this.p4)
Vec3.copy(this.p4, this.p5)
Vec3.copy(this.p5, this.p6)
Vec3.copy(this.v12, this.v23)
}
this.pos(this.p6, this.getElementIndex(this.getResidueIndex(residueIndex + 3 as ResidueIndex), 'trace'))
this.pos(this.v23, this.getElementIndex(residueIndex, 'direction')) this.pos(this.v23, this.getElementIndex(residueIndex, 'direction'))
// this.pos(this.v34, this.getAtomIndex(residueIndex + 1 as ResidueIndex, 'direction'))
this.setControlPoint(value.p0, this.p0, this.p1, this.p2, residueIndex - 2 as ResidueIndex) this.setControlPoint(value.p0, this.p0, this.p1, this.p2, residueIndex - 2 as ResidueIndex)
this.setControlPoint(value.p1, this.p1, this.p2, this.p3, residueIndex - 1 as ResidueIndex) this.setControlPoint(value.p1, this.p1, this.p2, this.p3, residueIndex - 1 as ResidueIndex)
...@@ -193,6 +206,7 @@ export class AtomicPolymerTraceIterator implements Iterator<PolymerTraceElement> ...@@ -193,6 +206,7 @@ export class AtomicPolymerTraceIterator implements Iterator<PolymerTraceElement>
constructor(private unit: Unit.Atomic) { constructor(private unit: Unit.Atomic) {
this.atomicConformation = unit.model.atomicConformation this.atomicConformation = unit.model.atomicConformation
this.residueAtomSegments = unit.model.atomicHierarchy.residueAtomSegments this.residueAtomSegments = unit.model.atomicHierarchy.residueAtomSegments
this.cyclicPolymerMap = unit.model.atomicHierarchy.cyclicPolymerMap
this.secondaryStructureType = unit.model.properties.secondaryStructure.type this.secondaryStructureType = unit.model.properties.secondaryStructure.type
this.polymerIt = SortedRanges.transientSegments(getPolymerRanges(unit), unit.elements) this.polymerIt = SortedRanges.transientSegments(getPolymerRanges(unit), unit.elements)
this.residueIt = Segmentation.transientSegments(this.residueAtomSegments, unit.elements); this.residueIt = Segmentation.transientSegments(this.residueAtomSegments, unit.elements);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment