"integration-tests/models/test_flash_starcoder2.py" did not exist on "dbdc587dddf0f16b7c05b28fb632acf9f65f185f"
Unverified Commit 36c7b771 authored by Mufei Li's avatar Mufei Li Committed by GitHub
Browse files

[LifeSci] Move to Independent Repo (#1592)

* Move LifeSci

* Remove doc
parent 94c67203
......@@ -24,7 +24,7 @@ DGL is an easy-to-use, high performance and scalable Python package for deep lea
## Using DGL
**A data scientist** may want to apply a pre-trained model to your data right away. For this you can use DGL's [Application packages, formally *Model Zoo*](https://github.com/dmlc/dgl/tree/master/apps). Application packages are developed for domain applications, as is the case for [DGL-LifeScience](https://github.com/dmlc/dgl/tree/master/apps/life_sci). We will soon add model zoo for knowledge graph embedding learning and recommender systems. Here's how you will use a pretrained model:
**A data scientist** may want to apply a pre-trained model to your data right away. For this you can use DGL's [Application packages, formally *Model Zoo*](https://github.com/dmlc/dgl/tree/master/apps). Application packages are developed for domain applications, as is the case for [DGL-LifeScience](https://github.com/awslabs/dgl-lifesci). We will soon add model zoo for knowledge graph embedding learning and recommender systems. Here's how you will use a pretrained model:
```python
from dgllife.data import Tox21
from dgllife.model import load_pretrained
......@@ -148,7 +148,7 @@ Overall there are 30+ models implemented by using DGL:
- [TensorFlow](https://github.com/dmlc/dgl/tree/master/examples/tensorflow)
### DGL for domain applications
- [DGL-LifeSci](https://github.com/dmlc/dgl/tree/master/apps/life_sci), previously DGL-Chem
- [DGL-LifeSci](https://github.com/awslabs/dgl-lifesci), previously DGL-Chem
- [DGL-KE](https://github.com/awslabs/dgl-ke)
- DGL-RecSys(coming soon)
......
# Contributing to DGL-LifeSci
Contribution is always welcome. All contributions must go through pull requests
and code review.
Below is a list of community contributors for this project.
Contributors
------------
* [Chengqiang Lu](https://github.com/geekinglcq): Alchemy dataset; MPNN, MGCN and SchNet
* [Jiajing Hu](https://github.com/jjhu94): Weave
#!/usr/bin/env groovy
// Adapted from github.com/dmlc/dgl/Jenkinsfile
app_linux_libs = "_deps/dgl*.whl"
app = "dgllife"
def init_git() {
sh "rm -rf *"
checkout scm
sh "git submodule update --recursive --init"
}
// pack libraries for later use
def pack_dgl(name, libs) {
echo "Packing ${libs} into ${name}"
stash includes: libs, name: name
}
// unpack libraries saved before
def unpack_dgl(name, libs) {
unstash name
echo "Unpacked ${libs} from ${name}"
}
def build_linux(dev) {
init_git()
sh "bash tests/scripts/build.sh ${dev}"
pack_dgl("${app}-${dev}-linux", app_linux_libs)
}
def unit_test_linux(backend, dev) {
init_git()
unpack_dgl("${app}-${dev}-linux", app_linux_libs)
timeout(time: 10, unit: 'MINUTES') {
sh "bash tests/scripts/task_unit_test.sh ${backend} ${dev}"
}
}
pipeline {
agent any
stages {
stage("Lint Check") {
agent {
docker {
label "linux-cpu-node"
image "dgllib/dgl-ci-lint"
}
}
steps {
init_git()
sh "bash tests/scripts/task_lint.sh"
}
post {
always {
cleanWs disableDeferredWipeout: true, deleteDirs: true
}
}
}
stage("Build") {
parallel {
stage("CPU Build") {
agent {
docker {
label "linux-cpu-node"
image "dgllib/${app}-ci-cpu"
}
}
steps {
build_linux("cpu")
}
post {
always {
cleanWs disableDeferredWipeout: true, deleteDirs: true
}
}
}
stage("GPU Build") {
agent {
docker {
label "linux-cpu-node"
image "dgllib/${app}-ci-gpu"
//args "-u root"
}
}
steps {
build_linux("gpu")
}
post {
always {
cleanWs disableDeferredWipeout: true, deleteDirs: true
}
}
}
}
}
stage("Test") {
parallel {
stage("Torch CPU") {
agent {
docker {
label "linux-cpu-node"
image "dgllib/${app}-ci-cpu"
}
}
stages {
stage("Unit test") {
steps {
unit_test_linux("pytorch", "cpu")
}
}
}
post {
always {
cleanWs disableDeferredWipeout: true, deleteDirs: true
}
}
}
stage("Torch GPU") {
agent {
docker {
label "linux-gpu-node"
image "dgllib/${app}-ci-gpu"
args "--runtime nvidia"
}
}
stages {
stage("Unit test") {
steps {
sh "nvidia-smi"
unit_test_linux("pytorch", "gpu")
}
}
}
post {
always {
cleanWs disableDeferredWipeout: true, deleteDirs: true
}
}
}
}
}
}
}
\ No newline at end of file
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
\ No newline at end of file
# DGL-LifeSci
[Documentation](https://lifesci.dgl.ai/index.html) | [Discussion Forum](https://discuss.dgl.ai)
## Introduction
Deep learning on graphs has been an arising trend in the past few years. There are a lot of graphs in
life science such as molecular graphs and biological networks, making it an import area for applying
deep learning on graphs. DGL-LifeSci is a DGL-based package for various applications in life science
with graph neural networks.
We provide various functionalities, including but not limited to methods for graph construction,
featurization, and evaluation, model architectures, training scripts and pre-trained models.
For a list of community contributors, see [here](CONTRIBUTORS.md).
**For a full list of work implemented in DGL-LifeSci, see [here](examples/README.md).**
## Installation
### Requirements
DGL-LifeSci should work on
* all Linux distributions no earlier than Ubuntu 16.04
* macOS X
* Windows 10
DGL-LifeSci requires python 3.6+, DGL 0.4.3+ and PyTorch 1.2.0+.
Additionally, we require `RDKit 2018.09.3` for cheminformatics. We recommend installing it with
```
conda install -c conda-forge rdkit==2018.09.3
```
For other installation recipes for RDKit, see the [official documentation](https://www.rdkit.org/docs/Install.html).
### Pip installation for DGL-LifeSci
```
pip install dgllife
```
### Conda installation for DGL-LifeSci
```
conda install -c dglteam dgllife
```
### Installation from source
If you want to try experimental features, you can install from source as follows:
```
git clone https://github.com/dmlc/dgl.git
cd apps/life_sci/python
python setup.py install
```
### Verifying successful installation
Once you have installed the package, you can verify the success of installation with
```python
import dgllife
print(dgllife.__version__)
# 0.2.2
```
If you are new to DGL, the first time you import dgl a message will pop up as below:
```
DGL does not detect a valid backend option. Which backend would you like to work with?
Backend choice (pytorch, mxnet or tensorflow):
```
and you need to enter `pytorch`.
## Example Usage
To apply graph neural networks to molecules with DGL, we need to first construct `DGLGraph` --
the graph data structure in DGL and prepare initial node/edge features. Below gives an example of
constructing a bi-directed graph from a molecule and featurizing it with atom and bond features such
as atom type and bond type.
```python
from dgllife.utils import smiles_to_bigraph, CanonicalAtomFeaturizer, CanonicalBondFeaturizer
# Node featurizer
node_featurizer = CanonicalAtomFeaturizer(atom_data_field='h')
# Edge featurizer
edge_featurizer = CanonicalBondFeaturizer(bond_data_field='h')
# SMILES (a string representation for molecule) for Penicillin
smiles = 'CC1(C(N2C(S1)C(C2=O)NC(=O)CC3=CC=CC=C3)C(=O)O)C'
g = smiles_to_bigraph(smiles=smiles,
node_featurizer=node_featurizer,
edge_featurizer=edge_featurizer)
print(g)
"""
DGLGraph(num_nodes=23, num_edges=50,
ndata_schemes={'h': Scheme(shape=(74,), dtype=torch.float32)}
edata_schemes={'h': Scheme(shape=(12,), dtype=torch.float32)})
"""
```
We implement various models that users can import directly. Below gives an example of defining a GCN-based model
for molecular property prediction.
```python
from dgllife.model import GCNPredictor
model = GCNPredictor(in_feats=1)
```
For a full example of applying `GCNPredictor`, run the following command
```bash
python examples/property_prediction/classification.py -m GCN -d Tox21
```
For more examples on molecular property prediction, generative models, protein-ligand binding affinity
prediction and reaction prediction, see `examples`.
We also provide pre-trained models for most examples, which can be used off-shelf without training from scratch.
Below gives an example of loading a pre-trained model for `GCNPredictor` on a molecular property prediction dataset.
```python
from dgllife.data import Tox21
from dgllife.model import load_pretrained
from dgllife.utils import smiles_to_bigraph, CanonicalAtomFeaturizer
dataset = Tox21(smiles_to_bigraph, CanonicalAtomFeaturizer())
model = load_pretrained('GCN_Tox21') # Pretrained model loaded
model.eval()
smiles, g, label, mask = dataset[0]
feats = g.ndata.pop('h')
label_pred = model(g, feats)
print(smiles) # CCOc1ccc2nc(S(N)(=O)=O)sc2c1
print(label_pred[:, mask != 0]) # Mask non-existing labels
# tensor([[ 1.4190, -0.1820, 1.2974, 1.4416, 0.6914,
# 2.0957, 0.5919, 0.7715, 1.7273, 0.2070]])
```
Similarly, we can load a pre-trained model for generating molecules. If possible, we recommend running
the code block below with Jupyter notebook.
```python
from dgllife.model import load_pretrained
model = load_pretrained('DGMG_ZINC_canonical')
model.eval()
smiles = []
for i in range(4):
smiles.append(model(rdkit_mol=True))
print(smiles)
# ['CC1CCC2C(CCC3C2C(NC2=CC(Cl)=CC=C2N)S3(=O)=O)O1',
# 'O=C1SC2N=CN=C(NC(SC3=CC=CC=N3)C1=CC=CO)C=2C1=CCCC1',
# 'CC1C=CC(=CC=1)C(=O)NN=C(C)C1=CC=CC2=CC=CC=C21',
# 'CCN(CC1=CC=CC=C1F)CC1CCCN(C)C1']
```
If you are running the code block above in Jupyter notebook, you can also visualize the molecules generated with
```python
from IPython.display import SVG
from rdkit import Chem
from rdkit.Chem import Draw
mols = [Chem.MolFromSmiles(s) for s in smiles]
SVG(Draw.MolsToGridImage(mols, molsPerRow=4, subImgSize=(180, 150), useSVG=True))
```
![](https://data.dgl.ai/dgllife/dgmg/dgmg_model_zoo_example2.png)
## Speed Reference
Below we provide some reference numbers to show how DGL improves the speed of training models per epoch in seconds.
| Model | Original Implementation | DGL Implementation | Improvement |
| ---------------------------------- | ----------------------- | -------------------------- | ---------------------------- |
| GCN on Tox21 | 5.5 (DeepChem) | 1.0 | 5.5x |
| AttentiveFP on Aromaticity | 6.0 | 1.2 | 5x |
| JTNN on ZINC | 1826 | 743 | 2.5x |
| WLN for reaction center prediction | 11657 | 858 (1 GPU) / 134 (8 GPUs) | 13.6x (1GPU) / 87.0x (8GPUs) |
| WLN for candidate ranking | 40122 | 22268 | 1.8x |
DGL-LifeSci is moved [here](https://github.com/awslabs/dgl-lifesci).
# Conda Recipe
Build the package with `conda build .`
\ No newline at end of file
$PYTHON setup.py install --single-version-externally-managed --record=record.txt # Python command to install the script.
\ No newline at end of file
python:
- 3.6
- 3.7
\ No newline at end of file
package:
name: dgllife{{ environ.get('APP_PACKAGE_SUFFIX', '') }}
version: "0.2.2"
source:
url: https://files.pythonhosted.org/packages/19/e7/7d9890c7ddb303613f8a9c0bafafa40239e65f9c0698e699f19f577412fc/dgllife-0.2.2.tar.gz
sha256: 812a93d54cd5c049a7368aae01d53b5a4a12ca2d0e4e57d74fa4a844a1c01d92
requirements:
build:
- python {{ python }}
- setuptools
- cmake
- git
- cython
run:
- python
- requests
- scikit-learn
- pandas
- tqdm
- numpy
- scipy
- networkx
about:
license: Apache
\ No newline at end of file
From dgllib/dgl-sagemaker-cpu:dgl_0.4_pytorch_1.2.0_rdkit
RUN pip uninstall -y scikit-learn
RUN pip install scikit-learn==0.22.2.post1
RUN pip uninstall -y pandas
RUN pip install pandas==0.24.2
RUN pip uninstall -y dgl
RUN pip install --pre dgl
\ No newline at end of file
From dgllib/dgl-sagemaker-gpu:dgl_0.4_pytorch_1.2.0_rdkit
RUN pip uninstall -y scikit-learn
RUN pip install scikit-learn==0.22.2.post1
RUN pip uninstall -y pandas
RUN pip install pandas==0.24.2
RUN pip uninstall -y dgl-cu100
RUN pip install --pre dgl-cu101
\ No newline at end of file
# Build Docker Image for CI
Docker images are used by the CI and release script. Make sure to install necessary requirements in it.
## To build
```bash
docker build -t dgllib/dgllife-ci-cpu:latest -f Dockerfile.ci_cpu .
```
```bash
docker build -t dgllib/dgllife-ci-gpu:latest -f Dockerfile.ci_gpu .
```
## To push
```bash
docker push dgllib/dgllife-ci-cpu:latest
```
```bash
docker push dgllib/dgllife-ci-gpu:latest
```
build
# tutorials are auto-generated
source/tutorials
source/generated
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SOURCEDIR = source
BUILDDIR = build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
pytorch:
@echo "##################################################################"
@echo "# #"
@echo "# Step 1: Building PyTorch tutorials #"
@echo "# #"
@echo "##################################################################"
@DGLBACKEND=pytorch $(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
html-noexec:
$(SPHINXBUILD) -D plot_gallery=0 -b html "$(SOURCEDIR)" "$(BUILDDIR)/html"
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
html: Makefile pytorch
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Documentation and Tutorials
===
Requirements
------------
* sphinx
* sphinx-gallery
* sphinx_rtd_theme
Build documents
---------------
First, clean up existing files:
```
./clean.sh
```
Then build:
```
make html
```
Render locally
--------------
```
cd build/html
python3 -m http.server 8000
```
#!/bin/sh
make clean
rm -rf build
rm -rf source/tutorials
rm -rf source/generated
.. _apidata:
Datasets
========
.. contents:: Contents
:local:
Molecular Property Prediction
-----------------------------
Tox21
`````
.. autoclass:: dgllife.data.Tox21
:members: task_pos_weights, __getitem__, __len__
:show-inheritance:
Alchemy for Quantum Chemistry
`````````````````````````````
.. autoclass:: dgllife.data.TencentAlchemyDataset
:members: set_mean_and_std, __getitem__, __len__
Pubmed Aromaticity
``````````````````
.. autoclass:: dgllife.data.PubChemBioAssayAromaticity
:members: __getitem__, __len__
:show-inheritance:
Adapting to New Datasets with CSV
`````````````````````````````````
.. autoclass:: dgllife.data.MoleculeCSVDataset
:members: __getitem__, __len__
Reaction Prediction
-------------------
USPTO
`````
.. autoclass:: dgllife.data.USPTOCenter
:members: __getitem__, __len__
:show-inheritance:
.. autoclass:: dgllife.data.USPTORank
:members: ignore_large, __getitem__, __len__
:show-inheritance:
Adapting to New Datasets for Weisfeiler-Lehman Networks
```````````````````````````````````````````````````````
.. autoclass:: dgllife.data.WLNCenterDataset
:members: __getitem__, __len__
.. autoclass:: dgllife.data.WLNRankDataset
:members: ignore_large, __getitem__, __len__
Protein-Ligand Binding Affinity Prediction
------------------------------------------
PDBBind
```````
.. autoclass:: dgllife.data.PDBBind
:members: __getitem__, __len__
.. _apimodelgnn:
Graph Neural Networks for Updating Node/Edge Representations
============================================================
All models based on graph neural networks start with updating node/edge representations.
We introduce various GNN models implemented in DGL-LifeSci for representation update.
.. contents:: Contents
:local:
AttentiveFP
-----------
.. automodule:: dgllife.model.gnn.attentivefp
:members:
GAT
---
.. automodule:: dgllife.model.gnn.gat
:members:
GCN
---
.. automodule:: dgllife.model.gnn.gcn
:members:
MGCN
----
.. automodule:: dgllife.model.gnn.mgcn
:members:
MPNN
----
.. automodule:: dgllife.model.gnn.mpnn
:members:
SchNet
------
.. automodule:: dgllife.model.gnn.schnet
:members:
Weave
-----
.. automodule:: dgllife.model.gnn.weave
:members:
GIN
---
.. automodule:: dgllife.model.gnn.gin
:members:
WLN
---
.. automodule:: dgllife.model.gnn.wln
:members:
.. _apimodelpretrain:
Pre-trained Models
==================
We provide multiple pre-trained models for users to use without the need of training from scratch.
Example Usage
-------------
Property Prediction
```````````````````
.. code-block:: python
from dgllife.data import Tox21
from dgllife.model import load_pretrained
from dgllife.utils import smiles_to_bigraph, CanonicalAtomFeaturizer
dataset = Tox21(smiles_to_bigraph, CanonicalAtomFeaturizer())
model = load_pretrained('GCN_Tox21') # Pretrained model loaded
model.eval()
smiles, g, label, mask = dataset[0]
feats = g.ndata.pop('h')
label_pred = model(g, feats)
print(smiles) # CCOc1ccc2nc(S(N)(=O)=O)sc2c1
print(label_pred[:, mask != 0]) # Mask non-existing labels
# tensor([[ 1.4190, -0.1820, 1.2974, 1.4416, 0.6914,
# 2.0957, 0.5919, 0.7715, 1.7273, 0.2070]])
Generative Models
.. code-block:: python
from dgllife.model import load_pretrained
model = load_pretrained('DGMG_ZINC_canonical')
model.eval()
smiles = []
for i in range(4):
smiles.append(model(rdkit_mol=True))
print(smiles)
# ['CC1CCC2C(CCC3C2C(NC2=CC(Cl)=CC=C2N)S3(=O)=O)O1',
# 'O=C1SC2N=CN=C(NC(SC3=CC=CC=N3)C1=CC=CO)C=2C1=CCCC1',
# 'CC1C=CC(=CC=1)C(=O)NN=C(C)C1=CC=CC2=CC=CC=C21',
# 'CCN(CC1=CC=CC=C1F)CC1CCCN(C)C1']
If you are running the code block above in Jupyter notebook, you can also visualize the molecules generated with
.. code-block:: python
from IPython.display import SVG
from rdkit import Chem
from rdkit.Chem import Draw
mols = [Chem.MolFromSmiles(s) for s in smiles]
SVG(Draw.MolsToGridImage(mols, molsPerRow=4, subImgSize=(180, 150), useSVG=True))
.. image:: https://data.dgl.ai/dgllife/dgmg/dgmg_model_zoo_example2.png
API
---
.. autofunction:: dgllife.model.load_pretrained
.. _apimodelreadout:
Readout for Computing Graph Representations
===========================================
After updating node/edge representations with graph neural networks (GNNs), a common operation is to compute
graph representations out of updated node/edge representations. For example, we need to compute molecular
representations out of atom/bond representations in molecular property prediction. We call the various modules
for computing graph-level representations **readout** as in Neural Message Passing for Quantum Chemistry and this
section lists the readout modules implemented in DGL-LifeSci.
.. contents:: Contents
:local:
AttentiveFP Readout
-------------------
.. automodule:: dgllife.model.readout.attentivefp_readout
:members:
MLP Readout
-----------
.. automodule:: dgllife.model.readout.mlp_readout
:members:
Weighted Sum and Max Readout
----------------------------
.. automodule:: dgllife.model.readout.weighted_sum_and_max
:members:
Weave Readout
-------------
.. automodule:: dgllife.model.readout.weave_readout
:members:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment