Skip to content

Commit

Permalink
#1285 Add new query properties support to KET format
Browse files Browse the repository at this point in the history
Fix C++ UTs
  • Loading branch information
AliaksandrDziarkach committed Sep 26, 2023
1 parent e1135fc commit 7c696ca
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 27 deletions.
30 changes: 3 additions & 27 deletions core/indigo-core/tests/tests/formats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<char> 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<std::size_t>(out.size())};
printf(json_out.c_str());
// ASSERT_EQ(json, json_out);
ASSERT_EQ(json, json_out);
}
126 changes: 126 additions & 0 deletions data/molecules/basic/ket_with_query_properties.ket
Original file line number Diff line number Diff line change
@@ -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
}
]
}
}

0 comments on commit 7c696ca

Please sign in to comment.