Skip to content

Commit cc93abf

Browse files
committed
update unit test for surface site to work with Pt
1 parent cd17f45 commit cc93abf

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

rmgpy/molecule/atomtype.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@ def get_features(self):
307307
single=[0], all_double=[0], r_double=[], o_double=[], s_double=[], triple=[0], quadruple=[0],
308308
benzene=[0], lone_pairs=[0])
309309
ATOMTYPES['Pto'] = AtomType(label='Pto', generic=['Rx', 'Rx!H', 'X', 'Pt', 'Xo'], specific=[],
310-
single=[0], all_double=[0], r_double=[], o_double=[], s_double=[], triple=[0], quadruple=[0],
311-
benzene=[0], lone_pairs=[0])
310+
single=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18], all_double=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18], r_double=[], o_double=[], s_double=[], triple=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18],
311+
quadruple=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18], benzene=[0], lone_pairs=[0])
312312

313313
# Non-surface atomTypes, R being the most generic:
314314
ATOMTYPES['R'] = AtomType(label='R', generic=['Rx'], specific=[

rmgpy/molecule/translator.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,11 @@ def _rdkit_translator(input_object, identifier_type, mol=None):
383383
output = from_rdkit_mol(mol, rdkitmol)
384384
elif isinstance(input_object, mm.Molecule):
385385
# We are converting from a molecule to a string identifier
386+
generic_X = False # keep track of whether this is generic 'X' or specific 'Pt'
387+
for atom in input_object.vertices:
388+
if atom.element.symbol == 'X':
389+
generic_X = True
390+
break
386391
if identifier_type == 'smi':
387392
rdkitmol = to_rdkit_mol(input_object, sanitize=False)
388393
else:
@@ -404,6 +409,8 @@ def _rdkit_translator(input_object, identifier_type, mol=None):
404409
else:
405410
raise ValueError('Unexpected input format. Should be a Molecule or a string.')
406411

412+
if generic_X:
413+
output = output.replace('Pt', 'X')
407414
return output
408415

409416

test/rmgpy/molecule/moleculeTest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ def test_is_surface_site(self):
287287
"""
288288
for element in element_list:
289289
atom = Atom(element=element, radical_electrons=0, charge=0, label="*1", lone_pairs=0)
290-
if element.symbol == "X":
290+
if element.symbol in ["X", "Pt"]:
291291
assert atom.is_surface_site()
292292
else:
293293
assert not atom.is_surface_site()

0 commit comments

Comments
 (0)