Skip to content

Commit

Permalink
#2031 - Build a data structure for a reaction tree (#2201)
Browse files Browse the repository at this point in the history
Co-authored-by: Ilya Zaytsev <ilya_zaytsev@epam.com>
  • Loading branch information
nupagadi and Ilya Zaytsev authored Aug 12, 2024
1 parent 5561a82 commit f56299d
Show file tree
Hide file tree
Showing 17 changed files with 693 additions and 191 deletions.
6 changes: 5 additions & 1 deletion api/tests/integration/ref/reaction/pathway.py.out
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
{"root":{"nodes":[{"$ref":"mol0"},{"$ref":"mol1"},{"$ref":"mol2"},{"$ref":"mol3"},{"$ref":"mol4"},{"$ref":"mol5"}]},"mol0":{"type":"molecule","atoms":[{"label":"C","location":[3.0799999237060549,-1.3640999794006348,0.0]},{"label":"C","location":[2.309999942779541,-0.030399978160858156,0.0]},{"label":"C","location":[0.7699999809265137,-0.030399978160858156,0.0]},{"label":"C","location":[0.0,-1.3640999794006348,0.0]},{"label":"C","location":[0.7699999809265137,-2.6977999210357668,0.0]},{"label":"C","location":[2.309999942779541,-2.6977999210357668,0.0]},{"label":"C","location":[3.0799999237060549,1.3033000230789185,0.0]},{"label":"O","location":[2.3039000034332277,2.6977999210357668,0.0]},{"label":"O","location":[4.563899993896484,1.3266000747680665,0.0]}],"bonds":[{"type":1,"atoms":[0,1]},{"type":2,"atoms":[1,2]},{"type":1,"atoms":[2,3]},{"type":2,"atoms":[3,4]},{"type":1,"atoms":[4,5]},{"type":2,"atoms":[5,0]},{"type":2,"atoms":[6,7]},{"type":1,"atoms":[6,8]},{"type":1,"atoms":[1,6]}]},"mol1":{"type":"molecule","atoms":[{"label":"C","location":[17.643901824951173,-0.6668999791145325,0.0]},{"label":"C","location":[16.8739013671875,0.6668000221252441,0.0]},{"label":"C","location":[15.333901405334473,0.6668000221252441,0.0]},{"label":"C","location":[14.5639009475708,-0.6668999791145325,0.0]},{"label":"C","location":[15.333901405334473,-2.000499963760376,0.0]},{"label":"C","location":[16.8739013671875,-2.000499963760376,0.0]},{"label":"N","location":[17.643901824951173,2.000499963760376,0.0]}],"bonds":[{"type":1,"atoms":[0,1]},{"type":2,"atoms":[1,2]},{"type":1,"atoms":[2,3]},{"type":2,"atoms":[3,4]},{"type":1,"atoms":[4,5]},{"type":2,"atoms":[5,0]},{"type":1,"atoms":[1,6]}]},"mol2":{"type":"molecule","atoms":[{"label":"C","location":[3.0799999237060549,-11.364099502563477,0.0]},{"label":"C","location":[2.309999942779541,-10.030400276184082,0.0]},{"label":"C","location":[0.7699999809265137,-10.030400276184082,0.0]},{"label":"C","location":[0.0,-11.364099502563477,0.0]},{"label":"C","location":[0.7699999809265137,-12.697799682617188,0.0]},{"label":"C","location":[2.309999942779541,-12.697799682617188,0.0]},{"label":"C","location":[3.0799999237060549,-8.696700096130371,0.0]},{"label":"O","location":[2.3039000034332277,-7.3022003173828129,0.0]},{"label":"O","location":[4.563899993896484,-8.673399925231934,0.0]}],"bonds":[{"type":1,"atoms":[0,1]},{"type":2,"atoms":[1,2]},{"type":1,"atoms":[2,3]},{"type":2,"atoms":[3,4]},{"type":1,"atoms":[4,5]},{"type":2,"atoms":[5,0]},{"type":2,"atoms":[6,7]},{"type":1,"atoms":[6,8]},{"type":1,"center":4,"atoms":[1,6]}]},"mol3":{"type":"molecule","atoms":[{"label":"C","location":[17.643798828125,-10.666899681091309,0.0]},{"label":"C","location":[16.87380027770996,-9.333200454711914,0.0]},{"label":"C","location":[15.33389949798584,-9.333200454711914,0.0]},{"label":"C","location":[14.563899993896485,-10.666899681091309,0.0]},{"label":"C","location":[15.33389949798584,-12.000499725341797,0.0]},{"label":"C","location":[16.87380027770996,-12.000499725341797,0.0]},{"label":"N","location":[17.643798828125,-7.999500274658203,0.0]}],"bonds":[{"type":1,"atoms":[0,1]},{"type":2,"atoms":[1,2]},{"type":1,"atoms":[2,3]},{"type":2,"atoms":[3,4]},{"type":1,"atoms":[4,5]},{"type":2,"atoms":[5,0]},{"type":1,"center":4,"atoms":[1,6]}]},"mol4":{"type":"molecule","atoms":[{"label":"O","location":[0.0,-20.206249237060548,0.0],"mapping":1},{"label":"O","location":[0.7125000953674316,-19.793750762939454,0.0],"mapping":2}],"bonds":[{"type":1,"center":2,"atoms":[0,1]}]},"mol5":{"type":"molecule","atoms":[{"label":"O","location":[10.712499618530274,-20.206249237060548,0.0],"mapping":1},{"label":"O","location":[11.424999237060547,-19.793750762939454,0.0],"mapping":2}],"bonds":[{"type":1,"center":2,"atoms":[0,1]}]}}
pathway1.rdf:SUCCEED
pathway2.rdf:SUCCEED
pathway3.rdf:SUCCEED
pathway4.rdf:SUCCEED
pathway5.rdf:SUCCEED
33 changes: 22 additions & 11 deletions api/tests/integration/tests/reaction/pathway.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import errno
import difflib
import os
import sys


def find_diff(a, b):
return "\n".join(difflib.unified_diff(a.splitlines(), b.splitlines()))


sys.path.append(
os.path.normpath(
os.path.join(os.path.abspath(__file__), "..", "..", "..", "common")
Expand All @@ -10,16 +15,22 @@
from env_indigo import *

indigo = Indigo()
input_path = joinPathPy("reactions/", __file__)
ref_path = joinPathPy("ref/", __file__)

if not os.path.exists(joinPathPy("out", __file__)):
try:
os.makedirs(joinPathPy("out", __file__))
except OSError as e:
if e.errno != errno.EEXIST:
raise
files = ["pathway1", "pathway2", "pathway3", "pathway4", "pathway5"]

r1 = indigo.loadReactionFromFile(
joinPathPy("reactions/pathway_simple.rdf", __file__)
)
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()

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

-INDIGO- 0808240900

2 1
$MOL

-INDIGO-08082409002D

6 6 0 0 0 0 0 0 0 0999 V2000
0.0560 -6.4789 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1.7863 -6.4784 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.9228 -5.9788 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1.7863 -7.4794 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.0560 -7.4839 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.9250 -7.9789 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-08082409002D

5 5 0 0 0 0 0 0 0 0999 V2000
6.2577 -6.2569 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
6.7581 -7.7970 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
7.0674 -6.8507 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
5.7574 -7.7970 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
5.4480 -6.8507 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-08082409002D

7 7 0 0 0 0 0 0 0 0999 V2000
12.1705 -6.6231 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
12.1705 -7.6231 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
13.0365 -8.1231 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
13.9026 -7.6231 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
13.9026 -6.6231 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
13.0365 -6.1231 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
14.7686 -6.1231 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
5 7 1 0 0 0 0
M END

$RFMT
$RXN

-INDIGO- 0809241137

3 1
$MOL

-INDIGO-08092411372D

7 7 0 0 0 0 0 0 0 0999 V2000
11.6489 -9.0554 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
11.6489 -10.0554 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
12.5149 -10.5554 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
13.3810 -10.0554 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
13.3810 -9.0554 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
12.5149 -8.5554 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
14.2470 -8.5554 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
5 7 1 0 0 0 0
M END
$MOL

-INDIGO-08092411372D

7 7 0 0 0 0 0 0 0 0999 V2000
19.5343 -8.8815 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
20.0347 -10.4216 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
20.3439 -9.4753 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
19.0339 -10.4216 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
18.7246 -9.4753 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
19.5343 -7.8815 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
20.5343 -7.8815 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
1 6 2 0 0 0 0
6 7 1 0 0 0 0
M END
$MOL

-INDIGO-08092411372D

8 8 0 0 0 0 0 0 0 0999 V2000
5.9649 -9.1617 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
6.7488 -8.5442 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
7.7218 -8.7667 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
8.1559 -9.6625 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
5.9704 -10.1689 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
7.7225 -10.5696 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
6.7488 -10.7921 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
4.9990 -8.9029 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
2 1 1 0 0 0 0
1 5 1 0 0 0 0
5 7 1 0 0 0 0
7 6 1 0 0 0 0
6 4 1 0 0 0 0
4 3 1 0 0 0 0
3 2 1 0 0 0 0
1 8 1 0 0 0 0
M END
$MOL

-INDIGO-08092411372D

9 9 0 0 0 0 0 0 0 0999 V2000
26.4095 -9.2478 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
28.1398 -9.2473 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
27.2763 -8.7477 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
28.1398 -10.2482 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
26.4095 -10.2527 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
27.2785 -10.7477 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
25.5435 -10.7527 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
26.5714 -11.4548 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
28.8469 -10.9553 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
5 7 1 0 0 0 0
6 8 2 0 0 0 0
4 9 1 0 0 0 0
M END

132 changes: 132 additions & 0 deletions api/tests/integration/tests/reaction/reactions/pathway2.rdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
$RDFILE 1
$RFMT
$RXN

-INDIGO- 0808240900

2 1
$MOL

-INDIGO-08082409002D

6 6 0 0 0 0 0 0 0 0999 V2000
0.0560 -6.4789 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1.7863 -6.4784 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.9228 -5.9788 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1.7863 -7.4794 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.0560 -7.4839 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.9250 -7.9789 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-08082409002D

5 5 0 0 0 0 0 0 0 0999 V2000
6.2577 -6.2569 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
6.7581 -7.7970 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
7.0674 -6.8507 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
5.7574 -7.7970 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
5.4480 -6.8507 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-08082409002D

7 7 0 0 0 0 0 0 0 0999 V2000
12.1705 -6.6231 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
12.1705 -7.6231 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
13.0365 -8.1231 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
13.9026 -7.6231 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
13.9026 -6.6231 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
13.0365 -6.1231 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
14.7686 -6.1231 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
5 7 1 0 0 0 0
M END

$RFMT
$RXN

-INDIGO- 0808240901

2 1
$MOL

-INDIGO-08082409012D

7 7 0 0 0 0 0 0 0 0999 V2000
12.1705 -6.6231 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
12.1705 -7.6231 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
13.0365 -8.1231 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
13.9026 -7.6231 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
13.9026 -6.6231 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
13.0365 -6.1231 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
14.7686 -6.1231 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
5 7 1 0 0 0 0
M END
$MOL

-INDIGO-08082409012D

7 7 0 0 0 0 0 0 0 0999 V2000
20.0558 -6.4492 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
20.5562 -7.9893 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
20.8654 -7.0430 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
19.5554 -7.9893 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
19.2461 -7.0430 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
20.0558 -5.4492 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
21.0558 -5.4492 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
1 6 2 0 0 0 0
6 7 1 0 0 0 0
M END
$MOL

-INDIGO-08082409012D

9 9 0 0 0 0 0 0 0 0999 V2000
26.9310 -6.8155 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
28.6613 -6.8150 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
27.7978 -6.3154 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
28.6613 -7.8159 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
26.9310 -7.8204 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
27.8000 -8.3154 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
26.0650 -8.3204 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
27.0929 -9.0225 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
29.3684 -8.5230 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
5 7 1 0 0 0 0
6 8 2 0 0 0 0
4 9 1 0 0 0 0
M END
Loading

0 comments on commit f56299d

Please sign in to comment.