From 65ffc63c8681e1948d3b3499f8570c298e34b3f3 Mon Sep 17 00:00:00 2001 From: Hetal Patel Date: Fri, 25 Mar 2022 16:36:28 -0400 Subject: [PATCH] added 3-4 ring filers and C-C, O-O filters --- HiPRGen/reaction_questions.py | 4 +-- HiPRGen/species_questions.py | 59 +++++++++++++++++++++++++++++++++-- 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/HiPRGen/reaction_questions.py b/HiPRGen/reaction_questions.py index 459a33c..469290b 100644 --- a/HiPRGen/reaction_questions.py +++ b/HiPRGen/reaction_questions.py @@ -707,12 +707,12 @@ def __call__(self, reaction, mols, params): (too_many_reactants_or_products(), Terminal.DISCARD), (dcharge_too_large(), Terminal.DISCARD), (reactant_and_product_not_isomorphic(), Terminal.DISCARD), - (dG_above_threshold(0.0, "free_energy", 0.0), Terminal.DISCARD), + (dG_above_threshold(0.2, "free_energy", 0.0), Terminal.DISCARD), (reaction_default_true(), Terminal.KEEP) ]), - (dG_above_threshold(0.0, "solvation_free_energy", 0.0), Terminal.DISCARD), + (dG_above_threshold(0.2, "free_energy", 0.0), Terminal.DISCARD), (star_count_diff_above_threshold(6), Terminal.DISCARD), diff --git a/HiPRGen/species_questions.py b/HiPRGen/species_questions.py index 4edd18e..3d24092 100644 --- a/HiPRGen/species_questions.py +++ b/HiPRGen/species_questions.py @@ -88,7 +88,7 @@ def __init__(self, threshold): self.threshold = threshold def __call__(self, mol): - if (mol.spin_multiplicity == 2): + if (mol.spin_multiplicity == 2) and mol.entry_id != "None": num_partial_spins_above_threshold = 0 for i in range(mol.num_atoms): if mol.partial_spins_nbo[i] > self.threshold: @@ -201,7 +201,7 @@ def __init__(self): pass def __call__(self, mol): - if mol.num_atoms > 1: + if mol.num_atoms > 1 and mol.entry_id != "None": for i in range(mol.num_atoms): if mol.species[i] == 'H': @@ -355,6 +355,56 @@ def __call__(self, mol): else: return False + + +class C_C_bond(MSONable): + def __init__(self): + pass + + def __call__(self,mol): + decision = False + if mol.num_atoms != 1: + for node_num, node_dict in mol.graph.nodes(data=True): + if node_dict["specie"] == "C": + c_neighbor_count = 0 + neighbor_count = len(list(mol.graph.neighbors(node_num))) + for neighbor_node_num in mol.graph.neighbors(node_num): + if mol.graph.nodes[neighbor_node_num]["specie"] == "C": + c_neighbor_count = c_neighbor_count + 1 + if c_neighbor_count == neighbor_count: + decision = True + return decision + +class O_O_bond(MSONable): + def __init__(self): + pass + + def __call__(self,mol): + decision = False + if mol.num_atoms != 1 and mol.num_atoms != 2 and mol.num_atoms != 3 : + for node_num, node_dict in mol.graph.nodes(data=True): + if node_dict["specie"] == "O": + o_neighbor_count = 0 + neighbor_count = len(list(mol.graph.neighbors(node_num))) + for neighbor_node_num in mol.graph.neighbors(node_num): + if mol.graph.nodes[neighbor_node_num]["specie"] == "O": + o_neighbor_count = o_neighbor_count + 1 + if o_neighbor_count == neighbor_count: + decision = True + +class rings_3_4(MSONable): + def __init__(self): + pass + + def __call__(self,mol): + try: + cycle = nx.find_cycle(mol.covalent_graph) + if len(cycle) == 4 or len(cycle) == 3: + return True + except nx.exception.NetworkXNoCycle: + return False + + # any species filter which modifies bonding has to come before # any filter checking for connectivity (which includes the metal-centric complex filter) @@ -372,7 +422,10 @@ def __call__(self, mol): (add_star_hashes(), Terminal.KEEP), (add_unbroken_fragment(), Terminal.KEEP), (add_single_bond_fragments(), Terminal.KEEP), - (species_default_true(), Terminal.KEEP) + (species_default_true(), Terminal.KEEP), + (C_C_bond(), Terminal.KEEP), + (O_O_bond(), Terminal.KEEP), + (rings_3_4(), Terminal.KEEP) ] mg_species_decision_tree = [