Skip to content
Open
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
31 changes: 17 additions & 14 deletions src/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ Thank you!\n";
exit(EXIT_FAILURE);
}

if (!vm.count("ligand") && !vm.count("batch")) {
std::cerr << desc_simple << "\n\nERROR: Missing ligand(s).\n";
if (!vm.count("ligand") && !vm.count("batch") && !vm.count("write_maps")) {
std::cerr << desc_simple << "\n\nERROR: Missing ligand(s) or --write_maps.\n";
exit(EXIT_FAILURE);
} else if (vm.count("ligand") && vm.count("batch")) {
std::cerr << desc_simple << "\n\nERROR: Can't use both --ligand and --batch arguments simultaneously.\n";
Expand Down Expand Up @@ -408,10 +408,6 @@ Thank you!\n";
v.set_ad4_weights(weight_ad4_vdw, weight_ad4_hb, weight_ad4_elec,
weight_ad4_dsolv, weight_glue, weight_ad4_rot);
v.load_maps(maps);

// It works, but why would you do this?!
if (vm.count("write_maps"))
v.write_maps(out_maps);
}

if (vm.count("ligand")) {
Expand All @@ -429,9 +425,6 @@ Thank you!\n";
} else {
v.compute_vina_maps(center_x, center_y, center_z, size_x, size_y, size_z, grid_spacing, force_even_voxels);
}

if (vm.count("write_maps"))
v.write_maps(out_maps);
}
}

Expand Down Expand Up @@ -460,11 +453,8 @@ Thank you!\n";
if (vm.count("maps")) {
v.load_maps(maps);
} else {
// Will compute maps for all Vina atom types
v.compute_vina_maps(center_x, center_y, center_z, size_x, size_y, size_z, grid_spacing);

if (vm.count("write_maps"))
v.write_maps(out_maps);
// Batch mode is allowed only if not ad4?
Copy link
Copy Markdown
Contributor

@rwxayheee rwxayheee Feb 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I think batch mode is allowed with ad4. It will go to the if (vm.count("maps")) { v.load_maps(maps); } condition just a little above this. You can run a test and tell us if it's broken. The only difference is: with ad4, we will provide the maps beforehand, instead of asking it to compute the maps. Since you suggested that the read maps flag should not coexist with write maps flag, there will be no usage case of write maps for ad4. See this tutorial for the expected procedure: https://autodock-vina.readthedocs.io/en/latest/docking_basic.html#a-using-autodock4-forcefield

v.compute_vina_maps(center_x, center_y, center_z, size_x, size_y, size_z, grid_spacing, force_even_voxels);
}
}

Expand Down Expand Up @@ -529,6 +519,19 @@ Thank you!\n";
std::cout << "Failed to parse " << failed_ligand_parsing << " ligands.\n";
}
}

if (vm.count("write_maps")) {
// Will compute maps only for Vina atom types in the ligand(s)
// In the case users ask for score and local only with the autobox arg, we compute the optimal box size for it/them.
if (vm.count("ligand") && autobox) {
v.set_ligand_from_file(ligand_names);
Copy link
Copy Markdown
Contributor

@rwxayheee rwxayheee Feb 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here when people have ligand and write_maps, the ligand will be set twice. To avoid this, you can keep the code structure in 4d37e15. This means: (1) we can have the previous structure if ligand ... elseif batch ... elseif write_maps (2) we can call write_maps at the end of each condition (3) for the last condition, when there's no ligand and not batch mode, we can use the simple v.compute_vina_maps(center_x, center_y, center_z, size_x, size_y, size_z, grid_spacing, force_even_voxels); to write maps. In other words, deleting https://github.com/pslacerda/AutoDock-Vina/blob/4d37e15412b7fb45c2df4bb9f74aeb067e3e1c40/src/main/main.cpp#L532-L537 from commit 4d37e15 could be an easy fix, to avoid the undefined behaviors in the invalid condition

std::vector<double> dim = v.grid_dimensions_from_ligand(buffer_size);
v.compute_vina_maps(dim[0], dim[1], dim[2], dim[3], dim[4], dim[5], grid_spacing, force_even_voxels);
} else {
v.compute_vina_maps(center_x, center_y, center_z, size_x, size_y, size_z, grid_spacing, force_even_voxels);
}
v.write_maps(out_maps);
}
}

catch(pdbqt_parse_error& e) {
Expand Down