Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -284,7 +284,6 @@ def display_pdb(path_to_pdb):
|
|
284 |
allowpaymentrequest="" frameborder="0" srcdoc='{x}'></iframe>"""
|
285 |
'''
|
286 |
|
287 |
-
|
288 |
def get_motif_preview(pdb_id, contigs):
|
289 |
try:
|
290 |
input_pdb = fetch_pdb(pdb_id=pdb_id.lower() if pdb_id else None)
|
@@ -292,44 +291,39 @@ def get_motif_preview(pdb_id, contigs):
|
|
292 |
return gr.HTML("PDB ID를 입력해주세요"), None
|
293 |
|
294 |
parse = parse_pdb(input_pdb)
|
295 |
-
|
296 |
-
|
297 |
-
#output_name = './rewrite_'+input_pdb.split('/')[-1]
|
298 |
-
#writepdb(output_name, torch.tensor(parse_og['xyz']),torch.tensor(parse_og['seq']))
|
299 |
-
#parse = parse_pdb(output_name)
|
300 |
-
output_name = input_pdb
|
301 |
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
|
332 |
-
|
333 |
return gr.HTML(f"오류가 발생했습니다: {str(e)}"), None
|
334 |
|
335 |
def fetch_pdb(pdb_id=None):
|
|
|
284 |
allowpaymentrequest="" frameborder="0" srcdoc='{x}'></iframe>"""
|
285 |
'''
|
286 |
|
|
|
287 |
def get_motif_preview(pdb_id, contigs):
|
288 |
try:
|
289 |
input_pdb = fetch_pdb(pdb_id=pdb_id.lower() if pdb_id else None)
|
|
|
291 |
return gr.HTML("PDB ID를 입력해주세요"), None
|
292 |
|
293 |
parse = parse_pdb(input_pdb)
|
294 |
+
output_name = input_pdb
|
|
|
|
|
|
|
|
|
|
|
295 |
|
296 |
+
pdb = open(output_name, "r").read()
|
297 |
+
view = py3Dmol.view(width=500, height=500)
|
298 |
+
view.addModel(pdb, "pdb")
|
299 |
|
300 |
+
if contigs in ['',0]:
|
301 |
+
contigs = ['0']
|
302 |
+
else:
|
303 |
+
contigs = [contigs]
|
304 |
|
305 |
+
print('DEBUG: ',contigs)
|
306 |
+
|
307 |
+
pdb_map = get_mappings(ContigMap(parse,contigs))
|
308 |
+
print('DEBUG: ',pdb_map)
|
309 |
+
print('DEBUG: ',pdb_map['con_ref_idx0'])
|
310 |
+
roi = [x[1]-1 for x in pdb_map['con_ref_pdb_idx']]
|
311 |
+
|
312 |
+
colormap = {0:'#D3D3D3', 1:'#F74CFF'}
|
313 |
+
colors = {i+1: colormap[1] if i in roi else colormap[0] for i in range(parse['xyz'].shape[0])}
|
314 |
+
view.setStyle({"cartoon": {"colorscheme": {"prop": "resi", "map": colors}}})
|
315 |
+
view.zoomTo()
|
316 |
+
output = view._make_html().replace("'", '"')
|
317 |
+
print(view._make_html())
|
318 |
+
x = f"""<!DOCTYPE html><html></center> {output} </center></html>""" # do not use ' in this input
|
319 |
+
|
320 |
+
return f"""<iframe height="500px" width="100%" name="result" allow="midi; geolocation; microphone; camera;
|
321 |
+
display-capture; encrypted-media;" sandbox="allow-modals allow-forms
|
322 |
+
allow-scripts allow-same-origin allow-popups
|
323 |
+
allow-top-navigation-by-user-activation allow-downloads" allowfullscreen=""
|
324 |
+
allowpaymentrequest="" frameborder="0" srcdoc='{x}'></iframe>""", output_name
|
325 |
|
326 |
+
except Exception as e:
|
327 |
return gr.HTML(f"오류가 발생했습니다: {str(e)}"), None
|
328 |
|
329 |
def fetch_pdb(pdb_id=None):
|