-
Notifications
You must be signed in to change notification settings - Fork 5
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
Bugfix and minor cleanup of ResultsSummary code + control SHELXE use depending on resolution #52
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.
Left some comments, think we should also consider either always raise
-ing exceptions or calling ample_util.exit_util
. Currently it's mixed in the code and I think that's very inconsistent.
My vote is for the former, since that enables others to use AMPLE more like a library with their own error handling rather than applications just exiting.
ample/util/options_processor.py
Outdated
optd['tmscore_exe'] = 'TMscore' + ample_util.EXE_EXT | ||
try: | ||
optd['tmscore_exe'] = ample_util.find_exe(optd['tmscore_exe']) | ||
optd['have_tmscore'] = True |
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.
Change this to a try - except - else ... we're not really testing the setting of a variable.
try:
optd['tmscore_exe'] = ample_util.find_exe(optd['tmscore_exe'])
except ample_util.FileNotFoundError:
logger.warning("Cannot find TMScore executable: %s", optd['tmscore_exe'])
optd['maxcluster_exe'] = maxcluster.find_maxcluster(optd)
optd['have_tmscore'] = False
else:
optd['have_tmscore'] = True
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.
Note the change of logger message from debug
to warning
, since the former is what we're really looking for.
ample/util/options_processor.py
Outdated
# Modelling and ensemble options | ||
# | ||
############################################################################### | ||
logger.info('Running on %d processors' % optd['nproc']) |
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.
Comma-separated instead of %
ample/util/options_processor.py
Outdated
# cluster queueing | ||
if optd['submit_qtype']: | ||
optd['submit_qtype'] = optd['submit_qtype'].upper() | ||
if optd['submit_cluster'] and not optd['submit_qtype']: |
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.
Could we not deprecate the -submit_cluster
flag? Not necessarily remove it entirely but add a warning message to the help menu and make it do nothing ...
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 agree, but that's something for a separate pull request
ample/util/options_processor.py
Outdated
if optd['purge']: | ||
purge = optd['purge'] | ||
# Need to handle ackward compatibility where purge was boolean | ||
if purge is True: |
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.
You can typecast the bool to int simply by putting int(True)
>>> int(True)
1
>>> int(False)
0
So this entire bit of code should probably be simply
try:
opt['purge'] = int(opt['purge'])
except ValueError:
msg = 'Purge must be specified as an integer, got: {}'.format(optd['purge'])
exit_util.exit_error(msg)
logger.info('*** Purge mode level %d specified - intermediate files will be deleted ***', optd['purge'])
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.
Nice - I love getting rid of unneeded code!
ample/util/options_processor.py
Outdated
@@ -381,6 +325,16 @@ def process_options(optd): | |||
msg = "Cannot find theseus executable: {0}".format(optd['theseus_exe']) | |||
exit_util.exit_error(msg) | |||
|
|||
# SCRWL - we always check for SCRWL as if we are processing QUARK models we want to add sidechains to them | |||
if not optd['scwrl_exe']: | |||
optd['scwrl_exe'] = 'Scwrl4' + ample_util.EXE_EXT |
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.
Maybe make absolute path to binary by setting os.path.join(os.environ['CCP4'], 'bin', 'Scwrl4' + ample_util.EXE_EXT)
ample/util/options_processor.py
Outdated
if optd['phaser_rms'] != 'auto': | ||
try: | ||
phaser_rms = float(optd['phaser_rms']) | ||
optd['phaser_rms'] = phaser_rms |
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 again the try - except - else statement structure. Assignment is not really part of the try - except clause
ample/util/options_processor.py
Outdated
# | ||
if optd['use_shelxe']: | ||
if optd['mtz_max_resolution'] > mrbump_util.SHELXE_MAX_PERMITTED_RESOLUTION: | ||
logger.warn("Disabling use of SHELXE as max resolution of {} is < accepted limit of {}".\ |
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 ,
-seperated handling instead of .format
ample/util/options_processor.py
Outdated
logger.info('Making fragments (including homologues)') | ||
# Model building programs | ||
if optd['refine_rebuild_arpwarp'] or optd['shelxe_rebuild_arpwarp']: | ||
if not (os.environ.has_key('warpbin') |
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.
AAAAAAAAARRRRGH ... don't ever ever ever use has_key
again!!
Only joking, it's deprecated in Python 3.X and not really recommended either. Turn this into 'warpbin' in os.environ
.
ample/util/options_processor.py
Outdated
logger.info('\nMaking Rosetta Models') | ||
else: | ||
logger.info('NOT making Rosetta Models') | ||
logger.info('Using arpwarp script: {0}'.format(os.path.join(os.environ['warpbin'], "auto_tracing.sh"))) |
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 ,
-seperated handling instead of .format
self.assertFalse(options.d['use_shelxe']) | ||
self.assertFalse(options.d['shelxe_rebuild']) | ||
|
||
# Check we don't accidently turn it off if above limit |
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.
Being picky I'd turn this into a separate test function
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, but no ;)
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.
But yes ;-)
Typecast to check for purge option Change use of format to arguments for logger Set path to $CCP4/bin for shipped executables
The changes were all sensible, so I've made most of them. I agree that we need to think better about exiting as it causes an issue as the exit code as it's currently written doesn't have access to any AMPLE variables, so it can't clean up properly. I agree that Exceptions are probably the better way to go and then just have the main routine trap them and be responsible for exiting there. Again something for another day. |
ample/util/options_processor.py
Outdated
logger.info('*** Purge mode level %d specified - intermediate files will be deleted ***', optd['purge']) | ||
try: | ||
optd['purge'] = int(optd['purge']) | ||
except ValueError: |
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.
You need to add a KeyError
to the exception in case it's not defined.
ample/util/options_processor.py
Outdated
@@ -412,13 +406,12 @@ def process_mr_options(optd): | |||
|
|||
# Model building programs | |||
if optd['refine_rebuild_arpwarp'] or optd['shelxe_rebuild_arpwarp']: | |||
if not (os.environ.has_key('warpbin') | |||
and os.path.isfile(os.path.join(os.environ['warpbin'], "auto_tracing.sh"))): | |||
if not ('warpbin' in os.environ and os.path.isfile(os.path.join(os.environ['warpbin'], "auto_tracing.sh"))): |
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.
Instead of doing the same os.path.join
twice, I would re-write this bit like:
if optd['refine_rebuild_arpwarp'] or optd['shelxe_rebuild_arpwarp']:
auto_tracing_sh = os.path.join(os.environ['warpbin'], "auto_tracing.sh")
if 'warpbin' in os.environ and os.path.isfile(auto_tracing_sh):
logger.info('Using arpwarp script: %s', auto_tracing_sh)
else:
logger.warn('Cannot find arpwarp script! Disabling use of arpwarp.')
optd['refine_rebuild_arpwarp'] = False
optd['shelxe_rebuild_arpwarp'] = 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.
Thinking about this, what happens if a user decides not to install arpwarp ... then the warpbin
is not even in os.environ
... we need to be careful here
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.
Please include this as well Jens
I maintain the belief that doing it now is little effort and it gets done. If this gets added to the infinitely-long TODO list, chances are it will never ever be correctly done. Surely it's not too much effort either to exchange the |
Jens there are still two outstanding parts. Once a logger message and one the modified if statement. |
I've sorted it myself now quickly. |
Needs refactoring but not today...