Skip to content

Commit be6e89a

Browse files
committed
update unit test for surface site to work with Pt
1 parent 16aad30 commit be6e89a

4 files changed

Lines changed: 13 additions & 4 deletions

File tree

rmgpy/molecule/adjlist.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ def check_partial_charge(atom):
9292
the theoretical one:
9393
9494
"""
95-
if atom.symbol in {'X','L','R'} or 'X' in [z.label for z in get_atomtype(atom, atom.bonds).generic]:
95+
# if atom.symbol in {'X','L','R'} or 'X' in [z.label for z in get_atomtype(atom, atom.bonds).generic]:
96+
# TODO handle this in a more generic way so we don't have to add more metals here
97+
if atom.symbol in {'X','L','R','Pt'}:
9698
return # because we can't check it.
9799

98100
valence = PeriodicSystem.valence_electrons[atom.symbol]

rmgpy/molecule/atomtype.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ def get_features(self):
294294
single=[0], all_double=[0], r_double=[], o_double=[], s_double=[], triple=[0], quadruple=[0],
295295
benzene=[0], lone_pairs=[0])
296296
ATOMTYPES['Pto'] = AtomType(label='Pto', generic=['Rx', 'Rx!H', 'X', 'Pt', 'Xo'], specific=[],
297-
single=[0], all_double=[0], r_double=[], o_double=[], s_double=[], triple=[0], quadruple=[0],
298-
benzene=[0], lone_pairs=[0])
297+
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],
298+
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])
299299

300300
# Non-surface atomTypes, R being the most generic:
301301
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
@@ -370,6 +370,11 @@ def _rdkit_translator(input_object, identifier_type, mol=None):
370370
output = from_rdkit_mol(mol, rdkitmol)
371371
elif isinstance(input_object, mm.Molecule):
372372
# We are converting from a molecule to a string identifier
373+
generic_X = False # keep track of whether this is generic 'X' or specific 'Pt'
374+
for atom in input_object.vertices:
375+
if atom.element.symbol == 'X':
376+
generic_X = True
377+
break
373378
if identifier_type == 'smi':
374379
rdkitmol = to_rdkit_mol(input_object, sanitize=False)
375380
else:
@@ -391,6 +396,8 @@ def _rdkit_translator(input_object, identifier_type, mol=None):
391396
else:
392397
raise ValueError('Unexpected input format. Should be a Molecule or a string.')
393398

399+
if generic_X:
400+
output = output.replace('Pt', 'X')
394401
return output
395402

396403

test/rmgpy/molecule/moleculeTest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def test_is_surface_site(self):
262262
"""
263263
for element in element_list:
264264
atom = Atom(element=element, radical_electrons=0, charge=0, label="*1", lone_pairs=0)
265-
if element.symbol == "X":
265+
if element.symbol in ["X", "Pt"]:
266266
assert atom.is_surface_site()
267267
else:
268268
assert not atom.is_surface_site()

0 commit comments

Comments
 (0)