Completed
Push — master ( 4cde57...24f8d3 )
by Rich
01:30
created

SpaceDistanceCalculator   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
c 1
b 0
f 1
dl 0
loc 24
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A _transform_mol() 0 16 4
A __init__() 0 5 1
1
#! /usr/bin/env python
2
#
3
# Copyright (C) 2015 Rich Lewis <[email protected]>
4
# License: 3-clause BSD
5
6
"""
7
## skchem.descriptors.atom
8
9
Module specifying atom based descriptor generators.
10
"""
11
12
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...
13
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 progressbar
0 ignored issues
show
Configuration introduced by
The import progressbar 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
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
from rdkit.Chem import Crippen
0 ignored issues
show
Configuration introduced by
The import rdkit.Chem 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 import Lipinski
0 ignored issues
show
Configuration introduced by
The import rdkit.Chem 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
from rdkit.Chem import rdMolDescriptors, rdPartialCharges
0 ignored issues
show
Configuration introduced by
The import rdkit.Chem 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...
20
from rdkit.Chem.rdchem import HybridizationType
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...
21
from rdkit.Chem.rdDistGeom import EmbedMolecule
0 ignored issues
show
Configuration introduced by
The import rdkit.Chem.rdDistGeom 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...
22
23
import functools
24
import warnings
25
26
from .. import core
27
from ..data import PERIODIC_TABLE
28
from ..filters import OrganicFilter
29
from .. import forcefields
30
31
def element(a):
0 ignored issues
show
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
32
33
    """ Return the element """
34
35
    return a.GetSymbol()
36
37
def is_element(a, symbol='C'):
0 ignored issues
show
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
38
39
    """ Is the atom of a given element """
40
    return element(a) == symbol
