# HG changeset patch # User trinity_ctat # Date 1506969391 14400 # Node ID 70b3058d39d99369e642cc1dbfd123fee7f425ce # Parent 93f07220f08c8dc1ce341f5a65ae93e9e1e0d3a0 Adding more debugging statements. diff -r 93f07220f08c -r 70b3058d39d9 EdgeR_differentialExpression_wrapper.py --- a/EdgeR_differentialExpression_wrapper.py Fri Sep 29 14:12:02 2017 -0400 +++ b/EdgeR_differentialExpression_wrapper.py Mon Oct 02 14:36:31 2017 -0400 @@ -37,7 +37,8 @@ # Take off the last part of the path (which is the Trinity command) TRINITY_BASE_DIR = "/".join(TrinityPath.split("/")[0:-1]) else: - sys.stderr.write("Either set TRINITY_HOME to the trinity base directory, or ensure that directory is in the PATH before running.") + sys.stderr.write("Either set TRINITY_HOME to the trinity base directory, " + \ + "or ensure that directory is in the PATH before running.") sys.exit(1) usage= "usage: " + " $counts_matrix" + " $dispersion" @@ -49,17 +50,30 @@ print " " def run_command(cmd): - print "The command used: " + cmd - pipe=subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE) - pipe.wait() - ret= pipe.returncode + # 2017-10-02 + # Cicada Dennis put the subprocess command in a try/except statement. + # Errors were going undetected the way it was written previously. + print "Running command:\n\t" + cmd + try: + pipe = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE) + cmd_stdout, cmd_stderr = pipe.communicate() + except: + msg = "ERROR while running command:\n\t" + cmd + sys.stderr.write(msg) + raise + + sys.stdout.write(cmd_stdout) + ret = pipe.returncode if ret: print "command died: " + str(ret) - print pipe.stderr.readlines() - sys.exit(1) + sys.stderr.write(cmd_stderr) + sys.exit(ret) else: + # Any error output is written to stdout instead of stderr, since no error has occurred. + sys.stderr.write(cmd_stderr) return -print " " + +print "" countmatrix= "counts_matrix" @@ -67,7 +81,6 @@ run_command(cmd) cmd= TRINITY_BASE_DIR + "/Analysis/DifferentialExpression/run_DE_analysis.pl "+ " --matrix "+ countmatrix + " --method edgeR " + " --output edgeR_results "+ " --dispersion " + sys.argv[2] + " --tar_gz_outdir" - run_command(cmd) sys.exit(0)