Ejemplo n.º 1
0
 def fix_fastqc(self, rep=[], flist=[], runlog=[]):
     """ add some of our stuff to the html
     """
     bodyindex = len(rep) - 1  # hope they don't change this
     footrow = bodyindex - 1
     footer = rep[footrow]
     rep = rep[:footrow] + rep[footrow + 1:]
     res = [
         '<div class="module"><h2>Files created by FastQC</h2><table cellspacing="2" cellpadding="2">\n'
     ]
     flist.sort()
     for i, f in enumerate(flist):
         if not (os.path.isdir(f)):
             fn = os.path.split(f)[-1]
             res.append('<tr><td><a href="%s">%s</a></td></tr>\n' %
                        (fn, getFileString(fn, self.opts.outputdir)))
     res.append('</table>\n')
     res.append(
         '<a href="http://www.bioinformatics.bbsrc.ac.uk/projects/fastqc/">FastQC documentation and full attribution is here</a><br/><hr/>\n'
     )
     res.append(
         'FastQC was run by Galaxy using the rgenetics rgFastQC wrapper - see http://rgenetics.org for details and licensing\n</div>'
     )
     res.append(footer)
     fixed = rep[:bodyindex] + res + rep[bodyindex:]
     return fixed  # with our additions
Ejemplo n.º 2
0
 def write_html_report(self):
     """
     write the report as html
     """
     
     out_folder = self.opts.outdir
     my_template = Template(
         filename=os.path.join(self.tool_folder, self.__class__.HTML_REPORT_TEMPLATE), 
         strict_undefined=True)
     
     if os.path.exists(os.path.abspath(out_folder)):
         files = [os.path.join(out_folder, x) for x in os.listdir(out_folder) 
                  if not x.startswith('.')]
         files.sort(key=lambda f: os.path.getmtime(f))
         file_info = [(os.path.split(f)[-1], getFileString(os.path.split(f)[-1], self.opts.outdir))
                      for f in files]
     else:
         file_info = []
           
     template_parameters = {
         'program_name': str(self.program_name), 
         'timestamp' : str(timenow()),
         'file_info': file_info,
         'log_data' : open(self.tlogname).read().replace('\n', '\n<BR />'),
         'command_string': str(self.cl)
         }
         
     f = open(self.opts.htmlout, 'w')
     f.write(my_template.render(**template_parameters))
     f.close()
 def makehtml(self):
     """
     write the report as html
     """
     logdat = open(self.tlogname,'r').readlines()
     res = []
     res.append(galhtmlprefix % progname)
     res.append(galhtmlattr % (progname,timenow()))
     res.append('<b>Your job produced the following outputs - check here for a record of what was done and any unexpected events</b><hr/>')
     try:
         flist = os.listdir(self.opts.outdir)
     except:
         flist = []
     if len(flist) > 0: # show what's left
         flist = [x for x in flist if not (x.startswith('.') or x == 'None')]
         tlist = [(os.path.getmtime(os.path.join(self.opts.outdir,x)),x) for x in flist]
         tlist.sort()
         flist = [x[1] for x in tlist]
         res.append('<div><b>Output files.</b><hr/>\n')
         res.append('<table>\n')
         for i,f in enumerate(flist):
             fn = os.path.split(f)[-1]
             fs = getFileString(fn,self.opts.outdir)
             res.append('<tr><td><a href="%s">%s</a></td></tr>\n' % (fn,fs))
         res.append('</table></div>\n')
     res.append('<b>Log of activity</b><hr/>\n')
     res.append('\n%s' % '<br/>'.join(logdat))
     res.append('<hr/>Note: The freely available <a href="http://picard.sourceforge.net/command-line-overview.shtml">Picard software</a> \n')
     res.append('generated all outputs reported here. These third party tools were')
     res.append('orchestrated by the Galaxy rgEstLibComplexity wrapper and this command line from the Galaxy form:<br/>\n%s' % (self.cl))
     res.append(galhtmlpostfix)
     f = open(self.opts.htmlout,'w')
     f.write('\n'.join(res))
     f.close()
