index.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import {RcsbFv3DCustom} from "../../RcsbFv3D/RcsbFv3DCustom";
  2. import {RcsbFvStructureConfigInterface} from "../../RcsbFvStructure/RcsbFvStructure";
  3. import {
  4. CustomViewInterface,
  5. FeatureBlockInterface
  6. } from "../../RcsbFvSequence/SequenceViews/CustomView/CustomView";
  7. import {RcsbRepresentationPreset} from "./TrajectoryPreset";
  8. import {PluginStateObject} from "molstar/lib/mol-plugin-state/objects";
  9. import {fvConfig1, fvConfig2} from "./FeatureViewerConfig";
  10. import {
  11. LoadMethod,
  12. LoadMolstarInterface
  13. } from "../../RcsbFvStructure/StructureViewers/MolstarViewer/MolstarActionManager";
  14. import {ViewerProps} from "@rcsb/rcsb-molstar/build/src/viewer";
  15. const block: FeatureBlockInterface<LoadMolstarInterface> = {
  16. blockId:"MyBlock_1",
  17. featureViewConfig: [fvConfig1, fvConfig2]
  18. };
  19. const customConfig: CustomViewInterface<LoadMolstarInterface> = {
  20. blockConfig:[block]
  21. }
  22. const sequenceConfig = {
  23. title: "Single chain example",
  24. subtitle: "PDB entry with single chain",
  25. config: customConfig
  26. };
  27. const molstarConfig: RcsbFvStructureConfigInterface<LoadMolstarInterface,{viewerProps:Partial<ViewerProps>}> = {
  28. loadConfig: [{
  29. loadMethod: LoadMethod.loadPdbId,
  30. loadParams: {
  31. entryId: "1ash",
  32. reprProvider: RcsbRepresentationPreset,
  33. params: {
  34. id: "structure_1",
  35. modelMap: new Map<string,string>(),
  36. mapStructure: function (key: string, structure: PluginStateObject.Molecule.Structure): void{
  37. this.modelMap.set(key,structure.data.units[0].model.id);
  38. },
  39. getMap: function(): Map<string,string>{
  40. return this.modelMap;
  41. }
  42. }
  43. }
  44. },{
  45. loadMethod: LoadMethod.loadPdbId,
  46. loadParams: {
  47. entryId: "101m",
  48. reprProvider: RcsbRepresentationPreset,
  49. params: {
  50. id: "structure_2",
  51. modelMap: new Map<string,string>(),
  52. mapStructure: function (key: string, structure: PluginStateObject.Molecule.Structure): void{
  53. this.modelMap.set(key,structure.data.units[0].model.id);
  54. },
  55. getMap: function(): Map<string,string>{
  56. return this.modelMap;
  57. }
  58. }
  59. }
  60. }],
  61. structureViewerConfig: {
  62. viewerProps:{
  63. showImportControls: true,
  64. showSessionControls: false
  65. }
  66. }
  67. };
  68. document.addEventListener("DOMContentLoaded", function(event) {
  69. const panel3d = new RcsbFv3DCustom({
  70. elementId: "pfv",
  71. structurePanelConfig: molstarConfig,
  72. sequencePanelConfig: sequenceConfig,
  73. cssConfig:{
  74. structurePanel:{
  75. minWidth:800,
  76. minHeight:800
  77. },
  78. sequencePanel:{
  79. minWidth:800
  80. }
  81. }
  82. });
  83. panel3d.render();
  84. });