Skip to content

Commit 16aad30

Browse files
committed
add Pt atom type
1 parent ade423c commit 16aad30

5 files changed

Lines changed: 57 additions & 26 deletions

File tree

rmgpy/molecule/adjlist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def check_partial_charge(atom):
9292
the theoretical one:
9393
9494
"""
95-
if atom.symbol in {'X','L','R'}:
95+
if atom.symbol in {'X','L','R'} or 'X' in [z.label for z in get_atomtype(atom, atom.bonds).generic]:
9696
return # because we can't check it.
9797

9898
valence = PeriodicSystem.valence_electrons[atom.symbol]

rmgpy/molecule/atomtype.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def get_features(self):
257257
'Cl','Cl1s',
258258
'Br','Br1s',
259259
'I','I1s',
260-
'F','F1s','X','Xv','Xo'])
260+
'F','F1s','X','Xv','Xo','Pt','Ptv','Pto'])
261261

262262
ATOMTYPES['Rx!H'] = AtomType(label='Rx!H', generic=['Rx'], specific=[
263263
'R!H',
@@ -273,20 +273,29 @@ def get_features(self):
273273
'Cl','Cl1s',
274274
'Br','Br1s',
275275
'I','I1s',
276-
'F','F1s','X','Xv','Xo'])
276+
'F','F1s','X','Xv','Xo','Pt','Ptv','Pto'])
277277

278278
# Surface sites:
279-
ATOMTYPES['X'] = AtomType(label='X', generic=['Rx', 'Rx!H'], specific=['Xv', 'Xo'])
279+
ATOMTYPES['X'] = AtomType(label='X', generic=['Rx', 'Rx!H'], specific=['Xv', 'Xo', 'Pt'])
280280

281281
# Vacant surface site:
282-
ATOMTYPES['Xv'] = AtomType('Xv', generic=['X','Rx', 'Rx!H'], specific=[],
282+
ATOMTYPES['Xv'] = AtomType('Xv', generic=['X','Rx', 'Rx!H'], specific=['Ptv'],
283283
single=[0], all_double=[0], r_double=[], o_double=[], s_double=[], triple=[0], quadruple=[0],
284284
benzene=[0], lone_pairs=[0])
285285
# Occupied surface site:
286-
ATOMTYPES['Xo'] = AtomType('Xo', generic=['X','Rx', 'Rx!H'], specific=[],
286+
ATOMTYPES['Xo'] = AtomType('Xo', generic=['X','Rx', 'Rx!H'], specific=['Pto'],
287287
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],
288288
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])
289289

290+
ATOMTYPES['Pt'] = AtomType(label='Pt', generic=['Rx', 'Rx!H', 'X'], specific=['Ptv', 'Pto'])
291+
# single=[0], all_double=[0], r_double=[], o_double=[], s_double=[], triple=[0], quadruple=[0],
292+
# benzene=[0], lone_pairs=[0])
293+
ATOMTYPES['Ptv'] = AtomType(label='Ptv', generic=['Rx', 'Rx!H', 'X', 'Pt', 'Xv'], specific=[],
294+
single=[0], all_double=[0], r_double=[], o_double=[], s_double=[], triple=[0], quadruple=[0],
295+
benzene=[0], lone_pairs=[0])
296+
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])
290299

291300
# Non-surface atomTypes, R being the most generic:
292301
ATOMTYPES['R'] = AtomType(label='R', generic=['Rx'], specific=[
@@ -675,6 +684,12 @@ def get_features(self):
675684
ATOMTYPES['X'].set_actions(increment_bond=['X'], decrement_bond=['X'], form_bond=['X'], break_bond=['X'], increment_radical=[], decrement_radical=[], increment_lone_pair=[], decrement_lone_pair=[])
676685
ATOMTYPES['Xv'].set_actions(increment_bond=[], decrement_bond=[], form_bond=['Xo'], break_bond=[], increment_radical=[], decrement_radical=[], increment_lone_pair=[], decrement_lone_pair=[])
677686
ATOMTYPES['Xo'].set_actions(increment_bond=['Xo'], decrement_bond=['Xo'], form_bond=[], break_bond=['Xv'], increment_radical=[], decrement_radical=[], increment_lone_pair=[], decrement_lone_pair=[])
687+
ATOMTYPES['Pt'].set_actions(increment_bond=['Pt'], decrement_bond=['Pt'], form_bond=['Pt'], break_bond=['Pt'], increment_radical=[], decrement_radical=[], increment_lone_pair=[], decrement_lone_pair=[])
688+
ATOMTYPES['Ptv'].set_actions(increment_bond=[], decrement_bond=[], form_bond=['Pto'], break_bond=[], increment_radical=[], decrement_radical=[], increment_lone_pair=[], decrement_lone_pair=[])
689+
ATOMTYPES['Pto'].set_actions(increment_bond=['Pto'], decrement_bond=['Pto'], form_bond=[], break_bond=['Ptv'], increment_radical=[], decrement_radical=[], increment_lone_pair=[], decrement_lone_pair=[])
690+
691+
692+
678693

679694
ATOMTYPES['R'].set_actions(increment_bond=['R'], decrement_bond=['R'], form_bond=['R'], break_bond=['R'], increment_radical=['R'], decrement_radical=['R'], increment_lone_pair=['R'], decrement_lone_pair=['R'])
680695
ATOMTYPES['R!H'].set_actions(increment_bond=['R!H'], decrement_bond=['R!H'], form_bond=['R!H'], break_bond=['R!H'], increment_radical=['R!H'], decrement_radical=['R!H'], increment_lone_pair=['R!H'], decrement_lone_pair=['R!H'])
@@ -812,7 +827,7 @@ def get_features(self):
812827
ATOMTYPES['F1s'].set_actions(increment_bond=[], decrement_bond=[], form_bond=['F1s'], break_bond=['F1s'], increment_radical=['F1s'], decrement_radical=['F1s'], increment_lone_pair=[], decrement_lone_pair=[])
813828

814829
# these are ordered in priority of picking if a more general atomtype is encountered
815-
allElements = ['H', 'C', 'O', 'N', 'S', 'P', 'Si', 'F', 'Cl', 'Br', 'I', 'Ne', 'Ar', 'He', 'X']
830+
allElements = ['H', 'C', 'O', 'N', 'S', 'P', 'Si', 'F', 'Cl', 'Br', 'I', 'Ne', 'Ar', 'He', 'X', 'Pt']
816831
# list of elements that do not have more specific atomTypes
817832
nonSpecifics = ['H', 'He', 'Ne', 'Ar',]
818833

rmgpy/molecule/element.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,13 @@ class PeriodicSystem(object):
123123
isotopes of the same element may have slight different electronegativities, which is not reflected below
124124
"""
125125
valences = {'H': 1, 'He': 0, 'C': 4, 'N': 3, 'O': 2, 'F': 1, 'Ne': 0,
126-
'Si': 4, 'P': 3, 'S': 2, 'Cl': 1, 'Br': 1, 'Ar': 0, 'I': 1, 'X': 4}
126+
'Si': 4, 'P': 3, 'S': 2, 'Cl': 1, 'Br': 1, 'Ar': 0, 'I': 1, 'X': 4, 'Pt': 4}
127127
valence_electrons = {'H': 1, 'He': 2, 'C': 4, 'N': 5, 'O': 6, 'F': 7, 'Ne': 8,
128-
'Si': 4, 'P': 5, 'S': 6, 'Cl': 7, 'Br': 7, 'Ar': 8, 'I': 7, 'X': 4}
128+
'Si': 4, 'P': 5, 'S': 6, 'Cl': 7, 'Br': 7, 'Ar': 8, 'I': 7, 'X': 4, 'Pt': 4}
129129
lone_pairs = {'H': 0, 'He': 1, 'C': 0, 'N': 1, 'O': 2, 'F': 3, 'Ne': 4,
130-
'Si': 0, 'P': 1, 'S': 2, 'Cl': 3, 'Br': 3, 'Ar': 4, 'I': 3, 'X': 0}
130+
'Si': 0, 'P': 1, 'S': 2, 'Cl': 3, 'Br': 3, 'Ar': 4, 'I': 3, 'X': 0, 'Pt': 0}
131131
electronegativity = {'H': 2.20, 'D': 2.20, 'T': 2.20, 'C': 2.55, 'C13': 2.55, 'N': 3.04, 'O': 3.44, 'O18': 3.44,
132-
'F': 3.98, 'Si': 1.90, 'P': 2.19, 'S': 2.58, 'Cl': 3.16, 'Br': 2.96, 'I': 2.66, 'X': 0.0}
132+
'F': 3.98, 'Si': 1.90, 'P': 2.19, 'S': 2.58, 'Cl': 3.16, 'Br': 2.96, 'I': 2.66, 'X': 0.0, 'Pt': 0}
133133

