Mercurial > repos > trinity_ctat > align_and_estimate_abundance
comparison trinityToolWrapper.py @ 2:9e5c3f162eca draft
Needed to dereference links when searching for TRINITY_BASE_DIR.
| author | trinity_ctat | 
|---|---|
| date | Tue, 26 Sep 2017 11:34:17 -0400 | 
| parents | a9723c18d389 | 
| children | 32b6a47c9312 | 
   comparison
  equal
  deleted
  inserted
  replaced
| 1:b33e9252e6b4 | 2:9e5c3f162eca | 
|---|---|
| 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 else: | 
| 20 # Cicada Dennis added looking for the location of the Trinity program using the unix "which" utility. | 20 # 2017-09-26 | 
| 21 # Cicada Dennis added looking for the location of the Trinity program using the Unix "which" utility. | |
| 21 # 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. | |
| 22 try: | 24 try: | 
| 23 pipe1 = subprocess.Popen(["which", "Trinity"], stdout=subprocess.PIPE) | 25 pipe1 = subprocess.Popen(["which", "Trinity"], stdout=subprocess.PIPE) | 
| 24 except: | 26 except: | 
| 25 t, v, tb = sys.exc_info() | 27 t, v, tb = sys.exc_info() | 
| 26 sys.stderr.write("You must set the environmental variable TRINITY_HOME to the base installation directory of Trinity before running this"); | 28 sys.stderr.write("You must set the environmental variable TRINITY_HOME to the base installation directory of Trinity before running {:s}.".format(sys.argv[0]); | 
| 27 raise t, v, tb | 29 raise t, v, tb | 
| 28 else: | 30 else: | 
| 29 output1, err1 = pipe1.communicate() | 31 TrinityPath, err_info = pipe1.communicate() | 
| 32 # FIX - probably should be checking err_info for errors... | |
| 33 # Determine the TRINITY_BASE_DIR from output1. | |
| 34 # If TrinityPath is a link, we need to dereference the link. | |
| 35 while os.path.islink(TrinityPath) | |
| 36 TrinityPath = os.path.join(os.path.dirname(TrinityPath),os.readlink(TrinityPath)) | |
| 30 # 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) | 
| 31 TRINITY_BASE_DIR = "/".join(output1.split("/")[0:-1]) | 38 TRINITY_BASE_DIR = "/".join(TrinityPath.split("/")[0:-1]) | 
| 32 | 39 | 
| 33 # get bindir | 40 # get bindir | 
| 34 bindir = sys.argv[0] | 41 bindir = sys.argv[0] | 
| 35 bindir = bindir.split("/") | 42 bindir = bindir.split("/") | 
| 36 if len(bindir) > 1: | 43 if len(bindir) > 1: | 
