123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- import Viewer from './viewer'
- import { StateContext } from './state/context';
- import { Progress } from 'mol-task';
- import { MmcifUrlToModel, ModelToStructure, StructureToSpacefill, StructureToBallAndStick, StructureToDistanceRestraint, StructureToCartoon, StructureToBackbone, StructureCenter } from './state/transform';
- import { UrlEntity } from './state/entity';
- import { SpacefillProps } from 'mol-geo/representation/structure/spacefill';
- import { Context } from 'mol-app/context/context';
- import { BallAndStickProps } from 'mol-geo/representation/structure/ball-and-stick';
- import { CartoonProps } from 'mol-geo/representation/structure/cartoon';
- import { DistanceRestraintProps } from 'mol-geo/representation/structure/distance-restraint';
- import { BackboneProps } from 'mol-geo/representation/structure/backbone';
- const spacefillProps: SpacefillProps = {
- doubleSided: true,
- colorTheme: { name: 'chain-id' },
- quality: 'auto',
- useFog: false
- }
- const ballAndStickProps: BallAndStickProps = {
- doubleSided: true,
- colorTheme: { name: 'chain-id' },
- sizeTheme: { name: 'uniform', value: 0.05 },
- linkRadius: 0.05,
- quality: 'auto',
- useFog: false
- }
- const distanceRestraintProps: DistanceRestraintProps = {
- doubleSided: true,
- colorTheme: { name: 'chain-id' },
- linkRadius: 0.5,
- quality: 'auto',
- useFog: false
- }
- const backboneProps: BackboneProps = {
- doubleSided: true,
- colorTheme: { name: 'chain-id' },
-
- quality: 'auto',
- useFog: false,
- alpha: 0.5
- }
- const cartoonProps: CartoonProps = {
- doubleSided: true,
- colorTheme: { name: 'chain-id' },
-
- quality: 'auto',
- useFog: false
- }
- export class Stage {
- viewer: Viewer
- ctx = new StateContext(Progress.format)
- constructor(public globalContext: Context) {
- }
- initRenderer (canvas: HTMLCanvasElement, container: HTMLDivElement) {
- this.viewer = Viewer.create(canvas, container)
- this.viewer.animate()
- this.ctx.viewer = this.viewer
-
-
-
-
-
-
-
-
-
- this.loadPdbid('3sn6')
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- async loadMmcifUrl (url: string) {
- const urlEntity = UrlEntity.ofUrl(this.ctx, url)
- const modelEntity = await MmcifUrlToModel.apply(this.ctx, urlEntity)
- console.log(modelEntity.value)
- const structureEntity = await ModelToStructure.apply(this.ctx, modelEntity)
- StructureToBallAndStick.apply(this.ctx, structureEntity, { ...ballAndStickProps, visible: false })
- StructureToSpacefill.apply(this.ctx, structureEntity, { ...spacefillProps, visible: false })
- StructureToDistanceRestraint.apply(this.ctx, structureEntity, { ...distanceRestraintProps, visible: false })
- StructureToBackbone.apply(this.ctx, structureEntity, { ...backboneProps, visible: true })
- StructureToCartoon.apply(this.ctx, structureEntity, { ...cartoonProps, visible: true })
- StructureCenter.apply(this.ctx, structureEntity)
- this.globalContext.components.sequenceView.setState({ structure: structureEntity.value });
-
-
-
-
-
-
-
-
-
- }
- loadPdbid (pdbid: string) {
- return this.loadMmcifUrl(`http://www.ebi.ac.uk/pdbe/static/entry/${pdbid}_updated.cif`)
-
- }
- dispose () {
-
- }
- }
|