jfaustin commited on
Commit
86d28da
·
1 Parent(s): a5b0df3

refact: remove useless stuff

Browse files
Files changed (3) hide show
  1. Dockerfile +1 -0
  2. app.py +5 -3
  3. molecule.py +1 -24
Dockerfile CHANGED
@@ -26,6 +26,7 @@ RUN cd /app/folding-studio && uv pip install -e .
26
 
27
  COPY app.py /app/app.py
28
  COPY molecule.py /app/molecule.py
 
29
 
30
  EXPOSE 7860
31
  ENV GRADIO_SERVER_NAME="0.0.0.0"
 
26
 
27
  COPY app.py /app/app.py
28
  COPY molecule.py /app/molecule.py
29
+ # COPY pred.cif /app/boltz_results/pred_model_0.cif
30
 
31
  EXPOSE 7860
32
  ENV GRADIO_SERVER_NAME="0.0.0.0"
app.py CHANGED
@@ -66,14 +66,17 @@ def predict(sequence: str) -> str:
66
  )
67
  logger.info("Prediction done. Output directory: %s", output_dir)
68
 
 
 
69
  # Convert output CIF to PDB
70
  pred_cif = list(output_dir.rglob("*_model_0.cif"))[0]
71
  logger.info("Output file: %s", pred_cif)
72
 
73
- converted_pdb_path = output_dir / "pred.pdb"
74
  convert_cif_to_pdb(str(pred_cif), str(converted_pdb_path))
75
  logger.info("Converted PDB file: %s", converted_pdb_path)
76
 
 
77
  # Generate molecular visualization
78
  mol = _create_molecule_visualization(
79
  converted_pdb_path,
@@ -93,7 +96,6 @@ def _write_fasta_file(filepath: Path, sequence: str) -> None:
93
  def _create_molecule_visualization(pdb_path: Path, sequence: str, output_dir: Path) -> str:
94
  """Create molecular visualization using molecule module."""
95
  return molecule(
96
- str(pdb_path),
97
  str(pdb_path),
98
  lenSeqs=1,
99
  num_res=len(sequence),
@@ -106,7 +108,6 @@ def _create_molecule_visualization(pdb_path: Path, sequence: str, output_dir: Pa
106
  "Mean pLDDT": 0,
107
  "seq": sequence
108
  }],
109
- random_dir=output_dir
110
  )
111
 
112
 
@@ -114,6 +115,7 @@ def _wrap_in_iframe(content: str) -> str:
114
  """Wrap content in an HTML iframe with appropriate styling and permissions."""
115
  return f"""<iframe
116
  name="result"
 
117
  allow="midi; geolocation; microphone; camera; display-capture; encrypted-media;"
118
  sandbox="allow-modals allow-forms allow-scripts allow-same-origin allow-popups allow-top-navigation-by-user-activation allow-downloads"
119
  allowfullscreen=""
 
66
  )
67
  logger.info("Prediction done. Output directory: %s", output_dir)
68
 
69
+ # # TODO: remove this
70
+ # output_dir = Path("boltz_results")
71
  # Convert output CIF to PDB
72
  pred_cif = list(output_dir.rglob("*_model_0.cif"))[0]
73
  logger.info("Output file: %s", pred_cif)
74
 
75
+ converted_pdb_path = str(output_dir / "pred.pdb")
76
  convert_cif_to_pdb(str(pred_cif), str(converted_pdb_path))
77
  logger.info("Converted PDB file: %s", converted_pdb_path)
78
 
79
+
80
  # Generate molecular visualization
81
  mol = _create_molecule_visualization(
82
  converted_pdb_path,
 
96
  def _create_molecule_visualization(pdb_path: Path, sequence: str, output_dir: Path) -> str:
97
  """Create molecular visualization using molecule module."""
98
  return molecule(
 
99
  str(pdb_path),
100
  lenSeqs=1,
101
  num_res=len(sequence),
 
108
  "Mean pLDDT": 0,
109
  "seq": sequence
110
  }],
 
111
  )
112
 
113
 
 
115
  """Wrap content in an HTML iframe with appropriate styling and permissions."""
116
  return f"""<iframe
117
  name="result"
118
+ style="width: 100%; height: 100vh;"
119
  allow="midi; geolocation; microphone; camera; display-capture; encrypted-media;"
120
  sandbox="allow-modals allow-forms allow-scripts allow-same-origin allow-popups allow-top-navigation-by-user-activation allow-downloads"
121
  allowfullscreen=""
molecule.py CHANGED
@@ -20,10 +20,9 @@ def read_mol(molpath):
20
 
21
 
22
  def molecule(
23
- input_pdb, aligned_pdb, lenSeqs, num_res, selectedResidues, allSeqs, sequences, random_dir
24
  ):
25
 
26
- mol = read_mol(input_pdb)
27
  options = ""
28
  pred_mol = "["
29
  seqdata = "{"
