def makeHtml(self): """ Create an HTML file content to list all the artifacts found in the html_dir @type self: koala.Random2PG.Random2PG """ try: galhtmlprefix = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="generator" content="Galaxy %s tool output" /> <title></title> <link rel="stylesheet" href="/static/koala.css" type="text/css" /> <link rel="stylesheet" href="/static/style/base.css" type="text/css" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> <script src="http://code.highcharts.com/highcharts.js"></script> <script src="http://code.highcharts.com/highcharts-more.js"></script> <script src="http://code.highcharts.com/modules/exporting.js"></script> </head> <body> <div class="toolFormBody">""" galhtmlpostfix = """</div></body></html>\n""" flist = os.listdir(self.opts.htmlfiledir) flist.sort() html = [] html.append(galhtmlprefix % self.progname) html.append('<div class="sucessmessage">') html.append('<br>') html.append('<h1 align="center">2PG Random Ab Initio Algorithm results</h1><br></div>') html.append('<br>') html.append('<div class="sectionmessage">') html.append('<br>Submitted Primary Sequence.<br><br></div>') html.append('<div class="code">') html.append('Length: %s<br>' % len(self.sequence)) html.append('%s<br></div>' % self.sequence) fhtml = [] fitFiles = [] outputfiles = [] compressedFile = [] imageFiles = [] if len(flist) > 0: for rownum, fname in enumerate(flist): dname, e = os.path.splitext(fname) sfsize = get_file_size(fname, self.opts.htmlfiledir) if e.lower() == ".fit": fitFiles.append(fname) elif e.lower() == ".png": imageFiles.append(fname) elif e.lower() in ".zip, .gz": compressedFile.append(fname) elif not e.lower() in self.ignoreoutfiles: outputfiles.append(fname) # Arquivos fit for fit in fitFiles: sfsize = get_file_size(fit, self.opts.htmlfiledir) fhtml.append('<tr>') fhtml.append('<td><a href="%s">%s</a></td>' % (fit, fit)) fhtml.append('<td>%s</td>' % (sfsize)) fhtml.append('</tr>') if len(fhtml) > 0: html.append('<br>') html.append('<div class="sectionmessage">') html.append('<br>Download Calculated values of selected Objectives.<br><br></div>') fhtml.insert( 0, '<div class="filetables"><table border="1"><tr><th>File</th>' '<th>Size</th></tr>\n') fhtml.append('</table></div><br>') html += fhtml fhtml = [] # images (e depois models) listaArquivosPdb = list_directory( self.path_runs.get_path_execution(), 'randomSolution-M*.pdb') if len(listaArquivosPdb) <= 20: size = int(len(listaArquivosPdb) / 5) rest = len(listaArquivosPdb) % 5 else: size = 4 # vai mostrar no máximo 20 imagens rest = 0 idx = 0 # controla indice das imagens e dos metodos start = 0 end = 5 # limite de colunas para uma linha if size < 1: n = len(listaArquivosPdb) fhtml.append('<tr>') idx_linha = idx for i in range(0, n): pdbName, ext = os.path.splitext(listaArquivosPdb[idx]) fhtml.append( '<td><a href="%s.png"><img src="%s.png" ' 'title="Click to see %s.png bigger" width="130"/></a></td>' % (pdbName, pdbName, pdbName)) idx += 1 idx = idx_linha fhtml.append('</tr><tr>') for i in range(0, n): fhtml.append( '<td><a href="%s">%s</a></td>' % ( listaArquivosPdb[idx], listaArquivosPdb[idx])) idx += 1 idx = idx_linha fhtml.append('</tr><tr>') for i in range(0, n): sfsize = get_file_size( listaArquivosPdb[idx], self.opts.htmlfiledir) fhtml.append('<td>%s</td>' % (sfsize)) idx += 1 idx = idx_linha fhtml.append('</tr>') else: for img in range(0, size): fhtml.append('<tr>') idx_linha = idx for i in range(start, end): pdbName, ext = os.path.splitext(listaArquivosPdb[idx]) fhtml.append( '<td><a href="%s.png"><img src="%s.png" ' 'title="Click to see %s.png bigger" width="130"/></a></td>' % (pdbName, pdbName, pdbName)) idx += 1 idx = idx_linha fhtml.append('</tr><tr>') for i in range(start, end): fhtml.append( '<td><a href="%s">%s</a></td>' % ( listaArquivosPdb[idx], listaArquivosPdb[idx])) idx += 1 idx = idx_linha fhtml.append('</tr><tr>') for i in range(start, end): sfsize = get_file_size( listaArquivosPdb[idx], self.opts.htmlfiledir) fhtml.append('<td>%s</td>' % (sfsize)) idx += 1 fhtml.append('</tr>') fhtml.append('<tr>') idx_linha = idx for i in range(0, rest): pdbName, ext = os.path.splitext(listaArquivosPdb[idx]) fhtml.append( '<td><a href="%s.png"><img src="%s.png" ' 'title="Click to see %s.png bigger" width="130"/></a></td>' % (pdbName, pdbName, pdbName)) idx += 1 idx = idx_linha fhtml.append('</tr><tr>') for i in range(0, rest): fhtml.append( '<td><a href="%s">%s</a></td>' % ( listaArquivosPdb[idx], listaArquivosPdb[idx])) idx += 1 idx = idx_linha fhtml.append('</tr><tr>') for i in range(0, rest): sfsize = get_file_size( listaArquivosPdb[idx], self.opts.htmlfiledir) fhtml.append('<td>%s</td>' % (sfsize)) idx += 1 idx = idx_linha fhtml.append('</tr>') if len(fhtml) > 0: html.append('<br>') html.append('<div class="sectionmessage">') html.append('<br>Best Tertiary Structures<br>') html.append('<br></div>') if(self.opts.useJmol == 'true'): html.append('<div class="active-jmol">') html.append('<br>') html.append( '<a href=/datasets/%s/display/%s.htm>Activate JMol</a>' % ( self.opts.datasetID, self.opts.datasetID)) html.append('<br></div>') model = '' if size < 1: for i in range(0, len(listaArquivosPdb)): model += '<th>Model</th>' else: model = '<th>Model</th>'\ '<th>Model</th>'\ '<th>Model</th>'\ '<th>Model</th>'\ '<th>Model</th>' fhtml.insert( 0, '<div class="filetables"><table border="1">' '<tr>' + model + '</tr>\n') fhtml.append('</table></div><br/>') html += fhtml fhtml = [] # Outros arquivos de output for output in outputfiles: sfsize = get_file_size(output, self.opts.htmlfiledir) fhtml.append('<tr>') fhtml.append('<td><a href="%s">%s</a></td>' % (output, output)) fhtml.append('<td>%s</td>' % (sfsize)) fhtml.append('</tr>') if len(fhtml) > 0: html.append('<br>') html.append('<div class="sectionmessage">') html.append('<br>Download the output files:<br><br></div>') fhtml.insert( 0, '<div class="filetables"><table border="1"><tr><th>Output File</th>' '<th>Size</th></tr>\n') fhtml.append('</table></div><br>') html += fhtml fhtml = [] # arquivo zipado for output in compressedFile: sfsize = get_file_size(output, self.opts.htmlfiledir) fhtml.append('<tr>') fhtml.append('<td><a href="%s">%s</a></td>' % (output, output)) fhtml.append('<td>%s</td>' % (sfsize)) fhtml.append('</tr>') if len(fhtml) > 0: html.append('<br>') html.append('<div class="sectionmessage">') html.append('<br>Compressed file with all the output files<br><br></div>') fhtml.insert( 0, '<div class="filetables"><table border="1"><tr><th>File</th>' '<th>Size</th></tr>\n') fhtml.append('</table></div><br>') html += fhtml self.time_execution.set_job_end(datetime.datetime.now()) self.endTime = datetime.datetime.now() dif = self.time_execution.calculate_time_execution() html.append('<div>Time execution:<br>') html.append('Start: %s<br>' % self.time_execution.get_job_start().strftime("%d/%m/%Y %H:%M:%S")) html.append('End: %s<br>' % self.time_execution.get_job_end().strftime("%d/%m/%Y %H:%M:%S")) html.append('Total time: ~%dh:%dm:%ds' % (dif[0], dif[1], dif[2])) html.append('</div>') html.append('<hr>') html.append('<div>Citation<br>') html.append('Please, cite the used algorithm in this tool:<br><br>') html.append('') html.append('<br></div>') html.append(galhtmlpostfix) htmlf = file(self.opts.filehtml, 'w') htmlf.write('\n'.join(html)) htmlf.write('\n') htmlf.close() except Exception, e: show_error_message("Error on makeHtml:\n%s" % str(e))
def makeHtmlWithJMol(self, pdbReference): """ Create an HTML file content to list all the artifacts found in the html_dir @type self: koala.SortByFront.SortByFront """ try: galhtmlprefix = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="generator" content="Galaxy %s tool output" /> <title></title> <link rel="stylesheet" href="/static/koala.css" type="text/css" /> <link rel="stylesheet" href="/static/style/base.css" type="text/css" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> <script src="http://code.highcharts.com/highcharts.js"></script> <script src="http://code.highcharts.com/highcharts-more.js"></script> <script src="http://code.highcharts.com/modules/exporting.js"></script> <script type="text/javascript" src="/static/js/JSmol.min.js"></script> <script type="text/javascript"> Jmol._isAsync = false; Jmol.getProfile() var jmolApplet0; jmol_isReady = function(applet) { document.title = (applet._id + " is ready") Jmol._getElement(applet, "appletdiv").style.border="1px solid blue" } Info = { width: 400, height: 300, debug: false, color: "#F0F0F0", zIndexBase: 20000, z:{monitorZIndex:100}, addSelectionOptions: false, serverURL: "/static/js/php/jsmol.php", use: "HTML5", jarPath: "/static/js/java", j2sPath: "/static/js/j2s", jarFile: "JmolApplet.jar", isSigned: false, disableJ2SLoadMonitor: false, disableInitialConsole: false, readyFunction: jmol_isReady, allowjavascript: true, script: "set antialiasDisplay;set showtiming;load async /datasets/%s/display/%s;cartoons only;color cartoons structure; spin on" //,defaultModel: ":dopamine" //,noscript: true //console: "none", // default will be jmolApplet0_infodiv //script: "set antialiasDisplay;background white;load data/caffeine.mol;" //delay 3;background yellow;delay 0.1;background white;for (var i = 0; i < 10; i+=1){rotate y 3;delay 0.01}" } </script> </head> <body> <div class="toolFormBody">""" galhtmlpostfix = """</div></body></html>\n""" flist = os.listdir(self.opts.htmlfiledir) flist.sort() html = [] html.append(galhtmlprefix % (self.progname, self.opts.datasetID, pdbReference)) html.append('<div class="sucessmessage">') html.append('<br>') html.append('<h1 align="center">2PG Random Ab Initio Algorithm results</h1><br></div>') html.append('<br>') html.append('<div class="sectionmessage">') html.append('<br>Submitted Primary Sequence.<br><br></div>') html.append('<div class="code">') html.append('Length: %s<br>' % len(self.sequence)) html.append('%s<br></div>' % self.sequence) fhtml = [] fitFiles = [] outputfiles = [] compressedFile = [] imageFiles = [] if len(flist) > 0: for rownum, fname in enumerate(flist): dname, e = os.path.splitext(fname) sfsize = get_file_size(fname, self.opts.htmlfiledir) if e.lower() == ".fit": fitFiles.append(fname) elif e.lower() == ".png": imageFiles.append(fname) elif e.lower() in ".zip, .gz": compressedFile.append(fname) elif not e.lower() in self.ignoreoutfiles: outputfiles.append(fname) # Arquivos fit for fit in fitFiles: sfsize = get_file_size(fit, self.opts.htmlfiledir) fhtml.append('<tr>') fhtml.append('<td><a href="%s">%s</a></td>' % (fit, fit)) fhtml.append('<td>%s</td>' % (sfsize)) fhtml.append('</tr>') if len(fhtml) > 0: html.append('<br>') html.append('<div class="sectionmessage">') html.append('<br>Download Calculated values of selected Objectives.<br><br></div>') fhtml.insert( 0, '<div class="filetables"><table border="1"><tr><th>File</th>' '<th>Size</th></tr>\n') fhtml.append('</table></div><br>') html += fhtml fhtml = [] # images (e depois models) listaArquivosPdb = list_directory( self.path_runs.get_path_execution(), 'randomSolution-M*.pdb') if len(listaArquivosPdb) <= 20: size = int(len(listaArquivosPdb) / 5) rest = len(listaArquivosPdb) % 5 else: size = 4 # vai mostrar no máximo 20 imagens rest = 0 idx = 0 # controla indice das imagens e dos metodos start = 0 end = 5 # limite de colunas para uma linha if size < 1: n = len(listaArquivosPdb) fhtml.append('<tr>') idx_linha = idx for i in range(0, n): pdbName, ext = os.path.splitext(listaArquivosPdb[idx]) fhtml.append( '<td><a href="/datasets/%s/display/%s.png">' '<img src="/datasets/%s/display/%s.png" ' 'title="Click to see %s.png bigger" width="130"/></a></td>' % (self.opts.datasetID, pdbName, self.opts.datasetID, pdbName, pdbName)) idx += 1 idx = idx_linha fhtml.append('</tr><tr>') for i in range(0, n): fhtml.append( '<td><a href="/datasets/%s/display/%s">%s</a></td>' % ( self.opts.datasetID, listaArquivosPdb[idx], listaArquivosPdb[idx])) idx += 1 idx = idx_linha fhtml.append('</tr><tr>') for i in range(0, n): sfsize = get_file_size( listaArquivosPdb[idx], self.opts.htmlfiledir) fhtml.append('<td>%s</td>' % (sfsize)) idx += 1 idx = idx_linha fhtml.append('</tr><tr>') for i in range(0, n): fhtml.append( '<td>' '<a href="javascript:Jmol.script(jmolApplet0,' "'load /datasets/%s/display/%s;cartoons only; \ color cartoons structure; spin on')" '">Load on Jmol</a></td>' % ( self.opts.datasetID, listaArquivosPdb[idx])) idx += 1 idx = idx_linha else: for img in range(0, size): fhtml.append('<tr>') idx_linha = idx for i in range(start, end): pdbName, ext = os.path.splitext(listaArquivosPdb[idx]) fhtml.append( '<td><a href="/datasets/%s/display/%s.png">' '<img src="/datasets/%s/display/%s.png" ' 'title="Click to see %s.png bigger" width="130"/></a></td>' % (self.opts.datasetID, pdbName, self.opts.datasetID, pdbName, pdbName)) idx += 1 idx = idx_linha fhtml.append('</tr><tr>') for i in range(start, end): fhtml.append( '<td><a href="/datasets/%s/display/%s">%s</a></td>' % ( self.opts.datasetID, listaArquivosPdb[idx], listaArquivosPdb[idx])) idx += 1 idx = idx_linha fhtml.append('</tr><tr>') for i in range(start, end): sfsize = get_file_size( listaArquivosPdb[idx], self.opts.htmlfiledir) fhtml.append('<td>%s</td>' % (sfsize)) idx += 1 idx = idx_linha fhtml.append('</tr><tr>') for i in range(start, end): fhtml.append( '<td>' '<a href="javascript:Jmol.script(jmolApplet0,' "'load /datasets/%s/display/%s;cartoons only; \ color cartoons structure; spin on')" '">Load on Jmol</a></td>' % ( self.opts.datasetID, listaArquivosPdb[idx])) idx += 1 fhtml.append('<tr>') idx_linha = idx for i in range(0, rest): pdbName, ext = os.path.splitext(listaArquivosPdb[idx]) fhtml.append( '<td><a href="/datasets/%s/display/%s.png">' '<img src="/datasets/%s/display/%s.png" ' 'title="Click to see %s.png bigger" width="130"/></a></td>' % (self.opts.datasetID, pdbName, self.opts.datasetID, pdbName, pdbName)) idx += 1 idx = idx_linha fhtml.append('</tr><tr>') for i in range(0, rest): fhtml.append( '<td><a href="/datasets/%s/display/%s">%s</a></td>' % ( self.opts.datasetID, listaArquivosPdb[idx], listaArquivosPdb[idx])) idx += 1 idx = idx_linha fhtml.append('</tr><tr>') for i in range(0, rest): sfsize = get_file_size( listaArquivosPdb[idx], self.opts.htmlfiledir) fhtml.append('<td>%s</td>' % (sfsize)) idx += 1 idx = idx_linha fhtml.append('</tr><tr>') for i in range(0, rest): fhtml.append( '<td>' '<a href="javascript:Jmol.script(jmolApplet0,' "'load /datasets/%s/display/%s;cartoons only; \ color cartoons structure; spin on')" '">Load on Jmol</a></td>' % ( self.opts.datasetID, listaArquivosPdb[idx])) idx += 1 idx = idx_linha if len(fhtml) > 0: html.append('<br>') html.append('<div class="sectionmessage">') html.append('<br>Best Tertiary Structures<br>') html.append('<br></div>') model = '' if size < 1: for i in range(0, len(listaArquivosPdb)): model += '<th>Model</th>' else: model = '<th>Model</th>'\ '<th>Model</th>'\ '<th>Model</th>'\ '<th>Model</th>'\ '<th>Model</th>' fhtml.insert( 0, '<div class="filetables"><table border="1">' '<tr>' + model + '</tr>\n') fhtml.append('</table></div><br/>') # html += fhtml fhtml.append('<div class="jmol-applet">') fhtml.append('<script>') fhtml.append('jmolApplet0 = Jmol.getApplet("jmolApplet0", Info)') fhtml.append("var lastPrompt=0;") fhtml.append('</script></div>') html += fhtml fhtml = [] # Outros arquivos de output for output in outputfiles: sfsize = get_file_size(output, self.opts.htmlfiledir) fhtml.append('<tr>') fhtml.append('<td><a href="%s">%s</a></td>' % (output, output)) fhtml.append('<td>%s</td>' % (sfsize)) fhtml.append('</tr>') if len(fhtml) > 0: html.append('<br>') html.append('<div class="sectionmessage">') html.append('<br>Download the output files:<br><br></div>') fhtml.insert( 0, '<div class="filetables"><table border="1"><tr><th>Output File</th>' '<th>Size</th></tr>\n') fhtml.append('</table></div><br>') html += fhtml fhtml = [] # arquivo zipado for output in compressedFile: sfsize = get_file_size(output, self.opts.htmlfiledir) fhtml.append('<tr>') fhtml.append('<td><a href="%s">%s</a></td>' % (output, output)) fhtml.append('<td>%s</td>' % (sfsize)) fhtml.append('</tr>') if len(fhtml) > 0: html.append('<br>') html.append('<div class="sectionmessage">') html.append('<br>Compressed file with all the output files<br><br></div>') fhtml.insert( 0, '<div class="filetables"><table border="1"><tr><th>File</th>' '<th>Size</th></tr>\n') fhtml.append('</table></div><br>') html += fhtml self.time_execution.set_job_end(datetime.datetime.now()) self.endTime = datetime.datetime.now() dif = self.time_execution.calculate_time_execution() html.append('<div>Time execution:<br>') html.append('Start: %s<br>' % self.time_execution.get_job_start().strftime("%d/%m/%Y %H:%M:%S")) html.append('End: %s<br>' % self.time_execution.get_job_end().strftime("%d/%m/%Y %H:%M:%S")) html.append('Total time: ~%dh:%dm:%ds' % (dif[0], dif[1], dif[2])) html.append('</div>') html.append('<hr>') html.append('<div>Citation<br>') html.append('Please, cite the used algorithm in this tool:<br><br>') html.append('') html.append('<br></div>') html.append(galhtmlpostfix) htmlf = file("%s.htm" % os.path.join(self.opts.htmlfiledir, self.opts.datasetID), 'w') htmlf.write('\n'.join(html)) htmlf.write('\n') htmlf.close() except Exception, e: show_error_message("Error on makeHtmlWithJMol:\n%s" % str(e))
def makeHtml(self): """ Create an HTML file content to list all the artifacts found in the html_dir @type self: koala.SortMethodByFront.SortMethodByFront """ galhtmlprefix = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="generator" content="Galaxy %s tool output - see http://g2.trac.bx.psu.edu/" /> <title></title> <link rel="stylesheet" href="/static/koala.css" type="text/css" /> <link rel="stylesheet" href="/static/style/base.css" type="text/css" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> <script src="http://code.highcharts.com/highcharts.js"></script> <script src="http://code.highcharts.com/highcharts-more.js"></script> <script src="http://code.highcharts.com/modules/exporting.js"></script> </head> <body> <div class="toolFormBody">""" galhtmlpostfix = """</div></body></html>\n""" flist = os.listdir(self.opts.htmlfiledir) flist.sort() html = [] html.append(galhtmlprefix % self.progname) html.append('<div class="sucessmessage">') html.append('<br>') html.append('<h1 align="center">Sort Methods By Front Dominance results</h1><br></div>') html.append('<br>') html.append('<div class="sectionmessage">') html.append('<br>Below, there is a graph with the best solutions.<br><br></div>') html.append('<div id="container2" style="min-width: 310px; height: 400px; margin: 0 auto">') html.append('<script type="text/javascript">') html.append(str(self.buildHighchart())) html.append('</script></div><br>') fhtml = [] frontFiles = [] outputfiles = [] compressedFile = [] if len(flist) > 0: for rownum, fname in enumerate(flist): dname, e = os.path.splitext(fname) sfsize = get_file_size(fname, self.opts.htmlfiledir) if e.lower() == ".front": frontFiles.append(fname) elif e.lower() in ".zip, .gz": compressedFile.append(fname) elif not e.lower() in self.ignoreoutfiles: outputfiles.append(fname) # Arquivos front for front in frontFiles: sfsize = get_file_size(front, self.opts.htmlfiledir) fhtml.append('<tr>') fhtml.append('<td><a href="%s">%s</a></td>' % (front, front)) fhtml.append('<td>%s</td>' % (sfsize)) fhtml.append('</tr>') if len(fhtml) > 0: html.append('<br>') html.append('<div class="sectionmessage">') html.append('<br>Download Calculated fronts.<br><br></div>') fhtml.insert( 0, '<div class="filetables"><table border="1"><tr><th>File</th>' '<th>Size</th></tr>\n') fhtml.append('</table></div><br>') html += fhtml fhtml = [] # Outros arquivos de output for output in outputfiles: sfsize = get_file_size(output, self.opts.htmlfiledir) fhtml.append('<tr>') fhtml.append('<td><a href="%s">%s</a></td>' % (output, output)) fhtml.append('<td>%s</td>' % (sfsize)) fhtml.append('</tr>') if len(fhtml) > 0: html.append('<br>') html.append('<div class="sectionmessage">') html.append('<br>Download the output files:<br><br></div>') fhtml.insert( 0, '<div class="filetables"><table border="1"><tr><th>Output File</th>' '<th>Size</th></tr>\n') fhtml.append('</table></div><br>') html += fhtml fhtml = [] # arquivo zipado for output in compressedFile: sfsize = get_file_size(output, self.opts.htmlfiledir) fhtml.append('<tr>') fhtml.append('<td><a href="%s">%s</a></td>' % (output, output)) fhtml.append('<td>%s</td>' % (sfsize)) fhtml.append('</tr>') if len(fhtml) > 0: html.append('<br>') html.append('<div class="sectionmessage">') html.append('<br>Compressed file with all the output files<br><br></div>') fhtml.insert( 0, '<div class="filetables"><table border="1"><tr><th>File</th>' '<th>Size</th></tr>\n') fhtml.append('</table></div><br>') html += fhtml self.time_execution.set_job_end(datetime.datetime.now()) self.endTime = datetime.datetime.now() dif = self.time_execution.calculate_time_execution() html.append('<div>Time execution:<br>') html.append('Start: %s<br>' % self.time_execution.get_job_start().strftime("%d/%m/%Y %H:%M:%S")) html.append('End: %s<br>' % self.time_execution.get_job_end().strftime("%d/%m/%Y %H:%M:%S")) html.append('Total time: ~%dh:%dm:%ds' % (dif[0], dif[1], dif[2])) html.append('</div>') html.append(galhtmlpostfix) htmlf = file(self.opts.filehtml, 'w') htmlf.write('\n'.join(html)) htmlf.write('\n') htmlf.close()
def makeHtml(self): """ Create an HTML file content to list all the artifacts found in the html_dir @type self: koala.CalculateRMSD.CalculateRMSD """ try: galhtmlprefix = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="generator" content="Galaxy %s tool output - see http://g2.trac.bx.psu.edu/" /> <title></title> <link rel="stylesheet" href="/static/koala.css" type="text/css" /> <link rel="stylesheet" href="/static/style/base.css" type="text/css" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> <script src="http://code.highcharts.com/highcharts.js"></script> <script src="http://code.highcharts.com/highcharts-more.js"></script> <script src="http://code.highcharts.com/modules/exporting.js"></script> </head> <body> <div class="toolFormBody">""" galhtmlpostfix = """</div></body></html>\n""" flist = os.listdir(self.opts.htmlfiledir) html = [] html.append(galhtmlprefix % self.progname) html.append('<div class="sucessmessage">') html.append('<br>') html.append('<h1 align="center">RMSD results</h1><br></div>') html.append('<br>') html.append('<div class="sectionmessage">') html.append('<br>Below, there is a table with the RMSD values.<br><br></div>') html.append('<div class="filetables">') html.append('<table border="1"><tr><th>Model</th><th>RMSD-Score</th></tr>\n') html.append(str(self.buildRMSDTable())) html.append('</table></div><br/>') fhtml = [] frontFiles = [] outputfiles = [] compressedFile = [] imageFiles = [] if len(flist) > 0: for rownum, fname in enumerate(flist): dname, e = os.path.splitext(fname) sfsize = get_file_size(fname, self.opts.htmlfiledir) if e.lower() == ".front": frontFiles.append(fname) elif e.lower() == ".png": imageFiles.append(fname) elif e.lower() in ".zip, .gz": compressedFile.append(fname) elif not e.lower() in self.ignoreoutfiles: outputfiles.append(fname) # Arquivos front for front in frontFiles: sfsize = get_file_size(front, self.opts.htmlfiledir) fhtml.append('<tr>') fhtml.append('<td><a href="%s">%s</a></td>' % (front, front)) fhtml.append('<td>%s</td>' % (sfsize)) fhtml.append('</tr>') if len(fhtml) > 0: html.append('<br>') html.append('<div class="sectionmessage">') html.append('<br>Download Calculated fronts.<br><br></div>') fhtml.insert( 0, '<div class="filetables"><table border="1"><tr><th>File</th>' '<th>Size</th></tr>\n') fhtml.append('</table></div><br>') html += fhtml fhtml = [] # images (e depois models) listaArquivosPdb = self.methods if len(listaArquivosPdb) <= 20: # mostra tudo size = int(len(listaArquivosPdb) / 5) rest = len(listaArquivosPdb) % 5 else: size = 4 # vai mostrar no máximo 20 imagens rest = 0 idx = 0 # controla indice das imagens e dos metodos start = 0 end = 5 # limite de colunas para uma linha if size < 1: n = len(listaArquivosPdb) fhtml.append('<tr>') idx_linha = idx for i in range(0, n): fhtml.append( '<td><a href="%s"><img src="%s" ' 'title="Click to see %s bigger" width="130"/></a></td>' % (imageFiles[idx], imageFiles[idx], imageFiles[idx])) idx += 1 idx = idx_linha fhtml.append('</tr><tr>') for i in range(0, n): fhtml.append( '<td><a href="%s">%s</a></td>' % ( listaArquivosPdb[idx], listaArquivosPdb[idx])) idx += 1 idx = idx_linha fhtml.append('</tr><tr>') for i in range(0, n): sfsize = get_file_size( listaArquivosPdb[idx], self.opts.htmlfiledir) fhtml.append('<td>%s</td>' % (sfsize)) idx += 1 idx = idx_linha fhtml.append('</tr>') else: for img in range(0, size): fhtml.append('<tr>') idx_linha = idx for i in range(start, end): fhtml.append( '<td><a href="%s"><img src="%s" ' 'title="Click to see %s bigger" width="130"/></a></td>' % (imageFiles[idx], imageFiles[idx], imageFiles[idx])) idx += 1 idx = idx_linha fhtml.append('</tr><tr>') for i in range(start, end): fhtml.append( '<td><a href="%s">%s</a></td>' % ( listaArquivosPdb[idx], listaArquivosPdb[idx])) idx += 1 idx = idx_linha fhtml.append('</tr><tr>') for i in range(start, end): sfsize = get_file_size( listaArquivosPdb[idx], self.opts.htmlfiledir) fhtml.append('<td>%s</td>' % (sfsize)) idx += 1 fhtml.append('</tr>') fhtml.append('<tr>') idx_linha = idx for i in range(0, rest): fhtml.append( '<td><a href="%s"><img src="%s" ' 'title="Click to see %s bigger" width="130"/></a></td>' % (imageFiles[idx], imageFiles[idx], imageFiles[idx])) idx += 1 idx = idx_linha fhtml.append('</tr><tr>') for i in range(0, rest): fhtml.append( '<td><a href="%s">%s</a></td>' % ( listaArquivosPdb[idx], listaArquivosPdb[idx])) idx += 1 idx = idx_linha fhtml.append('</tr><tr>') for i in range(0, rest): sfsize = get_file_size( listaArquivosPdb[idx], self.opts.htmlfiledir) fhtml.append('<td>%s</td>' % (sfsize)) idx += 1 idx = idx_linha fhtml.append('</tr>') if len(fhtml) > 0: html.append('<br>') html.append('<div class="sectionmessage">') html.append('<br>Best Tertiary Structures<br>') html.append('<br></div>') if(self.opts.useJmol == 'true'): html.append('<div class="active-jmol">') html.append('<br>') html.append( '<a href=/datasets/%s/display/%s.htm>Activate JMol</a>' % ( self.opts.datasetID, self.opts.datasetID)) html.append('<br></div>') model = '' if size < 1: for i in range(0, len(listaArquivosPdb)): model += '<th>Model</th>' else: model = '<th>Model</th>'\ '<th>Model</th>'\ '<th>Model</th>'\ '<th>Model</th>'\ '<th>Model</th>' fhtml.insert( 0, '<div class="filetables"><table border="1">' '<tr>' + model + '</tr>\n') fhtml.append('</table></div><br/>') html += fhtml fhtml = [] # Outros arquivos de output for output in outputfiles: sfsize = get_file_size(output, self.opts.htmlfiledir) fhtml.append('<tr>') fhtml.append('<td><a href="%s">%s</a></td>' % (output, output)) fhtml.append('<td>%s</td>' % (sfsize)) fhtml.append('</tr>') if len(fhtml) > 0: html.append('<br>') html.append('<div class="sectionmessage">') html.append('<br>Download the output files:<br><br></div>') fhtml.insert( 0, '<div class="filetables"><table border="1"><tr><th>Output File</th>' '<th>Size</th></tr>\n') fhtml.append('</table></div><br>') html += fhtml fhtml = [] # arquivo zipado for output in compressedFile: sfsize = get_file_size(output, self.opts.htmlfiledir) fhtml.append('<tr>') fhtml.append('<td><a href="%s">%s</a></td>' % (output, output)) fhtml.append('<td>%s</td>' % (sfsize)) fhtml.append('</tr>') if len(fhtml) > 0: html.append('<br>') html.append('<div class="sectionmessage">') html.append('<br>Compressed file with all the output files<br><br></div>') fhtml.insert( 0, '<div class="filetables"><table border="1"><tr><th>File</th>' '<th>Size</th></tr>\n') fhtml.append('</table></div><br>') html += fhtml self.time_execution.set_job_end(datetime.datetime.now()) self.endTime = datetime.datetime.now() dif = self.time_execution.calculate_time_execution() html.append('<div>Time execution:<br>') html.append('Start: %s<br>' % self.time_execution.get_job_start().strftime("%d/%m/%Y %H:%M:%S")) html.append('End: %s<br>' % self.time_execution.get_job_end().strftime("%d/%m/%Y %H:%M:%S")) html.append('Total time: ~%dh:%dm:%ds' % (dif[0], dif[1], dif[2])) html.append('</div>') html.append('<hr>') html.append('<div>Citation<br>') html.append('This tool uses the g_rms program, part of GROMACS package.<br>') html.append('Please, cite the used algorithm in this tool:<br><br>') html.append('Van Der Spoel, D., Lindahl, E., Hess, B., Groenhof, G., Mark, ' 'A. E. and Berendsen, H. J. C., GROMACS: Fast, flexible, and free. J. ' 'Comput. Chem., 1701–1718. 2005') html.append('<br></div>') html.append(galhtmlpostfix) htmlf = file(self.opts.filehtml, 'w') htmlf.write('\n'.join(html)) htmlf.write('\n') htmlf.close() except Exception, e: show_error_message("Error on makeHtml: \n%s" % e)
def makeHtml(self): """ Create an HTML file content to list all the artifacts found in the html_dir @type self: koala.DominanceRanking.DominanceRanking """ galhtmlprefix = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="generator" content="Galaxy %s tool output - see http://g2.trac.bx.psu.edu/" /> <title></title> <link rel="stylesheet" href="/static/koala.css" type="text/css" /> <link rel="stylesheet" href="/static/style/base.css" type="text/css" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> <script src="http://code.highcharts.com/highcharts.js"></script> <script src="http://code.highcharts.com/highcharts-more.js"></script> <script src="http://code.highcharts.com/modules/exporting.js"></script> </head> <body> <div class="toolFormBody">""" galhtmlpostfix = """</div></body></html>\n""" flist = os.listdir(self.opts.htmlfiledir) flist.sort() html = [] html.append(galhtmlprefix % self.progname) html.append('<br>') html.append('<div class="sucessmessage">') html.append('<br>') html.append('<h1 align="center">Dominance Ranking results</h1><br></div>') html.append('<br>') html.append('<div class="sectionmessage">') html.append( '<br>Below, there is a table with the result of dominance ranking.<br><br></div>') html.append('<div class="filetables">') html.append('<table border="1">' '<tr>' '<th>Model</th>' '<th>Dominance</th>' '<th>Wins</th>' '<th>Loses</th>' '<th>Percentage Wins</th>' '</tr>\n') html.append(str(self.buildDominanceRankingTable())) html.append('</table></div><br/>') html.append('<br>') html.append('<div class="sectionmessage">') html.append( '<br> A graph with the best solutions for each objectivies combination.<br><br></div>') for i, fit in enumerate(self.combinations): html.append( '<div id="container%s" style="min-width: ' '310px; height: 400px; margin: 0 auto">' % i) html.append('<script type="text/javascript">') html.append(str(self.build_Highchart(fit, "container%s" % i))) html.append('</script></div><br>') fhtml = [] frontFiles = [] outputfiles = [] compressedFile = [] imageFiles = [] if len(flist) > 0: for rownum, fname in enumerate(flist): dname, e = os.path.splitext(fname) sfsize = get_file_size(fname, self.opts.htmlfiledir) if e.lower() == ".front": frontFiles.append(fname) elif e.lower() == ".png": imageFiles.append(fname) elif e.lower() in ".zip, .gz": compressedFile.append(fname) elif not e.lower() in self.ignoreoutfiles: outputfiles.append(fname) # Arquivos front for front in frontFiles: sfsize = get_file_size(front, self.opts.htmlfiledir) fhtml.append('<tr>') fhtml.append('<td><a href="%s">%s</a></td>' % (front, front)) fhtml.append('<td>%s</td>' % (sfsize)) fhtml.append('</tr>') if len(fhtml) > 0: html.append('<br>') html.append('<div class="sectionmessage">') html.append('<br>Download Calculated fronts.<br><br></div>') fhtml.insert( 0, '<div class="filetables"><table border="1"><tr><th>File</th>' '<th>Size</th></tr>\n') fhtml.append('</table></div><br>') html += fhtml fhtml = [] # images (e depois models) listaArquivosPdb = self.methods if len(listaArquivosPdb) <= 20: size = int(len(listaArquivosPdb) / 5) rest = len(listaArquivosPdb) % 5 else: size = 4 # vai mostrar no máximo 20 imagens rest = 0 idx = 0 # controla indice das imagens e dos metodos start = 0 end = 5 # limite de colunas para uma linha if size < 1: n = len(listaArquivosPdb) fhtml.append('<tr>') idx_linha = idx for i in range(0, n): fhtml.append( '<td><a href="%s"><img src="%s" ' 'title="Click to see %s bigger" width="130"/></a></td>' % (imageFiles[idx], imageFiles[idx], imageFiles[idx])) idx += 1 idx = idx_linha fhtml.append('</tr><tr>') for i in range(0, n): fhtml.append( '<td><a href="%s">%s</a></td>' % ( listaArquivosPdb[idx], listaArquivosPdb[idx])) idx += 1 idx = idx_linha fhtml.append('</tr><tr>') for i in range(0, n): sfsize = get_file_size( listaArquivosPdb[idx], self.opts.htmlfiledir) fhtml.append('<td>%s</td>' % (sfsize)) idx += 1 idx = idx_linha fhtml.append('</tr>') else: for img in range(0, size): fhtml.append('<tr>') idx_linha = idx for i in range(start, end): fhtml.append( '<td><a href="%s"><img src="%s" ' 'title="Click to see %s bigger" width="130"/></a></td>' % (imageFiles[idx], imageFiles[idx], imageFiles[idx])) idx += 1 idx = idx_linha fhtml.append('</tr><tr>') for i in range(start, end): fhtml.append( '<td><a href="%s">%s</a></td>' % ( listaArquivosPdb[idx], listaArquivosPdb[idx])) idx += 1 idx = idx_linha fhtml.append('</tr><tr>') for i in range(start, end): sfsize = get_file_size( listaArquivosPdb[idx], self.opts.htmlfiledir) fhtml.append('<td>%s</td>' % (sfsize)) idx += 1 fhtml.append('</tr>') fhtml.append('<tr>') idx_linha = idx for i in range(0, rest): fhtml.append( '<td><a href="%s"><img src="%s" ' 'title="Click to see %s bigger" width="130"/></a></td>' % (imageFiles[idx], imageFiles[idx], imageFiles[idx])) idx += 1 idx = idx_linha fhtml.append('</tr><tr>') for i in range(0, rest): fhtml.append( '<td><a href="%s">%s</a></td>' % ( listaArquivosPdb[idx], listaArquivosPdb[idx])) idx += 1 idx = idx_linha fhtml.append('</tr><tr>') for i in range(0, rest): sfsize = get_file_size( listaArquivosPdb[idx], self.opts.htmlfiledir) fhtml.append('<td>%s</td>' % (sfsize)) idx += 1 idx = idx_linha fhtml.append('</tr>') if len(fhtml) > 0: html.append('<br>') html.append('<div class="sectionmessage">') html.append('<br>Best Tertiary Structures<br>') html.append('<br></div>') if(self.opts.useJmol == 'true'): html.append('<div class="active-jmol">') html.append('<br>') html.append( '<a href=/datasets/%s/display/%s.htm>Activate JMol</a>' % ( self.opts.datasetID, self.opts.datasetID)) html.append('<br></div>') model = '' if size < 1: for i in range(0, len(listaArquivosPdb)): model += '<th>Model</th>' else: model = '<th>Model</th>'\ '<th>Model</th>'\ '<th>Model</th>'\ '<th>Model</th>'\ '<th>Model</th>' fhtml.insert( 0, '<div class="filetables"><table border="1">' '<tr>' + model + '</tr>\n') fhtml.append('</table></div><br/>') html += fhtml fhtml = [] # Outros arquivos de output for output in outputfiles: sfsize = get_file_size(output, self.opts.htmlfiledir) fhtml.append('<tr>') fhtml.append('<td><a href="%s">%s</a></td>' % (output, output)) fhtml.append('<td>%s</td>' % (sfsize)) fhtml.append('</tr>') if len(fhtml) > 0: html.append('<br>') html.append('<div class="sectionmessage">') html.append('<br>Download the output files:<br><br></div>') fhtml.insert( 0, '<div class="filetables"><table border="1"><tr><th>Output File</th>' '<th>Size</th></tr>\n') fhtml.append('</table></div><br>') html += fhtml fhtml = [] # arquivo zipado for output in compressedFile: sfsize = get_file_size(output, self.opts.htmlfiledir) fhtml.append('<tr>') fhtml.append('<td><a href="%s">%s</a></td>' % (output, output)) fhtml.append('<td>%s</td>' % (sfsize)) fhtml.append('</tr>') if len(fhtml) > 0: html.append('<br>') html.append('<div class="sectionmessage">') html.append('<br>Compressed file with all the output files<br><br></div>') fhtml.insert( 0, '<div class="filetables"><table border="1"><tr><th>File</th>' '<th>Size</th></tr>\n') fhtml.append('</table></div><br>') html += fhtml self.time_execution.set_job_end(datetime.datetime.now()) self.endTime = datetime.datetime.now() dif = self.time_execution.calculate_time_execution() html.append('<div>Time execution:<br>') html.append('Start: %s<br>' % self.time_execution.get_job_start().strftime("%d/%m/%Y %H:%M:%S")) html.append('End: %s<br>' % self.time_execution.get_job_end().strftime("%d/%m/%Y %H:%M:%S")) html.append('Total time: ~%dh:%dm:%ds' % (dif[0], dif[1], dif[2])) html.append('</div>') html.append(galhtmlpostfix) htmlf = file(self.opts.filehtml, 'w') htmlf.write('\n'.join(html)) htmlf.write('\n') htmlf.close()