lkjjj26 commited on
Commit
71958c3
ยท
1 Parent(s): 727ecf1
Files changed (1) hide show
  1. app.py +27 -24
app.py CHANGED
@@ -7,7 +7,7 @@ from shiny import App, render, ui, reactive
7
  import pandas as pd
8
  import warnings
9
  import re
10
- from UniprotKB_P_Sequence_RCSB_API_test import ProteinQuery, ProteinSearchEngine
11
  import plotly.graph_objects as go
12
  from shinywidgets import output_widget, render_widget
13
  import requests
@@ -395,7 +395,31 @@ class PDBSearchAssistant:
395
 
396
  if not pdb_path or not os.path.exists(pdb_path):
397
  print(f"Failed to download PDB file for {pdb_id}")
398
- return []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
399
 
400
  # Parse structure
401
  parser = PDB.PDBParser(QUIET=True)
@@ -488,27 +512,6 @@ class PDBSearchAssistant:
488
  print(f"Error processing query: {str(e)}")
489
  return {"type": "structure", "results": []}
490
 
491
- def pdbsummary(name):
492
-
493
- search_engine = ProteinSearchEngine()
494
-
495
- query = ProteinQuery(
496
- name,
497
- max_resolution= 5.0
498
- )
499
-
500
- results = search_engine.search(query)
501
-
502
- answer = ""
503
- for i, structure in enumerate(results, 1):
504
- answer += f"\n{i}. PDB ID : {structure.pdb_id}\n"
505
- answer += f"\nResolution : {structure.resolution:.2f} A \n"
506
- answer += f"Method : {structure.method}\n Title : {structure.title}\n"
507
- answer += f"Release Date : {structure.release_date}\n Sequence length: {len(structure.sequence)} aa\n"
508
- answer += f" Sequence:\n {structure.sequence}\n"
509
-
510
- return answer
511
-
512
  def render_html(pdb_id):
513
  if pdb_id is None:
514
  return ""
@@ -1012,7 +1015,7 @@ app_ui = ui.page_fluid(
1012
  ui.tags.ul(
1013
  ui.tags.li("Human hemoglobin C resolution better than 2.5ร…"),
1014
  ui.tags.li("Find structures containing sequence with similarity 90% MNIFEMLRIDEGLRLKIYKDTEGYYTIGIGHLLTKSPSLNAAKSELDKAIGRNTNGVITKDEAEKLFNQDVDAAVRGILRNAKLKPVYDSLDAVRRAALINMVFQMGETGVAGFTNSLRMLQQKRWDEAAVNLAKSRWYNQTPNRAKRVITTFRTGTWDAYKNL"),
1015
- ui.tags.li("Sequence of PDB ID 8ET6")
1016
  )
1017
  )
1018
  )
 
7
  import pandas as pd
8
  import warnings
9
  import re
10
+ from UniprotKB_P_Sequence_RCSB_API_test import ProteinSearchEngine
11
  import plotly.graph_objects as go
12
  from shinywidgets import output_widget, render_widget
13
  import requests
 
395
 
396
  if not pdb_path or not os.path.exists(pdb_path):
397
  print(f"Failed to download PDB file for {pdb_id}")
398
+
399
+ structure_url = f"https://data.rcsb.org/rest/v1/core/entry/{pdb_id}"
400
+ response = requests.get(structure_url)
401
+ structure_data = response.json() if response.status_code == 200 else {}
402
+
403
+
404
+ sequence_url = f"https://data.rcsb.org/rest/v1/core/polymer_entity/{pdb_id}/1"
405
+ seq_response = requests.get(sequence_url)
406
+ seq_data = seq_response.json() if response.status_code == 200 else {}
407
+ sequence = seq_data.get('entity_poly', {}).get('pdbx_seq_one_letter_code', 'N/A')
408
+
409
+ sequences = []
410
+
411
+ chain_info = {
412
+ 'chain_id': "A", # chain.id, ์ž„์˜ ์„ค์ • api 3๊ฐœ์จ์„œ ๊ฐ€์ ธ์˜ค๊ธฐ๋Š” ๊ฐ€๋Šฅ
413
+ 'entity_id': '1', # Default entity ID
414
+ 'description': structure_data.get('struct', {}).get('title', 'N/A'),
415
+ 'sequence': sequence,
416
+ 'length': len(sequence),
417
+ 'resolution': structure_data.get('rcsb_entry_info', {}).get('resolution_combined', [0.0])[0],
418
+ 'method': structure_data.get('exptl', [{}])[0].get('method', 'Unknown'),
419
+ 'release_date': structure_data.get('rcsb_accession_info', {}).get('initial_release_date', 'N/A')
420
+ }
421
+ sequences.append(chain_info)
422
+ return sequences
423
 
424
  # Parse structure
425
  parser = PDB.PDBParser(QUIET=True)
 
512
  print(f"Error processing query: {str(e)}")
513
  return {"type": "structure", "results": []}
514
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
515
  def render_html(pdb_id):
516
  if pdb_id is None:
517
  return ""
 
1015
  ui.tags.ul(
1016
  ui.tags.li("Human hemoglobin C resolution better than 2.5ร…"),
1017
  ui.tags.li("Find structures containing sequence with similarity 90% MNIFEMLRIDEGLRLKIYKDTEGYYTIGIGHLLTKSPSLNAAKSELDKAIGRNTNGVITKDEAEKLFNQDVDAAVRGILRNAKLKPVYDSLDAVRRAALINMVFQMGETGVAGFTNSLRMLQQKRWDEAAVNLAKSRWYNQTPNRAKRVITTFRTGTWDAYKNL"),
1018
+ ui.tags.li("Sequence of PDB ID 8ET6"),
1019
  )
1020
  )
1021
  )