Skip to content

Commit

Permalink
Merge pull request #1330 from ghutchis/fix-nitrogen-valence
Browse files Browse the repository at this point in the history
Adjust nitrogen valence determination
  • Loading branch information
ghutchis authored Sep 9, 2023
2 parents 8970c8b + 1878545 commit 664ef1d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion avogadro/core/mdlvalence_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static unsigned int atomValence(const unsigned char atomicNumber,
case -1:
return 2;
case 0:
if (numBonds <= 3)
if (numBonds != 5)
return 3;
return 5;
case 1:
Expand Down
7 changes: 4 additions & 3 deletions tests/qtgui/hydrogentoolstest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,10 @@ TEST(HydrogenToolsTest, valencyAdjustment_N)
RWAtom N = mol.addAtom(7);
int expectedAdjustment = 3;
for (int i = 0; i < 8; ++i, --expectedAdjustment) {
if (i == 4) // neutral N can have 3 or 5 bonds in our valence model.
expectedAdjustment += 2;
EXPECT_EQ(expectedAdjustment, HydrogenTools::valencyAdjustment(N));
if (i == 5) // neutral N can have 3 or 5 bonds in our valence model.
EXPECT_EQ(0, HydrogenTools::valencyAdjustment(N));
else
EXPECT_EQ(expectedAdjustment, HydrogenTools::valencyAdjustment(N));
mol.addBond(mol.addAtom(1), N, 1);
}
}
Expand Down

0 comments on commit 664ef1d

Please sign in to comment.