|
@@ -12,6 +12,13 @@ import { AssemblySymmetry } from 'mol-model-props/rcsb/symmetry';
|
|
import { ShapeRepresentation, ShapeProps } from 'mol-geo/representation/shape';
|
|
import { ShapeRepresentation, ShapeProps } from 'mol-geo/representation/shape';
|
|
import { getAxesShape } from './assembly-symmetry';
|
|
import { getAxesShape } from './assembly-symmetry';
|
|
import Viewer from 'mol-view/viewer';
|
|
import Viewer from 'mol-view/viewer';
|
|
|
|
+import { CarbohydrateRepresentation } from 'mol-geo/representation/structure/representation/carbohydrate';
|
|
|
|
+import { MeshBuilder } from 'mol-geo/mesh/mesh-builder';
|
|
|
|
+import { addSphere } from 'mol-geo/mesh/builder/sphere';
|
|
|
|
+import { Shape } from 'mol-model/shape';
|
|
|
|
+import { Color } from 'mol-util/color';
|
|
|
|
+import { computeUnitBoundary } from 'mol-model/structure/structure/util/boundary';
|
|
|
|
+import { addBoundingBox } from 'mol-geo/mesh/builder/bounding-box';
|
|
|
|
|
|
export interface StructureView {
|
|
export interface StructureView {
|
|
readonly label: string
|
|
readonly label: string
|
|
@@ -21,7 +28,8 @@ export interface StructureView {
|
|
|
|
|
|
readonly cartoon: CartoonRepresentation
|
|
readonly cartoon: CartoonRepresentation
|
|
readonly ballAndStick: BallAndStickRepresentation
|
|
readonly ballAndStick: BallAndStickRepresentation
|
|
- readonly axes: ShapeRepresentation<ShapeProps>
|
|
|
|
|
|
+ readonly carbohydrate: CarbohydrateRepresentation
|
|
|
|
+ readonly symmetryAxes: ShapeRepresentation<ShapeProps>
|
|
|
|
|
|
readonly modelId: number
|
|
readonly modelId: number
|
|
readonly assemblyId: string
|
|
readonly assemblyId: string
|
|
@@ -45,7 +53,9 @@ interface StructureViewProps {
|
|
export async function StructureView(viewer: Viewer, models: ReadonlyArray<Model>, props: StructureViewProps = {}): Promise<StructureView> {
|
|
export async function StructureView(viewer: Viewer, models: ReadonlyArray<Model>, props: StructureViewProps = {}): Promise<StructureView> {
|
|
const cartoon = CartoonRepresentation()
|
|
const cartoon = CartoonRepresentation()
|
|
const ballAndStick = BallAndStickRepresentation()
|
|
const ballAndStick = BallAndStickRepresentation()
|
|
- const axes = ShapeRepresentation()
|
|
|
|
|
|
+ const carbohydrate = CarbohydrateRepresentation()
|
|
|
|
+ const symmetryAxes = ShapeRepresentation()
|
|
|
|
+ const polymerSphere = ShapeRepresentation()
|
|
|
|
|
|
let label: string
|
|
let label: string
|
|
let model: Model | undefined
|
|
let model: Model | undefined
|
|
@@ -156,14 +166,46 @@ export async function StructureView(viewer: Viewer, models: ReadonlyArray<Model>
|
|
useFog: false // TODO fog not working properly
|
|
useFog: false // TODO fog not working properly
|
|
}, structure).run()
|
|
}, structure).run()
|
|
|
|
|
|
|
|
+ await carbohydrate.createOrUpdate({
|
|
|
|
+ colorTheme: { name: 'carbohydrate-symbol' },
|
|
|
|
+ sizeTheme: { name: 'uniform', value: 1, factor: 1 },
|
|
|
|
+ useFog: false // TODO fog not working properly
|
|
|
|
+ }, structure).run()
|
|
|
|
+
|
|
viewer.center(structure.boundary.sphere.center)
|
|
viewer.center(structure.boundary.sphere.center)
|
|
|
|
+
|
|
|
|
+ const mb = MeshBuilder.create()
|
|
|
|
+ mb.setGroup(0)
|
|
|
|
+ addSphere(mb, structure.boundary.sphere.center, structure.boundary.sphere.radius, 3)
|
|
|
|
+ addBoundingBox(mb, structure.boundary.box, 1, 2, 8)
|
|
|
|
+ for (let i = 0, il = structure.units.length; i < il; ++i) {
|
|
|
|
+ mb.setGroup(1)
|
|
|
|
+ const u = structure.units[i]
|
|
|
|
+ const ci = u.model.atomicHierarchy.chainAtomSegments.index[u.elements[0]]
|
|
|
|
+ const ek = u.model.atomicHierarchy.getEntityKey(ci)
|
|
|
|
+ if (u.model.entities.data.type.value(ek) === 'water') continue
|
|
|
|
+ const boundary = computeUnitBoundary(u)
|
|
|
|
+ addSphere(mb, boundary.sphere.center, boundary.sphere.radius, 3)
|
|
|
|
+ addBoundingBox(mb, boundary.box, 0.5, 2, 8)
|
|
|
|
+ }
|
|
|
|
+ const shape = Shape.create('boundary', mb.getMesh(), [Color(0xCC6633), Color(0x3366CC)], ['sphere boundary'])
|
|
|
|
+ await polymerSphere.createOrUpdate({
|
|
|
|
+ alpha: 0.5,
|
|
|
|
+ doubleSided: false,
|
|
|
|
+ depthMask: false,
|
|
|
|
+ useFog: false // TODO fog not working properly
|
|
|
|
+ }, shape).run()
|
|
} else {
|
|
} else {
|
|
cartoon.destroy()
|
|
cartoon.destroy()
|
|
ballAndStick.destroy()
|
|
ballAndStick.destroy()
|
|
|
|
+ carbohydrate.destroy()
|
|
|
|
+ polymerSphere.destroy()
|
|
}
|
|
}
|
|
|
|
|
|
viewer.add(cartoon)
|
|
viewer.add(cartoon)
|
|
viewer.add(ballAndStick)
|
|
viewer.add(ballAndStick)
|
|
|
|
+ viewer.add(carbohydrate)
|
|
|
|
+ viewer.add(polymerSphere)
|
|
}
|
|
}
|
|
|
|
|
|
async function createSymmetryRepr() {
|
|
async function createSymmetryRepr() {
|
|
@@ -173,21 +215,21 @@ export async function StructureView(viewer: Viewer, models: ReadonlyArray<Model>
|
|
const axesShape = getAxesShape(symmetryFeatureId, assemblySymmetry)
|
|
const axesShape = getAxesShape(symmetryFeatureId, assemblySymmetry)
|
|
if (axesShape) {
|
|
if (axesShape) {
|
|
// getClusterColorTheme(symmetryFeatureId, assemblySymmetry)
|
|
// getClusterColorTheme(symmetryFeatureId, assemblySymmetry)
|
|
- await axes.createOrUpdate({
|
|
|
|
|
|
+ await symmetryAxes.createOrUpdate({
|
|
colorTheme: { name: 'shape-group' },
|
|
colorTheme: { name: 'shape-group' },
|
|
// colorTheme: { name: 'uniform', value: Color(0xFFCC22) },
|
|
// colorTheme: { name: 'uniform', value: Color(0xFFCC22) },
|
|
useFog: false // TODO fog not working properly
|
|
useFog: false // TODO fog not working properly
|
|
}, axesShape).run()
|
|
}, axesShape).run()
|
|
} else {
|
|
} else {
|
|
- axes.destroy()
|
|
|
|
|
|
+ symmetryAxes.destroy()
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- axes.destroy()
|
|
|
|
|
|
+ symmetryAxes.destroy()
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- axes.destroy()
|
|
|
|
|
|
+ symmetryAxes.destroy()
|
|
}
|
|
}
|
|
- viewer.add(axes)
|
|
|
|
|
|
+ viewer.add(symmetryAxes)
|
|
viewer.requestDraw()
|
|
viewer.requestDraw()
|
|
}
|
|
}
|
|
|
|
|
|
@@ -201,7 +243,8 @@ export async function StructureView(viewer: Viewer, models: ReadonlyArray<Model>
|
|
|
|
|
|
cartoon,
|
|
cartoon,
|
|
ballAndStick,
|
|
ballAndStick,
|
|
- axes,
|
|
|
|
|
|
+ carbohydrate,
|
|
|
|
+ symmetryAxes,
|
|
|
|
|
|
get modelId() { return modelId },
|
|
get modelId() { return modelId },
|
|
get assemblyId() { return assemblyId },
|
|
get assemblyId() { return assemblyId },
|
|
@@ -217,12 +260,13 @@ export async function StructureView(viewer: Viewer, models: ReadonlyArray<Model>
|
|
destroy: () => {
|
|
destroy: () => {
|
|
viewer.remove(cartoon)
|
|
viewer.remove(cartoon)
|
|
viewer.remove(ballAndStick)
|
|
viewer.remove(ballAndStick)
|
|
- viewer.remove(axes)
|
|
|
|
|
|
+ viewer.remove(carbohydrate)
|
|
|
|
+ viewer.remove(symmetryAxes)
|
|
viewer.requestDraw()
|
|
viewer.requestDraw()
|
|
|
|
|
|
cartoon.destroy()
|
|
cartoon.destroy()
|
|
ballAndStick.destroy()
|
|
ballAndStick.destroy()
|
|
- axes.destroy()
|
|
|
|
|
|
+ symmetryAxes.destroy()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|