|
49 | 49 | except ImportError:
|
50 | 50 | import Queue # Python 2
|
51 | 51 |
|
| 52 | + |
| 53 | +def which_path(file_name): |
| 54 | + for path in os.environ["PATH"].split(os.pathsep): |
| 55 | + full_path = os.path.join(path, file_name) |
| 56 | + if os.path.exists(full_path) and os.access(full_path, os.X_OK): |
| 57 | + return full_path |
| 58 | + return None |
| 59 | + |
52 | 60 | #get AUGUSTUS path from the required ENV AUGUSTUS_CONFIG_PATH
|
53 | 61 | try:
|
54 | 62 | AUGUSTUS = os.environ["AUGUSTUS_CONFIG_PATH"]
|
|
61 | 69 | elif AUGUSTUS.endswith('config'+os.sep):
|
62 | 70 | AUGUSTUS_BASE = AUGUSTUS.replace('config'+os.sep, '')
|
63 | 71 | #location of scripts
|
64 |
| -NEWSPECIES = os.path.join(AUGUSTUS_BASE, 'scripts', 'new_species.pl') |
65 |
| -GB2SMALL = os.path.join(AUGUSTUS_BASE, 'scripts', 'gff2gbSmallDNA.pl') |
66 |
| -OPTIMIZE = os.path.join(AUGUSTUS_BASE, 'scripts', 'optimize_augustus.pl') |
| 72 | +#check if they are in PATH first, if not then try: |
| 73 | +if which_path('new_species.pl'): |
| 74 | + NEWSPECIES = 'new_species.pl' |
| 75 | +else: |
| 76 | + NEWSPECIES = os.path.join(AUGUSTUS_BASE, 'scripts', 'new_species.pl') |
| 77 | +if which_path('gff2gbSmallDNA.pl'): |
| 78 | + GB2SMALL = 'gff2gbSmallDNA.pl' |
| 79 | +else: |
| 80 | + GB2SMALL = os.path.join(AUGUSTUS_BASE, 'scripts', 'gff2gbSmallDNA.pl') |
| 81 | +if which_path('optimize_augustus.pl'): |
| 82 | + OPTIMIZE = 'optimize_augustus.pl' |
| 83 | +else: |
| 84 | + OPTIMIZE = os.path.join(AUGUSTUS_BASE, 'scripts', 'optimize_augustus.pl') |
| 85 | + |
| 86 | +for x in [NEWSPECIES, GB2SMALL, OPTIMIZE]: |
| 87 | + if not which_path(x): |
| 88 | + print('Error: {:} is not in PATH, exiting'.format(x)) |
| 89 | + sys.exit(1) |
67 | 90 |
|
68 | 91 |
|
69 | 92 | class BUSCOLogger(logging.getLoggerClass()):
|
|
0 commit comments