import multiprocessing


def _set_resources(parallel, config):
    """Set resource availability for programs, downsizing to local runs.
    """
    for program in ["gatk", "novoalign"]:
        if not config["resources"].has_key(program):
            config["resources"][program] = {}
        if parallel["type"] == "local":
            cores = min(parallel["cores"], multiprocessing.cpu_count())
            config["resources"][program]["cores"] = cores
    return config