From 7c696ca24588ecdb9a550a2dacdf4f0dda9c3383 Mon Sep 17 00:00:00 2001 From: Aliaksandr Dziarkach <18146690+AliaksandrDziarkach@users.noreply.github.com> Date: Wed, 27 Sep 2023 00:26:18 +0300 Subject: [PATCH] #1285 Add new query properties support to KET format Fix C++ UTs --- core/indigo-core/tests/tests/formats.cpp | 30 +---- .../basic/ket_with_query_properties.ket | 126 ++++++++++++++++++ 2 files changed, 129 insertions(+), 27 deletions(-) create mode 100644 data/molecules/basic/ket_with_query_properties.ket diff --git a/core/indigo-core/tests/tests/formats.cpp b/core/indigo-core/tests/tests/formats.cpp index db7187c5dd..9a820fe611 100644 --- a/core/indigo-core/tests/tests/formats.cpp +++ b/core/indigo-core/tests/tests/formats.cpp @@ -350,22 +350,7 @@ TEST_F(IndigoCoreFormatsTest, json_load_save) { QueryMolecule q_mol; - char* ket = R"({"root":{"nodes":[{"$ref":"mol0"},{"$ref":"mol1"}]},"mol0":{"type":"molecule","atoms":[ -{"label":"C","location":[6.872400427225807,-8.203302184026775,0]},{"label":"C","location":[8.183693207880431,-9.188796758369131,0]}, -{"label":"C","location":[7.549396700010967,-8.661999658659791,0]},{"label":"C","location":[6.355203274663791,-8.661999658659791,0]}, -{"label":"C","location":[6.183604219405395,-7.66270516029316,0]},{"label":"C","location":[8.01389414271216,-8.184302288631033,0]}, -{"label":"C","location":[5.716306792119568,-9.537294839706838,0]},{"label":"C","location":[6.478602595286669,-9.074097389848514,0]}], -"bonds":[{"type":1,"atoms":[1,2]},{"type":1,"atoms":[3,4]},{"type":1,"atoms":[4,0]},{"type":1,"atoms":[0,5]},{"type":1,"atoms":[5,1]}, -{"type":1,"atoms":[3,6]},{"type":1,"atoms":[0,7]},{"type":1,"atoms":[6,7]},{"type":1,"atoms":[3,2]}]}, -"mol1":{"type":"molecule","atoms":[{"label":"C","location":[4.759849152128566,-4.125074417174607,0]}, -{"label":"C","location":[6.490150847871433,-4.124589229177203,0]},{"label":"C","location":[5.626637509491239,-3.6249668888501874,0]}, -{"label":"C","location":[6.490150847871433,-5.125532067822148,0]},{"label":"C","location":[4.759849152128566,-5.130020056798137,0]}, -{"label":"C","location":[5.6288208554795585,-5.625033111149812,0]}],"bonds":[{"type":2,"atoms":[2,0]},{"type":2,"atoms":[3,1]}, -{"type":1,"atoms":[0,4]},{"type":1,"atoms":[1,2]},{"type":2,"atoms":[4,5]},{"type":1,"atoms":[5,3]}], -"sgroups":[{"type":"DAT","atoms":[0,1,2,3,4,5],"context":"Fragment","fieldName":"2323fc","fieldData":"22","bonds":[0,1,2,3,4,5]}]}})"; - - BufferScanner scanner(ket); - FileScanner sc(dataPath("ket_with_query_properties.ket").c_str()); + FileScanner sc(dataPath("molecules/basic/ket_with_query_properties.ket").c_str()); std::string json; sc.readAll(json); rapidjson::Document data; @@ -374,24 +359,15 @@ TEST_F(IndigoCoreFormatsTest, json_load_save) if (data.HasMember("root")) { MoleculeJsonLoader loader(data); - /** - loader.stereochemistry_options = stereochemistry_options; - loader.ignore_noncritical_query_features = ignore_noncritical_query_features; - loader.treat_x_as_pseudoatom = treat_x_as_pseudoatom; - loader.skip_3d_chirality = skip_3d_chirality; - loader.ignore_no_chiral_flag = ignore_no_chiral_flag; - loader.treat_stereo_as = treat_stereo_as; - //*/ loader.loadMolecule(q_mol); - // return; } } Array out; ArrayOutput std_out(out); MoleculeJsonSaver saver(std_out); + saver.pretty_json = true; saver.saveMolecule(q_mol); std::string json_out{out.ptr(), static_cast(out.size())}; - printf(json_out.c_str()); - // ASSERT_EQ(json, json_out); + ASSERT_EQ(json, json_out); } diff --git a/data/molecules/basic/ket_with_query_properties.ket b/data/molecules/basic/ket_with_query_properties.ket new file mode 100644 index 0000000000..3752098544 --- /dev/null +++ b/data/molecules/basic/ket_with_query_properties.ket @@ -0,0 +1,126 @@ +{ + "root": { + "nodes": [ + { + "$ref": "mol0" + } + ] + }, + "mol0": { + "type": "molecule", + "atoms": [ + { + "label": "C", + "location": [ + 6.3348493576049809, + -5.550074577331543, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 8.06515121459961, + -5.549589157104492, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 7.2016377449035648, + -5.049966812133789, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 8.06515121459961, + -6.55053186416626, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 6.3348493576049809, + -6.555019855499268, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 7.203820705413818, + -7.050033092498779, + 0.0 + ], + "queryProperties": { + "aromaticity": "aliphatic", + "connectivity": 5, + "ringMembership": 3, + "ringSize": 4 + } + } + ], + "bonds": [ + { + "type": 2, + "atoms": [ + 2, + 0 + ] + }, + { + "type": 2, + "atoms": [ + 3, + 1 + ] + }, + { + "type": 1, + "atoms": [ + 0, + 4 + ] + }, + { + "type": 1, + "atoms": [ + 1, + 2 + ] + }, + { + "type": 2, + "atoms": [ + 4, + 5 + ] + }, + { + "type": 1, + "atoms": [ + 5, + 3 + ] + } + ], + "sgroups": [ + { + "type": "MUL", + "atoms": [ + 0, + 1, + 2, + 3, + 4, + 5 + ], + "mul": 1 + } + ] + } +} \ No newline at end of file