diff --git a/.gitignore b/.gitignore index c2e59666..a2c1fc08 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/example/index.py b/unidock/example/index.py new file mode 100644 index 00000000..21988ce5 --- /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 00000000..e53d3a14 --- /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) diff --git a/unidock/src/lib/vina.cpp b/unidock/src/lib/vina.cpp index 51fb688c..6ad79e43 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 diff --git a/unidock/src/main/main.cpp b/unidock/src/main/main.cpp index 3d1a9f51..8231993d 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); + } } } }