Skip to content

Commit

Permalink
BugFix: xyz2mol non-robust behavior if resonance generation fails
Browse files Browse the repository at this point in the history
There are cases ResonanceMolSupplier returns None, causing error in downstream. This commit makes sure, if nothing meaningful is created, at least the mol created previously will be returned.
  • Loading branch information
xiaoruiDong committed Nov 1, 2023
1 parent 209bdf1 commit b981120
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions rdmc/external/xyz2mol.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,14 @@ def AC2mol(mol, AC, atoms, charge, allow_charged_fragments=True,
return []

# BO2mol returns an arbitrary resonance form. Let's make the rest
mols = rdchem.ResonanceMolSupplier(mol, Chem.UNCONSTRAINED_CATIONS, Chem.UNCONSTRAINED_ANIONS)
mols = [mol for mol in mols]
mols = [mol for mol in rdchem.ResonanceMolSupplier(
mol,
Chem.ALLOW_INCOMPLETE_OCTETS | Chem.UNCONSTRAINED_CATIONS | Chem.UNCONSTRAINED_ANIONS,
) if mol is not None]

if not mols:
mols = [mol] # For some cases, resonance structure supplier creates Nones


return mols

Expand Down

0 comments on commit b981120

Please sign in to comment.