alidenewade commited on
Commit
3752899
·
verified ·
1 Parent(s): 119ab23

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -25
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 with dark theme."""
181
  if not mol:
182
  return None
183
  drawer = rdMolDraw2D.MolDraw2DSVG(*size)
184
- drawer.drawOptions().clearBackground = False # Keep background transparent/dark
185
- drawer.drawOptions().addStereoAnnotation = True
186
- drawer.drawOptions().baseFontSize = 0.8
 
187
 
188
- # Set dark theme colors for RDKit drawing
189
- # These colors are approximations for a dark theme and may need fine-tuning
190
- # Atom colors (dictionary mapping atomic number to RGB tuple)
191
- atom_colors = {
192
- 6: (0.8, 0.8, 0.8), # Carbon (light gray)
193
- 7: (0.2, 0.5, 1.0), # Nitrogen (blue)
194
- 8: (1.0, 0.2, 0.2), # Oxygen (red)
195
- 9: (0.2, 0.8, 0.2), # Fluorine (green)
196
- 15: (1.0, 0.5, 0.0), # Phosphorus (orange)
197
- 16: (1.0, 0.8, 0.0), # Sulfur (yellow)
198
- 17: (0.2, 0.7, 0.2), # Chlorine (dark green)
199
- 35: (0.5, 0.2, 0.8), # Bromine (purple)
200
- 53: (0.8, 0.2, 0.5), # Iodine (pink/magenta)
201
- }
202
- # Set default atom color
203
- drawer.drawOptions().setAtomColor(Chem.rdatomicnumlist.Get): (0.8, 0.8, 0.8) # Default to light gray for unknown atoms
204
- for atom_num, color in atom_colors.items():
205
- drawer.drawOptions().setAtomColor(atom_num, color)
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()