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))
def run_Random(self): """ Create the 2PG Random configuration file and begin the execution. @type self: koala.Random2PG.Random2PG """ 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) if SizePopulation > 1: show_error_message( "Error: The population file must contain only one model") copy_necessary_files( self.path_runs.get_path_execute(), self.path_runs.get_path_execution(), self.framework.get_framework()) self.framework.set_parameter( 'rotamer_library', self.opts.rotamerLibrary) self.framework.set_parameter( 'StepNumber', self.opts.stepNumber) self.framework.set_parameter( 'How_Many_Rotation', self.opts.howManyRotation) self.framework.set_parameter( 'force_field', self.opts.forceField) self.framework.set_parameter( 'SequenceAminoAcidsPathFileName', self.path_runs.get_path_execution() + 'fasta.txt') 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', '%s/Database/' % get_path_algorithms('2pg_build_conformation')) create_configuration_file( self.path_runs.get_path_execution(), self.framework) self.framework.set_command( self.path_runs.get_path_execution(), 'protpred-Gromacs-Random_Algorithm') 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(), 'random_algorithm_solutions.pdb', 20, 'randomSolution') if(self.opts.runMinimization == 'true'): self.do_minimization("randomSolution") pdbs = list_directory( self.path_runs.get_path_execution(), 'randomSolution-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, 'randomSolution-M') 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(), "2PGRandom"): 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(), '2PGRandom.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))
def run_Build_Conformation(self): """ Create the 2PG Build Conformation configuration file and begin the execution to create a initial population. @type self: koala.BuildConformation2PG.BuildConformation2PG """ try: self.path_runs.set_path_execute() 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, ) copy_necessary_files( self.path_runs.get_path_execute(), self.path_runs.get_path_execution(), self.framework.get_framework() ) self.framework.set_parameter("gromacs_energy_min", self.opts.gromacsEnergyMin) self.framework.set_parameter("SizePopulation", self.opts.sizePopulation) self.framework.set_parameter("force_field", self.opts.forceField) self.framework.set_parameter("rotamer_library", self.opts.rotamerLibrary) if self.opts.forceField == "amber99sb-ildn": self.framework.set_parameter("c_terminal_charge", self.opts.cTerminal) self.framework.set_parameter("n_terminal_charge", self.opts.nTerminal) self.framework.set_parameter( "SequenceAminoAcidsPathFileName", self.path_runs.get_path_execution() + "fasta.txt" ) 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")) create_configuration_file(self.path_runs.get_path_execution(), self.framework) self.framework.set_command(self.path_runs.get_path_execution(), "protpred-Gromacs_pop_initial") 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.") path_output, file_output = os.path.split(self.opts.output) result, html = get_result_files(self.path_runs.get_path_execution(), self.opts.toolname) send_output_results(path_output, file_output, result) except Exception, e: show_error_message(str(e))