def set_top_level_directory(self): """ Sets top level working folder to contain all simulation steps. """ working_folder = os.path.abspath("{}_Pele".format(self.env.residue)) if not self.env.folder: self.working_folder = (helpers.get_next_peledir(working_folder) if not self.env.adaptive_restart else helpers.get_next_peledir(working_folder)) else: self.working_folder = os.path.abspath(self.env.folder)
def set_working_folder(self): """ Sets top level working folder named after the residue (unless the user specified 'working_folder' in YAML. Folders for each mutation subset are enumerated automatically and placed within the top level directory. """ resname_folder = os.path.abspath("{}_Pele".format(self.env.residue)) if not self.env.folder: self.working_folder = (helpers.get_next_peledir(resname_folder) if not self.env.adaptive_restart else helpers.get_latest_peledir(resname_folder)) else: self.working_folder = os.path.abspath(self.env.folder)
def _set_params_global(self): """ Set parameters for global exploration. Users can choose their own working folder. """ self.original_dir = os.path.abspath(os.getcwd()) working_folder = os.path.abspath("{}_Pele".format(self.args.residue)) if not self.args.folder: self.working_folder = (get_next_peledir(working_folder) if not self.args.adaptive_restart else get_latest_peledir(working_folder)) else: self.working_folder = os.path.abspath(self.args.folder) self.args.folder = os.path.join(self.working_folder, "1_global_exploration") self.args.full = True # needed for global exploration
def build_adaptive_variables(self, args): """ It builds the parameters for adaptive, according to the arguments that are supplied, and returns the corresponding Parameters instance. Parameters ---------- args : a YamlParser object The YamlParser object containing the input parameters chosen by the user Returns ------- parameters : a Parameters object The Parameters object containing the parameters for PELE """ import os from pele_platform.features import adaptive from pele_platform.Utilities.Helpers import helpers # Define main PELE directory main_dir = os.path.abspath("{}_Pele".format(args.residue)) # Set the PELE directory # In case that folder is not set by the user, we will try to suggest # the best candidate considering whether we want to restart a previous # simulation or we want to run a new one from scratch. if not args.folder: # If the simulation is being restarted (after debug), adaptive_restarted (from last epoch) # or if we're running only_analysis we need to retrieve the LAST pele_dir. Otherwise create a new one # with a new index. if args.restart or args.adaptive_restart or args.only_analysis: pele_dir = helpers.get_latest_peledir(main_dir) else: pele_dir = helpers.get_next_peledir(main_dir) # In case that the user has specified the output folder, we will # use it, regardless it already exists. else: pele_dir = os.path.abspath(args.folder) if (args.restart or args.adaptive_restart or args.only_analysis) and not os.path.exists(pele_dir): raise OSError( f"Directory {pele_dir} was not found. Please ensure you set the correct path to the top level" f" directory, e.g. 'LIG_Pele' using the 'working_folder' flag when restarting or analysing " f"the simulation.") # Retrieve the specific args for adaptive specific_args = adaptive.retrieve_software_settings(args, pele_dir) # Add pele_dir specific_args['pele_dir'] = pele_dir # Initialize Parameters object self._parameters = Parameters(args, specific_args) self._initialized = True # Set software self.parameters.software = "Adaptive" return self.parameters
def run_ppi(parsed_yaml: dict) -> (pv.ParametersBuilder, pv.ParametersBuilder): # Let user choose working folder original_dir = os.path.abspath(os.getcwd()) working_folder = os.path.abspath("{}_Pele".format(parsed_yaml.residue)) if not parsed_yaml.folder: working_folder = get_next_peledir(working_folder) if not parsed_yaml.adaptive_restart else get_latest_peledir( working_folder) else: working_folder = os.path.abspath(parsed_yaml.folder) # Set main folder parsed_yaml.folder = os.path.join(working_folder, "1_interface_exploration") # get arguments from input.yaml n_waters = parsed_yaml.n_waters parsed_yaml.n_waters = None protein_file = parsed_yaml.system chain = parsed_yaml.protein ligand_pdb = parsed_yaml.ligand_pdb # Parametrize hetero molecules before merging PDBs, if using peleffy. Otherwise they will go through Plop in # Adaptive.simulation. if parsed_yaml.use_peleffy: templates, rotamers, to_skip = parametrize_hetero_ppi(parsed_yaml) parsed_yaml.template = parsed_yaml.template.extend(templates) if parsed_yaml.template else templates parsed_yaml.rotamers = parsed_yaml.rotamers.extend(rotamers) if parsed_yaml.rotamers else rotamers parsed_yaml.skip_ligand_prep = parsed_yaml.skip_ligand_prep.extend(to_skip) if parsed_yaml.skip_ligand_prep else to_skip # no waters in the first simulation parsed_yaml.water_arg = None parsed_yaml.use_peleffy = parsed_yaml.use_peleffy if parsed_yaml.use_peleffy is not None else False # remove chains except for "protein" flag protein_file = prepare_structure(protein_file, ligand_pdb, chain, True, peleffy=parsed_yaml.use_peleffy) parsed_yaml.system = protein_file # start simulation 1 - induced fit parsed_yaml.induced_fit_long = True simulation1 = si.run_adaptive(parsed_yaml) simulation1_path = os.path.join(simulation1.pele_dir, simulation1.output) # cluster best structures if not parsed_yaml.debug: with cd(simulation1_path): cluster_best_structures("5", n_components=simulation1.n_components, residue=simulation1.residue, topology=simulation1.topology, directory=working_folder, logger=simulation1.logger) # adjust original input.yaml if not parsed_yaml.skip_refinement: parsed_yaml.system = os.path.join(working_folder, "refinement_input/*.pdb") parsed_yaml.folder = os.path.join(working_folder, "2_refinement_simulation") parsed_yaml.induced_fit_long = None parsed_yaml.ppi = None parsed_yaml.poses = None parsed_yaml.rescoring = True del parsed_yaml.water_arg # Set waters only if specified by user if n_waters != 0: parsed_yaml.waters = "all_waters" parsed_yaml.n_waters = n_waters else: parsed_yaml.waters = None parsed_yaml.n_waters = n_waters parsed_yaml.adaptive_restart = False if not parsed_yaml.test: parsed_yaml.iterations = 1 parsed_yaml.steps = 100 parsed_yaml.box_center = simulation1.box_center parsed_yaml.box_radius = 100 # We should have a look at how to set no box but at the moment super big # start simulation 2 - minimisation with cd(original_dir): if not parsed_yaml.debug: simulation2 = launch_simulation(parsed_yaml) else: simulation2 = None else: simulation2 = None return simulation1, simulation2
def build_adaptive_variables(self, args): """ It builds the parameters for adaptive, according to the arguments that are supplied, and returns the corresponding Parameters instance. Parameters ---------- args : a YamlParser object The YamlParser object containing the input parameters chosen by the user Returns ------- parameters : a Parameters object The Parameters object containing the parameters for PELE """ import os from pele_platform.constants import constants from pele_platform.features import adaptive from pele_platform.Utilities.Helpers import helpers # Define main PELE directory main_dir = os.path.abspath("{}_Pele".format(args.residue)) # Set the PELE directory # In case that folder is not set by the user, we will try to suggest # the best candidate considering whether we want to restart a previous # simulation or we want to run a new one from scratch. if not args.folder: # Check if the simulation is being restarted or not # TODO the restart flag is undocumented and counterintuitive # since it apparently is doing the opposite of # adaptive_restart if args.restart in constants.FIRST_RESTART: pele_dir = helpers.get_next_peledir(main_dir) else: pele_dir = helpers.get_latest_peledir(main_dir) # Check if the adaptive simulation is being restarted or not # Also check if we are only running the analysis if args.adaptive_restart or args.only_analysis: # Take the last folder name pele_dir = helpers.get_latest_peledir(main_dir) else: # Get a new folder name pele_dir = helpers.get_next_peledir(main_dir) # In case that the user has specified the output folder, we will # use it, regardless it already exists. else: pele_dir = os.path.abspath(args.folder) # Retrieve the specific args for adaptive specific_args = adaptive.retrieve_software_settings(args, pele_dir) # Add pele_dir specific_args['pele_dir'] = pele_dir # Initialize Parameters object self._parameters = Parameters(args, specific_args) self._initialized = True # Set software self.parameters.software = "Adaptive" return self.parameters