Skip to content

Commit

Permalink
Merge branch 'release/v0.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
philopon committed Sep 8, 2017
2 parents 873a230 + eab68c3 commit 9c98609
Show file tree
Hide file tree
Showing 21 changed files with 413 additions and 133 deletions.
8 changes: 0 additions & 8 deletions .zenodo.json

This file was deleted.

25 changes: 13 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,23 @@ molecular descriptor calculator.

.. image:: https://ci.appveyor.com/api/projects/status/iwk6268d27jusvni/branch/master?svg=true
:target: https://ci.appveyor.com/project/philopon/mordred/branch/master

.. image:: https://coveralls.io/repos/github/mordred-descriptor/mordred/badge.svg?branch=master
:target: https://coveralls.io/github/mordred-descriptor/mordred?branch=master
:target: https://coveralls.io/github/mordred-descriptor/mordred?branch=master

.. image:: https://codeclimate.com/github/mordred-descriptor/mordred/badges/gpa.svg
:target: https://codeclimate.com/github/mordred-descriptor/mordred
:alt: Code Climate

.. image:: https://anaconda.org/mordred-descriptor/mordred/badges/version.svg
:target: https://anaconda.org/mordred-descriptor/mordred

.. image:: https://img.shields.io/pypi/v/mordred.svg
:target: https://pypi.python.org/pypi/mordred

.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.61242.svg
:target: https://doi.org/10.5281/zenodo.61242

.. image:: https://zenodo.org/badge/48859647.svg
:target: https://zenodo.org/badge/latestdoi/48859647


Installation
------------
Expand Down Expand Up @@ -65,7 +66,7 @@ calculate all descriptors
benzene,36,27,3,24.0, (snip)
chrolobenzene,45,42,5,30.0, (snip)
save to file (display progress bar)

.. code:: console
Expand All @@ -89,7 +90,7 @@ only ABCIndex
name,ABC,ABCGG
benzene,4.242640687119286,3.9999999999999996
chlorobenzene,5.059137268047012,4.785854275382693
ABCIndex and AcidBase

.. code:: console
Expand All @@ -98,7 +99,7 @@ ABCIndex and AcidBase
name,ABC,ABCGG,nAcid,nBase
benzene,4.242640687119286,3.9999999999999996,0,0
chlorobenzene,5.059137268047012,4.785854275382693,0,0
multiple input

.. code:: console
Expand All @@ -108,7 +109,7 @@ multiple input
benzene,4.242640687119286,3.9999999999999996
chlorobenzene,5.059137268047012,4.785854275382693
pentane,2.8284271247461903,3.1462643699419726
show help

.. code:: console
Expand Down Expand Up @@ -177,7 +178,7 @@ as library
1 1.3922
2 1.2688
Name: SLogP, dtype: float64
see `examples <examples>`_

Documentation
Expand All @@ -186,6 +187,7 @@ Documentation
- `master <http://mordred-descriptor.github.io/documentation/master>`__
- `develop <http://mordred-descriptor.github.io/documentation/develop>`__

- `v0.6.0 <http://mordred-descriptor.github.io/documentation/v0.6.0>`__
- `v0.5.1 <http://mordred-descriptor.github.io/documentation/v0.5.1>`__
- `v0.5.0 <http://mordred-descriptor.github.io/documentation/v0.5.0>`__
- `v0.4.1 <http://mordred-descriptor.github.io/documentation/v0.4.1>`__
Expand All @@ -196,4 +198,3 @@ Documentation
- `v0.2.1 <http://mordred-descriptor.github.io/documentation/v0.2.1>`__
- `v0.2.0 <http://mordred-descriptor.github.io/documentation/v0.2.0>`__
- `v0.1.0 <http://mordred-descriptor.github.io/documentation/v0.1.0>`__

71 changes: 36 additions & 35 deletions examples/020-single_mol-multiple_desc.py
Original file line number Diff line number Diff line change
@@ -1,53 +1,54 @@
from rdkit import Chem
from mordred import Chi, ABCIndex, RingCount, Calculator, is_missing, descriptors

benzene = Chem.MolFromSmiles('c1ccccc1')
from multiprocessing import freeze_support

# Create empty Calculator instance
calc1 = Calculator()

# Register descriptor instance
calc1.register(Chi.Chi(type='path_cluster', order=4))
from rdkit import Chem

# Register descriptor class using preset
calc1.register(RingCount.RingCount)
from mordred import Chi, ABCIndex, RingCount, Calculator, is_missing, descriptors

# Register all descriptors in module
calc1.register(ABCIndex)
if __name__ == "__main__":
freeze_support()

benzene = Chem.MolFromSmiles("c1ccccc1")

