Completed
Push — master ( 2bc047...202252 )
by Rich
01:16
created

FusionFingerprinter.transform()   C

Complexity

Conditions 10

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 10
dl 0
loc 13
rs 6

How to fix   Complexity   

Complexity

Complex classes like FusionFingerprinter.transform() often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

1
#! /usr/bin/env python
2
#
3
# Copyright (C) 2007-2009 Rich Lewis <[email protected]>
4
# License: 3-clause BSD
5
6
"""
7
skchem.descriptors.fingerprints
8
9
Fingerprinting classes and associated functions are defined.
10
11
"""
12
13
from functools import wraps
14
15
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...
16
from rdkit.Chem import DataStructs
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...
17
from rdkit.Chem.rdMolDescriptors import (GetMorganFingerprint,
0 ignored issues
show
Configuration introduced by
The import rdkit.Chem.rdMolDescriptors 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
                                         GetHashedMorganFingerprint,
19
                                         GetAtomPairFingerprint,
20
                                         GetHashedAtomPairFingerprint,
21
                                         GetTopologicalTorsionFingerprint,
22
                                         GetHashedTopologicalTorsionFingerprint,
23
                                         GetMACCSKeysFingerprint,
24
                                         GetFeatureInvariants,
25
                                         GetConnectivityInvariants)
26
from rdkit.Chem.rdReducedGraphs import GetErGFingerprint
0 ignored issues
show
Configuration introduced by
The import rdkit.Chem.rdReducedGraphs 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...
27
from rdkit.Chem.rdmolops import RDKFingerprint
0 ignored issues
show
Configuration introduced by
The import rdkit.Chem.rdmolops 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...
28
29
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...
30
import skchem
31
32
def skchemize(func, columns=None, *args, **kwargs):
33
    """
34
35
    transform an RDKit fingerprinting function to work well with pandas
36
37
    >>> from rdkit import Chem
38
    >>> import skchem
39
    >>> from skchem.descriptors import skchemize
40
    >>> from skchem.core import Mol
41
    >>> f = skchemize(Chem.RDKFingerprint)
42
    >>> m = Mol.from_smiles('c1ccccc1')
43
    >>> f(m)
44
    0       0
45
    1       0
46
    2       0
47
    3       0
48
    4       0
49
    5       0
50
    6       0
51
    7       0
52
    8       0
53
    9       0
54
    10      0
55
    11      0
56
    12      0
57
    13      0
58
    14      0
59
    15      0
60
    16      0
61
    17      0
62
    18      0
63
    19      0
64
    20      0
65
    21      0
66
    22      0
67
    23      0
68
    24      0
69
    25      0
70
    26      0
71
    27      0
72
    28      0
73
    29      0
74
           ..
75
    2018    0
76
    2019    0
77
    2020    0
78
    2021    0
79
    2022    0
80
    2023    0
81
    2024    0
82
    2025    0
83
    2026    0
84
    2027    0
85
    2028    0
86
    2029    0
87
    2030    0
88
    2031    0
89
    2032    0
90
    2033    0
91
    2034    0
92
    2035    0
93
    2036    0
94
    2037    0
95
    2038    0
96
    2039    0
97
    2040    0
98
    2041    0
99
    2042    0
100
    2043    0
101
    2044    0
102
    2045    0
103
    2046    0
104
    2047    0
105
    dtype: int64
106
    >>> from skchem.data import resource
107
    >>> df = skchem.read_sdf(resource('test_sdf', 'multi_molecule-simple.sdf'))
108
    >>> df.structure.apply(f)
109
          0     1     2     3     4     5     6     7     8     9     ...   2038  \\
110
    name                                                              ...
111
    297      0     0     0     0     0     0     0     0     0     0  ...      0
112
    6324     0     0     0     0     0     0     0     0     0     0  ...      0
113
    6334     0     0     0     0     0     0     0     0     0     0  ...      0
114
    <BLANKLINE>
115
          2039  2040  2041  2042  2043  2044  2045  2046  2047
116
    name
117
    297      0     0     0     0     0     0     0     0     0
118
    6324     0     0     0     0     0     0     0     0     0
119
    6334     0     0     0     0     0     0     0     0     0
120
    <BLANKLINE>
121
    [3 rows x 2048 columns]
122
123
    """
