diff --git a/quast_libs/qutils.py b/quast_libs/qutils.py index 3fd809d237..5a43ddec95 100644 --- a/quast_libs/qutils.py +++ b/quast_libs/qutils.py @@ -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\d+)\.(?P\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) diff --git a/quast_libs/run_busco.py b/quast_libs/run_busco.py index 33ee84f128..6da19d7ad6 100644 --- a/quast_libs/run_busco.py +++ b/quast_libs/run_busco.py @@ -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' @@ -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): @@ -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 @@ -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 quast.support@cab.spbu.ru') if not qconfig.debug: