-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
413 additions
and
133 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.