FeatureViewerConfig.ts 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. import {FeatureViewInterface} from "../../RcsbFvSequence/SequenceViews/CustomView/CustomView";
  2. import {StructureViewerPublicInterface, SaguaroRegionList} from "../../RcsbFvStructure/StructureViewerInterface";
  3. import {RegionSelectionInterface} from "../../RcsbFvState/RcsbFvSelectorManager";
  4. import {RcsbFvRowConfigInterface} from "@rcsb/rcsb-saguaro/lib/RcsbFv/RcsbFvConfig/RcsbFvConfigInterface";
  5. import {RcsbFvDisplayTypes} from "@rcsb/rcsb-saguaro/lib/RcsbFv/RcsbFvConfig/RcsbFvDefaultConfigValues";
  6. import {RcsbFvTrackDataElementInterface} from "@rcsb/rcsb-saguaro/lib/RcsbDataManager/RcsbDataManager";
  7. import {RcsbFv} from "@rcsb/rcsb-saguaro/lib/RcsbFv/RcsbFv";
  8. import {RcsbFvStateInterface} from "../../RcsbFvState/RcsbFvStateInterface";
  9. const rowConfig: Array<RcsbFvRowConfigInterface> = [{
  10. trackId: "sequenceTrack",
  11. trackHeight: 20,
  12. trackColor: "#F9F9F9",
  13. displayType: RcsbFvDisplayTypes.SEQUENCE,
  14. nonEmptyDisplay: true,
  15. rowTitle: "1ASH SEQUENCE",
  16. trackData: [{
  17. begin: 1,
  18. label: "ANKTRELCMKSLEHAKVDTSNEARQDGIDLYKHMFENYPPLRKYFKSREEYTAEDVQNDPFFAKQGQKILLACHVLCATYDDRETFNAYTRELLDRHARDHVHMPPEVWTDFWKLFEEYLGKKTTLDEPTKQAWHEIGREFAKEINKHGR"
  19. }]
  20. },{
  21. trackId: "blockTrack",
  22. trackHeight: 20,
  23. trackColor: "#F9F9F9",
  24. displayType: RcsbFvDisplayTypes.BLOCK,
  25. displayColor: "#FF0000",
  26. rowTitle: "1ASH",
  27. trackData: [{
  28. begin: 30,
  29. end: 60
  30. }]
  31. }];
  32. export const fvConfig1: FeatureViewInterface<any, any> = {
  33. boardId:"1ash_board",
  34. boardConfig: {
  35. range: {
  36. min: 1,
  37. max: 150
  38. },
  39. rowTitleWidth: 190,
  40. includeAxis: true
  41. },
  42. rowConfig: rowConfig,
  43. sequenceSelectionChangeCallback: (plugin: StructureViewerPublicInterface<any, any>, stateManager: RcsbFvStateInterface, sequenceRegion: Array<RcsbFvTrackDataElementInterface>) => {
  44. stateManager.selectionState.clearSelection("select", {modelId:"structure_1", labelAsymId:"A"});
  45. if(sequenceRegion.length > 0) {
  46. const regions = sequenceRegion.map(r => ({
  47. modelId: "structure_1",
  48. labelAsymId: "A",
  49. region: {begin: r.begin, end: r.end ?? r.begin, source: "sequence"} as RegionSelectionInterface
  50. }));
  51. stateManager.selectionState.addSelectionFromMultipleRegions(regions, "select");
  52. plugin.select(regions.map(r => ({
  53. ...r,
  54. begin: r.region.begin,
  55. end: r.region.end
  56. })), "select", "set");
  57. }else{
  58. plugin.clearSelection("select", {modelId: "structure_1", labelAsymId: "A"})
  59. plugin.resetCamera();
  60. }
  61. },
  62. sequenceElementClickCallback: (plugin: StructureViewerPublicInterface<any, any>, stateManager: RcsbFvStateInterface, d?: RcsbFvTrackDataElementInterface) => {
  63. if(d!=null)
  64. plugin.cameraFocus("structure_1", "A", d.begin, d.end ?? d.begin);
  65. },
  66. sequenceHoverCallback: (plugin: StructureViewerPublicInterface<any, any>, stateManager: RcsbFvStateInterface, elements: Array<RcsbFvTrackDataElementInterface>) => {
  67. if(elements == null || elements.length == 0)
  68. plugin.clearSelection("hover");
  69. else
  70. plugin.select(elements.map(e=>({
  71. modelId: "structure_1",
  72. labelAsymId: "A",
  73. begin: e.begin,
  74. end: e.end ?? e.begin
  75. })), "hover", "set");
  76. },
  77. structureSelectionCallback: (plugin: StructureViewerPublicInterface<any, any>, pfv: RcsbFv, stateManager: RcsbFvStateInterface) => {
  78. const sel: SaguaroRegionList | undefined = stateManager.selectionState.getSelectionWithCondition("structure_1", "A", "select");
  79. if(sel == null) {
  80. pfv.clearSelection("select");
  81. plugin.resetCamera();
  82. }else {
  83. pfv.setSelection({elements: sel.regions, mode: "select"});
  84. }
  85. },
  86. structureHoverCallback: (plugin: StructureViewerPublicInterface<any, any>, pfv: RcsbFv, stateManager: RcsbFvStateInterface) => {
  87. const sel: SaguaroRegionList | undefined = stateManager.selectionState.getSelectionWithCondition("structure_1", "A", "hover");
  88. if(sel == null)
  89. pfv.clearSelection("hover");
  90. else
  91. pfv.setSelection({elements:sel.regions, mode:"hover"});
  92. }
  93. }
  94. export const fvConfig2: FeatureViewInterface<any, any> = {
  95. boardId:"1ash_board_bis",
  96. boardConfig: {
  97. range: {
  98. min: 1,
  99. max: 150
  100. },
  101. rowTitleWidth: 190,
  102. includeAxis: true
  103. },
  104. rowConfig: rowConfig,
  105. sequenceSelectionChangeCallback: (plugin: StructureViewerPublicInterface<any, any>, stateManager: RcsbFvStateInterface, sequenceRegion: Array<RcsbFvTrackDataElementInterface>) => {
  106. stateManager.selectionState.clearSelection("select", {modelId:"structure_2", labelAsymId:"A"});
  107. if(sequenceRegion.length > 0) {
  108. const regions = sequenceRegion.map(r => ({
  109. modelId: "structure_2",
  110. labelAsymId: "A",
  111. region: {begin: r.begin, end: r.end ?? r.begin, source: "sequence"} as RegionSelectionInterface
  112. }));
  113. stateManager.selectionState.addSelectionFromMultipleRegions(regions, "select");
  114. plugin.select(regions.map(r => ({
  115. ...r,
  116. begin: r.region.begin,
  117. end: r.region.end
  118. })), "select", "set");
  119. }else{
  120. plugin.clearSelection("select", {modelId: "structure_2", labelAsymId: "A"})
  121. plugin.resetCamera();
  122. }
  123. },
  124. sequenceElementClickCallback: (plugin: StructureViewerPublicInterface<any, any>, stateManager: RcsbFvStateInterface, d?: RcsbFvTrackDataElementInterface) => {
  125. if(d!=null)
  126. plugin.cameraFocus("structure_2", "A", d.begin, d.end ?? d.begin);
  127. },
  128. sequenceHoverCallback: (plugin: StructureViewerPublicInterface<any, any>, stateManager: RcsbFvStateInterface, elements: Array<RcsbFvTrackDataElementInterface>) => {
  129. if(elements == null || elements.length == 0)
  130. plugin.clearSelection("hover");
  131. else
  132. plugin.select(elements.map(e=>({
  133. modelId: "structure_2",
  134. labelAsymId: "A",
  135. begin: e.begin,
  136. end: e.end ?? e.begin
  137. })), "hover", "set");
  138. },
  139. structureSelectionCallback: (plugin: StructureViewerPublicInterface<any, any>, pfv: RcsbFv, stateManager: RcsbFvStateInterface) => {
  140. const sel: SaguaroRegionList | undefined = stateManager.selectionState.getSelectionWithCondition("structure_2", "A", "select");
  141. if(sel == null) {
  142. pfv.clearSelection("select");
  143. plugin.resetCamera();
  144. }else {
  145. pfv.setSelection({elements: sel.regions, mode: "select"});
  146. }
  147. },
  148. structureHoverCallback: (plugin: StructureViewerPublicInterface<any, any>, pfv: RcsbFv, stateManager: RcsbFvStateInterface) => {
  149. const sel: SaguaroRegionList | undefined = stateManager.selectionState.getSelectionWithCondition("structure_2", "A", "hover");
  150. if(sel == null)
  151. pfv.clearSelection("hover");
  152. else
  153. pfv.setSelection({elements:sel.regions, mode:"hover"});
  154. }
  155. }