@@ -92,17 +91,6 @@ def molecule(
92
  <script src="https://3Dmol.csb.pitt.edu/build/3Dmol-min.js"></script>
93
  </head>
94
  <body>
95
- <div class="max-w-2xl flex items-center space-x-2 py-3">
96
- <label for="seq"
97
- class=" text-right whitespace-nowrap block text-base font-medium text-gray-900 dark:text-gray-400">Select
98
- a sequence</label>
99
- <select id="seq"
100
- class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
101
- """
102
- + options
103
- + """
104
- </select>
105
- </div>
106
  <div class="font-mono bg-gray-100 py-3 px-2 font-sm rounded">
107
  <p id="seqText" class="max-w-4xl font-xs block" style="word-break: break-all;">
108
  </p>
@@ -151,8 +139,6 @@ def molecule(
151
  $("#plddt").text(seqs[i]["plddt"])
152
  viewer = $3Dmol.createViewer(element, config);
153
  viewer.addModel(data[i], "pdb");
154
- viewer.addModel(pdb, "pdb");
155
- viewer.getModel(1).setStyle({}, { cartoon: { colorscheme: { prop: "resi", map: colors } } })
156
  viewer.getModel(0).setStyle({}, { cartoon: { colorfunc: colorAlpha } });
157
  viewer.zoomTo();
158
  viewer.render();
@@ -182,9 +168,6 @@ def molecule(
182
  let data = """
183
  + pred_mol
184
  + """
185
- let pdb = `"""
186
- + mol
187
- + """`
188
  var selectedResidues = """
189
  + f"{selectedResidues}"
190
  + """
@@ -235,20 +218,16 @@ def molecule(
235
 
236
  if ($("#startstructure").prop("checked")) {
237
  viewer.getModel(0).setStyle( {"and": [{resn: ["GLY", "PRO"], invert: true},{atom: BB, invert: true},]},{stick: {colorscheme: "WhiteCarbon", radius: 0.3}, cartoon: { colorfunc: colorAlpha }});
238
- viewer.getModel(1).setStyle( {"and": [{resn: ["GLY", "PRO"], invert: true},{atom: BB, invert: true},]},{stick: {colorfunc:colorFixedSidechain, radius: 0.3}, cartoon: {colorscheme:{prop:"resi",map:colors} }});
239
  }else{
240
  viewer.getModel(0).setStyle( {"and": [{resn: ["GLY", "PRO"], invert: true},{atom: BB, invert: true},]},{stick: {colorscheme: "WhiteCarbon", radius: 0.3}, cartoon: { colorfunc: colorAlpha }});
241
- viewer.getModel(1).setStyle();
242
  }
243
 
244
  viewer.render()
245
  } else {
246
  if ($("#startstructure").prop("checked")) {
247
  viewer.getModel(0).setStyle({cartoon: { colorfunc: colorAlpha }});
248
- viewer.getModel(1).setStyle({cartoon: {colorscheme:{prop:"resi",map:colors} }});
249
  }else{
250
  viewer.getModel(0).setStyle({cartoon: { colorfunc: colorAlpha }});
251
- viewer.getModel(1).setStyle();
252
  }
253
  viewer.render()
254
  }
@@ -262,12 +241,10 @@ def molecule(
262
  $("#startstructure").change(function () {
263
  if (this.checked) {
264
  $("#sidechain").prop( "checked", false );
265
- viewer.getModel(1).setStyle({},{cartoon: {colorscheme:{prop:"resi",map:colors} } })
266
  viewer.getModel(0).setStyle({}, { cartoon: { colorfunc: colorAlpha } });
267
  viewer.render()
268
  } else {
269
  $("#sidechain").prop( "checked", false );
270
- viewer.getModel(1).setStyle({},{})
271
  viewer.getModel(0).setStyle({}, { cartoon: { colorfunc: colorAlpha } });
272
  viewer.render()
273
  }
 
20
 
21
 
22
  def molecule(
23
+ input_pdb, lenSeqs, num_res, selectedResidues, allSeqs, sequences
24
  ):
25
 
 
26
  options = ""
27
  pred_mol = "["
28
  seqdata = "{"
 
91
  <script src="https://3Dmol.csb.pitt.edu/build/3Dmol-min.js"></script>
92
  </head>
93
  <body>
 
 
 
 
 
 
 
 
 
 
 
94
  <div class="font-mono bg-gray-100 py-3 px-2 font-sm rounded">
95
  <p id="seqText" class="max-w-4xl font-xs block" style="word-break: break-all;">
96
  </p>
 
139
  $("#plddt").text(seqs[i]["plddt"])
140
  viewer = $3Dmol.createViewer(element, config);
141
  viewer.addModel(data[i], "pdb");
 
 
142
  viewer.getModel(0).setStyle({}, { cartoon: { colorfunc: colorAlpha } });
143
  viewer.zoomTo();
144
  viewer.render();
 
168
  let data = """
169
  + pred_mol
170
  + """
 
 
 
171
  var selectedResidues = """
172
  + f"{selectedResidues}"
173
  + """
 
218
 
219
  if ($("#startstructure").prop("checked")) {
220
  viewer.getModel(0).setStyle( {"and": [{resn: ["GLY", "PRO"], invert: true},{atom: BB, invert: true},]},{stick: {colorscheme: "WhiteCarbon", radius: 0.3}, cartoon: { colorfunc: colorAlpha }});
 
221
  }else{
222
  viewer.getModel(0).setStyle( {"and": [{resn: ["GLY", "PRO"], invert: true},{atom: BB, invert: true},]},{stick: {colorscheme: "WhiteCarbon", radius: 0.3}, cartoon: { colorfunc: colorAlpha }});
 
223
  }
224
 
225
  viewer.render()
226
  } else {
227
  if ($("#startstructure").prop("checked")) {
228
  viewer.getModel(0).setStyle({cartoon: { colorfunc: colorAlpha }});
 
229
  }else{
230
  viewer.getModel(0).setStyle({cartoon: { colorfunc: colorAlpha }});
 
231
  }
232
  viewer.render()
233
  }
 
241
  $("#startstructure").change(function () {
242
  if (this.checked) {
243
  $("#sidechain").prop( "checked", false );
 
244
  viewer.getModel(0).setStyle({}, { cartoon: { colorfunc: colorAlpha } });
245
  viewer.render()
246
  } else {
247
  $("#sidechain").prop( "checked", false );
 
248
  viewer.getModel(0).setStyle({}, { cartoon: { colorfunc: colorAlpha } });
249
  viewer.render()
250
  }