JishnuSetia commited on
Commit
0307f2a
·
verified ·
1 Parent(s): ea395de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -8
app.py CHANGED
@@ -3,13 +3,11 @@ from rdkit import Chem
3
  from rdkit.Chem import AllChem, Draw
4
 
5
  def visualize_molecule(mol_smiles):
6
- # Create a molecule using SMILES notation
7
  mol = Chem.MolFromSmiles(mol_smiles)
8
 
9
- # Add hydrogen atoms
10
  mol = Chem.AddHs(mol)
11
 
12
- # Generate 2D coordinates for the molecule
13
  AllChem.Compute2DCoords(mol)
14
 
15
  return mol
@@ -19,18 +17,15 @@ st.title('Molecular Structure Visualization')
19
  st.write("By Jishnu Setia")
20
 
21
  # Input molecule SMILES string
22
- mol_smiles = st.text_input('Enter molecule SMILES:', 'CCl.O.Br.Cl.C=C.C#C.[Na]Br.[Na]Cl.[Na+].[Br-].c1ccccc1.c1c(O)c(I)c(F)c(Br)c1(Cl)') # Default: Sodium ion
23
 
24
- # Visualize the molecule
25
  if mol_smiles:
26
  mol = visualize_molecule(mol_smiles)
27
  img = Draw.MolToImage(mol, size=(700, 400))
28
  st.image(img)
29
-
30
- # Add space
31
  st.write(" ")
32
 
33
- # Instructions for SMILES notation
34
  st.markdown("<h2>SMILES (Simplified Molecular Input Line Entry System)</h2>", unsafe_allow_html=True)
35
  st.write("SMILES is a string format for representing molecular structures.")
36
  st.write("You can represent various features using specific characters in SMILES notation:")
 
3
  from rdkit.Chem import AllChem, Draw
4
 
5
  def visualize_molecule(mol_smiles):
6
+
7
  mol = Chem.MolFromSmiles(mol_smiles)
8
 
 
9
  mol = Chem.AddHs(mol)
10
 
 
11
  AllChem.Compute2DCoords(mol)
12
 
13
  return mol
 
17
  st.write("By Jishnu Setia")
18
 
19
  # Input molecule SMILES string
20
+ mol_smiles = st.text_input('Enter molecule SMILES:', 'CCl.O.Br.Cl.C=C.C#C.[Na]Br.[Na]Cl.[Na+].[Br-].c1ccccc1.c1c(O)c(I)c(F)c(Br)c1(Cl)')
21
 
 
22
  if mol_smiles:
23
  mol = visualize_molecule(mol_smiles)
24
  img = Draw.MolToImage(mol, size=(700, 400))
25
  st.image(img)
 
 
26
  st.write(" ")
27
 
28
+ # Instructions for SMILES
29
  st.markdown("<h2>SMILES (Simplified Molecular Input Line Entry System)</h2>", unsafe_allow_html=True)
30
  st.write("SMILES is a string format for representing molecular structures.")
31
  st.write("You can represent various features using specific characters in SMILES notation:")