Hgraph2graph Job Scripts

From UFRC
Jump to navigation Jump to search

Return to the main Hgraph2graph page

Example of script used to test the application installation

#!/bin/bash
#SBATCH --job-name=hgraph2graph_20210428_test
#SBATCH --mail-type=NONE
#SBATCH --partition=gpu
#SBATCH --gres=gpu:a100:1
#SBATCH --cpus-per-task=32
#SBATCH --mem-per-cpu=4gb
#SBATCH --time=24:00:00
#SBATCH --output=hgraph2graph_20210428_test.log

echo "Setting up test environment..."
TEST_PWD=/data/apps/tests/hgraph2graph/20210428
TEST_DATADIR=${TEST_PWD}/example_data
TEST_WORKDIR=${TEST_PWD}/test_output

module purge
module load hgraph2graph/20210428

# Remove any previous test results and re-create a working directory
if [ -d ${TEST_WORKDIR} ]; then rm -rf ${TEST_WORKDIR}/; fi
mkdir ${TEST_WORKDIR}
mkdir ${TEST_WORKDIR}/train_processed

echo "Starting test run at $(date) on $(hostname)..."
###################################

echo "Extract substructure vocabulary from a given set of molecules..."
python ${HPC_HGRAPH2GRAPH_DIR}/get_vocab.py \
    --ncpu ${SLURM_CPUS_ON_NODE:-4} \
    < ${TEST_DATADIR}/sample.txt \
    > ${TEST_WORKDIR}/vocab.txt

# echo "Preprocess training data..."
python ${HPC_HGRAPH2GRAPH_DIR}/preprocess.py \
    --train ${TEST_DATADIR}/sample.txt \
    --vocab ${TEST_WORKDIR}/vocab.txt \
    --ncpu ${SLURM_CPUS_ON_NODE:-4} \
    --mode single
mv tensor* ${TEST_WORKDIR}/train_processed/

echo "Train graph generation model..."
mkdir -p ${TEST_WORKDIR}/ckpt/chembl-pretrained
python ${HPC_HGRAPH2GRAPH_DIR}/train_generator.py \
    --train ${TEST_WORKDIR}/train_processed/ \
    --vocab ${TEST_WORKDIR}/vocab.txt \
    --save_dir ${TEST_WORKDIR}/ckpt/chembl-pretrained

echo "Sample molecules from a model checkpoint..."
python ${HPC_HGRAPH2GRAPH_DIR}/generate.py \
    --vocab  ${TEST_WORKDIR}/vocab.txt \
    --model ${TEST_WORKDIR}/ckpt/chembl-pretrained/model.ckpt.5000 \
    --nsample 1000

###################################

# There should be some files in the work directory
echo "There should be some results listed below:"
find ${TEST_WORKDIR} -type f ! -empty -ls

echo "Test complete at $(date)."