Exemplo n.º 1
0
def analyse_msm(iteration, env, folder):
    with hp.cd(env.adap_l_output):
        try:
            getRepr.main(os.path.join(env.adap_l_output, folder, REPRESENTATIVES_FILE), ".", output=REPRESENTATIVES_STRUCTURES % iteration, topology=env.topology)
        except IndexError:
            pass
        pt.main(4, 1, 5, folder, True, True, True, None, None, env.system_fix, True, False, None, folder, env.residue)
Exemplo n.º 2
0
def run_msm(env, runTica=True):
    with hp.cd(env.adap_l_output):
        trajs_per_epoch = len(glob.glob(os.path.join("0", "*report*")))
        if runTica:
            td.main(DIMENSIONS, clusters, env.residue, lagtime, trajs_per_epoch, 1000)
            return()
        else:
            extractCoords.main(lig_resname=env.residue, non_Repeat=False, atom_Ids="", nProcessors=env.cpus, parallelize=False, topology=env.topology)
            prepareMSMFolders.main()
            estimateDGAdaptive.main(trajs_per_epoch, env.lagtime, env.msm_clust, lagtimes=env.lagtimes, output=env.results)
            results_file = summerize(env.results)
Exemplo n.º 3
0
    def run_pele(self, env, limitTime=False):
        with helpers.cd(os.path.dirname(self.file)):
            toRun = ["mpirun", "-np", str(env.cpus), env.pele_bin, env.pele_temp]
            print(" ".join(toRun))
            startTime = time.time()

            if limitTime:
                try:
                    proc = subprocess.Popen(toRun, shell=False,  universal_newlines=True, preexec_fn=os.setsid)
                    (out, err) = proc.communicate(timeout=limitTime)
                except subprocess.TimeoutExpired:
                    print("killing")
                    os.killpg(os.getpgid(proc.pid), signal.SIGTERM)
            else:
                proc = subprocess.Popen(toRun, shell=False, universal_newlines=True)
                (out, err) = proc.communicate()
                print(out)
                if err:
                    print(err)

            endTime = time.time()
        return "PELE took %.2f sec" % (endTime - startTime)
Exemplo n.º 4
0
 def run_adaptive(self, env, hook=False, limitTime=False):
     with helpers.cd(os.path.dirname(self.file)):
         if hook:
             ad.main(self.file, clusteringHook=self.interactive_clustering)
         else:
             ad.main(self.file, msm_env=env, limitTime=limitTime)
