Exemplo n.º 1
0
def compile_aligner(logger, only_clean=False):
    global contig_aligner
    default_requirements = ['nucmer', 'delta-filter', 'show-coords', 'show-snps', 'mummer', 'mummerplot', 'mgaps']

    if only_clean:
        aligners_to_try = [
            ('E-MEM', 'emem', default_requirements + ['e-mem']),
            ('MUMmer', 'mummer', default_requirements)]
        for i, (name, flag_name, requirements) in enumerate(aligners_to_try):
            compile_tool(name, contig_aligner_dirpath, requirements, logger=logger, only_clean=only_clean, flag_suffix='.' + flag_name)
        return True

    mummer_failed = check_prev_compilation_failed('MUMmer', mummer_failed_compilation_flag, just_notice=True, logger=logger)
    emem_failed = check_prev_compilation_failed('E-MEM', e_mem_failed_compilation_flag, just_notice=True, logger=logger)
    if mummer_failed and emem_failed:
        contig_aligner = None
        logger.error("Compilation of contig aligner software was unsuccessful! QUAST functionality will be limited.")
        return False

    if contig_aligner is not None:
        compilation_failed = emem_failed if is_emem_aligner() else mummer_failed
        if not compilation_failed:
            return True
        contig_aligner = None

    if not qconfig.force_nucmer and not emem_failed:
        if get_installed_emem() or isfile(join(contig_aligner_dirpath, 'e-mem')):
            emem_requirements = default_requirements
        elif qconfig.platform_name == 'macosx' and isfile(join(contig_aligner_dirpath, 'e-mem-osx')):
            shutil.copy(join(contig_aligner_dirpath, 'e-mem-osx'), join(contig_aligner_dirpath, 'e-mem'))
            emem_requirements = default_requirements
        else:
            emem_requirements = default_requirements + ['e-mem']
        aligners_to_try = [
            ('E-MEM', 'emem', emem_requirements),
            ('MUMmer', 'mummer', default_requirements)]
    else:
        aligners_to_try = [
            ('MUMmer', 'mummer', default_requirements)]

    for i, (name, flag_name, requirements) in enumerate(aligners_to_try):
        success_compilation = compile_tool(name, contig_aligner_dirpath, requirements, just_notice=(i < len(aligners_to_try) - 1),
                                           logger=logger, only_clean=only_clean, flag_suffix='.' + flag_name,
                                           make_cmd='no-emem' if 'e-mem' not in requirements else None)
        if not success_compilation:
            continue
        contig_aligner = name  # successfully compiled
        return True

    logger.error("Compilation of contig aligner software was unsuccessful! QUAST functionality will be limited.")
    return False
Exemplo n.º 2
0
def compile_aligner(logger, only_clean=False, compile_all_aligners=False):
    global contig_aligner
    global contig_aligner_dirpath

    if not compile_all_aligners:
        if contig_aligner_dirpath is not None and not \
                check_prev_compilation_failed(contig_aligner, join(contig_aligner_dirpath, 'make.failed'), just_notice=True, logger=logger):
            return True

        if not qconfig.force_nucmer and not contig_aligner_dirpath and qconfig.platform_name == 'macosx':
            if get_installed_emem() or \
                    not check_prev_compilation_failed('E-MEM', e_mem_failed_compilation_flag, just_notice=True, logger=logger):
                contig_aligner = 'E-MEM'
                contig_aligner_dirpath = join(qconfig.LIBS_LOCATION, 'E-MEM-osx')
                return True

    default_requirements = ['nucmer', 'delta-filter', 'show-coords', 'show-snps', 'mummer', 'mgaps']

    if qconfig.platform_name == 'macosx':
        aligners_to_try = [
            ('MUMmer', join(qconfig.LIBS_LOCATION, 'MUMmer3.23-osx'), default_requirements)]
    else:
        if not qconfig.force_nucmer:
            if get_installed_emem():
                emem_requirements = default_requirements
            else:
                emem_requirements = default_requirements + ['e-mem']
            aligners_to_try = [
                ('E-MEM', join(qconfig.LIBS_LOCATION, 'E-MEM-linux'), emem_requirements),
                ('MUMmer', join(qconfig.LIBS_LOCATION, 'MUMmer3.23-linux'), default_requirements)]
        else:
            aligners_to_try = [
                ('MUMmer', join(qconfig.LIBS_LOCATION, 'MUMmer3.23-linux'), default_requirements)]

    for i, (name, dirpath, requirements) in enumerate(aligners_to_try):
        success_compilation = compile_tool(name, dirpath, requirements, just_notice=(i < len(aligners_to_try) - 1),
                                           logger=logger, only_clean=only_clean, make_cmd='no-emem' if 'E-MEM' in name and get_installed_emem() else None)
        if not success_compilation:
            continue
        contig_aligner = name
        contig_aligner_dirpath = dirpath  # successfully compiled
        if not compile_all_aligners:
            return True

    if compile_all_aligners and contig_aligner and contig_aligner_dirpath:
        return True
    logger.error("Compilation of contig aligner software was unsuccessful! QUAST functionality will be limited.")
    return False
