Update app.py
Browse files
app.py
CHANGED
|
@@ -17,14 +17,16 @@ def get_chemical_info(chemical_name):
|
|
| 17 |
|
| 18 |
# Atoms
|
| 19 |
output.append("\nAtoms:")
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
| 22 |
|
| 23 |
# Bonds
|
| 24 |
output.append("\nBonds:")
|
| 25 |
for bond in compound.bonds:
|
| 26 |
-
atom1 = bond.
|
| 27 |
-
atom2 = bond.
|
| 28 |
output.append(f" Bond between {atom1} and {atom2}, Order: {bond.order}")
|
| 29 |
|
| 30 |
return "\n".join(output)
|
|
|
|
| 17 |
|
| 18 |
# Atoms
|
| 19 |
output.append("\nAtoms:")
|
| 20 |
+
atom_dict = {}
|
| 21 |
+
for atom in compound.atoms:
|
| 22 |
+
atom_dict[atom.idx] = atom.element
|
| 23 |
+
output.append(f" Atom {atom.idx}: Element = {atom.element}")
|
| 24 |
|
| 25 |
# Bonds
|
| 26 |
output.append("\nBonds:")
|
| 27 |
for bond in compound.bonds:
|
| 28 |
+
atom1 = atom_dict.get(bond.aid1, f"Atom {bond.aid1}")
|
| 29 |
+
atom2 = atom_dict.get(bond.aid2, f"Atom {bond.aid2}")
|
| 30 |
output.append(f" Bond between {atom1} and {atom2}, Order: {bond.order}")
|
| 31 |
|
| 32 |
return "\n".join(output)
|