index.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  6. <link rel="icon" href="./favicon.ico" type="image/x-icon">
  7. <title>Mol* Viewer</title>
  8. <style>
  9. * {
  10. margin: 0;
  11. padding: 0;
  12. box-sizing: border-box;
  13. }
  14. html, body {
  15. width: 100%;
  16. height: 100%;
  17. overflow: hidden;
  18. }
  19. hr {
  20. margin: 10px;
  21. }
  22. h1, h2, h3, h4, h5 {
  23. margin-top: 5px;
  24. margin-bottom: 3px;
  25. }
  26. button {
  27. padding: 2px;
  28. }
  29. #app {
  30. max-width: 100%;
  31. flex: 0 0 100%;
  32. position: relative;
  33. left: 2px;
  34. top: 2px;
  35. width: 800px;
  36. height: 600px;
  37. }
  38. #controls {
  39. position: absolute;
  40. top: 2px;
  41. left: 810px;
  42. z-index: 10;
  43. width: 15rem;
  44. font-family: sans-serif;
  45. font-size: smaller;
  46. }
  47. #controls > button {
  48. /*display: block;*/
  49. width: 100%;
  50. text-align: left;
  51. margin: 5px 0px;
  52. }
  53. #controls > input, #controls > select {
  54. width: 100%;
  55. display: block;
  56. }
  57. </style>
  58. <link rel="stylesheet" type="text/css" href="molstar.css" />
  59. </head>
  60. <body>
  61. <div id="app"></div>
  62. <div id="controls"></div>
  63. <script type="text/javascript" src="./tm_molstar.js"></script>
  64. <script type="text/javascript">
  65. // init viewer
  66. var viewer = new tm_molstar.Viewer('app', {
  67. layoutShowControls: false,
  68. layoutIsExpanded: false,
  69. viewportShowExpand: true,
  70. collapseLeftPanel: true
  71. });
  72. function load(pdbId) {
  73. viewer.plugin.clear();
  74. tm_molstar.loadWithUNITMPMembraneRepresentation(viewer.plugin, {
  75. structureUrl: `https://cs.litemol.org/${pdbId}/full`,
  76. regionDescriptorUrl: `http://localhost:8000/build/data/${pdbId}.json`,
  77. });
  78. }
  79. function $(id) { return document.getElementById(id); }
  80. function addControl(label, action) {
  81. var btn = document.createElement('button');
  82. btn.onclick = action;
  83. btn.innerText = label;
  84. $('controls').appendChild(btn);
  85. }
  86. let idList = [
  87. '1a0s', // TODO: wrong rotation
  88. '2atk', // PASSED
  89. '1afo', // TODO: something is wrong with the rotation
  90. '1xl4', // PASSED
  91. '1xl6', // PASSED
  92. '4x8a', // TODO: something is very wrong with membrane planes
  93. '6xvf', // TODO: something is very wrong with membrane planes
  94. ];
  95. idList.forEach((pdbId) => addControl(pdbId, () => load(pdbId)));
  96. addControl('Reset', () => {
  97. viewer.plugin.clear();
  98. tm_molstar.loadInitialSnapshot(viewer.plugin)
  99. });
  100. </script>
  101. </body>
  102. </html>