Skip to content

Commit

Permalink
BugFix: miscellaneous fixes for generate reaction complex
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoruiDong committed Jun 27, 2021
1 parent 44fc72e commit 3bfd840
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions rdmc/external/rmg.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def from_rdkit_mol(rdkitmol,

return mol


def find_reaction_family(database: 'RMGDatabase',
reactants: list,
products: list,
Expand Down Expand Up @@ -142,6 +143,7 @@ def find_reaction_family(database: 'RMGDatabase',
else:
if verbose:
print('Doesn\'t match any RMG reaction family!')
return None, None


def generate_reaction_complex(database: 'RMGDatabase',
Expand Down Expand Up @@ -170,7 +172,10 @@ def generate_reaction_complex(database: 'RMGDatabase',
verbose=verbose)
except TypeError:
# Cannot find any matches
return
return None, None
else:
if family_label == None:
return None, None

# Make the reaction family preserver atom orders
family = database.kinetics.families[family_label]
Expand Down Expand Up @@ -219,8 +224,13 @@ def generate_reaction_complex(database: 'RMGDatabase',

# Create a reactant complex
reactant_structure = mm.Molecule()
for struct in reactants:
reactant_structure = reactant_structure.merge(struct.copy(deep=True))
if len(reactants) == 1:
reactant_structure = reactants[0].copy(deep=True)
else:
for struct in reactants:
reactant_structure = reactant_structure.merge(
struct.copy(deep=True)
)

# Make a copy for the reactant complex for output
reactant_complex = reactant_structure.copy(deep=True)
Expand All @@ -242,6 +252,8 @@ def generate_reaction_complex(database: 'RMGDatabase',
match = check_isomorphic_molecules(product_structures, products)
if match:
return reactant_complex, product_complex
else:
raise RuntimeError('Cannot find the correct reaction mapping.')


def check_isomorphic_molecules(mols_1: List['Molecule'],
Expand Down

0 comments on commit 3bfd840

Please sign in to comment.