Mercurial > repos > trinity_ctat > edger_differential_expression
comparison EdgeR_differentialExpression_wrapper.py @ 3:70b3058d39d9 draft
Adding more debugging statements.
| author | trinity_ctat |
|---|---|
| date | Mon, 02 Oct 2017 14:36:31 -0400 |
| parents | 023628c034b6 |
| children |
comparison
equal
deleted
inserted
replaced
| 2:93f07220f08c | 3:70b3058d39d9 |
|---|---|
| 35 TrinityPath = os.path.join(os.path.dirname(TrinityPath),os.readlink(TrinityPath)) | 35 TrinityPath = os.path.join(os.path.dirname(TrinityPath),os.readlink(TrinityPath)) |
| 36 # print "The new path is: {:s}".format(TrinityPath) | 36 # print "The new path is: {:s}".format(TrinityPath) |
| 37 # Take off the last part of the path (which is the Trinity command) | 37 # Take off the last part of the path (which is the Trinity command) |
| 38 TRINITY_BASE_DIR = "/".join(TrinityPath.split("/")[0:-1]) | 38 TRINITY_BASE_DIR = "/".join(TrinityPath.split("/")[0:-1]) |
| 39 else: | 39 else: |
| 40 sys.stderr.write("Either set TRINITY_HOME to the trinity base directory, or ensure that directory is in the PATH before running.") | 40 sys.stderr.write("Either set TRINITY_HOME to the trinity base directory, " + \ |
| 41 "or ensure that directory is in the PATH before running.") | |
| 41 sys.exit(1) | 42 sys.exit(1) |
| 42 | 43 |
| 43 usage= "usage: " + " $counts_matrix" + " $dispersion" | 44 usage= "usage: " + " $counts_matrix" + " $dispersion" |
| 44 | 45 |
| 45 if len(sys.argv)<2: | 46 if len(sys.argv)<2: |
| 47 else: | 48 else: |
| 48 print "All good- command going ahead" | 49 print "All good- command going ahead" |
| 49 print " " | 50 print " " |
| 50 | 51 |
| 51 def run_command(cmd): | 52 def run_command(cmd): |
| 52 print "The command used: " + cmd | 53 # 2017-10-02 |
| 53 pipe=subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE) | 54 # Cicada Dennis put the subprocess command in a try/except statement. |
| 54 pipe.wait() | 55 # Errors were going undetected the way it was written previously. |
| 55 ret= pipe.returncode | 56 print "Running command:\n\t" + cmd |
| 57 try: | |
| 58 pipe = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE) | |
| 59 cmd_stdout, cmd_stderr = pipe.communicate() | |
| 60 except: | |
| 61 msg = "ERROR while running command:\n\t" + cmd | |
| 62 sys.stderr.write(msg) | |
| 63 raise | |
| 64 | |
| 65 sys.stdout.write(cmd_stdout) | |
| 66 ret = pipe.returncode | |
| 56 if ret: | 67 if ret: |
| 57 print "command died: " + str(ret) | 68 print "command died: " + str(ret) |
| 58 print pipe.stderr.readlines() | 69 sys.stderr.write(cmd_stderr) |
| 59 sys.exit(1) | 70 sys.exit(ret) |
| 60 else: | 71 else: |
| 72 # Any error output is written to stdout instead of stderr, since no error has occurred. | |
| 73 sys.stderr.write(cmd_stderr) | |
| 61 return | 74 return |
| 62 print " " | 75 |
| 76 print "" | |
| 63 | 77 |
| 64 countmatrix= "counts_matrix" | 78 countmatrix= "counts_matrix" |
| 65 | 79 |
| 66 cmd= "cp " + sys.argv[1] + " " + countmatrix | 80 cmd= "cp " + sys.argv[1] + " " + countmatrix |
| 67 run_command(cmd) | 81 run_command(cmd) |
| 68 | 82 |
| 69 cmd= TRINITY_BASE_DIR + "/Analysis/DifferentialExpression/run_DE_analysis.pl "+ " --matrix "+ countmatrix + " --method edgeR " + " --output edgeR_results "+ " --dispersion " + sys.argv[2] + " --tar_gz_outdir" | 83 cmd= TRINITY_BASE_DIR + "/Analysis/DifferentialExpression/run_DE_analysis.pl "+ " --matrix "+ countmatrix + " --method edgeR " + " --output edgeR_results "+ " --dispersion " + sys.argv[2] + " --tar_gz_outdir" |
| 70 | |
| 71 run_command(cmd) | 84 run_command(cmd) |
| 72 | 85 |
| 73 sys.exit(0) | 86 sys.exit(0) |
