Skip to content

Commit

Permalink
Staging (#42)
Browse files Browse the repository at this point in the history
Co-authored-by: The Technocrat <[email protected]>
  • Loading branch information
NiklasTR and thetechnocrat-dev authored Jan 30, 2023
1 parent d95ccda commit 686a393
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
data

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
48 changes: 47 additions & 1 deletion client.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,52 @@ def generate_diffdock_instructions(
}
return json.dumps(instructions)

#TODO: #26 introduce guidance on volume mounting, especially mounting multiple volumes
def generate_vina_instructions(
debug_logs=True,
protein="1a30/1a30_protein.pdb",
ligand="1a30/1a30_ligand.sdf",
output="1a30/1a30_scored_vina.sdf.gz",
cnn_scoring="none",
modifier="score_only",
) -> dict:
instructions = {
"container_id": "gnina/gnina:latest",
"debug_logs": debug_logs,
"short_args": {"v": "/home/ubuntu/casf-2016:/inputs"},
"long_args": {"gpus": 0},
"cmd": (
"gnina -r"
f" /inputs/{protein} -l /inputs/{ligand} -o"
f" /inputs/{output}"
f" --autobox_ligand /inputs/{protein} --cnn_scoring {cnn_scoring} --exhaustiveness 64"
f" --{modifier}"
),
}
return json.dumps(instructions)

def generate_gnina_instructions(
debug_logs=True,
protein="1a30/1a30_protein.pdb",
ligand="1a30/1a30_ligand.sdf",
output="1a30/1a30_scored_gnina.sdf.gz",
cnn_scoring="rescore",
modifier="score_only",
) -> dict:
instructions = {
"container_id": "gnina/gnina:latest",
"debug_logs": debug_logs,
"short_args": {"v": "/home/ubuntu/casf-2016:/inputs"},
"long_args": {"gpus": 0},
"cmd": (
"gnina -r"
f" /inputs/{protein} -l /inputs/{ligand} -o"
f" /inputs/{output}"
f" --autobox_ligand /inputs/{protein} --cnn_scoring {cnn_scoring} --exhaustiveness 64"
f" --{modifier}"
),
}
return json.dumps(instructions)

if __name__ == "__main__":
print(generate_diffdock_instructions())
print(generate_vina_instructions())
39 changes: 39 additions & 0 deletions demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import client
import process
import os
import json

if __name__ == "__main__":
casf_list = os.listdir("/home/ubuntu/casf-2016")
# print("generating docking instructions")
# docking_instruct = client.generate_diffdock_instructions()
# print("running docking")
# process.main(docking_instruct)
instruction_list = []
print("generating scoring instructions for vina")
for i in casf_list:
protein = i + '/' + i + '_protein.pdb'
ligand = i + '/' + i + '_ligand.sdf'
output = i + '/' + i + '_scored_vina.sdf.gz'
instruction = client.generate_vina_instructions(
protein=protein,
ligand=ligand,
output=output
)
print(instruction)
instruction_list.append(instruction)
print("generating scoring instructions for gnina")
for i in casf_list:
protein = i + '/' + i + '_protein.pdb'
ligand = i + '/' + i + '_ligand.sdf'
output = i + '/' + i + '_scored_gnina.sdf.gz'
instruction = client.generate_gnina_instructions(
protein=protein,
ligand=ligand,
output=output
)
print(instruction)
instruction_list.append(instruction)
print("running scoring")
for instruction in instruction_list:
process.main(json.loads(instruction))
16 changes: 14 additions & 2 deletions demo.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
# run from basedir
# pull container images for basic CASF 2016 evaluation
docker pull ghcr.io/labdao/diffdock:main
docker pull gnina/gnina
docker pull ghcr.io/labdao/casf-2016-eval:main

# pull data for basic CASF 2016 evaluation
mkdir data
cd data
ipfs get bafybeiaqyjf65cs2slhilsrqvo3mo6ckdqnr5spplcts7svq7256hiiguy -o /home/ubuntu/casf-2016
cd ..
# avoided by adding some examples into git
# aws s3 sync s3://labdao-benchmark/CASF-2016/coreset/1a30/ data


## interactive for debug
# docker run -it -v /home/ubuntu/casf-2016-evaluator/data/coreset:/inputs -v /home/ubuntu/outputs:/outputs gnina/gnina bash
# NOTRUN dock gnina
Expand All @@ -14,7 +24,7 @@ docker pull ghcr.io/labdao/casf-2016-eval:main

# run scoring
docker run \
-v /home/ubuntu/casf-2016-evaluator/data/coreset:/inputs \
-v /home/ubuntu/data/bafybeiaqyjf65cs2slhilsrqvo3mo6ckdqnr5spplcts7svq7256hiiguy:/inputs \
-v /home/ubuntu/outputs:/outputs \
gnina/gnina \
gnina --autobox_ligand /inputs/1a30/1a30_protein.pdb \
Expand All @@ -23,4 +33,6 @@ docker run \
--score_only \
-r /inputs/1a30/1a30_protein.pdb \
-l /inputs/1a30/1a30_ligand.sdf \
-o /outputs/scored_vina.sdf.gz
-o 1a30_scored_vina.sdf.gz && \
mkdir -p /outputs/1a30 && \
mv 1a30_scored_vina.sdf.gz /outputs/1a30/
4 changes: 4 additions & 0 deletions install.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
set -E
trap '[ "$?" -ne 77 ] || exit 77' ERR

# https://unix.stackexchange.com/questions/48533/exit-shell-script-from-a-subshell
set -E
trap '[ "$?" -ne 77 ] || exit 77' ERR

# Docker install directions from https://docs.docker.com/engine/install/ubuntu/
echo "Installing Docker"
sudo apt-get update
Expand Down
18 changes: 18 additions & 0 deletions ipfs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#TODO #20
wget https://dist.ipfs.tech/kubo/v0.18.0/kubo_v0.18.0_linux-amd64.tar.gz
tar -xvzf kubo_v0.18.0_linux-amd64.tar.gz
cd kubo
sudo bash install.sh
ipfs --version

# post installation
ipfs init
ipfs cat /ipfs/QmQPeNsJPyVWPFDVHb77w8G42Fvo15z4bG2X8D2GhfbSXc/readme


# port forwarding
# 127.0.0.1:5001/webui
# name files with ipfs get QmWLy5XUKuSVJiYirLfw3xSxD42BDPZEVvCv7f2mGanUiD -o test.png

# NOTRUN screen -ls
screen -dm ipfs daemon -D
1 change: 1 addition & 0 deletions process.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def __init__(self, msg: str) -> None:


def validate_instructions(instructions: dict) -> None:
#TODO: #38 validate instructions if it is a dict
for key in REQUIRED_INSTRUCTION_FIELDS:
if key not in instructions:
raise InputError(f"Missing required input field {key}")
Expand Down

0 comments on commit 686a393

Please sign in to comment.