Example #1
0
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
    def run(self):
        """
        Runs the simulation for all inputs.

        Returns
        -------
            A list of job parameters (EnviroBuilder objects) for each simulation subset.
        """
        self.set_package_params()
        self.check_cpus()
        self.set_working_folder()
        self.all_mutations = self.retrieve_inputs()
        self.restart_checker()
        self.split_into_subsets()

        for idx, subset in enumerate(self.mutation_subsets, self.start):
            self.env.input = subset
            self.env.cpus = self.env.cpus_per_mutation * len(subset) + 1
            self.env.folder = os.path.join(
                self.working_folder, "{}{}".format(self.subset_folder, idx))

            with helpers.cd(self.original_dir):
                job = simulation.run_adaptive(self.env)
                self.postprocessing(job)
                self.all_jobs.append(deepcopy(job))
                self.logger(job)

        return self.all_jobs
Example #3
0
 def launch_package(self,
                    package: str,
                    no_check=False) -> pv.ParametersBuilder:
     # Launch package from API
     if not no_check:
         ck.check_executable_and_env_variables(self._args)
     if package == self.adaptive or package == "interaction_restrictions":
         job_variables = ad.run_adaptive(self._args)
     elif package == self.gpcr_orth:
         job_variables = gpcr.GpcrLauncher(self._args).run_gpcr_simulation()
     elif package == self.out_in:
         job_variables = outin.OutInLauncher(
             self._args).run_outin_simulation()
     elif package == self.site_finder:
         job_variables = al.SiteFinderLauncher(self._args).run_site_finder()
     elif package == self.ppi:
         job_variables = run_ppi(self._args)
     elif package == self.saturated_mutagenesis:
         job_variables = SaturatedMutagenesis(self._args).run()
     elif package == self.covalent_docking:
         job_variables = CovalentDocking(self._args).run()
     elif package == self.frag:
         # Set variables and input ready
         job_variables = fr.FragRunner(self._args).run_simulation()
     return job_variables
    def run_equilibration(self):
        """
        Launches the simulation with equilibration args.
        """
        from pele_platform.Adaptive.simulation import run_adaptive

        self.equilibration_parameters = run_adaptive(
            self.equilibration_parameters)
Example #5
0
    def _launch_refinement(self):

        with cd(self.original_dir):
            # with cd(self.working_folder):
            if not self.args.debug:
                sim_params = si.run_adaptive(self.args)
            else:
                sim_params = None

        return sim_params
Example #6
0
    def run(self):
        """
        Runs the whole covalent docking pipeline.
        Returns
        -------
            A tuple of EnviroBuilder objects with job variables for both simulations.
        """
        self.env.residue_type = self.get_residue_type()
        self.correct_system()
        self.set_general_perturbation_params()
        self.job1 = simulation.run_adaptive(self.env)

        if not self.env.debug:
            self.choose_refinement_input()
            self.set_refinement_perturbation_params()
            self.job2 = simulation.run_adaptive(self.env)
        else:
            self.job2 = None

        return self.job1, self.job2
Example #7
0
    def launch(self):
        if self._args.software == "msm":
            if (self._args.clust > self.cpus and self.restart != "msm"
                    and not self.test):
                raise ValueError(
                    cs.CLUSTER_ERROR.format(self.cpus, self._args.clust))
            else:
                msm.run(self._args)

        elif self.software == "adaptive":
            ad.run_adaptive(self._args)

        elif self.software in ["glide", "induce_fit"]:
            gl.run(self._args)

        elif self.software == "frag":
            main = os.path.join(cs.DIR, "LigandGrowing/grow.py")
            "{} {} -cp {} -fp {} -ca {} -fa {}".format(cs.PYTHON3, main,
                                                       self._args.system,
                                                       self._args.frag,
                                                       self._args.ca,
                                                       self._args.fa)
Example #8
0
    def run_outin_simulation(self) -> pv.ParametersBuilder:
        """
        Runs the whole OutIn workflow.

        Returns
        --------
        simulation_parameters : pv.ParametersBuilder
            An object containing all simulation parameters.
        """
        # Set parameters for gpcr and launch simulation
        self._check_mandatory_fields()
        self._set_parameters()
        simulation_parameters = si.run_adaptive(self.args)
        return simulation_parameters
Example #9
0
 def launch_package(self, package: str, no_check=False) -> pv.EnviroBuilder:
     #launch package from API
     if not no_check:
         ck.check_executable_and_env_variables(self._args)
     if package == self.adaptive:
         job_variables = ad.run_adaptive(self._args)
     elif package == self.gpcr_orth:
         job_variables = gpcr.GpcrLauncher(self._args).run_gpcr_simulation()
     elif package == self.allosteric:
         job_variables = run_allosteric(self._args)
     elif package == self.ppi:
         job_variables = run_ppi(self._args)
     elif package == self.frag:
         #Set variables and input ready
         job_variables = fr.FragRunner(self._args).run_simulation()
     return job_variables
Example #10
0
 def _launch_global(self):
     sim_params = si.run_adaptive(self.args)
     return sim_params
Example #11
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
Example #12
0
 def run_gpcr_simulation(self) -> pv.EnviroBuilder:
     #Set parameters for gpcr and launch simulation
     self._set_parameters()
     simulation_parameters = si.run_adaptive(self.args)
     return simulation_parameters
Example #13
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 = 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
Example #14
0
def run(args):
    env = sim.run_adaptive(args)
    if args.restart in ["all", "adaptive", "score"]:
        env = pele.EnviroBuilder.build_env(args)
        split_traj_dirs = split_trajectory(env)
        rescore(split_traj_dirs, env)
def launch_simulation(original_yaml):
    job_parameters = si.run_adaptive(original_yaml)
    return job_parameters
Example #16
0
 def run_gpcr_simulation(self) -> pv.ParametersBuilder:
     #Set parameters for gpcr and launch simulation
     self._check_mandatory_fields()
     self._set_parameters()
     simulation_parameters = si.run_adaptive(self.args)
     return simulation_parameters