Skip to content

Commit

Permalink
Merge branch 'release/v0.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
philopon committed Sep 2, 2017
2 parents bf6c8a9 + e83cd17 commit 590fd85
Show file tree
Hide file tree
Showing 64 changed files with 676 additions and 69 deletions.
6 changes: 6 additions & 0 deletions README.rst
Expand Up @@ -184,7 +184,13 @@ Documentation
-------------

- `master <http://mordred-descriptor.github.io/documentation/master>`__
- `develop <http://mordred-descriptor.github.io/documentation/develop>`__

- `v0.5.0 <http://mordred-descriptor.github.io/documentation/v0.5.0>`__
- `v0.4.1 <http://mordred-descriptor.github.io/documentation/v0.4.1>`__
- `v0.4.0 <http://mordred-descriptor.github.io/documentation/v0.4.0>`__
- `v0.3.2 <http://mordred-descriptor.github.io/documentation/v0.3.2>`__
- `v0.3.1 <http://mordred-descriptor.github.io/documentation/v0.3.1>`__
- `v0.3.0 <http://mordred-descriptor.github.io/documentation/v0.3.0>`__
- `v0.2.1 <http://mordred-descriptor.github.io/documentation/v0.2.1>`__
- `v0.2.0 <http://mordred-descriptor.github.io/documentation/v0.2.0>`__
Expand Down
74 changes: 51 additions & 23 deletions docs/scripts/gen_default_descs.py
Expand Up @@ -3,7 +3,7 @@

load_path.nop()

prelude = '''
prelude = """
Descriptor List
===============
preset descriptors
Expand All @@ -13,42 +13,70 @@
calc = Calculator(descriptors)
.. csv-table:: Descriptor list
:header: "#", "module", "name", "constructor", "dim"
:widths: 10, 20, 20, 40, 10
:header: "#", "module", "name", "constructor", "dim", "description"
:widths: 1, 2, 2, 4, 1, 10
'''[1:]
"""[1:]


def main(out):
out.write(prelude)
class DescriptorInfo(object):
def __init__(self, d):
self.raw = d

i = 0
@property
def module(self):
return self.raw.__module__

for mdl in descriptors.all:
mdl_name = '.'.join(mdl.__name__.split('.'))
mdl_ppr = ':py:mod:`~{}`'.format(mdl_name)
first = True
@property
def constructor(self):
return self.raw.__class__.__name__

for Desc in get_descriptors_from_module(mdl):
@property
def parameters(self):
return [Descriptor._pretty(p) for p in self.raw.parameters()]

for desc in Desc.preset():
i += 1
@property
def dimention(self):
return "3D" if self.raw.require_3D else "2D"

@property
def description(self):
return self.raw.description()

def to_rst(self, hide_module=False):
mdl = "" if hide_module else ":py:mod:`~{}`".format(self.module)
desc = self.raw
cnst = ":py:class:`~{}.{}` ({})".format(
self.module, self.constructor, ", ".join(self.parameters))
info = self.description
dim = self.dimention

if not first:
mdl_ppr = ''
return '{}, {}, "{}", {}, "{}"'.format(mdl, desc, cnst, dim, info)

cnst = desc.__class__.__name__
args = ', '.join(Descriptor._pretty(p) for p in desc.parameters())

cnst = ':py:class:`~{}.{}` ({})'.format(mdl_name, cnst, args)
def get_all_descriptors():
for mdl in descriptors.all:
ds = []
for Desc in get_descriptors_from_module(mdl):
for desc in Desc.preset():
ds.append(desc)

dim = '3D' if desc.require_3D else '2D'
yield ds

out.write(' {}, {}, {}, "{}", {}\n'.format(i, mdl_ppr, desc, cnst, dim))

first = False
def main(out):
out.write(prelude)

i = 0

for descs in get_all_descriptors():
first = True
for desc in descs:
i += 1
out.write(" {}, {}\n".format(i, DescriptorInfo(desc).to_rst(not first)))
first = False


if __name__ == '__main__':
if __name__ == "__main__":
import sys
main(sys.stdout)
41 changes: 41 additions & 0 deletions docs/scripts/gen_descriptor_list_xlsx.py
@@ -0,0 +1,41 @@
from openpyxl import Workbook
from openpyxl.styles import Font

from gen_default_descs import DescriptorInfo, get_all_descriptors


def main(out):
wb = Workbook()
ws = wb.active
ws.title = "descriptors"

ws.append(["index", "module", "name", "constructor", "dimention", "description"])
for cell in ws["1:1"]:
cell.font = Font(bold=True)

i = 0
for descs in get_all_descriptors():
first = True
for desc in descs:
i += 1
info = DescriptorInfo(desc)
ws.append([
i,
info.module.split(".")[-1] if first else None,
str(info.raw),
"{}({})".format(info.constructor, ", ".join(info.parameters)),
info.dimention,
info.description,
])
first = False

for cells in ws.columns:
l = max(len(str(cell.value or "")) for cell in cells)
ws.column_dimensions[cells[0].column].width = l + 1

wb.save(out)


if __name__ == "__main__":
import sys
main(sys.argv[1])
2 changes: 1 addition & 1 deletion docs/subpackages/mordred.descriptors.rst
@@ -1,5 +1,5 @@
mordred.descriptors
=============
===================

.. automodule:: mordred.descriptors
:members:
Expand Down
6 changes: 6 additions & 0 deletions mordred/ABCIndex.py
Expand Up @@ -41,6 +41,9 @@ class ABCIndex(ABCIndexBase):

__slots__ = ()

def description(self):
return "atom-bond connectivity index"

@staticmethod
def _each_bond(bond):
du = bond.GetBeginAtom().GetDegree()
Expand All @@ -67,6 +70,9 @@ class ABCGGIndex(ABCIndexBase):

__slots__ = ()

def description(self):
return "Graovac-Ghorbani atom-bond connectivity index"

def dependencies(self):
return {"D": DistanceMatrix(self.explicit_hydrogens)}

Expand Down
6 changes: 6 additions & 0 deletions mordred/AcidBase.py
Expand Up @@ -51,6 +51,9 @@ class AcidicGroupCount(SmartsCountBase):

__slots__ = ()

def description(self):
return "acidic group count"

_name = "nAcid"

SMARTS = (
Expand All @@ -66,6 +69,9 @@ class BasicGroupCount(SmartsCountBase):

__slots__ = ()

def description(self):
return "basic group count"

_name = "nBase"

SMARTS = (
Expand Down
3 changes: 3 additions & 0 deletions mordred/AdjacencyMatrix.py
Expand Up @@ -15,6 +15,9 @@ class AdjacencyMatrix(Descriptor):
__slots__ = ("_type",)
explicit_hydrogens = False

def description(self):
return "{} of adjacency matrix".format(self._type.__name__)

@classmethod
def preset(cls):
return map(cls, methods)
Expand Down
6 changes: 6 additions & 0 deletions mordred/Aromatic.py
Expand Up @@ -27,6 +27,9 @@ class AromaticAtomsCount(AromaticBase):
__slots__ = ()
_name = "nAromAtom"

def description(self):
return "aromatic atoms count"

def calculate(self):
return sum(
1
Expand All @@ -41,6 +44,9 @@ class AromaticBondsCount(AromaticBase):
__slots__ = ()
_name = "nAromBond"

def description(self):
return "aromatic bonds count"

def calculate(self):
return sum(
1
Expand Down
12 changes: 12 additions & 0 deletions mordred/AtomCount.py
Expand Up @@ -8,6 +8,15 @@
)


_desc_conv = {
"Atom": "all",
"Bridgehead": "bridgehead",
"HeavyAtom": "heavy",
"Spiro": "spiro",
"X": "halogen",
}


class AtomCount(Descriptor):
r"""atom count descriptor.
Expand All @@ -24,6 +33,9 @@ class AtomCount(Descriptor):

