index.js 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. "use strict";
  2. var __assign = (this && this.__assign) || function () {
  3. __assign = Object.assign || function(t) {
  4. for (var s, i = 1, n = arguments.length; i < n; i++) {
  5. s = arguments[i];
  6. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  7. t[p] = s[p];
  8. }
  9. return t;
  10. };
  11. return __assign.apply(this, arguments);
  12. };
  13. var rowConfigChainA = [
  14. {
  15. trackId: "sequenceTrack",
  16. trackHeight: 20,
  17. trackColor: "#F9F9F9",
  18. displayType: "sequence" /* SEQUENCE */,
  19. nonEmptyDisplay: true,
  20. rowTitle: "CHAIN A",
  21. trackData: [
  22. {
  23. begin: 1,
  24. value: "CGVPAIQPVLSGLSRIVNGEEAVPGSWPWQVSLQDKTGFHFCGGSLINENWVVTAAHCGVTTSDVVVAGEFDQGSSSEKIQKLKIAKVFKNSKYNSLTINNDITLLKLSTAASFSQTVSAVCLPSASDDFAAGTTCVTTGWGLTRYTNANTPDRLQQASLPLLSNTNCKKYWGTKIKDAMICAGASGVSSCMGDSGGPLVCKKNGAWTLVGIVSWGSSTCSTSTPGVYARVTALVNWVQQTLAAN"
  25. }
  26. ]
  27. }, {
  28. trackId: "blockTrack",
  29. trackHeight: 20,
  30. trackColor: "#F9F9F9",
  31. displayType: "block" /* BLOCK */,
  32. displayColor: "#76ae91",
  33. rowTitle: "FEATURE",
  34. trackData: [{
  35. begin: 20,
  36. end: 25
  37. }, {
  38. begin: 150,
  39. end: 160
  40. }]
  41. }
  42. ];
  43. var rowConfigChainB = [
  44. {
  45. trackId: "sequenceTrack",
  46. trackHeight: 20,
  47. trackColor: "#F9F9F9",
  48. displayType: "sequence" /* SEQUENCE */,
  49. nonEmptyDisplay: true,
  50. rowTitle: "CHAIN B",
  51. trackData: [
  52. {
  53. begin: 1,
  54. value: "TEFGSELKSFPEVVGKTVDQAREYFTLHYPQYDVYFLPEGSPVTLDLRYNRVRVFYNPGTNVVNHVPHVG"
  55. }
  56. ]
  57. }, {
  58. trackId: "blockTrack",
  59. trackHeight: 20,
  60. trackColor: "#F9F9F9",
  61. displayType: "block" /* BLOCK */,
  62. displayColor: "#f17070",
  63. rowTitle: "FEATURE",
  64. trackData: [{
  65. begin: 20,
  66. end: 50
  67. }]
  68. }
  69. ];
  70. var fvConfigChainA = {
  71. boardId: "1acb.A_board",
  72. boardConfig: {
  73. range: {
  74. min: 1,
  75. max: 245
  76. },
  77. disableMenu:true,
  78. rowTitleWidth: 80,
  79. trackWidth: 670,
  80. includeAxis: true
  81. },
  82. rowConfig: rowConfigChainA,
  83. sequenceSelectionChangeCallback: function (plugin, selectorManager, sequenceRegion) {
  84. selectorManager.clearSelection("select", { modelId: "1acb_board", labelAsymId: "A" });
  85. plugin.clearSelection("select", { modelId: "1acb_board", labelAsymId: "A" });
  86. if (sequenceRegion.length > 0) {
  87. var regions = sequenceRegion.map(function (r) {
  88. var _a;
  89. return ({
  90. modelId: "1acb_board",
  91. labelAsymId: "A",
  92. region: { begin: r.begin, end: (_a = r.end) !== null && _a !== void 0 ? _a : r.begin, source: "sequence" }
  93. });
  94. });
  95. selectorManager.addSelectionFromMultipleRegions(regions, "select");
  96. plugin.select(regions.map(function (r) { return (__assign(__assign({}, r), { begin: r.region.begin, end: r.region.end })); }), "select", "add");
  97. }
  98. else {
  99. plugin.resetCamera();
  100. }
  101. },
  102. sequenceElementClickCallback: function (plugin, selectorManager, d) {
  103. var _a;
  104. if (d != null)
  105. plugin.cameraFocus("1acb_board", "A", d.begin, (_a = d.end) !== null && _a !== void 0 ? _a : d.begin);
  106. },
  107. sequenceHoverCallback: function (plugin, selectorManager, elements) {
  108. if (elements == null || elements.length == 0)
  109. plugin.clearSelection("hover");
  110. else
  111. plugin.select(elements.map(function (e) {
  112. var _a;
  113. return ({
  114. modelId: "1acb_board",
  115. labelAsymId: "A",
  116. begin: e.begin,
  117. end: (_a = e.end) !== null && _a !== void 0 ? _a : e.begin
  118. });
  119. }), "hover", "set");
  120. },
  121. structureSelectionCallback: function (plugin, pfv, selection) {
  122. var sel = selection.getSelectionWithCondition("1acb_board", "A", "select");
  123. if (sel == null) {
  124. pfv.clearSelection("select");
  125. plugin.resetCamera();
  126. }
  127. else {
  128. pfv.setSelection({ elements: sel.regions, mode: "select" });
  129. }
  130. },
  131. structureHoverCallback: function (plugin, pfv, selection) {
  132. var sel = selection.getSelectionWithCondition("1acb_board", "A", "hover");
  133. if (sel == null)
  134. pfv.clearSelection("hover");
  135. else
  136. pfv.setSelection({ elements: sel.regions, mode: "hover" });
  137. }
  138. };
  139. var fvConfigChainB = {
  140. boardId: "1acb.B_board",
  141. boardConfig: {
  142. range: {
  143. min: 1,
  144. max: 70
  145. },
  146. disableMenu:true,
  147. rowTitleWidth: 80,
  148. trackWidth: 670,
  149. includeAxis: true
  150. },
  151. rowConfig: rowConfigChainB,
  152. sequenceSelectionChangeCallback: function (plugin, selectorManager, sequenceRegion) {
  153. selectorManager.clearSelection("select", { modelId: "1acb_board", labelAsymId: "B" });
  154. plugin.clearSelection("select", { modelId: "1acb_board", labelAsymId: "B" });
  155. if (sequenceRegion.length > 0) {
  156. var regions = sequenceRegion.map(function (r) {
  157. var _a;
  158. return ({
  159. modelId: "1acb_board",
  160. labelAsymId: "B",
  161. region: { begin: r.begin, end: (_a = r.end) !== null && _a !== void 0 ? _a : r.begin, source: "sequence" }
  162. });
  163. });
  164. selectorManager.addSelectionFromMultipleRegions(regions, "select");
  165. plugin.select(regions.map(function (r) { return (__assign(__assign({}, r), { begin: r.region.begin, end: r.region.end })); }), "select", "add");
  166. }
  167. else {
  168. plugin.resetCamera();
  169. }
  170. },
  171. sequenceElementClickCallback: function (plugin, selectorManager, d) {
  172. var _a;
  173. if (d != null)
  174. plugin.cameraFocus("1acb_board", "B", d.begin, (_a = d.end) !== null && _a !== void 0 ? _a : d.begin);
  175. },
  176. sequenceHoverCallback: function (plugin, selectorManager, elements) {
  177. if (elements == null || elements.length == 0)
  178. plugin.clearSelection("hover");
  179. else
  180. plugin.select(elements.map(function (e) {
  181. var _a;
  182. return ({
  183. modelId: "1acb_board",
  184. labelAsymId: "B",
  185. begin: e.begin,
  186. end: (_a = e.end) !== null && _a !== void 0 ? _a : e.begin
  187. });
  188. }), "hover", "set");
  189. },
  190. structureSelectionCallback: function (plugin, pfv, selection) {
  191. var sel = selection.getSelectionWithCondition("1acb_board", "B", "select");
  192. if (sel == null) {
  193. pfv.clearSelection("select");
  194. plugin.resetCamera();
  195. }
  196. else {
  197. pfv.setSelection({ elements: sel.regions, mode: "select" });
  198. }
  199. },
  200. structureHoverCallback: function (plugin, pfv, selection) {
  201. var sel = selection.getSelectionWithCondition("1acb_board", "B", "hover");
  202. if (sel == null)
  203. pfv.clearSelection("hover");
  204. else
  205. pfv.setSelection({ elements: sel.regions, mode: "hover" });
  206. }
  207. };
  208. var blockChainA = {
  209. blockId: "chainA",
  210. featureViewConfig: [fvConfigChainA]
  211. };
  212. var blockChainB = {
  213. blockId: "chainB",
  214. featureViewConfig: [fvConfigChainB]
  215. };
  216. var blockSelectorElement = function (blockSelectorManager) {
  217. return (React.createElement("div", null,
  218. React.createElement("select", { onChange: function (e) {
  219. blockSelectorManager.setActiveBlock(e.target.value);
  220. } },
  221. React.createElement("option", { value: "chainA" }, "Chain A"),
  222. React.createElement("option", { value: "chainB" }, "Chain B"))));
  223. };
  224. var customConfig = {
  225. blockConfig: [blockChainA, blockChainB],
  226. blockSelectorElement: blockSelectorElement
  227. };
  228. var sequenceConfig = {
  229. title: undefined,
  230. subtitle: undefined,
  231. config: customConfig
  232. };
  233. var molstarConfig = {
  234. loadConfig: {
  235. loadMethod: "loadPdbIds",
  236. loadParams: [{
  237. pdbId: "1acb",
  238. id: "1acb_board"
  239. }]
  240. },
  241. pluginConfig: {
  242. showImportControls: true,
  243. showSessionControls: false
  244. },
  245. };
  246. document.addEventListener("DOMContentLoaded", function (event) {
  247. var panel3d = new RcsbFv3D.custom({
  248. elementId: "pfv",
  249. structurePanelConfig: molstarConfig,
  250. sequencePanelConfig: sequenceConfig,
  251. cssConfig: {
  252. overwriteCss:true,
  253. rootPanel:{
  254. display:"flex",
  255. flexDirection:"column-reverse"
  256. },
  257. structurePanel:{
  258. width: 750,
  259. height: 700
  260. },
  261. sequencePanel:{
  262. width:750,
  263. marginBottom:5
  264. }
  265. },
  266. });
  267. panel3d.render();
  268. });