コード例 #1
0
ファイル: main.py プロジェクト: TheKipiDragon/pele_platform
def run_allosteric(parsed_yaml: dict) -> (pv.EnviroBuilder, pv.EnviroBuilder):
    '''
    Run allosteric simulation by:
    1) Run global exploration to identify most important pockets
    2) Run induced fit simulation to find deep pockets
    '''
    #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 = is_repited(
            working_folder) if not parsed_yaml.adaptive_restart else is_last(
                working_folder)
    else:
        working_folder = os.path.abspath(parsed_yaml.folder)

    #Set main folder
    parsed_yaml.folder = os.path.join(working_folder, "1_global_exploration")

    # start initial simulation
    parsed_yaml.full = True
    simulation = si.run_adaptive(parsed_yaml)
    simulation_path = os.path.join(simulation.pele_dir, simulation.output)

    # get best structures and cluster them
    with cd(simulation_path):
        # NEED ALGORITHM TO CHOOSE OPTIMUM NUMBERS OF CLUSTERS!!!!
        cluster_best_structures("5",
                                n_components=simulation.n_components,
                                residue=simulation.residue,
                                topology=simulation.topology,
                                directory=working_folder)

    # 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.full = None
        parsed_yaml.poses = None
        parsed_yaml.induced_fit_exhaustive = True
        if not parsed_yaml.test:
            parsed_yaml.iterations = 20
            parsed_yaml.pele_steps = 10
        parsed_yaml.box_center = simulation.box_center
        parsed_yaml.box_radius = simulation.box_radius
        # refine selected best structures
        with cd(original_dir):
            induced_fit = si.run_adaptive(parsed_yaml)
    else:
        induced_fit = None

    return simulation, induced_fit
コード例 #2
0
 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.is_repeated(resname_folder)
                                if not self.env.adaptive_restart else
                                helpers.is_last(resname_folder))
     else:
         self.working_folder = os.path.abspath(self.env.folder)
コード例 #3
0
 def build_adaptive_variables(self, args):
     #DEFINE MAIN PATH
     pele_dir = os.path.abspath("{}_Pele".format(args.residue))
     if not args.folder:
         self.pele_dir = hp.is_repited(
             pele_dir) if args.restart in cs.FIRST_RESTART else hp.is_last(
                 pele_dir)
         self.pele_dir = hp.is_repited(
             pele_dir) if not args.adaptive_restart else hp.is_last(
                 pele_dir)
     else:
         self.pele_dir = os.path.abspath(args.folder)
     #####Define default variables, files and folder "HIDING VARIABLES " --> CHANGE#########
     for key, value in adfs.retrieve_software_settings(
             args, self.pele_dir).items():
         setattr(self, key, value)
     #####Initialize all variables by combining default and user input######
     simulation_params.SimulationParams.__init__(self, args)
     simulation_folders.SimulationPaths.__init__(self, args)
     for key, value in adfs.retrieve_software_settings(
             args, self.pele_dir).items():
         setattr(self, key, value)
コード例 #4
0
ファイル: main.py プロジェクト: hemahecodes/pele_platform
 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 = (
             is_repeated(working_folder)
             if not self.args.adaptive_restart
             else is_last(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
コード例 #5
0
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 = is_repeated(
            working_folder) if not parsed_yaml.adaptive_restart else is_last(
                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")

    # Check n_waters before launching the simulation
    #water_checker(parsed_yaml)

    # 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

    # no waters in the first simulation
    parsed_yaml.water_arg = None

    # remove chains except for "protein" flag
    protein_file = prepare_structure(protein_file, ligand_pdb, chain, True)
    parsed_yaml.system = protein_file

    # start simulation 1 - induced fit
    parsed_yaml.induced_fit_exhaustive = 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_exhaustive = None
        parsed_yaml.ppi = None
        parsed_yaml.poses = None
        parsed_yaml.rescoring = True
        del parsed_yaml.water_arg
        # Set waters ony 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
コード例 #6
0
    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.is_repeated(main_dir)
            else:
                pele_dir = helpers.is_last(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.is_last(main_dir)
            else:
                # Get a new folder name
                pele_dir = helpers.is_repeated(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