-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from NREL/nfp-0.3.3
Update for new model files
- Loading branch information
Showing
14 changed files
with
100 additions
and
463 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
include alfabet/model_files/* | ||
include versioneer.py | ||
include alfabet/_version.py |
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,3 +1,6 @@ | ||
|
||
from . import _version | ||
|
||
__version__ = _version.get_versions()['version'] | ||
|
||
_model_tag = 'v0.1' # Tag on https://github.com/pstjohn/alfabet-models/ | ||
_model_files_baseurl = f'https://github.com/pstjohn/alfabet-models/releases/download/{_model_tag}/' |
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
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,50 @@ | ||
import nfp | ||
from pooch import retrieve | ||
|
||
from alfabet import _model_files_baseurl | ||
|
||
|
||
def atom_featurizer(atom): | ||
""" Return an integer hash representing the atom type | ||
""" | ||
|
||
return str(( | ||
atom.GetSymbol(), | ||
atom.GetNumRadicalElectrons(), | ||
atom.GetFormalCharge(), | ||
atom.GetChiralTag(), | ||
atom.GetIsAromatic(), | ||
nfp.get_ring_size(atom, max_size=6), | ||
atom.GetDegree(), | ||
atom.GetTotalNumHs(includeNeighbors=True) | ||
)) | ||
|
||
|
||
def bond_featurizer(bond, flipped=False): | ||
if not flipped: | ||
atoms = "{}-{}".format( | ||
*tuple((bond.GetBeginAtom().GetSymbol(), | ||
bond.GetEndAtom().GetSymbol()))) | ||
else: | ||
atoms = "{}-{}".format( | ||
*tuple((bond.GetEndAtom().GetSymbol(), | ||
bond.GetBeginAtom().GetSymbol()))) | ||
|
||
btype = str((bond.GetBondType(), | ||
bond.GetIsConjugated())) | ||
ring = 'R{}'.format(nfp.get_ring_size(bond, max_size=6)) if bond.IsInRing() else '' | ||
|
||
return " ".join([atoms, btype, ring]).strip() | ||
|
||
|
||
preprocessor = nfp.SmilesPreprocessor( | ||
atom_features=atom_featurizer, | ||
bond_features=bond_featurizer, | ||
explicit_hs=True, | ||
bond_indices=True, | ||
output_dtype='int64' | ||
) | ||
|
||
preprocessor.from_json(retrieve( | ||
_model_files_baseurl + 'preprocessor.json', | ||
known_hash='412d15ca4d0e8b5030e9b497f566566922818ff355b8ee677a91dd23696878ac')) |
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 |
---|---|---|
|
@@ -9,5 +9,7 @@ dependencies: | |
- pytest | ||
- pandas | ||
- tqdm | ||
- joblib | ||
- scikit-learn | ||
- numpy=1.19.* | ||
- tensorflow |
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
Empty file.
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,15 @@ | ||
import rdkit.Chem | ||
|
||
from alfabet.neighbors import find_neighbor_bonds | ||
|
||
|
||
def test_find_neighbor_bonds(): | ||
neighbor_df = find_neighbor_bonds('CC', 0) | ||
assert neighbor_df.distance.min() < 1E-3 # bond should be in the database | ||
|
||
for _, row in neighbor_df.iterrows(): | ||
mol = rdkit.Chem.AddHs(rdkit.Chem.MolFromSmiles(row.molecule)) | ||
bond = mol.GetBondWithIdx(row.bond_index) | ||
assert bond.GetEndAtom().GetSymbol() == 'C' | ||
assert bond.GetBeginAtom().GetSymbol() == 'C' | ||
assert bond.GetBondType() == rdkit.Chem.rdchem.BondType.SINGLE |