__slots__ = ("_type",)

def description(self):
return "number of {} atoms".format(_desc_conv.get(self._type, self._type))

@classmethod
def preset(cls):
return map(cls, [
Expand Down
16 changes: 16 additions & 0 deletions mordred/Autocorrelation.py
Expand Up @@ -18,6 +18,10 @@ def __str__(self):
self._avec.as_argument,
)

def description(self):
return "{} of lag {} weighted by {}".format(
self._description_name, self._order, self._avec.get_long())

def parameters(self):
return self._order, self._prop

Expand Down Expand Up @@ -155,6 +159,8 @@ class ATS(AutocorrelationBase):

__slots__ = ()

_description_name = "moreau-broto autocorrelation"

@classmethod
def preset(cls):
return (
Expand Down Expand Up @@ -193,6 +199,8 @@ class AATS(ATS):

__slots__ = ()

_description_name = "averaged moreau-broto autocorrelation"

def dependencies(self):
return {"ATS": self._ATS, "gsum": self._gsum}

Expand All @@ -216,6 +224,8 @@ class ATSC(AutocorrelationBase):

__slots__ = ()

_description_name = "centered moreau-broto autocorrelation"

@classmethod
def preset(cls):
return (
Expand Down Expand Up @@ -254,6 +264,8 @@ class AATSC(ATSC):

__slots__ = ()

_description_name = "averaged and centered moreau-broto autocorrelation"

def dependencies(self):
return {"ATSC": self._ATSC, "gsum": self._gsum}

Expand Down Expand Up @@ -283,6 +295,8 @@ class MATS(AutocorrelationBase):

__slots__ = ()

_description_name = "moran coefficient"

@classmethod
def preset(cls):
return (
Expand Down Expand Up @@ -317,6 +331,8 @@ class GATS(MATS):

__slots__ = ()

_description_name = "geary coefficient"

def dependencies(self):
return {
"avec": self._avec,
Expand Down
8 changes: 8 additions & 0 deletions mordred/BCUT.py
@@ -1,6 +1,7 @@
import numpy as np

from ._base import Descriptor
from ._util import to_ordinal
from ._atomic_property import AtomicProperty, get_properties

__all__ = ("BCUT",)
Expand Down Expand Up @@ -87,6 +88,13 @@ class BCUT(BCUTBase):

__slots__ = ("_prop", "_nth",)

def description(self):
return "{} {} eigenvalue of Burden matrix weighted by {}".format(
to_ordinal(np.abs(self._nth) if self._nth < 0 else 1 + self._nth),
"lowest" if self._nth < 0 else "heighest",
self._prop.get_long(),
)

@classmethod
def preset(cls):
return (
Expand Down
3 changes: 3 additions & 0 deletions mordred/BalabanJ.py
Expand Up @@ -11,6 +11,9 @@ class BalabanJ(Descriptor):

__slots__ = ()

def description(self):
return "Balaban's J index"

explicit_hydrogens = False

@classmethod
Expand Down
4 changes: 4 additions & 0 deletions mordred/BaryszMatrix.py
Expand Up @@ -64,6 +64,10 @@ class BaryszMatrix(BaryszMatrixBase):

__slots__ = ("_prop", "_type",)

def description(self):
return "{} from Barysz matrix weighted by {}".format(
self._type.description(), self._prop.get_long())

@classmethod
def preset(cls):
return (cls(p, m) for p in get_properties() for m in methods)
Expand Down
3 changes: 3 additions & 0 deletions mordred/BertzCT.py
Expand Up @@ -12,6 +12,9 @@ class BertzCT(Descriptor):
__slots__ = ()
explicit_hydrogens = False

def description(self):
return "Bertz CT"

@classmethod
def preset(cls):
yield cls()
Expand Down

0 comments on commit 590fd85

Please sign in to comment.