### Navigate to Molecular Property Prediction Example Source: https://github.com/awslabs/dgl-lifesci/blob/master/docs/source/cli.rst Change directory to the molecular property prediction example to follow its README for setup and execution. ```bash cd dgl-lifesci/examples/property_prediction/csv_data_configuration/ ``` -------------------------------- ### Navigate to Reaction Prediction Example Source: https://github.com/awslabs/dgl-lifesci/blob/master/docs/source/cli.rst Change directory to the reaction prediction example to follow its README for setup and execution. ```bash cd dgl-lifesci/examples/reaction_prediction/rexgen_direct/ ``` -------------------------------- ### Install DGL-LifeSci from Source Source: https://github.com/awslabs/dgl-lifesci/blob/master/README.md Installs DGL-LifeSci from its GitHub repository, useful for trying experimental features. Navigate to the python directory before installing. ```bash git clone https://github.com/awslabs/dgl-lifesci.git cd dgl-lifesci/python python setup.py install ``` -------------------------------- ### Install OGB Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/link_prediction/ogbl-ppa/README.md Install the OGB library, version 1.1.1, which is required for the dataset. ```bash pip install ogb ``` -------------------------------- ### Launch TensorBoard for Monitoring Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/generative_models/dgmg/README.md Launch TensorBoard to monitor the training process. Ensure tensorboardX and TensorFlow are installed. The log directory should be set appropriately. ```bash tensorboard --logdir=. ``` -------------------------------- ### Monitor Training Progress Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/reaction_prediction/rexgen_direct/README.md Example output showing the training progress, including epoch, iteration, loss, and gradient norm. This helps in monitoring the model's learning. ```bash Epoch 1/50, iter 8150/20452 | loss 8.4788 | grad norm 12.9927 Epoch 1/50, iter 8200/20452 | loss 8.6722 | grad norm 14.0833 ``` -------------------------------- ### Example Reaction SMILES Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/reaction_prediction/rexgen_direct/README.md Illustrates the format of reaction SMILES with reactants, products, and atom mapping. ```bash [CH3:14][NH2:15].[N+:1](=[O:2])([O-:3])[c:4]1[cH:5][c:6]([C:7](=[O:8])[OH:9])[cH:10][cH:11][c:12]1[Cl:13].[OH2:16]>>[N+:1](=[O:2])([O-:3])[c:4]1[cH:5][c:6]([C:7](=[O:8])[OH:9])[cH:10][cH:11][c:12]1[NH:15][CH3:14] ``` -------------------------------- ### Start Training DGMG Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/generative_models/dgmg/README.md Use train.py to start training the DGMG model. Specify the dataset and graph generation order. Optional arguments include random seed and number of processes. ```bash python train.py -d DATASET -o {random,canonical} ``` -------------------------------- ### OGBG-PPA Property Prediction Example Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/README.md Example script for property prediction on the ogbg-ppa dataset. ```python import torch import torch.nn as nn import torch.optim as optim from dgllife.datasets import OGBGPPAPrediction from dgllife.model import GCN # Load dataset dataset = OGBGPPAPrediction(root='../data') graph = dataset[0] # Define model model = GCN(in_feats=graph.ndata['feat'].shape[1], hidden_feats=[32, 32, 32], graph_norm=True) # Define loss and optimizer loss_fn = nn.MSELoss() optimizer = optim.Adam(model.parameters(), lr=0.01) # Training and evaluation would follow here print("OGBG-PPA dataset loaded and GCN model defined.") ``` -------------------------------- ### Install DGL-LifeSci via Pip Source: https://github.com/awslabs/dgl-lifesci/blob/master/README.md Installs the DGL-LifeSci package using pip for general use. ```bash pip install dgllife ``` -------------------------------- ### Verify DGL-LifeSci Installation Source: https://github.com/awslabs/dgl-lifesci/blob/master/README.md Checks if DGL-LifeSci is installed correctly by printing its version number. Requires the package to be installed first. ```python import dgllife print(dgllife.__version__) # 0.3.2 ``` -------------------------------- ### OGBL-PPA Link Prediction Example Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/README.md Example script for link prediction on the ogbl-ppa dataset. ```python import torch import torch.nn as nn import torch.optim as optim from dgllife.datasets import OGBLPPA from dgllife.model import GCN # Load dataset dataset = OGBLPPA(root='../data') graph = dataset[0] # Define model model = GCN(in_feats=graph.ndata['feat'].shape[1], hidden_feats=[32, 32, 32], graph_norm=True) # Define loss and optimizer loss_fn = nn.BCEWithLogitsLoss() optimizer = optim.Adam(model.parameters(), lr=0.01) # Training and evaluation would follow here print("OGBL-PPA dataset loaded and GCN model defined.") ``` -------------------------------- ### Clone DGL-LifeSci Repository Source: https://github.com/awslabs/dgl-lifesci/blob/master/docs/source/cli.rst Clone the DGL-LifeSci GitHub repository to your local machine to access the command line tools and examples. ```bash git clone https://github.com/awslabs/dgl-lifesci.git ``` -------------------------------- ### Install Specific RDKit Version via Conda Source: https://github.com/awslabs/dgl-lifesci/blob/master/README.md Installs RDKit version 2018.09.3 using conda, which is required for the JTVAE example. ```bash conda install -c rdkit rdkit==2018.09.3 ``` -------------------------------- ### Evaluate Model Performance Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/reaction_prediction/rexgen_direct/README.md Example evaluation result format displayed when the learning rate is decayed. It shows total samples trained and top-k accuracy on the validation set. ```bash total samples 800000, (epoch 2/35, iter 2443/2557) | acc@12 0.9278 | acc@16 0.9419 | acc@20 0.9496 | acc@40 0.9596 | acc@80 0.9596 | ``` -------------------------------- ### Example Mapped Rxn SMILES Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/reaction_prediction/rexgen_direct/README.md An example of reaction SMILES after being converted to a canonical form and having atom mapping applied. ```text [O:15]=[CH:1][NH:2][CH2:3][CH2:4][c:5]1[cH:6][cH:7][c:8]([O:9][CH3:10])[c:11]([O:12][CH3:13])[cH:14]1>>[CH:1]1=[N:2][CH2:3][CH2:4][c:5]2[cH:14][c:11]([O:12][CH3:13])[c:8]([O:9][CH3:10])[cH:7][c:6]12 ``` -------------------------------- ### Install RDKit via Pip Source: https://github.com/awslabs/dgl-lifesci/blob/master/README.md Installs the RDKit library, a dependency for DGL-LifeSci. For specific versions like 2018.09.3, use conda. ```bash pip install rdkit ``` -------------------------------- ### Serve HTML Documentation Locally Source: https://github.com/awslabs/dgl-lifesci/blob/master/docs/README.md Navigate to the build directory and run this command to serve the generated HTML documentation locally using Python's http.server. ```bash cd build/html python3 -m http.server 8000 ``` -------------------------------- ### Build HTML Documentation Source: https://github.com/awslabs/dgl-lifesci/blob/master/docs/README.md Execute this command to build the HTML version of the documentation. ```bash make html ``` -------------------------------- ### Install RDKit with Conda Source: https://github.com/awslabs/dgl-lifesci/blob/master/docs/source/install/index.rst Installs RDKit version 2018.09.3 using conda. Other versions are not tested. ```bash conda install -c conda-forge rdkit==2018.09.3 ``` -------------------------------- ### Run Training Script Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/property_prediction/ogbg_ppa/README.md Execute the main training script. Specify the GNN model to use (e.g., gcn, gin, gcn-virtual, gin-virtual). The script defaults to using GPU if available. ```bash python main.py --gnn X ``` -------------------------------- ### Create Conda Environment Source: https://github.com/awslabs/dgl-lifesci/blob/master/README.md Recommended way to set up a Python environment for DGL-LifeSci. Ensure Python 3.6+ is used. ```bash conda create -n dgllife python=3.6 ``` -------------------------------- ### Download Atom Weight Visualization Notebook Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/property_prediction/pubchem_aromaticity/README.md Download the Jupyter notebook for performing atom weight visualization. This notebook helps in interpreting the model's learned atom importance weights. ```bash wget https://data.dgl.ai/dgllife/attentive_fp/atom_weight_visualization.ipynb ``` -------------------------------- ### Supervised Pre-training Script Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/property_prediction/pretrain_gnns/chem/README.md Run this command for supervised pre-training. It loads a self-supervised model from INPUT_MODEL_FILE and trains it further. Custom datasets should be in a specific pickled format. ```bash python pretrain_supervised.py --input_model_file INPUT_MODEL_FILE --output_model_file OUTPUT_MODEL_FILE ``` -------------------------------- ### Custom Dataset Configuration Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/generative_models/dgmg/README.md Configure training with your own dataset by providing paths to training and validation files. ```bash -tf TRAIN_FILE, Path to a file with one SMILES a line for training data. This is only necessary if you want to use a new dataset. (default: None) -vf VAL_FILE, Path to a file with one SMILES a line for validation data. This is only necessary if you want to use a new dataset. (default: None) ``` -------------------------------- ### Train Models from Scratch Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/property_prediction/alchemy/README.md Use this command to train SchNet, MPNN, or MGCN models from scratch on the Alchemy dataset. Replace 'X' with the desired model name. ```bash python main.py -m X ``` -------------------------------- ### Create DGL Graphs with Pre-trained Featurizers Source: https://context7.com/awslabs/dgl-lifesci/llms.txt Demonstrates how to convert SMILES strings into DGL graphs using pre-trained atom and bond featurizers. Ensure necessary libraries like torch and dgl are imported. ```python from dgllife.utils import PretrainAtomFeaturizer, PretrainBondFeaturizer from dgllife.utils import smiles_to_bigraph node_featurizer = PretrainAtomFeaturizer() edge_featurizer = PretrainBondFeaturizer() graphs = [smiles_to_bigraph(s, node_featurizer=node_featurizer, edge_featurizer=edge_featurizer) for s in ['CCO', 'CC(=O)O']] bg = dgl.batch(graphs) with torch.no_grad(): node_embeds = model( bg, [bg.ndata['atomic_num'], bg.ndata['chirality_type']], [bg.edata['bond_type'], bg.edata['bond_direction_type']], ) print(node_embeds.shape) # torch.Size([total_nodes, 300]) ``` -------------------------------- ### Download Evaluation Jupyter Notebook Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/generative_models/dgmg/README.md Download the provided Jupyter notebook to visualize generated molecules and compare property distributions against training data. ```bash wget https://data.dgl.ai/dgllife/dgmg/eval_jupyter.ipynb ``` -------------------------------- ### Clean Documentation Files Source: https://github.com/awslabs/dgl-lifesci/blob/master/docs/README.md Run this script to clean up existing generated documentation files before rebuilding. ```bash ./clean.sh ``` -------------------------------- ### Optional Training Arguments Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/generative_models/dgmg/README.md Configure training with optional arguments like random seed and number of processes for DGMG. ```bash -s SEED, random seed (default: 0) -np NUM_PROCESSES, number of processes to use (default: 32) ``` -------------------------------- ### Multi-GPU Training Configuration Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/reaction_prediction/rexgen_direct/README.md To enable multi-GPU training, specify the GPU IDs using the --gpus argument. This command trains the model using GPUs with the specified IDs. ```bash python find_reaction_center_train.py --gpus id1,id2,... ``` -------------------------------- ### Load and Use Pre-trained GNN Models Source: https://context7.com/awslabs/dgl-lifesci/llms.txt Shows how to load pre-trained GNN models like GCN for property prediction (e.g., Tox21) using `load_pretrained`. Requires torch and dgl for inference. ```python from dgllife.utils import load_pretrained # Pre-trained GCN on Tox21 model = load_pretrained('GCN_Tox21') model.eval() print(type(model)) # # Use it for inference import torch import dgl from dgllife.utils import smiles_to_bigraph, CanonicalAtomFeaturizer node_featurizer = CanonicalAtomFeaturizer() smiles_list = ['CC(=O)Oc1ccccc1C(=O)O', 'c1cccnc1'] # Aspirin, Pyridine graphs = [smiles_to_bigraph(s, node_featurizer=node_featurizer) for s in smiles_list] bg = dgl.batch(graphs) with torch.no_grad(): logits = model(bg, bg.ndata['h']) # (2, 12) — 12 Tox21 endpoints probs = torch.sigmoid(logits) print(probs.shape) # torch.Size([2, 12]) print(probs[0]) # Predicted toxicity probabilities for Aspirin ``` -------------------------------- ### Pre-train and Train JT-VAE Model Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/generative_models/jtvae/README.md Execute these commands to first pre-train the VAE model without KL regularization, and then train it with KL regularization using the pre-trained checkpoints. Adjust the KL regularization weight using the -z flag. ```bash CUDA_VISIBLE_DEVICES=0 python pretrain.py ``` ```bash CUDA_VISIBLE_DEVICES=0 python vaetrain.py -m pre_model/model.iter-2 ``` -------------------------------- ### Build CPU Docker Image Source: https://github.com/awslabs/dgl-lifesci/blob/master/docker/README.md Builds a Docker image for CPU-based CI. Ensure you have a Dockerfile named 'Dockerfile.ci_cpu' in the current directory. ```bash docker build -t dgllib/dgllife-ci-cpu:latest -f Dockerfile.ci_cpu . ``` -------------------------------- ### Command-line Usage for MTL Training Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/property_prediction/MTL/README.md Use this command to run training experiments. Specify the dataset CSV, model type, multitask mode, output path, SMILES column, and task columns. ```bash python -c CSV -m MODEL --mode MODE -p PATH -s SMILES -t TASKS ``` -------------------------------- ### Train AttentiveFP Model Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/property_prediction/pubchem_aromaticity/README.md Run this command to train the AttentiveFP model from scratch on the dataset. ```bash python main.py ``` -------------------------------- ### Train GNN Property Predictors via CLI Source: https://context7.com/awslabs/dgl-lifesci/llms.txt Command-line interface for training GNN-based property predictors on custom CSV data. Supports various models, featurizers, splitting strategies, and hyperparameter optimization. ```bash # --- Regression: train on a CSV with SMILES and numeric property columns --- python examples/property_prediction/csv_data_configuration/regression_train.py \ -c my_molecules.csv \ # Path to CSV file -sc smiles \ # Name of the SMILES column -t logP,MW \ # Target column names (omit to use all non-SMILES columns) -mo AttentiveFP \ # Model: GCN|GAT|Weave|MPNN|AttentiveFP|NF|gin_supervised_* -a attentivefp \ # Atom featurizer: canonical|attentivefp -b attentivefp \ # Bond featurizer: canonical|attentivefp -s scaffold_smiles \ # Split: scaffold_smiles|random|scaffold_decompose -sr 0.8,0.1,0.1 \ # Train/val/test fractions -me r2 \ # Metric: r2|mae|rmse -ne 20 \ # Bayesian hyperparameter search trials (None=fixed config) -n 1000 \ # Max training epochs (early stopping on val metric) -p regression_results # Output directory: model.pth, eval.txt, configure.json ``` -------------------------------- ### Self-supervised Pre-training with Attribute Masking Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/property_prediction/pretrain_gnns/chem/README.md Execute this script for self-supervised pre-training using attribute masking. The model learns to predict masked node/edge attributes based on graph structure. Specify --dataset for custom datasets. ```bash python pretrain_masking.py --output_model_file OUTPUT_MODEL_FILE ``` -------------------------------- ### Easy Evaluation for Reaction Prediction Model Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/reaction_prediction/rexgen_direct/README.md Run this command for an easier evaluation scenario, which excludes reactants not contributing heavy atoms to the product. This makes the task simpler. ```bash python find_reaction_center_eval.py --easy ``` -------------------------------- ### Train Reaction Center Prediction Model Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/reaction_prediction/rexgen_direct/README.md Use this command to train the reaction center prediction model with default options. Ensure GPU is available for faster training. ```bash python find_reaction_center_train.py ``` -------------------------------- ### Build GPU Docker Image Source: https://github.com/awslabs/dgl-lifesci/blob/master/docker/README.md Builds a Docker image for GPU-based CI. Ensure you have a Dockerfile named 'Dockerfile.ci_gpu' in the current directory. ```bash docker build -t dgllib/dgllife-ci-gpu:latest -f Dockerfile.ci_gpu . ``` -------------------------------- ### Training Progress Output Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/reaction_prediction/rexgen_direct/README.md Observe the training progress, which includes epoch, iteration, time, accuracy, and gradient norm. This output is printed in the terminal during the training process. ```bash Epoch 6/6, iter 16439/20061 | time 1.1124 | accuracy 0.8500 | grad norm 5.3218 Epoch 6/6, iter 16440/20061 | time 1.1124 | accuracy 0.9500 | grad norm 2.1163 ``` -------------------------------- ### IO Utils Source: https://github.com/awslabs/dgl-lifesci/blob/master/docs/source/api/utils.mols.rst Utilities for loading molecules and accessing their information. ```APIDOC ## get_mol_3d_coordinates ### Description Get 3D coordinates of atoms in a molecule. ## load_molecule ### Description Load a molecule from a file. ## multiprocess_load_molecules ### Description Load molecules from multiple files using multiprocessing. ## load_smiles_from_txt ### Description Load SMILES strings from a text file. ``` -------------------------------- ### Troubleshoot RuntimeError: received 0 items of ancdata Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/reaction_prediction/rexgen_direct/README.md If you encounter this runtime error, try reducing the number of processes used for mini-batch construction by specifying '-nw A'. The default values for A are 100 for training and 32 for evaluation. ```bash RuntimeError: received 0 items of ancdata try using a smaller number of processes with "-nw A". ``` -------------------------------- ### Optional Training Arguments Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/property_prediction/ogbg_ppa/README.md View and utilize optional arguments for the training script, such as dropout rate, number of GNN layers, hidden feature dimensions, batch size, epochs, number of workers for data loading, and output filename. ```bash --dropout, dropout to use, (default=0.5) --n_layers, number of GNN layers to use, (default=5) --hidden_feats, number of hidden units in GNNs, (default=300) --batch_size, batch size for training, (default=32) --epochs, number of epochs for training, (default=100) --num_workers, number of processes for data loading, (default=1) --filename, filename to output results. By default, it will be the same as the gnn used. ``` -------------------------------- ### Featurization for Molecules - General Utils Source: https://github.com/awslabs/dgl-lifesci/blob/master/docs/source/api/utils.mols.rst General utilities for featurization. ```APIDOC ## one_hot_encoding ### Description Perform one-hot encoding on a categorical feature. ## ConcatFeaturizer ### Description Featurizer that concatenates multiple featurizers. ``` -------------------------------- ### Load and Use Pre-trained Model for Property Prediction Source: https://github.com/awslabs/dgl-lifesci/blob/master/docs/source/api/model.pretrain.rst Demonstrates loading a pre-trained GCN model for Tox21 property prediction. Ensure necessary imports and dataset are prepared before use. ```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]]) ``` -------------------------------- ### Push CPU Docker Image Source: https://github.com/awslabs/dgl-lifesci/blob/master/docker/README.md Pushes the built CPU Docker image to the registry. This makes the image available for CI or release processes. ```bash docker push dgllib/dgllife-ci-cpu:latest ``` -------------------------------- ### Evaluate Pre-trained Reaction Prediction Model Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/reaction_prediction/rexgen_direct/README.md Evaluate the provided pre-trained model without needing to train from scratch. Simply run the evaluation script without any specific model path. ```bash python find_reaction_center_eval.py ``` -------------------------------- ### Evaluate Reaction Prediction Model Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/reaction_prediction/rexgen_direct/README.md Use this command to evaluate a trained candidate ranking model. Specify model paths for candidate ranking and reaction center prediction, along with the test dataset path. Omit '--model-path X' to use a pre-trained candidate ranking model and '-cmp Y' to use a pre-trained reaction center prediction model. ```bash python candidate_ranking_eval.py --model-path X -cmp Y --test-path Z ``` -------------------------------- ### Push GPU Docker Image Source: https://github.com/awslabs/dgl-lifesci/blob/master/docker/README.md Pushes the built GPU Docker image to the registry. This makes the image available for CI or release processes. ```bash docker push dgllib/dgllife-ci-gpu:latest ``` -------------------------------- ### Evaluate Candidate Ranking Model Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/reaction_prediction/rexgen_direct/README.md Evaluate the candidate ranking model. Provide the path to the trained candidate ranking model using --model-path and the path to the reaction center prediction model using -cmp. If -cmp is not specified, a pre-trained model will be used. ```bash python candidate_ranking_eval.py --model-path X -cmp Y ``` -------------------------------- ### Run Regression Inference on New Molecules Source: https://context7.com/awslabs/dgl-lifesci/llms.txt Use this script for regression inference on new molecules. Specify the input file, path to training results, and output path for inference results. ```bash python examples/property_prediction/csv_data_configuration/regression_inference.py \ -f new_molecules.txt \ -tp regression_results \ -ip regression_inference_results ``` -------------------------------- ### Run Experiment with Trained Model Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/property_prediction/MTL/README.md Execute this command after generating the synthetic dataset to run an experiment using a GCN model in parallel mode. Results and checkpoints will be saved to the specified path. ```bash python main.py -c syn_data.csv -m GCN --mode parallel -p results -s smiles -t logP,logD ``` -------------------------------- ### PDBBind Dataset Subsets and Splitting Methods Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/binding_affinity_prediction/README.md Lists available PDBBind dataset subsets and splitting methods for training and evaluation. Note specific implementations for 'structure' and 'sequence' splits on PDBBind v2007 Refined. ```text { PDBBind_core_pocket_random, PDBBind_core_pocket_scaffold, PDBBind_core_pocket_stratified, PDBBind_core_pocket_temporal, PDBBind_refined_pocket_random, PDBBind_refined_pocket_scaffold, PDBBind_refined_pocket_stratified, PDBBind_refined_pocket_temporal, PDBBind_refined_pocket_structure, PDBBind_refined_pocket_sequence } ``` -------------------------------- ### Test JT-VAE Model for Molecule Reconstruction Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/generative_models/jtvae/README.md Run this command to evaluate the molecule reconstruction performance of a trained JT-VAE model. Replace 'Y' with the path to your model checkpoint. If no path is specified, it defaults to a pre-trained model without KL regularization. ```bash CUDA_VISIBLE_DEVICES=0 python reconstruct.py -m Y ``` -------------------------------- ### Train Property Prediction Model Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/property_prediction/csv_data_configuration/README.md Use this command to initiate the training process for predicting real-valued properties. Specify the path to your CSV data and the header for the SMILES column. Various optional arguments allow customization of the model, featurizers, and training parameters. ```bash python regression_train.py -c X -sc Y ``` -------------------------------- ### Required Arguments for eval.py Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/generative_models/dgmg/README.md Use these arguments to specify the dataset, generation order, and model path for evaluation. The dataset supports ChEMBL and ZINC. Model path is optional if using pre-trained models. ```bash -d DATASET, dataset to use (default: None), built-in support exists for ChEMBL, ZINC -o {random,canonical}, order to generate graphs, used for naming evaluation directory (default: None) -p MODEL_PATH, path to saved model (default: None). This is not needed if you want to use pretrained models. -pr, Whether to use a pre-trained model (default: False) ``` -------------------------------- ### FreeSolv Dataset Loading with DGL Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/README.md Loads the FreeSolv dataset for solubility prediction using DGL. ```python from dgllife.data import FreeSolv FreeSolv('../data') ``` -------------------------------- ### Fine-tuning for Downstream Tasks Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/property_prediction/pretrain_gnns/chem/README.md Use this script to fine-tune a pre-trained model for specific downstream tasks. Load the supervised pre-trained model from INPUT_MODEL_FILE and specify the target dataset. ```bash python classification.py --input_model_file INPUT_MODEL_FILE --output_model_file OUTPUT_MODEL_FILE --dataset DOWNSTREAM_DATASET ``` -------------------------------- ### Train Reaction Prediction Model Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/reaction_prediction/rexgen_direct/README.md Use this command to train a reaction prediction model on a new dataset. Specify training and validation paths. Omit '-cmp Z' to use a pre-trained reaction center prediction model. ```bash python candidate_ranking_train.py --train-path X --val-path Y -cmp Z ``` -------------------------------- ### ESOL Dataset Loading with DGL Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/README.md Loads the ESOL dataset for solubility prediction using DGL. ```python from dgllife.data import ESOL ESOL('../data') ``` -------------------------------- ### Optional Arguments for eval.py Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/generative_models/dgmg/README.md These optional arguments allow for fine-tuning the evaluation process, including setting random seeds, the number of molecules to generate, maximum generation steps, and multiprocessing configurations. ```bash -s SEED, random seed (default: 0) -ns NUM_SAMPLES, Number of molecules to generate (default: 100000) -mn MAX_NUM_STEPS, Max number of steps allowed in generated molecules to ensure termination (default: 400) -np NUM_PROCESSES, number of processes to use (default: 32) -gt GENERATION_TIME, max time (seconds) allowed for generation with multiprocess (default: 600) ``` -------------------------------- ### Alchemy Dataset Loading with DGL Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/README.md Loads the Alchemy dataset for quantum chemistry property prediction using DGL. ```python from dgllife.data import Alchemy Alchemy('../data') ``` -------------------------------- ### WLN Source: https://github.com/awslabs/dgl-lifesci/blob/master/docs/source/api/model.gnn.rst Implements the Weisfeiler-Lehman Network (WLN) model. ```APIDOC ## WLN ### Description Provides an implementation of the Weisfeiler-Lehman Network (WLN) model. ### Module dgllife.model.gnn.wln ``` -------------------------------- ### Run Link Prediction Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/link_prediction/ogbl-ppa/README.md Execute the link prediction script with default options. By default, CPU is used for computation. ```bash python full_graph_link_predictor.py ``` -------------------------------- ### Evaluate Pre-trained Model Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/reaction_prediction/rexgen_direct/README.md Evaluate the provided pre-trained candidate ranking model without needing to specify model paths. This command directly runs the evaluation using the default pre-trained model. ```bash python candidate_ranking_eval.py ``` -------------------------------- ### Load and Use Pre-trained Model for Generative Tasks Source: https://github.com/awslabs/dgl-lifesci/blob/master/docs/source/api/model.pretrain.rst Shows how to load a pre-trained DGMG model for generating SMILES strings of molecules. The model is set to evaluation mode before generation. ```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'] ``` -------------------------------- ### Run Inference with CSV/TXT Data Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/property_prediction/csv_data_configuration/README.md Execute the inference script with a specified input file containing SMILES strings. The input file can be in CSV or TXT format. Optional arguments allow customization of SMILES column, training results path, inference output path, tasks, and data loading processes. ```bash python regression_inference.py -f X ``` -------------------------------- ### Data Pre-processing with Custom Processes Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/reaction_prediction/rexgen_direct/README.md Adjust the number of processes for data pre-processing if you encounter 'BrokenPipeError'. Use the -np argument followed by the desired number of processes. ```bash python find_reaction_center_train.py -np X ``` ```bash python find_reaction_center_eval.py -np X ``` -------------------------------- ### PubChem Aromaticity Dataset Loading with DGL Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/README.md Loads the PubChem Aromaticity dataset for aromaticity prediction using DGL. ```python from dgllife.data import PubChemAromaticity PubChemAromaticity('../data') ``` -------------------------------- ### Evaluate Pre-trained Model with DGL-LifeSci Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/property_prediction/moleculenet/README.md Append the -p flag to the training commands to directly evaluate a pre-trained model without retraining. ```bash python classification.py -d DATASET -mo MODEL -f FEATURE -p ``` ```bash python regression.py -d DATASET -mo MODEL -f FEATURE -p ``` -------------------------------- ### Analysis Utils Source: https://github.com/awslabs/dgl-lifesci/blob/master/docs/source/api/utils.mols.rst Utilities for analyzing a collection of molecules. ```APIDOC ## analyze_mols ### Description Analyze a collection of molecules. ``` -------------------------------- ### Link Prediction Script Arguments Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/link_prediction/ogbl-ppa/README.md Overview of optional arguments for the link prediction script, including GPU usage, model selection, and training parameters. ```bash --use_gpu, use gpu for computation --use_sage, use GraphSAGE rather than GCN --num_layers, number of GNN layers to use as well as linear layers for final link prediction (default=3) --hidden_feats, size for hidden representations (default=256) --dropout, (default=0.0) --batch_size, batch size to use for link prediction (default=64 * 1024) --lr, learning rate (default=0.01) --epochs, number of epochs for training (default=20) --eval_steps, evaluate hits@100 every {eval_steps} epochs (default=1) --runs, number of random experiments to perform (default=1) ``` -------------------------------- ### Train Reaction Prediction Model Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/reaction_prediction/rexgen_direct/README.md Command to train a reaction prediction model using a specified training dataset path. ```bash python find_reaction_center_train.py --train-path X --val-path Y ``` -------------------------------- ### Build 3D Proximity Graph with `mol_to_nearest_neighbor_graph` Source: https://context7.com/awslabs/dgl-lifesci/llms.txt Constructs a graph where edges connect atoms within a specified Euclidean distance. Useful for physics-inspired models. Ensure 3D coordinates are pre-computed. ```python from rdkit import Chem from rdkit.Chem import AllChem from dgllife.utils import mol_to_nearest_neighbor_graph, get_mol_3d_coordinates smiles = 'CC1(C(N2C(S1)C(C2=O)NC(=O)CC3=CC=CC=C3)C(=O)O)C' # Penicillin G mol = Chem.MolFromSmiles(smiles) AllChem.EmbedMolecule(mol) AllChem.MMFFOptimizeMolecule(mol) coords = get_mol_3d_coordinates(mol) g = mol_to_nearest_neighbor_graph( mol, coords, neighbor_cutoff=1.25, # Ångström; captures only covalent-bond-length neighbors keep_dists=True, dist_field='dist', ) print(g) # DGLGraph(num_nodes=23, num_edges=6, ...) print(g.edata['dist']) # tensor([[1.2024], [1.2024], [1.2270], [1.2270], [1.2259], [1.2259]]) ``` -------------------------------- ### Evaluate Reaction Prediction Model Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/reaction_prediction/rexgen_direct/README.md Use this command to evaluate a trained reaction prediction model. Specify the model path using the --model-path argument. ```bash python find_reaction_center_eval.py --model-path X ``` -------------------------------- ### Train Reaction Center Prediction Model Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/reaction_prediction/rexgen_direct/README.md Train the reaction center prediction model using default options. Specify the path to a trained model for reaction center prediction using the -cmp argument. If -cmp is not specified, a pre-trained model will be used. ```bash python candidate_ranking_train.py -cmp X ``` -------------------------------- ### Analyze CSV Data for Molecules Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/property_prediction/csv_data_configuration/README.md Use this script to perform a quick analysis of molecules in a CSV file. Specify the CSV file path and the header for the SMILES column. Optional arguments control the number of processes and the result path. ```bash python analysis.py -c X -sc Y ``` -------------------------------- ### Train Regression Model with DGL-LifeSci Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/property_prediction/moleculenet/README.md Use this command to train a regression model on a specified dataset. Customize the dataset, model architecture, and feature representation. ```bash python regression.py -d DATASET -mo MODEL -f FEATURE ``` -------------------------------- ### PDBBind Dataset Loading with DGL Source: https://github.com/awslabs/dgl-lifesci/blob/master/examples/README.md Loads the PDBBind dataset for binding affinity prediction using DGL. ```python from dgllife.data import PDBBind PDBBind('../data') ```