Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,6 +6,7 @@ import sys
|
|
| 6 |
HTML_TEMPLATE = '''<!DOCTYPE html>
|
| 7 |
<html>
|
| 8 |
<head>
|
|
|
|
| 9 |
</head>
|
| 10 |
<body>
|
| 11 |
<h1>Result:</h1>
|
|
@@ -14,6 +15,23 @@ HTML_TEMPLATE = '''<!DOCTYPE html>
|
|
| 14 |
</html>
|
| 15 |
'''
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
def generate(input_file):
|
| 19 |
try:
|
|
@@ -21,7 +39,8 @@ def generate(input_file):
|
|
| 21 |
except:
|
| 22 |
return HTML_TEMPLATE.format(content='Error: could not open the provided file')
|
| 23 |
|
| 24 |
-
|
|
|
|
| 25 |
|
| 26 |
|
| 27 |
demo = gr.Blocks()
|
|
@@ -31,8 +50,8 @@ with demo:
|
|
| 31 |
with gr.Row():
|
| 32 |
with gr.Column():
|
| 33 |
gr.Markdown('## Input Fragments')
|
| 34 |
-
gr.Markdown('Upload the file with 3D-coordinates of the input fragments in .mol or .sdf format')
|
| 35 |
-
input_file = gr.File(file_count='single', label='Input fragments in .mol2 or .sdf format')
|
| 36 |
|
| 37 |
button = gr.Button('Generate Linker!')
|
| 38 |
|
|
|
|
| 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>
|
|
|
|
| 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 |
+
|
| 35 |
|
| 36 |
def generate(input_file):
|
| 37 |
try:
|
|
|
|
| 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 |
|
| 46 |
demo = gr.Blocks()
|
|
|
|
| 50 |
with gr.Row():
|
| 51 |
with gr.Column():
|
| 52 |
gr.Markdown('## Input Fragments')
|
| 53 |
+
gr.Markdown('Upload the file with 3D-coordinates of the input fragments in .pdb, .mol or .sdf format')
|
| 54 |
+
input_file = gr.File(file_count='single', label='Input fragments in .pdb, .mol2 or .sdf format')
|
| 55 |
|
| 56 |
button = gr.Button('Generate Linker!')
|
| 57 |
|