Exemple #1
0
def make_and_check_prog(name, verbose=False, raise_error=True):
    p = program.Program(prog_name_to_default[name],
                        prog_to_version_cmd[name][0],
                        prog_to_version_cmd[name][1],
                        environment_var=prog_to_env_var.get(name, None))

    if not p.in_path():
        handle_error("Didn't find " + name + " in path. Looked for:" + p.path,
                     raise_error=raise_error)
        return p

    version = p.version()
    if version is None:
        handle_error('Found ' + name + " but couldn't get version.",
                     raise_error=raise_error)
        return p

    if not p.version_at_least(min_versions[name]):
        handle_error('Version of ' + name + ' too low. I found ' +
                     p.version() + ', but must be at least ' +
                     min_versions[name],
                     raise_error=raise_error)
        return p

    if verbose:
        print('Using', name, 'version', p.version())

    return p
Exemple #2
0
def make_and_check_prog(name,
                        verbose=False,
                        raise_error=True,
                        filehandle=None,
                        debug=False,
                        required=False):
    p = program.Program(prog_name_to_default[name],
                        prog_to_version_cmd[name][0],
                        prog_to_version_cmd[name][1],
                        environment_var=prog_to_env_var.get(name, None),
                        debug=debug)

    if not p.in_path():
        if required:
            die = True
        else:
            die = raise_error and (name not in not_required)
        handle_error("WARNING: Didn't find " + name + " in path. Looked for:" +
                     p.path,
                     raise_error=die)
        return p

    version = p.version

    if version is None:
        handle_error('Found ' + name + " but couldn't get version.",
                     raise_error=raise_error)
        return p

    if not p.version_at_least(min_versions[name]):
        handle_error('Version of ' + name + ' too low. I found ' + p.version +
                     ', but must be at least ' + min_versions[name] +
                     '. Found here:\n' + p.from_which,
                     raise_error=raise_error)
        return p

    if name == 'spades' and p.version == bad_versions['spades']:
        handle_error(
            'ERROR! SPAdes version ' + bad_versions['spades'] +
            ' is incompatible with Circlator. Please use SPAdes 3.7.1',
            raise_error=raise_error)
        return p

    if name == 'spades' and not p.version.startswith('3.7.'):
        print(
            'WARNING: SPAdes version',
            p.version,
            'is being used. It will work, but better results are usually obtained from Circlator using SPAdes version 3.7.1. Although 3.7.1 is not the latest version, we recommend it for Circlator.',
            file=sys.stderr)

    if verbose:
        print(name, p.version, p.from_which, sep='\t')

    if filehandle:
        print(name, p.version, p.from_which, sep='\t', file=filehandle)

    return p