From 4732aa1980d76f9f9c48e34a91031530a6a69a49 Mon Sep 17 00:00:00 2001 From: Sevy Harris Date: Wed, 7 Feb 2024 13:53:08 -0500 Subject: [PATCH] use Ar workaround to construct surface molecules --- rmgpy/molecule/molecule.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/rmgpy/molecule/molecule.py b/rmgpy/molecule/molecule.py index 03727be792..034ee70654 100644 --- a/rmgpy/molecule/molecule.py +++ b/rmgpy/molecule/molecule.py @@ -984,7 +984,20 @@ def __init__(self, atoms=None, symmetry=-1, multiplicity=-187, reactive=True, pr self.from_inchi(inchi) self._inchi = inchi elif smiles: - self.from_smiles(smiles) + if 'X' in smiles: + self.from_smiles(smiles.replace('X', 'Ar')) + lines = self.to_adjacency_list().split('\n') + for i, line in enumerate(lines): + if 'Ar' in line: + lines[i] = lines[i].replace('Ar', 'X') + # remove any extra electron pairs + lines[i] = lines[i].replace('p3', 'p0') + lines[i] = lines[i].replace('p2', 'p0') + lines[i] = lines[i].replace('p1', 'p0') + adj_list = '\n'.join(lines) + self = self.from_adjacency_list(adj_list) + else: + self.from_smiles(smiles) self._smiles = smiles if multiplicity != -187: # it was set explicitly, so re-set it (from_smiles etc may have changed it)