Mercurial > repos > trinity_ctat > align_and_estimate_abundance
comparison trinityToolWrapper.py @ 10:a8fa525a2f30 draft
Trying to fix a syntax error.
author | trinity_ctat |
---|---|
date | Tue, 26 Sep 2017 22:26:13 -0400 |
parents | b6152cc26ffd |
children | 2e0e45063fad |
comparison
equal
deleted
inserted
replaced
9:b6152cc26ffd | 10:a8fa525a2f30 |
---|---|
22 # I tried using "command -v Trinity" but for some reason, I was getting a OS permission error with that. | 22 # I tried using "command -v Trinity" but for some reason, I was getting a OS permission error with that. |
23 # I just found distutils.spawn.find_executable() which might work, but already implemented the below. | 23 # I just found distutils.spawn.find_executable() which might work, but already implemented the below. |
24 try: | 24 try: |
25 pipe1 = subprocess.Popen(["which", "Trinity"], stdout=subprocess.PIPE) | 25 pipe1 = subprocess.Popen(["which", "Trinity"], stdout=subprocess.PIPE) |
26 except: | 26 except: |
27 msg = "You must set the environmental variable TRINITY_HOME to the base installation directory of Trinity before running {:s}.".format(sys.argv[0]) | 27 msg = "You must set the environmental variable TRINITY_HOME to the base installation directory of Trinity before running {:s}.\n".format(sys.argv[0]) |
28 sys.stderr.write(msg) | 28 sys.stderr.write(msg) |
29 # t, v, tb = sys.exc_info() | 29 # t, v, tb = sys.exc_info() |
30 # raise t, v, tb | 30 # raise t, v, tb |
31 # For some reason the above was giving a syntax error. | 31 # For some reason the above was giving a syntax error. |
32 # A simple raise shoudl reraise the existing exception. | 32 # A simple raise should reraise the existing exception. |
33 raise | 33 raise |
34 else: | 34 else: |
35 TrinityPath, err_info = pipe1.communicate() | 35 TrinityPath, err_info = pipe1.communicate() |
36 # FIX - probably should be checking err_info for errors... | 36 # FIX - probably should be checking err_info for errors... |
37 # Determine the TRINITY_BASE_DIR from output1. | 37 # Determine the TRINITY_BASE_DIR from output1. |
38 # If TrinityPath is a link, we need to dereference the link. | 38 # If TrinityPath is a link, we need to dereference the link. |
39 TrinityPath = TrinityPath.rstrip() # Need to strip off a newline. | 39 TrinityPath = TrinityPath.rstrip() # Need to strip off a newline. |
40 # print "Trinity that was found is: {:s}".format(repr(TrinityPath)) | 40 # print "Trinity that was found is: {:s}".format(repr(TrinityPath)) |
41 # print os.path.islink(TrinityPath) | 41 # print os.path.islink(TrinityPath) |
42 TrinityPath = os.path.abspath(TrinityPath) | 42 TrinityPath = os.path.abspath(TrinityPath) |
43 print "The Absolute Trinity path that was found is: {:s}".format(TrinityPath) | 43 # msg = "The Absolute Trinity path that was found is: {:s}".format(TrinityPath) |
44 # print msg | |
44 # print os.path.islink(TrinityPath) | 45 # print os.path.islink(TrinityPath) |
45 while os.path.islink(TrinityPath): | 46 while os.path.islink(TrinityPath): |
46 print "That path is a link." | 47 # print "That path is a link." |
47 TrinityPath = os.path.join(os.path.dirname(TrinityPath),os.readlink(TrinityPath)) | 48 TrinityPath = os.path.join(os.path.dirname(TrinityPath),os.readlink(TrinityPath)) |
48 print "The new path is: {:s}".format(TrinityPath) | 49 # print "The new path is: {:s}".format(TrinityPath) |
49 # Take off the last part of the path (which is the Trinity command) | 50 # Take off the last part of the path (which is the Trinity command) |
50 TRINITY_BASE_DIR = "/".join(TrinityPath.split("/")[0:-1]) | 51 TRINITY_BASE_DIR = "/".join(TrinityPath.split("/")[0:-1]) |
51 else: | 52 else: |
52 sys.stderr.write("Either set TRINITY_HOME to the trinity base directory, or ensure that directory is in the PATH before running.") | 53 sys.stderr.write("Either set TRINITY_HOME to the trinity base directory, or ensure that directory is in the PATH before running.") |
53 sys.exit() | 54 sys.exit() |