Skip to content

Commit

Permalink
busco: handling augustus versions properly, default is 3.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeigurevich committed Jun 7, 2022
1 parent 7d94c96 commit 8704550
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
37 changes: 22 additions & 15 deletions quast_libs/qutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,39 +688,46 @@ def relpath(path, start=curdir):
return join(*rel_list)


def get_path_to_program(program, dirpath=None, min_version=None, recommend_version=None):
def get_path_to_program(program, dirpath=None, min_version=None, recommend_version=None, max_allowed_version=None):
"""
returns the path to an executable or None if it can't be found
"""
OLD_VERSION = 0
INCOMPATIBLE_VERSION = 0
CORRECT_VERSION = 1
NOT_RECOMMENDED_VERSION = 2

def is_exe(fpath):
if os.path.isfile(fpath) and os.access(fpath, os.X_OK):
version_check = check_version(fpath, min_version, recommend_version)
if version_check != OLD_VERSION:
version_check = check_version(fpath, min_version, recommend_version, max_allowed_version)
if version_check != INCOMPATIBLE_VERSION:
if version_check == NOT_RECOMMENDED_VERSION:
logger.warning('Version of installed %s differs from its version in QUAST package (%s). '
logger.warning('Version of installed %s differs from its version in the QUAST package (%s). '
'Please make sure that you use an actual version of software.' % (program, recommend_version))
return True
return False

def check_version(fpath, min_version, recommend_version=None):
if not min_version: return CORRECT_VERSION
def check_version(fpath, min_version, recommend_version=None, max_allowed_version=None):
if not min_version:
return CORRECT_VERSION
p = subprocess.Popen([fpath, '--version'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
stdout, stderr = p.communicate()
version_pattern = re.compile('(?P<major_version>\d+)\.(?P<minor_version>\d+)')
v = version_pattern.search(str(stdout))
if not v.group('major_version') or not v.group('minor_version'):
return OLD_VERSION
version, minor_version = map(int, min_version.split('.'))
rec_version, rec_minor_version = map(int, recommend_version.split('.'))
return INCOMPATIBLE_VERSION
version, minor_version = map(int, min_version.split('.')[:2])
if int(v.group('major_version')) == version and int(v.group('minor_version')) >= minor_version:
if not recommend_version or (int(v.group('major_version')) == rec_version and int(v.group('minor_version')) == rec_minor_version):
return CORRECT_VERSION
else:
return NOT_RECOMMENDED_VERSION
else: return OLD_VERSION
if max_allowed_version is not None:
max_version, max_minor_version = map(int, max_allowed_version.split('.')[:2])
if int(v.group('major_version')) > max_version or int(v.group('minor_version')) > max_minor_version:
return INCOMPATIBLE_VERSION
if recommend_version is not None:
rec_version, rec_minor_version = map(int, recommend_version.split('.')[:2])
if int(v.group('major_version')) != rec_version or int(v.group('minor_version')) != rec_minor_version:
return NOT_RECOMMENDED_VERSION
return CORRECT_VERSION
else:
return INCOMPATIBLE_VERSION

if dirpath:
exe_file = os.path.join(dirpath, program)
Expand Down
10 changes: 8 additions & 2 deletions quast_libs/run_busco.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

logger = get_logger(qconfig.LOGGER_DEFAULT_NAME)

augustus_version = '3.3.3'
augustus_version = '3.2.3'
augustus_max_allowed_version = '3.3'
augustus_url = 'http://bioinf.uni-greifswald.de/augustus/binaries/old/augustus-' + augustus_version + '.tar.gz'
bacteria_db_url = 'https://busco-archive.ezlab.org/v3/datasets/bacteria_odb9.tar.gz'
fungi_db_url = 'https://busco-archive.ezlab.org/v3/datasets/fungi_odb9.tar.gz'
Expand Down Expand Up @@ -116,7 +117,9 @@ def __check_preinstalled_augustus_completeness(dirpath):
return True
return False

preinstalled_augustus = qutils.get_path_to_program('augustus')
preinstalled_augustus = qutils.get_path_to_program('augustus', min_version=augustus_version,
recommend_version=augustus_version,
max_allowed_version=augustus_max_allowed_version)
if preinstalled_augustus is not None:
preinstalled_augustus_dirpath = os.path.dirname(os.path.dirname(preinstalled_augustus))
if __check_preinstalled_augustus_completeness(preinstalled_augustus_dirpath):
Expand Down Expand Up @@ -235,6 +238,7 @@ def do(contigs_fpaths, output_dir, logger):
return

config_fpath = make_config(output_dir, tmp_dir, busco_threads, clade_dirpath, augustus_dirpath)
logger.info(' running BUSCO with augustus from ' + augustus_dirpath)
logger.info('Logs and results will be saved under ' + output_dir + '...')

os.environ['BUSCO_CONFIG_FILE'] = config_fpath
Expand Down Expand Up @@ -281,6 +285,8 @@ def do(contigs_fpaths, output_dir, logger):
' 3. Problem with BUSCO dependencies, most likely Augustus. Check that the binaries in ' + augustus_dirpath + '/bin/ are working properly.\n'
' If something is wrong with Augustus, you may try to install it yourself '
'(https://github.com/Gaius-Augustus/Augustus or `conda install -c bioconda augustus`) and make sure "augustus" binary is in PATH.\n'
' Please install the PROPER VERSION of Augustus, we tested BUSCO with augustus-' + augustus_version +
', it may also work with augustus-' + augustus_max_allowed_version + ', the newer/older versions are not supported.\n'
' 4. Some other problem with BUSCO. Check the logs (you may need to rerun QUAST with --debug to see all intermediate files).\n'
' If you cannot solve the problem yourself, post an issue at https://github.com/ablab/quast/issues or write to [email protected]')
if not qconfig.debug:
Expand Down

0 comments on commit 8704550

Please sign in to comment.