-
Notifications
You must be signed in to change notification settings - Fork 11
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
allow mdpow-solvationenergy to select alchemlyb estimators #148
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make mdpow-solvationenergy
a model for the scripts.
- Replace optparse with argparse so that we can use better option processing.
- The logic for force/no data is convoluted and should be simplified to avoid code duplication.
- Please add more logger INFO output.
mdpow/fep.py
Outdated
if G.method != "TI": | ||
errmsg = "Method %s is not implemented in MDPOW, use estimator='alchemlyb'" % G.method | ||
logger.error(errmsg) | ||
raise ValueError(errmsg) | ||
G.start = kwargs.pop('start', 0) | ||
G.stop = kwargs.pop('stop', None) | ||
G.SI = kwargs.pop('stop', False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks wrong — the kwarg should not be "start" but .. SI?
scripts/mdpow-solvationenergy
Outdated
if not estimator in ('mdpow', 'alchemlyb'): | ||
errmsg = "estimator = %r is not supported, must be 'mdpow' or 'alchemlyb'" % estimator | ||
logger.error(errmsg) | ||
raise ValueError(errmsg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add INFO logger that states which estimator is used
scripts/mdpow-solvationenergy
Outdated
parser.add_option('--noSI', dest='SI', | ||
action="store_false", | ||
help="Disable statistical inefficiency analysis" | ||
"Statitical inefficiency analysis is performed by default when using" | ||
"alchemlyb estimators and is disabled when using mdpow estimator.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make this a BooleanOptionalAction action option with argparse so that we have --SI
and --no-SI
(helps with #147 )
scripts/mdpow-solvationenergy
Outdated
force=False, stride=10, permissive=False, solvent='water') | ||
import argparse | ||
|
||
parser = argparse.ArgumentParser(usage=__doc__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC you need to do something special so that argparse shows defaults, something like ArgumentParserWithDefaults or so — check the docs. Then remove the [%default]
everywhere (IIRC...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be setting argparse.ArgumentDefaultsHelpFormatter and then the default values would be shown in the help message automatically.
scripts/mdpow-solvationenergy
Outdated
parser.add_argument('--noSI', dest='SI', | ||
action="store_false", | ||
help="Disable statistical inefficiency analysis" | ||
"Statitical inefficiency analysis is performed by default when using" | ||
"alchemlyb estimators and is disabled when using mdpow estimator.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the bool action
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I check the python documentation, BooleanOptionalAction action option is added in 3.9, we can't use it in 2.7.
Meet an unexpected error about the usage messsage |
Local tests output:
|
output from mdpow-solvationenergy -h
|
Thanks @VOD555 , it looks good, but can you also add before each SI analysis the window which is analyzed ? Thanks. |
@VOD555 Looks good. At the |
Thanks @VOD555 ! |
@orbeckst It's ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all the changes. Looking good but see comments
- The logic of the
for G in (G1, G2)
loop is broken and needs to be fixed — that's not your fault but it needs to be fixed and this PR is a good place. - I'd like the option for SI to be called
--SI
and--no-SI
. I hope @iorga won't be too upset. I'd like it to work like a proper bool option. - Let the script fail right away if
SI == True
andestimator == "mdpow"
just so that there's never any confusion of what is and isn't applied. If the user wants SI and then they need to use alchemlyb. This will work by default.
mdpow/fep.py
Outdated
@@ -1366,17 +1372,24 @@ def p_transfer(G1, G2, **kwargs): | |||
|
|||
# for this version. use the method given instead of the one in the input cfg file | |||
G.method = kwargs.pop('method', 'MBAR') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole loop logic needs to be fixed.
for G in (G1, G2):
G_kwargs = kwargs.copy()
# then use G_kwargs.pop() etc in this loop.
...
At the moment, G2
gets an almost empty kwargs
and uses defaults for everything.
@@ -208,7 +208,7 @@ if __name__ == "__main__": | |||
help="force rereading all data [%default]") | |||
parser.add_option('--noSI', dest='SI', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename as --no-SI
so that when we use argparse bool options, it has the same name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make things clear, also add
parser.add_option('--SI', dest='SI', action="store_true", ...)
as the on switch. Set the default for SI
to True
.
scripts/mdpow-solvationenergy
Outdated
if len(opts.directory) == 0: | ||
logger.fatal("A directory is required. See --help.") | ||
sys.exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be omitted thanks to narg+
— or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, narg+
can automatically raise an error when given no input.
Fix mdpow-solvationenergy here and then do a PR for the others. Smaller PRs are better! |
- changed `--noSI` to `--no-SI` - added `--SI` (the default)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Let the script fail right away if
SI == True
andestimator == "mdpow"
just so that there's never any confusion of what is and isn't applied. If the user wants SI and then they need to use alchemlyb. This will work by default. - update CHANGES
(Add --SI
/ --no-SI
to mdpow-pow in other PR).
Add notes to CHANGES and do whatever check you can think of (run the script at least locally... test would be nice but I don't think we test any of the scripts :-p ). When you're happy, squash merge (or tell me to do the merge). Thank youm, @VOD555 ! |
Local tests show no problem with |
I'm going to merge the PR |
Fix #135
-allow solvationenergy to use alchemlyb estimators