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

Bond.draw()   A

Complexity

Conditions 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 2
dl 0
loc 7
rs 9.4285
1
#! /usr/bin/env python
2
#
3
# Copyright (C) 2007-2009 Rich Lewis <[email protected]>
4
# License: 3-clause BSD
5
6
"""
7
skchem.core.bond
8
9
Defining chemical bonds in scikit-chem.
10
"""
11
12
import rdkit.Chem
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...
13
from skchem.core import Atom
14
from skchem.core import ChemicalObject
15
16
class Bond(rdkit.Chem.rdchem.Bond, ChemicalObject):
17
18
    """
19
    Class representing a chemical bond in scikit-chem.
20
21
    """
22
23
    @property
24
    def order(self):
25
26
        """
27
        The order of the bond.
28
29
        Parameters
30
        ----------
31
32
        None
33
34
        Returns
35
        -------
36
37
        bond :int
38
39
        """
40
41
        return self.GetBondTypeAsDouble()
0 ignored issues
show
Bug introduced by
The Instance of Bond does not seem to have a member named GetBondTypeAsDouble.

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...
42
43
    @order.setter
44
    def order(self, value):
45
46
        """ Set the order of the bond.  Not implemented."""
47
48
        raise NotImplementedError
49
50
    @property
51
    def atoms(self):
52
53
        """ Return an iterable of the atoms involved in the bond. """
54
55
        return [Atom.from_super(self.GetBeginAtom()), Atom.from_super(self.GetEndAtom())]
0 ignored issues
show
Bug introduced by
The Instance of Bond does not seem to have a member named GetBeginAtom.

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...
Bug introduced by
The Instance of Bond does not seem to have a member named GetEndAtom.

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...
56
57
    @atoms.setter
58
    def atoms(self, value):
59
60
        """ Set the atoms of the molecule.  Not implemented. """
61
62
        raise NotImplementedError
63
64
    def draw(self):
65
66
        """ Draw the bond inline. """
67
68
        return '{}{}{}'.format(self.atoms[0].element, \
69
            '-' if self.order == 1 else self.GetSmarts(), \
0 ignored issues
show
Bug introduced by
The Instance of Bond does not seem to have a member named GetSmarts.

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...
70
            self.atoms[0].element)
71
72
    def to_dict(self):
73
74
        """ Convert to a dictionary representation. """
75
76
        return {"b": self.GetBeginAtomIdx(), "e": self.GetEndAtomIdx(), "o": self.order}
0 ignored issues
show
Bug introduced by
The Instance of Bond does not seem to have a member named GetBeginAtomIdx.

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...
Bug introduced by
The Instance of Bond does not seem to have a member named GetEndAtomIdx.

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...
77
78
    def __repr__(self):
79
        return '<{klass} type="{bond}" at {address}>'.format(klass=self.__class__.__name__, \
80
            bond=self.draw(), \
81
            address=hex(id(self)))
82
83
    def __str__(self):
84
        return self.draw()
85