124
    @wraps(func)
125
    def func_wrapper(m):
0 ignored issues
show
Coding Style Naming introduced by
The name m 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...
126
127
        """ Function that wraps an rdkit function allowing it to produce dataframes. """
128
129
        arr = np.array(0)
130
        DataStructs.ConvertToNumpyArray(func(m, *args, **kwargs), arr)
0 ignored issues
show
Coding Style introduced by
Usage of * or ** arguments should usually be done with care.

Generally, there is nothing wrong with usage of * or ** arguments. For readability of the code base, we suggest to not over-use these language constructs though.

For more information, we can recommend this blog post from Ned Batchelder including its comments which also touches this aspect.

Loading history...
131
132
        return pd.Series(arr, index=columns)
133
134
    return func_wrapper
135
136
137
class Fingerprinter(object):
138
139
    """ Fingerprinter Base class. """
140
141
    def __init__(self, name, func):
142
        self.NAME = name
0 ignored issues
show
Coding Style Naming introduced by
The name NAME does not conform to the attribute 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...
143
        self.func = func
144
145
    def __call__(self, obj):
146
        return self.transform(obj)
147
148
    def __add__(self, other):
149
        fpers = []
150
        for fper in (self, other):
151
            if isinstance(fper, FusionFingerprinter):
152
                fpers += fper.fingerprinters
0 ignored issues
show
Bug introduced by
The Instance of Fingerprinter does not seem to have a member named fingerprinters.

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...
153
            else:
154
                fpers.append(fper)
155
156
        return FusionFingerprinter(fpers)
157
158
    def fit(self, X, y):
0 ignored issues
show
Coding Style Naming introduced by
The name X 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 Naming introduced by
The name y 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 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...
Unused Code introduced by
The argument y seems to be unused.
Loading history...
Unused Code introduced by
The argument X seems to be unused.
Loading history...
159
        return self
160
161
    def transform(self, obj):
162
163
        """ calculate the fingerprint for the given object. """
164
165
        if isinstance(obj, skchem.Mol):
166
            return self._transform(obj)
167
168
        elif isinstance(obj, pd.DataFrame):
169
            return obj.structure.apply(self.transform)
170
171
        elif isinstance(obj, pd.Series):
172
            return obj.apply(self.transform)
173
174
        else:
175
            raise NotImplementedError
176
177
    def _transform(self, mol):
178
179
        """ Calculate the fingerprint on a molecule. """
180
181
        return pd.Series(list(self.func(mol)), name=mol.name)
182
183
184
class FusionFingerprinter(Fingerprinter):
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...
185
186
    def __init__(self, fingerprinters):
0 ignored issues
show
Bug introduced by
The __init__ method of the super-class Fingerprinter is not called.

It is generally advisable to initialize the super-class by calling its __init__ method:

class SomeParent:
    def __init__(self):
        self.x = 1

class SomeChild(SomeParent):
    def __init__(self):
        # Initialize the super class
        SomeParent.__init__(self)
Loading history...
187
188
        self.fingerprinters = fingerprinters
189
190
    def transform(self, obj):
191
192
        if isinstance(obj, skchem.Mol):
193
            return pd.concat([fp.transform(obj) for fp in self.fingerprinters],  keys=[fp.NAME for fp in self.fingerprinters])
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (126/100).

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

Loading history...
Coding Style introduced by
Exactly one space required after comma
return pd.concat([fp.transform(obj) for fp in self.fingerprinters], keys=[fp.NAME for fp in self.fingerprinters])
^
Loading history...
194
195
        elif isinstance(obj, pd.DataFrame):
196
            return pd.concat([fp.transform(obj) for fp in self.fingerprinters], keys=[fp.NAME for fp in self.fingerprinters], axis=1)
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (133/100).

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

Loading history...
197
198
        elif isinstance(obj, pd.Series):
199
            return pd.concat([fp.transform(obj.structure) for fp in self.fingerprinters],  keys=[fp.NAME for fp in self.fingerprinters], axis=1)
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (144/100).

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

Loading history...
Coding Style introduced by
Exactly one space required after comma
return pd.concat([fp.transform(obj.structure) for fp in self.fingerprinters], keys=[fp.NAME for fp in self.fingerprinters], axis=1)
^
Loading history...
200
201
        else:
202
            raise NotImplementedError
203
204
    def _transform(self, mol):
205
206
        return pd.concat([fp.transform(mol) for fp in self.fingerprinters])
207
208 View Code Duplication
class MorganFingerprinter(Fingerprinter):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
209
210
    """ Morgan Fingerprint Transformer. """
211
212
    NAME = 'morgan'
213
214
    def __init__(self, radius=2, n_feats=2048, as_bits=True,
0 ignored issues
show
Bug introduced by
The __init__ method of the super-class Fingerprinter is not called.

It is generally advisable to initialize the super-class by calling its __init__ method:

class SomeParent:
    def __init__(self):
        self.x = 1

class SomeChild(SomeParent):
    def __init__(self):
        # Initialize the super class
        SomeParent.__init__(self)
Loading history...
best-practice introduced by
Too many arguments (7/5)
Loading history...
215
                 use_features=False, use_bond_types=True, use_chirality=False):
216
217
        """
218
        @param radius
219
        @param n_feats
220
        @param as_bits
221
        @param use_features
222
        @param use_bond_types
223
        @param use_chirality
224
        """
225
        self.radius = radius
226
        self.n_feats = n_feats
227
        self.as_bits = as_bits
228
        self.use_features = use_features
229
        self.use_bond_types = use_bond_types
230
        self.use_chirality = use_chirality
231
232
    def _transform(self, mol):
233
234
        """
235
        @param mol
236
237
        @returns pd.Series
238
        """
239
        if self.n_feats == -1:
240
241
            res = GetMorganFingerprint(mol, self.radius,
242
                                       useFeatures=self.use_features,
243
                                       useBondTypes=self.use_bond_types,
244
                                       useChirality=self.use_chirality)
245
        else:
246
            res = list(GetHashedMorganFingerprint(mol, self.radius,
247
                                        nBits=self.n_feats,
0 ignored issues
show
Coding Style introduced by
Wrong continued indentation.
nBits=self.n_feats,
^ |
Loading history...
248
                                        useFeatures=self.use_features,
0 ignored issues
show
Coding Style introduced by
Wrong continued indentation.
useFeatures=self.use_features,
^ |
Loading history...
249
                                        useBondTypes=self.use_bond_types,
0 ignored issues
show
Coding Style introduced by
Wrong continued indentation.
useBondTypes=self.use_bond_types,
^ |
Loading history...
250
                                        useChirality=self.use_chirality))
0 ignored issues
show
Coding Style introduced by
Wrong continued indentation.
useChirality=self.use_chirality))
^ |
Loading history...
251
252
        res = pd.Series(res, name=mol.name)
253
254
        if self.as_bits:
255
            return (res > 0).astype(int)
256
        else:
257
            return res
258
259
260 View Code Duplication
class AtomPairFingerprinter(Fingerprinter):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
261
262
    """ Atom Pair Tranformer. """
263
264
    NAME = 'atom_pair'
265
266
    def __init__(self, min_length=1, max_length=30, n_feats=2048, as_bits=False, use_chirality=False):
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (102/100).

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

Loading history...
Bug introduced by
The __init__ method of the super-class Fingerprinter is not called.

It is generally advisable to initialize the super-class by calling its __init__ method:

class SomeParent:
    def __init__(self):
        self.x = 1

class SomeChild(SomeParent):
    def __init__(self):
        # Initialize the super class
        SomeParent.__init__(self)
Loading history...
best-practice introduced by
Too many arguments (6/5)
Loading history...
267
        self.min_length = min_length
268
        self.max_length = max_length
269
        self.n_feats = n_feats
270
        self.as_bits = as_bits
271
        self.use_chirality = use_chirality
272
273
    def _transform(self, mol):
274
275
        """
276
        @param molecules
277
278
        @return pd.Series
279
        """
280
281
        if self.n_feats == -1:
282
283
            res = GetAtomPairFingerprint(mol, minLength=self.min_length,
284
                                         maxLength=self.max_length,
285
                                         includeChirality=self.use_chirality)
286
        else:
