Skip to content

Commit

Permalink
Added cut_species_based_on_atom_indices function
Browse files Browse the repository at this point in the history
This function uses the new, faster and more accurate method for performing the scissoring for atom mapping. Instead of assigning the BDE's to the relevant species, which causes issues when further scissions are performed, this function uses the atom indices to perform the scission.
  • Loading branch information
kfir4444 committed Sep 26, 2023
1 parent 2f95dc7 commit 50b7e3d
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions arc/mapping/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -1250,3 +1250,39 @@ def determine_bdes_on_spc_based_on_atom_labels(spc: "ARCSpecies", bde: Tuple(int
return True
else:
return False


def cut_species_based_on_atom_indices(species: List["ARCSpecies"], bdes: List[Tuple[int, int]]) -> Optional[List["ARCSpecies"]]:
"""
A function for scissoring species based on their atom indices.
Args:
species (List[ARCSpecies]): The species list that requires scission.
bdes (List[Tuple[int, int]]): A list of the atoms between which the bond should be scissored. The atoms are described using the atom labels, and not the actuall atom positions.
Returns:
Optional[List["ARCSpecies"]]: The species after scission.
"""
if not bdes:
return species

for bde in bdes:
for index, spc in enumerate(species):
if determine_bdes_on_spc_based_on_atom_labels(spc, bde):
candidate = species.pop(index)
candidate.final_xyz = candidate.get_xyz()
if candidate.mol.copy(deep=True).smiles == "[H][H]":
labels = [atom.label for atom in candidate.mol.copy(deep=True).atoms]
try:
h1 = candidate.scissors()[0]
except SpeciesError:
return None
h2 = h1.copy()
h2.mol.atoms[0].label = labels[0] if h1.mol.atoms[0].label != labels[0] else labels[1]
species += [h1, h2]
else:
try:
species += candidate.scissors()
except SpeciesError:
return None
break

return species

0 comments on commit 50b7e3d

Please sign in to comment.