Mercurial > repos > trinity_ctat > align_and_estimate_abundance
comparison trinityToolWrapper.py @ 5:98d99fed9d35 draft
Strip eol off of TrinityPath, so os.path.islink() works correctly.
| author | trinity_ctat |
|---|---|
| date | Tue, 26 Sep 2017 13:33:20 -0400 |
| parents | cb71c6b0bf66 |
| children | 12bc09b4a26d |
comparison
equal
deleted
inserted
replaced
| 4:cb71c6b0bf66 | 5:98d99fed9d35 |
|---|---|
| 14 assert sys.version_info[:2] >= ( 2, 4 ) | 14 assert sys.version_info[:2] >= ( 2, 4 ) |
| 15 | 15 |
| 16 TRINITY_BASE_DIR = "" | 16 TRINITY_BASE_DIR = "" |
| 17 if os.environ.has_key('TRINITY_HOME'): | 17 if os.environ.has_key('TRINITY_HOME'): |
| 18 TRINITY_BASE_DIR = os.environ['TRINITY_HOME']; | 18 TRINITY_BASE_DIR = os.environ['TRINITY_HOME']; |
| 19 else: | 19 elif hasattr(os, 'symlink'): # symlink was implemented to always return false when it was not implemented in earlier versions. |
| 20 # 2017-09-26 | 20 # 2017-09-26 |
| 21 # Cicada Dennis added looking for the location of the Trinity program using the Unix "which" utility. | 21 # Cicada Dennis added looking for the location of the Trinity program using the Unix "which" utility. |
| 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: |
| 30 else: | 30 else: |
| 31 TrinityPath, err_info = pipe1.communicate() | 31 TrinityPath, err_info = pipe1.communicate() |
| 32 # FIX - probably should be checking err_info for errors... | 32 # FIX - probably should be checking err_info for errors... |
| 33 # Determine the TRINITY_BASE_DIR from output1. | 33 # Determine the TRINITY_BASE_DIR from output1. |
| 34 # If TrinityPath is a link, we need to dereference the link. | 34 # If TrinityPath is a link, we need to dereference the link. |
| 35 TrinityPath = TrinityPath.rstrip() # Need to strip off a newline. | |
| 36 # print "Trinity that was found is: {:s}".format(repr(TrinityPath)) | |
| 37 # print os.path.islink(TrinityPath) | |
| 38 TrinityPath = os.path.abspath(TrinityPath) | |
| 39 print "The Absolute Trinity path that was found is: {:s}".format(TrinityPath) | |
| 40 # print os.path.islink(TrinityPath) | |
| 35 while os.path.islink(TrinityPath): | 41 while os.path.islink(TrinityPath): |
| 42 print "That path is a link." | |
| 36 TrinityPath = os.path.join(os.path.dirname(TrinityPath),os.readlink(TrinityPath)) | 43 TrinityPath = os.path.join(os.path.dirname(TrinityPath),os.readlink(TrinityPath)) |
| 44 print "The new path is: {:s}".format(TrinityPath) | |
| 37 # Take off the last part of the path (which is the Trinity command) | 45 # Take off the last part of the path (which is the Trinity command) |
| 38 TRINITY_BASE_DIR = "/".join(TrinityPath.split("/")[0:-1]) | 46 TRINITY_BASE_DIR = "/".join(TrinityPath.split("/")[0:-1]) |
| 39 | 47 |
| 40 # get bindir | 48 # get bindir |
| 41 bindir = sys.argv[0] | 49 bindir = sys.argv[0] |
| 68 return | 76 return |
| 69 | 77 |
| 70 # If one needs to silence stdout | 78 # If one needs to silence stdout |
| 71 #args.append( ">" ) | 79 #args.append( ">" ) |
| 72 #args.append( "/dev/null" ) | 80 #args.append( "/dev/null" ) |
| 81 print "The TRINITY_BASE_DIR is:\n\t{:s}".format(TRINITY_BASE_DIR) | |
| 73 | 82 |
| 74 args[0] = "".join([TRINITY_BASE_DIR, '/', args[0]]); | 83 args[0] = "".join([TRINITY_BASE_DIR, '/', args[0]]); |
| 75 | 84 |
| 76 cmdline = " ".join(args) | 85 cmdline = " ".join(args) |
| 77 | 86 |
| 87 print "The command being invoked is:\n\t{:s}".format(cmdline) | |
| 78 | 88 |
| 79 | 89 |
| 80 try: | 90 try: |
| 81 # Run program | 91 # Run program |
| 82 err_capture = open("stderr.txt", 'w') | 92 err_capture = open("stderr.txt", 'w') |
