From 4f9e11d130fa77be0c933c21290b99e6de971aa1 Mon Sep 17 00:00:00 2001 From: kfir4444 Date: Thu, 21 Sep 2023 13:55:24 +0300 Subject: [PATCH] Added copy_species_list_for_mapping function This due to issue #675, this function also moved the atom indices when copying.(https://github.com/ReactionMechanismGenerator/ARC/issues/675) --- arc/mapping/engine.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arc/mapping/engine.py b/arc/mapping/engine.py index 5ff2fdcdd5..50c1a3fb02 100644 --- a/arc/mapping/engine.py +++ b/arc/mapping/engine.py @@ -1291,3 +1291,18 @@ def cut_species_based_on_atom_indices(species: List["ARCSpecies"], bdes: List[Tu break return species + + +def copy_species_list_for_mapping(species: List["ARCSpecies"]) -> List["ARCSpecies"]: + """ + A helper function for copying the species list for mapping. Also keeps the atom indices when copying. + Args: + species (List[ARCSpecies]): The species list to be copied. + Returns: + List[ARCSpecies]: The copied species list. + """ + copies = [spc.copy() for spc in species] + for copy, spc in zip(copies, species): + for atom1, atom2 in zip(copy.mol.atoms, spc.mol.atoms): + atom1.label = atom2.label + return copies