Exemplo n.º 1
0
def test_module():
    # a rule without README
    m = snaketools.Module('mark_duplicates')
    m.description
    print(m)
    m.path
    m.snakefile

    # a rule with README
    m = snaketools.Module('dag')
    m.description
    m.overview
    m.is_executable()
    m.check()

    # a pipeline
    m = snaketools.Module('quality_control')
    m.is_executable()
    m.check()
    m.snakefile
    m.name
    m
    print(m)
    assert m.cluster_config.endswith("cluster_config.json")
    assert m.schema_config.endswith("schema.yaml")
Exemplo n.º 2
0
def test_module():
    # a rule without README
    m = snaketools.Module('mark_duplicates_dynamic')
    m.description
    print(m)
    m # test __repr__
    m.__repr__()
    m.path
    m.snakefile
    m.overview
    # a rule with README
    m = snaketools.Module('dag')
    m.description
    m.overview
    assert m.is_executable()
    m.check()

    # a pipeline
    m = snaketools.Module('compressor')
    m.is_executable()
    m.check()
    m.snakefile
    m.name
    m
    print(m)
    assert m.cluster_config.endswith("cluster_config.json")
    assert m.schema_config.endswith("schema.yaml")
Exemplo n.º 3
0
def test_sequana_config():
    s = snaketools.Module("compressor")
    config = snaketools.SequanaConfig(s.config)

    assert config.config.get("compressor")["source"] == "fastq.gz"
    assert config.config.get("kraken:dummy") == None

    # --------------------------------- tests different constructors
    config = snaketools.SequanaConfig()
    config = snaketools.SequanaConfig({"test": 1})
    assert config.config.test == 1
    # with a dictionary
    config = snaketools.SequanaConfig(config.config)
    # with a sequanaConfig instance
    config = snaketools.SequanaConfig(config)
    # with a non-yaml file
    try:
        json = sequana_data('test_summary_fastq_stats.json')
        config = snaketools.SequanaConfig(json)
        assert False
    except:
        assert True
    try:
        config = snaketools.SequanaConfig("dummy_dummy")
        assert False
    except:
        assert True

    # Test an exception
    s = snaketools.Module("compressor")
    config = snaketools.SequanaConfig(s.config)
    config._recursive_update(config._yaml_code,
                             {"input_directory_dummy": "test"})

    #config.check_config_with_schema(s.schema_config)
    # loop over all pipelines, read the config, save it and check the content is
    # identical. This requires to remove the templates. We want to make sure the
    # empty strings are kept and that "no value" are kept as well
    #
    #    field1: ""
    #    field2:
    #
    # is unchanged
    from easydev import TempFile
    output = TempFile(suffix=".yaml")
    for pipeline in snaketools.pipeline_names:
        config_filename = Module(pipeline)._get_config()
        cfg1 = SequanaConfig(config_filename)
        cfg1.cleanup()  # remove templates and strip strings

        cfg1.save(output.name)
        cfg2 = SequanaConfig(output.name)
        assert cfg2._yaml_code == cfg1._yaml_code
        cfg2._update_config()
        assert cfg1.config == cfg2.config
    output.delete()
Exemplo n.º 4
0
def test_yamlreader():
    filename = sequana_data("test_gui_generic_config.yaml")
    r = YamlDocParser(filename)
    assert r.sections['N'] == '# example of docstring\n'

    # check docstring is parsed with #### removed
    r = YamlDocParser(snaketools.Module('quality_control').config)
    docstring = r._block2docstring("fastqc")
    assert docstring.startswith("FastQC")

    assert r._block2docstring("dummy") is None

    # check that pipelines can be parsed
    for pipeline in snaketools.pipeline_names:
        filename = snaketools.Module(pipeline).config
        r = YamlDocParser(filename)
Exemplo n.º 5
0
def test_valid_config():
    config = snaketools.SequanaConfig(None)

    s = snaketools.Module("quality_control")
    config = snaketools.SequanaConfig(s.config)

    from easydev import TempFile
    with TempFile() as fh:
        config.save(fh.name)
Exemplo n.º 6
0
def _test_module_onweb():
    m = snaketools.Module('quality_control')
    m.onweb()