287
            res = list(GetHashedAtomPairFingerprint(mol, minLength=self.min_length,
288
                                         maxLength=self.max_length,
0 ignored issues
show
Coding Style introduced by
Wrong continued indentation.
maxLength=self.max_length,
^ |
Loading history...
289
                                         nBits=self.n_feats,
0 ignored issues
show
Coding Style introduced by
Wrong continued indentation.
nBits=self.n_feats,
^ |
Loading history...
290
                                         includeChirality=self.use_chirality))
0 ignored issues
show
Coding Style introduced by
Wrong continued indentation.
includeChirality=self.use_chirality))
^ |
Loading history...
291
292
        res = pd.Series(res, name=mol.name)
293
294
        if self.as_bits:
295
            return (res > 0).astype(int)
296
        else:
297
            return res
298
299
class TopologicalTorsionFingerprinter(Fingerprinter):
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...
300
301
    NAME = 'topological_torsion'
302
303
    def __init__(self, target_size=4, n_feats=2048, as_bits=False,
0 ignored issues
show
Bug introduced by
The __init__ method of the super-class Fingerprinter is not called.

It is generally advisable to initialize the super-class by calling its __init__ method:

class SomeParent:
    def __init__(self):
        self.x = 1

class SomeChild(SomeParent):
    def __init__(self):
        # Initialize the super class
        SomeParent.__init__(self)
Loading history...
304
                 use_chirality=False):
305
                 self.target_size = target_size
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 17 were found.
Loading history...
306
                 self.n_feats = n_feats
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 17 were found.
Loading history...
307
                 self.as_bits = as_bits
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 17 were found.
Loading history...
308
                 self.use_chirality = use_chirality
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 17 were found.
Loading history...
309
310
    def _transform(self, mol):
311
312
        if self.n_feats == -1:
313
314
            res = GetTopologicalTorsionFingerprint(mol, targetSize=self.targetSize,
0 ignored issues
show
Bug introduced by
The Instance of TopologicalTorsionFingerprinter does not seem to have a member named targetSize.

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...
315
                                        includeChirality=self.use_chirality)
0 ignored issues
show
Coding Style introduced by
Wrong continued indentation.
includeChirality=self.use_chirality)
^ |
Loading history...
316
317
        else:
318
            res = list(GetHashedTopologicalTorsionFingerprint(mol,
319
                                        targetSize=self.targetSize,
0 ignored issues
show
Coding Style introduced by
Wrong continued indentation.
targetSize=self.targetSize,
^ |
Loading history...
Bug introduced by
The Instance of TopologicalTorsionFingerprinter does not seem to have a member named targetSize.

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...
320
                                        nBits=self.n_feats))
0 ignored issues
show
Coding Style introduced by
Wrong continued indentation.
nBits=self.n_feats))
^ |
Loading history...
321
322
        res = pd.Series(res, name=mol.name)
323
324
        if self.as_bits:
325
            return (res > 0).astype(int)
326
        else:
327
            return res
328
329
330
class MACCSKeysFingerprinter(Fingerprinter):
331
332
    """ MACCS Keys Fingerprints """
333
334
    NAME = 'maccs'
335
336
    def __init__(self):
0 ignored issues
show
Bug introduced by
The __init__ method of the super-class Fingerprinter is not called.

It is generally advisable to initialize the super-class by calling its __init__ method:

class SomeParent:
    def __init__(self):
        self.x = 1

class SomeChild(SomeParent):
    def __init__(self):
        # Initialize the super class
        SomeParent.__init__(self)
Loading history...
337
        pass
338
339
    def _transform(self, mol):
340
341
        return pd.Series(list(GetMACCSKeysFingerprint(mol)))
342
343
class ErGFingerprinter(Fingerprinter):
344
345
    """ ErG Fingerprints """
346
347
    NAME = 'erg'
348
349
    def __init__(self):
0 ignored issues
show
Bug introduced by
The __init__ method of the super-class Fingerprinter is not called.

It is generally advisable to initialize the super-class by calling its __init__ method:

class SomeParent:
    def __init__(self):
        self.x = 1

class SomeChild(SomeParent):
    def __init__(self):
        # Initialize the super class
        SomeParent.__init__(self)
Loading history...
350
        pass
351
352
    def _transform(self, mol):
353
354
        return pd.Series(GetErGFingerprint(mol))
355
356
class FeatureInvariantsFingerprinter(Fingerprinter):
357
358
    """ Feature invariant fingerprints. """
