def gmxmmpbsa(): # Adapted to run with MPI ? if len(sys.argv) > 1 and sys.argv[1] in ['MPI', 'mpi']: args = sys.argv args.pop(1) # remove mpi arg before passed it to app try: from mpi4py import MPI except ImportError: raise MMPBSA_Error( 'Could not import mpi4py package! Use serial version ' 'or install mpi4py.') else: # If we're not running "gmx_MMPBSA MPI", bring MPI into the top-level namespace # (which will overwrite the MPI from mpi4py, which we *want* to do in serial) from GMXMMPBSA.fake_mpi import MPI args = sys.argv # Set up error/signal handlers main.setup_run() # Instantiate the main MMPBSA_App app = main.MMPBSA_App(MPI) # Read the command-line arguments try: app.get_cl_args(args[1:]) except CommandlineError as e: sys.stderr.write('%s: %s' % (type(e).__name__, e) + '\n') sys.exit(1) # Perform our MMPBSA --clean now if app.FILES.clean: sys.stdout.write('Cleaning temporary files and quitting.\n') app.remove(0) sys.exit(0) # See if we wanted to print out our input file options if app.FILES.infilehelp: app.input_file.print_contents(sys.stdout) sys.exit(0) # If we're not rewriting output do whole shebang, otherwise load info and parms # Throw up a barrier before and after running the actual calcs if not app.FILES.rewrite_output: try: app.read_input_file() except InputError as e: sys.stderr.write('%s: %s' % (type(e).__name__, e) + '\n') sys.stderr.write(' Enter `%s --help` for help\n' % (split(sys.argv[0])[1])) sys.exit(1) app.process_input() app.check_for_bad_input() app.loadcheck_prmtops() app.file_setup() app.run_mmpbsa() # If we are rewriting output, load the info and check prmtops else: info = InfoFile(app) info.read_info() app.loadcheck_prmtops() # Now we parse the output, print, and finish app.parse_output_files() app.write_final_outputs() app.finalize()
def gmxmmpbsa(): stream_handler = logging.StreamHandler() stream_handler.setLevel(logging.INFO) formatter = logging.Formatter("[%(levelname)-7s] %(message)s") stream_handler.setFormatter(formatter) logging.basicConfig( level=logging.DEBUG, format="[%(levelname)-7s] %(message)s", handlers=[logging.FileHandler("gmx_MMPBSA.log", 'w'), stream_handler]) # Just for compatibility as mpi4py works as serial when run without mpirun # (since v1.4.2) if len(sys.argv) > 1 and sys.argv[1] in ['MPI', 'mpi']: from mpi4py import MPI else: # If we're not running "gmx_MMPBSA MPI", bring MPI into the top-level namespace # (which will overwrite the MPI from mpi4py, which we *want* to do in serial) from GMXMMPBSA.fake_mpi import MPI # Set up error/signal handlers main.setup_run() # Instantiate the main MMPBSA_App app = main.MMPBSA_App(MPI) # Read the command-line arguments try: app.get_cl_args(sys.argv[1:]) except CommandlineError as e: sys.stderr.write('%s: %s' % (type(e).__name__, e) + '\n') sys.exit(1) if app.FILES.createinput is not None: args_list = create_input_args(app.FILES.createinput) app.input_file.print_contents('mmpbsa.in', args_list) logging.info( f'Input file creation successful. Path: {Path("mmpbsa.in").absolute()}' ) sys.exit(0) # Perform our MMPBSA --clean now if app.FILES.clean: logging.info('Cleaning temporary files and quitting.\n') app.remove(-1) sys.exit(0) # See if we wanted to print out our input file options if app.FILES.infilehelp: app.input_file.print_contents(sys.stdout) sys.exit(0) # If we're not rewriting output do whole shebang, otherwise load info and parms # Throw up a barrier before and after running the actual calcs if not app.FILES.rewrite_output: try: app.read_input_file() except InputError as e: sys.stderr.write('%s: %s' % (type(e).__name__, e) + '\n') sys.stderr.write(' Enter `%s --help` for help\n' % (split(sys.argv[0])[1])) sys.exit(1) app.process_input() app.check_for_bad_input() app.make_prmtops() app.loadcheck_prmtops() app.file_setup() app.run_mmpbsa() # If we are rewriting output, load the info and check prmtops else: info = InfoFile(app) info.read_info() app.loadcheck_prmtops() # Now we parse the output, print, and finish app.parse_output_files() app.write_final_outputs() app.finalize()