Exemplo n.º 3
0
def compile_aligner(logger, only_clean=False):
    requirements = ['minimap2']
    aligner_failed_compilation_flag = join(contig_aligner_dirpath,
                                           'make.failed')

    if only_clean:
        compile_tool('Minimap2',
                     contig_aligner_dirpath,
                     requirements,
                     logger=logger,
                     only_clean=only_clean)
        return True

    if check_prev_compilation_failed('Minimap2',
                                     aligner_failed_compilation_flag,
                                     just_notice=True,
                                     logger=logger):
        logger.error(
            "Compilation of contig aligner software was unsuccessful! QUAST functionality will be limited."
        )
        return False

    if compile_tool('Minimap2',
                    contig_aligner_dirpath,
                    requirements,
                    just_notice=False,
                    logger=logger,
                    only_clean=only_clean):
        return True

    logger.error(
        "Compilation of contig aligner software was unsuccessful! QUAST functionality will be limited."
    )
    return False
Exemplo n.º 4
0
def download_tool(tool,
                  tool_version,
                  required_files,
                  logger,
                  url,
                  only_clean=False):
    tool_dirpath = get_dir_for_download(tool + tool_version,
                                        tool,
                                        required_files,
                                        logger,
                                        only_clean=only_clean)
    if not tool_dirpath:
        return None

    if only_clean:
        if os.path.isdir(tool_dirpath):
            shutil.rmtree(tool_dirpath, ignore_errors=True)
        return tool_dirpath

    failed_compilation_flag = join(tool_dirpath, 'make.failed')
    if not all(os.path.exists(join(tool_dirpath, fpath)) for fpath in required_files) and not \
            check_prev_compilation_failed(tool, failed_compilation_flag):
        downloaded_fpath = join(tool_dirpath, tool + '.tar.gz')
        logger.main_info('  Downloading third-party tools...')
        download_unpack_compressed_tar(tool, url, downloaded_fpath,
                                       tool_dirpath, logger)

        if not all(
                os.path.exists(join(tool_dirpath, fpath))
                for fpath in required_files):
            logger.warning('Failed to download ' + tool + ' from ' + url +
                           'and unpack it into ' + tool_dirpath)
            return None
    return tool_dirpath
Exemplo n.º 5
0
def download_manta(logger, bed_fpath=None, only_clean=False):
    global manta_dirpath
    manta_dirpath = get_dir_for_download('manta' + manta_version,
                                         'Manta', [config_manta_relpath],
                                         logger,
                                         only_clean=only_clean)
    if not manta_dirpath:
        return False

    manta_build_dirpath = join(manta_dirpath, 'build')
    config_manta_fpath = get_manta_fpath()
    if only_clean:
        if os.path.isdir(manta_build_dirpath):
            shutil.rmtree(manta_build_dirpath, ignore_errors=True)
        return True

    if not qconfig.no_sv and bed_fpath is None and not isfile(
            config_manta_fpath):
        if qconfig.platform_name == 'linux_64':
            url = manta_linux_url
            fpath = manta_ext_linux_fpath
        elif qconfig.platform_name == 'macosx':
            url = manta_osx_url
            fpath = manta_ext_osx_fpath
        else:
            logger.warning('Manta is not available for your platform.')
            return False

        if not exists(manta_build_dirpath):
            os.makedirs(manta_build_dirpath)
        manta_downloaded_fpath = join(manta_build_dirpath, 'manta.tar.bz2')

        if isfile(fpath):
            logger.info('Copying manta from ' + fpath)
            shutil.copy(fpath, manta_downloaded_fpath)
            logger.info('Unpacking ' + manta_downloaded_fpath + ' into ' +
                        manta_build_dirpath)
            unpack_tar(manta_downloaded_fpath, manta_build_dirpath)
        else:
            failed_compilation_flag = join(manta_dirpath, 'make.failed')
            if check_prev_compilation_failed('Manta', failed_compilation_flag):
                print_manta_warning(logger)
                return False

            logger.main_info('  Downloading binary distribution of Manta...')
            download_unpack_tar_bz('Manta', url, manta_downloaded_fpath,
                                   manta_build_dirpath, logger)

        manta_demo_dirpath = join(manta_build_dirpath, 'share', 'demo')
        if os.path.isdir(manta_demo_dirpath):
            shutil.rmtree(manta_demo_dirpath, ignore_errors=True)
        if not isfile(config_manta_fpath):
            logger.warning(
                'Failed to download binary distribution from https://github.com/ablab/quast/external_tools/manta '
                'and unpack it into ' + join(manta_dirpath, 'build/'))
            print_manta_warning(logger)
            return False
    return True