359
360
    NAME = 'feat_inv'
361
362
    def __init__(self):
0 ignored issues
show
Bug introduced by
The __init__ method of the super-class Fingerprinter is not called.

It is generally advisable to initialize the super-class by calling its __init__ method:

class SomeParent:
    def __init__(self):
        self.x = 1

class SomeChild(SomeParent):
    def __init__(self):
        # Initialize the super class
        SomeParent.__init__(self)
Loading history...
363
        pass
364
365
    def _transform(self, mol):
366
367
        return pd.Series(GetFeatureInvariants(mol))
368
369
class ConnectivityInvariantsFingerprinter(Fingerprinter):
370
371
    """ Connectiity invariant fingerprints """
372
    
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
373
    NAME = 'conn_inv'
374
375
    def __init__(self):
0 ignored issues
show
Bug introduced by
The __init__ method of the super-class Fingerprinter is not called.

It is generally advisable to initialize the super-class by calling its __init__ method:

class SomeParent:
    def __init__(self):
        self.x = 1

class SomeChild(SomeParent):
    def __init__(self):
        # Initialize the super class
        SomeParent.__init__(self)
Loading history...
376
        pass
377
378
    def _transform(self, mol):
379
380
        return pd.Series(GetConnectivityInvariants(mol))
381
382
class RDKFingerprinter(Fingerprinter):
0 ignored issues
show
best-practice introduced by
Too many instance attributes (9/7)
Loading history...
383
384
    """ RDKit fingerprint """
385
386
    NAME = 'rdk'
387
388
    def __init__(self, min_path=1, max_path=7, n_feats=2048, n_bits_per_hash=2,
0 ignored issues
show
Bug introduced by
The __init__ method of the super-class Fingerprinter is not called.

It is generally advisable to initialize the super-class by calling its __init__ method:

class SomeParent:
    def __init__(self):
        self.x = 1

class SomeChild(SomeParent):
    def __init__(self):
        # Initialize the super class
        SomeParent.__init__(self)
Loading history...
best-practice introduced by
Too many arguments (10/5)
Loading history...
Unused Code introduced by
The argument n_feats seems to be unused.
Loading history...
Unused Code introduced by
The argument min_path seems to be unused.
Loading history...
Unused Code introduced by
The argument n_bits_per_hash seems to be unused.
Loading history...
Unused Code introduced by
The argument max_path seems to be unused.
Loading history...
389
                 use_hs=True, target_density=0.0, min_size=128,
0 ignored issues
show
Unused Code introduced by
The argument use_hs seems to be unused.
Loading history...
Unused Code introduced by
The argument target_density seems to be unused.
Loading history...
Unused Code introduced by
The argument min_size seems to be unused.
Loading history...
390
                 branched_paths=True, use_bond_types=True):
0 ignored issues
show
Unused Code introduced by
The argument use_bond_types seems to be unused.
Loading history...
Unused Code introduced by
The argument branched_paths seems to be unused.
Loading history...
391
                 self.min_path = 1
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 17 were found.
Loading history...
392
                 self.max_path = 7
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 17 were found.
Loading history...
393
                 self.n_feats = 2048
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 17 were found.
Loading history...
394
                 self.n_bits_per_hash = 2
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 17 were found.
Loading history...
395
                 self.use_hs = True
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 17 were found.
Loading history...
396
                 self.target_density = 0.0
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 17 were found.
Loading history...
397
                 self.min_size = 128
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 17 were found.
Loading history...
398
                 self.branched_paths = True
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 17 were found.
Loading history...
399
                 self.use_bond_types = True
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 17 were found.
Loading history...
400
401
    def _transform(self, mol):
402
403
        return pd.Series(list(RDKFingerprint(mol, minPath=self.min_path,
404
                                             maxPath=self.max_path,
405
                                             fpSize=self.n_feats,
406
                                             nBitsPerHash=self.n_bits_per_hash,
407
                                             useHs=self.use_hs,
408
                                             tgtDensity=self.target_density,
409
                                             minSize=self.min_size,
410
                                             branchedPaths=self.branched_paths,
411
                                             useBondOrder=self.use_bond_types)),
412
                        name=mol.name)
0 ignored issues
show
Coding Style introduced by
Wrong continued indentation.
name=mol.name)
^|
Loading history...
413