Skip to content

Commit

Permalink
added verbosity flag to convert
Browse files Browse the repository at this point in the history
  • Loading branch information
Ellen Zhong committed Jun 20, 2014
1 parent 7390710 commit f1f8919
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions testing/UnitTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_desmond(args):
h1, h2 = add_handler(odir)
flags = ['--des_in', f, '--desmond', '--gromacs', '--lammps', '--odir', odir]
flags = add_flags(args, flags)
logger.info('Converting %s with command:\n python convert.py %s' % (f,' '.join(flags)))
logger.info('Converting %s with command:\n python convert.py %s\n' % (f,' '.join(flags)))
try:
diff = convert.main(flags) # reuses code from convert.py
assert(len(diff) == N_FORMATS)
Expand Down Expand Up @@ -138,7 +138,7 @@ def test_gromacs(args):
h1, h2 = add_handler(odir)
flags = ['--gro_in', g, t, '--desmond', '--gromacs', '--lammps', '--odir', odir]
flags = add_flags(args, flags)
logger.info('Converting %s, %s with command:\n python convert.py %s'
logger.info('Converting %s, %s with command:\n python convert.py %s\n'
% (g, t,' '.join(flags)))
try:
diff = convert.main(flags) # reuses code from convert.py
Expand Down Expand Up @@ -167,7 +167,7 @@ def test_lammps(args):
h1, h2 = add_handler(odir)
flags = ['--lmp_in', f, '--desmond', '--gromacs', '--lammps', '--odir', odir]
flags = add_flags(args, flags)
logger.info('Converting %s with command:\n python convert.py %s' % (f,' '.join(flags)))
logger.info('Converting %s with command:\n python convert.py %s\n' % (f,' '.join(flags)))
try:
diff = convert.main(flags) # reuses code from convert.py
assert(len(diff) == N_FORMATS)
Expand Down
10 changes: 6 additions & 4 deletions testing/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
# Make a global logging object.
if __name__ == '__main__':
logger = logging.getLogger('InterMolLog')
logger.setLevel(logging.INFO) # specifies lowest severity log messages to handle (DEBUG will be ignored)
logger.setLevel(logging.DEBUG) # specifies lowest severity log messages to handle
h = logging.StreamHandler()
#f = logging.Formatter("%(levelname)s %(asctime)s %(funcName)s %(lineno)d %(message)s")
h.setLevel(logging.INFO) # ignores DEBUG level for now
f = logging.Formatter("%(levelname)s %(asctime)s %(message)s", "%Y-%m-%d %H:%M:%S")
h.setFormatter(f)
logger.addHandler(h)
Expand Down Expand Up @@ -71,7 +71,7 @@ def get_parser():
metavar='path', default='lmp_openmpi',
help='path for LAMMPS binary, needed for energy evaluation')
group_misc.add_argument('-v', '--verbose', dest='verbose', action='store_true',
help='verbosity')
help='high verbosity, includes DEBUG level output')

# prints help if no arguments given
if len(sys.argv)==1:
Expand All @@ -88,6 +88,8 @@ def main(args=''):
args = parser.parse_args(args)

logger = logging.getLogger('InterMolLog')
if args.verbose:
h.setLevel(logging.DEBUG)
System._sys = System('InterMol')

# --------------- PROCESS INPUTS ----------------- #
Expand Down Expand Up @@ -210,7 +212,7 @@ def main(args=''):
e_outfile.append(-1)

# display energy comparison results
out = ['']
out = ['InterMol Conversion Energy Comparison Results','']
out.append('{0} input energy file: {1}'.format(input_type, e_infile))
for type, file in zip(output_type, e_outfile):
out.append('{0} output energy file: {1}'.format(type, file))
Expand Down
2 changes: 1 addition & 1 deletion testing/gromacs_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def gromacs_energies(top=None, gro=None, mdp=None, gropath='',grosuff='', grompp
select = " ".join(map(str, range(1, 20))) + " 0 "
cmd = 'echo {select} | {genergy_bin} -f {ener} -o {ener_xvg} -dp'.format(
select=select, genergy_bin=genergy_bin, ener=ener, ener_xvg=ener_xvg)
logger.debug('Running GROMACS with command:\n %s' % ' '.join(cmd))
logger.debug('Running GROMACS with command:\n %s' % cmd)
with open(stdout, 'wa') as out, open(stderr, 'wa') as err:
exit = subprocess.call(cmd, stdout=out, stderr=err, shell=True)
if exit:
Expand Down

0 comments on commit f1f8919

Please sign in to comment.