Skip to content

Commit

Permalink
Fix the NPE: 0 formal charges is the common CDK default if unset
Browse files Browse the repository at this point in the history
Change-Id: I66ef745de55acbe2b6c18672cd3dc45c67794699
  • Loading branch information
egonw committed Sep 15, 2014
1 parent 87bbe61 commit 15a3f08
Showing 1 changed file with 2 additions and 1 deletion.
Expand Up @@ -808,7 +808,8 @@ public static IMolecularFormula getMolecularFormula(IAtomContainer atomContainer
IAtom hAtom = null;
for (IAtom iAtom : atomContainer.atoms()) {
formula.addIsotope(iAtom);
charge += iAtom.getFormalCharge();
if (iAtom.getFormalCharge() != null)
charge += iAtom.getFormalCharge();

if (iAtom.getImplicitHydrogenCount() != null && (iAtom.getImplicitHydrogenCount() > 0)) {
if (hAtom == null) hAtom = atomContainer.getBuilder().newInstance(IAtom.class, "H");
Expand Down

0 comments on commit 15a3f08

Please sign in to comment.