comparison ctat_abundance_estimation_to_matrix.py @ 0:5eca0c75b178 draft default tip

Upload ctat tools.
author trinity_ctat
date Tue, 17 Jul 2018 11:47:32 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:5eca0c75b178
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]) + "/ctat_trinity_tool_wrapper.py " + " util/abundance_estimates_to_matrix.pl --gene_trans_map none --est_method RSEM --cross_sample_norm TMM " + " ".join(label_list)
36
37 run_command(cmd)
38
39 sys.exit(0)
40