From 3b1f84e15b8a63a79b5cc6563774cc3fc663aaa9 Mon Sep 17 00:00:00 2001 From: depristo Date: Wed, 20 May 2009 12:54:41 +0000 Subject: [PATCH] Slightly improved interface to merging utility for multiple bam files git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@757 348d0f76-0448-11de-a6fe-93d51630548a --- python/MergeBAMBatch.py | 6 +++--- python/ValidateGATK.py | 4 ++-- python/farm_commands.py | 12 +++++++++--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/python/MergeBAMBatch.py b/python/MergeBAMBatch.py index 1facedfb4..5c643fe38 100755 --- a/python/MergeBAMBatch.py +++ b/python/MergeBAMBatch.py @@ -13,7 +13,7 @@ bam_ext = '.bam' if __name__ == "__main__": usage = "usage: %prog [options]" parser = OptionParser(usage=usage) - parser.add_option("-q", "--farm", dest="farm_sub", + parser.add_option("-q", "--farm", dest="farmQueue", type="string", default=None, help="Farm queue to send processing jobs to") parser.add_option("-d", "--dir", dest="output_dir", @@ -47,8 +47,8 @@ if __name__ == "__main__": if OPTIONS.ignoreExistingFiles or not os.path.exists(output_filename): cmd = 'java -Xmx4096m -jar ' + MERGE_BIN + ' AS=true SO=coordinate O=' + output_filename + ' VALIDATION_STRINGENCY=SILENT ' + ' I=' + (' I='.join(sources)) print cmd - farm_commands.cmd(cmd, OPTIONS.farm_sub, output) + farm_commands.cmd(cmd, OPTIONS.farmQueue, output) if OPTIONS.ignoreExistingFiles or not os.path.exists(output_index): - ValidateGATK.indexBAM(output_filename) + ValidateGATK.indexBAM(output_filename, OPTIONS.farmQueue) diff --git a/python/ValidateGATK.py b/python/ValidateGATK.py index 114fa6f85..9dcf77c7a 100755 --- a/python/ValidateGATK.py +++ b/python/ValidateGATK.py @@ -6,9 +6,9 @@ import string defaultCommands = ['CountReads', 'Pileup'] -def indexBAM(reads): +def indexBAM(reads, queue=None): cmd = "samtools index " + reads - farm_commands.cmd(cmd, None, None) + farm_commands.cmd(cmd, queue, None) def readIntervalFile(file): def notHeaderP(line): diff --git a/python/farm_commands.py b/python/farm_commands.py index f6b618c98..7d33aaf46 100644 --- a/python/farm_commands.py +++ b/python/farm_commands.py @@ -3,15 +3,21 @@ import os #justPrintCommands = False -def cmd(cmd_str, farm_queue=False, output_head="", just_print_commands=False, outputFile = None): +def cmd(cmd_str, farm_queue=False, output_head=None, just_print_commands=False, outputFile = None): # if farm_queue is non-False, submits to queue, other if farm_queue: if outputFile <> None: farm_stdout = outputFile - else: + elif output_head <> None: farm_stdout = output_head+".stdout" - cmd_str = "bsub -q "+farm_queue+" -o "+farm_stdout+" "+cmd_str #+" TMP_DIR=/wga/scr1/andrewk/tmp" + else: + farm_stdout = None + + cmd_str = "bsub -q "+farm_queue+" "+cmd_str + if farm_stdout <> None: + cmd_str += " -o " + farm_stdout + print ">>> Farming via "+cmd_str else: print ">>> Executing "+cmd_str