Ejemplo n.º 4
0
 def fix_fastqc(self, rep=[], flist=[], runlog=[]):
     """ add some of our stuff to the html
     """
     bs = '</body></html>\n'  # hope they don't change this
     try:
         bodyindex = rep.index(bs)  # hope they don't change this
     except:
         bodyindex = len(rep) - 1
     res = []
     res.append('<table>\n')
     flist.sort()
     for i, f in enumerate(flist):
         if not (os.path.isdir(f)):
             fn = os.path.split(f)[-1]
             res.append('<tr><td><a href="%s">%s</a></td></tr>\n' %
                        (fn, getFileString(fn, self.opts.outputdir)))
     res.append('</table><p/>\n')
     res.append(
         '<a href="http://www.bioinformatics.bbsrc.ac.uk/projects/fastqc/">FastQC documentation and full attribution is here</a><br/><hr/>\n'
     )
     res.append(
         'FastQC was run by Galaxy using the rgenetics rgFastQC wrapper - see http://rgenetics.org for details and licensing\n'
     )
     fixed = rep[:bodyindex] + res + rep[bodyindex:]
     return fixed  # with our additions
Ejemplo n.º 5
0
    def write_html_report(self):
        """
        write the report as html
        """

        out_folder = self.opts.outdir
        my_template = Template(filename=os.path.join(
            self.tool_folder, self.__class__.HTML_REPORT_TEMPLATE),
                               strict_undefined=True)

        if os.path.exists(os.path.abspath(out_folder)):
            files = [
                os.path.join(out_folder, x) for x in os.listdir(out_folder)
                if not x.startswith('.')
            ]
            files.sort(key=lambda f: os.path.getmtime(f))
            file_info = [
                (os.path.split(f)[-1],
                 getFileString(os.path.split(f)[-1], self.opts.outdir))
                for f in files
            ]
        else:
            file_info = []

        template_parameters = {
            'program_name': str(self.program_name),
            'timestamp': str(timenow()),
            'file_info': file_info,
            'log_data': open(self.tlogname).read().replace('\n', '\n<BR />'),
            'command_string': str(self.cl)
        }

        f = open(self.opts.htmlout, 'w')
        f.write(my_template.render(**template_parameters))
        f.close()
 def makehtml(self):
     """
     write the report as html
     """
     logdat = open(self.tlogname, 'r').readlines()
     res = []
     res.append(galhtmlprefix % progname)
     res.append(galhtmlattr % (progname, timenow()))
     res.append(
         '<b>Your job produced the following outputs - check here for a record of what was done and any unexpected events</b><hr/>'
     )
     imghref = '%s.jpg' % os.path.splitext(self.isPDF)[0]  # removes .pdf
     res.append('<table cellpadding="10"><tr><td>\n')
     res.append(
         '<a href="%s"><img src="%s" alt="%s" hspace="10" align="middle"></a>\n'
         % (self.isPDF, imghref, imghref))
     res.append('</tr><td></table>\n')
     try:
         flist = os.listdir(self.opts.outdir)
     except:
         flist = []
     if len(
             flist
     ) > 0:  # we should clean everything up - picard doesn't tell us what it did in cleansam unfortunately
         flist = [
             x for x in flist if not (x.startswith('.') or x == 'None')
         ]
         tlist = [(os.path.getmtime(os.path.join(self.opts.outdir, x)), x)
                  for x in flist]
         tlist.sort()
         flist = [x[1] for x in tlist]
         res.append('<div><b>Output files.</b><hr/>\n')
         res.append('<table>\n')
         for i, f in enumerate(flist):
             fn = os.path.split(f)[-1]
             fs = getFileString(fn, self.opts.outdir)
             res.append('<tr><td><a href="%s">%s</a></td></tr>\n' %
                        (fn, fs))
         res.append('</table></div>\n')
     res.append('<b>Log of activity</b><hr/>\n')
     res.append('\n%s' % '<br/>'.join(logdat))
     res.append(
         '<hr/>Note: The freely available <a href="http://picard.sourceforge.net/command-line-overview.shtml">Picard software</a> \n'
     )
     res.append(
         'generated all outputs reported here. These third party tools were'
     )
     res.append(
         'orchestrated by the Galaxy rgInsertSize wrapper and this command line from the Galaxy form:<br/>\n%s'
         % (self.cl))
     res.append(galhtmlpostfix)
     f = open(self.opts.htmlout, 'w')
     f.write('\n'.join(res))
     f.close()
