-
Notifications
You must be signed in to change notification settings - Fork 97
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
14 changed files
with
296 additions
and
56 deletions.
There are no files selected for viewing
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,20 @@ | ||
from rdkit import Chem | ||
from mordred import Chi, ABCIndex | ||
|
||
benzene = Chem.MolFromSmiles('c1ccccc1') | ||
|
||
# create descriptor instance | ||
abci = ABCIndex.ABCIndex() | ||
|
||
# calculate descriptor value | ||
result = abci(benzene) | ||
|
||
print(str(abci), result) | ||
|
||
# create descriptor instance with parameter | ||
chi_pc4 = Chi.Chi(type='path_cluster', order=4) | ||
|
||
# calculate | ||
result = chi_pc4(benzene) | ||
|
||
print(str(chi_pc4), result) |
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,53 @@ | ||
from rdkit import Chem | ||
from mordred import Chi, ABCIndex, RingCount, Calculator, is_missing, descriptors | ||
|
||
benzene = Chem.MolFromSmiles('c1ccccc1') | ||
|
||
# Create empty Calculator instance | ||
calc1 = Calculator() | ||
|
||
# Register descriptor instance | ||
calc1.register(Chi.Chi(type='path_cluster', order=4)) | ||
|
||
# Register descriptor class using preset | ||
calc1.register(RingCount.RingCount) | ||
|
||
# Register all descriptors in module | ||
calc1.register(ABCIndex) | ||
|
||
|
||
# Calculate descriptors | ||
result = calc1(benzene) | ||
|
||
print(result) | ||
# >>> [0.0, 1, 0, 0, 0, 1, (snip) | ||
|
||
|
||
# Calculator constructor can register descriptors | ||
calc2 = Calculator(Chi.Chi) | ||
|
||
# Descriptors module contains all descriptors | ||
calc3 = Calculator(descriptors) | ||
|
||
# User can access all descriptor instances by descriptors property | ||
print(calc3.descriptors) | ||
# >>> (mordred.EccentricConnectivityIndex.EccentricConnectivityIndex(), (snip) | ||
|
||
|
||
# Calculate descriptors | ||
result = calc3(benzene) | ||
|
||
# get first missing value | ||
na1 = next(r for r in result if is_missing(r)) | ||
|
||
# get reason | ||
print(na1.error) | ||
# >>> missing 3D coordinate | ||
|
||
|
||
# Delete all missing value | ||
result = result.dropna() | ||
|
||
|
||
# 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from rdkit import Chem | ||
from mordred import Calculator, descriptors | ||
|
||
mols = [ | ||
Chem.MolFromSmiles('c1ccccc1'), | ||
Chem.MolFromSmiles('c1ccccc1Cl'), | ||
Chem.MolFromSmiles('c1ccccc1C'), | ||
] | ||
|
||
# Create Calculator | ||
calc = Calculator(descriptors) | ||
|
||
# map method calculate multiple molecules (return generator) | ||
print(list(calc.map(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from rdkit import Chem | ||
from mordred import Chi, ABCIndex | ||
|
||
benzene = Chem.MolFromSmiles('c1ccccc1') | ||
|
||
# create descriptor instance | ||
abci = ABCIndex.ABCIndex() | ||
chi_p2 = Chi.Chi(type='path', order=2) | ||
|
||
# create product term using descriptor arithmetic | ||
abci_x_chi_p2 = abci * chi_p2 | ||
|
||
# calculate descriptor value | ||
result = abci_x_chi_p2(benzene) | ||
|
||
print(abci_x_chi_p2, result) |
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 |
---|---|---|
|
@@ -50,7 +50,7 @@ def do_task(mol): | |
|
||
bar.write(e) | ||
|
||
yield r | ||
yield self._wrap_result(r) | ||
bar.update() | ||
|
||
finally: | ||
|
Oops, something went wrong.