From 89f5da1a9c6a9dc6d3dbc8fe8a373c95f4757a03 Mon Sep 17 00:00:00 2001 From: jackzzs Date: Fri, 24 Nov 2023 01:32:20 +0800 Subject: [PATCH] Update for super --- .../ProgressiveDocking/activation_script.sh | 2 +- Docking/ProgressiveDocking/phase_2.sh | 2 +- Docking/ProgressiveDocking/phase_3.sh | 2 +- Docking/ProgressiveDocking/phase_a.sh | 4 ++ Docking/ProgressiveDocking/sampling.py | 2 +- GUI/package-lock.json | 4 +- GUI/package.json | 5 +- GUI/server.py | 20 +++--- GUI/src/backend/auto_ssh.py | 14 +++- GUI/src/backend/backend_sanity_check.py | 3 +- README.md | 6 +- ...ckingLocal.yml => app-deepdocking-gui.yml} | 2 +- installation/install-linux.sh | 4 +- installation/install-windows.bat | 2 +- installation/install.py | 65 ++++++++++--------- preparation_scripts/compute_morgan_fp.sh | 1 - 16 files changed, 79 insertions(+), 59 deletions(-) rename installation/{DeepDockingLocal.yml => app-deepdocking-gui.yml} (85%) mode change 100644 => 100755 installation/install-linux.sh diff --git a/Docking/ProgressiveDocking/activation_script.sh b/Docking/ProgressiveDocking/activation_script.sh index 9788337..8e6c912 100644 --- a/Docking/ProgressiveDocking/activation_script.sh +++ b/Docking/ProgressiveDocking/activation_script.sh @@ -1,3 +1,3 @@ echo Activating virtual environment source ~/.bashrc -conda activate DeepDockingRemote \ No newline at end of file +conda activate app-deepdocking-gui-remote \ No newline at end of file diff --git a/Docking/ProgressiveDocking/phase_2.sh b/Docking/ProgressiveDocking/phase_2.sh index 29fb8da..a4a8025 100755 --- a/Docking/ProgressiveDocking/phase_2.sh +++ b/Docking/ProgressiveDocking/phase_2.sh @@ -32,7 +32,7 @@ python $script_path/jobid_writer.py -file_path $project_path -n_it $iteration -j # For some reason, running this with the conda environment activated causes an error. # We must deactivate it before running! source ~/.bashrc -source $local_path/deactivation_script.sh +source $script_path/deactivation_script.sh # Move into the project cd $project_path/iteration_$iteration diff --git a/Docking/ProgressiveDocking/phase_3.sh b/Docking/ProgressiveDocking/phase_3.sh index 45c7a06..b08e808 100644 --- a/Docking/ProgressiveDocking/phase_3.sh +++ b/Docking/ProgressiveDocking/phase_3.sh @@ -42,7 +42,7 @@ python jobid_writer.py -file_path $project_path -n_it $iteration -jid $SLURM_JOB cd $project_path/iteration_$iteration echo Running Phase 3 mkdir res -for i in $(ls -d chunks_smi/*); do fld=$(echo $i | rev | cut -d'/' -f 1 | rev); mkdir res/$fld; cd res/$fld; sbatch $slurm_args_g $scripts/autodock_gpu_ad.sh 64 sw $PATH_FLD ../../$i'/'$fld'_'pdbqt list.txt $num_energy_evaluations $num_runs $path_to_auto_dock_gpu $scripts; cd ../../;done +for i in $(ls -d chunks_smi/*); do fld=$(echo $i | rev | cut -d'/' -f 1 | rev); mkdir res/$fld; cd res/$fld; sbatch $slurm_args_g $scripts/autodock_gpu_ad.sh 128 sw $PATH_FLD ../../$i'/'$fld'_'pdbqt list.txt $num_energy_evaluations $num_runs $path_to_auto_dock_gpu $scripts; cd ../../;done cd $scripts python phase_changer.py -pf phase_3.sh -itr $project_path/iteration_$iteration diff --git a/Docking/ProgressiveDocking/phase_a.sh b/Docking/ProgressiveDocking/phase_a.sh index ce603fc..e04c2ba 100755 --- a/Docking/ProgressiveDocking/phase_a.sh +++ b/Docking/ProgressiveDocking/phase_a.sh @@ -46,6 +46,10 @@ echo - Chunk Size: $chunk_size echo - Percent First Mol: $percent_fist_mol echo - Percent Last Mol: $percent_last_mol +# This should activate the conda environment +source ~/.bashrc +source $local_path/activation_script.sh + # Grab everything from the logs file file_path=$(sed -n '1p' $2/$3/logs.txt) protein=$(sed -n '2p' $2/$3/logs.txt) diff --git a/Docking/ProgressiveDocking/sampling.py b/Docking/ProgressiveDocking/sampling.py index 54ef6f3..2f42fae 100755 --- a/Docking/ProgressiveDocking/sampling.py +++ b/Docking/ProgressiveDocking/sampling.py @@ -131,7 +131,7 @@ def train_valid_test(file_name): f_names = [] # Getting all the morgan_1024_predictions/smile_all_##.txt files - for f in glob.glob(data_directory+'/smile*_all_*.txt'): + for f in glob.glob(data_directory+'/*.txt'): f_names.append(f) print("num_f_names: ", len(f_names)) diff --git a/GUI/package-lock.json b/GUI/package-lock.json index 122327a..a3f9f0a 100644 --- a/GUI/package-lock.json +++ b/GUI/package-lock.json @@ -3154,7 +3154,6 @@ "dependencies": { "anymatch": "~3.1.1", "braces": "~3.0.2", - "fsevents": "~2.1.2", "glob-parent": "~5.1.0", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", @@ -8496,8 +8495,7 @@ "dependencies": { "chokidar": "^3.4.1", "graceful-fs": "^4.1.2", - "neo-async": "^2.5.0", - "watchpack-chokidar2": "^2.0.1" + "neo-async": "^2.5.0" }, "optionalDependencies": { "watchpack-chokidar2": "^2.0.1" diff --git a/GUI/package.json b/GUI/package.json index 3a5fd59..63365ea 100644 --- a/GUI/package.json +++ b/GUI/package.json @@ -38,8 +38,9 @@ "scripts": { "test": "mocha", "start-lin": "export FLASK_APP=server.py && export FLASK_ENV=local_host && flask run", - "start-win": "conda activate DeepDockingLocal && set FLASK_APP=server.py && set FLASK_ENV=local_host && flask run", - "start-dev": "conda activate DeepDockingLocal && set FLASK_APP=server.py && set FLASK_ENV=development && set FLASK_DEBUG=1 && flask run", + "start-lin-global": "export FLASK_APP=server.py && export FLASK_ENV=local_host && flask run --host=0.0.0.0", + "start-win": "conda activate app-deepdocking-gui && set FLASK_APP=server.py && set FLASK_ENV=local_host && flask run", + "start-dev": "conda activate app-deepdocking-gui && set FLASK_APP=server.py && set FLASK_ENV=development && set FLASK_DEBUG=1 && flask run", "build": "webpack --progress --config webpack.config.js", "dev-build": "webpack -d --progress --config webpack.config.js" }, diff --git a/GUI/server.py b/GUI/server.py index 91c5956..37f5991 100644 --- a/GUI/server.py +++ b/GUI/server.py @@ -29,16 +29,16 @@ MODE_SCAFFOLD = None PROJECTS_PATH = './src/backend/projects/' -# Launching the app automatically if prompted -if not app.debug: - # Ask user if they want to open the DD website automatically - prompt = "\nOpen Website On Default Browser? \nEnter y to launch or any other key to open manually: " - open_site = True if input(prompt).rstrip() == "y" else False - if open_site: - import webbrowser - webbrowser.open("http://127.0.0.1:5000/") - else: - print("Enter the provided link into your browser.") +# # Launching the app automatically if prompted +# if not app.debug: +# # Ask user if they want to open the DD website automatically +# prompt = "\nOpen Website On Default Browser? \nEnter y to launch or any other key to open manually: " +# open_site = True if input(prompt).rstrip() == "y" else False +# if open_site: +# import webbrowser +# webbrowser.open("http://127.0.0.1:5000/") +# else: +# print("Enter the provided link into your browser.") def serve_pil_image(pil_img): img_io = BytesIO() diff --git a/GUI/src/backend/auto_ssh.py b/GUI/src/backend/auto_ssh.py index 4b64b2f..e060a73 100644 --- a/GUI/src/backend/auto_ssh.py +++ b/GUI/src/backend/auto_ssh.py @@ -7,7 +7,7 @@ class SSH: """ This class will automatically ssh into the host cluster. """ - def __init__(self, host=None): + def __init__(self, host=None, port=None): if host is None: try: json_str = open('src/backend/db.json').read() # TODO: Sibling files not recognizing each other when called from another file path. @@ -16,9 +16,19 @@ def __init__(self, host=None): except FileNotFoundError as e: print(e.__traceback__, "'db.json' not found! Please run the installation first before running GUI.") raise e + + if port is None: + try: + json_str = open('src/backend/db.json').read() # TODO: Sibling files not recognizing each other when called from another file path. + db_dict = json.loads(json_str) + port = db_dict['port'] + except FileNotFoundError as e: + print(e.__traceback__, "'db.json' not found! Please run the installation first before running GUI.") + raise e # The information that will allow for ssh self.host = host + self.port = port self.user = "" self.pwrd = "" self.ssh = None @@ -40,7 +50,7 @@ def connect(self, username, password): # Connect to ssh and set out ssh object ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - ssh.connect(self.host, username=self.user, password=self.pwrd) + ssh.connect(self.host, port=self.port, username=self.user, password=self.pwrd) self.ssh = ssh def download(self, remote_path, local_path): diff --git a/GUI/src/backend/backend_sanity_check.py b/GUI/src/backend/backend_sanity_check.py index a64a336..13f564a 100644 --- a/GUI/src/backend/backend_sanity_check.py +++ b/GUI/src/backend/backend_sanity_check.py @@ -8,10 +8,11 @@ def check_backend(): json_str = open('src/backend/db.json').read() # TODO: Sibling files not recognizing each other when called from another file path. db_dict = json.loads(json_str) ip = db_dict['ip'] + port = db_dict.get['port'] user = input("cluster username: ") password = input("cluster password: ") - ssh_connection = SSH(host=ip) + ssh_connection = SSH(host=ip, port=port) ssh_connection.connect(username=user, password=password) backend = Backend(ssh=ssh_connection) return backend diff --git a/README.md b/README.md index 04e2dc8..b9b79ce 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ bash prepare_receptor.py receptor.pdb 'x_size,y_size,z_size' 'x_center,y_center, - path_adt_scripts: path to folder with AutodockTools python scripts (prepare_receptor4.py, etc etc..) ## 1. Starting up the GUI -After installation, a new Conda environment on your local device called *DeepDockingLocal* should now be available. To start up the GUI, activate the *DeepDockingLocal* environment then navigate to `Deep-Docking/GUI` and run the appropriate command to start up the server. +After installation, a new Conda environment on your local device called *app-deepdocking-gui* should now be available. To start up the GUI, activate the *app-deepdocking-gui* environment then navigate to `Deep-Docking/GUI` and run the appropriate command to start up the server. For mac and linux: ```bash @@ -84,7 +84,7 @@ npm run start-win After running the above, you should see something similar to the following: ```bash > dd_gui@2.0.0 start-win -> conda activate DeepDockingLocal && set FLASK_APP=server.py && set FLASK_ENV=local_host && flask run +> conda activate app-deepdocking-gui && set FLASK_APP=server.py && set FLASK_ENV=local_host && flask run * Serving Flask app "server.py " * Environment: local_host @@ -178,7 +178,7 @@ From the top scoring tab (figure 7) we can download a list of the top 1000 molec model_config = json.loads(model_config.decode('utf-8')) AttributeError: 'str' Object has no attribute 'decode' ``` - >This error is followed by an `IndexError` on line 264 of `get_model_image` and is most likely a dependancy issue with keras, make sure you have version 2.10.0 of `h5py` (versions 3.0+ cause issues) installed on the cluster side in the `DeepDockingRemote` conda environment. You can check the version by first activating the conda environment and then typing `pip show h5py`.
+ >This error is followed by an `IndexError` on line 264 of `get_model_image` and is most likely a dependancy issue with keras, make sure you have version 2.10.0 of `h5py` (versions 3.0+ cause issues) installed on the cluster side in the `app-deepdocking-gui-remote` conda environment. You can check the version by first activating the conda environment and then typing `pip show h5py`.
>You can install/downgrade it using pip: `pip install h5py==2.10.0` diff --git a/installation/DeepDockingLocal.yml b/installation/app-deepdocking-gui.yml similarity index 85% rename from installation/DeepDockingLocal.yml rename to installation/app-deepdocking-gui.yml index 07546d3..1a8b59e 100644 --- a/installation/DeepDockingLocal.yml +++ b/installation/app-deepdocking-gui.yml @@ -1,4 +1,4 @@ -name: DeepDockingLocal +name: app-deepdocking-gui channels: - conda-forge - bioconda diff --git a/installation/install-linux.sh b/installation/install-linux.sh old mode 100644 new mode 100755 index d194229..1caf8b1 --- a/installation/install-linux.sh +++ b/installation/install-linux.sh @@ -1,8 +1,8 @@ -#!/bin/bash +#!/bin/bash -l # Create the local env python3 install.py --phase install_local # Activate the env -conda activate DeepDockingLocal 2> conda.out +conda activate app-deepdocking-gui 2> conda.out # Install remote files and create remote env python3 install.py --phase install_remote diff --git a/installation/install-windows.bat b/installation/install-windows.bat index fb95d11..e4c5727 100644 --- a/installation/install-windows.bat +++ b/installation/install-windows.bat @@ -1,3 +1,3 @@ python install.py --phase install_local -call conda activate DeepDockingLocal > conda.out +call conda activate app-deepdocking-gui > conda.out python install.py --phase install_remote \ No newline at end of file diff --git a/installation/install.py b/installation/install.py index 129ff09..52f247c 100644 --- a/installation/install.py +++ b/installation/install.py @@ -19,11 +19,11 @@ def install_dependencies(simulate): print("Welcome to the DeepDocking Installer\n") print("Before installing Deep Docking, we require you to have the required dependencies to run the GUI.") - print("To do this, we will automatically create a new conda environment for you called DeepDockingLocal") + print("To do this, we will automatically create a new conda environment for you called app-deepdocking-gui") if input("'y' to create or enter any other key to exit ") == 'y': # TODO Check the os and change this accordingly if not simulate: - os.system("conda env create -f {}".format("DeepDockingLocal.yml")) + os.system("bash -c 'conda env create -f {}'".format("app-deepdocking-gui.yml")) else: exit() @@ -42,30 +42,34 @@ def install_deep_docking(simulate): print("To begin installing, we require you to log into your cluster") def login(): - login_info = input("Cluster username and IP (ex: johnsmith@111.209.108.241): ") + login_info = input("Cluster username and IP (ex: johnsmith@111.209.108.241:22): ").strip(" ") while '@' not in login_info: print("Please re-enter a valid login:") login_info = input("Cluster username and IP (ex: johnsmith@111.209.108.241): ").strip(" ") password = getpass("Cluster password: ") - ip = login_info.split("@")[1] + ip = login_info.split("@")[1].split(":")[0] user = login_info.split("@")[0] - ssh = InstallationAssistant(host=ip) + try: + port = int(login_info.split(":")[1]) + except IndexError: + port = 22 + ssh = InstallationAssistant(host=ip, port=port) if not simulate: try: ssh.connect(user, password) print("\nLogging you in... Welcome, {}.".format(user)) - return True, ssh, ip + return True, ssh, ip, port except ssh.connection_exception: print("Login failed... please try again") - return False, ssh, ip + return False, ssh, ip, port else: print("\nLogging you in... Welcome, {}.".format(user)) - return True, ssh, ip + return True, ssh, ip, port # Create a loop to log the user in despite making mistakes - logged_in, connection, ip = login() + logged_in, connection, ip, port = login() while not logged_in: - logged_in, connection, ip = login() + logged_in, connection, ip, port = login() print("Where would you like deep docking to be installed?") installation_path = input("Installation path: ").strip(" ") @@ -77,7 +81,7 @@ def login(): # Create the venv on the cluster and save the activation command if not simulate: connection.create_venv() - env_activation = "conda activate DeepDockingRemote" + env_activation = "conda activate app-deepdocking-gui-remote" env_deactivation = "conda deactivate" else: # If we did not create a new conda env, we will @@ -103,22 +107,23 @@ def login(): installation_information = {'remote_path': docking_path, 'local_dir': local_dir, 'ip': ip, + 'port': port, 'docking_path': docking_path, 'remote_gui_path': remote_gui_path, 'env_activation_command': env_activation, 'path_to_autodock': path_to_autodock} # This is the information the backend of the gui will use - local_activation_command = 'conda activate DeepDockingLocal' + local_activation_command = 'conda activate app-deepdocking-gui' if platform == "linux" or platform == "linux2": # linux - local_activation_command = 'conda activate DeepDockingLocal' + local_activation_command = 'conda activate app-deepdocking-gui' elif platform == "darwin": # OS X - local_activation_command = 'conda activate DeepDockingLocal' + local_activation_command = 'conda activate app-deepdocking-gui' elif platform == "win32": # Windows... - local_activation_command = 'conda activate DeepDockingLocal' + local_activation_command = 'conda activate app-deepdocking-gui' installation_information['project_path'] = docking_path.replace("/DeepDocking/", "/DeepDockingProjects/") installation_information['env_deactivation_command'] = env_deactivation @@ -157,10 +162,11 @@ def print_txt_message(text_file): class InstallationAssistant: """ This class will automatically ssh into the host cluster. """ - def __init__(self, host): + def __init__(self, host, port): # The information that will allow for ssh self.host = host + self.port = port self.user = "" self.pwrd = "" self.ssh = None @@ -185,7 +191,7 @@ def connect(self, username, password): # Connect to ssh and set out ssh object ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - ssh.connect(self.host, username=self.user, password=self.pwrd) + ssh.connect(self.host, username=self.user, password=self.pwrd, port=self.port) self.ssh = ssh def check_path(self, path): @@ -197,7 +203,7 @@ def create_venv(self): # TODO Create a bash script to install conda if the user does not have it yet # Build the commands to create the env - creation_command = "conda create -n DeepDockingRemote -y python=3.6.8" + creation_command = "conda create -n app-deepdocking-gui-remote -y python=3.6.8" specify = True if input("Specify library versions? (y/n) ") == 'y' else False install_tf = "pip install tensorflow-gpu" install_np = "pip install numpy" @@ -261,70 +267,70 @@ def write_to_out(addition): progress_bar() # install tf - out = self.command("conda activate DeepDockingRemote; " + install_tf) + out = self.command("conda activate app-deepdocking-gui-remote; " + install_tf) lines += out.readlines() write_to_out(lines) progress_bar.current += 1 progress_bar() # install pybel - # out = self.command("conda activate DeepDockingRemote; conda install -c openbabel openbabel") + # out = self.command("conda activate app-deepdocking-gui-remote; conda install -c openbabel openbabel") lines += [] write_to_out(lines) progress_bar.current += 1 progress_bar() # install numpy - out = self.command("conda activate DeepDockingRemote; " + install_np) + out = self.command("conda activate app-deepdocking-gui-remote; " + install_np) lines += out.readlines() write_to_out(lines) progress_bar.current += 1 progress_bar() # install pydot - out = self.command("conda activate DeepDockingRemote; pip install pydot") + out = self.command("conda activate app-deepdocking-gui-remote; pip install pydot") lines += out.readlines() write_to_out(lines) progress_bar.current += 1 progress_bar() # install openbabel - out = self.command("conda activate DeepDockingRemote; conda install -c conda-forge openbabel") + out = self.command("conda activate app-deepdocking-gui-remote; conda install -c conda-forge openbabel") lines += out.readlines() write_to_out(lines) progress_bar.current += 1 progress_bar() # install pandas - out = self.command("conda activate DeepDockingRemote; " + install_pd) + out = self.command("conda activate app-deepdocking-gui-remote; " + install_pd) lines += out.readlines() write_to_out(lines) progress_bar.current += 1 progress_bar() # install rdkit - out = self.command("conda activate DeepDockingRemote; conda install -c conda-forge rdkit") + out = self.command("conda activate app-deepdocking-gui-remote; conda install -c conda-forge rdkit") lines += out.readlines() write_to_out(lines) progress_bar.current += 1 progress_bar() # install sklearn - out = self.command("conda activate DeepDockingRemote; " + install_skl) + out = self.command("conda activate app-deepdocking-gui-remote; " + install_skl) lines += out.readlines() write_to_out(lines) progress_bar.current += 1 progress_bar() # install IPython - out = self.command("conda activate DeepDockingRemote; pip install IPython") + out = self.command("conda activate app-deepdocking-gui-remote; pip install IPython") lines += out.readlines() write_to_out(lines) progress_bar.current += 1 progress_bar() # install cuda tool kit - out = self.command("conda activate DeepDockingRemote; conda install -c anaconda cudatoolkit={}".format(cuda_version)) + out = self.command("conda activate app-deepdocking-gui-remote; conda install -c anaconda cudatoolkit={}".format(cuda_version)) lines += out.readlines() write_to_out(lines) progress_bar.current += 1 @@ -354,7 +360,8 @@ def install(self, local, remote, env_activation, env_deactivation): ftp_client.mkdir(remote + "/GUI") ftp_client.mkdir(remote + "/GUI/images") ftp_client.mkdir(remote + "/GUI/images/models") - except OSError: + except OSError as e: + print(e.__class__, e) print("The directory DeepDocking already exists at", remote) if input("Overwrite? If no, exit installation: y/n ").lower() in {'yes', 'y'}: # remove the dir (recursively) and make a new one diff --git a/preparation_scripts/compute_morgan_fp.sh b/preparation_scripts/compute_morgan_fp.sh index ef462f6..a4a5f8d 100644 --- a/preparation_scripts/compute_morgan_fp.sh +++ b/preparation_scripts/compute_morgan_fp.sh @@ -1,5 +1,4 @@ #!/bin/bash -#SBATCH --partition=normal #SBATCH --ntasks=1 #SBATCH --nodes=1 #SBATCH --job-name=calculate_morgan_fing