igashov commited on
Commit
1ac1b9b
·
1 Parent(s): 4e2bd93

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -13
app.py CHANGED
@@ -5,30 +5,38 @@ import sys
5
 
6
  HTML_TEMPLATE = '''<!DOCTYPE html>
7
  <html>
 
8
  <head>
9
- <script src="https://3Dmol.csb.pitt.edu/build/3Dmol-min.js"></script>
 
 
 
 
 
 
 
10
  </head>
 
11
  <body>
12
  <h1>Result:</h1>
13
  {content}
14
  </body>
 
15
  </html>
16
  '''
17
 
18
  VIS_TEMPLATE = '''
19
  <div id="container" class="mol-container"></div>
20
  <script>
21
- let ligand = "{path}"
22
- let viewer = null;
23
-
24
- $(document).ready(function () {{
25
- let element = $("#container");
26
- let config = {{ backgroundColor: "white" }};
27
- viewer = $3Dmol.createViewer(element, config);
28
- viewer.addModel( ligand, "Molecule" )
29
- viewer.getModel(1).setStyle({{stick:{{colorscheme:"magentaCarbon"}}}});
30
- viewer.render();
31
- })
32
  </script>
33
  '''
34
 
@@ -39,7 +47,7 @@ def generate(input_file):
39
  except:
40
  return HTML_TEMPLATE.format(content='Error: could not open the provided file')
41
 
42
- content = VIS_TEMPLATE.format(path=path)
43
  return HTML_TEMPLATE.format(content=content)
44
 
45
 
 
5
 
6
  HTML_TEMPLATE = '''<!DOCTYPE html>
7
  <html>
8
+
9
  <head>
10
+ <style>
11
+ .mol-container {
12
+ width: 60%;
13
+ height: 400px;
14
+ position: relative;
15
+ }
16
+ </style>
17
+ <script src="http://3Dmol.csb.pitt.edu/build/3Dmol-min.js""></script>
18
  </head>
19
+
20
  <body>
21
  <h1>Result:</h1>
22
  {content}
23
  </body>
24
+
25
  </html>
26
  '''
27
 
28
  VIS_TEMPLATE = '''
29
  <div id="container" class="mol-container"></div>
30
  <script>
31
+ $(function() {
32
+ let element = $('#container');
33
+ let config = { backgroundColor: 'orange' };
34
+ let viewer = $3Dmol.createViewer( element, config );
35
+ viewer.addSphere({ center: {x:0, y:0, z:0}, radius: 10.0, color: 'green' });
36
+ viewer.zoomTo();
37
+ viewer.render();
38
+ viewer.zoom(0.8, 2000);
39
+ });
 
 
40
  </script>
41
  '''
42
 
 
47
  except:
48
  return HTML_TEMPLATE.format(content='Error: could not open the provided file')
49
 
50
+ content = VIS_TEMPLATE
51
  return HTML_TEMPLATE.format(content=content)
52
 
53