Exemplo n.º 6
0
def compile_gnuplot(logger, only_clean=False):
    tool_dirpath = join(qconfig.LIBS_LOCATION, 'gnuplot')
    tool_exec_fpath = gnuplot_exec_fpath()

    if only_clean:
        if isfile(tool_exec_fpath):
            os.remove(tool_exec_fpath)
        return True

    if not isfile(tool_exec_fpath):
        failed_compilation_flag = join(tool_dirpath, 'make.failed')
        if check_prev_compilation_failed('gnuplot',
                                         failed_compilation_flag,
                                         just_notice=True,
                                         logger=logger):
            return None
        logger.main_info("Compiling gnuplot...")
        prev_dir = os.getcwd()
        os.chdir(tool_dirpath)
        return_code = qutils.call_subprocess(
            [
                './configure', '--with-qt=no', '--disable-wxwidgets',
                '--prefix=' + tool_dirpath
            ],
            stdout=open(join(tool_dirpath, 'make.log'), 'w'),
            stderr=open(join(tool_dirpath, 'make.err'), 'w'),
            indent='    ')
        if return_code == 0:
            return_code = qutils.call_subprocess(
                ['make'],
                stdout=open(join(tool_dirpath, 'make.log'), 'w'),
                stderr=open(join(tool_dirpath, 'make.err'), 'w'),
                indent='    ')
        os.chdir(prev_dir)
        if return_code != 0 or not isfile(tool_exec_fpath):
            write_failed_compilation_flag('gnuplot',
                                          tool_dirpath,
                                          failed_compilation_flag,
                                          just_notice=True,
                                          logger=logger)
            return None
    return tool_exec_fpath
Exemplo n.º 7
0
def compile_aligner(logger, only_clean=False):
    requirements = ['nucmer', 'delta-filter', 'show-coords', 'show-snps', 'mummer', 'mummerplot', 'mgaps']
    mummer_failed_compilation_flag = join(contig_aligner_dirpath, 'make.failed')

    if only_clean:
        compile_tool('MUMmer', contig_aligner_dirpath, requirements, logger=logger, only_clean=only_clean)
        return True

    if check_prev_compilation_failed('MUMmer', mummer_failed_compilation_flag, just_notice=True, logger=logger):
        logger.error("Compilation of contig aligner software was unsuccessful! QUAST functionality will be limited.")
        return False

    fix_configure_timestamps(contig_aligner_dirpath)
    prefix_arg = '--prefix=' + contig_aligner_dirpath
    if compile_tool('MUMmer', contig_aligner_dirpath, requirements, just_notice=False, logger=logger, only_clean=only_clean,
                    configure_args=[prefix_arg, 'LDFLAGS=-static'] if qconfig.platform_name != 'macosx' else [prefix_arg]):
        return True

    logger.error("Compilation of contig aligner software was unsuccessful! QUAST functionality will be limited.")
    return False
Exemplo n.º 8
0
def download_manta(logger, bed_fpath=None, only_clean=False):
    if only_clean:
        if os.path.isdir(manta_build_dirpath):
            shutil.rmtree(manta_build_dirpath)
        return True

    if not qconfig.no_sv and bed_fpath is None and not isfile(config_manta_fpath):
        if qconfig.platform_name == 'linux_64':
            url = manta_linux_url
            fpath = manta_ext_linux_fpath
        elif qconfig.platform_name == 'macosx':
            url = manta_osx_url
            fpath = manta_ext_osx_fpath
        else:
            logger.warning('Manta is not available for your platform.')
            return False

        if not exists(manta_build_dirpath):
            os.makedirs(manta_build_dirpath)
        manta_downloaded_fpath = join(manta_build_dirpath, 'manta.tar.bz2')

        if isfile(fpath):
            logger.info('Copying manta from ' + fpath)
            shutil.copy(fpath, manta_downloaded_fpath)
            logger.info('Unpacking ' + manta_downloaded_fpath + ' into ' + manta_build_dirpath)
            unpack_tar(manta_downloaded_fpath, manta_build_dirpath)

        else:
            failed_compilation_flag = join(manta_dirpath, 'make.failed')
            if check_prev_compilation_failed('Manta', failed_compilation_flag):
                print_manta_warning(logger)
                return True

            logger.main_info('  Downloading binary distribution of Manta...')
            download_unpack_tar_bz('Manta', url, manta_downloaded_fpath, manta_build_dirpath, logger)

        if not isfile(config_manta_fpath):
            logger.warning('Failed to download binary distribution from https://github.com/ablab/quast/external_tools/manta '
                           'and unpack it into ' + join(manta_dirpath, 'build/'))
            print_manta_warning(logger)
    return True
