ThorbenF commited on
Commit
a653779
·
1 Parent(s): 5dae6ce
Files changed (2) hide show
  1. .ipynb_checkpoints/app-checkpoint.py +7 -25
  2. app.py +7 -25
.ipynb_checkpoints/app-checkpoint.py CHANGED
@@ -177,45 +177,28 @@ def extract_protein_sequence(pdb_path):
177
  longest_sequence = one_letter_sequence
178
  longest_chain = chain
179
 
180
- return longest_sequence, longest_chain
181
 
182
  def process_pdb(pdb_id):
183
  # Fetch PDB file
184
  pdb_path = fetch_pdb(pdb_id)
185
 
186
  if not pdb_path:
187
- return "Failed to fetch PDB file", None
188
 
189
  # Extract protein sequence and chain
190
- protein_sequence, chain = extract_protein_sequence(pdb_path)
191
 
192
  if not protein_sequence:
193
- return "No suitable protein sequence found", None
194
-
195
  # Predict binding sites
196
  sequence, normalized_scores = predict_protein_sequence(protein_sequence)
197
 
198
- # Prepare representations for coloring residues
199
- reps = [
200
- {
201
- "model": 0,
202
- "chain": chain.id,
203
- "resname": res,
204
- "resnum": i+1,
205
- "style": "cartoon",
206
- "color": f'rgb({int(score * 255)}, 0, {int(255 - score * 255)})',
207
- "residue_range": f"{i+1}-{i+1}",
208
- "around": 0,
209
- "byres": True,
210
- "visible": True
211
- }
212
- for i, (res, score) in enumerate(zip(sequence, normalized_scores))
213
- ]
214
-
215
  # Prepare result string
216
  result_str = "\n".join([f"{aa}: {score:.2f}" for aa, score in zip(sequence, normalized_scores)])
217
 
218
- return result_str, {"root": [pdb_path]}
219
 
220
  # Create Gradio interface
221
  with gr.Blocks() as demo:
@@ -241,8 +224,7 @@ with gr.Blocks() as demo:
241
 
242
  # 3D Molecule visualization
243
  molecule_output = Molecule3D(
244
- label="Protein Structure",
245
- reps=[] # Start with empty representations
246
  )
247
 
248
  # Prediction logic
 
177
  longest_sequence = one_letter_sequence
178
  longest_chain = chain
179
 
180
+ return longest_sequence, longest_chain, pdb_path
181
 
182
  def process_pdb(pdb_id):
183
  # Fetch PDB file
184
  pdb_path = fetch_pdb(pdb_id)
185
 
186
  if not pdb_path:
187
+ return "Failed to fetch PDB file", pdb_path
188
 
189
  # Extract protein sequence and chain
190
+ protein_sequence, chain, pdb_file = extract_protein_sequence(pdb_path)
191
 
192
  if not protein_sequence:
193
+ return "No suitable protein sequence found", pdb_file
194
+
195
  # Predict binding sites
196
  sequence, normalized_scores = predict_protein_sequence(protein_sequence)
197
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  # Prepare result string
199
  result_str = "\n".join([f"{aa}: {score:.2f}" for aa, score in zip(sequence, normalized_scores)])
200
 
201
+ return result_str, pdb_file
202
 
203
  # Create Gradio interface
204
  with gr.Blocks() as demo:
 
224
 
225
  # 3D Molecule visualization
226
  molecule_output = Molecule3D(
227
+ label="Protein Structure"
 
228
  )
229
 
230
  # Prediction logic
app.py CHANGED
@@ -177,45 +177,28 @@ def extract_protein_sequence(pdb_path):
177
  longest_sequence = one_letter_sequence
178
  longest_chain = chain
179
 
180
- return longest_sequence, longest_chain
181
 
182
  def process_pdb(pdb_id):
183
  # Fetch PDB file
184
  pdb_path = fetch_pdb(pdb_id)
185
 
186
  if not pdb_path:
187
- return "Failed to fetch PDB file", None
188
 
189
  # Extract protein sequence and chain
190
- protein_sequence, chain = extract_protein_sequence(pdb_path)
191
 
192
  if not protein_sequence:
193
- return "No suitable protein sequence found", None
194
-
195
  # Predict binding sites
196
  sequence, normalized_scores = predict_protein_sequence(protein_sequence)
197
 
198
- # Prepare representations for coloring residues
199
- reps = [
200
- {
201
- "model": 0,
202
- "chain": chain.id,
203
- "resname": res,
204
- "resnum": i+1,
205
- "style": "cartoon",
206
- "color": f'rgb({int(score * 255)}, 0, {int(255 - score * 255)})',
207
- "residue_range": f"{i+1}-{i+1}",
208
- "around": 0,
209
- "byres": True,
210
- "visible": True
211
- }
212
- for i, (res, score) in enumerate(zip(sequence, normalized_scores))
213
- ]
214
-
215
  # Prepare result string
216
  result_str = "\n".join([f"{aa}: {score:.2f}" for aa, score in zip(sequence, normalized_scores)])
217
 
218
- return result_str, {"root": [pdb_path]}
219
 
220
  # Create Gradio interface
221
  with gr.Blocks() as demo:
@@ -241,8 +224,7 @@ with gr.Blocks() as demo:
241
 
242
  # 3D Molecule visualization
243
  molecule_output = Molecule3D(
244
- label="Protein Structure",
245
- reps=[] # Start with empty representations
246
  )
247
 
248
  # Prediction logic
 
177
  longest_sequence = one_letter_sequence
178
  longest_chain = chain
179
 
180
+ return longest_sequence, longest_chain, pdb_path
181
 
182
  def process_pdb(pdb_id):
183
  # Fetch PDB file
184
  pdb_path = fetch_pdb(pdb_id)
185
 
186
  if not pdb_path:
187
+ return "Failed to fetch PDB file", pdb_path
188
 
189
  # Extract protein sequence and chain
190
+ protein_sequence, chain, pdb_file = extract_protein_sequence(pdb_path)
191
 
192
  if not protein_sequence:
193
+ return "No suitable protein sequence found", pdb_file
194
+
195
  # Predict binding sites
196
  sequence, normalized_scores = predict_protein_sequence(protein_sequence)
197
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  # Prepare result string
199
  result_str = "\n".join([f"{aa}: {score:.2f}" for aa, score in zip(sequence, normalized_scores)])
200
 
201
+ return result_str, pdb_file
202
 
203
  # Create Gradio interface
204
  with gr.Blocks() as demo:
 
224
 
225
  # 3D Molecule visualization
226
  molecule_output = Molecule3D(
227
+ label="Protein Structure"
 
228
  )
229
 
230
  # Prediction logic