Skip to content

Commit

Permalink
fix(algo/guess): refine conflict resolving logic for heteroatoms (#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
jnooree authored Sep 25, 2024
1 parent c6acb66 commit 62ad10d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/algo/guess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1601,17 +1601,19 @@ namespace {
if (atom.degree() == atom.data().hybridization()) {
int max_multiple = 4 - atom.data().hybridization();
for (auto nei: atom) {
if (nei.dst().data().implicit_hydrogens() <= 0
|| nei.dst().degree() > 2)
if (nei.dst().data().implicit_hydrogens() <= 0 || nei.dst().degree() > 2
|| !nei.dst().data().element().main_group())
continue;

AtomData &nei_data = nei.dst().data();
auto max_nei_order =
4 - sum_bond_order(nei.dst()) + nei_data.implicit_hydrogens();
int nei_order_margin =
internal::common_valence(
internal::effective_element_or_element(nei.dst()))
- sum_bond_order(nei.dst()) + nei_data.implicit_hydrogens();
int allowed = std::min({
required,
max_multiple,
max_nei_order - nei.edge_data().order(),
nei_order_margin,
atom.data().implicit_hydrogens(),
nei_data.implicit_hydrogens(),
});
Expand Down

0 comments on commit 62ad10d

Please sign in to comment.