Commit 66923e01 authored by hgarrereyn's avatar hgarrereyn
Browse files

update links

parent fc6d92eb
......@@ -3,6 +3,5 @@ This folder contains data used during training and inference.
You can download the data here: https://pitt.box.com/s/ubohnl10idnarpam40hq6chggtaojqv7
Overview:
- `fragments_desc.h5` (3.9 GB): pdbbind fragment information created by `scripts/process_pdbbind2.py`
- `fragments_mini.h5` (824 KB): a minimal version of `fragments_desc.h5` with 3 receptors and 50 fragments for testing
- `fp_rdk_desc.h5` (625 MB): precomputed rdk fingerprints created by `scripts/make_fingerprints.py`
- `moad.h5` (7 GB): processed MOAD data loaded by `data_util.FragmentDataset`
- `rdk10_moad` (384 MB): RDK-10 fingerprints for MOAD data loaded by `data_util.FingerprintDataset` (generated with `scripts/make_fingerprints.py`)
import argparse
import sys
import os
import subprocess
import tempfile
RUN_DIR = '/zfs1/jdurrant/durrantlab/hag63/leadopt_pytorch'
def main():
parser = argparse.ArgumentParser()
parser.add_argument('-t','--time',default='10:00:00')
parser.add_argument('-p','--partition',default='gtx1080')
parser.add_argument('-m','--mem',default='16g')
parser.add_argument('path')
parser.add_argument('script')
args = parser.parse_args()
run_path = os.path.join(RUN_DIR, args.path)
if os.path.exists(run_path):
print('[!] Run exists at %s' % run_path)
overwrite = input('- Overwrite? [Y/n]: ')
if overwrite.lower() == 'n':
print('Exiting...')
exit(0)
else:
print('[*] Creating run directory %s' % run_path)
os.mkdir(run_path)
script = '''#!/bin/bash
#SBATCH --job-name={name}
#SBATCH --output={run_path}/slurm_out.txt
#SBATCH --error={run_path}/slurm_err.txt
#SBATCH --time={time}
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cluster=gpu
#SBATCH --partition={partition}
#SBATCH --mail-user=hag63@pitt.edu
#SBATCH --mail-type=END,FAIL
#SBATCH --gres=gpu:1
#SBATCH --mem={mem}
cd /ihome/jdurrant/hag63/cbio/leadopt_pytorch/
./setup.sh
export PYTHONPATH=/ihome/jdurrant/hag63/cbio/leadopt_pytorch/
# export WANDB_DIR=/ihome/jdurrant/hag63/wandb_abs
export WANDB_DISABLE_CODE=true
cd {run_path}
python /ihome/jdurrant/hag63/cbio/leadopt_pytorch/{script}
'''.format(
name='leadopt_%s' % args.path,
run_path=run_path,
time=args.time,
partition=args.partition,
mem=args.mem,
script=args.script
)
print('[*] Running script...')
with tempfile.NamedTemporaryFile('w') as f:
f.write(script)
f.flush()
r = subprocess.run('sbatch %s' % f.name, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
print(r)
if __name__=='__main__':
main()
#!/bin/bash
DEFAULT_RUN_PATH=/zfs1/jdurrant/durrantlab/hag63/leadopt_pytorch/
if [[ $# -ne 4 ]]; then
echo "Usage: $0 <run_name> <gpu_partition> <**args>"
exit 0
fi
ABS_SCRIPT=$(pwd)/train.py
# navigate to runs directory
RUNS_DIR="${RUNS_DIR:-$DEFAULT_RUN_PATH}"
cd $RUNS_DIR
if [[ -d $1 ]]; then
echo "Warning: run directory $1 already exists!"
exit -1
fi
echo "Creating run directory ($1)..."
mkdir $1
echo "Running script..."
sbatch <<EOT
#!/bin/bash
#SBATCH --job-name=$1
#SBATCH --output=$RUNS_DIR/$1/slurm_out.txt
#SBATCH --error=$RUNS_DIR/$1/slurm_err.txt
#SBATCH --time=10:00:00
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cluster=gpu
#SBATCH --partition=$2
#SBATCH --mail-user=hag63@pitt.edu
#SBATCH --mail-type=END,FAIL
#SBATCH --gres=gpu:1
#SBATCH --mem=80g
cd /ihome/jdurrant/hag63/cbio/leadopt_pytorch/
source ./setup.sh
PYTHON_PATH=$PYTHON_PATH:/ihome/jdurrant/hag63/cbio/leadopt_pytorch/
cd $RUNS_DIR/$1
python train.py $4
EOT
......@@ -131,7 +131,7 @@ def top_k_acc(fingerprints, fn, k, pre=''):
fingerprints: NxF tensor of fingerprints
fn: distance function to compare fingerprints
k: List[int] containing K-positions to evaluate (e.g. [1,5,10])
pre: optional postfix on the metric name
pre: optional prefix on the metric name
"""
def _top_k_acc(yp, yt):
......
......@@ -563,6 +563,11 @@ class VoxelNet(LeadoptModel):
print('done.')
def predict(self, batch):
with torch.no_grad():
pred = self._models['voxel'](batch)
return pred
MODELS = {
'voxelnet': VoxelNet
......
'''
rdkit/openbabel utility scripts
'''
from rdkit import Chem
import numpy as np
try:
import pybel
except:
from openbabel import pybel
from rdkit import Chem
def get_coords(mol):
"""Returns an array of atom coordinates from an rdkit mol."""
......@@ -279,55 +282,3 @@ def merge_smiles(sma, smb):
return sm
REPLACE = [
('N=[C+](=N)=N', 'N=C(N)N'),
('[C-](=O)=O', 'C(=O)O'),
# ('[NH2]', 'N'),
('[C+](=N)=N', 'C(=N)N'),
# ('[c+](=N)', 'c(=N)'),
('S(=O)(=O)=O', 'S(=O)(=O)O'),
('C#O', 'C=O'),
]
def fix_smiles(sm):
m = Chem.MolFromSmiles(sm, sanitize=False)
for a,b in REPLACE:
m = Chem.ReplaceSubstructs(
m,
Chem.MolFromSmiles(a, sanitize=False),
Chem.MolFromSmiles(b, sanitize=False),
replaceAll=True
)[0]
m.UpdatePropertyCache(strict=False)
for atom in m.GetAtoms():
# handle tetravalent nitrogen
if atom.GetAtomicNum() == 7 and atom.GetExplicitValence() == 4:
atom.SetFormalCharge(1)
if atom.GetAtomicNum() == 6 and atom.GetFormalCharge() == 1:
atom.SetFormalCharge(0)
if atom.GetAtomicNum() == 6 and atom.GetFormalCharge() == -1:
atom.SetFormalCharge(0)
if atom.GetAtomicNum() == 7 and atom.GetExplicitValence() == 5:
atom.SetNumExplicitHs(0)
if atom.GetAtomicNum() == 7 and atom.GetExplicitValence() == 6:
atom.SetNumExplicitHs(0)
atom.SetFormalCharge(1)
if atom.GetAtomicNum() == 7 and atom.GetExplicitValence() == 3 and atom.GetNumExplicitHs() == 0 and atom.GetIsAromatic() == True:
atom.SetFormalCharge(1)
h = m
try:
Chem.SanitizeMol(m)
except:
return None
return Chem.MolToSmiles(m)
Supports Markdown
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