Skip to content

Commit

Permalink
change subpackage structure
Browse files Browse the repository at this point in the history
  • Loading branch information
philopon committed Jan 15, 2016
1 parent f2e8893 commit 42cd718
Show file tree
Hide file tree
Showing 40 changed files with 84 additions and 53 deletions.
File renamed without changes.
File renamed without changes.
8 changes: 7 additions & 1 deletion mordred/Atom/_descriptor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
from ._atom_count import AtomCount
from ._carbon_types import CarbonTypes, HybridizationRatio
from .._aromatic import AromaticAtomsCount


_descriptors = [AtomCount, CarbonTypes, HybridizationRatio]
_descriptors = [
AtomCount,
AromaticAtomsCount,
CarbonTypes,
HybridizationRatio
]
__all__ = [d.__name__ for d in _descriptors]
File renamed without changes.
4 changes: 4 additions & 0 deletions mordred/Matrix/_burden.py → mordred/BCUT/_descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,7 @@ def calculate(self, mol, bev):
return np.sort(bev)[nth]
else:
return np.nan


_descriptors = [BCUT]
__all__ = [d.__name__ for d in _descriptors]
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from rdkit import Chem
from scipy.sparse.csgraph import shortest_path
import numpy as np
from ._matrix_attributes import methods, get_method
from .._matrix_attributes import methods, get_method


class BaryszMatrixDescriptor(Descriptor):
Expand Down Expand Up @@ -85,3 +85,7 @@ def __init__(self, prop='Z', method='SpMax'):

def calculate(self, mol, result):
return result


_descriptors = [BaryszMatrix]
__all__ = [d.__name__ for d in _descriptors]
2 changes: 2 additions & 0 deletions mordred/Bond/_descriptor.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from ._bond_types import BondCount
from .._aromatic import AromaticBondsCount
from ._hbond import HBondAcceptor, HBondDonor
from ._rotatable import RotatableBondsCount, RotatableBondsRatio

_descriptors = [
BondCount,
AromaticBondsCount,
HBondAcceptor, HBondDonor,
RotatableBondsCount, RotatableBondsRatio
]
Expand Down
File renamed without changes.
10 changes: 10 additions & 0 deletions mordred/DetourMatrix/_descriptor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from ._matrix import DetourMatrix
from ._index import DetourIndex


_descriptors = [
DetourMatrix,
DetourIndex,
]

__all__ = [d.__name__ for d in _descriptors]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .._base import Descriptor
from ..Matrix._detour import detour_matrix
from ._matrix import detour_matrix


class DetourIndex(Descriptor):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import networkx
import numpy as np
from .._base import Descriptor
from . import _matrix_attributes as ma
from .. import _matrix_attributes as ma


class LongestSimplePath(object):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .._base import Descriptor
from .._common import DistanceMatrix as D
from ._matrix_attributes import methods, get_method
from .._matrix_attributes import methods, get_method


class DistanceMatrix(Descriptor):
Expand Down Expand Up @@ -48,3 +48,7 @@ def __init__(self, method='SpMax'):

def calculate(self, mol, result):
return result


_descriptors = [DistanceMatrix]
__all__ = [d.__name__ for d in _descriptors]
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ def dependencies(self):

def calculate(self, mol, E, V):
return (E.astype('int') * V).sum()


_descriptors = [EccentricConnectivityIndex]
__all__ = [d.__name__ for d in _descriptors]
2 changes: 1 addition & 1 deletion mordred/Framework/_descriptor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .._base import Descriptor
from ..Ring._descriptor import Rings
from ..RingCount._descriptor import Rings
import networkx as nx


Expand Down
18 changes: 0 additions & 18 deletions mordred/Indices/_descriptor.py

This file was deleted.

File renamed without changes.
File renamed without changes.
9 changes: 4 additions & 5 deletions mordred/Lipinski/_descriptor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from .._base import Descriptor
from ..Model import WildmanCrippen
from ..Property import Weight
from ..Property import Weight, WildmanCrippenLogP

from rdkit.Chem import Lipinski as L

Expand Down Expand Up @@ -47,16 +46,16 @@ def __init__(self, variant='Lipinski'):
@property
def dependencies(self):
return dict(
CLogP=WildmanCrippen.make_key('LogP'),
LogP=WildmanCrippenLogP.make_key('LogP'),
Weight=Weight.make_key(),
)

