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

trace caps only when sec struc type changes

parent 5a3fed3c
No related branches found
No related tags found
No related merge requests found
...@@ -62,8 +62,8 @@ async function createPolymerTraceMesh(ctx: VisualContext, unit: Unit, structure: ...@@ -62,8 +62,8 @@ async function createPolymerTraceMesh(ctx: VisualContext, unit: Unit, structure:
if (isSheet) { if (isSheet) {
const height = width * aspectRatio const height = width * aspectRatio
const arrowHeight = v.secStrucChange ? height * arrowFactor : 0 const arrowHeight = v.secStrucLast ? height * arrowFactor : 0
addSheet(builder, curvePoints, normalVectors, binormalVectors, linearSegments, width, height, arrowHeight, true, true) addSheet(builder, curvePoints, normalVectors, binormalVectors, linearSegments, width, height, arrowHeight, v.secStrucFirst, v.secStrucLast)
} else { } else {
let height: number let height: number
if (isHelix) { if (isHelix) {
...@@ -74,7 +74,7 @@ async function createPolymerTraceMesh(ctx: VisualContext, unit: Unit, structure: ...@@ -74,7 +74,7 @@ async function createPolymerTraceMesh(ctx: VisualContext, unit: Unit, structure:
} else { } else {
height = width height = width
} }
addTube(builder, curvePoints, normalVectors, binormalVectors, linearSegments, radialSegments, width, height, 1, true, true) addTube(builder, curvePoints, normalVectors, binormalVectors, linearSegments, radialSegments, width, height, 1, v.secStrucFirst, v.secStrucLast)
} }
if (i % 10000 === 0 && ctx.runtime.shouldUpdate) { if (i % 10000 === 0 && ctx.runtime.shouldUpdate) {
......
...@@ -13,6 +13,7 @@ import SortedRanges from 'mol-data/int/sorted-ranges'; ...@@ -13,6 +13,7 @@ import SortedRanges from 'mol-data/int/sorted-ranges';
import { CoarseSphereConformation, CoarseGaussianConformation } from 'mol-model/structure/model/properties/coarse'; import { CoarseSphereConformation, CoarseGaussianConformation } from 'mol-model/structure/model/properties/coarse';
import { getAtomicMoleculeType, getElementIndexForAtomRole } from 'mol-model/structure/util'; import { getAtomicMoleculeType, getElementIndexForAtomRole } from 'mol-model/structure/util';
import { getPolymerRanges } from '../polymer'; import { getPolymerRanges } from '../polymer';
import { AtomicConformation } from 'mol-model/structure/model/properties/atomic';
/** /**
* Iterates over individual residues/coarse elements in polymers of a unit while * Iterates over individual residues/coarse elements in polymers of a unit while
...@@ -30,20 +31,22 @@ export function PolymerTraceIterator(unit: Unit): Iterator<PolymerTraceElement> ...@@ -30,20 +31,22 @@ export function PolymerTraceIterator(unit: Unit): Iterator<PolymerTraceElement>
interface PolymerTraceElement { interface PolymerTraceElement {
center: StructureElement center: StructureElement
first: boolean, last: boolean first: boolean, last: boolean
secStrucFirst: boolean, secStrucLast: boolean
secStrucType: SecondaryStructureType secStrucType: SecondaryStructureType
secStrucChange: boolean
moleculeType: MoleculeType moleculeType: MoleculeType
p0: Vec3, p1: Vec3, p2: Vec3, p3: Vec3, p4: Vec3 p0: Vec3, p1: Vec3, p2: Vec3, p3: Vec3, p4: Vec3
d12: Vec3, d23: Vec3 d12: Vec3, d23: Vec3
} }
const SecStrucTypeNA = SecondaryStructureType.create(SecondaryStructureType.Flag.NA)
function createPolymerTraceElement (unit: Unit): PolymerTraceElement { function createPolymerTraceElement (unit: Unit): PolymerTraceElement {
return { return {
center: StructureElement.create(unit), center: StructureElement.create(unit),
first: false, last: false, first: false, last: false,
secStrucType: SecondaryStructureType.create(SecondaryStructureType.Flag.NA), secStrucFirst: false, secStrucLast: false,
secStrucChange: false, secStrucType: SecStrucTypeNA,
moleculeType: MoleculeType.unknown, moleculeType: MoleculeType.unknown,
p0: Vec3.zero(), p1: Vec3.zero(), p2: Vec3.zero(), p3: Vec3.zero(), p4: Vec3.zero(), p0: Vec3.zero(), p1: Vec3.zero(), p2: Vec3.zero(), p3: Vec3.zero(), p4: Vec3.zero(),
d12: Vec3.create(1, 0, 0), d23: Vec3.create(1, 0, 0), d12: Vec3.create(1, 0, 0), d23: Vec3.create(1, 0, 0),
...@@ -57,10 +60,15 @@ export class AtomicPolymerTraceIterator implements Iterator<PolymerTraceElement> ...@@ -57,10 +60,15 @@ 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 secondaryStructureType: ArrayLike<SecondaryStructureType>
private residueSegmentMin: ResidueIndex private residueSegmentMin: ResidueIndex
private residueSegmentMax: ResidueIndex private residueSegmentMax: ResidueIndex
private prevSecStrucType: SecondaryStructureType
private currSecStrucType: SecondaryStructureType
private nextSecStrucType: SecondaryStructureType
private state: AtomicPolymerTraceIteratorState = AtomicPolymerTraceIteratorState.nextPolymer private state: AtomicPolymerTraceIteratorState = AtomicPolymerTraceIteratorState.nextPolymer
private residueAtomSegments: Segmentation<ElementIndex, ResidueIndex> private residueAtomSegments: Segmentation<ElementIndex, ResidueIndex>
private atomicConformation: AtomicConformation
private p0 = Vec3.zero(); private p0 = Vec3.zero();
private p1 = Vec3.zero(); private p1 = Vec3.zero();
...@@ -78,13 +86,13 @@ export class AtomicPolymerTraceIterator implements Iterator<PolymerTraceElement> ...@@ -78,13 +86,13 @@ export class AtomicPolymerTraceIterator implements Iterator<PolymerTraceElement>
hasNext: boolean = false; hasNext: boolean = false;
private pos(target: Vec3, index: number) { private pos(target: Vec3, index: number) {
target[0] = this.unit.model.atomicConformation.x[index] target[0] = this.atomicConformation.x[index]
target[1] = this.unit.model.atomicConformation.y[index] target[1] = this.atomicConformation.y[index]
target[2] = this.unit.model.atomicConformation.z[index] target[2] = this.atomicConformation.z[index]
} }
private updateResidueSegmentRange(polymerSegment: Segmentation.Segment<ResidueIndex>) { private updateResidueSegmentRange(polymerSegment: Segmentation.Segment<ResidueIndex>) {
const { index } = this.unit.model.atomicHierarchy.residueAtomSegments const { index } = this.residueAtomSegments
this.residueSegmentMin = index[this.unit.elements[polymerSegment.start]] this.residueSegmentMin = index[this.unit.elements[polymerSegment.start]]
this.residueSegmentMax = index[this.unit.elements[polymerSegment.end - 1]] this.residueSegmentMax = index[this.unit.elements[polymerSegment.end - 1]]
} }
...@@ -151,7 +159,11 @@ export class AtomicPolymerTraceIterator implements Iterator<PolymerTraceElement> ...@@ -151,7 +159,11 @@ export class AtomicPolymerTraceIterator implements Iterator<PolymerTraceElement>
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.pos(this.v34, this.getAtomIndex(residueIndex + 1 as ResidueIndex, 'direction'))
this.value.secStrucType = this.unit.model.properties.secondaryStructure.type[residueIndex] this.prevSecStrucType = this.currSecStrucType
this.currSecStrucType = this.nextSecStrucType
this.nextSecStrucType = residueIt.hasNext ? this.secondaryStructureType[residueIndex + 1] : SecStrucTypeNA
this.value.secStrucType = this.currSecStrucType
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)
...@@ -164,7 +176,8 @@ export class AtomicPolymerTraceIterator implements Iterator<PolymerTraceElement> ...@@ -164,7 +176,8 @@ export class AtomicPolymerTraceIterator implements Iterator<PolymerTraceElement>
value.first = residueIndex === this.residueSegmentMin value.first = residueIndex === this.residueSegmentMin
value.last = residueIndex === this.residueSegmentMax value.last = residueIndex === this.residueSegmentMax
value.secStrucChange = this.unit.model.properties.secondaryStructure.key[residueIndex] !== this.unit.model.properties.secondaryStructure.key[residueIndex + 1] value.secStrucFirst = this.prevSecStrucType !== this.currSecStrucType
value.secStrucLast = this.currSecStrucType !== this.nextSecStrucType
value.moleculeType = getAtomicMoleculeType(this.unit.model, residueIndex) value.moleculeType = getAtomicMoleculeType(this.unit.model, residueIndex)
if (!residueIt.hasNext) { if (!residueIt.hasNext) {
...@@ -178,7 +191,9 @@ export class AtomicPolymerTraceIterator implements Iterator<PolymerTraceElement> ...@@ -178,7 +191,9 @@ export class AtomicPolymerTraceIterator implements Iterator<PolymerTraceElement>
} }
constructor(private unit: Unit.Atomic) { constructor(private unit: Unit.Atomic) {
this.atomicConformation = unit.model.atomicConformation
this.residueAtomSegments = unit.model.atomicHierarchy.residueAtomSegments this.residueAtomSegments = unit.model.atomicHierarchy.residueAtomSegments
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);
this.value = createPolymerTraceElement(unit) this.value = createPolymerTraceElement(unit)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment