Completed
Push — master ( 87dea9...e88bec )
by Rich
15:57
created

AtomView.index()   A

Complexity

Conditions 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 5
ccs 2
cts 2
cp 1
rs 9.4285
cc 1
crap 1
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
0 ignored issues
show
Configuration introduced by
The import numpy could not be resolved.

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.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

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.

Loading history...
14
import pandas as pd
0 ignored issues
show
Configuration introduced by
The import pandas could not be resolved.

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.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

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.

Loading history...
15 1
16
from rdkit import Chem
0 ignored issues
show
Configuration introduced by
The import rdkit could not be resolved.

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.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

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.

Loading history...
17 1
from rdkit.Chem.rdchem import GetPeriodicTable
0 ignored issues
show
Configuration introduced by
The import rdkit.Chem.rdchem could not be resolved.

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.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

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.

Loading history...
18
from rdkit.Chem.AtomPairs.Utils import NumPiElectrons
0 ignored issues
show
Configuration introduced by
The import rdkit.Chem.AtomPairs.Utils could not be resolved.

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.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

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.

Loading history...
19
20 1
from .base import ChemicalObject, PropertyView, ChemicalObjectView
21
from ..resource import PERIODIC_TABLE
22
23
24 1
RD_PT = GetPeriodicTable()
25
26
27
class Atom(Chem.rdchem.Atom, ChemicalObject):
0 ignored issues
show
best-practice introduced by
Too many public methods (43/20)
Loading history...
28
29 1
    """ Object representing an Atom in scikit-chem. """
30
31 1
    @property
32
    def owner(self):
33
34
        """ skchem.Mol: the owning molecule.
35
36 1
        Warnings:
37
            This will seg fault if the atom is created manually.
38 1
        """
39
        from .mol import Mol
40
        return Mol.from_super(self.GetOwningMol())
0 ignored issues
show
Bug introduced by
The Instance of Atom does not seem to have a member named GetOwningMol.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
41
42
    @property
43
    def bonds(self):
44
45 1
        """ tuple<skchem.Bonds>: the bonds to this `Atom`. """
46
47 1
        from .bond import Bond  # as bond imports atom, have to do it here
48
        return tuple(Bond.from_super(bond) for bond in self.GetBonds())
0 ignored issues
show
Bug introduced by
The Instance of Atom does not seem to have a member named GetBonds.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
49
50
    def neighbours(self):
51
52 1
        """ tuple<Atom>: the neighbours of the atom. """
53 1
54 1
        return tuple(Atom.from_super(neigh) for neigh in self.GetNeighbors())
0 ignored issues
show
Bug introduced by
The Instance of Atom does not seem to have a member named GetNeighbors.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
55
56 1
    @property
57
    def symbol(self):
58
59
        """ str: the element symbol of the atom. """
60
61
        return self.GetSymbol()
0 ignored issues
show
Bug introduced by
The Instance of Atom does not seem to have a member named GetSymbol.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
62
63
    @property
64 1
    def atomic_number(self):
65
66 1
        """ int: the atomic number of the atom. """
67
68
        return self.GetAtomicNum()
0 ignored issues
show
Bug introduced by
The Instance of Atom does not seem to have a member named GetAtomicNum.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
69 1
70
    @property
71 1
    def atomic_mass(self):
72 1
73 1
        """ float: the atomic mass of the atom in u. """
74 1
75
        return self.GetMass()
0 ignored issues
show
Bug introduced by
The Instance of Atom does not seem to have a member named GetMass.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
76
77
    @property
78
    def formal_charge(self):
79 1
80
        """ int: the formal charge. """
81
82
        return int(self.GetFormalCharge())
0 ignored issues
show
Bug introduced by
The Instance of Atom does not seem to have a member named GetFormalCharge.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
83 1
84 1
    @property
85
    def degree(self):
86 1
87
        """ int: the degree of the atom. """
88
89
        return self.GetDegree()
0 ignored issues
show
Bug introduced by
The Instance of Atom does not seem to have a member named GetDegree.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
90 1
91
    @property
92 1
    def depleted_degree(self):
93
94
        """ int: the degree of the atom in the h depleted molecular graph. """
95
96
        return self.degree - self.n_instanced_hs
97
98
    @property
99 1
    def full_degree(self):
100
101
        """ int: the full degree of the atom in the h full molecular graph. """
102
103
        return self.degree + self.n_hs
104
105 1
    @property
106
    def valence_degree(self):
107
108
        """ int: the valence degree.
0 ignored issues
show
Bug introduced by
A suspicious escape sequence \d was found. Did you maybe forget to add an r prefix?

Escape sequences in Python are generally interpreted according to rules similar to standard C. Only if strings are prefixed with r or R are they interpreted as regular expressions.

The escape sequence that was used indicates that you might have intended to write a regular expression.

Learn more about the available escape sequences. in the Python documentation.

Loading history...
109 1
110
        $$ \delta_i^v = Z_i^v - h_i $$
111
112
        Where $ Z_i^v $ is the number of valence electrons and $ h_i $ is the
113
        number of hydrogens.
114
        """
115
116
        res = self.n_val_electrons - self.n_hs
117
118
        # this seems drastic...
119
        #if self.principal_quantum_number > 2:
120
        #    res /= self.atomic_number - self.n_val_electrons - 1
121
122
        return res
123
124
    @property
125
    def n_hs(self):
126
127
        """ int: the instanced, implicit and explicit number of hydrogens """
128
129
        return self.GetTotalNumHs() + self.n_instanced_hs
0 ignored issues
show
Bug introduced by
The Instance of Atom does not seem to have a member named GetTotalNumHs.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
130
131
    @property
132
    def n_implicit_hs(self):
133
134
        """ int: the number of implicit hydrogens. """
135
136
        return self.GetNumExplicitHs()
0 ignored issues
show
Bug introduced by
The Instance of Atom does not seem to have a member named GetNumExplicitHs.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
137
138
    @property
139
    def n_explicit_hs(self):
140
141
        """ int: the number of explicit hydrogens. """
142
143
        return self.GetNumImplicitHs()
0 ignored issues
show
Bug introduced by
The Instance of Atom does not seem to have a member named GetNumImplicitHs.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
144
145
    @property
146
    def n_instanced_hs(self):
147
148
        """ int: The number of instanced hydrogens. """
149
150
        return sum(a.atomic_number == 1
151
                   for a in self.neighbours())
152
153
    @property
154
    def n_total_hs(self):
155
156
        """ int: the total number of hydrogens (according to rdkit). """
157
158
        return self.GetTotalNumHs()
0 ignored issues
show
Bug introduced by
The Instance of Atom does not seem to have a member named GetTotalNumHs.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
159
160
    @property
161
    def n_val_electrons(self):
162
163
        """ int: the number of valence electrons. """
164
165
        return RD_PT.GetNOuterElecs(self.atomic_number)
166
167
    @property
168
    def n_pi_electrons(self):
169
170
        """ int: the number of pi electrons. """
171
172
        return NumPiElectrons(self)
173
174
    @property
175
    def n_lone_pairs(self):
176
177
        """ int: the number of lone pairs. """
178
179
        return int(0.5 * (self.n_val_electrons - self.full_degree -
180
                          self.formal_charge - self.n_pi_electrons))
181
182
    @property
183
    def explicit_valence(self):
184
185
        """ int: the explicit valence. """
186
187
        return self.GetExplicitValence()
0 ignored issues
show
Bug introduced by
The Instance of Atom does not seem to have a member named GetExplicitValence.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
188
189
    @property
190
    def implicit_valence(self):
191
192
        """ int: the implicit valence. """
193
194
        return self.GetImplicitValence()
0 ignored issues
show
Bug introduced by
The Instance of Atom does not seem to have a member named GetImplicitValence.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
195
196
    @property
197
    def valence(self):
198
199
        """ int: the valence. """
200
201
        return self.GetTotalValence()
0 ignored issues
show
Bug introduced by
The Instance of Atom does not seem to have a member named GetTotalValence.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
202
203
    @property
204
    def hybridization_state(self):
205
206
        """ str: the hybridization state. """
207
208
        return self.GetHybridization().name
0 ignored issues
show
Bug introduced by
The Instance of Atom does not seem to have a member named GetHybridization.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
209
210
    @property
211
    def chiral_tag(self):
212
213
        """ int: the chiral tag. """
214
215
        return self.GetChiralTag()
0 ignored issues
show
Bug introduced by
The Instance of Atom does not seem to have a member named GetChiralTag.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
216
217
    @property
218
    def cahn_ingold_prelog(self):
219
220
        """ The Cahn Ingold Prelog chirality indicator. """
221
        try:
222
            return self.props['_CIPCode']
223
        except KeyError:
224
            if self.owner is not None:
225
                Chem.FindMolChiralCenters(self.owner)
226
        return self.props.get('_CIPCode', None)
227
228
    @property
229
    def is_terminal(self):
230
        """ bool: whether the atom is terminal. """
231
232
        return self.depleted_degree == 1
233
234
    @property
235
    def is_aromatic(self):
236
237
        """ bool: whether the atom is aromatic. """
238
239
        return self.GetIsAromatic()
0 ignored issues
show
Bug introduced by
The Instance of Atom does not seem to have a member named GetIsAromatic.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
240
241
    @property
242
    def is_in_ring(self):
243
244
        """ bool: whether the atom is in a ring. """
245
246
        return any(b.is_in_ring for b in self.bonds)
247
248
    @property
249
    def van_der_waals_radius(self):
250
251
        """ float: the Van der Waals radius in Å. """
0 ignored issues
show
Security introduced by
Cannot decode using encoding "ascii", unexpected byte at position 47
Loading history...
252
253
        return PERIODIC_TABLE.van_der_waals_radius[self.atomic_number]
254
255
    @property
256
    def van_der_waals_volume(self):
257
258
        """ float: the van der waals volume in Å^3.
0 ignored issues
show
Security introduced by
Cannot decode using encoding "ascii", unexpected byte at position 47
Loading history...
Bug introduced by
A suspicious escape sequence \p was found. Did you maybe forget to add an r prefix?

Escape sequences in Python are generally interpreted according to rules similar to standard C. Only if strings are prefixed with r or R are they interpreted as regular expressions.

The escape sequence that was used indicates that you might have intended to write a regular expression.

Learn more about the available escape sequences. in the Python documentation.

Loading history...
259
260
        $\frac{4}{3} \pi r_v^3 $ """
261
262
        return PERIODIC_TABLE.van_der_waals_volume[self.atomic_number]
263
264
    _cov_dict = {
265
        6: {'SP': 0.60, 'SP2': 0.67, 'SP3': 0.77},
266
        7: {'SP': 0.55, 'SP2': 0.62, 'SP3': 0.74},
267
        8: {'SP2': 0.62, 'SP3': 0.74},
268
        9: {'SP3': 0.72},
269
        15: {'SP2': 1.00, 'SP3': 1.10},
270
        16: {'SP2': 0.97, 'SP3': 1.04},
271
        17: {'SP3': 0.99},
272
        35: {'SP3': 1.14},
273
        55: {'SP3': 1.33}
274
    }
275
276
    @property
277
    def covalent_radius(self):
278
279
        """ float: the covalent radius in angstroms. """
280
281
        if self.atomic_number in self._cov_dict.keys():
282
            return self._cov_dict[self.atomic_number][self.hybridization_state]
283
        else:
284
            return PERIODIC_TABLE.covalent_radius[self.atomic_number]
285
286
    @property
287
    def ionisation_energy(self):
288
289
        """ float: the first ionisation energy in eV. """
290
291
        return PERIODIC_TABLE.first_ionisation_energy[self.atomic_number]
292
293
    @property
294
    def electron_affinity(self):
295
296
        """ float: the first electron affinity in eV. """
297
298
        return PERIODIC_TABLE.electron_affinity[self.atomic_number]
299
300
    @property
301
    def principal_quantum_number(self):
302
303
        """ int: the principle quantum number. """
304
305
        return np.digitize(self.atomic_number,
306
                           np.array([1, 3, 11, 19, 37, 55, 87, 121]))
307
308
    @property
309
    def polarisability(self):
310
311
        """ float: the atomic polarisability in 10^{-20} m^3. """
312
313
        return PERIODIC_TABLE.atomic_polarisability[self.atomic_number]
314
315
    @property
316
    def pauling_electronegativity(self):
317
318
        """ float: the pauling electronegativity on Pauling scale. """
319
320
        return PERIODIC_TABLE.pauling_electronegativity[self.atomic_number]
321
322
    @property
323
    def sanderson_electronegativity(self):
324
325
        """ float: the sanderson electronegativity on Pauling scale. """
326
327
        return PERIODIC_TABLE.sanderson_electronegativity[self.atomic_number]
328
329
    @property
330
    def kier_hall_electronegativity(self):
331
332
        """ float: the hall-keir electronegativity. """
333
334
        if self.atomic_number == 1:
335
            return -0.2
336
        else:
337
            return (self.valence_degree - self.depleted_degree) / \
338
                   (self.principal_quantum_number ** 2)
339
340
    @property
341
    def mcgowan_parameter(self):
342
343
        """ float: the mcgowan volume parameter"""
344
345
        return PERIODIC_TABLE.mcgowan_parameter[self.atomic_number]
346
347
    @property
348
    def kier_hall_alpha_contrib(self):
349
350
        """ float: the covalent radius in angstroms. """
351
352
        return self.covalent_radius / 0.77 - 1  # 0.77 is sp3 C
353
354
    @property
355
    def intrinsic_state(self):
356
357
        """ float: the intrinsic state of the atom. """
358
359
        return ((2 / self.principal_quantum_number) ** 2 *
360
                self.valence_degree + 1) / self.depleted_degree
361
362
    @property
363
    def hexcode(self):
364
365
        """ The hexcode to use as a color for the atom. """
366
367
        return PERIODIC_TABLE.hexcode[self.atomic_number]
368
369
    @property
370
    def props(self):
371
372
        """ PropertyView: rdkit properties of the atom. """
373
374
        if not hasattr(self, '_props'):
375
            self._props = PropertyView(self)
0 ignored issues
show
Coding Style introduced by
The attribute _props was defined outside __init__.

It is generally a good practice to initialize all attributes to default values in the __init__ method:

class Foo:
    def __init__(self, x=None):
        self.x = x
Loading history...
376
        return PropertyView(self)
377
378
    def __repr__(self):
379
380
        return '<{klass} element="{symbol}" at {address}>'.format(
381
            klass=self.__class__.__name__,
382
            symbol=self.symbol,
383
            address=hex(id(self))
384
            )
385
386
    def __str__(self):
387
388
        return self.symbol
389
390
391
class AtomView(ChemicalObjectView):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
best-practice introduced by
Too many public methods (40/20)
Loading history...
392
393
    def __getitem__(self, index):
394
        res = super(AtomView, self).__getitem__(index)
395
        if res is None:
396
            if np.abs(index) >= len(self):
397
                msg = 'Index {} out of range for molecule with' \
398
                    '{} atoms.'.format(index, len(self))
399
                raise IndexError(msg)
400
401
            # index is negative, so adding gives desired indexing from back
402
            if index < 0:
403
                index += len(self)
404
405
            return Atom.from_super(self.owner.GetAtomWithIdx(index))
406
407
        else:
408
            return res
409
410
    def __len__(self):
411
        return self.owner.GetNumAtoms()
412
413
    @property
414
    def symbol(self):
415
416
        """ np.array<str>: the symbols of the atoms in view """
417
418
        return np.array([atom.symbol for atom in self], dtype=(np.str_, 3))
419
420
    @property
421
    def atomic_number(self):
422
423
        """ np.array<int>: the atomic number of the atoms in view """
424
425
        return np.array([atom.atomic_number for atom in self])
426
427
    @property
428
    def atomic_mass(self):
429
430
        """ np.array<float>: the atomic mass of the atoms in view """
431
432
        return np.array([atom.atomic_mass for atom in self])
433
434
    @property
435
    def formal_charge(self):
436
437
        """ np.array<int>: the formal charge on the atoms in view """
438
439
        return np.array([atom.formal_charge for atom in self])
440
441
    @property
442
    def degree(self):
443
444
        """ np.array<int>: the degree of the atoms in view, according to
445
        rdkit. """
446
447
        return np.array([atom.degree for atom in self])
448
449
    @property
450
    def depleted_degree(self):
451
452
        """ np.array<int>: the degree of the atoms in the view in the
453
        h-depleted molecular graph.  """
454
455
        return np.array([atom.depleted_degree for atom in self])
456
457
    @property
458
    def full_degree(self):
459
460
        """ np.array<int>: the degree of the atoms in the view in the
461
        h-filled molecular graph. """
462
463
        return np.array([atom.full_degree for atom in self])
464
465
    @property
466
    def valence_degree(self):
467
468
        """ np.array<int>: the valence degree of the atoms in the view."""
469
470
        return np.array([atom.valence_degree for atom in self])
471
472
    @property
473
    def n_hs(self):
474
475
        """ np.array<int>: the number of hydrogens bonded to atoms in view. """
476
477
        return np.array([atom.n_hs for atom in self])
478
479
    @property
480
    def n_implicit_hs(self):
481
482
        """ np.array<int>: the number of implicit hydrogens bonded to atoms
483
        in view, according to rdkit.  """
484
485
        return np.array([atom.n_implicit_hs for atom in self])
486
487
    @property
488
    def n_explicit_hs(self):
489
490
        """ np.array<int>: the number of explicit  hydrogens bonded to atoms
491
        in view, according to rdkit.  """
492
493
        return np.array([atom.n_explicit_hs for atom in self])
494
495
    @property
496
    def n_instanced_hs(self):
497
498
        """ np.array<int>: the number of instanced hydrogens bonded to atoms
499
        in view.
500
501
        In this case, instanced means the number hs explicitly initialized as
502
        atoms. """
503
504
        return np.array([atom.n_instanced_hs for atom in self])
505
506
    @property
507
    def n_total_hs(self):
508
509
        """ np.array<int>: the number of total hydrogens bonded to atoms in
510
        view, according to rdkit.  """
511
512
        return np.array([atom.n_total_hs for atom in self])
513
514
    @property
515
    def n_val_electrons(self):
516
517
        """ np.array<int>: the number of valence electrons bonded to atoms
518
        in view.  """
519
520
        return np.array([atom.n_val_electrons for atom in self])
521
522
    @property
523
    def n_pi_electrons(self):
524
525
        """ np.array<int>: the number of pi electrons on atoms in view. """
526
527
        return np.array([atom.n_pi_electrons for atom in self])
528
529
    @property
530
    def n_lone_pairs(self):
531
532
        """ np.array<int>: the number of lone pairs on atoms in view. """
533
534
        return (0.5 * (self.n_val_electrons - self.full_degree -
535
                       self.formal_charge - self.n_pi_electrons)).astype(int)
536
537
    @property
538
    def explicit_valence(self):
539
540
        """ np.array<int>: the explicit valence of the atoms in view.. """
541
542
        return np.array([atom.explicit_valence for atom in self])
543
544
    @property
545
    def implicit_valence(self):
546
547
        """ np.array<int>: the explicit valence of the atoms in view. """
548
549
        return np.array([atom.implicit_valence for atom in self])
550
551
    @property
552
    def valence(self):
553
554
        """ np.array<int>: the valence of the atoms in view. """
555
556
        return np.array([atom.valence for atom in self])
557
558
    @property
559
    def hybridization_state(self):
560
561
        """ np.array<str>: the hybridization state of the atoms in view.
562
563
         One of 'SP', 'SP2', 'SP3', 'SP3D', 'SP3D2', 'UNSPECIFIED', 'OTHER'"""
564
565
        return np.array([atom.hybridization_state for atom in self])
566
567
    @property
568
    def chiral_tag(self):
569
570
        """ np.array<str>: the chiral tag of the atoms in view. """
571
572
        return np.array([atom.chiral_tag for atom in self])
573
574
    @property
575
    def cahn_ingold_prelog(self):
576
577
        """ np.array<str>: the CIP string representation of atoms in view. """
578
579
        return np.array([atom.cahn_ingold_prelog for atom in self],
580
                        (np.str_, 4))
581
582
    @property
583
    def is_terminal(self):
584
585
        """ np.array<bool>: whether the atoms in the view are terminal. """
586
587
        return self.depleted_degree == 1
588
589
    @property
590
    def is_aromatic(self):
591
592
        """ np.array<bool>: whether the atoms in the view are aromatic. """
593
594
        return np.array([atom.is_aromatic for atom in self])
595
596
    @property
597
    def is_in_ring(self):
598
599
        """ np.array<bool>: whether the atoms in the view are in a ring."""
600
601
        return np.array([atom.is_in_ring for atom in self])
602
603
    @property
604
    def van_der_waals_radius(self):
605
606
        """ np.array<float>: the Van der Waals radius of the atoms in the
607
        view. """
608
609
        return PERIODIC_TABLE.van_der_waals_radius[self.atomic_number].values
610
611
    @property
612
    def van_der_waals_volume(self):
613
614
        """ np.array<float>: the Van der Waals volume of the atoms in the
615
        view. """
616
617
        return PERIODIC_TABLE.van_der_waals_volume[self.atomic_number].values
618
619
    @property
620
    def covalent_radius(self):
621
622
        """ np.array<float>: the covalent radius of the atoms in the view. """
623
624
        return np.array([atom.covalent_radius for atom in self])
625
626
    @property
627
    def ionisation_energy(self):
628
629
        """ np.array<float>: the first ionisation energy of the atoms in the
630
        view. """
631
632
        return PERIODIC_TABLE.first_ionisation_energy[
633
            self.atomic_number].values
634
635
    @property
636
    def electron_affinity(self):
637
638
        """ np.array<float>: the electron affinity of the atoms in the
639
        view. """
640
641
        return PERIODIC_TABLE.electron_affinity[self.atomic_number].values
642
643
    @property
644
    def principal_quantum_number(self):
645
646
        """ np.array<float>: the principal quantum number of the atoms in the
647
        view. """
648
649
        return np.digitize(self.atomic_number,
650
                           np.array([1, 3, 11, 19, 37, 55, 87, 121]))
651
652
    @property
653
    def polarisability(self):
654
655
        """ np.array<float>: the atomic polarisability of the atoms in the
656
        view. """
657
658
        return PERIODIC_TABLE.atomic_polarisability[self.atomic_number].values
659
660
    @property
661
    def pauling_electronegativity(self):
662
663
        """ np.array<float>: the pauling electronegativity of the atoms in the
664
        view. """
665
666
        return PERIODIC_TABLE.pauling_electronegativity[
667
            self.atomic_number].values
668
669
    @property
670
    def sanderson_electronegativity(self):
671
672
        """ np.array<float>: the sanderson electronegativity of the atoms in
673
        the view. """
674
675
        return PERIODIC_TABLE.sanderson_electronegativity[
676
            self.atomic_number].values
677
678
    @property
679
    def kier_hall_electronegativity(self):
680
681
        """ np.array<float>: the hall kier electronegativity of the atoms in
682
        the view."""
683
684
        return np.array([atom.kier_hall_electronegativity for atom in self])
685
686
    @property
687
    def mcgowan_parameter(self):
688
689
        """ np.array<float>: the mcgowan parameter of the atoms in the
690
        iew. """
691
692
        return PERIODIC_TABLE.mcgowan_parameter[self.atomic_number].values
693
694
    @property
695
    def kier_hall_alpha_contrib(self):
696
697
        """ np.array<float>: the contribution to the kier hall alpha for each
698
        atom in the view. """
699
700
        return self.covalent_radius / 0.77 - 1
701
702
    @property
703
    def intrinsic_state(self):
704
705
        """ np.ndarray<float>: the intrinsic state of the atoms in the
706
        view. """
707
708
        return ((2 / self.principal_quantum_number) ** 2 *
709
                self.valence_degree + 1) / self.depleted_degree
710
711
    @property
712
    def hexcode(self):
713
714
        """ The hexcode to use as a color for the atoms in the view. """
715
716
        return PERIODIC_TABLE.hexcode[self.atomic_number].values
717
    @property
718
    def index(self):
719
720
        """ pd.Index: an index for the atoms in the view. """
721
722
        return pd.RangeIndex(len(self), name='atom_idx')
723