From dccd63d9c7d4fc3e1109c2065468d0af23c3a3dc Mon Sep 17 00:00:00 2001 From: lmacaya Date: Thu, 25 Aug 2022 10:49:51 -0400 Subject: [PATCH 1/2] Modifications to setup_abfe and analyze_dhdl --- src/pmx/analysis.py | 4 ++-- src/pmx/gmx.py | 2 +- src/pmx/scripts/analyze_dhdl.py | 2 ++ src/pmx/scripts/setup_abfe.py | 35 ++++++++++++++++++++++++++------- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/pmx/analysis.py b/src/pmx/analysis.py index 39efd340..139bc614 100644 --- a/src/pmx/analysis.py +++ b/src/pmx/analysis.py @@ -371,7 +371,7 @@ def smooth(x, window_len=11, window='hanning'): print("Plotting: no smoothing for Wr") plt.legend(shadow=True, fancybox=True, loc='upper center', prop={'size': 12}) - plt.ylabel(r'W [kJ/mol]', fontsize=20) + plt.ylabel(f'W [{units}]', fontsize=20) plt.xlabel(r'# Snapshot', fontsize=20) plt.grid(lw=2) plt.xlim(0, x[-1]+1) @@ -384,7 +384,7 @@ def smooth(x, window_len=11, window='hanning'): plt.hist(wr, bins=nbins, orientation='horizontal', facecolor='blue', alpha=.75, density=True) - x = np.arange(mini, maxi, .5) + x = np.arange(mini, maxi, .05) y1 = gauss_func(Af, mf, devf, x) y2 = gauss_func(Ab, mb, devb, x) diff --git a/src/pmx/gmx.py b/src/pmx/gmx.py index 2ee60ab7..f17d174f 100644 --- a/src/pmx/gmx.py +++ b/src/pmx/gmx.py @@ -13,7 +13,7 @@ def get_gmx(): """Gets path to gmx executable, and throws error if not found. """ - gmx = which('gmx') + gmx = which('gmx_mpi') if which('gmx') is None else which('gmx') if gmx is not None: return gmx else: diff --git a/src/pmx/scripts/analyze_dhdl.py b/src/pmx/scripts/analyze_dhdl.py index 9dc73309..1f0e2ac3 100755 --- a/src/pmx/scripts/analyze_dhdl.py +++ b/src/pmx/scripts/analyze_dhdl.py @@ -618,6 +618,8 @@ def main(args): # plot work distributions # ----------------------- if args.wplot.lower() != 'none': + res_ab = [i * unit_fact for i in res_ab] + res_ba = [i * unit_fact for i in res_ba] if quiet is False: print('\n Plotting histograms......') # hierarchy of estimators: BAR > Crooks > Jarz diff --git a/src/pmx/scripts/setup_abfe.py b/src/pmx/scripts/setup_abfe.py index 4be9db9b..62b8b4db 100644 --- a/src/pmx/scripts/setup_abfe.py +++ b/src/pmx/scripts/setup_abfe.py @@ -120,7 +120,25 @@ def parse_options(): 'behaviour, provide a random seed.', default=None, type=int) - + parser.add_argument('--conc', + metavar='float', + dest='conc', + help='Specify salt concentration (mol/liter). ' + 'Default is 0.15 M.', + default=None, + type=float) + parser.add_argument('--pname', + metavar='pname', + dest='pname', + help='Name of the positive ion. ' + 'Default is NA.', + default='NA') + parser.add_argument('--nname', + metavar='nname', + dest='nname', + help='Name of the negative ion. ' + 'Default is CL.', + default='CL') args, unknown = parser.parse_known_args() check_unknown_cmd(unknown) @@ -250,8 +268,9 @@ def main(args): # ----------------- gmx.solvate(cp='doublebox.gro', cs='spc216.gro', p='doublebox.top', o='solvate.gro') gmx.write_mdp(mdp='enmin', fout='genion.mdp') - gmx.grompp(f='genion.mdp', c='solvate.gro', p='doublebox.top', o='genion.tpr', maxwarn=1) - gmx.genion(s='genion.tpr', p='doublebox.top', o='genion.gro', conc=0.15, neutral=True) + gmx.grompp(f='genion.mdp', c='solvate.gro', p='doublebox.top', o='genion.tpr', maxwarn=10) + gmx.genion(s='genion.tpr', p='doublebox.top', o='genion.gro', conc=args.conc, neutral=True, + other_flags=f'-pname {args.pname} -nname {args.nname}') # add restraints to topology doubletop = Topology('doublebox.top', assign_types=False) @@ -276,8 +295,9 @@ def main(args): gmx.editconf(f='complex.gro', o='editconf.gro', bt='cubic', d=1.2) gmx.solvate(cp='editconf.gro', cs='spc216.gro', p='complex.top', o='solvate.gro') gmx.write_mdp(mdp='enmin', fout='genion.mdp') - gmx.grompp(f='genion.mdp', c='solvate.gro', p='complex.top', o='genion.tpr', maxwarn=1) - gmx.genion(s='genion.tpr', p='complex.top', o='genion.gro', conc=0.15, neutral=True) + gmx.grompp(f='genion.mdp', c='solvate.gro', p='complex.top', o='genion.tpr', maxwarn=10) + gmx.genion(s='genion.tpr', p='complex.top', o='genion.gro', conc=args.conc, neutral=True, + other_flags=f'-pname {args.pname} -nname {args.nname}') # add restraints to topology comtop = Topology('complex.top', assign_types=False) @@ -314,8 +334,9 @@ def main(args): gmx.editconf(f='ligand.gro', o='editconf.gro', bt='cubic', d=1.2) gmx.solvate(cp='editconf.gro', cs='spc216.gro', p='ligand.top', o='solvate.gro') gmx.write_mdp(mdp='enmin', fout='genion.mdp') - gmx.grompp(f='genion.mdp', c='solvate.gro', p='ligand.top', o='genion.tpr', maxwarn=1) - gmx.genion(s='genion.tpr', p='ligand.top', o='genion.gro', conc=0.15, neutral=True) + gmx.grompp(f='genion.mdp', c='solvate.gro', p='ligand.top', o='genion.tpr', maxwarn=10) + gmx.genion(s='genion.tpr', p='ligand.top', o='genion.gro', conc=args.conc, neutral=True, + other_flags=f'-pname {args.pname} -nname {args.nname}') os.chdir('../') From b35827c60a543274f29641df1a284a36b90516d0 Mon Sep 17 00:00:00 2001 From: lmacaya Date: Thu, 25 Aug 2022 11:00:16 -0400 Subject: [PATCH 2/2] Fix default salt concentration --- src/pmx/scripts/setup_abfe.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pmx/scripts/setup_abfe.py b/src/pmx/scripts/setup_abfe.py index 62b8b4db..83f86b60 100644 --- a/src/pmx/scripts/setup_abfe.py +++ b/src/pmx/scripts/setup_abfe.py @@ -124,8 +124,8 @@ def parse_options(): metavar='float', dest='conc', help='Specify salt concentration (mol/liter). ' - 'Default is 0.15 M.', - default=None, + 'Default is no salt added.', + default=0, type=float) parser.add_argument('--pname', metavar='pname',