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

Split QP step into two in sample sidechain #389

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
74 changes: 60 additions & 14 deletions src/qfit/qfit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1027,13 +1027,9 @@ def _sample_sidechain(self):

if len(self._coor_set) > 15000:
logger.warning(
f"[{self.identifier}] Too many conformers generated ({len(self._coor_set)}). "
f"Reverting to a previous iteration of degrees of freedom: item 0. "
f"n_coords: {[len(cs) for (cs) in iter_coor_set]}"
f"[{self.identifier}] Too many conformers generated ({len(self._coor_set)}). Splitting QP scoring."
)
self._coor_set = iter_coor_set[0]
self._bs = iter_b_set[0]


if not self._coor_set:
msg = (
"No conformers could be generated. Check for initial "
Expand All @@ -1048,15 +1044,65 @@ def _sample_sidechain(self):
self._write_intermediate_conformers(
prefix=f"sample_sidechain_iter{iteration}"
)

if len(self._coor_set) <= 15000:
# If <15000 conformers are generated, QP score conformer occupancy normally
self._convert()
self._solve_qp()
self._update_conformers()
if self.options.write_intermediate_conformers:
self._write_intermediate_conformers(
prefix=f"sample_sidechain_iter{iteration}_qp"
)
if len(self._coor_set) > 15000:
# If >15000 conformers are generated, split the QP conformer scoring into two
temp_coor_set = self._coor_set
temp_bs = self._bs

# Splitting the arrays into two sections
half_index = len(temp_coor_set) // 2 # Integer division for splitting
section_1_coor = temp_coor_set[:half_index]
section_1_bs = temp_bs[:half_index]
section_2_coor = temp_coor_set[half_index:]
section_2_bs = temp_bs[half_index:]

# Process the first section
self._coor_set = section_1_coor
self._bs = section_1_bs

# QP score the first section
self._convert()
self._solve_qp()
self._update_conformers()
if self.options.write_intermediate_conformers:
self._write_intermediate_conformers(
prefix=f"sample_sidechain_iter{iteration}_qp"
)

# QP score conformer occupancy
self._convert()
self._solve_qp()
self._update_conformers()
if self.options.write_intermediate_conformers:
self._write_intermediate_conformers(
prefix=f"sample_sidechain_iter{iteration}_qp"
)
# Save results from the first section
qp_temp_coor = self._coor_set
qp_temp_bs = self._bs

# Process the second section
self._coor_set = section_2_coor
self._bs = section_2_bs

# QP score the second section
self._convert()
self._solve_qp()
self._update_conformers()
if self.options.write_intermediate_conformers:
self._write_intermediate_conformers(
prefix=f"sample_sidechain_iter{iteration}_qp"
)

# Save results from the second section
qp_2_temp_coor = self._coor_set
qp_2_temp_bs = self._bs

# Concatenate the results from both sections
self._coor_set = np.concatenate((qp_temp_coor, qp_2_temp_coor), axis=0)
self._bs = np.concatenate((qp_temp_bs, qp_2_temp_bs), axis=0)

# MIQP score conformer occupancy
self.sample_b()
Expand Down