From 7ce9a8f38b42936bebbdb5e50853c092eb41ee42 Mon Sep 17 00:00:00 2001 From: ysy Date: Mon, 1 Apr 2024 23:23:12 +0800 Subject: [PATCH 1/3] feat: add safe mode option in main.cpp for large ligands --- .gitignore | 2 +- unidock/src/main/main.cpp | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index c2e5966..a2c1fc0 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,7 @@ unidock/example/screening_test/unidock unidock/example/screening_test/fail_result unidock/example/screening_test/receptor_grids unidock/example/screening_test/unidock_root -unidock/example/screening_test/test_dock +unidock/example/screening_test/astex unidock_tools/dist unidock_tools/dist/* *.egg-info diff --git a/unidock/src/main/main.cpp b/unidock/src/main/main.cpp index 3d1a9f5..8231993 100644 --- a/unidock/src/main/main.cpp +++ b/unidock/src/main/main.cpp @@ -345,7 +345,7 @@ bug reporting, license agreements, and more information. \n"; int max_step = 0; int max_gpu_memory = 0; int refine_step = 5; - + bool safe_mode = false; // autodock4.2 weights double weight_ad4_vdw = 0.1662; double weight_ad4_hb = 0.1209; @@ -412,7 +412,8 @@ bug reporting, license agreements, and more information. \n"; // >(&gpu_batch_ligand_names_sdf)->multitoken(), "gpu batch ligand (SDF)") ("scoring", value(&sf_name)->default_value(sf_name), - "scoring function (ad4, vina or vinardo)"); + "scoring function (ad4, vina or vinardo)") + ("safe_mode",bool_switch(&safe_mode)); // options_description search_area("Search area (required, except with --score_only)"); options_description search_area("Search space (required)"); search_area.add_options()( @@ -1018,6 +1019,7 @@ bug reporting, license agreements, and more information. \n"; } std::sort(ligands.begin(), ligands.end(), compareLigands); int groupSize = ligands.size() / 4; + if (safe_mode==false){ std::vector smallGroup(ligands.begin(), ligands.begin() + groupSize); std::vector mediumGroup(ligands.begin() + groupSize, ligands.begin() + 2 * groupSize); std::vector largeGroup(ligands.begin() + 2 * groupSize, ligands.begin() + 3 * groupSize); @@ -1052,7 +1054,13 @@ bug reporting, license agreements, and more information. \n"; min_rmsd,max_evals,max_step,seed, refine_step, local_only, energy_range); template_batch_docking(v,all_ligands,extraLargeGroup,"Extra Large",exhaustiveness, multi_bias,max_memory, receptor_atom_numbers, out_dir,bias_file, num_modes, - min_rmsd,max_evals,max_step,seed, refine_step, local_only, energy_range); + min_rmsd,max_evals,max_step,seed, refine_step, local_only, energy_range);} + else{ + std::vector extraLargeGroup(ligands.begin(), ligands.end()); + template_batch_docking(v,all_ligands,extraLargeGroup,"Extra Large in safe mode",exhaustiveness, multi_bias,max_memory, + receptor_atom_numbers, out_dir,bias_file, num_modes, + min_rmsd,max_evals,max_step,seed, refine_step, local_only, energy_range); + } } } } From a617d62e8600424807267031dbe6a48056df27f5 Mon Sep 17 00:00:00 2001 From: ysy Date: Wed, 3 Apr 2024 23:44:44 +0800 Subject: [PATCH 2/3] feat: refactor get_sdf_poses_gpu function, support all poses output --- unidock/src/lib/vina.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/unidock/src/lib/vina.cpp b/unidock/src/lib/vina.cpp index 51fb688..6ad79e4 100644 --- a/unidock/src/lib/vina.cpp +++ b/unidock/src/lib/vina.cpp @@ -949,8 +949,10 @@ std::string Vina::get_sdf_poses_gpu(int ligand_id, int how_many, double energy_r - If there is no conf to write - The energy of the current conf is superior than best_energy + energy_range */ - if (n >= how_many || !not_max(m_poses_gpu[ligand_id][i].e) - || m_poses_gpu[ligand_id][i].e > best_energy + energy_range) + // std::cout<= how_many || !not_max(m_poses_gpu[ligand_id][i].e) + // || m_poses_gpu[ligand_id][i].e > best_energy + energy_range) + if (n >= how_many) break; // check energy_range sanity FIXME // Push the current pose to model From a8487bc4e04e6d4778708ba68a0836a4f7232e50 Mon Sep 17 00:00:00 2001 From: Shaoyi Yang Date: Mon, 15 Apr 2024 17:41:05 +0800 Subject: [PATCH 3/3] feat: add pose analysis file --- unidock/example/index.py | 23 ++++++++ .../example/screening_test/run_analysis.py | 55 +++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 unidock/example/index.py create mode 100644 unidock/example/screening_test/run_analysis.py diff --git a/unidock/example/index.py b/unidock/example/index.py new file mode 100644 index 0000000..21988ce --- /dev/null +++ b/unidock/example/index.py @@ -0,0 +1,23 @@ +import glob +import os +from pathlib import Path +def find_sdf_files_recursively(folder_path): + # 将字符串路径转换为Path对象 + folder_path = Path(folder_path) + + # 使用rglob查找所有以.sdf结尾的文件 + sdf_files = list(folder_path.rglob('*.sdf')) + + # 将Path对象列表转换为字符串路径列表 + sdf_files_str = [str(file) for file in sdf_files] + + return sdf_files_str + +# 假设我们要搜索的文件夹路径为'/path/to/your/folder' +folder_path = '/home/yxyy/Documents/code/Uni-Dock/unidock/example/screening_test/astex' + +# 调用函数并打印结果 +sdf_files = find_sdf_files_recursively(folder_path) +print(sdf_files) +for sdf in sdf_files: + print(sdf) diff --git a/unidock/example/screening_test/run_analysis.py b/unidock/example/screening_test/run_analysis.py new file mode 100644 index 0000000..e53d3a1 --- /dev/null +++ b/unidock/example/screening_test/run_analysis.py @@ -0,0 +1,55 @@ +import csv +import subprocess +import glob +import os +from pathlib import Path +def find_sdf_files_recursively(folder_path): + # 将字符串路径转换为Path对象 + folder_path = Path(folder_path) + + # 使用rglob查找所有以.sdf结尾的文件 + sdf_files = list(folder_path.rglob('*.sdf')) + + # 将Path对象列表转换为字符串路径列表 + sdf_files_str = [str(file) for file in sdf_files] + + return sdf_files_str + +# 假设我们要搜索的文件夹路径为'/path/to/your/folder' +folder_path = '/home/yxyy/Documents/code/Uni-Dock/unidock/example/screening_test/astex' + +# 调用函数并打印结果 +sdf_files = find_sdf_files_recursively(folder_path) +sdf_files.sort() +for sdf in sdf_files: + print(sdf) +def build_commands_from_csv(csv_file): + commands = [] + with open(csv_file, newline='') as csvfile: + reader = csv.DictReader(csvfile) + i=0 + file_path = "/home/yxyy/Documents/code/Uni-Dock/unidock/example/screening_test/def_ligands.txt" + + for row in reader: + with open(file_path, "w") as file: + file.write(sdf_files[i]) + pdb_id = row['PDB_ID'] + x = row['X'] + y = row['Y'] + z = row['Z'] + command = f"../../build/unidock --receptor ./receptor_grids/{pdb_id}/unidock/receptor_grids/protein_conf_0/protein.pdbqt --ligand_index def_ligands.txt --center_x {x} --center_y {y} --center_z {z} --size_x 27 --size_y 27 --size_z 27 --dir ./result/def --exhaustiveness 1024 --max_step 1 --num_modes 1024 --scoring vina --refine_step 5 --seed 5 --verbosity 1" + commands.append(command) + try: + # 使用shell=True来执行字符串形式的命令 + subprocess.run(command, shell=True, check=True) + print(f"命令执行成功: {command}") + except subprocess.CalledProcessError as e: + print(f"命令执行失败: {command}\n错误信息: {e}") + i+=1 + return commands + +# 调用函数并打印结果 +csv_file = '/home/yxyy/Documents/code/Uni-Dock/unidock/example/screening_test/astex/pdb_center.csv' +commands = build_commands_from_csv(csv_file) +# for command in commands: +# print(command)