Skip to content

Commit

Permalink
Bugfix where k-off convergence plots were not being generated. Also a…
Browse files Browse the repository at this point in the history
…dded check that Amber parameters files have the correct extensions so that mdtraj can read them.
  • Loading branch information
lvotapka committed Aug 12, 2023
1 parent 76e920d commit f0680c0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion seekr2/converge.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def converge(model, k_on_state=None, image_directory=None, verbose=False,

if image_directory is None or image_directory == "" or not long_converge:
return data_sample_list, times_dict

k_off_fig, ax = common_converge.plot_scalar_conv(
k_off_conv, max_step_list, title="$k_{off}$ Convergence",
label="k_{off} (s^{-1})", timestep_in_ns=timestep_in_ns)
Expand Down
20 changes: 15 additions & 5 deletions seekr2/modules/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,13 @@ def load_structure_with_mdtraj(model, anchor, mode="pdb", coords_filename=None):
return traj

elif anchor.amber_params is not None:

if anchor.amber_params.prmtop_filename is not None:
if (anchor.amber_params.prmtop_filename is None) \
or (anchor.amber_params.prmtop_filename == ""):
return None
else:
prmtop_filename = os.path.join(
building_directory, anchor.amber_params.prmtop_filename)
else:
return None

if mode == "pdb":
if anchor.amber_params.pdb_coordinates_filename is not None \
and anchor.amber_params.pdb_coordinates_filename != "":
Expand All @@ -249,7 +250,16 @@ def load_structure_with_mdtraj(model, anchor, mode="pdb", coords_filename=None):
else:
# anchor has no structure files: at least test that mdtraj
# can load the parm file
dummy = mdtraj.load(prmtop_filename)
if anchor.amber_params.prmtop_filename is None:
return None
my_splitext = os.path.splitext(prmtop_filename)
assert len(my_splitext) == 2, \
"File must have '.parm7' or '.prmtop extension: " \
+f"{prmtop_filename}"
extension = my_splitext[1]
assert extension in [".parm7", ".prmtop"], \
"File must have '.parm7' or '.prmtop' extension: " \
+f"{prmtop_filename}"
return None

elif mode == "elber_umbrella":
Expand Down
2 changes: 1 addition & 1 deletion seekr2/modules/common_converge.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def plot_scalar_conv(conv_values, conv_intervals, label, title, timestep_in_ns,
ax : object
matplotlib Axes object
"""
if not np.all(np.isfinite(conv_values)) or np.all(conv_values == 0):
if not np.any(np.isfinite(conv_values)) or np.all(conv_values == 0):
return None, None
fig, ax = plt.subplots()
ax.plot(np.multiply(conv_intervals, timestep_in_ns), conv_values,
Expand Down
2 changes: 1 addition & 1 deletion seekr2/modules/elber_analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def monte_carlo_milestoning_error(
if verbose: print("collecting ", num, " MCMC samples from ",
num*(stride) + skip, " total moves")
new_data_sample = None
for counter in range(num * (stride) + skip):
for counter in range(num * (stride) + skip + 1):
#if verbose: print("MCMC stepnum: ", counter)
Qnew = markov_chain_monte_carlo\
.irreversible_stochastic_matrix_algorithm_sample(Q, N, R)
Expand Down
2 changes: 1 addition & 1 deletion seekr2/modules/mmvt_analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ def monte_carlo_milestoning_error(
mmvt_Qij_alpha[alpha])
nonzero_indices_Q_alpha_list.append(nonzero_indices_Q_alpha)

for counter in range(num * (stride) + skip):
for counter in range(num * (stride) + skip + 1):
new_data_sample = MMVT_data_sample(model)
new_data_sample.N_alpha_beta = main_data_sample.N_alpha_beta
new_data_sample.N_i_j_alpha = main_data_sample.N_i_j_alpha
Expand Down

0 comments on commit f0680c0

Please sign in to comment.