Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/analyse pose #113

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 23 additions & 0 deletions unidock/example/index.py
Original file line number Diff line number Diff line change
@@ -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)
55 changes: 55 additions & 0 deletions unidock/example/screening_test/run_analysis.py
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 4 additions & 2 deletions unidock/src/lib/vina.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<<i<<std::endl;
// if (n >= 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
Expand Down
14 changes: 11 additions & 3 deletions unidock/src/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -412,7 +412,8 @@ bug reporting, license agreements, and more information. \n";
// >(&gpu_batch_ligand_names_sdf)->multitoken(), "gpu batch ligand (SDF)")

("scoring", value<std::string>(&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()(
Expand Down Expand Up @@ -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<Ligand> smallGroup(ligands.begin(), ligands.begin() + groupSize);
std::vector<Ligand> mediumGroup(ligands.begin() + groupSize, ligands.begin() + 2 * groupSize);
std::vector<Ligand> largeGroup(ligands.begin() + 2 * groupSize, ligands.begin() + 3 * groupSize);
Expand Down Expand Up @@ -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<ExtraLargeConfig>(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<Ligand> extraLargeGroup(ligands.begin(), ligands.end());
template_batch_docking<ExtraLargeConfig>(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);
}
}
}
}
Expand Down