Exemplo n.º 5
0
def run(args):
    # Build folders and logging
    env = pele.EnviroBuilder.build_env(args)

    if args.restart == "all":

        # Build System
        env.logger.info("Checking {} system for Pele".format(args.residue))
        syst = sp.SystemBuilder.build_system(args.system, args.mae_lig,
                                             args.residue, env.pele_dir)

        # Prepare System
        system_fix, missing_residues, gaps, metals, protein_constraints = ppp.main(
            syst.system,
            env.pele_dir,
            charge_terminals=args.charge_ter,
            no_gaps_ter=args.gaps_ter,
            mid_chain_nonstd_residue=env.nonstandard,
            renumber=env.renumber,
            dynamic_waters=env.water)
        env.logger.info(
            cs.SYSTEM.format(system_fix, missing_residues, gaps, metals))

        # Parametrize Ligand
        env.logger.info("Creating template for residue {}".format(
            args.residue))
        with hp.cd(env.pele_dir):
            plop.parametrize_miss_residues(args, env, syst)
        env.logger.info("Template {}z created".format(args.residue.lower()))

        # Parametrize missing residues
        for res, __, _ in missing_residues:
            if res != args.residue:
                env.logger.info("Creating template for residue {}".format(res))
                with hp.cd(env.pele_dir):
                    mr.create_template(args, env)
                    env.logger.info("Template {}z created".format(res))

        # Parametrize solvent parameters if need it
        if env.solvent == "OBC":
            shutil.copy(env.obc_tmp, env.obc_file)
            for template in glob.glob(os.path.join(env.template_folder, "*")):
                obc.main(template, env.obc_file)

        # Fill in Simulation Templates
        ad.SimulationBuilder(env.pele_exit_temp, env.topology,
                             cs.EX_PELE_KEYWORDS, env.native, args.forcefield,
                             args.chain, "\n".join(protein_constraints),
                             env.license, env.log, env.solvent)
        ad.SimulationBuilder(env.pele_temp, env.topology, cs.EX_PELE_KEYWORDS,
                             env.native, args.forcefield, args.chain,
                             "\n".join(protein_constraints), env.license,
                             env.log, env.solvent, env.dynamic_water)

    if args.restart in ["all", "pele"]:

        #Check restart variables
        try:
            initial_iteration = max([
                int(os.path.basename(os.path.normpath(folder)))
                for folder in glob.glob(os.path.join(env.adap_l_output, "*/"))
                if os.path.basename(os.path.normpath(folder)).isdigit()
            ])
        except ValueError:
            initial_iteration = 0

        # For each iteration
        for i in range(initial_iteration, env.iterations):

            if not env.one_exit or i == 0:
                # Run Multiple Adaptive Exit if no specified the contrary
                env.logger.info("Running ExitPath Adaptive {}".format(i))
                env.update_variable_for_iteration(i)
                shutil.copy(env.adap_exit_template, env.ad_ex_temp)
                simulation = ad.SimulationBuilder(
                    env.ad_ex_temp, env.topology, cs.EX_ADAPTIVE_KEYWORDS,
                    cs.RESTART, env.adap_ex_output, env.adap_ex_input,
                    env.cpus, env.pele_exit_temp, env.residue, env.equil_steps,
                    env.random_num, env.exit_iters, env.eq_struct,
                    env.pele_bin, env.pele_data, env.pele_documents)
                simulation.run_adaptive(env, hook=True)
                env.logger.info("ExitPath Adaptive run successfully")

                # KMeans Clustering with different seed
                env.logger.info("Running Exit Path Clustering")
                with hp.cd(env.adap_ex_output):
                    env.logger.info("Seed {}".format(env.random_num))
                    cluster_centers = cl.main(env.clusters,
                                              env.cluster_output,
                                              args.residue,
                                              "",
                                              env.cpus,
                                              env.adap_ex_output,
                                              env.topology,
                                              env.sasamin,
                                              env.sasamax,
                                              env.sasa,
                                              env.perc_sasa_min,
                                              env.perc_sasa_int,
                                              seed=env.random_num,
                                              iteration=i)
                env.logger.info("Exit Path Clustering run successfully")

            # Create Exploration Box
            env.logger.info("Creating box")
            box, BS_sasa_min, BS_sasa_max = bx.create_box(
                cluster_centers, env, i)
            env.logger.info("Box created successfully ")

            # Explore
            env.logger.info("Running standard Pele")
            inputs = [
                cs.INPUT_PELE.format(f) for f in glob.glob(env.adap_l_input)
            ]
            output = os.path.join(env.adap_l_output, str(i))
            if not os.path.isdir(output):
                os.mkdir(output)
            hp.change_output(env.pele_temp, output, i)
            simulation = ad.SimulationBuilder(
                env.pele_temp, env.topology, cs.PELE_KEYWORDS, cs.RESTART,
                os.path.join(env.adap_l_output, output), ",\n".join(inputs),
                env.random_num, env.steps, box, env.box_metric, BS_sasa_min,
                BS_sasa_max, env.temp)
            time_sim = simulation.run_pele(env, limitTime=env.time)
            env.logger.info("Pele run successfully in {}".format(time_sim))

            # Analyse simulation
            env.logger.info("Running MSM analysis")
            msm.analyse_results(env,
                                runTica=False,
                                last=i == (env.iterations - 1))
            env.logger.info("MSM analysis run successfully")

    if args.restart in ["msm", "analyse"]:

        # MSM Final Analysis
        env.logger.info("Running MSM analysis")
        env.update_variable_for_iteration(env.iterations - 1)
        msm.analyse_results(env, runTica=False, last=True)
        env.logger.info("MSM analysis run successfully")

    env.logger.info("{} System run successfully".format(args.residue))