Ejemplo n.º 7
0
 def writehtml(self):
     """
     write the report as html
     """
     logdat = open(self.tlogname,'r').readlines()
     res = []
     res.append(galhtmlprefix % progname)
     res.append(galhtmlattr % (progname,timenow()))
     try:
         flist = os.listdir(self.opts.outdir)
     except:
         flist = []
     if len(flist) > 0: # show what's left
         flist = [x for x in flist if not (x.startswith('.') or x == 'None')]
         pdfs = [x for x in flist if os.path.splitext(x)[-1].lower() == '.pdf']
         tlist = [(os.path.getmtime(os.path.join(self.opts.outdir,x)),x) for x in flist]
         tlist.sort()
         flist = [x[1] for x in tlist]
         if len(pdfs) > 0:
             cells = []
             pdfs.sort()
             res.append('<div><table cellpadding="5" cellspacing="10">\n')
             for p in pdfs:                           
                 pfname = os.path.split(p)[-1]
                 pfroot = os.path.splitext(pfname)[0]
                 imghref = '%s.jpg' % pfroot # thumbnail name from mogrify
                 cl = ['mogrify', '-resize x300 -write %s %s' % (imghref,pfname),]
                 self.run(cl)
                 s = '<a href="%s"><img src="%s" title="%s" hspace="10" align="middle"></a>' % (pfname,imghref,pfname)
                 cells.append('<td>%s</br>%s</td>' % (pfroot,s))
             ncells = len(cells)
             for i in range(ncells):
                 if i % 2 == 1:
                     res.append('<tr>%s%s</tr>\n' % (cells[i-1],cells[i])) 
             if ncells % 2 == 0: # last one
                     res.append('<tr colspan="2">%s</tr>\n' % (cells[-1]))                     
             res.append('</table></div>\n')
         res.append('<div><b>Output files.</b><hr/>\n')
         res.append('<table>\n')
         for i,f in enumerate(flist):
             fn = os.path.split(f)[-1]
             fs = getFileString(fn,self.opts.outdir)
             res.append('<tr><td><a href="%s">%s</a></td></tr>\n' % (fn,fs))
         res.append('</table></div>\n')
     res.append('<b>Your job produced the following log of activity - check here for a record of what was done and any unexpected events</b><hr/>')
     res.append('\n%s' % '<br/>'.join(logdat))
     res.append('<hr/>Note: The freely available <a href="http://www.broadinstitute.org/gsa/wiki/index.php/Main_Page">GATK</a> \n')
     res.append('did all the work reportexampleBAM.bam ed here. GATK is an independent non-Galaxy community resource, whose third party tools were')
     res.append('orchestrated by the Galaxy rgGATKRecalibrate wrapper and this command line from the Galaxy form:<br/>\n%s' % (self.cl))
     res.append(galhtmlpostfix)
     f = open(self.opts.htmlout,'w')
     f.write('\n'.join(res))
     f.close()
 def writehtml(self):
     """
     write the report as html
     """
     logdat = open(self.tlogname,'r').readlines()
     res = []
     res.append(galhtmlprefix % progname)
     res.append(galhtmlattr % (progname,timenow()))
     try:
         flist = os.listdir(self.opts.outdir)
     except:
         flist = []
     if len(flist) > 0: # show what's left
         flist = [x for x in flist if not (x.startswith('.') or x == 'None')]
         pdfs = [x for x in flist if os.path.splitext(x)[-1].lower() == '.pdf']
         tlist = [(os.path.getmtime(os.path.join(self.opts.outdir,x)),x) for x in flist]
         tlist.sort()
         flist = [x[1] for x in tlist]
         if len(pdfs) > 0:
             cells = []
             pdfs.sort()
             res.append('<div><table cellpadding="5" cellspacing="10">\n')
             for p in pdfs:                           
                 pfname = os.path.split(p)[-1]
                 pfroot = os.path.splitext(pfname)[0]
                 imghref = '%s.jpg' % pfroot # thumbnail name from mogrify
                 cl = ['mogrify', '-resize x300 -write %s %s' % (imghref,pfname),]
                 self.run(cl)
                 s = '<a href="%s"><img src="%s" alt="%s" hspace="10" align="middle"></a>' % (pfname,imghref,pfname)
                 cells.append('<td>%s</br>%s</td>' % (pfroot,s))
             ncells = len(cells)
             for i in range(ncells):
                 if i % 2 == 1:
                     res.append('<tr>%s%s</tr>\n' % (cells[i-1],cells[i])) 
             if ncells % 2 == 0: # last one
                     res.append('<tr colspan="2">%s</tr>\n' % (cells[-1]))                     
             res.append('</table></div>\n')
         res.append('<div><b>Output files.</b><hr/>\n')
         res.append('<table>\n')
         for i,f in enumerate(flist):
             fn = os.path.split(f)[-1]
             fs = getFileString(fn,self.opts.outdir)
             res.append('<tr><td><a href="%s">%s</a></td></tr>\n' % (fn,fs))
         res.append('</table></div>\n')
     res.append('<b>Your job produced the following log of activity - check here for a record of what was done and any unexpected events</b><hr/>')
     res.append('\n%s' % '<br/>'.join(logdat))
     res.append('<hr/>Note: The freely available <a href="http://www.broadinstitute.org/gsa/wiki/index.php/Main_Page">GATK</a> \n')
     res.append('did all the work reportexampleBAM.bam ed here. GATK is an independent non-Galaxy community resource, whose third party tools were')
     res.append('orchestrated by the Galaxy rgGATKRecalibrate wrapper and this command line from the Galaxy form:<br/>\n%s' % (self.cl))
     res.append(galhtmlpostfix)
     f = open(self.opts.htmlout,'w')
     f.write('\n'.join(res))
     f.close()
