1
|
|
|
#! /usr/bin/env python |
2
|
|
|
# |
3
|
|
|
# Copyright (C) 2016 Rich Lewis <[email protected]> |
4
|
|
|
# License: 3-clause BSD |
5
|
|
|
|
6
|
1 |
|
""" |
7
|
|
|
# skchem.features.descriptors.fundamentals |
8
|
|
|
|
9
|
|
|
Fundamental representations for descriptors. |
10
|
|
|
""" |
11
|
|
|
|
12
|
|
|
|
13
|
1 |
|
from rdkit.Chem import rdmolops |
|
|
|
|
14
|
1 |
|
import numpy as np |
|
|
|
|
15
|
|
|
|
16
|
1 |
|
from .caching import cache |
|
|
|
|
17
|
1 |
|
from ...core import Mol |
18
|
|
|
|
19
|
|
|
|
20
|
1 |
|
@cache |
21
|
1 |
|
def atom_props(mol, prop_name='unweighted', c_scaled=False): |
22
|
|
|
|
23
|
|
|
""" Atom based properties.""" |
24
|
|
|
|
25
|
1 |
|
if prop_name == 'unweighted': |
26
|
|
|
return np.ones(len(mol.atoms)) |
27
|
|
|
else: |
28
|
1 |
|
props = getattr(mol.atoms, prop_name) |
29
|
1 |
|
if c_scaled: |
30
|
1 |
|
props /= getattr(Mol.from_smiles('CC').atoms[0], prop_name) |
|
|
|
|
31
|
1 |
|
return props |
32
|
|
|
|
33
|
|
|
|
34
|
|
|
|
35
|
|
|
|
36
|
1 |
|
@cache |
37
|
|
|
def distance_matrix(mol): |
38
|
|
|
|
39
|
|
|
""" The topological distance matrix. """ |
40
|
|
|
|
41
|
1 |
|
return rdmolops.GetDistanceMatrix(mol) |
42
|
|
|
|
43
|
|
|
|
44
|
1 |
|
@cache |
45
|
|
|
def adjacency_matrix(mol): |
46
|
|
|
|
47
|
|
|
""" The topological adjacency matrix. """ |
48
|
|
|
|
49
|
|
|
return rdmolops.GetAdjacencyMatrix(mol) |
50
|
|
|
|
51
|
|
|
|
52
|
1 |
|
@cache |
53
|
|
|
def bond_order_adjacency_matrix(mol): |
54
|
|
|
|
55
|
|
|
""" The bond order scaled topological adjacency matrix. """ |
56
|
|
|
return rdmolops.GetAdjacencyMatrix(mol, useBO=1) |
57
|
|
|
|
58
|
|
|
|
59
|
|
|
# probably this anymore (props, degrees) |
60
|
1 |
|
@cache |
61
|
|
|
def degrees(mol): |
|
|
|
|
62
|
|
|
|
63
|
|
|
return mol.atoms.degree |
64
|
|
|
|
65
|
|
|
|
66
|
1 |
|
@cache |
67
|
1 |
|
def geometric_matrix(mol, conformer=-1): |
|
|
|
|
68
|
|
|
return rdmolops.Get3DDistanceMatrix(mol, confId=conformer) |
69
|
|
|
|
70
|
|
|
|
71
|
1 |
|
@cache |
72
|
1 |
|
def molecular_matrix(mol, conformer=-1): |
|
|
|
|
73
|
|
|
return mol.conformers[conformer].positions |
74
|
|
|
|
75
|
|
|
|
76
|
1 |
|
__all__ = ['distance_matrix', 'adjacency_matrix', |
77
|
|
|
'bond_order_adjacency_matrix', 'degrees', 'geometric_matrix', |
78
|
|
|
'molecular_matrix'] |
|
|
|
|
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.
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.