Exemplo n.º 9
0
def download_tool(tool, tool_version, required_files, logger, url, only_clean=False):
    tool_dirpath = get_dir_for_download(tool + tool_version, tool, required_files, logger, only_clean=only_clean)
    if not tool_dirpath:
        return None

    if only_clean:
        if os.path.isdir(tool_dirpath):
            shutil.rmtree(tool_dirpath, ignore_errors=True)
        return tool_dirpath

    failed_compilation_flag = join(tool_dirpath, 'make.failed')
    if not all(os.path.exists(join(tool_dirpath, fpath)) for fpath in required_files) and not \
            check_prev_compilation_failed(tool, failed_compilation_flag):
        downloaded_fpath = join(tool_dirpath, tool + '.tar.gz')
        logger.main_info('  Downloading ' + tool + '...')
        download_unpack_compressed_tar(tool, url, downloaded_fpath, tool_dirpath, logger)

        if not all(os.path.exists(join(tool_dirpath, fpath)) for fpath in required_files):
            logger.warning('Failed to download ' + tool + ' from ' + url + 'and unpack it into ' + tool_dirpath)
            return None
    return tool_dirpath
Exemplo n.º 10
0
def manta_compilation_failed():
    failed_compilation_flag = join(manta_dirpath, 'make.failed')
    if check_prev_compilation_failed('Manta', failed_compilation_flag):
        return True
    return False
Exemplo n.º 11
0
def manta_compilation_failed():
    failed_compilation_flag = join(manta_dirpath, 'make.failed')
    if check_prev_compilation_failed('Manta', failed_compilation_flag):
        return True
    return False
Exemplo n.º 12
0
def compile_jellyfish(logger, only_clean=False):
    make_logs_basepath = join(jellyfish_src_dirpath, 'make')
    failed_compilation_flag = make_logs_basepath + '.failed'

    if only_clean:
        safe_rm(jellyfish_bin_fpath)
        safe_rm(failed_compilation_flag)
        return True

    if exists(jellyfish_bin_fpath):
        try:
            import jellyfish
        except:
            safe_rm(jellyfish_bin_fpath)

    if not exists(jellyfish_bin_fpath):
        if check_prev_compilation_failed('Jellyfish',
                                         failed_compilation_flag,
                                         logger=logger):
            return False

        # making
        logger.main_info('Compiling Jellyfish (details are in ' +
                         make_logs_basepath + '.log and make.err)')
        os.utime(join(jellyfish_src_dirpath, 'aclocal.m4'), None)
        os.utime(join(jellyfish_src_dirpath, 'Makefile.in'), None)
        os.utime(join(jellyfish_src_dirpath, 'config.h.in'), None)
        os.utime(join(jellyfish_src_dirpath, 'configure'), None)
        prev_dir = os.getcwd()
        os.chdir(jellyfish_src_dirpath)
        safe_rm(
            join(jellyfish_src_dirpath, 'swig', 'python', '__init__.pyc')
        )  ## in case if jellyfish was compiled with different python version
        safe_rm(jellyfish_python_dirpath)
        call_subprocess([
            './configure', '--prefix=' + jellyfish_dirpath,
            '--enable-python-binding=' + jellyfish_python_dirpath,
            'PYTHON_VERSION=' + str(sys.version_info[0]) + '.' +
            str(sys.version_info[1])
        ],
                        stdout=open(make_logs_basepath + '.log', 'w'),
                        stderr=open(make_logs_basepath + '.err', 'w'))
        try:
            return_code = call_subprocess(
                ['make'],
                stdout=open(make_logs_basepath + '.log', 'a'),
                stderr=open(make_logs_basepath + '.err', 'a'),
                logger=logger)
            return_code = call_subprocess(
                ['make', 'install'],
                stdout=open(make_logs_basepath + '.log', 'a'),
                stderr=open(make_logs_basepath + '.err', 'a'),
                logger=logger)
        except IOError:
            os.chdir(prev_dir)
            msg = 'Permission denied accessing ' + jellyfish_src_dirpath + '. Did you forget sudo?'
            logger.notice(msg)
            return False

        os.chdir(prev_dir)
        if return_code != 0 or not exists(jellyfish_bin_fpath):
            write_failed_compilation_flag('Jellyfish',
                                          jellyfish_src_dirpath,
                                          failed_compilation_flag,
                                          logger=logger)
            return False
    return True