Ejemplo n.º 1
0
    def run_SortByFront(self, fitness):
        """
        Run the 2PG Sort algorithm for each objectivies combinations
        @type self: koala.DominanceRanking.DominanceRanking
        @type fitness: string
        """

        NumberObjective, Fitness_Energy = format_fitness(fitness)

        self.framework.set_parameter('NumberObjective', NumberObjective)
        self.framework.set_parameter('Fitness_Energy', Fitness_Energy)

        create_configuration_file(self.path_runs.get_path_execution(), self.framework)

        config = 'configuration.conf'

        cl = [self.framework.get_command(), config, '&']

        retProcess = subprocess.Popen(
            cl, 0, stdout=None,  stderr=subprocess.STDOUT, shell=False)
        retCode = retProcess.wait()
        if(retCode != 0):
            show_error_message(
                "The 2PG framework finished wrong.\n"
                "Try to check and rename the PDB input files or contact the system administrator.")
    def run_SortByFront(self):
        """
        Run the 2PG Sort algorithm to calculate the Pareto fronts and sorting
        @type self: koala.SortByFront.SortByFront
        """

        self.path_runs.set_path_execute()
        self.path_runs.set_execution_directory()

        copy_necessary_files(
            self.path_runs.get_path_execute(),
            self.path_runs.get_path_execution(),
            self.framework.get_framework())

        self.framework.set_parameter(
                'objective_analisys_dimo_source',
                '/home/%s/programs/dimo/DIMO2' % get_logged_user())
        self.framework.set_parameter('Local_Execute', self.path_runs.get_path_execution())
        self.framework.set_parameter(
                'Path_Gromacs_Programs',
                get_path_gromacs())
        self.framework.set_parameter(
                'NativeProtein',
                '%s1VII.pdb' % self.path_runs.get_path_execution())

        NumberObjective, Fitness_Energy = format_fitness(self.opts.inputFitness)

        self.framework.set_parameter('NumberObjective', NumberObjective)
        self.framework.set_parameter('Fitness_Energy', Fitness_Energy)

        create_configuration_file(
            self.path_runs.get_path_execution(), self.framework)

        config = 'configuration.conf'

        if self.opts.compressedFile == '1':

            inputFiles = self.opts.inputPDBs.split(",")

            for input_f in inputFiles:
                if zipfile.is_zipfile(input_f):
                    extract_zip_file(input_f, self.path_runs.get_path_execution())
                else:
                    try:
                        inF = gzip.GzipFile(input_f, 'rb')
                        f = inF.read()
                        inF.close()
                        if f:
                            extract_gz_file(input_f, self.path_runs.get_path_execution())
                    except Exception, e:
                        raise Exception("The input file could not be read.\n%s" % e)
Ejemplo n.º 3
0
    def build_rankingDominance(self):
        """
        Create the 2PG Sort configuration file and build the dominance
        @type self: koala.DominanceRanking.DominanceRanking
        """

        self.path_runs.set_path_execute()
        self.path_runs.set_execution_directory()

        copy_necessary_files(
            self.path_runs.get_path_execute(),
            self.path_runs.get_path_execution(),
            self.framework.get_framework())

        self.framework.set_parameter(
                    'objective_analisys_dimo_source',
                    '/home/%s/programs/dimo/DIMO2' % get_logged_user())
        self.framework.set_parameter('Local_Execute', self.path_runs.get_path_execution())
        self.framework.set_parameter('Path_Gromacs_Programs', get_path_gromacs())
        self.framework.set_parameter(
            'NativeProtein', '%s1VII.pdb' % self.path_runs.get_path_execution())

        self.combinations = format_fitness(self.opts.inputFitness, self.opts.toolname)

        if self.opts.compressedFile == '1':

            inputFiles = self.opts.inputPDBs.split(",")

            for input_f in inputFiles:
                if zipfile.is_zipfile(input_f):
                    extract_zip_file(input_f, self.path_runs.get_path_execution())
                else:
                    try:
                        inF = gzip.GzipFile(input_f, 'rb')
                        f = inF.read()
                        inF.close()
                        if f:
                            extract_gz_file(input_f, self.path_runs.get_path_execution())
                    except Exception, e:
                        raise Exception("The input file could not be read.\n%s" % e)
Ejemplo n.º 4
0
    def run_NSGAII(self):
        """
        Create the 2PG NSGA-II configuration file and begin the execution.

        @type self: koala.NSGAII2PG.NSGAII2PG
        """
        try:
            self.path_runs.set_path_execute()
            if self.opts.inputEmail:
                email = validate_email(self.opts.inputEmail)
                self.path_runs.set_execution_directory(email)
            else:
                self.path_runs.set_execution_directory()

            self.sequence = create_local_fasta_file(
                self.path_runs.get_path_execution(),
                self.opts.fromFasta,
                self.opts.inputFasta,
                self.opts.toolname,
                self.framework,
            )

            SizePopulation = create_local_pop_file(
                self.path_runs.get_path_execution(), self.opts.inputPop, self.framework
            )

            copy_necessary_files(
                self.path_runs.get_path_execute(), self.path_runs.get_path_execution(), self.framework.get_framework()
            )

            self.framework.set_parameter("NumberGeration", self.opts.numberGeration)
            self.framework.set_parameter("SizePopulation", SizePopulation)
            self.framework.set_parameter(
                "SequenceAminoAcidsPathFileName", self.path_runs.get_path_execution() + "fasta.txt"
            )
            self.framework.set_parameter("How_Many_Rotation", self.opts.howManyRotation)
            self.framework.set_parameter("rotamer_library", self.opts.rotamerLibrary)
            self.framework.set_parameter("Local_Execute", self.path_runs.get_path_execution())
            self.framework.set_parameter("Path_Gromacs_Programs", get_path_gromacs())
            self.framework.set_parameter("NativeProtein", "%s1VII.pdb" % self.path_runs.get_path_execution())
            self.framework.set_parameter("Database", "%sDatabase/" % get_path_algorithms("2pg_build_conformation"))

            NumberObjective, Fitness_Energy = format_fitness(self.opts.inputFitness, self.opts.toolname)

            self.framework.set_parameter("NumberObjective", NumberObjective)
            self.framework.set_parameter("Fitness_Energy", Fitness_Energy)

            create_configuration_file(self.path_runs.get_path_execution(), self.framework)

            self.framework.set_command(self.path_runs.get_path_execution(), "protpred-Gromacs-NSGA2")

            config = "configuration.conf"

            cl = [self.framework.get_command(), config, "&"]

            retProcess = subprocess.Popen(cl, 0, stdout=None, stderr=subprocess.STDOUT, shell=False)
            retCode = retProcess.wait()
            if retCode != 0:
                show_error_message("The 2PG framework finished wrong.\nContact the system administrator.")

            parse_pdb(
                self.path_runs.get_path_execution(),
                "pop_NON_DOMINATED_%s.pdb" % self.opts.numberGeration,
                20,
                "NSGAIISolutions",
            )

            if self.opts.runMinimization == "true":
                self.do_minimization("NSGAIISolutions")

            pdbs = list_directory(self.path_runs.get_path_execution(), "NSGAIISolutions-M*.pdb")

            build_images(pdbs, self.path_runs.get_path_execution())

            path_output, file_output = os.path.split(self.opts.filehtml)

            name, ext = os.path.splitext(self.opts.filehtml)

            htmldir = os.path.join(path_output, "%s_files" % name)

            if not os.path.exists(htmldir):
                os.makedirs(htmldir)

            self.opts.htmlfiledir = htmldir

            result, filesHtml = get_result_files(
                self.path_runs.get_path_execution(), self.opts.toolname, "NSGAIISolutions-M"
            )

            send_output_results(path_output, file_output, result)

            send_output_files_html(self.opts.htmlfiledir, filesHtml)
            send_output_files_html(self.opts.htmlfiledir, [result])

            if self.opts.createCompressFile == "True":
                if compress_files(pdbs, self.path_runs.get_path_execution(), "2PGNSGAII"):
                    path_output, file_output = os.path.split(self.opts.outputZip)
                    send_output_results(
                        path_output, file_output, os.path.join(self.path_runs.get_path_execution(), "2PGNSGAII.zip")
                    )

            self.makeHtml()

            if self.opts.useJmol in ("True", "true"):
                self.makeHtmlWithJMol(pdbs[0])

            if self.opts.inputEmail:
                send_email(
                    "*****@*****.**",
                    email,
                    "%s Execution on Galaxy - Cloud USP" % self.opts.toolname,
                    get_message_email(self.opts.toolname),
                    [],
                    "smtp.gmail.com",
                )

        except Exception, e:
            show_error_message(str(e))