# HG changeset patch
# User devteam
# Date 1393392440 18000
# Node ID b23e39dbfe30b0b71172dff7004f22527b5b2c1b
# Parent 8d15620a9420bc01d3b5d545fe6aa18f0fbcfc78
Deleted selected files
diff -r 8d15620a9420 -r b23e39dbfe30 picard_MeanQualityByCylce.xml
--- a/picard_MeanQualityByCylce.xml Wed Feb 26 00:25:02 2014 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-
-Calculates mean quality
-picard
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Picard documentation says:
-
-
-MeanQualityByCycle
-
-Usage: program [options...]
-
-Option Description
-CHART_OUTPUT=File A file (with .pdf extension) to write the chart to. Required.
-ALIGNED_READS_ONLY=Boolean If set to true, calculate mean quality over aligned reads only. Default value: false. This option can be set to 'null' to clear the default value. Possible values: {true, false}
-PF_READS_ONLY=Boolean If set to true calculate mean quality over PF reads only. Default value: false. This option can be set to 'null' to clear the default value. Possible values: {true, false}
-INPUT=File Input SAM or BAM file. Required.
-OUTPUT=File File to write the output to. Required.
-REFERENCE_SEQUENCE=File Reference sequence fasta Default value: null.
-ASSUME_SORTED=Boolean If true (default), then the sort order in the header file will be ignored. Default value: true. This option can be set to 'null' to clear the default value. Possible values: {true, false}
-STOP_AFTER=Long Stop after processing N reads, mainly for debugging. Default value: 0. This option can be set to 'null' to clear the default value.
-
-
-
-
diff -r 8d15620a9420 -r b23e39dbfe30 picard_wrapper.py
--- a/picard_wrapper.py Wed Feb 26 00:25:02 2014 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,823 +0,0 @@
-#!/usr/bin/env python
-"""
-Originally written by Kelly Vincent
-pretty output and additional picard wrappers by Ross Lazarus for rgenetics
-Runs all available wrapped Picard tools.
-usage: picard_wrapper.py [options]
-code Ross wrote licensed under the LGPL
-see http://www.gnu.org/copyleft/lesser.html
-"""
-
-import optparse, os, sys, subprocess, tempfile, shutil, time, logging
-
-galhtmlprefix = """
-
-
-
-
-
-
-
-
-
-
-"""
-galhtmlattr = """Galaxy tool %s run at %s """
-galhtmlpostfix = """
\n"""
-
-
-def stop_err( msg ):
- sys.stderr.write( '%s\n' % msg )
- sys.exit()
-
-
-def timenow():
- """return current time as a string
-"""
- return time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(time.time()))
-
-
-class PicardBase():
- """
-simple base class with some utilities for Picard
-adapted and merged with Kelly Vincent's code april 2011 Ross
-lots of changes...
-"""
-
- def __init__(self, opts=None,arg0=None):
- """ common stuff needed at init for a picard tool
-"""
- assert opts <> None, 'PicardBase needs opts at init'
- self.opts = opts
- if self.opts.outdir == None:
- self.opts.outdir = os.getcwd() # fixmate has no html file eg so use temp dir
- assert self.opts.outdir <> None,'## PicardBase needs a temp directory if no output directory passed in'
- self.picname = self.baseName(opts.jar)
- if self.picname.startswith('picard'):
- self.picname = opts.picard_cmd # special case for some tools like replaceheader?
- self.progname = self.baseName(arg0)
- self.version = '0.002'
- self.delme = [] # list of files to destroy
- self.title = opts.title
- self.inputfile = opts.input
- try:
- os.makedirs(opts.outdir)
- except:
- pass
- try:
- os.makedirs(opts.tmpdir)
- except:
- pass
- self.log_filename = os.path.join(self.opts.outdir,'%s.log' % self.picname)
- self.metricsOut = os.path.join(opts.outdir,'%s.metrics.txt' % self.picname)
- self.setLogging(logfname=self.log_filename)
-
- def baseName(self,name=None):
- return os.path.splitext(os.path.basename(name))[0]
-
- def setLogging(self,logfname="picard_wrapper.log"):
- """setup a logger
-"""
- logging.basicConfig(level=logging.INFO,
- filename=logfname,
- filemode='a')
-
-
- def readLarge(self,fname=None):
- """ read a potentially huge file.
-"""
- try:
- # get stderr, allowing for case where it's very large
- tmp = open( fname, 'rb' )
- s = ''
- buffsize = 1048576
- try:
- while True:
- more = tmp.read( buffsize )
- if len(more) > 0:
- s += more
- else:
- break
- except OverflowError:
- pass
- tmp.close()
- except Exception, e:
- stop_err( 'Read Large Exception : %s' % str( e ) )
- return s
-
- def runCL(self,cl=None,output_dir=None):
- """ construct and run a command line
-we have galaxy's temp path as opt.temp_dir so don't really need isolation
-sometimes stdout is needed as the output - ugly hacks to deal with potentially vast artifacts
-"""
- assert cl <> None, 'PicardBase runCL needs a command line as cl'
- if output_dir == None:
- output_dir = self.opts.outdir
- if type(cl) == type([]):
- cl = ' '.join(cl)
- fd,templog = tempfile.mkstemp(dir=output_dir,suffix='rgtempRun.txt')
- tlf = open(templog,'wb')
- fd,temperr = tempfile.mkstemp(dir=output_dir,suffix='rgtempErr.txt')
- tef = open(temperr,'wb')
- process = subprocess.Popen(cl, shell=True, stderr=tef, stdout=tlf, cwd=output_dir)
- rval = process.wait()
- tlf.close()
- tef.close()
- stderrs = self.readLarge(temperr)
- stdouts = self.readLarge(templog)
- if rval > 0:
- s = '## executing %s returned status %d and stderr: \n%s\n' % (cl,rval,stderrs)
- stdouts = '%s\n%s' % (stdouts,stderrs)
- else:
- s = '## executing %s returned status %d and nothing on stderr\n' % (cl,rval)
- logging.info(s)
- os.unlink(templog) # always
- os.unlink(temperr) # always
- return s, stdouts, rval # sometimes s is an output
-
- def runPic(self, jar, cl):
- """
-cl should be everything after the jar file name in the command
-"""
- runme = ['java -Xmx%s' % self.opts.maxjheap]
- runme.append(" -Djava.io.tmpdir='%s' " % self.opts.tmpdir)
- runme.append('-jar %s' % jar)
- runme += cl
-
- print runme,self.opts.outdir
-
- s,stdouts,rval = self.runCL(cl=runme, output_dir=self.opts.outdir)
- return stdouts,rval
-
- def samToBam(self,infile=None,outdir=None):
- """
-use samtools view to convert sam to bam
-"""
- fd,tempbam = tempfile.mkstemp(dir=outdir,suffix='rgutilsTemp.bam')
- cl = ['samtools view -h -b -S -o ',tempbam,infile]
- tlog,stdouts,rval = self.runCL(cl,outdir)
- return tlog,tempbam,rval
-
- def sortSam(self, infile=None,outfile=None,outdir=None):
- """
-"""
- print '## sortSam got infile=%s,outfile=%s,outdir=%s' % (infile,outfile,outdir)
- cl = ['samtools sort',infile,outfile]
- tlog,stdouts,rval = self.runCL(cl,outdir)
- return tlog
-
- def cleanup(self):
- for fname in self.delme:
- try:
- os.unlink(fname)
- except:
- pass
-
- def prettyPicout(self,transpose,maxrows):
- """organize picard outpouts into a report html page
-"""
- res = []
- try:
- r = open(self.metricsOut,'r').readlines()
- except:
- r = []
- if len(r) > 0:
- res.append('Picard on line resources
\n')
- if transpose:
- res.append('Picard output (transposed to make it easier to see)\n')
- else:
- res.append('Picard output\n')
- res.append('
\n')
- dat = []
- heads = []
- lastr = len(r) - 1
- # special case for estimate library complexity hist
- thist = False
- for i,row in enumerate(r):
- if row.strip() > '':
- srow = row.split('\t')
- if row.startswith('#'):
- heads.append(row.strip()) # want strings
- else:
- dat.append(srow) # want lists
- if row.startswith('## HISTOGRAM'):
- thist = True
- if len(heads) > 0:
- hres = ['
%s
' % (i % 2,x) for i,x in enumerate(heads)]
- res += hres
- heads = []
- if len(dat) > 0:
- if transpose and not thist:
- tdat = map(None,*dat) # transpose an arbitrary list of lists
- tdat = ['
%s
%s
\n' % ((i+len(heads)) % 2,x[0],x[1]) for i,x in enumerate(tdat)]
- else:
- tdat = ['\t'.join(x).strip() for x in dat] # back to strings :(
- tdat = ['
%s
\n' % ((i+len(heads)) % 2,x) for i,x in enumerate(tdat)]
- res += tdat
- dat = []
- res.append('
\n')
- return res
-
- def fixPicardOutputs(self,transpose,maxloglines):
- """
-picard produces long hard to read tab header files
-make them available but present them transposed for readability
-"""
- logging.shutdown()
- self.cleanup() # remove temp files stored in delme
- rstyle=""""""
- res = [rstyle,]
- res.append(galhtmlprefix % self.progname)
- res.append(galhtmlattr % (self.picname,timenow()))
- flist = [x for x in os.listdir(self.opts.outdir) if not x.startswith('.')]
- pdflist = [x for x in flist if os.path.splitext(x)[-1].lower() == '.pdf']
- if len(pdflist) > 0: # assumes all pdfs come with thumbnail .jpgs
- for p in pdflist:
- pbase = os.path.splitext(p)[0] # removes .pdf
- imghref = '%s.jpg' % pbase
- mimghref = '%s-0.jpg' % pbase # multiple pages pdf -> multiple thumbnails without asking!
- if mimghref in flist:
- imghref=mimghref # only one for thumbnail...it's a multi page pdf
- res.append('