Skip to content

Commit

Permalink
Update dependence conda package versions
Browse files Browse the repository at this point in the history
  • Loading branch information
mjwen committed Aug 28, 2020
1 parent 877eeab commit 57f0494
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 36 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -e .
conda install pytorch torchvision cpuonly -c pytorch
conda install dgl -c dglteam
conda install pymatgen==2020.6.8 -c conda-forge
conda install rdkit==2020.03.3 -c conda-forge
conda install pytorch==1.6.0 torchvision cpuonly -c pytorch
conda install dgl==0.5.0 -c dglteam
conda install pymatgen==2020.8.13 -c conda-forge
conda install rdkit==2020.03.5 -c conda-forge
conda install openbabel==3.1.1 -c conda-forge
- name: Lint with flake8
run: |
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Use the pretrained model:
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/mjwen/bondnet/pretrained?filepath=bondnet%2Fscripts%2Fpredict_binder.ipynb)

Train the model:
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/mjwen/bondnet/master?filepath=bondnet%2Fscripts%2Ftrain_bde.ipynb)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/mjwen/bondnet/pretrained?filepath=bondnet%2Fscripts%2Ftrain_bde.ipynb)


# Table of Contents
Expand Down Expand Up @@ -76,7 +76,7 @@ can be found [here](./bondnet/scripts/examples/predict).

The [train_bde.ipynb](./bondnet/scripts/train_bde.ipynb) Jupyter notebook shows
how to train BonDNet on a BDE dataset of both neutral and charged molecules.
Try it at: [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/mjwen/bondnet/master?filepath=bondnet%2Fscripts%2Ftrain_bde.ipynb)
Try it at: [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/mjwen/bondnet/pretrained?filepath=bondnet%2Fscripts%2Ftrain_bde.ipynb)

The [train_bde.ipynb](./bondnet/scripts/train_bde.ipynb) Jupyter notebook trains a model on CPU.
If you want to train on GPUs (a single GPU or distributed), take a look at
Expand Down
8 changes: 4 additions & 4 deletions binder/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ channels:
- defaults
dependencies:
- pip
- pymatgen==2020.6.8
- rdkit==2020.03.3
- pymatgen==2020.8.13
- rdkit==2020.03.5
- openbabel==3.1.1
- pytorch==1.5.0
- pytorch==1.6.0
- torchvision
- dgl==0.4.3
- dgl==0.5.0
30 changes: 11 additions & 19 deletions bondnet/data/grapher.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,23 @@ def __init__(self, atom_featurizer=None, bond_featurizer=None, self_loop=True):
)

def build_graph(self, mol):
g = dgl.DGLGraph()

# Add nodes
num_atoms = mol.GetNumAtoms()
g.add_nodes(num_atoms)
num_bonds = mol.GetNumBonds()

# Add edges
src_list = []
dst_list = []
num_bonds = mol.GetNumBonds()
for i in range(num_bonds):
bond = mol.GetBondWithIdx(i)
u = bond.GetBeginAtomIdx()
v = bond.GetEndAtomIdx()
src_list.extend([u, v])
dst_list.extend([v, u])
g.add_edges(src_list, dst_list)

if self.self_loop:
nodes = g.nodes()
g.add_edges(nodes, nodes)
src_list.extend(range(num_atoms))
dst_list.extend(range(num_atoms))

g = dgl.graph((src_list, dst_list), num_nodes=num_atoms)

# add name
g.mol_name = mol.GetProp("_Name")
Expand Down Expand Up @@ -136,20 +132,16 @@ def __init__(self, atom_featurizer=None, bond_featurizer=None, self_loop=True):

def build_graph(self, mol):

g = dgl.DGLGraph()
num_atoms = mol.GetNumAtoms()
g.add_nodes(num_atoms)

