Spaces:
Runtime error
Runtime error
igashov
commited on
Commit
·
a05c989
1
Parent(s):
05e91b8
vis
Browse files
app.py
CHANGED
@@ -85,7 +85,7 @@ def show_input(input_file):
|
|
85 |
except Exception as e:
|
86 |
return f'Could not read the molecule: {e}'
|
87 |
|
88 |
-
html = output.
|
89 |
return output.IFRAME_TEMPLATE.format(html=html)
|
90 |
|
91 |
|
@@ -148,8 +148,14 @@ def generate(input_file):
|
|
148 |
print('Converted to SDF')
|
149 |
break
|
150 |
|
151 |
-
|
152 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
return [
|
154 |
output.IFRAME_TEMPLATE.format(html=html),
|
155 |
[inp_sdf, inp_xyz, out_sdf, out_xyz],
|
|
|
85 |
except Exception as e:
|
86 |
return f'Could not read the molecule: {e}'
|
87 |
|
88 |
+
html = output.INITIAL_RENDERING_TEMPLATE.format(molecule=molecule, fmt=extension)
|
89 |
return output.IFRAME_TEMPLATE.format(html=html)
|
90 |
|
91 |
|
|
|
148 |
print('Converted to SDF')
|
149 |
break
|
150 |
|
151 |
+
input_fragments_content = read_molecule_content(inp_sdf)
|
152 |
+
generated_molecule_content = read_molecule_content(out_sdf)
|
153 |
+
html = output.SAMPLES_RENDERING_TEMPLATE.format(
|
154 |
+
fragments=input_fragments_content,
|
155 |
+
fragments_fmt='sdf',
|
156 |
+
molecule=generated_molecule_content,
|
157 |
+
molecule_fmt='sdf',
|
158 |
+
)
|
159 |
return [
|
160 |
output.IFRAME_TEMPLATE.format(html=html),
|
161 |
[inp_sdf, inp_xyz, out_sdf, out_xyz],
|
output.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
|
2 |
<html>
|
3 |
<head>
|
4 |
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
@@ -33,6 +33,55 @@ HTML_TEMPLATE = """<!DOCTYPE html>
|
|
33 |
"""
|
34 |
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
INVALID_FORMAT_MSG = """
|
37 |
<!DOCTYPE html>
|
38 |
<html>
|
@@ -58,7 +107,7 @@ INVALID_FORMAT_MSG = """
|
|
58 |
</html>
|
59 |
"""
|
60 |
|
61 |
-
|
62 |
<html>
|
63 |
<head>
|
64 |
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
|
|
1 |
+
INITIAL_RENDERING_TEMPLATE = """<!DOCTYPE html>
|
2 |
<html>
|
3 |
<head>
|
4 |
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
|
|
33 |
"""
|
34 |
|
35 |
|
36 |
+
SAMPLES_RENDERING_TEMPLATE = """<!DOCTYPE html>
|
37 |
+
<html>
|
38 |
+
<head>
|
39 |
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
40 |
+
<style>
|
41 |
+
.mol-container {{
|
42 |
+
width: 600px;
|
43 |
+
height: 600px;
|
44 |
+
position: relative;
|
45 |
+
}}
|
46 |
+
.mol-container select{{
|
47 |
+
background-image:None;
|
48 |
+
}}
|
49 |
+
</style>
|
50 |
+
<script src="https://3Dmol.csb.pitt.edu/build/3Dmol-min.js"></script>
|
51 |
+
</head>
|
52 |
+
|
53 |
+
<body>
|
54 |
+
<button id="fragments">Input Fragments</button>
|
55 |
+
<button id="molecule">Output Molecule</button>
|
56 |
+
<div id="container" class="mol-container"></div>
|
57 |
+
<script>
|
58 |
+
$(document).ready(function() {{
|
59 |
+
let element = $("#container");
|
60 |
+
let config = {{ backgroundColor: "white" }};
|
61 |
+
let viewer = $3Dmol.createViewer( element, config );
|
62 |
+
viewer.addModel(`{fragments}`, "{fragments_fmt}")
|
63 |
+
viewer.getModel().setStyle({{ stick: {{ colorscheme:"greenCarbon" }} }})
|
64 |
+
viewer.addModel(`{molecule}`, "{molecule_fmt}")
|
65 |
+
viewer.getModel().setStyle({{ stick: {{ colorscheme:"greenCarbon" }} }})
|
66 |
+
viewer.zoomTo();
|
67 |
+
viewer.render();
|
68 |
+
}});
|
69 |
+
$("#fragments").click(function() {{
|
70 |
+
viewer.getModel(0).show();
|
71 |
+
viewer.getModel(1).hide();
|
72 |
+
viewer.render();
|
73 |
+
}});
|
74 |
+
$("#molecule").click(function() {{
|
75 |
+
viewer.getModel(1).show();
|
76 |
+
viewer.getModel(0).hide();
|
77 |
+
viewer.render();
|
78 |
+
}});
|
79 |
+
</script>
|
80 |
+
</body>
|
81 |
+
</html>
|
82 |
+
"""
|
83 |
+
|
84 |
+
|
85 |
INVALID_FORMAT_MSG = """
|
86 |
<!DOCTYPE html>
|
87 |
<html>
|
|
|
107 |
</html>
|
108 |
"""
|
109 |
|
110 |
+
INITIAL_RENDERING_TEMPLATE = """<!DOCTYPE html>
|
111 |
<html>
|
112 |
<head>
|
113 |
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|