# Calculate descriptors
result = calc1(benzene)
# Create empty Calculator instance
calc1 = Calculator()

print(result)
# >>> [0.0, 1, 0, 0, 0, 1, (snip)
# Register descriptor instance
calc1.register(Chi.Chi(type="path_cluster", order=4))

# Register descriptor class using preset
calc1.register(RingCount.RingCount)

# Calculator constructor can register descriptors
calc2 = Calculator(Chi.Chi)
# Register all descriptors in module
calc1.register(ABCIndex)

# Descriptors module contains all descriptors
calc3 = Calculator(descriptors)
# Calculate descriptors
result = calc1(benzene)

# User can access all descriptor instances by descriptors property
print(calc3.descriptors)
# >>> (mordred.EccentricConnectivityIndex.EccentricConnectivityIndex(), (snip)
print(result)
# >>> [0.0, 1, 0, 0, 0, 1, (snip)

# Calculator constructor can register descriptors
calc2 = Calculator(Chi.Chi)

# Calculate descriptors
result = calc3(benzene)
# Descriptors module contains all descriptors
calc3 = Calculator(descriptors)

# get first missing value
na1 = next(r for r in result if is_missing(r))
# User can access all descriptor instances by descriptors property
print(calc3.descriptors)
# >>> (mordred.EccentricConnectivityIndex.EccentricConnectivityIndex(), (snip)

# get reason
print(na1.error)
# >>> missing 3D coordinate
# Calculate descriptors
result = calc3(benzene)

# get first missing value
na1 = next(r for r in result if is_missing(r))

# Delete all missing value
result = result.dropna()
# get reason
print(na1.error)
# >>> missing 3D coordinate

# Delete all missing value
result = result.drop_missing()

# convert to dict
print(result.asdict())
# convert to dict
print(result.asdict())
28 changes: 17 additions & 11 deletions examples/030-multiple_mol-multiple_desc.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
from multiprocessing import freeze_support

from rdkit import Chem

from mordred import Calculator, descriptors

mols = [
Chem.MolFromSmiles('c1ccccc1'),
Chem.MolFromSmiles('c1ccccc1Cl'),
Chem.MolFromSmiles('c1ccccc1C'),
]
if __name__ == "__main__":
freeze_support()

mols = [
Chem.MolFromSmiles("c1ccccc1"),
Chem.MolFromSmiles("c1ccccc1Cl"),
Chem.MolFromSmiles("c1ccccc1C"),
]

# Create Calculator
calc = Calculator(descriptors)
# Create Calculator
calc = Calculator(descriptors)

# map method calculate multiple molecules (return generator)
print(list(calc.map(mols)))
# map method calculate multiple molecules (return generator)
print(list(calc.map(mols)))

# pandas method calculate multiple molecules (return pandas DataFrame)
print(calc.pandas(mols))
# pandas method calculate multiple molecules (return pandas DataFrame)
print(calc.pandas(mols))
2 changes: 0 additions & 2 deletions mordred/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
r"""modred descriptor calculator."""

from ._base import (
all_descriptors,
Calculator,
Descriptor,
get_descriptors_from_module,
Expand All @@ -15,7 +14,6 @@
"__version__",
"Descriptor",
"Calculator",
"all_descriptors",
"get_descriptors_from_module",
"is_missing",
"Result",
Expand Down
3 changes: 1 addition & 2 deletions mordred/_base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
)
from .calculator import Calculator, get_descriptors_from_module
from .parallel import parallel
from .util import is_missing, all_descriptors
from .util import is_missing
from .result import Result


__all__ = (
"all_descriptors",
"Descriptor",
"Calculator",
"get_descriptors_from_module",
Expand Down
6 changes: 3 additions & 3 deletions mordred/_base/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,14 @@ def pandas(self, mols, nproc=None, nmols=None, quiet=False, ipynb=False, id=-1):
pandas.DataFrame
"""
import pandas
from .pandas_module import MordredDataFrame, Series

if isinstance(mols, pandas.Series):
if isinstance(mols, Series):
index = mols.index
else:
index = None

return pandas.DataFrame(
return MordredDataFrame(
(list(r) for r in self.map(mols, nproc, nmols, quiet, ipynb, id)),
columns=[str(d) for d in self.descriptors],
index=index,
Expand Down
18 changes: 18 additions & 0 deletions mordred/_base/pandas_module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import numpy as np
from pandas import Series, DataFrame

from .util import is_missing

__all__ = ("MordredDataFrame", "Series")


class MordredDataFrame(DataFrame):
@property
def _constructor(self):
return self.__class__

def fill_missing(self, value=np.nan, inplace=False):
t = self if inplace else self.copy()

t[t.applymap(is_missing)] = value
return t
Loading

0 comments on commit 9c98609

Please sign in to comment.