Spaces:
Sleeping
Sleeping
Vaishnav14220
commited on
Commit
·
f1cd4aa
1
Parent(s):
fe705fb
Fix PDF generation error by handling None values in SMILES arrays
Browse files
app.py
CHANGED
|
@@ -57,12 +57,17 @@ def generate_all_reactions_pdf():
|
|
| 57 |
pdf.cell(200, 8, txt=f"Reaction {idx+1}: {row['name']}", ln=True)
|
| 58 |
pdf.set_font("Arial", size=8)
|
| 59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
pdf.cell(200, 6, txt=f"Reactants: {', '.join(row['reactants'])}", ln=True)
|
| 61 |
-
pdf.cell(200, 6, txt=f"Reactants SMILES: {', '.join(
|
| 62 |
pdf.cell(200, 6, txt=f"Reagents: {', '.join(row['reagents']) if len(row['reagents']) > 0 else 'None'}", ln=True)
|
| 63 |
-
pdf.cell(200, 6, txt=f"Reagents SMILES: {', '.join(
|
| 64 |
pdf.cell(200, 6, txt=f"Products: {', '.join(row['products'])}", ln=True)
|
| 65 |
-
pdf.cell(200, 6, txt=f"Products SMILES: {', '.join(
|
| 66 |
pdf.ln(5)
|
| 67 |
|
| 68 |
# Check if we need a new page
|
|
|
|
| 57 |
pdf.cell(200, 8, txt=f"Reaction {idx+1}: {row['name']}", ln=True)
|
| 58 |
pdf.set_font("Arial", size=8)
|
| 59 |
|
| 60 |
+
# Handle potential None values in SMILES
|
| 61 |
+
reactants_smiles = [s for s in row['reactants_smiles'] if s is not None]
|
| 62 |
+
reagents_smiles = [s for s in row['reagents_smiles'] if s is not None]
|
| 63 |
+
products_smiles = [s for s in row['products_smiles'] if s is not None]
|
| 64 |
+
|
| 65 |
pdf.cell(200, 6, txt=f"Reactants: {', '.join(row['reactants'])}", ln=True)
|
| 66 |
+
pdf.cell(200, 6, txt=f"Reactants SMILES: {', '.join(reactants_smiles) if reactants_smiles else 'None'}", ln=True)
|
| 67 |
pdf.cell(200, 6, txt=f"Reagents: {', '.join(row['reagents']) if len(row['reagents']) > 0 else 'None'}", ln=True)
|
| 68 |
+
pdf.cell(200, 6, txt=f"Reagents SMILES: {', '.join(reagents_smiles) if reagents_smiles else 'None'}", ln=True)
|
| 69 |
pdf.cell(200, 6, txt=f"Products: {', '.join(row['products'])}", ln=True)
|
| 70 |
+
pdf.cell(200, 6, txt=f"Products SMILES: {', '.join(products_smiles) if products_smiles else 'None'}", ln=True)
|
| 71 |
pdf.ln(5)
|
| 72 |
|
| 73 |
# Check if we need a new page
|