Exemplo n.º 1
0
def test_plugin_cleanup():
    for p in init_plugins():
        deactivate(p)

    # cleanup after testing pluging
    genome_dir = os.path.join(os.getcwd(), ".genomepy_plugin_tests")
    genomepy.utils.rm_rf(genome_dir)
Exemplo n.º 2
0
def manage_plugins(command, plugin_names=None):
    """Enable or disable plugins.
    """
    if plugin_names is None:
        plugin_names = []
    active_plugins = config.get("plugin", [])
    plugins = init_plugins()
    if command == "enable":
        for name in plugin_names:
            if name not in plugins:
                raise ValueError("Unknown plugin: {}".format(name))
            if name not in active_plugins:
                active_plugins.append(name)
    elif command == "disable":
        for name in plugin_names:
            if name in active_plugins:
                active_plugins.remove(name)
    elif command == "list":
        print("{:20}{}".format("plugin", "enabled"))
        for plugin in sorted(plugins):
            print("{:20}{}".format(plugin, {
                False: "",
                True: "*"
            }[plugin in active_plugins]))
    else:
        raise ValueError("Invalid plugin command")
    config["plugin"] = active_plugins
    config.save()

    if command in ["enable", "disable"]:
        print("Enabled plugins: {}".format(", ".join(sorted(active_plugins))))
Exemplo n.º 3
0
def genome(request, tempdir):
    """Create a test genome."""
    name = "dm3"    # Use fake name for blacklist test
    fafile = "tests/data/small_genome.fa"

    # Input needs to be bgzipped, depending on param
    if os.path.exists(fafile + ".gz"):
        if request.param == "unzipped":
            check_call(["gunzip", fafile + ".gz"])
    elif request.param == "bgzipped":
        check_call(["bgzip", fafile])

    tmpdir = os.path.join(tempdir, request.param, name)
    os.makedirs(tmpdir)

    if request.param == "bgzipped":
        fafile += ".gz"

    copyfile(fafile, os.path.join(tmpdir, os.path.basename(fafile)))
    for p in init_plugins():
        activate(p)
    # provide the fixture value
    yield Genome(name, genome_dir=os.path.join(tempdir, request.param))
    if os.path.exists(fafile) and request.param == "unzipped":
        check_call(["bgzip", fafile])
Exemplo n.º 4
0
def manage_plugins(command, plugin_names=None):
    """List, enable or disable plugins."""
    plugins = init_plugins()
    for name in plugin_names if plugin_names else []:
        if name not in plugins:
            raise ValueError(f"Unknown plugin: {name}")

    active_plugins = config.get("plugin", [])
    if command == "list":
        print("{:20}{}".format("plugin", "enabled"))
        for plugin in sorted(plugins):
            print("{:20}{}".format(plugin, {
                False: "",
                True: "*"
            }[plugin in active_plugins]))
        return

    elif command in ["enable", "activate"]:
        for name in plugin_names:
            if name not in active_plugins:
                active_plugins.append(name)

    elif command in ["disable", "deactivate"]:
        for name in plugin_names:
            if name in active_plugins:
                active_plugins.remove(name)

    else:
        raise ValueError(f"Invalid plugin command: {command}")

    config["plugin"] = active_plugins
    config.save()
    print("Enabled plugins: {}".format(", ".join(sorted(active_plugins))))
Exemplo n.º 5
0
def manage_plugins(command, plugin_names=None):
    """Enable or disable plugins.
    """ 
    if plugin_names is None:
        plugin_names = []
    active_plugins = config.get("plugin", [])
    plugins = init_plugins()
    if command == "enable":
        for name in plugin_names:
            if name not in plugins:
                raise ValueError("Unknown plugin: {}".format(name))
            if name not in active_plugins:
                active_plugins.append(name)
    elif command == "disable":
        for name in plugin_names:
            if name in active_plugins:
                active_plugins.remove(name)
    elif command == "list":
        print("{:20}{}".format("plugin", "enabled"))
        for plugin in sorted(plugins):
            print("{:20}{}".format(plugin, {False:"", True:"*"}[plugin in active_plugins]))
    else:
        raise ValueError("Invalid plugin command")
    config["plugins"] = active_plugins
    config.save()

    if command in ["enable", "disable"]:
        print("Enabled plugins: {}".format(", ".join(sorted(active_plugins))))
Exemplo n.º 6
0
def test_plugins():
    # activate and check all plugins
    for p in init_plugins():
        if p not in ["blacklist", "star"]:
            assert genomepy.utils.cmd_ok(p)
        elif p == "star":
            assert genomepy.utils.cmd_ok(p.upper())
        activate(p)
Exemplo n.º 7
0
def genome(tempdir):
    """Create a test genome.""" 
    name = "small_genome" 
    fafile = "tests/data/small_genome.fa"
    if os.path.exists(fafile + ".gz"):
        check_call(["gunzip", fafile + ".gz"])

    os.mkdir(os.path.join(tempdir, name))
    copyfile(fafile, os.path.join(tempdir, name, os.path.basename(fafile)))
    for p in init_plugins():
        activate(p)
    yield Genome(name, genome_dir=tempdir)  # provide the fixture value
    if os.path.exists(fafile):
        check_call(["gzip", fafile])