Skip to content

Commit bdb26d4

Browse files
authored
#1230 Unable to save file if the canvas has a reaction arrow and a Functional Group (#1237)
1 parent 36719d3 commit bdb26d4

File tree

6 files changed

+199
-15
lines changed

6 files changed

+199
-15
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*** KET to MOL ***
22
suplabel.ket:SUCCEED
3+
empty_apid.ket:SUCCEED
34
ket-reaction-arrow.ket:SUCCEED

api/tests/integration/tests/formats/ket_to_mol.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ def find_diff(a, b):
2424
ref_path = joinPathPy("ref/", __file__)
2525
root_rea = joinPathPy("reactions/", __file__)
2626

27-
files = [
28-
"suplabel",
29-
]
27+
files = ["suplabel"]
3028

3129
files.sort()
3230
for filename in files:
@@ -41,16 +39,17 @@ def find_diff(a, b):
4139
print(filename + ".ket:FAILED")
4240
print(diff)
4341

44-
files = [
45-
"ket-reaction-arrow",
46-
]
42+
files = ["ket-reaction-arrow", "empty_apid"]
4743

4844
files.sort()
4945
for filename in files:
5046
rc = indigo.loadReactionFromFile(os.path.join(root_rea, filename + ".ket"))
47+
ket = rc.rxnfile()
48+
# with open(os.path.join(ref_path, filename) + ".mol", "w") as file:
49+
# file.write(ket)
50+
5151
with open(os.path.join(ref_path, filename) + ".mol", "r") as file:
5252
ket_ref = file.read()
53-
ket = rc.rxnfile()
5453
diff = find_diff(ket_ref, ket)
5554
if not diff:
5655
print(filename + ".ket:SUCCEED")
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
{
2+
"root": {
3+
"nodes": [
4+
{
5+
"$ref": "mol0"
6+
},
7+
{
8+
"type": "arrow",
9+
"data": {
10+
"mode": "open-angle",
11+
"pos": [
12+
{
13+
"x": 3.1,
14+
"y": -4.575,
15+
"z": 0
16+
},
17+
{
18+
"x": 7.804253394535632,
19+
"y": -4.575,
20+
"z": 0
21+
}
22+
]
23+
}
24+
}
25+
]
26+
},
27+
"mol0": {
28+
"type": "molecule",
29+
"atoms": [
30+
{
31+
"label": "C",
32+
"location": [
33+
9.325000000000001,
34+
-3.875,
35+
0
36+
]
37+
},
38+
{
39+
"label": "O",
40+
"location": [
41+
9.825003666733892,
42+
-3.008993649216902,
43+
0
44+
]
45+
},
46+
{
47+
"label": "O",
48+
"location": [
49+
9.825003666733892,
50+
-4.741006350783098,
51+
0
52+
]
53+
},
54+
{
55+
"label": "C",
56+
"location": [
57+
10.825011000201673,
58+
-3.008993649216902,
59+
0
60+
]
61+
},
62+
{
63+
"label": "C",
64+
"location": [
65+
11.825018333669453,
66+
-3.008993649216902,
67+
0
68+
]
69+
},
70+
{
71+
"label": "C",
72+
"location": [
73+
10.825011000201673,
74+
-2.008986315749121,
75+
0
76+
]
77+
},
78+
{
79+
"label": "C",
80+
"location": [
81+
10.825011000201673,
82+
-4.009000982684682,
83+
0
84+
]
85+
}
86+
],
87+
"bonds": [
88+
{
89+
"type": 1,
90+
"atoms": [
91+
0,
92+
1
93+
]
94+
},
95+
{
96+
"type": 2,
97+
"atoms": [
98+
0,
99+
2
100+
]
101+
},
102+
{
103+
"type": 1,
104+
"atoms": [
105+
1,
106+
3
107+
]
108+
},
109+
{
110+
"type": 1,
111+
"atoms": [
112+
3,
113+
4
114+
]
115+
},
116+
{
117+
"type": 1,
118+
"atoms": [
119+
3,
120+
5
121+
]
122+
},
123+
{
124+
"type": 1,
125+
"atoms": [
126+
3,
127+
6
128+
]
129+
}
130+
],
131+
"sgroups": [
132+
{
133+
"type": "SUP",
134+
"atoms": [
135+
0,
136+
1,
137+
2,
138+
3,
139+
4,
140+
5,
141+
6
142+
],
143+
"name": "Boc",
144+
"id": 0,
145+
"attachmentPoints": [
146+
{
147+
"attachmentAtom": 0,
148+
"attachmentId": ""
149+
}
150+
]
151+
}
152+
]
153+
}
154+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
$RXN
2+
3+
-INDIGO- 0100000000
4+
5+
0 1
6+
$MOL
7+
8+
-INDIGO-01000000002D
9+
10+
7 6 0 0 0 0 0 0 0 0999 V2000
11+
9.3250 -3.8750 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
12+
9.8250 -3.0090 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
13+
9.8250 -4.7410 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
14+
10.8250 -3.0090 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
15+
11.8250 -3.0090 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
16+
10.8250 -2.0090 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
17+
10.8250 -4.0090 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
18+
1 2 1 0 0 0 0
19+
1 3 2 0 0 0 0
20+
2 4 1 0 0 0 0
21+
4 5 1 0 0 0 0
22+
4 6 1 0 0 0 0
23+
4 7 1 0 0 0 0
24+
M STY 1 1 SUP
25+
M SLB 1 1 1
26+
M SAL 1 7 1 2 3 4 5 6 7
27+
M SMT 1 Boc
28+
M SAP 1 1 1 0
29+
M SDI 1 4 0.0000 0.0000 0.0000 0.0000
30+
M SDI 1 4 0.0000 0.0000 0.0000 0.0000
31+
M END

core/indigo-core/molecule/src/molfile_saver.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,8 +1667,11 @@ void MolfileSaver::_writeCtab2000(Output& output, BaseMolecule& mol, bool query)
16671667
int leave_idx = 0;
16681668
if (superatom.attachment_points[j].lvidx > -1)
16691669
leave_idx = _atom_mapping[superatom.attachment_points[j].lvidx];
1670-
output.printf(" %3d %3d %c%c", _atom_mapping[superatom.attachment_points[j].aidx], leave_idx, superatom.attachment_points[j].apid[0],
1671-
superatom.attachment_points[j].apid[1]);
1670+
const int KApIdNumPlaces = 2;
1671+
std::string apid_str = superatom.attachment_points[j].apid.ptr();
1672+
if (apid_str.size() < KApIdNumPlaces)
1673+
apid_str = std::string(KApIdNumPlaces - apid_str.size(), ' ') + apid_str;
1674+
output.printf(" %3d %3d %.*s", _atom_mapping[superatom.attachment_points[j].aidx], leave_idx, KApIdNumPlaces, apid_str.c_str());
16721675
k++;
16731676
nrem--;
16741677
if ((k == 6) || (nrem == 0))

utils/indigo-service/backend/service/v2/validation.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class InputFormatSchema(Schema):
1616
"chemical/x-daylight-smiles",
1717
"chemical/x-cml",
1818
"chemical/x-inchi",
19+
"chemical/x-inchi-key",
1920
"chemical/x-iupac",
2021
"chemical/x-daylight-smarts",
2122
"chemical/x-inchi-aux",
@@ -228,12 +229,7 @@ def sim_min_range(self, data, **kwargs):
228229

229230
@validates_schema
230231
def sim_max_range(self, data, **kwargs):
231-
print(
232-
data,
233-
data.get("type"),
234-
data.get("max_sim"),
235-
data.get("min_sim"),
236-
)
232+
print(data, data.get("type"), data.get("max_sim"), data.get("min_sim"))
237233
if (
238234
data.get("type")
239235
and "sim" in data.get("type")

0 commit comments

Comments
 (0)