Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -177,35 +177,34 @@ def load_standard_models(model_name="seyonec/PubChem10M_SMILES_BPE_450k"):
|
|
| 177 |
# --- RDKit and Py3Dmol Visualization Functions ---
|
| 178 |
|
| 179 |
def mol_to_svg(mol, size=(400, 300)):
|
| 180 |
-
"""Converts an RDKit molecule object to an SVG image string
|
| 181 |
if not mol:
|
| 182 |
return None
|
| 183 |
drawer = rdMolDraw2D.MolDraw2DSVG(*size)
|
| 184 |
-
|
| 185 |
-
drawer.drawOptions().
|
| 186 |
-
drawer.drawOptions().
|
|
|
|
| 187 |
|
| 188 |
-
# Set dark theme colors for RDKit drawing
|
| 189 |
-
#
|
| 190 |
-
#
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
#
|
| 203 |
-
drawer.drawOptions().setAtomColor(
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
drawer.drawOptions().bondColor = (0.7, 0.7, 0.7) # Bond color (medium gray)
|
| 208 |
-
drawer.drawOptions().highlightColour = (0.2, 0.6, 1.0) # Highlight color (blue)
|
| 209 |
|
| 210 |
drawer.DrawMolecule(mol)
|
| 211 |
drawer.FinishDrawing()
|
|
|
|
| 177 |
# --- RDKit and Py3Dmol Visualization Functions ---
|
| 178 |
|
| 179 |
def mol_to_svg(mol, size=(400, 300)):
|
| 180 |
+
"""Converts an RDKit molecule object to an SVG image string using default RDKit colors."""
|
| 181 |
if not mol:
|
| 182 |
return None
|
| 183 |
drawer = rdMolDraw2D.MolDraw2DSVG(*size)
|
| 184 |
+
# Removing custom color settings as per user request to use default RDKit colors
|
| 185 |
+
# drawer.drawOptions().clearBackground = False # Keep background transparent/dark
|
| 186 |
+
# drawer.drawOptions().addStereoAnnotation = True
|
| 187 |
+
# drawer.drawOptions().baseFontSize = 0.8
|
| 188 |
|
| 189 |
+
# # Set dark theme colors for RDKit drawing - REMOVED AS PER USER REQUEST
|
| 190 |
+
# atom_colors = {
|
| 191 |
+
# 6: (0.8, 0.8, 0.8), # Carbon (light gray)
|
| 192 |
+
# 7: (0.2, 0.5, 1.0), # Nitrogen (blue)
|
| 193 |
+
# 8: (1.0, 0.2, 0.2), # Oxygen (red)
|
| 194 |
+
# 9: (0.2, 0.8, 0.2), # Fluorine (green)
|
| 195 |
+
# 15: (1.0, 0.5, 0.0), # Phosphorus (orange)
|
| 196 |
+
# 16: (1.0, 0.8, 0.0), # Sulfur (yellow)
|
| 197 |
+
# 17: (0.2, 0.7, 0.2), # Chlorine (dark green)
|
| 198 |
+
# 35: (0.5, 0.2, 0.8), # Bromine (purple)
|
| 199 |
+
# 53: (0.8, 0.2, 0.5), # Iodine (pink/magenta)
|
| 200 |
+
# }
|
| 201 |
+
# # Set default atom color
|
| 202 |
+
# drawer.drawOptions().setAtomColor(Chem.rdatomicnumlist.Get): (0.8, 0.8, 0.8) # Default to light gray for unknown atoms
|
| 203 |
+
# for atom_num, color in atom_colors.items():
|
| 204 |
+
# drawer.drawOptions().setAtomColor(atom_num, color)
|
| 205 |
+
|
| 206 |
+
# drawer.drawOptions().bondColor = (0.7, 0.7, 0.7) # Bond color (medium gray)
|
| 207 |
+
# drawer.drawOptions().highlightColour = (0.2, 0.6, 1.0) # Highlight color (blue)
|
|
|
|
|
|
|
| 208 |
|
| 209 |
drawer.DrawMolecule(mol)
|
| 210 |
drawer.FinishDrawing()
|