Mercurial > repos > crs4 > edena
diff edena_ovl_wrapper.py @ 2:b8c6a38530eb draft default tip
Support Edena v. 3.131028 (new <version_command>, official overlapping log file, covStats output file removed, -lph and -sph options instead of -peHorizon). Use $GALAXY_SLOTS instead of $EDENA
_SITE_OPTIONS. Directly call edena, remove edena_ovl_wrapper.py and edena_ass_wrapper.py . Discard stderr instead of redirecting to stdout. Do not redirect stdout to logfile. Add readme.rst .
author | crs4 |
---|---|
date | Fri, 31 Jan 2014 12:08:21 -0500 |
parents | cd6cc6d76708 |
children |
line wrap: on
line diff
--- a/edena_ovl_wrapper.py Fri Oct 18 14:09:11 2013 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Edena (overlapping) -version 0.2.1 (andrea.pinna@crs4.it) -""" - -import optparse -import shutil -import subprocess -import sys - -def __main__(): - # load arguments - print 'Parsing Edena (overlapping) input options...' - parser = optparse.OptionParser() - parser.add_option('--unpaired_input', action='append', dest='unpaired_input', help='') - parser.add_option('--dr_pair_1', action='append', dest='dr_pair_1', help='') - parser.add_option('--dr_pair_2', action='append', dest='dr_pair_2', help='') - parser.add_option('--rd_pair_1', action='append', dest='rd_pair_1', help='') - parser.add_option('--rd_pair_2', action='append', dest='rd_pair_2', help='') - parser.add_option('--nThreads', dest='nThreads', type='int', help='') - parser.add_option('--minOlap', dest='minOlap', type='int', help='') - parser.add_option('--readsTruncation', dest='readsTruncation', type='int', help='') - parser.add_option('--output', dest='output', help='') - parser.add_option('--logfile', dest='logfile', help='') - (options, args) = parser.parse_args() - if len(args) > 0: - parser.error('Wrong number of arguments') - - # build Edena (overlapping) command to be executed - # unpaired input(s) - if options.unpaired_input: - unpaired_input = '-r' - for item in options.unpaired_input: - unpaired_input += ' %s' % (item) - else: - unpaired_input = '' - # direct-reverse paired-end files - if options.dr_pair_1 and options.dr_pair_2: - dr_pairs = '-DRpairs' - for i in range(len(options.dr_pair_1)): - dr_pairs += ' %s %s' % (options.dr_pair_1[i], options.dr_pair_2[i]) - else: - dr_pairs = '' - # reverse-direct paired-end files - if options.rd_pair_1 and options.rd_pair_2: - rd_pairs = '-RDpairs' - for i in range(len(options.rd_pair_1)): - rd_pairs += ' %s %s' % (options.rd_pair_1[i], options.rd_pair_2[i]) - else: - rd_pairs = '' - # nThreads - nThreads = '-nThreads %d' % (options.nThreads) if options.nThreads is not None else '' - # minimum overlap - minOlap = '-M %d' % (options.minOlap) if options.minOlap is not None else '' - # 3' end reads truncation - readsTruncation = '-t %d' % (options.readsTruncation) if options.readsTruncation is not None else '' - # output file(s) - output = options.output - logfile = options.logfile - - # Build Edena (overlapping) command - cmd = 'edena %s %s %s %s %s %s -p galaxy_output' % (unpaired_input, dr_pairs, rd_pairs, nThreads, minOlap, readsTruncation) - print '\nEdena (overlapping) command to be executed:\n %s' % (cmd) - - # Execution of Edena - print 'Executing Edena (overlapping)...' - log = open(logfile, 'w') if logfile else sys.stdout - try: - subprocess.check_call(cmd, stdout=log, stderr=subprocess.STDOUT, shell=True) # need to redirect stderr because edena writes some logging info there (e.g. "Computing overlaps >=30...") - finally: - if log != sys.stdout: - log.close() - print 'Edena (overlapping) executed!' - - shutil.move('galaxy_output.ovl', output) - - -if __name__ == "__main__": - __main__()