andreamena commited on
Commit
8192e34
·
verified ·
1 Parent(s): d34e11f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -4
app.py CHANGED
@@ -97,6 +97,7 @@ def preprocess_input(payload_smiles, linker_smiles, peptide_seq):
97
  df.to_excel('temp_input.xlsx', index=False)
98
 
99
  # 2. Get Graph Features
 
100
  dataset_gen = Graph_Classification_Dataset(
101
  'temp_input.xlsx',
102
  smiles_field1='Payload SMILES',
@@ -109,8 +110,25 @@ def preprocess_input(payload_smiles, linker_smiles, peptide_seq):
109
  addH=True
110
  ).get_data()
111
 
112
- _, _, val_dataset = dataset_gen
113
- x1, adjoin1, _, x2, adjoin2, _ = next(iter(val_dataset))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
 
115
  # Masks
116
  seq1 = tf.cast(tf.math.equal(x1, 0), tf.float32)
@@ -121,7 +139,7 @@ def preprocess_input(payload_smiles, linker_smiles, peptide_seq):
121
  # 3. Get Peptide Features
122
  t2 = get_t2_features(peptide_seq)
123
 
124
- # DYNAMIC GENERATION (The Fix)
125
  t1 = get_protbert_embedding(peptide_seq)
126
 
127
  return x1, mask1, adjoin1, x2, mask2, adjoin2, t1, t2
@@ -173,7 +191,7 @@ import re # Needed for regex in protbert cleaning
173
 
174
  with gr.Blocks(title="PDCNet Ensemble Demo") as demo:
175
  gr.Markdown("# 💊 PDCNet Ensemble Predictor")
176
- gr.Markdown("Predict the activity of Peptide-Drug Conjugates. Supports **Any Peptide Sequence** via live ProtBERT embedding.")
177
 
178
  with gr.Row():
179
  with gr.Column():
 
97
  df.to_excel('temp_input.xlsx', index=False)
98
 
99
  # 2. Get Graph Features
100
+ # We rely on the existing loader, but we need to handle the random splitting
101
  dataset_gen = Graph_Classification_Dataset(
102
  'temp_input.xlsx',
103
  smiles_field1='Payload SMILES',
 
110
  addH=True
111
  ).get_data()
112
 
113
+ # Unpack the three datasets (Train, Test, Val)
114
+ train_ds, test_ds, val_ds = dataset_gen
115
+
116
+ # CRITICAL FIX: Check all 3 datasets for the data
117
+ # (Because with 1 row, it randomly lands in one and leaves the others empty)
118
+ target_batch = None
119
+ for ds in [train_ds, test_ds, val_ds]:
120
+ try:
121
+ # Try to grab the batch
122
+ target_batch = next(iter(ds))
123
+ if target_batch is not None:
124
+ break # Found it!
125
+ except Exception:
126
+ continue # This one was empty, check the next
127
+
128
+ if target_batch is None:
129
+ return None, None, None, None, None, None, None, None
130
+
131
+ x1, adjoin1, _, x2, adjoin2, _ = target_batch
132
 
133
  # Masks
134
  seq1 = tf.cast(tf.math.equal(x1, 0), tf.float32)
 
139
  # 3. Get Peptide Features
140
  t2 = get_t2_features(peptide_seq)
141
 
142
+ # DYNAMIC GENERATION
143
  t1 = get_protbert_embedding(peptide_seq)
144
 
145
  return x1, mask1, adjoin1, x2, mask2, adjoin2, t1, t2
 
191
 
192
  with gr.Blocks(title="PDCNet Ensemble Demo") as demo:
193
  gr.Markdown("# 💊 PDCNet Ensemble Predictor")
194
+ gr.Markdown("Predict the activity of Peptide-Drug Conjugates.")
195
 
196
  with gr.Row():
197
  with gr.Column():