Mercurial > repos > fubar > fastqc
changeset 3:7e6db50c9d47 draft
Uploaded
author | fubar |
---|---|
date | Tue, 04 Jun 2013 22:42:51 -0400 |
parents | 40b80f54e1a7 |
children | d101029906cb |
files | FastQC/rgFastQC.py |
diffstat | 1 files changed, 23 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/FastQC/rgFastQC.py Tue Jun 04 22:18:27 2013 -0400 +++ b/FastQC/rgFastQC.py Tue Jun 04 22:42:51 2013 -0400 @@ -27,6 +27,25 @@ import zipfile import gzip +def pathfind(program): + """ toolshed path munging isn't so try to work around june 5 2013 + """ + def is_exe(fpath): + return os.path.isfile(fpath) and os.access(fpath, os.X_OK) + + fpath, fname = os.path.split(program) + if fpath: + if is_exe(program): + return program + else: + for path in os.environ["PATH"].split(os.pathsep): + path = path.strip('"') + exe_file = os.path.join(path, program) + if is_exe(exe_file): + return exe_file + + return None + class FastQC(): """wrapper """ @@ -35,6 +54,9 @@ def __init__(self,opts=None): assert opts <> None self.opts = opts + fastqcexe = pathfind(opts.executable) + assert (fastqcexe != None),'##rgFastQC.py error - cannot find passed fastqc executable %s in path %s' % (opts.executable,os.environ['PATH']) + self.fastqcexe = fastqcexe def getFileString(self, fpath, outpath): """ @@ -68,7 +90,7 @@ dummy,tlog = tempfile.mkstemp(prefix='rgFastQC',suffix=".log",dir=self.opts.outputdir) sout = open(tlog, 'w') fastq = os.path.basename(self.opts.input) - cl = [self.opts.executable,'--outdir=%s' % self.opts.outputdir] + cl = [self.fastqcexe,'--outdir=%s' % self.opts.outputdir] if self.opts.informat in ['sam','bam']: cl.append('--f=%s' % self.opts.informat) if self.opts.contaminants <> None : @@ -184,7 +206,6 @@ shutil.move(sauce,dest) os.rmdir(adir) - if __name__ == '__main__': op = optparse.OptionParser() @@ -198,7 +219,6 @@ op.add_option('-e', '--executable', default='fastqc') opts, args = op.parse_args() assert opts.input <> None - assert os.path.isfile(opts.executable),'##rgFastQC.py error - cannot find executable %s' % opts.executable if not os.path.exists(opts.outputdir): os.makedirs(opts.outputdir) f = FastQC(opts)