Skip to content

Commit

Permalink
updated filtration.py and family.py so that new kinetic families work…
Browse files Browse the repository at this point in the history
… for PFAS chemistry.
  • Loading branch information
Nora Khalil authored and Nora Khalil committed Aug 22, 2024
1 parent 4def2a4 commit e5b0147
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
5 changes: 3 additions & 2 deletions rmgpy/data/kinetics/family.py
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@ def apply_recipe(self, reactant_structures, forward=True, unique=True, relabel_a
struct.reset_ring_membership()
if label in ['1,2_insertion_co', 'r_addition_com', 'co_disproportionation',
'intra_no2_ono_conversion', 'lone_electron_pair_bond',
'1,2_nh3_elimination', '1,3_nh3_elimination', 'co2_elimination_from_lactone_ether']:
'1,2_nh3_elimination', '1,3_nh3_elimination', 'co2_elimination_from_lactone_ether']: #, 'enol_ether_formation']:
struct.update_charge()
else:
raise TypeError('Expecting Molecule or Group object, not {0}'.format(struct.__class__.__name__))
Expand Down Expand Up @@ -1669,8 +1669,9 @@ def _generate_product_structures(self, reactant_structures, maps, forward, relab
product_structures = self.apply_recipe(reactant_structures, forward=forward, relabel_atoms=relabel_atoms)
if not product_structures:
return None
except (InvalidActionError, KekulizationError, AtomTypeError): #added in by NK
except (InvalidActionError, KekulizationError, AtomTypeError) as e: #added in by NK
# If unable to apply the reaction recipe, then return no product structures
print(e)
return None
except ActionError:
logging.error('Could not generate product structures for reaction family {0} in {1} '
Expand Down
13 changes: 13 additions & 0 deletions rmgpy/molecule/filtration.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def filter_structures(mol_list, mark_unreactive=True, allow_expanded_octet=True,
if not all([(mol.multiplicity == mol_list[0].multiplicity) for mol in mol_list]):
raise ValueError("Cannot filter structures with different multiplicities!")

if 'F' in mol_list[0].smiles:
print('testing')
# Get an octet deviation list
octet_deviation_list = get_octet_deviation_list(mol_list, allow_expanded_octet=allow_expanded_octet)

Expand Down Expand Up @@ -117,7 +119,18 @@ def get_octet_deviation(mol, allow_expanded_octet=True):
continue
val_electrons = 2 * (int(atom.get_total_bond_order()) + atom.lone_pairs) + atom.radical_electrons
if atom.is_carbon() or atom.is_nitrogen() or atom.is_oxygen():
if '(F)[C]OC(F)' in mol.smiles: #we need to have an exception for some PFAS chemistry
# There are some cases for PFAS chemistry where a resonance structure of molecules like FC(F)(F)[C]OC(F)(F)F is FC(F)(F)[C-]=[O+]C(F)(F)F.
# However, the get_octet_deviation function marks the FC(F)(F)[C]OC(F)(F)F as unreactive and keeps the FC(F)(F)[C-]=[O+]C(F)(F)F as reactive.
# This is a problem because Brown University calculated reaction rates using the first structure, so we want to keep that reactive and write a reaction recipe with this structure.
if atom.is_carbon() and val_electrons==6: #this is the C with just 2 single bonds and no unpaired
val_electrons += 2 #add two to the valence charge so we get a total octet deviation of 0
if atom.is_oxygen():
pass #no modification of oxygen valence
else:
pass # if not related to PFAS chemistry
octet_deviation += abs(8 - val_electrons) # expecting C/N/O to be near octet

elif atom.is_sulfur():
if not allow_expanded_octet:
# If allow_expanded_octet is False, then adhere to the octet rule for sulfur as well.
Expand Down

0 comments on commit e5b0147

Please sign in to comment.