stage.ts 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /**
  2. * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. */
  6. import Viewer from './viewer'
  7. import { StateContext } from './state/context';
  8. import { Progress } from 'mol-task';
  9. import { MmcifUrlToModel, ModelToStructure, StructureToSpacefill, StructureToBallAndStick, StructureToDistanceRestraint, StructureToCartoon, StructureToBackbone, StructureCenter, StructureToCarbohydrate } from './state/transform';
  10. import { UrlEntity } from './state/entity';
  11. import { SpacefillProps } from 'mol-geo/representation/structure/representation/spacefill';
  12. import { Context } from 'mol-app/context/context';
  13. import { BallAndStickProps } from 'mol-geo/representation/structure/representation/ball-and-stick';
  14. import { CartoonProps } from 'mol-geo/representation/structure/representation/cartoon';
  15. import { DistanceRestraintProps } from 'mol-geo/representation/structure/representation/distance-restraint';
  16. import { BackboneProps } from 'mol-geo/representation/structure/representation/backbone';
  17. // import { Queries as Q, StructureProperties as SP, Query, Selection } from 'mol-model/structure';
  18. const spacefillProps: SpacefillProps = {
  19. doubleSided: true,
  20. colorTheme: { name: 'chain-id' },
  21. quality: 'auto',
  22. useFog: false
  23. }
  24. const ballAndStickProps: BallAndStickProps = {
  25. doubleSided: true,
  26. colorTheme: { name: 'chain-id' },
  27. sizeTheme: { name: 'uniform', value: 0.15 },
  28. linkRadius: 0.15,
  29. quality: 'auto',
  30. useFog: false
  31. }
  32. const distanceRestraintProps: DistanceRestraintProps = {
  33. doubleSided: true,
  34. colorTheme: { name: 'chain-id' },
  35. linkRadius: 0.5,
  36. quality: 'auto',
  37. useFog: false
  38. }
  39. const backboneProps: BackboneProps = {
  40. doubleSided: true,
  41. colorTheme: { name: 'chain-id' },
  42. // colorTheme: { name: 'uniform', value: 0xFF0000 },
  43. quality: 'auto',
  44. useFog: false,
  45. alpha: 0.5
  46. }
  47. const cartoonProps: CartoonProps = {
  48. doubleSided: true,
  49. colorTheme: { name: 'chain-id' },
  50. // colorTheme: { name: 'uniform', value: 0x2200CC },
  51. quality: 'auto',
  52. useFog: false
  53. }
  54. const carbohydrateProps: CartoonProps = {
  55. doubleSided: true,
  56. colorTheme: { name: 'carbohydrate-symbol' },
  57. // colorTheme: { name: 'uniform', value: 0x2200CC },
  58. quality: 'auto',
  59. useFog: false
  60. }
  61. export class Stage {
  62. viewer: Viewer
  63. ctx = new StateContext(Progress.format)
  64. constructor(public globalContext: Context) {
  65. }
  66. initRenderer (canvas: HTMLCanvasElement, container: HTMLDivElement) {
  67. this.viewer = Viewer.create(canvas, container)
  68. this.viewer.animate()
  69. this.ctx.viewer = this.viewer
  70. // this.loadPdbid('1jj2')
  71. // this.loadPdbid('1grm') // helix-like sheets
  72. // this.loadPdbid('4umt') // ligand has bond with order 3
  73. // this.loadPdbid('1crn') // small
  74. // this.loadPdbid('1hrv') // viral assembly
  75. // this.loadPdbid('1rb8') // virus
  76. // this.loadPdbid('1blu') // metal coordination
  77. // this.loadPdbid('3pqr') // inter unit bonds, two polymer chains, ligands, water, carbohydrates linked to protein
  78. // this.loadPdbid('4v5a') // ribosome
  79. // this.loadPdbid('3j3q') // ...
  80. // this.loadPdbid('2np2') // dna
  81. // this.loadPdbid('1d66') // dna
  82. // this.loadPdbid('9dna') // A form dna
  83. // this.loadPdbid('1bna') // B form dna
  84. // this.loadPdbid('199d') // C form dna
  85. // this.loadPdbid('4lb6') // Z form dna
  86. // this.loadPdbid('1egk') // 4-way dna-rna junction
  87. // this.loadPdbid('1y26') // rna
  88. // this.loadPdbid('1xv6') // rna, modified nucleotides
  89. // this.loadPdbid('3bbm') // rna with linker
  90. // this.loadPdbid('1euq') // t-rna
  91. // this.loadPdbid('2e2i') // rna, dna, protein
  92. // this.loadPdbid('1gfl') // GFP, flourophore has carbonyl oxygen removed
  93. // this.loadPdbid('1sfi') // contains cyclic peptid
  94. // this.loadPdbid('3sn6') // discontinuous chains
  95. // this.loadPdbid('2zex') // contains carbohydrate polymer
  96. // this.loadPdbid('3sgj') // contains carbohydrate polymer
  97. // this.loadPdbid('3ina') // contains GlcN and IdoA
  98. // this.loadPdbid('1umz') // contains Xyl (Xyloglucan)
  99. // this.loadPdbid('1mfb') // contains Abe
  100. // this.loadPdbid('2gdu') // contains sucrose
  101. // this.loadPdbid('2fnc') // contains maltotriose
  102. // this.loadPdbid('4zs9') // contains raffinose
  103. // this.loadPdbid('2yft') // contains kestose
  104. // this.loadPdbid('2b5t') // contains large carbohydrate polymer
  105. this.loadPdbid('1b5f') // contains carbohydrate with alternate locations
  106. // this.loadMmcifUrl(`../../examples/1cbs_full.bcif`)
  107. // this.loadMmcifUrl(`../../examples/1cbs_updated.cif`)
  108. // this.loadMmcifUrl(`../../examples/1crn.cif`)
  109. // this.loadPdbid('5u0q') // mixed dna/rna in same polymer
  110. // this.loadPdbid('5u0q') // temp
  111. // this.loadMmcifUrl(`../../../test/pdb-dev/PDBDEV_00000001.cif`) // ok
  112. // this.loadMmcifUrl(`../../../test/pdb-dev/PDBDEV_00000002.cif`) // ok
  113. // this.loadMmcifUrl(`../../../test/pdb-dev/PDBDEV_00000003.cif`) // ok
  114. // this.loadMmcifUrl(`../../../test/pdb-dev/PDBDEV_00000004.cif`) // TODO issue with cross-link extraction
  115. // this.loadMmcifUrl(`../../../test/pdb-dev/PDBDEV_00000005.cif`) // ok
  116. // this.loadMmcifUrl(`../../../test/pdb-dev/PDBDEV_00000006.cif`) // TODO only three spacefill atoms rendered
  117. // this.loadMmcifUrl(`../../../test/pdb-dev/PDBDEV_00000007.cif`) // TODO only three spacefill atoms rendered
  118. // this.loadMmcifUrl(`../../../test/pdb-dev/PDBDEV_00000008.cif`) // ok
  119. // this.loadMmcifUrl(`../../../test/pdb-dev/PDBDEV_00000010.cif`) // ok
  120. // this.loadMmcifUrl(`../../../test/pdb-dev/PDBDEV_00000011.cif`) // ok
  121. // this.loadMmcifUrl(`../../../test/pdb-dev/PDBDEV_00000012.cif`) // ok
  122. // this.loadMmcifUrl(`../../../test/pdb-dev/PDBDEV_00000014.cif`) // ok
  123. // this.loadMmcifUrl(`../../../test/pdb-dev/PDBDEV_00000016.cif`) // TODO only three spacefill atoms rendered
  124. }
  125. async loadMmcifUrl (url: string) {
  126. const urlEntity = UrlEntity.ofUrl(this.ctx, url)
  127. const modelEntity = await MmcifUrlToModel.apply(this.ctx, urlEntity)
  128. console.log(modelEntity.value)
  129. const structureEntity = await ModelToStructure.apply(this.ctx, modelEntity)
  130. StructureToBallAndStick.apply(this.ctx, structureEntity, { ...ballAndStickProps, visible: true })
  131. StructureToSpacefill.apply(this.ctx, structureEntity, { ...spacefillProps, visible: false })
  132. StructureToDistanceRestraint.apply(this.ctx, structureEntity, { ...distanceRestraintProps, visible: false })
  133. StructureToBackbone.apply(this.ctx, structureEntity, { ...backboneProps, visible: false })
  134. StructureToCartoon.apply(this.ctx, structureEntity, { ...cartoonProps, visible: true })
  135. StructureToCarbohydrate.apply(this.ctx, structureEntity, { ...carbohydrateProps, visible: true })
  136. StructureCenter.apply(this.ctx, structureEntity)
  137. this.globalContext.components.sequenceView.setState({ structure: structureEntity.value });
  138. // const structureEntity2 = await ModelToStructure.apply(this.ctx, modelEntity)
  139. // const q1 = Q.generators.atoms({
  140. // residueTest: l => SP.residue.label_seq_id(l) < 7
  141. // });
  142. // structureEntity2.value = Selection.unionStructure(await Query(q1)(structureEntity2.value).run());
  143. // await StructureToBackbone.apply(this.ctx, structureEntity2, { ...backboneProps, visible: true })
  144. // await StructureToCartoon.apply(this.ctx, structureEntity2, { ...cartoonProps, visible: true })
  145. // await StructureToBallAndStick.apply(this.ctx, structureEntity2, { ...ballAndStickProps, visible: false })
  146. // StructureCenter.apply(this.ctx, structureEntity2)
  147. }
  148. loadPdbid (pdbid: string) {
  149. // return this.loadMmcifUrl(`http://www.ebi.ac.uk/pdbe/static/entry/${pdbid}_updated.cif`)
  150. return this.loadMmcifUrl(`https://files.rcsb.org/download/${pdbid}.cif`)
  151. }
  152. dispose () {
  153. // TODO
  154. }
  155. }