瀏覽代碼

polymer trace tweaks

Alexander Rose 6 年之前
父節點
當前提交
5a7a43553d

+ 8 - 3
src/mol-geo/representation/structure/visual/polymer-trace-mesh.ts

@@ -25,7 +25,7 @@ import { createMeshValues, updateMeshValues, updateRenderableState, createRender
 import { MeshBuilder } from '../../../shape/mesh-builder';
 import { MeshBuilder } from '../../../shape/mesh-builder';
 import { getPolymerElementCount, PolymerTraceIterator } from './util/polymer';
 import { getPolymerElementCount, PolymerTraceIterator } from './util/polymer';
 import { Vec3 } from 'mol-math/linear-algebra';
 import { Vec3 } from 'mol-math/linear-algebra';
-import { SecondaryStructureType } from 'mol-model/structure/model/types';
+import { SecondaryStructureType, MoleculeType } from 'mol-model/structure/model/types';
 // import { radToDeg } from 'mol-math/misc';
 // import { radToDeg } from 'mol-math/misc';
 
 
 const tmpNormal = Vec3.zero()
 const tmpNormal = Vec3.zero()
@@ -88,7 +88,6 @@ async function createPolymerTraceMesh(ctx: RuntimeContext, unit: Unit, mesh?: Me
     const builder = MeshBuilder.create(polymerElementCount * 30, polymerElementCount * 30 / 2, mesh)
     const builder = MeshBuilder.create(polymerElementCount * 30, polymerElementCount * 30 / 2, mesh)
     const linearSegments = 8
     const linearSegments = 8
     const radialSegments = 12
     const radialSegments = 12
-    const tension = 0.9
 
 
     const tanA = Vec3.zero()
     const tanA = Vec3.zero()
     const tanB = Vec3.zero()
     const tanB = Vec3.zero()
@@ -111,6 +110,10 @@ async function createPolymerTraceMesh(ctx: RuntimeContext, unit: Unit, mesh?: Me
         // builder.setId(elements[v.center.element])
         // builder.setId(elements[v.center.element])
         builder.setId(v.center.element)
         builder.setId(v.center.element)
 
 
+        const isNucleic = v.moleculeType === MoleculeType.DNA || v.moleculeType === MoleculeType.RNA
+        const isSheet = SecondaryStructureType.is(v.secStrucType, SecondaryStructureType.Flag.Beta)
+        const tension = (isNucleic || isSheet) ? 0.5 : 0.9
+
         for (let j = 0; j <= linearSegments; ++j) {
         for (let j = 0; j <= linearSegments; ++j) {
             const t = j * 1.0 / linearSegments;
             const t = j * 1.0 / linearSegments;
             // if ((v.last && t > 0.5) || (v.first && t < 0.5)) break
             // if ((v.last && t > 0.5) || (v.first && t < 0.5)) break
@@ -190,13 +193,15 @@ async function createPolymerTraceMesh(ctx: RuntimeContext, unit: Unit, mesh?: Me
         let width = 0.2, height = 0.2
         let width = 0.2, height = 0.2
 
 
         // TODO size theme
         // TODO size theme
-        if (SecondaryStructureType.is(v.secStrucType, SecondaryStructureType.Flag.Beta)) {
+        if (isSheet) {
             width = 0.15; height = 1.0
             width = 0.15; height = 1.0
             const arrowHeight = v.secStrucChange ? 1.7 : 0
             const arrowHeight = v.secStrucChange ? 1.7 : 0
             builder.addSheet(controlPoints, normalVectors, binormalVectors, linearSegments, width, height, arrowHeight, true, true)
             builder.addSheet(controlPoints, normalVectors, binormalVectors, linearSegments, width, height, arrowHeight, true, true)
         } else {
         } else {
             if (SecondaryStructureType.is(v.secStrucType, SecondaryStructureType.Flag.Helix)) {
             if (SecondaryStructureType.is(v.secStrucType, SecondaryStructureType.Flag.Helix)) {
                 width = 0.2; height = 1.0
                 width = 0.2; height = 1.0
+            } else if (isNucleic) {
+                width = 1.5; height = 0.3
             }
             }
             builder.addTube(controlPoints, normalVectors, binormalVectors, linearSegments, radialSegments, width, height, 1, true, true)
             builder.addTube(controlPoints, normalVectors, binormalVectors, linearSegments, radialSegments, width, height, 1, true, true)
         }
         }

+ 3 - 0
src/mol-geo/representation/structure/visual/util/polymer.ts

@@ -330,6 +330,7 @@ interface PolymerTraceElement {
     first: boolean, last: boolean
     first: boolean, last: boolean
     secStrucType: SecondaryStructureType
     secStrucType: SecondaryStructureType
     secStrucChange: boolean
     secStrucChange: boolean
+    moleculeType: MoleculeType
     t0: Vec3, t1: Vec3, t2: Vec3, t3: Vec3, t4: Vec3
     t0: Vec3, t1: Vec3, t2: Vec3, t3: Vec3, t4: Vec3
     d12: Vec3, d23: Vec3
     d12: Vec3, d23: Vec3
 }
 }
@@ -340,6 +341,7 @@ function createPolymerTraceElement (unit: Unit): PolymerTraceElement {
         first: false, last: false,
         first: false, last: false,
         secStrucType: SecondaryStructureType.create(SecondaryStructureType.Flag.NA),
         secStrucType: SecondaryStructureType.create(SecondaryStructureType.Flag.NA),
         secStrucChange: false,
         secStrucChange: false,
+        moleculeType: MoleculeType.unknown,
         t0: Vec3.zero(), t1: Vec3.zero(), t2: Vec3.zero(), t3: Vec3.zero(), t4: Vec3.zero(),
         t0: Vec3.zero(), t1: Vec3.zero(), t2: Vec3.zero(), t3: Vec3.zero(), t4: 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),
     }
     }
@@ -465,6 +467,7 @@ 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.secStrucChange = this.unit.model.properties.secondaryStructure.key[residueIndex] !== this.unit.model.properties.secondaryStructure.key[residueIndex + 1]
+            value.moleculeType = getMoleculeType(this.unit.model, residueIndex)
 
 
             if (!residueIt.hasNext) {
             if (!residueIt.hasNext) {
                 this.state = AtomicPolymerTraceIteratorState.nextPolymer
                 this.state = AtomicPolymerTraceIteratorState.nextPolymer

+ 2 - 1
src/mol-view/stage.ts

@@ -80,7 +80,8 @@ export class Stage {
         // this.loadPdbid('3pqr') // inter unit bonds, two polymer chains, ligands, water
         // this.loadPdbid('3pqr') // inter unit bonds, two polymer chains, ligands, water
         // this.loadPdbid('4v5a') // ribosome
         // this.loadPdbid('4v5a') // ribosome
         // this.loadPdbid('3j3q') // ...
         // this.loadPdbid('3j3q') // ...
-        this.loadPdbid('3sn6') // discontinuous chains
+        this.loadPdbid('2np2') // dna
+        // this.loadPdbid('3sn6') // discontinuous chains
         // this.loadMmcifUrl(`../../examples/1cbs_full.bcif`)
         // this.loadMmcifUrl(`../../examples/1cbs_full.bcif`)
         // this.loadMmcifUrl(`../../examples/1cbs_updated.cif`)
         // this.loadMmcifUrl(`../../examples/1cbs_updated.cif`)
         // this.loadMmcifUrl(`../../examples/1crn.cif`)
         // this.loadMmcifUrl(`../../examples/1crn.cif`)