comparison analyze_diff_exp_wrapper.py @ 3:b5d906ce0f06 draft

Adding some debugging statements.
author trinity_ctat
date Mon, 02 Oct 2017 13:29:07 -0400
parents 6f54e220d035
children 08f897c2b57e
comparison
equal deleted inserted replaced
2:6f54e220d035 3:b5d906ce0f06
54 Normalized_Matrix=sys.argv[2] 54 Normalized_Matrix=sys.argv[2]
55 Pvalue=sys.argv[3] 55 Pvalue=sys.argv[3]
56 Cvalue=sys.argv[4] 56 Cvalue=sys.argv[4]
57 57
58 def run_command(cmd): 58 def run_command(cmd):
59 print "The command used: " + cmd 59 # 2017-10-02
60 pipe= subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE) 60 # Cicada Dennis put the subprocess command in a try/except statement.
61 pipe.wait() 61 # Errors were going undetected the way it was written previously.
62 ret= pipe.returncode 62 try:
63 pipe = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
64 cmd_stdout, cmd_stderr = pipe.communicate()
65 except:
66 msg = "ERROR while running command:\n\t" + cmd
67 sys.stderr.write(msg)
68 raise
69
70 sys.stdout.write(cmd_stdout)
71 ret = pipe.returncode
63 if ret: 72 if ret:
64 print "command died: " + str(ret) 73 print "command died: " + str(ret)
65 print pipe.stderr.readlines() 74 sys.stderr.write(cmd_stderr)
66 sys.exit(ret) 75 sys.exit(ret)
67 else: 76 else:
77 # Any error output written to stdout instead of stderr, since no error has occurred.
78 sys.stderr.write(cmd_stderr)
68 return 79 return
69 80
70 print "" 81 print ""
71 Final_tar_gz= "edgeR.tar.gz" 82 Final_tar_gz= "edgeR.tar.gz"
72 run_command("cp "+ sys.argv[1] + " " + "Final_tar_gz") 83 run_command("cp "+ sys.argv[1] + " " + "Final_tar_gz")