Skip to content

Commit b1b7fb1

Browse files
authored
Fixes rdkit#7501 dative bonds in cdxml (rdkit#7757)
* Fix datative bonds in CDXML * Finalize test * Don't sanitize, use normal smiles
1 parent 9aa77ac commit b1b7fb1

File tree

3 files changed

+270
-0
lines changed

3 files changed

+270
-0
lines changed

Code/GraphMol/FileParsers/CDXMLParser.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,8 @@ bool parse_fragment(RWMol &mol, ptree &frag,
369369
order = Bond::BondType::AROMATIC;
370370
} else if (attr.second.data() == "any") {
371371
order = Bond::BondType::UNSPECIFIED;
372+
} else if (attr.second.data() == "dative") {
373+
order = Bond::BondType::DATIVE;
372374
} else {
373375
int bond_order = stoi(attr.second.data());
374376

Code/GraphMol/FileParsers/cdxml_parser_catch.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,3 +1187,14 @@ TEST_CASE("Github #7528 - read fragments in groups") {
11871187
REQUIRE(mols.size() == 2);
11881188
}
11891189
}
1190+
1191+
TEST_CASE("Github #7501 - dative bonds") {
1192+
std::string cdxmlbase =
1193+
std::string(getenv("RDBASE")) + "/Code/GraphMol/test_data/CDXML/";
1194+
SECTION("case 1") {
1195+
auto fname = cdxmlbase + "github7501-dative.cdxml";
1196+
CDXMLParserParams params;
1197+
auto mols = MolsFromCDXMLFile(fname, params);
1198+
CHECK(MolToSmiles(*mols[0]) == "CC(C)->[Os]12<-CCCN->1CC=N->2"); // All datives to the Oxygen
1199+
}
1200+
}
Lines changed: 257 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,257 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!DOCTYPE CDXML SYSTEM "http://www.cambridgesoft.com/xml/cdxml.dtd" >
3+
<CDXML
4+
CreationProgram="ChemDraw 22.2.0.3300"
5+
Name="dative_bond_parsing_issue.cdmxl.cdxml"
6+
BoundingBox="242.88 187.37 297.19 243.37"
7+
WindowPosition="0 0"
8+
WindowSize="1073741824 1073741824"
9+
WindowIsZoomed="yes"
10+
FractionalWidths="yes"
11+
InterpretChemically="yes"
12+
ShowAtomQuery="yes"
13+
ShowAtomStereo="no"
14+
ShowAtomEnhancedStereo="yes"
15+
ShowAtomNumber="no"
16+
ShowResidueID="no"
17+
ShowBondQuery="yes"
18+
ShowBondRxn="yes"
19+
ShowBondStereo="no"
20+
ShowTerminalCarbonLabels="no"
21+
ShowNonTerminalCarbonLabels="no"
22+
HideImplicitHydrogens="no"
23+
LabelFont="3"
24+
LabelSize="10"
25+
LabelFace="96"
26+
CaptionFont="3"
27+
CaptionSize="10"
28+
HashSpacing="2.50"
29+
MarginWidth="1.60"
30+
LineWidth="0.60"
31+
BoldWidth="2"
32+
BondLength="14.40"
33+
BondSpacing="18"
34+
ChainAngle="120"
35+
LabelJustification="Auto"
36+
CaptionJustification="Left"
37+
AminoAcidTermini="HOH"
38+
ShowSequenceTermini="yes"
39+
ShowSequenceBonds="yes"
40+
ShowSequenceUnlinkedBranches="no"
41+
ResidueWrapCount="40"
42+
ResidueBlockCount="10"
43+
PrintMargins="36 36 36 36"
44+
MacPrintInfo="0003000001200120000000000B6608A0FF84FF880BE309180367052703FC0002000001200120000000000B6608A0000100000064000000010001010100000001270F000100010000000000000000000000000002001901900000000000600000000000000000000100000000000000000000000000000000"
45+
ChemPropName=""
46+
ChemPropFormula="Chemical Formula: "
47+
ChemPropExactMass="Exact Mass: "
48+
ChemPropMolWt="Molecular Weight: "
49+
ChemPropMOverZ="m/z: "
50+
ChemPropAnalysis="Elemental Analysis: "
51+
ChemPropBoilingPt="Boiling Point: "
52+
ChemPropMeltingPt="Melting Point: "
53+
ChemPropCritTemp="Critical Temp: "
54+
ChemPropCritPres="Critical Pres: "
55+
ChemPropCritVol="Critical Vol: "
56+
ChemPropGibbs="Gibbs Energy: "
57+
ChemPropLogP="Log P: "
58+
ChemPropMR="MR: "
59+
ChemPropHenry="Henry&apos;s Law: "
60+
ChemPropEForm="Heat of Form: "
61+
ChemProptPSA="tPSA: "
62+
ChemPropCLogP="CLogP: "
63+
ChemPropCMR="CMR: "
64+
ChemPropLogS="LogS: "
65+
ChemPropPKa="pKa: "
66+
ChemPropID=""
67+
ChemPropFragmentLabel=""
68+
color="0"
69+
bgcolor="1"
70+
RxnAutonumberStart="1"
71+
RxnAutonumberConditions="no"
72+
RxnAutonumberStyle="Roman"
73+
RxnAutonumberFormat="(#)"
74+
><colortable>
75+
<color r="1" g="1" b="1"/>
76+
<color r="0" g="0" b="0"/>
77+
<color r="1" g="0" b="0"/>
78+
<color r="1" g="1" b="0"/>
79+
<color r="0" g="1" b="0"/>
80+
<color r="0" g="1" b="1"/>
81+
<color r="0" g="0" b="1"/>
82+
<color r="1" g="0" b="1"/>
83+
</colortable><fonttable>
84+
<font id="3" charset="iso-8859-1" name="Arial"/>
85+
</fonttable><page
86+
id="74"
87+
BoundingBox="0 0 540 719.75"
88+
HeaderPosition="36"
89+
FooterPosition="36"
90+
PrintTrimMarks="yes"
91+
HeightPages="1"
92+
WidthPages="1"
93+
><fragment
94+
id="1"
95+
BoundingBox="242.88 187.37 297.19 243.37"
96+
Z="3"
97+
><n
98+
id="2"
99+
p="270.03 196.33"
100+
Z="4"
101+
AS="N"
102+
/><n
103+
id="12"
104+
p="270.03 213.73"
105+
Z="11"
106+
Element="76"
107+
NumHydrogens="0"
108+
NeedsClean="yes"
109+
AS="N"
110+
><t
111+
p="270.03 217.63"
112+
BoundingBox="263.64 209.17 276.42 217.73"
113+
LabelJustification="Center"
114+
Justification="Center"
115+
LabelAlignment="Center"
116+
><s font="3" size="10" color="0" face="96">Os</s></t></n><n
117+
id="13"
118+
p="286.58 208.36"
119+
Z="12"
120+
Element="7"
121+
NumHydrogens="1"
122+
NeedsClean="yes"
123+
AS="N"
124+
><t
125+
p="282.97 203.91"
126+
BoundingBox="282.97 195.57 290.19 212.26"
127+
LabelJustification="Left"
128+
LabelAlignment="Above"
129+
LineStarts="2 4"
130+
><s font="3" size="10" color="0" face="96">NH</s></t></n><n
131+
id="14"
132+
p="253.48 208.36"
133+
Z="13"
134+
AS="N"
135+
/><n
136+
id="15"
137+
p="270.03 231.13"
138+
Z="14"
139+
Element="7"
140+
NumHydrogens="1"
141+
NeedsClean="yes"
142+
AS="N"
143+
><t
144+
p="266.42 235.03"
145+
BoundingBox="266.42 226.69 273.64 243.37"
146+
LabelJustification="Left"
147+
LabelAlignment="Below"
148+
LineStarts="2 3"
149+
><s font="3" size="10" color="0" face="96">NH</s></t></n><n
150+
id="18"
151+
p="296.81 222.43"
152+
Z="17"
153+
AS="N"
154+
/><n
155+
id="23"
156+
p="286.58 236.51"
157+
Z="22"
158+
AS="N"
159+
/><n
160+
id="24"
161+
p="253.48 236.51"
162+
Z="23"
163+
AS="N"
164+
/><n
165+
id="25"
166+
p="243.26 222.43"
167+
Z="24"
168+
AS="N"
169+
/><n
170+
id="65"
171+
p="254.96 187.63"
172+
Z="64"
173+
AS="N"
174+
/><n
175+
id="71"
176+
p="285.10 187.63"
177+
Z="70"
178+
AS="N"
179+
/><b
180+
id="36"
181+
Z="35"
182+
B="2"
183+
E="12"
184+
Order="dative"
185+
BS="N"
186+
/><b
187+
id="37"
188+
Z="36"
189+
B="13"
190+
E="12"
191+
Order="dative"
192+
BS="N"
193+
/><b
194+
id="38"
195+
Z="37"
196+
B="14"
197+
E="12"
198+
Order="dative"
199+
BS="N"
200+
/><b
201+
id="39"
202+
Z="38"
203+
B="15"
204+
E="12"
205+
Order="dative"
206+
BS="N"
207+
/><b
208+
id="42"
209+
Z="41"
210+
B="13"
211+
E="18"
212+
Order="2"
213+
BS="N"
214+
BondCircularOrdering="0 37 48 0"
215+
/><b
216+
id="48"
217+
Z="47"
218+
B="18"
219+
E="23"
220+
BS="N"
221+
/><b
222+
id="49"
223+
Z="48"
224+
B="23"
225+
E="15"
226+
BS="N"
227+
/><b
228+
id="50"
229+
Z="49"
230+
B="15"
231+
E="24"
232+
BS="N"
233+
/><b
234+
id="51"
235+
Z="50"
236+
B="24"
237+
E="25"
238+
BS="N"
239+
/><b
240+
id="52"
241+
Z="51"
242+
B="25"
243+
E="14"
244+
BS="N"
245+
/><b
246+
id="66"
247+
Z="65"
248+
B="2"
249+
E="65"
250+
BS="N"
251+
/><b
252+
id="72"
253+
Z="71"
254+
B="2"
255+
E="71"
256+
BS="N"
257+
/></fragment></page></CDXML>

0 commit comments

Comments
 (0)