1
|
|
|
#! /usr/bin/env python |
2
|
|
|
# |
3
|
|
|
# Copyright (C) 2015-2016 Rich Lewis <[email protected]> |
4
|
|
|
# License: 3-clause BSD |
5
|
|
|
|
6
|
|
|
|
7
|
1 |
|
""" |
8
|
|
|
## skchem.core.atom |
9
|
|
|
|
10
|
|
|
Defining atoms in scikit-chem. |
11
|
|
|
""" |
12
|
|
|
|
13
|
1 |
|
import numpy as np |
|
|
|
|
14
|
1 |
|
import pandas as pd |
|
|
|
|
15
|
|
|
|
16
|
1 |
|
from rdkit import Chem |
|
|
|
|
17
|
1 |
|
from rdkit.Chem.rdchem import GetPeriodicTable |
|
|
|
|
18
|
1 |
|
from rdkit.Chem.AtomPairs.Utils import NumPiElectrons |
|
|
|
|
19
|
|
|
|
20
|
1 |
|
from .base import ChemicalObject, PropertyView, ChemicalObjectView |
21
|
1 |
|
from ..resource import PERIODIC_TABLE |
22
|
|
|
|
23
|
|
|
|
24
|
1 |
|
RD_PT = GetPeriodicTable() |
25
|
|
|
|
26
|
|
|
|
27
|
1 |
|
class Atom(Chem.rdchem.Atom, ChemicalObject): |
|
|
|
|
28
|
|
|
|
29
|
|
|
""" Object representing an Atom in scikit-chem. """ |
30
|
|
|
|
31
|
1 |
|
@property |
32
|
|
|
def index(self): |
33
|
|
|
|
34
|
|
|
""" int: the index of the atom. """ |
35
|
|
|
|
36
|
1 |
|
return self.GetIdx() |
|
|
|
|
37
|
|
|
|
38
|
1 |
|
@property |
39
|
|
|
def owner(self): |
40
|
|
|
|
41
|
|
|
""" skchem.Mol: the owning molecule. |
42
|
|
|
|
43
|
|
|
Warnings: |
44
|
|
|
This will seg fault if the atom is created manually. |
45
|
|
|
""" |
46
|
1 |
|
from .mol import Mol |
47
|
1 |
|
return Mol.from_super(self.GetOwningMol()) |
|
|
|
|
48
|
|
|
|
49
|
1 |
|
@property |
50
|
|
|
def bonds(self): |
51
|
|
|
|
52
|
|
|
""" tuple<skchem.Bonds>: the bonds to this `Atom`. """ |
53
|
|
|
|
54
|
1 |
|
from .bond import Bond # as bond imports atom, have to do it here |
55
|
1 |
|
return tuple(Bond.from_super(bond) for bond in self.GetBonds()) |
|
|
|
|
56
|
|
|
|
57
|
1 |
|
def neighbours(self): |
58
|
|
|
|
59
|
|
|
""" tuple<Atom>: the neighbours of the atom. """ |
60
|
|
|
|
61
|
1 |
|
return tuple(Atom.from_super(neigh) for neigh in self.GetNeighbors()) |
|
|
|
|
62
|
|
|
|
63
|
1 |
|
@property |
64
|
|
|
def symbol(self): |
65
|
|
|
|
66
|
|
|
""" str: the element symbol of the atom. """ |
67
|
|
|
|
68
|
1 |
|
return self.GetSymbol() |
|
|
|
|
69
|
|
|
|
70
|
1 |
|
@property |
71
|
|
|
def atomic_number(self): |
72
|
|
|
|
73
|
|
|
""" int: the atomic number of the atom. """ |
74
|
|
|
|
75
|
1 |
|
return self.GetAtomicNum() |
|
|
|
|
76
|
|
|
|
77
|
1 |
|
@property |
78
|
|
|
def atomic_mass(self): |
79
|
|
|
|
80
|
|
|
""" float: the atomic mass of the atom in u. """ |
81
|
|
|
|
82
|
1 |
|
return self.GetMass() |
|
|
|
|
83
|
|
|
|
84
|
1 |
|
@property |
85
|
|
|
def formal_charge(self): |
86
|
|
|
|
87
|
|
|
""" int: the formal charge. """ |
88
|
|
|
|
89
|
1 |
|
return int(self.GetFormalCharge()) |
|
|
|
|
90
|
|
|
|
91
|
1 |
|
@property |
92
|
|
|
def degree(self): |
93
|
|
|
|
94
|
|
|
""" int: the degree of the atom. """ |
95
|
|
|
|
96
|
1 |
|
return self.GetDegree() |
|
|
|
|
97
|
|
|
|
98
|
1 |
|
@property |
99
|
|
|
def depleted_degree(self): |
100
|
|
|
|
101
|
|
|
""" int: the degree of the atom in the h depleted molecular graph. """ |
102
|
|
|
|
103
|
1 |
|
return self.degree - self.n_instanced_hs |
104
|
|
|
|
105
|
1 |
|
@property |
106
|
|
|
def full_degree(self): |
107
|
|
|
|
108
|
|
|
""" int: the full degree of the atom in the h full molecular graph. """ |
109
|
|
|
|
110
|
1 |
|
return self.degree + self.n_hs |
111
|
|
|
|
112
|
1 |
|
@property |
113
|
|
|
def valence_degree(self): |
114
|
|
|
|
115
|
|
|
""" int: the valence degree. |
|
|
|
|
116
|
|
|
|
117
|
|
|
$$ \delta_i^v = Z_i^v - h_i $$ |
118
|
|
|
|
119
|
|
|
Where $ Z_i^v $ is the number of valence electrons and $ h_i $ is the |
120
|
|
|
number of hydrogens. |
121
|
|
|
""" |
122
|
|
|
|
123
|
1 |
|
res = self.n_val_electrons - self.n_hs |
124
|
|
|
|
125
|
|
|
# this seems drastic... |
126
|
|
|
#if self.principal_quantum_number > 2: |
127
|
|
|
# res /= self.atomic_number - self.n_val_electrons - 1 |
128
|
|
|
|
129
|
1 |
|
return res |
130
|
|
|
|
131
|
1 |
|
@property |
132
|
|
|
def n_hs(self): |
133
|
|
|
|
134
|
|
|
""" int: the instanced, implicit and explicit number of hydrogens """ |
135
|
|
|
|
136
|
1 |
|
return self.GetTotalNumHs() + self.n_instanced_hs |
|
|
|
|
137
|
|
|
|
138
|
1 |
|
@property |
139
|
|
|
def n_implicit_hs(self): |
140
|
|
|
|
141
|
|
|
""" int: the number of implicit hydrogens. """ |
142
|
|
|
|
143
|
1 |
|
return self.GetNumExplicitHs() |
|
|
|
|
144
|
|
|
|
145
|
1 |
|
@property |
146
|
|
|
def n_explicit_hs(self): |
147
|
|
|
|
148
|
|
|
""" int: the number of explicit hydrogens. """ |
149
|
|
|
|
150
|
1 |
|
return self.GetNumImplicitHs() |
|
|
|
|
151
|
|
|
|
152
|
1 |
|
@property |
153
|
|
|
def n_instanced_hs(self): |
154
|
|
|
|
155
|
|
|
""" int: The number of instanced hydrogens. """ |
156
|
|
|
|
157
|
1 |
|
return sum(a.atomic_number == 1 |
158
|
|
|
for a in self.neighbours()) |
159
|
|
|
|
160
|
1 |
|
@property |
161
|
|
|
def n_total_hs(self): |
162
|
|
|
|
163
|
|
|
""" int: the total number of hydrogens (according to rdkit). """ |
164
|
|
|
|
165
|
1 |
|
return self.GetTotalNumHs() |
|
|
|
|
166
|
|
|
|
167
|
1 |
|
@property |
168
|
|
|
def n_val_electrons(self): |
169
|
|
|
|
170
|
|
|
""" int: the number of valence electrons. """ |
171
|
|
|
|
172
|
1 |
|
return RD_PT.GetNOuterElecs(self.atomic_number) |
173
|
|
|
|
174
|
1 |
|
@property |
175
|
|
|
def n_pi_electrons(self): |
176
|
|
|
|
177
|
|
|
""" int: the number of pi electrons. """ |
178
|
|
|
|
179
|
1 |
|
return NumPiElectrons(self) |
180
|
|
|
|
181
|
1 |
|
@property |
182
|
|
|
def n_lone_pairs(self): |
183
|
|
|
|
184
|
|
|
""" int: the number of lone pairs. """ |
185
|
|
|
|
186
|
1 |
|
return int(0.5 * (self.n_val_electrons - self.full_degree - |
187
|
|
|
self.formal_charge - self.n_pi_electrons)) |
188
|
|
|
|
189
|
1 |
|
@property |
190
|
|
|
def explicit_valence(self): |
191
|
|
|
|
192
|
|
|
""" int: the explicit valence. """ |
193
|
|
|
|
194
|
1 |
|
return self.GetExplicitValence() |
|
|
|
|
195
|
|
|
|
196
|
1 |
|
@property |
197
|
|
|
def implicit_valence(self): |
198
|
|
|
|
199
|
|
|
""" int: the implicit valence. """ |
200
|
|
|
|
201
|
1 |
|
return self.GetImplicitValence() |
|
|
|
|
202
|
|
|
|
203
|
1 |
|
@property |
204
|
|
|
def valence(self): |
205
|
|
|
|
206
|
|
|
""" int: the valence. """ |
207
|
|
|
|
208
|
1 |
|
return self.GetTotalValence() |
|
|
|
|
209
|
|
|
|
210
|
1 |
|
@property |
211
|
|
|
def hybridization_state(self): |
212
|
|
|
|
213
|
|
|
""" str: the hybridization state. """ |
214
|
|
|
|
215
|
1 |
|
return self.GetHybridization().name |
|
|
|
|
216
|
|
|
|
217
|
1 |
|
@property |
218
|
|
|
def chiral_tag(self): |
219
|
|
|
|
220
|
|
|
""" int: the chiral tag. """ |
221
|
|
|
|
222
|
1 |
|
return self.GetChiralTag() |
|
|
|
|
223
|
|
|
|
224
|
1 |
|
@property |
225
|
|
|
def cahn_ingold_prelog(self): |
226
|
|
|
|
227
|
|
|
""" The Cahn Ingold Prelog chirality indicator. """ |
228
|
1 |
|
try: |
229
|
1 |
|
return self.props['_CIPCode'] |
230
|
1 |
|
except KeyError: |
231
|
1 |
|
if self.owner is not None: |
232
|
1 |
|
Chem.FindMolChiralCenters(self.owner) |
233
|
1 |
|
return self.props.get('_CIPCode', None) |
234
|
|
|
|
235
|
1 |
|
@property |
236
|
|
|
def is_terminal(self): |
237
|
|
|
""" bool: whether the atom is terminal. """ |
238
|
|
|
|
239
|
1 |
|
return self.depleted_degree == 1 |
240
|
|
|
|
241
|
1 |
|
@property |
242
|
|
|
def is_aromatic(self): |
243
|
|
|
|
244
|
|
|
""" bool: whether the atom is aromatic. """ |
245
|
|
|
|
246
|
1 |
|
return self.GetIsAromatic() |
|
|
|
|
247
|
|
|
|
248
|
1 |
|
@property |
249
|
|
|
def is_in_ring(self): |
250
|
|
|
|
251
|
|
|
""" bool: whether the atom is in a ring. """ |
252
|
|
|
|
253
|
1 |
|
return any(b.is_in_ring for b in self.bonds) |
254
|
|
|
|
255
|
1 |
|
@property |
256
|
|
|
def van_der_waals_radius(self): |
257
|
|
|
|
258
|
|
|
""" float: the Van der Waals radius in angstroms. """ |
259
|
|
|
|
260
|
1 |
|
return PERIODIC_TABLE.van_der_waals_radius[self.atomic_number] |
261
|
|
|
|
262
|
1 |
|
@property |
263
|
|
|
def van_der_waals_volume(self): |
264
|
|
|
|
265
|
|
|
""" float: the van der waals volume in angstroms^3. |
|
|
|
|
266
|
|
|
|
267
|
|
|
$\frac{4}{3} \pi r_v^3 $ """ |
268
|
|
|
|
269
|
1 |
|
return PERIODIC_TABLE.van_der_waals_volume[self.atomic_number] |
270
|
|
|
|
271
|
1 |
|
_cov_dict = { |
272
|
|
|
6: {'SP': 0.60, 'SP2': 0.67, 'SP3': 0.77}, |
273
|
|
|
7: {'SP': 0.55, 'SP2': 0.62, 'SP3': 0.74}, |
274
|
|
|
8: {'SP2': 0.62, 'SP3': 0.74}, |
275
|
|
|
9: {'SP3': 0.72}, |
276
|
|
|
15: {'SP2': 1.00, 'SP3': 1.10}, |
277
|
|
|
16: {'SP2': 0.97, 'SP3': 1.04}, |
278
|
|
|
17: {'SP3': 0.99}, |
279
|
|
|
35: {'SP3': 1.14}, |
280
|
|
|
55: {'SP3': 1.33} |
281
|
|
|
} |
282
|
|
|
|
283
|
1 |
|
@property |
284
|
|
|
def covalent_radius(self): |
285
|
|
|
|
286
|
|
|
""" float: the covalent radius in angstroms. """ |
287
|
|
|
|
288
|
1 |
|
if self.atomic_number in self._cov_dict.keys(): |
289
|
1 |
|
hstate = self.hybridization_state |
290
|
1 |
|
hstate = 'SP3' if hstate == 'UNSPECIFIED' else hstate |
291
|
1 |
|
return self._cov_dict[self.atomic_number][hstate] |
292
|
|
|
else: |
293
|
1 |
|
return PERIODIC_TABLE.covalent_radius[self.atomic_number] |
294
|
|
|
|
295
|
1 |
|
@property |
296
|
|
|
def ionisation_energy(self): |
297
|
|
|
|
298
|
|
|
""" float: the first ionisation energy in eV. """ |
299
|
|
|
|
300
|
1 |
|
return PERIODIC_TABLE.first_ionisation_energy[self.atomic_number] |
301
|
|
|
|
302
|
1 |
|
@property |
303
|
|
|
def electron_affinity(self): |
304
|
|
|
|
305
|
|
|
""" float: the first electron affinity in eV. """ |
306
|
|
|
|
307
|
1 |
|
return PERIODIC_TABLE.electron_affinity[self.atomic_number] |
308
|
|
|
|
309
|
1 |
|
@property |
310
|
|
|
def principal_quantum_number(self): |
311
|
|
|
|
312
|
|
|
""" int: the principle quantum number. """ |
313
|
|
|
|
314
|
1 |
|
return np.digitize(self.atomic_number, |
315
|
|
|
np.array([1, 3, 11, 19, 37, 55, 87, 121])) |
316
|
|
|
|
317
|
1 |
|
@property |
318
|
|
|
def polarisability(self): |
319
|
|
|
|
320
|
|
|
""" float: the atomic polarisability in 10^{-20} m^3. """ |
321
|
|
|
|
322
|
1 |
|
return PERIODIC_TABLE.atomic_polarisability[self.atomic_number] |
323
|
|
|
|
324
|
1 |
|
@property |
325
|
|
|
def pauling_electronegativity(self): |
326
|
|
|
|
327
|
|
|
""" float: the pauling electronegativity on Pauling scale. """ |
328
|
|
|
|
329
|
1 |
|
return PERIODIC_TABLE.pauling_electronegativity[self.atomic_number] |
330
|
|
|
|
331
|
1 |
|
@property |
332
|
|
|
def sanderson_electronegativity(self): |
333
|
|
|
|
334
|
|
|
""" float: the sanderson electronegativity on Pauling scale. """ |
335
|
|
|
|
336
|
1 |
|
return PERIODIC_TABLE.sanderson_electronegativity[self.atomic_number] |
337
|
|
|
|
338
|
1 |
|
@property |
339
|
|
|
def kier_hall_electronegativity(self): |
340
|
|
|
|
341
|
|
|
""" float: the hall-keir electronegativity. """ |
342
|
|
|
|
343
|
1 |
|
if self.atomic_number == 1: |
344
|
1 |
|
return -0.2 |
345
|
|
|
else: |
346
|
|
|
# py2 compat |
347
|
1 |
|
return float(self.valence_degree - self.depleted_degree) / \ |
348
|
|
|
(self.principal_quantum_number ** 2) |
349
|
|
|
|
350
|
1 |
|
@property |
351
|
|
|
def mcgowan_parameter(self): |
352
|
|
|
|
353
|
|
|
""" float: the mcgowan volume parameter""" |
354
|
|
|
|
355
|
1 |
|
return PERIODIC_TABLE.mcgowan_parameter[self.atomic_number] |
356
|
|
|
|
357
|
1 |
|
@property |
358
|
|
|
def kier_hall_alpha_contrib(self): |
359
|
|
|
|
360
|
|
|
""" float: the covalent radius in angstroms. """ |
361
|
|
|
|
362
|
1 |
|
return self.covalent_radius / 0.77 - 1 # 0.77 is sp3 C |
363
|
|
|
|
364
|
1 |
|
@property |
365
|
|
|
def intrinsic_state(self): |
366
|
|
|
|
367
|
|
|
""" float: the intrinsic state of the atom. """ |
368
|
|
|
|
369
|
|
|
# py2compat |
370
|
1 |
|
return ((2. / self.principal_quantum_number) ** 2 * |
371
|
|
|
self.valence_degree + 1) / self.depleted_degree |
372
|
|
|
|
373
|
1 |
|
@property |
374
|
|
|
def hexcode(self): |
375
|
|
|
|
376
|
|
|
""" The hexcode to use as a color for the atom. """ |
377
|
|
|
|
378
|
1 |
|
return PERIODIC_TABLE.hexcode[self.atomic_number] |
379
|
|
|
|
380
|
1 |
|
@property |
381
|
|
|
def props(self): |
382
|
|
|
|
383
|
|
|
""" PropertyView: rdkit properties of the atom. """ |
384
|
|
|
|
385
|
1 |
|
if not hasattr(self, '_props'): |
386
|
1 |
|
self._props = PropertyView(self) |
|
|
|
|
387
|
1 |
|
return PropertyView(self) |
388
|
|
|
|
389
|
1 |
|
def __repr__(self): |
390
|
|
|
|
391
|
1 |
|
return '<{klass} element="{symbol}" at {address}>'.format( |
392
|
|
|
klass=self.__class__.__name__, |
393
|
|
|
symbol=self.symbol, |
394
|
|
|
address=hex(id(self)) |
395
|
|
|
) |
396
|
|
|
|
397
|
1 |
|
def __str__(self): |
398
|
|
|
|
399
|
1 |
|
return self.symbol |
400
|
|
|
|
401
|
|
|
|
402
|
1 |
|
class AtomView(ChemicalObjectView): |
|
|
|
|
403
|
|
|
|
404
|
1 |
|
def __getitem__(self, index): |
405
|
1 |
|
res = super(AtomView, self).__getitem__(index) |
406
|
1 |
|
if res is None: |
407
|
1 |
|
if np.abs(index) >= len(self): |
408
|
1 |
|
msg = 'Index {} out of range for molecule with' \ |
409
|
|
|
'{} atoms.'.format(index, len(self)) |
410
|
1 |
|
raise IndexError(msg) |
411
|
|
|
|
412
|
|
|
# index is negative, so adding gives desired indexing from back |
413
|
1 |
|
if index < 0: |
414
|
1 |
|
index += len(self) |
415
|
|
|
|
416
|
1 |
|
return Atom.from_super(self.owner.GetAtomWithIdx(index)) |
417
|
|
|
|
418
|
|
|
else: |
419
|
1 |
|
return res |
420
|
|
|
|
421
|
1 |
|
def __len__(self): |
422
|
1 |
|
return self.owner.GetNumAtoms() |
423
|
|
|
|
424
|
1 |
|
@property |
425
|
|
|
def symbol(self): |
426
|
|
|
|
427
|
|
|
""" np.array<str>: the symbols of the atoms in view """ |
428
|
|
|
|
429
|
1 |
|
return np.array([atom.symbol for atom in self], dtype=(np.str_, 3)) |
430
|
|
|
|
431
|
1 |
|
@property |
432
|
|
|
def atomic_number(self): |
433
|
|
|
|
434
|
|
|
""" np.array<int>: the atomic number of the atoms in view """ |
435
|
|
|
|
436
|
1 |
|
return np.array([atom.atomic_number for atom in self]) |
437
|
|
|
|
438
|
1 |
|
@property |
439
|
|
|
def atomic_mass(self): |
440
|
|
|
|
441
|
|
|
""" np.array<float>: the atomic mass of the atoms in view """ |
442
|
|
|
|
443
|
1 |
|
return np.array([atom.atomic_mass for atom in self]) |
444
|
|
|
|
445
|
1 |
|
@property |
446
|
|
|
def formal_charge(self): |
447
|
|
|
|
448
|
|
|
""" np.array<int>: the formal charge on the atoms in view """ |
449
|
|
|
|
450
|
1 |
|
return np.array([atom.formal_charge for atom in self]) |
451
|
|
|
|
452
|
1 |
|
@property |
453
|
|
|
def degree(self): |
454
|
|
|
|
455
|
|
|
""" np.array<int>: the degree of the atoms in view, according to |
456
|
|
|
rdkit. """ |
457
|
|
|
|
458
|
1 |
|
return np.array([atom.degree for atom in self]) |
459
|
|
|
|
460
|
1 |
|
@property |
461
|
|
|
def depleted_degree(self): |
462
|
|
|
|
463
|
|
|
""" np.array<int>: the degree of the atoms in the view in the |
464
|
|
|
h-depleted molecular graph. """ |
465
|
|
|
|
466
|
1 |
|
return np.array([atom.depleted_degree for atom in self]) |
467
|
|
|
|
468
|
1 |
|
@property |
469
|
|
|
def full_degree(self): |
470
|
|
|
|
471
|
|
|
""" np.array<int>: the degree of the atoms in the view in the |
472
|
|
|
h-filled molecular graph. """ |
473
|
|
|
|
474
|
1 |
|
return np.array([atom.full_degree for atom in self]) |
475
|
|
|
|
476
|
1 |
|
@property |
477
|
|
|
def valence_degree(self): |
478
|
|
|
|
479
|
|
|
""" np.array<int>: the valence degree of the atoms in the view.""" |
480
|
|
|
|
481
|
1 |
|
return np.array([atom.valence_degree for atom in self]) |
482
|
|
|
|
483
|
1 |
|
@property |
484
|
|
|
def n_hs(self): |
485
|
|
|
|
486
|
|
|
""" np.array<int>: the number of hydrogens bonded to atoms in view. """ |
487
|
|
|
|
488
|
1 |
|
return np.array([atom.n_hs for atom in self]) |
489
|
|
|
|
490
|
1 |
|
@property |
491
|
|
|
def n_implicit_hs(self): |
492
|
|
|
|
493
|
|
|
""" np.array<int>: the number of implicit hydrogens bonded to atoms |
494
|
|
|
in view, according to rdkit. """ |
495
|
|
|
|
496
|
1 |
|
return np.array([atom.n_implicit_hs for atom in self]) |
497
|
|
|
|
498
|
1 |
|
@property |
499
|
|
|
def n_explicit_hs(self): |
500
|
|
|
|
501
|
|
|
""" np.array<int>: the number of explicit hydrogens bonded to atoms |
502
|
|
|
in view, according to rdkit. """ |
503
|
|
|
|
504
|
1 |
|
return np.array([atom.n_explicit_hs for atom in self]) |
505
|
|
|
|
506
|
1 |
|
@property |
507
|
|
|
def n_instanced_hs(self): |
508
|
|
|
|
509
|
|
|
""" np.array<int>: the number of instanced hydrogens bonded to atoms |
510
|
|
|
in view. |
511
|
|
|
|
512
|
|
|
In this case, instanced means the number hs explicitly initialized as |
513
|
|
|
atoms. """ |
514
|
|
|
|
515
|
1 |
|
return np.array([atom.n_instanced_hs for atom in self]) |
516
|
|
|
|
517
|
1 |
|
@property |
518
|
|
|
def n_total_hs(self): |
519
|
|
|
|
520
|
|
|
""" np.array<int>: the number of total hydrogens bonded to atoms in |
521
|
|
|
view, according to rdkit. """ |
522
|
|
|
|
523
|
1 |
|
return np.array([atom.n_total_hs for atom in self]) |
524
|
|
|
|
525
|
1 |
|
@property |
526
|
|
|
def n_val_electrons(self): |
527
|
|
|
|
528
|
|
|
""" np.array<int>: the number of valence electrons bonded to atoms |
529
|
|
|
in view. """ |
530
|
|
|
|
531
|
1 |
|
return np.array([atom.n_val_electrons for atom in self]) |
532
|
|
|
|
533
|
1 |
|
@property |
534
|
|
|
def n_pi_electrons(self): |
535
|
|
|
|
536
|
|
|
""" np.array<int>: the number of pi electrons on atoms in view. """ |
537
|
|
|
|
538
|
1 |
|
return np.array([atom.n_pi_electrons for atom in self]) |
539
|
|
|
|
540
|
1 |
|
@property |
541
|
|
|
def n_lone_pairs(self): |
542
|
|
|
|
543
|
|
|
""" np.array<int>: the number of lone pairs on atoms in view. """ |
544
|
|
|
|
545
|
1 |
|
return (0.5 * (self.n_val_electrons - self.full_degree - |
546
|
|
|
self.formal_charge - self.n_pi_electrons)).astype(int) |
547
|
|
|
|
548
|
1 |
|
@property |
549
|
|
|
def explicit_valence(self): |
550
|
|
|
|
551
|
|
|
""" np.array<int>: the explicit valence of the atoms in view.. """ |
552
|
|
|
|
553
|
1 |
|
return np.array([atom.explicit_valence for atom in self]) |
554
|
|
|
|
555
|
1 |
|
@property |
556
|
|
|
def implicit_valence(self): |
557
|
|
|
|
558
|
|
|
""" np.array<int>: the explicit valence of the atoms in view. """ |
559
|
|
|
|
560
|
1 |
|
return np.array([atom.implicit_valence for atom in self]) |
561
|
|
|
|
562
|
1 |
|
@property |
563
|
|
|
def valence(self): |
564
|
|
|
|
565
|
|
|
""" np.array<int>: the valence of the atoms in view. """ |
566
|
|
|
|
567
|
1 |
|
return np.array([atom.valence for atom in self]) |
568
|
|
|
|
569
|
1 |
|
@property |
570
|
|
|
def hybridization_state(self): |
571
|
|
|
|
572
|
|
|
""" np.array<str>: the hybridization state of the atoms in view. |
573
|
|
|
|
574
|
|
|
One of 'SP', 'SP2', 'SP3', 'SP3D', 'SP3D2', 'UNSPECIFIED', 'OTHER'""" |
575
|
|
|
|
576
|
1 |
|
return np.array([atom.hybridization_state for atom in self]) |
577
|
|
|
|
578
|
1 |
|
@property |
579
|
|
|
def chiral_tag(self): |
580
|
|
|
|
581
|
|
|
""" np.array<str>: the chiral tag of the atoms in view. """ |
582
|
|
|
|
583
|
1 |
|
return np.array([atom.chiral_tag for atom in self]) |
584
|
|
|
|
585
|
1 |
|
@property |
586
|
|
|
def cahn_ingold_prelog(self): |
587
|
|
|
|
588
|
|
|
""" np.array<str>: the CIP string representation of atoms in view. """ |
589
|
|
|
|
590
|
1 |
|
return np.array([atom.cahn_ingold_prelog for atom in self], |
591
|
|
|
(np.str_, 4)) |
592
|
|
|
|
593
|
1 |
|
@property |
594
|
|
|
def is_terminal(self): |
595
|
|
|
|
596
|
|
|
""" np.array<bool>: whether the atoms in the view are terminal. """ |
597
|
|
|
|
598
|
1 |
|
return self.depleted_degree == 1 |
599
|
|
|
|
600
|
1 |
|
@property |
601
|
|
|
def is_aromatic(self): |
602
|
|
|
|
603
|
|
|
""" np.array<bool>: whether the atoms in the view are aromatic. """ |
604
|
|
|
|
605
|
1 |
|
return np.array([atom.is_aromatic for atom in self]) |
606
|
|
|
|
607
|
1 |
|
@property |
608
|
|
|
def is_in_ring(self): |
609
|
|
|
|
610
|
|
|
""" np.array<bool>: whether the atoms in the view are in a ring.""" |
611
|
|
|
|
612
|
1 |
|
return np.array([atom.is_in_ring for atom in self]) |
613
|
|
|
|
614
|
1 |
|
@property |
615
|
|
|
def van_der_waals_radius(self): |
616
|
|
|
|
617
|
|
|
""" np.array<float>: the Van der Waals radius of the atoms in the |
618
|
|
|
view. """ |
619
|
|
|
|
620
|
1 |
|
return PERIODIC_TABLE.van_der_waals_radius[self.atomic_number].values |
621
|
|
|
|
622
|
1 |
|
@property |
623
|
|
|
def van_der_waals_volume(self): |
624
|
|
|
|
625
|
|
|
""" np.array<float>: the Van der Waals volume of the atoms in the |
626
|
|
|
view. """ |
627
|
|
|
|
628
|
1 |
|
return PERIODIC_TABLE.van_der_waals_volume[self.atomic_number].values |
629
|
|
|
|
630
|
1 |
|
@property |
631
|
|
|
def covalent_radius(self): |
632
|
|
|
|
633
|
|
|
""" np.array<float>: the covalent radius of the atoms in the view. """ |
634
|
|
|
|
635
|
1 |
|
return np.array([atom.covalent_radius for atom in self]) |
636
|
|
|
|
637
|
1 |
|
@property |
638
|
|
|
def ionisation_energy(self): |
639
|
|
|
|
640
|
|
|
""" np.array<float>: the first ionisation energy of the atoms in the |
641
|
|
|
view. """ |
642
|
|
|
|
643
|
1 |
|
return PERIODIC_TABLE.first_ionisation_energy[ |
644
|
|
|
self.atomic_number].values |
645
|
|
|
|
646
|
1 |
|
@property |
647
|
|
|
def electron_affinity(self): |
648
|
|
|
|
649
|
|
|
""" np.array<float>: the electron affinity of the atoms in the |
650
|
|
|
view. """ |
651
|
|
|
|
652
|
1 |
|
return PERIODIC_TABLE.electron_affinity[self.atomic_number].values |
653
|
|
|
|
654
|
1 |
|
@property |
655
|
|
|
def principal_quantum_number(self): |
656
|
|
|
|
657
|
|
|
""" np.array<float>: the principal quantum number of the atoms in the |
658
|
|
|
view. """ |
659
|
|
|
|
660
|
1 |
|
return np.digitize(self.atomic_number, |
661
|
|
|
np.array([1, 3, 11, 19, 37, 55, 87, 121])) |
662
|
|
|
|
663
|
1 |
|
@property |
664
|
|
|
def polarisability(self): |
665
|
|
|
|
666
|
|
|
""" np.array<float>: the atomic polarisability of the atoms in the |
667
|
|
|
view. """ |
668
|
|
|
|
669
|
1 |
|
return PERIODIC_TABLE.atomic_polarisability[self.atomic_number].values |
670
|
|
|
|
671
|
1 |
|
@property |
672
|
|
|
def pauling_electronegativity(self): |
673
|
|
|
|
674
|
|
|
""" np.array<float>: the pauling electronegativity of the atoms in the |
675
|
|
|
view. """ |
676
|
|
|
|
677
|
1 |
|
return PERIODIC_TABLE.pauling_electronegativity[ |
678
|
|
|
self.atomic_number].values |
679
|
|
|
|
680
|
1 |
|
@property |
681
|
|
|
def sanderson_electronegativity(self): |
682
|
|
|
|
683
|
|
|
""" np.array<float>: the sanderson electronegativity of the atoms in |
684
|
|
|
the view. """ |
685
|
|
|
|
686
|
1 |
|
return PERIODIC_TABLE.sanderson_electronegativity[ |
687
|
|
|
self.atomic_number].values |
688
|
|
|
|
689
|
1 |
|
@property |
690
|
|
|
def kier_hall_electronegativity(self): |
691
|
|
|
|
692
|
|
|
""" np.array<float>: the hall kier electronegativity of the atoms in |
693
|
|
|
the view.""" |
694
|
|
|
|
695
|
1 |
|
return np.array([atom.kier_hall_electronegativity for atom in self]) |
696
|
|
|
|
697
|
1 |
|
@property |
698
|
|
|
def mcgowan_parameter(self): |
699
|
|
|
|
700
|
|
|
""" np.array<float>: the mcgowan parameter of the atoms in the |
701
|
|
|
iew. """ |
702
|
|
|
|
703
|
1 |
|
return PERIODIC_TABLE.mcgowan_parameter[self.atomic_number].values |
704
|
|
|
|
705
|
1 |
|
@property |
706
|
|
|
def kier_hall_alpha_contrib(self): |
707
|
|
|
|
708
|
|
|
""" np.array<float>: the contribution to the kier hall alpha for each |
709
|
|
|
atom in the view. """ |
710
|
|
|
|
711
|
1 |
|
return self.covalent_radius / 0.77 - 1 |
712
|
|
|
|
713
|
1 |
|
@property |
714
|
|
|
def intrinsic_state(self): |
715
|
|
|
|
716
|
|
|
""" np.ndarray<float>: the intrinsic state of the atoms in the |
717
|
|
|
view. """ |
718
|
|
|
|
719
|
|
|
#py2 compat |
720
|
1 |
|
return ((2. / self.principal_quantum_number).astype(float) ** 2 * |
721
|
|
|
self.valence_degree + 1) / self.depleted_degree |
722
|
|
|
|
723
|
1 |
|
@property |
724
|
|
|
def hexcode(self): |
725
|
|
|
|
726
|
|
|
""" The hexcode to use as a color for the atoms in the view. """ |
727
|
|
|
|
728
|
1 |
|
return PERIODIC_TABLE.hexcode[self.atomic_number].values |
729
|
|
|
|
730
|
1 |
|
def adjacency_matrix(self, bond_orders=False, force=True): |
731
|
|
|
|
732
|
|
|
""" The vertex adjacency matrix. |
733
|
|
|
|
734
|
|
|
Args: |
735
|
|
|
bond_orders (bool): |
736
|
|
|
Whether to use bond orders. |
737
|
|
|
force (bool): |
738
|
|
|
Whether to recalculate or used rdkit cached value. |
739
|
|
|
|
740
|
|
|
Returns: |
741
|
|
|
np.array[int] |
742
|
|
|
""" |
743
|
|
|
|
744
|
1 |
|
return Chem.GetAdjacencyMatrix(self.owner, useBO=bond_orders, |
745
|
|
|
force=force) |
746
|
|
|
|
747
|
1 |
|
def distance_matrix(self, bond_orders=False, force=True): |
748
|
|
|
|
749
|
|
|
""" The vertex distance matrix. |
750
|
|
|
|
751
|
|
|
Args: |
752
|
|
|
bond_orders (bool): |
753
|
|
|
Whether to use bond orders. |
754
|
|
|
force (bool): |
755
|
|
|
Whether to recalculate or used rdkit cached value. |
756
|
|
|
|
757
|
|
|
Returns: |
758
|
|
|
np.array[int] |
759
|
|
|
""" |
760
|
|
|
|
761
|
1 |
|
return Chem.GetDistanceMatrix(self.owner, useBO=bond_orders, |
762
|
|
|
force=force) |
763
|
|
|
|
764
|
1 |
|
@property |
765
|
|
|
def index(self): |
766
|
|
|
|
767
|
|
|
""" pd.Index: an index for the atoms in the view. """ |
768
|
|
|
|
769
|
|
|
return pd.RangeIndex(len(self), name='atom_idx') |
770
|
|
|
|
This can be caused by one of the following:
1. Missing Dependencies
This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.
2. Missing __init__.py files
This error could also result from missing
__init__.py
files in your module folders. Make sure that you place one file in each sub-folder.