Completed
Push — master ( 3371cb...5cb87e )
by Rich
01:23
created

molecular_weight()   A

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
cc 1
c 2
b 0
f 2
dl 0
loc 2
rs 10
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.physicochemical
8
9
Physicochemical descriptors and associated functions are defined.
10
11
"""
12
13
from rdkit.Chem import Descriptors
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...
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
16
from .fingerprints import Fingerprinter
17
from ..utils import camel_to_snail
18
19
DESCRIPTORS = [(camel_to_snail(s), f) for (s, f) in Descriptors.descList]
20
21
class PhysicochemicalFingerprinter(Fingerprinter):
22
23
    """ Physicochemical descriptor generator using RDKit descriptor """
24
25
    NAME = 'physchem'
26
27
    def __init__(self, descriptors='all'):
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...
28
29
        """ Create a physicochemical descriptor generator.
30
31
        Args:
32
            descriptors (list<(str, func)> or 'all'):
33
                Descriptors to calculate, or if 'all', use all descriptors."""
34
35
        if descriptors == 'all':
36
            self.descriptors = DESCRIPTORS
37
        else:
38
            self.descriptors = descriptors
39
        self.descriptor_names, _ = zip(*self.descriptors)
40
41
    def _transform(self, mol):
42
43
        return pd.Series({n: f(mol) for (n, f) in self.descriptors}, name=mol.name)
44