simonduerr commited on
Commit
573ab4f
·
1 Parent(s): 8071a09

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -14
app.py CHANGED
@@ -27,8 +27,8 @@ def read_mol(molpath):
27
 
28
  def molecule(input_pdb):
29
 
30
- mol = read_mol(input_pdb)
31
-
32
  x ="""<!DOCTYPE html>
33
  <html lang="en">
34
  <head>
@@ -53,15 +53,14 @@ def molecule(input_pdb):
53
  }
54
  #myViewer{
55
  float:left;
56
- width:400px;
57
- height: 400px;
58
  position:relative;
59
  }
60
  </style>
61
  </head>
62
 
63
  <body>
64
- <h4>PDBe Mol* AlphaFold Demo</h4>
65
  <div class="viewerSection">
66
  <!-- Molstar container -->
67
  <div id="myViewer"></div>
@@ -75,8 +74,8 @@ def molecule(input_pdb):
75
  //Set options (Checkout available options list in the documentation)
76
  var options = {
77
  customData: {
78
- url: "https://alphafold.ebi.ac.uk/files/AF-O15552-F1-model_v1.cif",
79
- format: "cif"
80
  },
81
  alphafoldView: true,
82
  bgColor: {r:255, g:255, b:255},
@@ -101,13 +100,12 @@ def molecule(input_pdb):
101
  allowpaymentrequest="" frameborder="0" srcdoc='{x}'></iframe>"""
102
 
103
 
104
- def update(inp, file, request: gr.Request):
105
  pdb_path = get_pdb(inp, file)
106
- print("Request headers dictionary:", request.headers)
107
- print("IP address:", request.client.host)
108
- return molecule(pdb_path)
109
-
110
 
 
111
  demo = gr.Blocks()
112
 
113
  with demo:
@@ -123,5 +121,5 @@ with demo:
123
  gr.Examples(["2CBA", "6VXX"], inp)
124
  btn = gr.Button("View structure")
125
  mol = gr.HTML()
126
- btn.click(fn=update, inputs=[inp, file], outputs=mol)
127
- demo.launch()
 
27
 
28
  def molecule(input_pdb):
29
 
30
+ print(input_pdb)
31
+ print(public_link+'/file='+os.path.basename(input_pdb))
32
  x ="""<!DOCTYPE html>
33
  <html lang="en">
34
  <head>
 
53
  }
54
  #myViewer{
55
  float:left;
56
+ width:100%;
57
+ height: 600px;
58
  position:relative;
59
  }
60
  </style>
61
  </head>
62
 
63
  <body>
 
64
  <div class="viewerSection">
65
  <!-- Molstar container -->
66
  <div id="myViewer"></div>
 
74
  //Set options (Checkout available options list in the documentation)
75
  var options = {
76
  customData: {
77
+ url: "{public_link+'/file='+os.path.basename(input_pdb)}",
78
+ format: "pdb"
79
  },
80
  alphafoldView: true,
81
  bgColor: {r:255, g:255, b:255},
 
100
  allowpaymentrequest="" frameborder="0" srcdoc='{x}'></iframe>"""
101
 
102
 
103
+ def update(inp, file, public_link):
104
  pdb_path = get_pdb(inp, file)
105
+ print("public link", public_link)
106
+ return molecule(pdb_path, public_link)
 
 
107
 
108
+ public_link = ""
109
  demo = gr.Blocks()
110
 
111
  with demo:
 
121
  gr.Examples(["2CBA", "6VXX"], inp)
122
  btn = gr.Button("View structure")
123
  mol = gr.HTML()
124
+ btn.click(fn=update, inputs=[inp, file, public_link], outputs=mol)
125
+ _, _, public_link = demo.launch()