diff --git a/api/tests/integration/ref/formats/ket_to_mol.py.out b/api/tests/integration/ref/formats/ket_to_mol.py.out index 3ac95c31be..d35f29db50 100644 --- a/api/tests/integration/ref/formats/ket_to_mol.py.out +++ b/api/tests/integration/ref/formats/ket_to_mol.py.out @@ -1,3 +1,4 @@ *** KET to MOL *** suplabel.ket:SUCCEED +empty_apid.ket:SUCCEED ket-reaction-arrow.ket:SUCCEED diff --git a/api/tests/integration/tests/formats/ket_to_mol.py b/api/tests/integration/tests/formats/ket_to_mol.py index 0960c6e009..ea2bc685de 100644 --- a/api/tests/integration/tests/formats/ket_to_mol.py +++ b/api/tests/integration/tests/formats/ket_to_mol.py @@ -24,9 +24,7 @@ def find_diff(a, b): ref_path = joinPathPy("ref/", __file__) root_rea = joinPathPy("reactions/", __file__) -files = [ - "suplabel", -] +files = ["suplabel"] files.sort() for filename in files: @@ -41,16 +39,17 @@ def find_diff(a, b): print(filename + ".ket:FAILED") print(diff) -files = [ - "ket-reaction-arrow", -] +files = ["ket-reaction-arrow", "empty_apid"] files.sort() for filename in files: rc = indigo.loadReactionFromFile(os.path.join(root_rea, filename + ".ket")) + ket = rc.rxnfile() + # with open(os.path.join(ref_path, filename) + ".mol", "w") as file: + # file.write(ket) + with open(os.path.join(ref_path, filename) + ".mol", "r") as file: ket_ref = file.read() - ket = rc.rxnfile() diff = find_diff(ket_ref, ket) if not diff: print(filename + ".ket:SUCCEED") diff --git a/api/tests/integration/tests/formats/reactions/empty_apid.ket b/api/tests/integration/tests/formats/reactions/empty_apid.ket new file mode 100644 index 0000000000..0498ed2928 --- /dev/null +++ b/api/tests/integration/tests/formats/reactions/empty_apid.ket @@ -0,0 +1,154 @@ +{ + "root": { + "nodes": [ + { + "$ref": "mol0" + }, + { + "type": "arrow", + "data": { + "mode": "open-angle", + "pos": [ + { + "x": 3.1, + "y": -4.575, + "z": 0 + }, + { + "x": 7.804253394535632, + "y": -4.575, + "z": 0 + } + ] + } + } + ] + }, + "mol0": { + "type": "molecule", + "atoms": [ + { + "label": "C", + "location": [ + 9.325000000000001, + -3.875, + 0 + ] + }, + { + "label": "O", + "location": [ + 9.825003666733892, + -3.008993649216902, + 0 + ] + }, + { + "label": "O", + "location": [ + 9.825003666733892, + -4.741006350783098, + 0 + ] + }, + { + "label": "C", + "location": [ + 10.825011000201673, + -3.008993649216902, + 0 + ] + }, + { + "label": "C", + "location": [ + 11.825018333669453, + -3.008993649216902, + 0 + ] + }, + { + "label": "C", + "location": [ + 10.825011000201673, + -2.008986315749121, + 0 + ] + }, + { + "label": "C", + "location": [ + 10.825011000201673, + -4.009000982684682, + 0 + ] + } + ], + "bonds": [ + { + "type": 1, + "atoms": [ + 0, + 1 + ] + }, + { + "type": 2, + "atoms": [ + 0, + 2 + ] + }, + { + "type": 1, + "atoms": [ + 1, + 3 + ] + }, + { + "type": 1, + "atoms": [ + 3, + 4 + ] + }, + { + "type": 1, + "atoms": [ + 3, + 5 + ] + }, + { + "type": 1, + "atoms": [ + 3, + 6 + ] + } + ], + "sgroups": [ + { + "type": "SUP", + "atoms": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6 + ], + "name": "Boc", + "id": 0, + "attachmentPoints": [ + { + "attachmentAtom": 0, + "attachmentId": "" + } + ] + } + ] + } +} \ No newline at end of file diff --git a/api/tests/integration/tests/formats/ref/empty_apid.mol b/api/tests/integration/tests/formats/ref/empty_apid.mol new file mode 100644 index 0000000000..1d7ef90553 --- /dev/null +++ b/api/tests/integration/tests/formats/ref/empty_apid.mol @@ -0,0 +1,31 @@ +$RXN + + -INDIGO- 0100000000 + + 0 1 +$MOL + + -INDIGO-01000000002D + + 7 6 0 0 0 0 0 0 0 0999 V2000 + 9.3250 -3.8750 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 9.8250 -3.0090 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 + 9.8250 -4.7410 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 + 10.8250 -3.0090 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 11.8250 -3.0090 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 10.8250 -2.0090 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 10.8250 -4.0090 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 0 0 0 0 + 1 3 2 0 0 0 0 + 2 4 1 0 0 0 0 + 4 5 1 0 0 0 0 + 4 6 1 0 0 0 0 + 4 7 1 0 0 0 0 +M STY 1 1 SUP +M SLB 1 1 1 +M SAL 1 7 1 2 3 4 5 6 7 +M SMT 1 Boc +M SAP 1 1 1 0 +M SDI 1 4 0.0000 0.0000 0.0000 0.0000 +M SDI 1 4 0.0000 0.0000 0.0000 0.0000 +M END diff --git a/core/indigo-core/molecule/src/molfile_saver.cpp b/core/indigo-core/molecule/src/molfile_saver.cpp index 66b3054629..c39f250ff1 100644 --- a/core/indigo-core/molecule/src/molfile_saver.cpp +++ b/core/indigo-core/molecule/src/molfile_saver.cpp @@ -1667,8 +1667,11 @@ void MolfileSaver::_writeCtab2000(Output& output, BaseMolecule& mol, bool query) int leave_idx = 0; if (superatom.attachment_points[j].lvidx > -1) leave_idx = _atom_mapping[superatom.attachment_points[j].lvidx]; - output.printf(" %3d %3d %c%c", _atom_mapping[superatom.attachment_points[j].aidx], leave_idx, superatom.attachment_points[j].apid[0], - superatom.attachment_points[j].apid[1]); + const int KApIdNumPlaces = 2; + std::string apid_str = superatom.attachment_points[j].apid.ptr(); + if (apid_str.size() < KApIdNumPlaces) + apid_str = std::string(KApIdNumPlaces - apid_str.size(), ' ') + apid_str; + output.printf(" %3d %3d %.*s", _atom_mapping[superatom.attachment_points[j].aidx], leave_idx, KApIdNumPlaces, apid_str.c_str()); k++; nrem--; if ((k == 6) || (nrem == 0)) diff --git a/utils/indigo-service/backend/service/v2/validation.py b/utils/indigo-service/backend/service/v2/validation.py index 4464e255f8..dd5b0194e1 100644 --- a/utils/indigo-service/backend/service/v2/validation.py +++ b/utils/indigo-service/backend/service/v2/validation.py @@ -16,6 +16,7 @@ class InputFormatSchema(Schema): "chemical/x-daylight-smiles", "chemical/x-cml", "chemical/x-inchi", + "chemical/x-inchi-key", "chemical/x-iupac", "chemical/x-daylight-smarts", "chemical/x-inchi-aux", @@ -228,12 +229,7 @@ def sim_min_range(self, data, **kwargs): @validates_schema def sim_max_range(self, data, **kwargs): - print( - data, - data.get("type"), - data.get("max_sim"), - data.get("min_sim"), - ) + print(data, data.get("type"), data.get("max_sim"), data.get("min_sim")) if ( data.get("type") and "sim" in data.get("type")