def test_load_starting_positions_wrong_dat_files(self): working_path = self.golden_data_path / 'load_starting_positions' / 'wrong_dat' os.chdir(working_path) swarms = 2 glowworms = 10 use_anm = False _ = load_starting_positions(swarms, glowworms, use_anm) assert False
def test_load_starting_positions_wrong_dat_files(self): working_path = os.path.join(self.golden_data_path, 'load_starting_positions', 'wrong_dat') os.chdir(working_path) swarms = 2 glowworms = 10 use_anm = False positions = load_starting_positions(swarms, glowworms, use_anm) assert False
def test_load_starting_positions(self): working_path = self.golden_data_path / 'load_starting_positions' / 'ok' os.chdir(working_path) swarms = 2 glowworms = 10 use_anm = False positions = load_starting_positions(swarms, glowworms, use_anm) assert positions == [ 'init/initial_positions_0.dat', 'init/initial_positions_1.dat' ]
def run_simulation(parser): """Main program""" try: parser = CommandLineParser() args = parser.args # Read setup and add it to the actual args object setup = get_setup_from_file(args.setup_file) for k, v in setup.items(): setattr(args, k, v) info_file = create_simulation_info_file(args) log.info("simulation parameters saved to %s" % info_file) # Read input structures (use parsed ones) parsed_lightdock_receptor = os.path.join( os.path.dirname(args.receptor_pdb), DEFAULT_LIGHTDOCK_PREFIX % os.path.basename(args.receptor_pdb)) receptor = read_input_structure(parsed_lightdock_receptor, args.noxt, args.noh, args.verbose_parser) parsed_lightdock_ligand = os.path.join( os.path.dirname(args.ligand_pdb), DEFAULT_LIGHTDOCK_PREFIX % os.path.basename(args.ligand_pdb)) ligand = read_input_structure(parsed_lightdock_ligand, args.noxt, args.noh, args.verbose_parser) # CRITICAL to not break compatibility with previous results receptor.move_to_origin() ligand.move_to_origin() if args.use_anm: try: receptor.n_modes = read_nmodes( "%s%s" % (DEFAULT_REC_NM_FILE, NUMPY_FILE_SAVE_EXTENSION)) except: log.warning("No ANM found for receptor molecule") receptor.n_modes = None try: ligand.n_modes = read_nmodes( "%s%s" % (DEFAULT_LIG_NM_FILE, NUMPY_FILE_SAVE_EXTENSION)) except: log.warning("No ANM found for ligand molecule") ligand.n_modes = None starting_points_files = load_starting_positions( args.swarms, args.glowworms, args.use_anm, args.anm_rec, args.anm_lig) scoring_functions, adapters = set_scoring_function( parser, receptor, ligand) tasks = prepare_gso_tasks(parser, adapters, scoring_functions, starting_points_files) # Preparing the parallel execution kraken = Kraken(tasks, parser.args.cores, parser.args.profiling) log.info("Monster spotted") reports_queue = kraken.release() log.info("Finished.") except KeyboardInterrupt: log.info("Caught interrupt...") try: kraken.sink() except: pass log.info("bye.") except OSError as e: log.error("OS error found") try: kraken.sink() except: pass raise e
def run_simulation(parser): """Main program, includes MPI directives""" try: comm = MPI.COMM_WORLD parser = CommandLineParser() args = parser.args # Read setup and add it to the actual args object setup = get_setup_from_file(args.setup_file) for k, v in setup.items(): setattr(args, k, v) minion_id = comm.rank if minion_id == 0: info_file = create_simulation_info_file(args) log.info("simulation parameters saved to %s" % info_file) comm.Barrier() # Read input structures (use parsed ones) parsed_lightdock_receptor = os.path.join( os.path.dirname(args.receptor_pdb), DEFAULT_LIGHTDOCK_PREFIX % os.path.basename(args.receptor_pdb)) receptor = read_input_structure(parsed_lightdock_receptor, args.noxt, args.noh, args.verbose_parser) parsed_lightdock_ligand = os.path.join( os.path.dirname(args.ligand_pdb), DEFAULT_LIGHTDOCK_PREFIX % os.path.basename(args.ligand_pdb)) ligand = read_input_structure(parsed_lightdock_ligand, args.noxt, args.noh, args.verbose_parser) # CRITICAL to not break compatibility with previous results receptor.move_to_origin() ligand.move_to_origin() if args.use_anm: try: receptor.n_modes = read_nmodes( "%s%s" % (DEFAULT_REC_NM_FILE, NUMPY_FILE_SAVE_EXTENSION)) except: log.warning("No ANM found for receptor molecule") receptor.n_modes = None try: ligand.n_modes = read_nmodes( "%s%s" % (DEFAULT_LIG_NM_FILE, NUMPY_FILE_SAVE_EXTENSION)) except: log.warning("No ANM found for ligand molecule") ligand.n_modes = None starting_points_files = load_starting_positions( args.swarms, args.glowworms, args.use_anm, args.anm_rec, args.anm_lig) comm.Barrier() num_workers = comm.size for worker_id in range(num_workers): if worker_id == minion_id: starting_points_files = glob.glob( 'init/initial_positions*.dat') scoring_functions, adapters = set_scoring_function( parser, receptor, ligand, minion_id) # Check if scoring functions are compatible with ANM if activated if args.use_anm and minion_id == 0: for s in scoring_functions: if not s.anm_support: raise NotSupportedInScoringError( f"ANM is activated while {type(s).__name__} has no support for it" ) # Prepare tasks depending on swarms to simulate if parser.args.swarm_list: swarm_ids = parser.args.swarm_list if min(swarm_ids) < 0 or max( swarm_ids) >= parser.args.swarms: raise SwarmNumError("Wrong list of swarms") else: swarm_ids = list(range(parser.args.swarms)) for id_swarm in swarm_ids: if worker_id == (id_swarm % num_workers): print('GSO cluster %d - Minion %d' % (id_swarm, minion_id)) gso = set_gso( parser.args.glowworms, adapters, scoring_functions, starting_points_files[id_swarm], parser.args.gso_seed, parser.args.translation_step, parser.args.rotation_step, parser.args.configuration_file, parser.args.use_anm, parser.args.nmodes_step, parser.args.anm_rec, parser.args.anm_lig, parser.args.local_minimization) saving_path = "%s%d" % (DEFAULT_SWARM_FOLDER, id_swarm) task = GSOClusterTask(id_swarm, gso, parser.args.steps, saving_path) task.run() comm.Barrier() except NotSupportedInScoringError as score_error: log.error("Error found in selected scoring function:") log.error(score_error) except KeyboardInterrupt: log.info("Caught interrupt...") log.info("bye.")
def run_simulation(parser): """Main program, includes MPI directives""" try: comm = MPI.COMM_WORLD parser = CommandLineParser() args = parser.args # Read setup and add it to the actual args object setup = get_setup_from_file(args.setup_file) for k, v in setup.iteritems(): setattr(args, k, v) minion_id = comm.rank if minion_id == 0: info_file = create_simulation_info_file(args) log.info("simulation parameters saved to %s" % info_file) comm.Barrier() # Read input structures receptor = read_input_structure(args.receptor_pdb, args.noxt) ligand = read_input_structure(args.ligand_pdb, args.noxt) # CRITICAL to not break compatibility with previous results receptor.move_to_origin() ligand.move_to_origin() if args.use_anm: try: receptor.n_modes = read_nmodes( "%s%s" % (DEFAULT_REC_NM_FILE, NUMPY_FILE_SAVE_EXTENSION)) except: log.warning("No ANM found for receptor molecule") receptor.n_modes = None try: ligand.n_modes = read_nmodes( "%s%s" % (DEFAULT_LIG_NM_FILE, NUMPY_FILE_SAVE_EXTENSION)) except: log.warning("No ANM found for ligand molecule") ligand.n_modes = None starting_points_files = load_starting_positions( args.swarms, args.glowworms, args.use_anm, args.anm_rec, args.anm_lig) comm.Barrier() num_workers = comm.size for worker_id in xrange(num_workers): if worker_id == minion_id: starting_points_files = glob.glob( 'init/initial_positions*.dat') scoring_functions, adapters = set_scoring_function( parser, receptor, ligand, minion_id) for id_swarm in xrange(parser.args.swarms): if worker_id == (id_swarm % num_workers): print 'GSO cluster %d - Minion %d' % (id_swarm, minion_id) gso = set_gso( parser.args.glowworms, adapters, scoring_functions, starting_points_files[id_swarm], parser.args.gso_seed, parser.args.translation_step, parser.args.rotation_step, parser.args.configuration_file, parser.args.use_anm, parser.args.nmodes_step, parser.args.anm_rec, parser.args.anm_lig, parser.args.local_minimization) saving_path = "%s%d" % (DEFAULT_SWARM_FOLDER, id_swarm) task = GSOClusterTask(id_swarm, gso, parser.args.steps, saving_path) task.run() comm.Barrier() except KeyboardInterrupt: log.info("Caught interrupt...") log.info("bye.")
def run_simulation(parser): """Main program, includes MPI directives""" try: comm = MPI.COMM_WORLD parser = CommandLineParser() args = parser.args # Read setup and add it to the actual args object setup = get_setup_from_file(args.setup_file) for k, v in setup.iteritems(): setattr(args, k, v) minion_id = comm.rank if minion_id == 0: info_file = create_simulation_info_file(args) log.info("simulation parameters saved to %s" % info_file) comm.Barrier() # Read input structures receptor = read_input_structure(args.receptor_pdb, args.noxt) ligand = read_input_structure(args.ligand_pdb, args.noxt) # CRITICAL to not break compatibility with previous results receptor.move_to_origin() ligand.move_to_origin() if args.use_anm: try: receptor.n_modes = read_nmodes("%s%s" % (DEFAULT_REC_NM_FILE, NUMPY_FILE_SAVE_EXTENSION) ) except: log.warning("No ANM found for receptor molecule") receptor.n_modes = None try: ligand.n_modes = read_nmodes("%s%s" % (DEFAULT_LIG_NM_FILE, NUMPY_FILE_SAVE_EXTENSION) ) except: log.warning("No ANM found for ligand molecule") ligand.n_modes = None starting_points_files = load_starting_positions(args.swarms, args.glowworms, args.use_anm, args.anm_rec, args.anm_lig) comm.Barrier() num_workers = comm.size for worker_id in xrange(num_workers): if worker_id == minion_id: starting_points_files = glob.glob('init/initial_positions*.dat') scoring_functions, adapters = set_scoring_function(parser, receptor, ligand, minion_id) for id_swarm in xrange(parser.args.swarms): if worker_id == (id_swarm % num_workers): print 'GSO cluster %d - Minion %d' % (id_swarm, minion_id) gso = set_gso(parser.args.glowworms, adapters, scoring_functions, starting_points_files[id_swarm], parser.args.gso_seed, parser.args.translation_step, parser.args.rotation_step, parser.args.configuration_file, parser.args.use_anm, parser.args.nmodes_step, parser.args.anm_rec, parser.args.anm_lig, parser.args.local_minimization) saving_path = "%s%d" % (DEFAULT_SWARM_FOLDER, id_swarm) task = GSOClusterTask(id_swarm, gso, parser.args.steps, saving_path) task.run() comm.Barrier() except KeyboardInterrupt: log.info("Caught interrupt...") log.info("bye.")