def test_make_targets():
    rules = [MockRule(name="samtools_depth", output={"txt": "{version}/{end}/medium.depth.txt"}),
             MockRule(name="samtools_rmdup", output={"txt": "{version}/{end}/medium.rmdup.txt"})]
    conf = config.application_config()
    tgt = helpers.make_targets(rules, conf, 'samtools', end='se')
    # samtools_rmdup only available for version 1.3.1
    assert len(tgt) == 3
def test_get_every_application_fixture():
    conf = config.application_config()
    for ad in config.APPLICATION_DIRECTORIES:
        app = os.path.basename(ad)
        version = conf[app]['_default']
        for command in conf[app].keys():
            if command.startswith("_"):
                continue
            af = config.get_application_fixture(app, command, version, 'se')
            for x in af.values():
                assert os.path.dirname(x).startswith(os.path.join(app, str(version)))
def application_output(application, command, version, end="se", **kwargs):
    """
    Fixture factory to generate application output.

    Params:
      application (str): application name
      command (str): application command name
      version (str): application version
      end (str): paired end or single end

    Returns:
      func: a filetype fixture function
    """
    from pytest_ngsfixtures.config import application_config
    conf = application_config()
    assert application in conf.keys(), "no such application '{}'".format(
        application)
    assert command in conf[application].keys(), "no such command '{}'".format(
        command)
    assert type(version) is str, "version must be string"
    if "_versions" in conf[application][command].keys():
        _versions = [str(x) for x in conf[application][command]["_versions"]]
    else:
        _versions = [str(x) for x in conf[application]["_versions"]]
    assert version in _versions, "no such application output for version '{}', application '{}'".format(
        version, application)
    assert end in ["se", "pe"], "end must be either se or pe"
    params = {'version': version, 'end': end}
    output = [
        x.format(**params)
        for x in conf[application][command]['output'].values()
    ]
    if len(output) == 1:
        src = os.path.join("applications", application, output[0])
        return filetype(src, **kwargs)
    else:
        src = [os.path.join("applications", application, x) for x in output]
        return fileset(src, **kwargs)
def test_collect_samtools_config_application():
    conf = config.application_config('samtools')
    assert 'samtools' in conf.keys()
    assert 'fastqc' not in conf.keys()
    assert 'input' in conf.keys()
def test_collect_bwa_config_application():
    conf = config.application_config('bwa')
    assert 'bwa' in conf.keys()
    assert 'fastqc' not in conf.keys()
    assert 'input' in conf.keys()
def test_collect_config():
    conf = config.application_config()
    assert 'bwa' in conf.keys()
    assert 'fastqc' in conf.keys()
    assert 'input' in conf.keys()