-
Notifications
You must be signed in to change notification settings - Fork 24
Hydrolysis families and tests #770
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
145c343
Minor: type hints changes in converter
alongd d1ded74
Exclude hidden and underscore files from ARC families list
LeenFahoum 40f5374
Added different hydrolysis arc families groups
LeenFahoum 041e4ec
Tests: Added tests for arc families groups
LeenFahoum c90d966
Added hydrolysis TS guess functionality to heuristics adapter
LeenFahoum db45728
Tests: Added tests for arc families groups
LeenFahoum 1a08d05
Tests: updated test_get_all_families()
LeenFahoum c8052c2
Update add_atom_to_xyz_using_internal_coords()
LeenFahoum f8226f2
Tests: Modifications and additions to converter tests
LeenFahoum 97abe96
Added a function to check if a reaction family is defined
LeenFahoum 5f77687
Defined the hydrolysis families in ts_adapters_by_rmg_family
LeenFahoum 7a86a55
Enable user to define a reaction family name and check its validity
LeenFahoum 7f17ee7
Added atoms electronegativity values YAML file
LeenFahoum 2a6ac5b
Fix: enforce consistency between solvation method and solvent
LeenFahoum 0e699be
Added YAML file for hydrolysis reactions parameters
LeenFahoum 38d792b
Fix TypeError in get_all_families when using a single family name string
LeenFahoum File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,142 @@ | ||
| #!/usr/bin/env python3 | ||
| # encoding: utf-8 | ||
|
|
||
| """ | ||
| This module contains unit tests for the kinetic families defined under arc.data.families. | ||
| """ | ||
|
|
||
| import unittest | ||
| import os | ||
|
|
||
| from arc.family.family import ReactionFamily, get_reaction_family_products, get_recipe_actions | ||
| from arc.imports import settings | ||
| from arc.reaction.reaction import ARCReaction | ||
| from arc.species.species import ARCSpecies | ||
|
|
||
| ARC_FAMILIES_PATH = settings['ARC_FAMILIES_PATH'] | ||
|
|
||
|
|
||
| class TestCarbonylBasedHydrolysisReactionFamily(unittest.TestCase): | ||
| """ | ||
| Contains unit tests for the carbonyl-based hydrolysis reaction family. | ||
| """ | ||
|
|
||
| @classmethod | ||
| def setUpClass(cls): | ||
| """Set up the test by defining the carbonyl-based hydrolysis reaction family.""" | ||
| cls.family = ReactionFamily('carbonyl_based_hydrolysis') | ||
|
|
||
| def test_carbonyl_based_hydrolysis_reaction(self): | ||
| """Test if carbonyl_based hydrolysis products are correctly generated.""" | ||
| carbonyl = ARCSpecies(label='carbonyl', smiles='CC(=O)OC') | ||
| water = ARCSpecies(label='H2O', smiles='O') | ||
| acid = ARCSpecies(label='acid', smiles='CC(=O)O') | ||
| alcohol = ARCSpecies(label='alcohol', smiles='CO') | ||
| rxn = ARCReaction(r_species=[carbonyl, water], p_species=[acid, alcohol]) | ||
| products = get_reaction_family_products(rxn) | ||
| product_smiles = [p.to_smiles() for p in products[0]['products']] | ||
| expected_product_smiles = ['CC(=O)O', 'CO'] | ||
| self.assertEqual(product_smiles, expected_product_smiles) | ||
|
|
||
| def test_recipe_actions(self): | ||
| """Test if the reaction recipe is applied correctly.""" | ||
| groups_file_path = os.path.join(ARC_FAMILIES_PATH, 'carbonyl_based_hydrolysis.py') | ||
| with open(groups_file_path, 'r') as f: | ||
| groups_as_lines = f.readlines() | ||
| actions = get_recipe_actions(groups_as_lines) | ||
| expected_actions = [ | ||
| ['BREAK_BOND', '*1', 1, '*2'], | ||
| ['BREAK_BOND', '*3', 1, '*4'], | ||
| ['FORM_BOND', '*1', 1, '*4'], | ||
| ['FORM_BOND', '*2', 1, '*3'], | ||
| ] | ||
| self.assertEqual(actions, expected_actions) | ||
|
|
||
| def test_carbonyl_based_hydrolysis_withP(self): | ||
| """Test if carbonyl-based hydrolysis products are correctly generated.""" | ||
| carbonyl= ARCSpecies(label='carbonyl', smiles='CP(=O)(OC)O') | ||
| water = ARCSpecies(label='H2O', smiles='O') | ||
| acid = ARCSpecies(label='acid', smiles='CP(=O)(O)O') | ||
| alcohol = ARCSpecies(label='alcohol', smiles='CO') | ||
| rxn = ARCReaction(r_species=[carbonyl, water], p_species=[acid, alcohol]) | ||
| products = get_reaction_family_products(rxn) | ||
| product_smiles = [p.to_smiles() for p in products[0]['products']] | ||
| expected_product_smiles = ['CP(=O)(O)O', 'CO'] | ||
| self.assertEqual(product_smiles, expected_product_smiles) | ||
|
|
||
|
|
||
| class TestNitrileHydrolysisReactionFamily(unittest.TestCase): | ||
| """ | ||
| Contains unit tests for the nitrile hydrolysis reaction family. | ||
| """ | ||
|
|
||
| @classmethod | ||
| def setUpClass(cls): | ||
| """Set up the test by defining the nitrile hydrolysis reaction family.""" | ||
| cls.family = ReactionFamily('nitrile_hydrolysis') | ||
|
|
||
| def test_nitrile_hydrolysis_reaction(self): | ||
| """Test if nitrile hydrolysis products are correctly generated.""" | ||
| nitrile = ARCSpecies(label='nitrile', smiles='CC#N') | ||
| water = ARCSpecies(label='H2O', smiles='O') | ||
| acid = ARCSpecies(label='acid', smiles='CC(=N)O') | ||
| rxn = ARCReaction(r_species=[nitrile, water], p_species=[acid]) | ||
| products = get_reaction_family_products(rxn) | ||
| product_smiles = [p.to_smiles() for p in products[0]['products']] | ||
| expected_product_smiles = ['CC(=N)O'] | ||
| self.assertEqual(product_smiles, expected_product_smiles) | ||
|
|
||
| def test_recipe_actions(self): | ||
| """Test if the reaction recipe is applied correctly for nitrile hydrolysis.""" | ||
| groups_file_path = os.path.join(ARC_FAMILIES_PATH, 'nitrile_hydrolysis.py') | ||
| with open(groups_file_path, 'r') as f: | ||
| groups_as_lines = f.readlines() | ||
| actions = get_recipe_actions(groups_as_lines) | ||
| expected_actions =[ | ||
| ['CHANGE_BOND', '*1', -1, '*2'], | ||
| ['BREAK_BOND', '*3', 1, '*4'], | ||
| ['FORM_BOND', '*1', 1, '*4'], | ||
| ['FORM_BOND', '*2', 1, '*3'], | ||
| ] | ||
| self.assertEqual(actions, expected_actions) | ||
|
|
||
|
|
||
| class TestEtherHydrolysisReactionFamily(unittest.TestCase): | ||
| """ | ||
| Contains unit tests for the ether hydrolysis reaction family. | ||
| """ | ||
|
|
||
| @classmethod | ||
| def setUpClass(cls): | ||
| """Set up the test by defining the ether hydrolysis reaction family.""" | ||
| cls.family = ReactionFamily('ether_hydrolysis') | ||
|
|
||
| def test_ether_hydrolysis_reaction(self): | ||
| """Test if ether hydrolysis products are correctly generated.""" | ||
| ether = ARCSpecies(label='ether', smiles='CCOC') | ||
| water = ARCSpecies(label='H2O', smiles='O') | ||
| alcohol1 = ARCSpecies(label='alcohol1', smiles='CCO') | ||
| alcohol2 = ARCSpecies(label='alcohol2', smiles='CO') | ||
| rxn = ARCReaction(r_species=[ether, water], p_species=[alcohol1, alcohol2]) | ||
| products = get_reaction_family_products(rxn) | ||
| product_smiles = [p.to_smiles() for p in products[0]['products']] | ||
| expected_product_smiles = ['CCO', 'CO'] | ||
| self.assertEqual(product_smiles, expected_product_smiles) | ||
|
|
||
| def test_recipe_actions(self): | ||
| """Test if the reaction recipe is applied correctly.""" | ||
| groups_file_path = os.path.join(ARC_FAMILIES_PATH, 'ether_hydrolysis.py') | ||
| with open(groups_file_path, 'r') as f: | ||
| groups_as_lines = f.readlines() | ||
| actions = get_recipe_actions(groups_as_lines) | ||
| expected_actions = [ | ||
| ['BREAK_BOND', '*1', 1, '*2'], | ||
| ['BREAK_BOND', '*3', 1, '*4'], | ||
| ['FORM_BOND', '*1', 1, '*4'], | ||
| ['FORM_BOND', '*2', 1, '*3'], | ||
| ] | ||
| self.assertEqual(actions, expected_actions) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| unittest.main() | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.