Skip to content

Commit

Permalink
Merge pull request #280 from cdk/bug/atypevalence
Browse files Browse the repository at this point in the history
Correct valence calculation in CDKAtomTypeMatcher
  • Loading branch information
egonw committed Mar 21, 2017
2 parents 57cd683 + 5db4119 commit 162bce9
Showing 1 changed file with 7 additions and 2 deletions.
Expand Up @@ -2511,8 +2511,13 @@ private boolean isAcceptable(IAtom atom, IAtomContainer container, IAtomType typ
}

// confirm correct valency
if (type.getValency() != CDKConstants.UNSET && container.getBondOrderSum(atom) > type.getValency())
return false;
if (type.getValency() != CDKConstants.UNSET) {
double valence = container.getBondOrderSum(atom);
if (atom.getImplicitHydrogenCount() != 0)
valence += atom.getImplicitHydrogenCount();
if (valence > type.getValency())
return false;
}

// confirm correct formal charge
if (atom.getFormalCharge() != CDKConstants.UNSET && !atom.getFormalCharge().equals(type.getFormalCharge()))
Expand Down

0 comments on commit 162bce9

Please sign in to comment.