Skip to content
This repository was archived by the owner on Mar 21, 2025. It is now read-only.

Commit 8c17232

Browse files
authored
Prepare release v.0.0.10 (#11)
Improvements: - Combine graph descriptors and graph fingerprints - Add parallel processing - Add MØD rule apply (not testing yet due to conflict in conda) Bug fix: - MolToGraph adapted unsanitized rdkit.Mol * add graph_descriptors * update doc * prepare release * fix version * prepare release * prepare release 0.0.8 * update Molecule subpackage * update reaction cleaning * add graph fingerprint * update graph signature * add nx_to_gml function * update format package, transforming gml to nx and reverse; transformaing mol to nx and reverse * format * add new features, prepare release * fix format * combine graph descriptors, add parallel, fix MolToGraph * prepare release 0.0.10
1 parent fa4868b commit 8c17232

File tree

7 files changed

+267
-170
lines changed

7 files changed

+267
-170
lines changed

Test/SynGraph/Descriptor/test_graph_descriptors.py

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import unittest
22
import networkx as nx
3+
from synutility.SynIO.data_type import load_from_pickle
34
from synutility.SynGraph.Descriptor.graph_descriptors import GraphDescriptor
45

56

@@ -84,7 +85,9 @@ def setUp(self):
8485
self.graph.add_edge(35, 29, order=(0, 1.0), standard_order=-1.0)
8586
self.graph.add_edge(28, 29, order=(1.0, 0), standard_order=1.0)
8687
# Prepare the data dictionary
87-
self.data = [{"RC": self.graph}]
88+
self.data = {"RC": self.graph, "ITS": self.graph}
89+
90+
self.data_parallel = load_from_pickle("Data/test.pkl.gz")
8891

8992
def test_is_acyclic_graph(self):
9093
self.assertTrue(GraphDescriptor.is_acyclic_graph(self.acyclic_graph))
@@ -149,27 +152,43 @@ def test_get_element_count(self):
149152

150153
def test_get_descriptors(self):
151154
# Expected output after processing
152-
expected_output = [
153-
{
154-
"RC": self.graph,
155-
"topo": "Single Cyclic", # Adjust based on expected graph type analysis
156-
"cycle": [
157-
4
158-
], # Expected cycle results, to be filled after actual function implementation
159-
"atom_count": {"N": 1, "H": 1, "C": 1, "Br": 1},
160-
"rtype": "Elementary", # Expected reaction type
161-
"rstep": 1, # This should be based on the actual cycles count
162-
}
163-
]
155+
expected_output = {
156+
"RC": self.graph,
157+
"topo": "Single Cyclic", # Adjust based on expected graph type analysis
158+
"cycle": [
159+
4
160+
], # Expected cycle results, to be filled after actual function implementation
161+
"atom_count": {"N": 1, "H": 1, "C": 1, "Br": 1},
162+
"rtype": "Elementary", # Expected reaction type
163+
"rstep": 1, # This should be based on the actual cycles count
164+
}
164165

165166
# Run the descriptor function
166-
GraphDescriptor.get_descriptors(self.data, "RC")
167+
results = GraphDescriptor.get_descriptors(self.data, "RC")
168+
self.assertEqual(results["topo"], expected_output["topo"])
169+
self.assertEqual(results["cycle"], expected_output["cycle"])
170+
self.assertEqual(results["rstep"], expected_output["rstep"])
171+
self.assertEqual(results["atom_count"], expected_output["atom_count"])
172+
173+
def test_get_descriptors_parallel(self):
174+
# Expected output after processing
175+
expected_output = {
176+
"RC": self.graph,
177+
"topo": "Single Cyclic",
178+
"cycle": [4],
179+
"atom_count": {"N": 1, "H": 1, "C": 1, "Br": 1},
180+
"rtype": "Elementary",
181+
"rstep": 1,
182+
}
167183

168-
# Validate that the data has been enhanced correctly
169-
for obtained, expected in zip(self.data, expected_output):
170-
print("Hi", obtained)
171-
print("hiii", expected)
172-
self.assertDictEqual(obtained, expected)
184+
# Run the descriptor function
185+
results = GraphDescriptor.process_entries_in_parallel(
186+
self.data_parallel, "GraphRules", "ITSGraph", n_jobs=4
187+
)
188+
self.assertEqual(results[0]["topo"], expected_output["topo"])
189+
self.assertEqual(results[0]["cycle"], expected_output["cycle"])
190+
self.assertEqual(results[0]["rstep"], expected_output["rstep"])
191+
self.assertEqual(results[0]["atom_count"], expected_output["atom_count"])
173192

174193

175194
if __name__ == "__main__":

Test/SynGraph/Descriptor/test_graph_signature.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ def setUp(self):
1313

1414
def test_create_topology_signature(self):
1515
signature = GraphSignature(self.rc)
16-
self.assertEqual(signature.create_topology_signature(), "114")
16+
self.assertEqual(
17+
signature.create_topology_signature(
18+
topo="Single Cyclic", cycle=[4], rstep=1
19+
),
20+
"114",
21+
)
1722

1823
def test_create_node_signature(self):
1924
signature = GraphSignature(self.rc)
@@ -36,7 +41,10 @@ def test_create_graph_signature(self):
3641
edge_signature = "Br[-1]H/Br[1]C/C[-1]N/H[1]N"
3742
topo_signature = "114"
3843
expected = f"{topo_signature}.{node_signature}.{edge_signature}"
39-
self.assertEqual(signature.create_graph_signature(), expected)
44+
self.assertEqual(
45+
signature.create_graph_signature(topo="Single Cyclic", cycle=[4], rstep=1),
46+
expected,
47+
)
4048

4149

4250
# Running the tests

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "synutility"
7-
version = "0.0.9"
7+
version = "0.0.10"
88
authors = [
99
{name="Tieu Long Phan", email="tieu@bioinf.uni-leipzig.de"}
1010
]

0 commit comments

Comments
 (0)