Skip to content

Commit 2a96540

Browse files
authored
Merge pull request #79 from davidkastner/scripts
Update scripts
2 parents fb17df6 + 9c9ae0d commit 2a96540

File tree

6 files changed

+240
-198
lines changed

6 files changed

+240
-198
lines changed

pyqmmm/cli.py

Lines changed: 7 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def io(
132132
@click.option("--compare_distances", "-cd", is_flag=True, help="Plots distance metrics together.")
133133
@click.option("--plot_rmsd", "-rmsd", is_flag=True, help="Plots the RMSD from CPPTraj.")
134134
@click.option("--cluster_frames", "-cf", is_flag=True, help="Gets frames for largest CPPTraj cluster.")
135-
@click.help_option('--help', '-h', is_flag=True, help='Exiting pyQMMM.')
135+
@click.help_option('--help', '-h', is_flag=True, help='Exiting pyqmmm.')
136136
def md(
137137
gbsa_submit,
138138
gbsa_analysis,
@@ -215,7 +215,10 @@ def md(
215215
import pyqmmm.md.rmsd_clusters_colorcoder
216216
yaxis_title = "RMSD (Å)"
217217
cluster_count = int(input("How many cluster would you like plotted? "))
218-
pyqmmm.md.rmsd_clusters_colorcoder.rmsd_clusters_colorcoder(yaxis_title, cluster_count, layout='wide')
218+
layout = input("Enter layout (e.g., 'square', '5,4', or press enter for default): ").strip() or "wide"
219+
legend_input = input("Show legend? (y/n): ").strip().lower()
220+
show_legend = legend_input != 'n'
221+
pyqmmm.md.rmsd_clusters_colorcoder.rmsd_clusters_colorcoder(yaxis_title, cluster_count, layout, show_legend)
219222

220223
elif restraint_plot:
221224
click.echo("Generate single KDE plot with hyscore measurements:")
@@ -239,70 +242,8 @@ def md(
239242
pyqmmm.md.dssp_plotter.combine_dssp_files()
240243

241244
elif rmsf:
242-
click.echo("Calculates the RMSF:")
243-
click.echo("Loading...")
244245
import pyqmmm.md.rmsf_calculator
245-
protein = input("What is the name of your protein? ")
246-
topology = f"1/{protein}_dry.prmtop"
247-
reference_file = f"1/{protein}_dry.pdb"
248-
# trajectories = ["1/1_output/constP_prod.crd",
249-
# "7u/1_output/constP_prod.crd",
250-
# "2/1_output/constP_prod.crd",
251-
# "3/1_output/constP_prod.crd",
252-
# "7/1_output/constP_prod.crd",
253-
# "8u/1_output/constP_prod.crd",
254-
# "13/1_output/constP_prod.crd",
255-
# "15/1_output/constP_prod.crd",
256-
# ]
257-
# trajectories = ["1/1_output/constP_prod.crd",
258-
# "2/1_output/constP_prod.crd",
259-
# "3/1_output/constP_prod.crd",
260-
# "4/1_output/constP_prod.crd",
261-
# "5/1_output/constP_prod.crd",
262-
# "6/1_output/constP_prod.crd",
263-
# "7/1_output/constP_prod.crd",
264-
# "2n/1_output/constP_prod.crd",
265-
# ]
266-
trajectories = ["1/1_output/constP_prod.crd",
267-
"2/1_output/constP_prod.crd",
268-
"3/1_output/constP_prod.crd",
269-
"4/1_output/constP_prod.crd",
270-
"5/1_output/constP_prod.crd",
271-
"6/1_output/constP_prod.crd",
272-
"7/1_output/constP_prod.crd",
273-
"4n/1_output/constP_prod.crd",
274-
]
275-
# trajectories = ["2u/1_output/constP_prod.crd",
276-
# "3u/1_output/constP_prod.crd",
277-
# "4u/1_output/constP_prod.crd",
278-
# "5u/1_output/constP_prod.crd",
279-
# "6u/1_output/constP_prod.crd",
280-
# "7u/1_output/constP_prod.crd",
281-
# "9u/1_output/constP_prod.crd",
282-
# "10u/1_output/constP_prod.crd",
283-
# "11u/1_output/constP_prod.crd",
284-
# "12u/1_output/constP_prod.crd",
285-
# "13u/1_output/constP_prod.crd",
286-
# "14u/1_output/constP_prod.crd",
287-
# "15u/1_output/constP_prod.crd",
288-
# "16u/1_output/constP_prod.crd",
289-
# ]
290-
# topology = f"2u/{protein}_dry.prmtop"
291-
# reference_file = f"2u/{protein}_dry.pdb"
292-
# trajectories = ["2u/1_output/constP_prod.crd",
293-
# "3u_same-as-folded-16/1_output/constP_prod.crd",
294-
# "4u/1_output/constP_prod.crd",
295-
# "5u/1_output/constP_prod.crd",
296-
# "6u/1_output/constP_prod.crd",
297-
# "7u_same-as-folded-17/1_output/constP_prod.crd",
298-
# "9u_same-as-folded-18/1_output/constP_prod.crd",
299-
# "10u/1_output/constP_prod.crd",
300-
# "11u_same-as-folded-19/1_output/constP_prod.crd",
301-
# "12u/1_output/constP_prod.crd",
302-
# "13u/1_output/constP_prod.crd",
303-
# "14u/1_output/constP_prod.crd",
304-
# ]
305-
pyqmmm.md.rmsf_calculator.main(topology, trajectories, reference_file)
246+
pyqmmm.md.rmsf_calculator.main()
306247

307248
elif plot_rmsf:
308249
import pyqmmm.md.rmsf_plotter
@@ -345,7 +286,7 @@ def md(
345286
@click.option("--plot_combine_nebs", "-pcneb", is_flag=True, help="Combines and plots NEBs as a single trajectory.")
346287
@click.option("--extract_energies", "-ee", is_flag=True, help="Extract electronic energies")
347288
@click.option("--extract_gibbs", "-eg", is_flag=True, help="Extract Gibbs free energies")
348-
@click.help_option('--help', '-h', is_flag=True, help='Exiting pyQMMM.')
289+
@click.help_option('--help', '-h', is_flag=True, help='Exiting pyqmmm.')
349290
def qm(
350291
plot_energy,
351292
flip_xyz,

pyqmmm/md/hbond_analyzer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def compute_hbonds(cpptraj_script, submit_script, script_name):
2929
3030
See Also
3131
--------
32-
pyqmmm.md.hbonding_analyzer.analyze_hbonds()
32+
caddkit.md.hbonding_analyzer.analyze_hbonds()
3333
3434
"""
3535
# Check if hbond.gnu exists in the current directory

pyqmmm/md/restraint_plotter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def restraint_plots():
334334
print("This the goal of RESTRAINT PLOTS is to:")
335335
print("+ Vizualize a simulation against two order parameters.")
336336
print("+ Compare the results to the experimentally expected values.")
337-
print("+ An example config file can be found in pyQMMM/tutorials/restraint_plotter.\n")
337+
print("+ An example config file can be found in CADDKit/tutorials/restraint_plotter.\n")
338338

339339
# Uncomment the following line if you want to ask the user for input.
340340
# show_crosshairs = input('Would you like crosshairs (y/n)? ') == 'y'

pyqmmm/md/rmsd_clusters_colorcoder.py

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,25 @@ def dat2df(dat_file, rows_to_skip=1):
99
df = df.iloc[1:, :]
1010
return df
1111

12-
def get_plot(final_df, centroid_time_ns, yaxis_title, cluster_count, layout='wide'):
12+
def get_plot(final_df, centroid_time_ns, yaxis_title, cluster_count, layout='wide', show_legend=True):
13+
# Determine plot size and output filename
1314
if layout == 'square':
14-
plt.figure(figsize=(5, 5))
15+
figsize = (5, 5)
1516
filename = "clus_rmsd_square.png"
17+
elif "," in layout:
18+
try:
19+
w, h = map(float, layout.split(","))
20+
figsize = (w, h)
21+
filename = f"clus_rmsd_{int(w)}x{int(h)}.png"
22+
except ValueError:
23+
print("Invalid layout format. Use 'square' or 'width,height' like '5,4'.")
24+
return
1625
else:
26+
figsize = (6, 4)
1727
filename = "clus_rmsd.png"
1828

29+
plt.figure(figsize=figsize)
30+
1931
font = {"family": "sans-serif", "weight": "bold", "size": 10}
2032
plt.rc("font", **font)
2133
plt.rcParams["axes.linewidth"] = 2.5
@@ -28,7 +40,8 @@ def get_plot(final_df, centroid_time_ns, yaxis_title, cluster_count, layout='wid
2840
plt.rcParams["mathtext.default"] = "regular"
2941

3042
colors = ["#e63946", "#a8dadc", "#457b9d", "#1d3557", "#808080"] if cluster_count < 5 else [
31-
"#001219", "#005f73", "#0a9396", "#94d2bd", "#e9d8a6", "#ee9b00", "#ca6702", "#bb3e03", "#ae2012", "#9b2226", "#808080"
43+
"#001219", "#005f73", "#0a9396", "#94d2bd", "#e9d8a6", "#ee9b00",
44+
"#ca6702", "#bb3e03", "#ae2012", "#9b2226", "#808080"
3245
]
3346

3447
max_cluster_index = max(cluster_count, final_df["Cluster"].max())
@@ -69,15 +82,23 @@ def get_plot(final_df, centroid_time_ns, yaxis_title, cluster_count, layout='wid
6982

7083
plt.ylabel(f"{yaxis_title}", fontsize=16, weight="bold")
7184
plt.xlabel("time (ns)", fontsize=16, weight="bold")
72-
plt.tick_params(labelsize=14)
73-
plt.legend(loc='center left', bbox_to_anchor=(1, 0.5), frameon=False)
74-
plt.savefig(filename, bbox_inches="tight", dpi=600)
85+
plt.tick_params(
86+
axis='both',
87+
which='major',
88+
direction='in',
89+
length=10,
90+
width=2.5,
91+
top=True,
92+
right=True,
93+
labelsize=14
94+
)
7595

76-
def rmsd_clusters_colorcoder(yaxis_title, cluster_count, layout='wide'):
77-
print("\n.--------------------------.")
78-
print("| RMSD CLUSTERS COLORCODER |")
79-
print(".--------------------------.\n")
96+
if show_legend:
97+
plt.legend(loc='center left', bbox_to_anchor=(1, 0.5), frameon=False)
98+
99+
plt.savefig(filename, bbox_inches="tight", dpi=600)
80100

101+
def rmsd_clusters_colorcoder(yaxis_title, cluster_count, layout='wide', show_legend=True):
81102
expected_dat = ["rmsd.dat", "cnumvtime.dat", "summary.dat"]
82103
for dat in expected_dat:
83104
data_file = Path(dat)
@@ -100,9 +121,11 @@ def rmsd_clusters_colorcoder(yaxis_title, cluster_count, layout='wide'):
100121
final_df.columns = ["RMSD", "Cluster"]
101122
final_df["Time_ns"] = final_df.index * time_per_frame
102123

103-
get_plot(final_df, centroid_time_ns, yaxis_title, cluster_count, layout)
124+
get_plot(final_df, centroid_time_ns, yaxis_title, cluster_count, layout, show_legend)
104125

105126
if __name__ == "__main__":
106-
yaxis_title = "RMSD (Å)"
107-
cluster_count = int(input("How many cluster would you like plotted? "))
108-
rmsd_clusters_colorcoder(yaxis_title, cluster_count, layout='wide')
127+
cluster_count = int(input("How many clusters would you like plotted? "))
128+
layout = input("Enter layout (e.g., 'square', '5,4', or press enter for default): ").strip() or "wide"
129+
legend_input = input("Show legend? (y/n): ").strip().lower()
130+
show_legend = legend_input != 'n'
131+
rmsd_clusters_colorcoder("trajectory 1", cluster_count, layout, show_legend)

0 commit comments

Comments
 (0)