From 2b17b3cdb7670ff6dba5034d9a9c9cc5ad9c1837 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 e93f0092eb..04230a0839 100644 --- a/rmgpy/molecule/molecule.py +++ b/rmgpy/molecule/molecule.py @@ -981,7 +981,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)