Skip to content

Commit

Permalink
Change how implicit hydrogens are added (#11)
Browse files Browse the repository at this point in the history
* change how implicit hydroges are added to the graph
  • Loading branch information
klausweinbauer authored May 15, 2024
1 parent a033caa commit a1e4993
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions fgutils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ def add_implicit_hydrogens(graph: nx.Graph) -> nx.Graph:
if n_sym not in ["R", "H"]
]
for n_id, n_sym in nodes:
assert (
n_sym in valence_table.keys()
), "Element {} not found in valence table.".format(n_sym)
if n_sym not in valence_table.keys():
# No hydrogens are added if element is not in dict. These atoms
# are most likley not part of a functional group anyway so skipping
# hydrogens is fine
continue
bond_cnt = sum([b for _, _, b in graph.edges(n_id, data="bond")]) # type: ignore
# h_cnt can be negative; aromaticity is complicated, we just ignore that
valence = valence_table[n_sym]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "fgutils"
version = "0.0.15"
version = "0.0.16"
authors = [{name="Klaus Weinbauer", email="[email protected]"}]
description = "Library to get functional groups from molecular graphs."
readme = "README.md"
Expand Down

0 comments on commit a1e4993

Please sign in to comment.