Skip to content

Commit

Permalink
Fix #7311: problem with InChI for phosphinic acid (#7419)
Browse files Browse the repository at this point in the history
* backup

* remove default valence for Tl
  • Loading branch information
greglandrum committed May 3, 2024
1 parent 757d3ed commit 31f1195
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Code/GraphMol/atomic_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const std::string periodicTableAtomData =
78 Pt 1.36 1.3 2.05 195.078 10 195 194.9647911 -1
79 Au 1.36 1.34 2.1 196.967 11 197 196.9665687 -1
80 Hg 1.32 1.49 2.05 200.59 2 202 201.970643 -1
81 Tl 1.45 1.48 2.2 204.383 3 205 204.9744275 3
81 Tl 1.45 1.48 2.2 204.383 3 205 204.9744275 -1
82 Pb 1.46 1.48 2.3 207.2 4 208 207.9766521 2 4
83 Bi 1.48 1.45 2.3 208.98 5 209 208.9803987 3 5 7
84 Po 1.40 1.46 2.0 209 6 209 208.9824304 2 4 6
Expand Down
16 changes: 15 additions & 1 deletion External/INCHI-API/inchi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1806,7 +1806,21 @@ std::string MolToInchi(const ROMol& mol, ExtraInchiReturnValues& rv,
inchiAtoms[i].charge = atom->getFormalCharge();

// number of iso H
inchiAtoms[i].num_iso_H[0] = -1;
int nHs = -1;
switch (atom->getAtomicNum()) {
case 6:
case 7:
case 8:
case 9:
case 17:
case 35:
case 53:
nHs = -1;
break;
default:
nHs = atom->getTotalNumHs();
}
inchiAtoms[i].num_iso_H[0] = nHs;
inchiAtoms[i].num_iso_H[1] = 0;
inchiAtoms[i].num_iso_H[2] = 0;
inchiAtoms[i].num_iso_H[3] = 0;
Expand Down
18 changes: 18 additions & 0 deletions External/INCHI-API/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ void testGithubIssue614() {
m->removeAtom(3);
ExtraInchiReturnValues tmp;
std::string inchi = MolToInchi(*m, tmp);
std::cerr << " inchi: " << inchi << std::endl;
TEST_ASSERT(inchi == "InChI=1S/C3H6/c1-3-2/h3H,1H2,2H3");
delete m;
}
Expand Down Expand Up @@ -896,6 +897,22 @@ void testGithub6172() {
std::unique_ptr<ROMol> m{InchiToMol(inchi, tmp)};
TEST_ASSERT(!m);
}
BOOST_LOG(rdInfoLog) << "done" << std::endl;
}

void testGithub5311() {
BOOST_LOG(rdErrorLog) << "-------------------------------------" << std::endl;
BOOST_LOG(rdInfoLog) << "testing github #5311" << std::endl;

{
auto m = "O[PH2]=O"_smiles;
TEST_ASSERT(m);
ExtraInchiReturnValues tmp;
auto inchi = MolToInchi(*m, tmp);
std::cerr << "!!! " << inchi << std::endl;
TEST_ASSERT(inchi == "InChI=1S/H3O2P/c1-3-2/h3H2,(H,1,2)");
BOOST_LOG(rdInfoLog) << "done" << std::endl;
}
}
//-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
//
Expand All @@ -920,4 +937,5 @@ int main() {
testGithub3645();
test_clean_up_on_kekulization_error();
testGithub6172();
testGithub5311();
}

0 comments on commit 31f1195

Please sign in to comment.