if self.self_loop:
g.add_edges(
[i for i in range(num_atoms) for j in range(num_atoms)],
[j for i in range(num_atoms) for j in range(num_atoms)],
)
src_list = [i for i in range(num_atoms) for j in range(num_atoms)]
dst_list = [j for i in range(num_atoms) for j in range(num_atoms)]
else:
g.add_edges(
[i for i in range(num_atoms) for j in range(num_atoms - 1)],
[j for i in range(num_atoms) for j in range(num_atoms) if i != j],
)
src_list = [i for i in range(num_atoms) for j in range(num_atoms - 1)]
dst_list = [j for i in range(num_atoms) for j in range(num_atoms) if i != j]

g = dgl.graph((src_list, dst_list), num_nodes=num_atoms)

# add name
g.mol_name = mol.GetProp("_Name")
Expand Down
2 changes: 1 addition & 1 deletion bondnet/scripts/examples/train/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ To train BonDNet, three files are needed:
The [train_bde.ipynb](../../train_bde.ipynb) Jupyter notebook shows
how to train BonDNet on a BDE dataset of both neutral and charged molecules.
Try it at: [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/mjwen/bondnet/master?filepath=bondnet%2Fscripts%2Ftrain_bde.ipynb)
Try it at: [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/mjwen/bondnet/pretrained?filepath=bondnet%2Fscripts%2Ftrain_bde.ipynb)
The [train_bde.ipynb](../../train_bde.ipynb) Jupyter notebook trains a model on CPU.
If you want to train on GPUs (a single GPU or distributed), take a look at
Expand Down
4 changes: 2 additions & 2 deletions bondnet/scripts/train_bde.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"source": [
"# Train BonDNet \n",
"\n",
"In this notebook, we show how to train the BonDNet graph neural network model for bond dissociation energy (BDE) prediction. We only show how to train on CPUs. See [train_bde_distributed.py]() for a script for training on GPUs (a single GPU or distributed training on multiple GPUs). "
"In this notebook, we show how to train the BonDNet graph neural network model for bond dissociation energy (BDE) prediction. We only show how to train on CPUs. See [train_bde_distributed.py](./) for a script for training on GPUs (a single GPU or distributed training on multiple GPUs). "
]
},
{
Expand Down Expand Up @@ -47,7 +47,7 @@
"- `molecule_attributes.yaml` This file contains extra molecular attributes (charges here) for molecules given in `molecules.sdf`. Some molecular attributes can be inferred from its SDF block, and they are overrode by the attributes specified in the `molecule_attributes.yaml` file. \n",
"- `reactions.csv` This file list the bond dissociation reations formed by the molecules given in `molecules.sdf`. Each line lists the reactant, products, and BDE of a reaction. The reactant and products are specified by their index in `molecules.sdf`. \n",
"\n",
"See [here]() for the three files used in this notebook. "
"See [here](./examples/train) for the three files used in this notebook. "
]
},
{
Expand Down
17 changes: 17 additions & 0 deletions reminder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
This is a reminder file for the admin of the repo.

# Update dependence conda package version

When changing the version of dependence conda packages, the below files should be updated:
- [README.md](./README.md)
- [pythonpackage.yml](./.github/workflows/pythonpackage.yml)
- [environment.yml](./binder/environment.yml)


# Update binder link to Jupyter notebook

When the Jupyter notebook used as demo on binder are replaced, the binder links in the
below files should be updated.
- [README.md](./README.md)
- [predict/README.md](./bondnet/scripts/examples/predict/README.md)
- [train/README.md](./bondnet/scripts/examples/train/README.md)
6 changes: 2 additions & 4 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,9 @@ def make_homo_CH2O():
A global node u is attached to all atoms and bonds.
"""

g = dgl.DGLGraph()
g.add_nodes(4)
src = [0, 1, 1, 1, 2, 3]
des = [1, 0, 2, 3, 1, 1]
g.add_edges(src, des)
dst = [1, 0, 2, 3, 1, 1]
g = dgl.graph((src, dst))

feats = {}
N = 4
Expand Down

0 comments on commit 57f0494

Please sign in to comment.