Ejemplo n.º 9
0
 def writehtml(self):
     """
     write the report as html
     note complications needed to write pre and post reports - they have to be separated since gatk insists on giving them all the same names
     but at least allows a separate output directory...
     """
     logdat = open(self.tlogname, 'r').readlines()
     res = []
     res.append(galhtmlprefix % progname)
     res.append(galhtmlattr % (progname, timenow()))
     res.append(
         '<font size="-2">Note: The freely available <a href="http://www.broadinstitute.org/gsa/wiki/index.php/Main_Page">GATK</a>'
     )
     res.append(
         'did all the calculations arranged here in your Galaxy history')
     try:
         flist = os.listdir(self.opts.outdir)
     except:
         flist = []
     if len(flist) > 0:  # show what's left after cleanup
         flist = [
             x for x in flist if not (x.startswith('.') or x == 'None')
         ]
         pdfs = [
             x for x in flist if os.path.splitext(x)[-1].lower() == '.pdf'
         ]
         tlist = [(os.path.getmtime(os.path.join(self.opts.outdir, x)), x)
                  for x in flist]
         tlist.sort()
         flist = [x[1] for x in tlist]
         if len(pdfs) > 0:
             res = self.writeImages(pdfs, res)
         res.append('<div><b>Output files.</b><hr/>\n')
         res.append('<table>\n')
         for i, f in enumerate(flist):
             fn = os.path.split(f)[-1]
             fs = getFileString(fn, self.opts.outdir)
             res.append('<tr><td><a href="%s">%s</a></td></tr>\n' %
                        (fn, fs))
         res.append('</table></div>\n')
     res.append(
         '<b>Your job produced the following log of activity - check here for a record of what was done and any unexpected events</b><hr/>'
     )
     res.append('\n%s' % '<br/>'.join(logdat))
     res.append(galhtmlpostfix)
     f = open(self.opts.htmlout, 'w')
     f.write('\n'.join(res))
     f.close()
Ejemplo n.º 10
0
 def fix_fastqc(self,rep=[],flist=[],runlog=[]):
     """ add some of our stuff to the html
     """
     bodyindex = len(rep) -1  # hope they don't change this
     footrow = bodyindex - 1 
     footer = rep[footrow]
     rep = rep[:footrow] + rep[footrow+1:]
     res = ['<div class="module"><h2>Files created by FastQC</h2><table cellspacing="2" cellpadding="2">\n']
     flist.sort()
     for i,f in enumerate(flist):
          if not(os.path.isdir(f)):
              fn = os.path.split(f)[-1]
              res.append('<tr><td><a href="%s">%s</a></td></tr>\n' % (fn,getFileString(fn, self.opts.outputdir)))
     res.append('</table>\n') 
     res.append('<a href="http://www.bioinformatics.bbsrc.ac.uk/projects/fastqc/">FastQC documentation and full attribution is here</a><br/><hr/>\n')
     res.append('FastQC was run by Galaxy using the rgenetics rgFastQC wrapper - see http://rgenetics.org for details and licensing\n</div>')
     res.append(footer)
     fixed = rep[:bodyindex] + res + rep[bodyindex:]
     return fixed # with our additions
