diff --git a/rmgpy/data/kinetics/family.py b/rmgpy/data/kinetics/family.py index 8ba433e34a..7c0ec5405d 100644 --- a/rmgpy/data/kinetics/family.py +++ b/rmgpy/data/kinetics/family.py @@ -1520,9 +1520,10 @@ def apply_recipe(self, reactant_structures, forward=True, unique=True, relabel_a # (families with charged substances), the charge of structures will be updated if isinstance(struct, Molecule): struct.update_charge() - struct.update(sort_atoms=not self.save_order) - elif isinstance(struct, Fragment): - struct.update() + if isinstance(struct, Fragment): + struct.update() + else: + struct.update(sort_atoms=not self.save_order) elif isinstance(struct, Group): is_molecule = False struct.reset_ring_membership() diff --git a/rmgpy/molecule/group.py b/rmgpy/molecule/group.py index f596e7ab84..1dc56cc7f7 100644 --- a/rmgpy/molecule/group.py +++ b/rmgpy/molecule/group.py @@ -44,6 +44,7 @@ from rmgpy.molecule.atomtype import ATOMTYPES, allElements, nonSpecifics, get_features, AtomType from rmgpy.molecule.element import PeriodicSystem from rmgpy.molecule.graph import Vertex, Edge, Graph +from rmgpy.molecule.fragment import CuttingLabel ################################################################################ diff --git a/rmgpy/molecule/molecule.py b/rmgpy/molecule/molecule.py index 0867d87f89..3f647c336a 100644 --- a/rmgpy/molecule/molecule.py +++ b/rmgpy/molecule/molecule.py @@ -58,6 +58,7 @@ from rmgpy.molecule.graph import Vertex, Edge, Graph, get_vertex_connectivity_value from rmgpy.molecule.kekulize import kekulize from rmgpy.molecule.pathfinder import find_shortest_path +from rmgpy.molecule.fragment import CuttingLabel ################################################################################ diff --git a/rmgpy/reaction.py b/rmgpy/reaction.py index 90471acc19..19136c60fa 100644 --- a/rmgpy/reaction.py +++ b/rmgpy/reaction.py @@ -1440,16 +1440,15 @@ def is_balanced(self): if not isinstance(atom, CuttingLabel): reactants_net_charge += atom.charge reactant_elements[atom.element] += 1 - elif isinstance(reactant, Molecule): - molecule = reactant - for atom in molecule.atoms: - reactants_net_charge += atom.charge - reactant_elements[atom.element] += 1 elif isinstance(reactant, Fragment): for atom in reactant.atoms: if not isinstance(atom, CuttingLabel): reactants_net_charge += atom.charge reactant_elements[atom.element] += 1 + elif isinstance(reactant, Molecule): + for atom in reactant.atoms: + reactants_net_charge += atom.charge + reactant_elements[atom.element] += 1 for product in self.products: if isinstance(product, Species): molecule = product.molecule[0] @@ -1457,16 +1456,15 @@ def is_balanced(self): if not isinstance(atom, CuttingLabel): products_net_charge += atom.charge product_elements[atom.element] += 1 - elif isinstance(product, Molecule): - molecule = product - for atom in molecule.atoms: - products_net_charge += atom.charge - product_elements[atom.element] += 1 elif isinstance(product, Fragment): for atom in product.atoms: if not isinstance(atom, CuttingLabel): products_net_charge += atom.charge product_elements[atom.element] += 1 + elif isinstance(product, Molecule): + for atom in product.atoms: + products_net_charge += atom.charge + product_elements[atom.element] += 1 for element in element_list: if reactant_elements[element] != product_elements[element]: