Skip to content

Commit 37fd69e

Browse files
rwestJacksonBurns
authored andcommitted
Tweak to MoleculeDrawer: don't bother making a Geometry object.
The comment suggests it was going through Geometry in order to save the mapping, but this can be done with a direct call to to_rdkit_mol using return_mapping=True.
1 parent 576b1d6 commit 37fd69e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

rmgpy/molecule/draw.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -377,19 +377,20 @@ def _generate_coordinates(self, fix_surface_sites=True, use_rdkit=True):
377377

378378
if use_rdkit == True:
379379
# Use RDKit 2D coordinate generation:
380-
381-
# Generate the RDkit molecule from the RDkit molecule, use geometry
380+
# Generate the RDkit molecule from the RDkit molecule, saving mapping
382381
# in order to match the atoms in the rdmol with the atoms in the
383382
# RMG molecule (which is required to extract coordinates).
384-
self.geometry = Geometry(None, None, self.molecule, None)
383+
rdmol, rd_atom_idx = self.molecule.to_rdkit_mol(remove_h=False,
384+
return_mapping=True,
385+
sanitize="partial")
385386

386-
rdmol, rd_atom_idx = self.geometry.rd_build()
387387
AllChem.Compute2DCoords(rdmol)
388388

389389
# Extract the coordinates from each atom.
390+
rd_conformer = rdmol.GetConformer(0)
390391
for atom in atoms:
391392
index = rd_atom_idx[atom]
392-
point = rdmol.GetConformer(0).GetAtomPosition(index)
393+
point = rd_conformer.GetAtomPosition(index)
393394
coordinates[index, :] = [point.x * 0.6, point.y * 0.6]
394395

395396
# RDKit generates some molecules more vertically than horizontally,

0 commit comments

Comments
 (0)