Ejemplo n.º 11
0
 def fix_fastqc(self,rep=[],flist=[],runlog=[]):
     """ add some of our stuff to the html
     """
     bs = '</body></html>\n' # hope they don't change this
     try:
         bodyindex = rep.index(bs) # hope they don't change this
     except:
         bodyindex = len(rep) - 1
     res = []
     res.append('<table>\n')
     flist.sort()
     for i,f in enumerate(flist):
          if not(os.path.isdir(f)):
              fn = os.path.split(f)[-1]
              res.append('<tr><td><a href="%s">%s</a></td></tr>\n' % (fn,getFileString(fn, self.opts.outputdir)))
     res.append('</table><p/>\n') 
     res.append('<a href="http://www.bioinformatics.bbsrc.ac.uk/projects/fastqc/">FastQC documentation and full attribution is here</a><br/><hr/>\n')
     res.append('FastQC was run by Galaxy using the rgenetics rgFastQC wrapper - see http://rgenetics.org for details and licensing\n')
     fixed = rep[:bodyindex] + res + rep[bodyindex:]
     return fixed # with our additions
 def writehtml(self):
     """
     write the report as html
     note complications needed to write pre and post reports - they have to be separated since gatk insists on giving them all the same names
     but at least allows a separate output directory...
     """
     logdat = open(self.tlogname, "r").readlines()
     res = []
     res.append(galhtmlprefix % progname)
     res.append(galhtmlattr % (progname, timenow()))
     res.append(
         '<font size="-2">Note: The freely available <a href="http://www.broadinstitute.org/gsa/wiki/index.php/Main_Page">GATK</a>'
     )
     res.append("did all the calculations arranged here in your Galaxy history")
     try:
         flist = os.listdir(self.opts.outdir)
     except:
         flist = []
     if len(flist) > 0:  # show what's left after cleanup
         flist = [x for x in flist if not (x.startswith(".") or x == "None")]
         pdfs = [x for x in flist if os.path.splitext(x)[-1].lower() == ".pdf"]
         tlist = [(os.path.getmtime(os.path.join(self.opts.outdir, x)), x) for x in flist]
         tlist.sort()
         flist = [x[1] for x in tlist]
         if len(pdfs) > 0:
             res = self.writeImages(pdfs, res)
         res.append("<div><b>Output files.</b><hr/>\n")
         res.append("<table>\n")
         for i, f in enumerate(flist):
             fn = os.path.split(f)[-1]
             fs = getFileString(fn, self.opts.outdir)
             res.append('<tr><td><a href="%s">%s</a></td></tr>\n' % (fn, fs))
         res.append("</table></div>\n")
     res.append(
         "<b>Your job produced the following log of activity - check here for a record of what was done and any unexpected events</b><hr/>"
     )
     res.append("\n%s" % "<br/>".join(logdat))
     res.append(galhtmlpostfix)
     f = open(self.opts.htmlout, "w")
     f.write("\n".join(res))
     f.close()
 def makehtml(self):
     """
     write the report as html
     """
     logdat = open(self.tlogname,'r').readlines()
     res = []
     res.append(galhtmlprefix % progname)
     res.append(galhtmlattr % (progname,timenow()))
     res.append('<b>Your job produced the following outputs - check here for a record of what was done and any unexpected events</b><hr/>')
     imghref = '%s.jpg' % os.path.splitext(self.isPDF)[0] # removes .pdf
     res.append('<table cellpadding="10"><tr><td>\n')
     res.append('<a href="%s"><img src="%s" alt="%s" hspace="10" align="middle"></a>\n' % (self.isPDF,imghref,imghref))
     res.append('</tr><td></table>\n')
     try:
         flist = os.listdir(self.opts.outdir)
     except:
         flist = []
     if len(flist) > 0: # we should clean everything up - picard doesn't tell us what it did in cleansam unfortunately
         flist = [x for x in flist if not (x.startswith('.') or x == 'None')]
         tlist = [(os.path.getmtime(os.path.join(self.opts.outdir,x)),x) for x in flist]
         tlist.sort()
         flist = [x[1] for x in tlist]
         res.append('<div><b>Output files.</b><hr/>\n')
         res.append('<table>\n')
         for i,f in enumerate(flist):
             fn = os.path.split(f)[-1]
             fs = getFileString(fn,self.opts.outdir)
             res.append('<tr><td><a href="%s">%s</a></td></tr>\n' % (fn,fs))
         res.append('</table></div>\n')
     res.append('<b>Log of activity</b><hr/>\n')
     res.append('\n%s' % '<br/>'.join(logdat))
     res.append('<hr/>Note: The freely available <a href="http://picard.sourceforge.net/command-line-overview.shtml">Picard software</a> \n')
     res.append('generated all outputs reported here. These third party tools were')
     res.append('orchestrated by the Galaxy rgInsertSize wrapper and this command line from the Galaxy form:<br/>\n%s' % (self.cl))
     res.append(galhtmlpostfix)
     f = open(self.opts.htmlout,'w')
     f.write('\n'.join(res))
     f.close()