134134

135135
################################################################################

rmgpy/molecule/molecule.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ def is_surface_site(self):
407407
"""
408408
Return ``True`` if the atom represents a surface site or ``False`` if not.
409409
"""
410-
return self.symbol == 'X'
410+
return self.symbol == 'X' or self.symbol in [z.label for z in ATOMTYPES['X'].specific]
411411

412412
def is_bonded_to_surface(self):
413413
"""
@@ -984,18 +984,23 @@ def __init__(self, atoms=None, symmetry=-1, multiplicity=-187, reactive=True, pr
984984
self.from_inchi(inchi)
985985
self._inchi = inchi
986986
elif smiles:
987-
if 'X' in smiles:
988-
self.from_smiles(smiles.replace('X', 'Ar'))
989-
lines = self.to_adjacency_list().split('\n')
990-
for i, line in enumerate(lines):
991-
if 'Ar' in line:
992-
lines[i] = lines[i].replace('Ar', 'X')
993-
# remove any extra electron pairs
994-
lines[i] = lines[i].replace('p3', 'p0')
995-
lines[i] = lines[i].replace('p2', 'p0')
996-
lines[i] = lines[i].replace('p1', 'p0')
997-
adj_list = '\n'.join(lines)
998-
self = self.from_adjacency_list(adj_list)
987+
for surface_site_symbol in ['X', 'Pt']:
988+
if surface_site_symbol in smiles:
989+
assert 'Ar' not in smiles
990+
self.from_smiles(smiles.replace(surface_site_symbol, 'Ar'))
991+
lines = self.to_adjacency_list().split('\n')
992+
for i, line in enumerate(lines):
993+
if 'Ar' in line: # The adjacency list needs to use the identified 'X' for a site
994+
lines[i] = lines[i].replace('Ar', surface_site_symbol)
995+
# remove any extra electron pairs
996+
lines[i] = lines[i].replace('p3', 'p0')
997+
lines[i] = lines[i].replace('p2', 'p0')
998+
lines[i] = lines[i].replace('p1', 'p0')
999+
adj_list = '\n'.join(lines)
1000+
self = self.from_adjacency_list(adj_list)
1001+
# but now we have to change the symbol back to 'Pt or 'X' for the smiles
1002+
# self.smiles = self.smiles.replace('X', surface_site_symbol)
1003+
break
9991004
else:
10001005
self.from_smiles(smiles)
10011006
self._smiles = smiles
@@ -1166,9 +1171,11 @@ def contains_surface_site(self):
11661171
Returns ``True`` iff the molecule contains an 'X' surface site.
11671172
"""
11681173
cython.declare(atom=Atom)
1174+
cython.declare(z=AtomType)
11691175
for atom in self.atoms:
1170-
if atom.symbol == 'X':
1176+
if atom.symbol == 'X' or atom.symbol in [z.label for z in ATOMTYPES['X'].specific]:
11711177
return True
1178+
# atom_type = get_atomtype(atom, atom.bonds)
11721179
return False
11731180

11741181
def number_of_surface_sites(self):

test/rmgpy/molecule/moleculeTest.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1640,7 +1640,16 @@ def test_smiles(self):
16401640
"C=C[X]",
16411641
"CO.[X]",
16421642
"C#[X]",
1643-
"CCC(C)[X]"
1643+
"CCC(C)[X]",
1644+
"[Pt]",
1645+
"[Pt]C=C[Pt]",
1646+
"O[Pt]",
1647+
"CO[Pt]",
1648+
"[PtH]",
1649+
"C=C[Pt]",
1650+
"CO.[Pt]",
1651+
"C#[Pt]",
1652+
"CCC(C)[Pt]"
16441653
]
16451654
for s in test_strings:
16461655
molecule = Molecule(smiles=s)

0 commit comments

Comments
 (0)