-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update curate oxidation and reduction
- Loading branch information
1 parent
6c7b08b
commit 3586276
Showing
12 changed files
with
827 additions
and
413 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import unittest | ||
from synrbl.SynChemImputer.curate_oxidation import CurationOxidation | ||
|
||
|
||
class TestCurationOxidation(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.curate = CurationOxidation() | ||
self.data = [ | ||
{"R-id": "alcohol_carbonyl", "reactions": "CCO.[O]>>CC=O"}, | ||
{"R-id": "alcohol_acid", "reactions": "CCO.[O]>>CC(=O)O"}, | ||
{"R-id": "carbonyl_acid", "reactions": "CC=O.[O]>>CC(=O)O"}, | ||
] | ||
|
||
def test_alcohol_carbonyl(self): | ||
result = self.curate.process_dict( | ||
self.data[0], | ||
"reactions", | ||
return_all=True, | ||
compounds_template=self.curate.compounds_template, | ||
reaction_templates=self.curate.reaction_templates, | ||
) | ||
self.assertEqual( | ||
result["curated_reaction"][0], | ||
"CCO.O=[Cr](Cl)(-[O-])=O.c1cc[nH+]cc1>>CC=O.O=[Cr](O)O.c1cc[nH+]cc1.[Cl-]", | ||
) | ||
self.assertEqual(result["stoichiometric"][0], [1]) | ||
|
||
def test_alcohol_acid(self): | ||
result = self.curate.process_dict( | ||
self.data[1], | ||
"reactions", | ||
return_all=True, | ||
compounds_template=self.curate.compounds_template, | ||
reaction_templates=self.curate.reaction_templates, | ||
) | ||
print(result["curated_reaction"][0]) | ||
self.assertEqual( | ||
result["curated_reaction"][0], | ||
( | ||
"CCO.[K][O][Mn](=O)(=O)=O.OS(=O)(=O)O>>" | ||
+ "CC(=O)O.[K][O]S(=O)(=O)[O][K].[Mn]1[O]S(=O)(=O)[O]1" | ||
), | ||
) | ||
self.assertEqual(result["stoichiometric"][0], [5, 4, 6, 5, 11, 2, 4]) | ||
|
||
def test_aldehyde_acid(self): | ||
result = self.curate.process_dict( | ||
self.data[2], | ||
"reactions", | ||
return_all=True, | ||
compounds_template=self.curate.compounds_template, | ||
reaction_templates=self.curate.reaction_templates, | ||
) | ||
self.assertEqual( | ||
result["curated_reaction"][0], | ||
"CC=O.O=[Mn](=O)(=O)O[K].O>>CC(=O)O.O=[Mn]=O.O[K]", | ||
) | ||
self.assertEqual(result["stoichiometric"][0], [5, 4, 6, 5, 4, 1]) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
import unittest | ||
from synrbl.SynChemImputer.curate_reduction import CurationReduction | ||
|
||
|
||
class TestCurationReduction(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.curate = CurationReduction() | ||
self.data = [ | ||
{"R-id": "aldehyde", "reactions": "CC=O.[H].[H]>>CCO"}, | ||
{"R-id": "ketone", "reactions": "CC(=O)C.[H].[H]>>CC(O)C"}, | ||
{"R-id": "acid", "reactions": "CC(=O)O.[H].[H].[H].[H]>>CCO.O"}, | ||
{"R-id": "ester", "reactions": "CC(=O)OC.[H].[H].[H].[H]>>CCO.CO"}, | ||
] | ||
|
||
def test_aldehyde(self): | ||
result_ion = self.curate.process_dict( | ||
self.data[0], | ||
"reactions", | ||
return_all=True, | ||
neutralize=False, | ||
compounds_template=self.curate.compounds_template, | ||
reaction_templates=self.curate.reaction_templates, | ||
) | ||
self.assertEqual( | ||
result_ion["curated_reaction"][1], "CC=O.[BH4-].[Na+].[H+]>>CCO.[BH3].[Na+]" | ||
) | ||
|
||
result_neutral = self.curate.process_dict( | ||
self.data[0], | ||
"reactions", | ||
return_all=True, | ||
neutralize=True, | ||
compounds_template=self.curate.compounds_template, | ||
reaction_templates=self.curate.reaction_templates, | ||
) | ||
self.assertEqual( | ||
result_neutral["curated_reaction"][1], | ||
"CC=O.[BH4-].[Na+].Cl>>CCO.[BH3].[Na][Cl]", | ||
) | ||
|
||
def test_ketone(self): | ||
result_ion = self.curate.process_dict( | ||
self.data[1], | ||
"reactions", | ||
return_all=True, | ||
neutralize=False, | ||
compounds_template=self.curate.compounds_template, | ||
reaction_templates=self.curate.reaction_templates, | ||
) | ||
self.assertEqual( | ||
result_ion["curated_reaction"][2], | ||
"CC(=O)C.[BH3-]C#N.[Na+].[H+]>>CC(O)C.[BH2]C#N.[Na+]", | ||
) | ||
|
||
result_neutral = self.curate.process_dict( | ||
self.data[1], | ||
"reactions", | ||
return_all=True, | ||
neutralize=True, | ||
compounds_template=self.curate.compounds_template, | ||
reaction_templates=self.curate.reaction_templates, | ||
) | ||
self.assertEqual( | ||
result_neutral["curated_reaction"][2], | ||
"CC(=O)C.[BH3-]C#N.[Na+].Cl>>CC(O)C.[BH2]C#N.[Na][Cl]", | ||
) | ||
|
||
def test_acid(self): | ||
result_ion = self.curate.process_dict( | ||
self.data[2], | ||
"reactions", | ||
return_all=True, | ||
neutralize=False, | ||
compounds_template=self.curate.compounds_template, | ||
reaction_templates=self.curate.reaction_templates, | ||
) | ||
self.assertEqual( | ||
result_ion["curated_reaction"][0], | ||
( | ||
"CC(=O)O.[AlH4-].[Li+].[H+].[AlH4-].[Li+].[H+]>>" | ||
+ "CCO.O.[AlH3].[Li+].[AlH3].[Li+]", | ||
), | ||
) | ||
|
||
result_neutral = self.curate.process_dict( | ||
self.data[2], | ||
"reactions", | ||
return_all=True, | ||
neutralize=True, | ||
compounds_template=self.curate.compounds_template, | ||
reaction_templates=self.curate.reaction_templates, | ||
) | ||
self.assertEqual( | ||
result_neutral["curated_reaction"][0], | ||
( | ||
"CC(=O)O.[AlH4-].[Li+].Cl.[AlH4-].[Li+].Cl>>" | ||
+ "CCO.O.[AlH3].[Li][Cl].[AlH3].[Li][Cl]" | ||
), | ||
) | ||
|
||
def test_ester(self): | ||
result_ion = self.curate.process_dict( | ||
self.data[3], | ||
"reactions", | ||
return_all=True, | ||
neutralize=False, | ||
compounds_template=self.curate.compounds_template, | ||
reaction_templates=self.curate.reaction_templates, | ||
) | ||
self.assertEqual( | ||
result_ion["curated_reaction"][0], | ||
( | ||
"CC(=O)OC.[BH4-].[Na+].[H+].[BH4-].[Na+].[H+]>>" | ||
+ "CCO.CO.[BH3].[Na+].[BH3].[Na+]" | ||
), | ||
) | ||
|
||
result_neutral = self.curate.process_dict( | ||
self.data[3], | ||
"reactions", | ||
return_all=True, | ||
neutralize=True, | ||
compounds_template=self.curate.compounds_template, | ||
reaction_templates=self.curate.reaction_templates, | ||
) | ||
print(result_neutral) | ||
self.assertEqual( | ||
result_neutral["curated_reaction"][0], | ||
( | ||
"CC(=O)OC.[BH4-].[Na+].Cl.[BH4-].[Na+].Cl>>" | ||
+ "CCO.CO.[BH3].[Na][Cl].[BH3].[Na][Cl]" | ||
), | ||
) | ||
|
||
def test_parallel_curate(self): | ||
result = self.curate.parallel_curate( | ||
self.data, n_jobs=2, verbose=2, return_all=True, neutralize=False | ||
) | ||
|
||
self.assertEqual( | ||
result[0]["curated_reaction"][1], "CC=O.[BH4-].[Na+].[H+]>>CCO.[BH3].[Na+]" | ||
) | ||
self.assertEqual( | ||
result[1]["curated_reaction"][2], | ||
"CC(=O)C.[BH3-]C#N.[Na+].[H+]>>CC(O)C.[BH2]C#N.[Na+]", | ||
) | ||
self.assertEqual( | ||
result[2]["curated_reaction"][0], | ||
( | ||
"CC(=O)O.[AlH4-].[Li+].[H+].[AlH4-].[Li+].[H+]>>" | ||
+ "CCO.O.[AlH3].[Li+].[AlH3].[Li+]", | ||
), | ||
) | ||
self.assertEqual( | ||
result[3]["curated_reaction"][0], | ||
( | ||
"CC(=O)OC.[BH4-].[Na+].[H+].[BH4-].[Na+].[H+]>>" | ||
+ "CCO.CO.[BH3].[Na+].[BH3].[Na+]", | ||
), | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
{ | ||
"aldehyde": ["template_1", "template_2", "template_3", "template_4"], | ||
"ketone": ["template_1", "template_2", "template_3", "template_4"], | ||
"ester": ["template_2", "template_3", "template_4"], | ||
"acyl_chloride": ["template_2", "template_3", "template_4"], | ||
"amid": ["template_4"], | ||
"carboxylic_acid": ["template_4"], | ||
"other": ["template_1"] | ||
"reduction": { | ||
"aldehyde": ["template_1", "template_2", "template_3", "template_4"], | ||
"ketone": ["template_1", "template_2", "template_3", "template_4"], | ||
"ester": ["template_2", "template_3", "template_4"], | ||
"acyl_chloride": ["template_2", "template_3", "template_4"], | ||
"amid": ["template_4"], | ||
"carboxylic_acid": ["template_4"], | ||
"other": ["template_1"] | ||
}, | ||
"oxidation": { | ||
"primary_alcohol>>aldehyde": ["template_1"], | ||
"secondary_alcohol>>ketone": ["template_1"], | ||
"primary_alcohol>>carboxylic_acid": ["template_2"], | ||
"aldehyde>>carboxylic_acid": ["template_3"], | ||
"other": [] | ||
} | ||
} |
Oops, something went wrong.