Skip to content
4 changes: 2 additions & 2 deletions INCHI-1-SRC/INCHI_BASE/src/strutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -6658,7 +6658,7 @@ int MolecularInorganicsPreprocessing(ORIG_ATOM_DATA *orig_at_data, INPUT_PARMS *
ligand_elem_array[ligand_type_count++] = neigh_elem;
}

if (at[i].bond_type[n] > 1 || is_el_a_metal(at[neigh_idx].el_number))
if ((at[i].bond_type[n] > 1 && at[i].bond_type[n] != 9) || is_el_a_metal(at[neigh_idx].el_number))
Comment thread
nnuk marked this conversation as resolved.
Outdated
{
must_keep_neighbor = 1;
}
Expand Down Expand Up @@ -6699,7 +6699,7 @@ int MolecularInorganicsPreprocessing(ORIG_ATOM_DATA *orig_at_data, INPUT_PARMS *

/* Check if the neighboring atom has more than 1 bond connected to the metal atom or
* if the neighbour is also a metal atom. In both cases no disconnection has to be done */
if (at[i].bond_type[n] > 1 || is_el_a_metal(at[neighbor_idx].el_number))
if ((at[i].bond_type[n] > 1 && at[i].bond_type[n] != 9) || is_el_a_metal(at[neighbor_idx].el_number))
{
ip->bMolecularInorganicsReconnectedInChI = 1;
continue; /* Skip disconnection for this bond */
Expand Down
125 changes: 125 additions & 0 deletions INCHI-1-TEST/tests/test_unit/test_molecularInorganics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,128 @@ M END

FreeINCHI(poutput);
}

TEST(test_molecularInorganics, test_MI_GHI_218)
{
const char* molblock = R"(stereochemistry.ds/mol_stereochemistry.ds_145.mol
Generated by WebMolKit

0 0 0 0 0 999 V3000
M V30 BEGIN CTAB
M V30 COUNTS 45 52 0 0 1
M V30 BEGIN ATOM
M V30 1 Ti 7.3506 0.0000 0.0000 0
M V30 2 O 6.1371 1.3858 0.0000 0
M V30 3 O 8.5641 -1.3858 0.0000 0
M V30 4 O 8.5641 1.3858 0.0000 0
M V30 5 O 6.1371 -1.3858 0.0000 0
M V30 6 O 8.1318 5.5124 0.0000 0
M V30 7 O 6.5694 -5.5124 0.0000 0
M V30 8 O 3.4466 2.8024 0.0000 0
M V30 9 O 11.2546 -2.8024 0.0000 0
M V30 10 O 3.3839 8.2243 0.0000 0
M V30 11 O 11.3173 -8.2243 0.0000 0
M V30 12 O 10.3725 1.5381 0.0000 0
M V30 13 O 4.3287 -1.5381 0.0000 0
M V30 14 O 14.9023 4.0839 0.0000 0
M V30 15 O -0.2011 -4.0839 0.0000 0
M V30 16 C 6.6006 2.8123 0.0000 0
M V30 17 C 8.1006 -2.8123 0.0000 0
M V30 18 C 8.1006 2.8123 0.0000 0
M V30 19 C 6.6006 -2.8123 0.0000 0
M V30 20 C 5.7985 4.1534 0.0000 0
M V30 21 C 8.9025 -4.1534 0.0000 0
M V30 22 C 8.9025 4.1534 0.0000 0
M V30 23 C 5.7985 -4.1534 0.0000 0
M V30 24 C 6.5694 5.5124 0.0000 0
M V30 25 C 8.1318 -5.5124 0.0000 0
M V30 26 C 10.4025 4.1360 0.0000 0
M V30 27 C 4.2987 -4.1360 0.0000 0
M V30 28 C 4.1715 4.1157 0.0000 0
M V30 29 C 10.5297 -4.1157 0.0000 0
M V30 30 C 5.7664 6.9281 0.0000 0
M V30 31 C 8.9346 -6.9281 0.0000 0
M V30 32 C 3.3361 5.5124 0.0000 0
M V30 33 C 11.3651 -5.5124 0.0000 0
M V30 34 C 4.1389 6.9281 0.0000 0
M V30 35 C 10.5621 -6.9281 0.0000 0
M V30 36 C 11.1374 2.8284 0.0000 0
M V30 37 C 3.5636 -2.8284 0.0000 0
M V30 38 C 11.1676 5.4263 0.0000 0
M V30 39 C 3.5336 -5.4263 0.0000 0
M V30 40 C 12.6374 2.8110 0.0000 0
M V30 41 C 2.0638 -2.8110 0.0000 0
M V30 42 C 12.6674 5.4089 0.0000 0
M V30 43 C 2.0338 -5.4089 0.0000 0
M V30 44 C 13.4023 4.1013 0.0000 0
M V30 45 C 1.2988 -4.1013 0.0000 0
M V30 END ATOM
M V30 BEGIN BOND
M V30 1 2 2 16
M V30 2 2 3 17
M V30 3 1 4 18
M V30 4 1 5 19
M V30 5 1 6 22
M V30 6 1 6 24
M V30 7 1 7 23
M V30 8 1 7 25
M V30 9 1 8 28
M V30 10 1 9 29
M V30 11 1 10 34
M V30 12 1 11 35
M V30 13 1 12 36
M V30 14 1 13 37
M V30 15 1 14 44
M V30 16 1 15 45
M V30 17 1 16 18
M V30 18 1 16 20
M V30 19 1 17 19
M V30 20 1 17 21
M V30 21 2 18 22
M V30 22 2 19 23
M V30 23 1 20 24
M V30 24 2 20 28
M V30 25 1 21 25
M V30 26 2 21 29
M V30 27 1 22 26
M V30 28 1 23 27
M V30 29 2 24 30
M V30 30 2 25 31
M V30 31 2 26 36
M V30 32 1 26 38
M V30 33 2 27 37
M V30 34 1 27 39
M V30 35 1 28 32
M V30 36 1 29 33
M V30 37 1 30 34
M V30 38 1 31 35
M V30 39 2 32 34
M V30 40 2 33 35
M V30 41 1 36 40
M V30 42 1 37 41
M V30 43 2 38 42
M V30 44 2 39 43
M V30 45 2 40 44
M V30 46 2 41 45
M V30 47 1 42 44
M V30 48 1 43 45
M V30 49 1 1 5
M V30 50 1 1 4 CFG=3
M V30 51 9 1 2 CFG=1 DISP=COORD
M V30 52 9 1 3 DISP=COORD
M V30 END BOND
M V30 END CTAB
M END)";

char options[] = "-MolecularInorganics";
inchi_Output output;
inchi_Output* poutput = &output;
memset(poutput, 0, sizeof(*poutput));

const char expected_inchi[] = "InChI=1B/2C15H10O7.Ti/c2*16-6-1-2-8(9(18)3-6)15-14(21)13(20)12-10(19)4-7(17)5-11(12)22-15;/h2*1-5,16-19,21H;/q2*-1;+4/p-2";

EXPECT_EQ(MakeINCHIFromMolfileText(molblock, options, poutput), 1);
EXPECT_STREQ(poutput->szInChI, expected_inchi);

FreeINCHI(poutput);
}