Skip to content

Commit

Permalink
use Ar workaround to construct surface molecules
Browse files Browse the repository at this point in the history
  • Loading branch information
sevyharris committed Oct 18, 2024
1 parent 704632d commit 4732aa1
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion rmgpy/molecule/molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4732aa1

Please sign in to comment.