Mercurial > repos > gkumar09 > trinity_rnaseq_protocol
diff trinityrnaseq_protocol/abundance_estimation_to_matrix_wrapper.py @ 0:1c37a8003755 draft
Uploaded
author | gkumar09 |
---|---|
date | Mon, 28 Sep 2015 22:44:29 -0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trinityrnaseq_protocol/abundance_estimation_to_matrix_wrapper.py Mon Sep 28 22:44:29 2015 -0400 @@ -0,0 +1,40 @@ +#!/usr/bin/env python + +import sys, os, string, subprocess + +#aliasing the filenames using the labels + + +def run_command(command): + print "Running command: " + command + + err_capture_file = open("my.stderr", 'w') # writing stderr to a file + cmd_run = subprocess.Popen(args=command, shell=True, stderr=err_capture_file, stdout=sys.stdout) + err = cmd_run.wait() # get exit code from command execution + err_capture_file.close() + + if err: + # report the error messages we captured, and exit non-zero + sys.stderr.write("Error, cmd: " + command + " died with ret: " + `err`) + for line in open(err_capture_file): + sys.stderr.write(line) + sys.exit(err) + return + +label_list = [] # symlink files to the labels +for i in range(1, len(sys.argv), 2): + filename=sys.argv[i] + label= sys.argv[i+1] + cmd= "ln -sf " + filename + " " + label + label_list.append(label) + run_command(cmd) + + +# run the abundance estimation script + +cmd = os.path.dirname(sys.argv[0]) + "/trinityToolWrapper.py " + " util/abundance_estimates_to_matrix.pl --est_method RSEM --cross_sample_fpkm_norm TMM " + " ".join(label_list) + +run_command(cmd) + +sys.exit(0) +