Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2236 Import/export multi-tails in KET #2295

Merged
merged 26 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion api/c/indigo/src/indigo_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ CEXPORT int indigoLayout(int object)
else if (IndigoBaseReaction::is(obj))
{
BaseReaction& rxn = obj.getBaseReaction();
bool no_layout = rxn.intermediateCount() || rxn.specialConditionsCount() || rxn.meta().getNonChemicalMetaCount();
bool no_layout = rxn.intermediateCount() || rxn.specialConditionsCount() || rxn.meta().getNonChemicalMetaCount() ||
obj.type == IndigoObject::PATHWAY_REACTION || rxn.multitaleCount();
if (!no_layout)
{
ReactionLayout rl(rxn, self.smart_layout);
Expand Down
27 changes: 21 additions & 6 deletions api/c/indigo/src/indigo_savers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@
#include "molecule/sequence_saver.h"
#include "molecule/smiles_saver.h"
#include "reaction/canonical_rsmiles_saver.h"
#include "reaction/pathway_reaction.h"
#include "reaction/pathway_reaction_json_saver.h"
#include "reaction/reaction_cdxml_saver.h"
#include "reaction/reaction_cml_saver.h"
#include "reaction/reaction_json_saver.h"
#include "reaction/rsmiles_saver.h"
#include "reaction/rxnfile_loader.h"
#include "reaction/rxnfile_saver.h"

#include <memory>

#include "indigo_io.h"
Expand Down Expand Up @@ -706,12 +709,24 @@ CEXPORT int indigoSaveJson(int item, int output)
}
else if (IndigoBaseReaction::is(obj))
{
ReactionJsonSaver saver(out);
self.initReactionJsonSaver(saver);
BaseReaction& rxn = obj.getBaseReaction();
saver.saveReaction(rxn);
out.flush();
return 1;
if (obj.type == IndigoObject::PATHWAY_REACTION)
{
PathwayReactionJsonSaver jn(out);
self.initReactionJsonSaver(jn);
BaseReaction& br = obj.getBaseReaction();
jn.saveReaction(dynamic_cast<PathwayReaction&>(br));
out.flush();
return 1;
}
else
{
ReactionJsonSaver saver(out);
self.initReactionJsonSaver(saver);
BaseReaction& rxn = obj.getBaseReaction();
saver.saveReaction(rxn);
out.flush();
return 1;
}
}
else if (IndigoKetDocument::is(obj))
{
Expand Down
8 changes: 7 additions & 1 deletion api/tests/integration/tests/reaction/pathway.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,22 @@ def find_diff(a, b):
"pathway6",
"pathway7",
"pathway8",
"pathway9",
"pathway10",
]

for filename in files:
rxn = indigo.loadReactionFromFile(
os.path.join(input_path, filename + ".rdf")
)
rxn_ref = open(os.path.join(ref_path, filename) + ".ket", "r").read()

rxn_txt = rxn.json()

# with open(os.path.join(ref_path, filename) + ".ket", "w") as file:
# file.write(rxn_txt)

rxn_ref = open(os.path.join(ref_path, filename) + ".ket", "r").read()

diff = find_diff(rxn_ref, rxn_txt)
if not diff:
print(filename + ".rdf:SUCCEED")
Expand Down
279 changes: 279 additions & 0 deletions api/tests/integration/tests/reaction/reactions/pathway10.rdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,279 @@
$RDFILE 1
$RFMT
$RXN

-INDIGO- 0903241149

2 3
$MOL

-INDIGO-09032411492D

5 5 0 0 0 0 0 0 0 0999 V2000
5.1216 -4.8963 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
5.1179 -3.9012 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
4.1096 -4.8834 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
4.1071 -3.9012 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
3.4000 -3.1941 0.0000 F 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0
2 4 1 0 0 0 0
4 3 1 0 0 0 0
3 1 1 0 0 0 0
4 5 1 0 0 0 0
M END
$MOL

-INDIGO-09032411492D

4 4 0 0 0 0 0 0 0 0999 V2000
6.9387 -4.8812 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
7.9400 -4.8812 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
7.4394 -4.0163 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
7.4394 -3.0163 0.0000 Cl 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0
2 3 1 0 0 0 0
3 1 1 0 0 0 0
3 4 1 0 0 0 0
M END
$MOL

-INDIGO-09032411492D

6 6 0 0 0 0 0 0 0 0999 V2000
15.0894 -3.3537 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
15.5898 -4.8938 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
15.8990 -3.9476 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
14.5890 -4.8938 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
14.2797 -3.9476 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
15.0894 -2.3537 0.0000 S 0 0 0 0 0 0 0 0 0 0 0 0
1 5 1 0 0 0 0
5 4 2 0 0 0 0
4 2 1 0 0 0 0
2 3 2 0 0 0 0
3 1 1 0 0 0 0
1 6 1 0 0 0 0
M END
$MOL

-INDIGO-09032411492D

4 4 0 0 0 0 0 0 0 0999 V2000
17.6887 -4.6312 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
18.6900 -4.6312 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
18.1894 -3.7663 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
18.4482 -2.8004 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0
2 3 1 0 0 0 0
3 1 1 0 0 0 0
3 4 1 0 0 0 0
M END
$MOL

-INDIGO-09032411492D

5 5 0 0 0 0 0 0 0 0999 V2000
21.4966 -4.7213 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
21.4929 -3.7262 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
20.4846 -4.7084 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
20.4821 -3.7262 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
22.2000 -3.0191 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0
2 4 1 0 0 0 0
4 3 1 0 0 0 0
3 1 1 0 0 0 0
2 5 1 0 0 0 0
M END

$RFMT
$RXN

-INDIGO- 0903241151

2 2
$MOL

-INDIGO-09032411512D

5 5 0 0 0 0 0 0 0 0999 V2000
4.9844 -5.1799 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
5.4848 -6.7200 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
5.7940 -5.7738 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
4.4840 -6.7200 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
4.1747 -5.7738 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1 5 1 0 0 0 0
5 4 2 0 0 0 0
4 2 1 0 0 0 0
2 3 2 0 0 0 0
3 1 1 0 0 0 0
M END
$MOL

-INDIGO-09032411512D

6 6 0 0 0 0 0 0 0 0999 V2000
7.7442 -5.3751 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
9.4745 -5.3746 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
8.6110 -4.8750 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
9.4745 -6.3755 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
7.7442 -6.3800 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
8.6132 -6.8750 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
3 1 2 0 0 0 0
1 5 1 0 0 0 0
5 6 2 0 0 0 0
6 4 1 0 0 0 0
4 2 2 0 0 0 0
2 3 1 0 0 0 0
M END
$MOL

-INDIGO-09032411512D

5 5 0 0 0 0 0 0 0 0999 V2000
16.2665 -6.3225 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
16.2628 -5.3274 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
15.2546 -6.3096 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
15.2521 -5.3274 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
17.2288 -5.0686 0.0000 P 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0
2 4 1 0 0 0 0
4 3 1 0 0 0 0
3 1 1 0 0 0 0
2 5 1 0 0 0 0
M END
$MOL

-INDIGO-09032411512D

6 6 0 0 0 0 0 0 0 0999 V2000
19.7433 -5.3250 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
19.7433 -6.3250 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
20.6093 -6.8250 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
21.4753 -6.3250 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
21.4753 -5.3250 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
20.6093 -4.8250 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
6 1 1 0 0 0 0
1 2 1 0 0 0 0
2 3 1 0 0 0 0
3 4 1 0 0 0 0
4 5 1 0 0 0 0
5 6 1 0 0 0 0
M END

$RFMT
$RXN

-INDIGO- 0903241152

5 1
$MOL

-INDIGO-09032411522D

4 4 0 0 0 0 0 0 0 0999 V2000
2.3905 -7.2966 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
3.3917 -7.2966 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
2.8912 -6.4316 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
3.1500 -5.4657 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0
2 3 1 0 0 0 0
3 1 1 0 0 0 0
3 4 1 0 0 0 0
M END
$MOL

-INDIGO-09032411522D

6 6 0 0 0 0 0 0 0 0999 V2000
6.3501 -5.7811 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
6.3501 -6.7811 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
7.2161 -7.2811 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
8.0821 -6.7811 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
8.0821 -5.7811 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
7.2161 -5.2811 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
6 1 1 0 0 0 0
1 2 1 0 0 0 0
2 3 1 0 0 0 0
3 4 1 0 0 0 0
4 5 1 0 0 0 0
5 6 1 0 0 0 0
M END
$MOL

-INDIGO-09032411522D

5 5 0 0 0 0 0 0 0 0999 V2000
11.2466 -6.8822 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
11.2429 -5.8871 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
10.2347 -6.8693 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
10.2322 -5.8871 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
11.9500 -5.1800 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0
2 4 1 0 0 0 0
4 3 1 0 0 0 0
3 1 1 0 0 0 0
2 5 1 0 0 0 0
M END
$MOL

-INDIGO-09032411522D

6 6 0 0 0 0 0 0 0 0999 V2000
14.7162 -5.7111 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
15.2166 -7.2512 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
15.5258 -6.3049 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
14.2158 -7.2512 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
13.9064 -6.3049 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
14.7162 -4.7111 0.0000 S 0 0 0 0 0 0 0 0 0 0 0 0
1 5 1 0 0 0 0
5 4 2 0 0 0 0
4 2 1 0 0 0 0
2 3 2 0 0 0 0
3 1 1 0 0 0 0
1 6 1 0 0 0 0
M END
$MOL

-INDIGO-09032411522D

5 5 0 0 0 0 0 0 0 0999 V2000
18.5922 -6.8581 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
18.5885 -5.8630 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
17.5803 -6.8452 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
17.5778 -5.8630 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
19.5544 -5.6042 0.0000 P 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0
2 4 1 0 0 0 0
4 3 1 0 0 0 0
3 1 1 0 0 0 0
2 5 1 0 0 0 0
M END
$MOL

-INDIGO-09032411522D

12 12 0 0 1 0 0 0 0 0999 V2000
30.0095 -4.9233 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
30.0095 -6.7984 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
28.1901 -7.7389 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
26.3706 -6.7985 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
28.1845 -4.9233 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
25.5727 -5.5176 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
29.0997 -5.3824 0.0000 C 0 0 1 0 0 0 0 0 0 0 0 0
29.0997 -6.3338 0.0000 C 0 0 1 0 0 0 0 0 0 0 0 0
28.1845 -6.7985 0.0000 C 0 0 1 0 0 0 0 0 0 0 0 0
27.2749 -6.3340 0.0000 C 0 0 1 0 0 0 0 0 0 0 0 0
27.2749 -5.3825 0.0000 C 0 0 1 0 0 0 0 0 0 0 0 0
26.3706 -4.9235 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
6 12 1 0 0 0 0
11 5 1 0 0 0 0
5 7 1 0 0 0 0
7 8 1 0 0 0 0
8 9 1 0 0 0 0
9 10 1 0 0 0 0
10 11 1 0 0 0 0
11 12 1 1 0 0 0
7 1 1 6 0 0 0
8 2 1 6 0 0 0
9 3 1 6 0 0 0
10 4 1 6 0 0 0
M END
Loading