Mercurial > repos > gkumar09 > trinity_rnaseq_protocol
comparison trinityrnaseq_protocol/abundance_estimation_to_matrix_wrapper.py @ 3:87c03e2aeba3 draft default tip
Uploaded
| author | gkumar09 |
|---|---|
| date | Sun, 18 Oct 2015 10:40:27 -0400 |
| parents | 1c37a8003755 |
| children |
comparison
equal
deleted
inserted
replaced
| 2:70e3c4c34a7c | 3:87c03e2aeba3 |
|---|---|
| 1 #!/usr/bin/env python | |
| 2 | |
| 3 import sys, os, string, subprocess | |
| 4 | |
| 5 #aliasing the filenames using the labels | |
| 6 | |
| 7 | |
| 8 def run_command(command): | |
| 9 print "Running command: " + command | |
| 10 | |
| 11 err_capture_file = open("my.stderr", 'w') # writing stderr to a file | |
| 12 cmd_run = subprocess.Popen(args=command, shell=True, stderr=err_capture_file, stdout=sys.stdout) | |
| 13 err = cmd_run.wait() # get exit code from command execution | |
| 14 err_capture_file.close() | |
| 15 | |
| 16 if err: | |
| 17 # report the error messages we captured, and exit non-zero | |
| 18 sys.stderr.write("Error, cmd: " + command + " died with ret: " + `err`) | |
| 19 for line in open(err_capture_file): | |
| 20 sys.stderr.write(line) | |
| 21 sys.exit(err) | |
| 22 return | |
| 23 | |
| 24 label_list = [] # symlink files to the labels | |
| 25 for i in range(1, len(sys.argv), 2): | |
| 26 filename=sys.argv[i] | |
| 27 label= sys.argv[i+1] | |
| 28 cmd= "ln -sf " + filename + " " + label | |
| 29 label_list.append(label) | |
| 30 run_command(cmd) | |
| 31 | |
| 32 | |
| 33 # run the abundance estimation script | |
| 34 | |
| 35 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) | |
| 36 | |
| 37 run_command(cmd) | |
| 38 | |
| 39 sys.exit(0) | |
| 40 |
