Skip to content

Commit 5397e7f

Browse files
authored
Merge pull request #2734 to Draw Hydrogen bonds (again)
Pull request #1961 introduced the ability to draw hydrogen bonds. To do so, Hydrogen atoms that have H bonds shouldn't be removed from the drawings. This check was removed without explanation in ec95153 which was designed to make drawing work for fragments. That broke drawing of hydrogen bonds. This pull request fixes it, and also removes some code duplication.
2 parents b30535b + 6f5c1c8 commit 5397e7f

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

rmgpy/molecule/draw.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ def draw(self, molecule, file_format, target=None):
184184
surface_sites = []
185185
for atom in self.molecule.atoms:
186186
if isinstance(atom, Atom) and atom.is_hydrogen() and atom.label == '':
187-
atoms_to_remove.append(atom)
187+
if not any(bond.is_hydrogen_bond() for bond in atom.bonds.values()):
188+
atoms_to_remove.append(atom)
188189
elif atom.is_surface_site():
189190
surface_sites.append(atom)
190191
if len(atoms_to_remove) < len(self.molecule.atoms) - len(surface_sites):
@@ -417,17 +418,6 @@ def _generate_coordinates(self, fix_surface_sites=True):
417418
coordinates[i1, 1] -= 0.2
418419
coordinates[i2, 1] += 0.2
419420

420-
# If two atoms lie on top of each other, push them apart a bit
421-
# This is ugly, but at least the mess you end up with isn't as misleading
422-
# as leaving everything piled on top of each other at the origin
423-
for atom1, atom2 in itertools.combinations(backbone, 2):
424-
i1, i2 = atoms.index(atom1), atoms.index(atom2)
425-
if np.linalg.norm(coordinates[i1, :] - coordinates[i2, :]) < 0.5:
426-
coordinates[i1, 0] -= 0.3
427-
coordinates[i2, 0] += 0.3
428-
coordinates[i1, 1] -= 0.2
429-
coordinates[i2, 1] += 0.2
430-
431421
# Center backbone at origin
432422
xmin = np.min(coordinates[:, 0])
433423
xmax = np.max(coordinates[:, 0])

0 commit comments

Comments
 (0)