41
42
element_features = {'is_{}'.format(e): functools.partial(is_element, symbol=e) for e in OrganicFilter.organic}
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (110/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
Coding Style Naming introduced by
The name element_features does not conform to the constant naming conventions ((([A-Z_][A-Z0-9_]*)|(__.*__))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
43
44
def is_h_acceptor(a):
0 ignored issues
show
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
45
46
    """ Is an H acceptor? """
47
48
    m = a.GetOwningMol()
0 ignored issues
show
Coding Style Naming introduced by
The name m does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
49
    idx = a.GetIdx()
50
    return idx in [i[0] for i in Lipinski._HAcceptors(m)]
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like _HAcceptors was declared protected and should not be accessed from this context.

Prefixing a member variable _ is usually regarded as the equivalent of declaring it with protected visibility that exists in other languages. Consequentially, such a member should only be accessed from the same class or a child class:

class MyParent:
    def __init__(self):
        self._x = 1;
        self.y = 2;

class MyChild(MyParent):
    def some_method(self):
        return self._x    # Ok, since accessed from a child class

class AnotherClass:
    def some_method(self, instance_of_my_child):
        return instance_of_my_child._x   # Would be flagged as AnotherClass is not
                                         # a child class of MyParent
Loading history...
51
52
def is_h_donor(a):
0 ignored issues
show
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
53
54
    """ Is an H donor? """
55
56
    m = a.GetOwningMol()
0 ignored issues
show
Coding Style Naming introduced by
The name m does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
57
    idx = a.GetIdx()
58
    return idx in [i[0] for i in Lipinski._HDonors(m)]
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like _HDonors was declared protected and should not be accessed from this context.

Prefixing a member variable _ is usually regarded as the equivalent of declaring it with protected visibility that exists in other languages. Consequentially, such a member should only be accessed from the same class or a child class:

class MyParent:
    def __init__(self):
        self._x = 1;
        self.y = 2;

class MyChild(MyParent):
    def some_method(self):
        return self._x    # Ok, since accessed from a child class

class AnotherClass:
    def some_method(self, instance_of_my_child):
        return instance_of_my_child._x   # Would be flagged as AnotherClass is not
                                         # a child class of MyParent
Loading history...
59
60
def is_hetero(a):
0 ignored issues
show
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
61
62
    """ Is a heteroatom? """
63
64
    m = a.GetOwningMol()
0 ignored issues
show
Coding Style Naming introduced by
The name m does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
65
    idx = a.GetIdx()
66
    return idx in [i[0] for i in Lipinski._Heteroatoms(m)]
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like _Heteroatoms was declared protected and should not be accessed from this context.

Prefixing a member variable _ is usually regarded as the equivalent of declaring it with protected visibility that exists in other languages. Consequentially, such a member should only be accessed from the same class or a child class:

class MyParent:
    def __init__(self):
        self._x = 1;
        self.y = 2;

class MyChild(MyParent):
    def some_method(self):
        return self._x    # Ok, since accessed from a child class

class AnotherClass:
    def some_method(self, instance_of_my_child):
        return instance_of_my_child._x   # Would be flagged as AnotherClass is not
                                         # a child class of MyParent
Loading history...
67
68
def atomic_number(a):
0 ignored issues
show
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
69
70
    """ Atomic number of atom """
71
72
    return a.GetAtomicNum()
73
74
def atomic_mass(a):
0 ignored issues
show
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
75
76
    """ Atomic mass of atom """
77
78
    return a.mass
79
80
def explicit_valence(a):
0 ignored issues
show
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
81
82
    """ Explicit valence of atom """
83
    return a.GetExplicitValence()
84
85
def implicit_valence(a):
0 ignored issues
show
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
86
87
    """ Implicit valence of atom """
88
89
    return a.GetImplicitValence()
90
91
def valence(a):
0 ignored issues
show
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
92
93
    """ returns the valence of the atom """
94
95
    return explicit_valence(a) + implicit_valence(a)
96
97
def formal_charge(a):
0 ignored issues
show
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
98
99
    """ Formal charge of atom """
100
101
    return a.GetFormalCharge()
102
103
def is_aromatic(a):
0 ignored issues
show
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
104
105
    """ Boolean if atom is aromatic"""
106
107
    return a.GetIsAromatic()
108
109
def num_implicit_hydrogens(a):
0 ignored issues
show
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
110
111
    """ Number of implicit hydrogens """
112
113
    return a.GetNumImplicitHs()
114
115
def num_explicit_hydrogens(a):
0 ignored issues
show
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
116
117
    """ Number of explicit hydrodgens """
118
119
    return a.GetNumExplicitHs()
120
121
def num_hydrogens(a):
0 ignored issues
show
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
122
123
    """ Number of hydrogens """
124
125
    return num_implicit_hydrogens(a) + num_explicit_hydrogens(a)
126
127
def is_in_ring(a):
0 ignored issues
show
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
128
129
    """ Whether the atom is in a ring """
130
131
    return a.IsInRing()
132
133
def crippen_log_p_contrib(a):
0 ignored issues
show
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
134
135
    """ Hacky way of getting logP contribution. """
136
137
    idx = a.GetIdx()
138
    m = a.GetOwningMol()
0 ignored issues
show
Coding Style Naming introduced by
The name m does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
139
    return Crippen._GetAtomContribs(m)[idx][0]
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like _GetAtomContribs was declared protected and should not be accessed from this context.

Prefixing a member variable _ is usually regarded as the equivalent of declaring it with protected visibility that exists in other languages. Consequentially, such a member should only be accessed from the same class or a child class:

class MyParent:
    def __init__(self):
        self._x = 1;
        self.y = 2;

class MyChild(MyParent):
    def some_method(self):
        return self._x    # Ok, since accessed from a child class

class AnotherClass:
    def some_method(self, instance_of_my_child):
        return instance_of_my_child._x   # Would be flagged as AnotherClass is not
                                         # a child class of MyParent
Loading history...
140
141
def crippen_molar_refractivity_contrib(a):
0 ignored issues
show
Coding Style Naming introduced by
The name crippen_molar_refractivity_contrib does not conform to the function naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
142
143
    """ Hacky way of getting molar refractivity contribution. """
144
145
    idx = a.GetIdx()
146
    m = a.GetOwningMol()
0 ignored issues
show
Coding Style Naming introduced by
The name m does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
147
    return Crippen._GetAtomContribs(m)[idx][1]
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like _GetAtomContribs was declared protected and should not be accessed from this context.

Prefixing a member variable _ is usually regarded as the equivalent of declaring it with protected visibility that exists in other languages. Consequentially, such a member should only be accessed from the same class or a child class:

class MyParent:
    def __init__(self):
        self._x = 1;
        self.y = 2;

class MyChild(MyParent):
    def some_method(self):
        return self._x    # Ok, since accessed from a child class

class AnotherClass:
    def some_method(self, instance_of_my_child):
        return instance_of_my_child._x   # Would be flagged as AnotherClass is not
                                         # a child class of MyParent
Loading history...
148
149
def tpsa_contrib(a):
0 ignored issues
show
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
150
151
    """ Hacky way of getting total polar surface area contribution. """
152
153
    idx = a.GetIdx()
154
    m = a.GetOwningMol()
0 ignored issues
show
Coding Style Naming introduced by
The name m does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
155
    return rdMolDescriptors._CalcTPSAContribs(m)[idx]
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like _CalcTPSAContribs was declared protected and should not be accessed from this context.

Prefixing a member variable _ is usually regarded as the equivalent of declaring it with protected visibility that exists in other languages. Consequentially, such a member should only be accessed from the same class or a child class:

class MyParent:
    def __init__(self):
        self._x = 1;
        self.y = 2;

class MyChild(MyParent):
    def some_method(self):
        return self._x    # Ok, since accessed from a child class

class AnotherClass:
    def some_method(self, instance_of_my_child):
        return instance_of_my_child._x   # Would be flagged as AnotherClass is not
                                         # a child class of MyParent
Loading history...
156
157
def labute_asa_contrib(a):
0 ignored issues
show
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
158
159
    """ Hacky way of getting accessible surface area contribution. """
160
161
    idx = a.GetIdx()
162
    m = a.GetOwningMol()
0 ignored issues
show
Coding Style Naming introduced by
The name m does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
163
    return rdMolDescriptors._CalcLabuteASAContribs(m)[0][idx]
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like _CalcLabuteASAContribs was declared protected and should not be accessed from this context.

Prefixing a member variable _ is usually regarded as the equivalent of declaring it with protected visibility that exists in other languages. Consequentially, such a member should only be accessed from the same class or a child class:

class MyParent:
    def __init__(self):
        self._x = 1;
        self.y = 2;

class MyChild(MyParent):
    def some_method(self):
        return self._x    # Ok, since accessed from a child class

class AnotherClass:
    def some_method(self, instance_of_my_child):
        return instance_of_my_child._x   # Would be flagged as AnotherClass is not
                                         # a child class of MyParent
Loading history...
164
165
def gasteiger_charge(a, force_calc=False):
0 ignored issues
show
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
166
167
    """ Hacky way of getting gasteiger charge """
168
169
    res = a.props.get('_GasteigerCharge', None)
170
    if res and not force_calc:
171
        return float(res)
172
    else:
173
        idx = a.GetIdx()
0 ignored issues
show
Unused Code introduced by
The variable idx seems to be unused.
Loading history...
174
        m = a.GetOwningMol()
0 ignored issues
show
Coding Style Naming introduced by
The name m does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
175
        rdPartialCharges.ComputeGasteigerCharges(m)
176
        return float(a.props['_GasteigerCharge'])
177
178
def electronegativity(a):
0 ignored issues
show
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This function 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...
179
180
    return PERIODIC_TABLE.loc[a.atomic_number, 'pauling_electronegativity']
181
182
def first_ionization(a):
0 ignored issues
show
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This function 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...
183
184
    return PERIODIC_TABLE.loc[a.atomic_number, 'first_ionisation_energy']
185
186
def group(a):
0 ignored issues
show
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This function 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...
187
188
    return PERIODIC_TABLE.loc[a.atomic_number, 'group']
189
190
def period(a):
0 ignored issues
show
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This function 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...
191
192
    return PERIODIC_TABLE.loc[a.atomic_number, 'period']
193
194
def is_hybridized(a, hybrid_type=HybridizationType.SP3):
0 ignored issues
show
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
195
196
    """ Hybridized as type hybrid_type, default SP3 """
197
198
    return str(a.GetHybridization()) is hybrid_type
199
200
hybridization_features = {'is_' + n + '_hybridized': functools.partial(is_hybridized, hybrid_type=n) for n in HybridizationType.names}
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (134/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
Coding Style Naming introduced by
The name hybridization_features does not conform to the constant naming conventions ((([A-Z_][A-Z0-9_]*)|(__.*__))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
201
202
atom_features = {
0 ignored issues
show
Coding Style Naming introduced by
The name atom_features does not conform to the constant naming conventions ((([A-Z_][A-Z0-9_]*)|(__.*__))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
203
    'atomic_number': atomic_number,
204
    'atomic_mass': atomic_mass,
205
    'formal_charge': formal_charge,
206
    'gasteiger_charge': gasteiger_charge,
207
    'electronegativity': electronegativity,
208
    'first_ionisation': first_ionization,
209
    'group': group,
210
    'period': period,
211
    'valence': valence,
212
    'is_aromatic': is_aromatic,
213
    'num_hydrogens': num_hydrogens,
214
    'is_in_ring': is_in_ring,
215
    'log_p_contrib': crippen_log_p_contrib,
216
    'molar_refractivity_contrib': crippen_molar_refractivity_contrib,
217
    'is_h_acceptor': is_h_acceptor,
218
    'is_h_donor': is_h_donor,
219
    'is_heteroatom': is_hetero,
220
    'total_polar_surface_area_contrib': tpsa_contrib,
221
    'total_labute_accessible_surface_area': labute_asa_contrib,
222
}
223
atom_features.update(element_features)
224
atom_features.update(hybridization_features)
225
226
class AtomFeatureCalculator(object):
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...
227
228
    def __init__(self, features='all', max_atoms=75):
229
        if features == 'all':
230
            features = atom_features
231
        self.features = pd.Series(features)
232
        self.max_atoms = max_atoms
233
234
    @property
235
    def feature_names(self):
0 ignored issues
show
Coding Style introduced by
This method 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...
236
        return self.features.index
237
238
    def transform(self, obj):
0 ignored issues
show
Coding Style introduced by
This method 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...
239
        if isinstance(obj, core.Atom):
240
            return self._transform_atom(obj)
241
        elif isinstance(obj, core.Mol):
242
            return self._transform_mol(obj)
243
        elif isinstance(obj, pd.Series):
244
            return self._transform_series(obj)
245
        elif isinstance(obj, pd.DataFrame):
246
            return self._transform_series(obj.structure)
247
        elif isinstance(obj, (tuple, list)):
248
            return self._transform_series(obj)
249
        else:
250
            raise NotImplementedError
251
252
    def _transform_atom(self, atom):
253
        return self.features.apply(lambda f: f(atom))
254
255
    def _transform_mol(self, mol):
256
        return pd.DataFrame(self.transform(a) for a in mol.atoms)
257
258
    def _transform_series(self, data):
259
        X = np.repeat(np.nan,
0 ignored issues
show
Coding Style Naming introduced by
The name X does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
260
                      len(self.feature_names) * self.max_atoms * len(data))\
261
                      .reshape((len(data), self.max_atoms, len(self.feature_names)))
262
        for i, mol in enumerate(data):
263
            X[i, :len(mol.atoms), :] = self._transform_mol(mol)
264
        res = pd.Panel(X, items=data.index)
265
        res.minor_axis = self.features.index
266
        res.major_axis.name = 'atom_idx'
267
        return res
268
269
270
    def __call__(self, *args, **kwargs):
271
        return self.transform(*args, **kwargs)
272
273
class DistanceCalculator(object):
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...
274
    def __init__(self, max_atoms=75):
275
        self.max_atoms = max_atoms
276
277
    def _transform_series(self, ser):
278
        bar = progressbar.ProgressBar()
0 ignored issues
show
introduced by
Black listed name "bar"
Loading history...
279
        res = pd.Panel(np.array([self.transform(mol) for mol in bar(ser)]), items=ser.index)
280
        res.major_axis.name = res.minor_axis.name = 'atom_idx'
281
        return res
282
283
    def transform(self, obj):
0 ignored issues
show
Coding Style introduced by
This method 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...
284
        if isinstance(obj, core.Atom):
285
            return self._transform_atom(obj)
0 ignored issues
show
Bug introduced by
The Instance of DistanceCalculator does not seem to have a member named _transform_atom.

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...
286
        elif isinstance(obj, core.Mol):
287
            return self._transform_mol(obj)
0 ignored issues
show
Bug introduced by
The Instance of DistanceCalculator does not seem to have a member named _transform_mol.

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...
288
        elif isinstance(obj, pd.Series):
289
            return self._transform_series(obj)
290
        elif isinstance(obj, pd.DataFrame):
291
            return self._transform_series(obj.structure)
292
        elif isinstance(obj, (tuple, list)):
293
            return self._transform_series(obj)
294
        else:
295
            raise NotImplementedError
296
297
    def __call__(self, *args, **kwargs):
298
        return self.transform(*args, **kwargs)
299
300
class GraphDistanceCalculator(DistanceCalculator):
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...
301
302
    def _transform_mol(self, mol):
303
        res = np.repeat(np.nan, self.max_atoms ** 2).reshape(self.max_atoms, self.max_atoms)
304
        res[:len(mol.atoms), :len(mol.atoms)] = Chem.GetDistanceMatrix(mol)
305
        return res
306
307
class SpaceDistanceCalculator(DistanceCalculator):
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...
308
309
    def __init__(self, max_atoms=75, warn_on_fail=True, error_on_fail=False, forcefield='uff'):
310
        self.forcefield = forcefields.get(forcefield)
311
        self.warn_on_fail = warn_on_fail
312
        self.error_on_fail = error_on_fail
313
        super(SpaceDistanceCalculator, self).__init__(max_atoms=max_atoms)
314
315
    def _transform_mol(self, mol):
316
        res = np.repeat(np.nan, self.max_atoms ** 2).reshape(self.max_atoms, self.max_atoms)
317
        success = EmbedMolecule(mol)
318
        if success == -1:
319
            msg = 'Failed to Embed Molecule {}'.format(mol.name)
320
            if self.error_on_fail:
321
                raise RuntimeError(msg)
322
            elif self.warn_on_fail:
323
                warnings.warn(msg)
324
                return res
325
            else:
326
                pass
327
        m_new = Chem.AddHs(mol, addCoords=True)
0 ignored issues
show
Unused Code introduced by
The variable m_new seems to be unused.
Loading history...
328
        self.forcefield.optimize(mol)
329
        res[:len(mol.atoms), :len(mol.atoms)] = Chem.Get3DDistanceMatrix(mol)
330
        return res
0 ignored issues
show
Coding Style introduced by
Final newline missing
Loading history...