def Lipinski(self, mol, CLogP, Weight, **other):
def Lipinski(self, mol, LogP, Weight, **other):
return\
L.NumHDonors(mol) <= 5 and\
L.NumHAcceptors(mol) <= 10 and\
Weight <= 500 and\
CLogP <= 5
LogP <= 5

def calculate(self, mol, **deps):
return getattr(self, self.variant)(mol, **deps)
Expand Down
14 changes: 0 additions & 14 deletions mordred/Matrix/_descriptor.py

This file was deleted.

File renamed without changes.
File renamed without changes.
9 changes: 8 additions & 1 deletion mordred/Property/_descriptor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
from ._weight import Weight
from ._mc_gowan_volume import McGowanVolume
from ._vdw_volume_abc import VdwVolumeABC
from ._wildman_crippen_logp import WildmanCrippenLogP

_descriptors = [
Weight,
McGowanVolume,
VdwVolumeABC,
WildmanCrippenLogP,
]

_descriptors = [Weight, McGowanVolume, VdwVolumeABC]
__all__ = [d.__name__ for d in _descriptors]
2 changes: 1 addition & 1 deletion mordred/Property/_vdw_volume_abc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .._base import Descriptor
from ..Bond import BondCount
from ..Ring import RingCount
from ..RingCount import RingCount

from rdkit import Chem
from math import pi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from rdkit.Chem import Crippen as _Crippen


class WildmanCrippen(Descriptor):
class WildmanCrippenLogP(Descriptor):
r'''
Wildman-Crippen LogP/MR descriptor
Expand Down Expand Up @@ -38,5 +38,5 @@ def calculate(self, mol):
else:
return _Crippen.MolMR(mol)

_descriptors = [WildmanCrippen]
_descriptors = [WildmanCrippenLogP]
__all__ = [d.__name__ for d in _descriptors]
1 change: 1 addition & 0 deletions mordred/RingCount/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from ._descriptor import *
File renamed without changes.
1 change: 1 addition & 0 deletions mordred/TopologicalIndex/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from ._descriptor import *
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,13 @@ def dependencies(self):

def calculate(self, mol, R, D):
return float(D - R) / float(D)


_descriptors = [
Radius,
Diameter,
TopologicalShapeIndex,
PetitjeanIndex,
]

__all__ = [d.__name__ for d in _descriptors]
1 change: 1 addition & 0 deletions mordred/WalkCount/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from ._descriptor import *
File renamed without changes.
1 change: 1 addition & 0 deletions mordred/WienerIndex/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from ._descriptor import *
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@ def calculate(self, mol, D):
return int(0.5 * (D == 3).sum())
else:
return int(0.5 * D.sum())


_descriptors = [WienerIndex]
__all__ = [d.__name__ for d in _descriptors]
1 change: 1 addition & 0 deletions mordred/ZagrebIndex/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from ._descriptor import *
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,7 @@ def calculate(self, mol, V):
(V[b.GetBeginAtomIdx()] * V[b.GetEndAtomIdx()]) ** self.variable
for b in mol.GetBonds()
)


_descriptors = [ZagrebIndex]
__all__ = [d.__name__ for d in _descriptors]
2 changes: 1 addition & 1 deletion mordred/Aromatic/_descriptor.py → mordred/_aromatic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .._base import Descriptor
from ._base import Descriptor


class AromaticAtomsCount(Descriptor):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .._base import Descriptor
from ._base import Descriptor
import numpy as np
from collections import namedtuple
from six import string_types
Expand Down
8 changes: 4 additions & 4 deletions tests/test_WildmanCrippen.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from mordred.Model import WildmanCrippen
from mordred.Property import WildmanCrippenLogP as LogP
from rdkit import Chem
from numpy.testing import assert_almost_equal

def test_WildmanCrippen1():
mol = Chem.MolFromSmiles('Oc1ccccc1OC')
yield assert_almost_equal, WildmanCrippen('LogP')(mol), 1.4, 2
yield assert_almost_equal, WildmanCrippen('MR')(mol), 34.66, 2
yield assert_almost_equal, LogP('LogP')(mol), 1.4, 2
yield assert_almost_equal, LogP('MR')(mol), 34.66, 2


def test_WildmanCrippen2():
mol = Chem.MolFromSmiles('c1ccccc1c2ccccn2')
yield assert_almost_equal, WildmanCrippen('LogP')(mol), 2.75, 2
yield assert_almost_equal, LogP('LogP')(mol), 2.75, 2

0 comments on commit 42cd718

Please sign in to comment.