示例#1
0
def test_patlas_compiler_channels():

    con = [{
        "input": {
            "process": "__init__",
            "lane": 0
        },
        "output": {
            "process": "mash_screen",
            "lane": 1
        }
    }, {
        "input": {
            "process": "__init__",
            "lane": 0
        },
        "output": {
            "process": "mapping_patlas",
            "lane": 2
        }
    }]

    nf = eg.NextflowGenerator(con, "teste.nf", process_map)

    nf._set_channels()
    nf._set_compiler_channels()

    assert len(nf.compilers["patlas_consensus"]["channels"]) == 2
示例#2
0
def test_automatic_dependency_multi():

    con = [{
        "input": {
            "process": "__init__",
            "lane": 1
        },
        "output": {
            "process": "trimmomatic",
            "lane": 1
        }
    }, {
        "input": {
            "process": "trimmomatic",
            "lane": 1
        },
        "output": {
            "process": "spades",
            "lane": 1
        }
    }]

    nf = eg.NextflowGenerator(con, "teste.nf", process_map)

    assert len([x for x in nf.processes
                if x.template == "integrity_coverage"]) == 1
示例#3
0
def test_automatic_dependency_non_raw():

    con = [{
        "input": {
            "process": "__init__",
            "lane": 1
        },
        "output": {
            "process": "spades",
            "lane": 1
        }
    }, {
        "input": {
            "process": "spades",
            "lane": 1
        },
        "output": {
            "process": "pilon",
            "lane": 1
        }
    }]

    nf = eg.NextflowGenerator(con, "teste.nf", process_map)

    assert nf.processes[2].parent_lane == 1
示例#4
0
def test_automatic_dependency_wfork_4():

    con = [{
        "input": {
            "process": "__init__",
            "lane": 0
        },
        "output": {
            "process": "reads_download",
            "lane": 1
        }
    }, {
        "input": {
            "process": "reads_download",
            "lane": 1
        },
        "output": {
            "process": "skesa",
            "lane": 2
        }
    }, {
        "input": {
            "process": "reads_download",
            "lane": 1
        },
        "output": {
            "process": "spades",
            "lane": 3
        }
    }]

    nf = eg.NextflowGenerator(con, "teste.nf", process_map)
    nf._set_channels()

    assert nf.processes[4].parent_lane == 3
示例#5
0
def test_automatic_dependency_wfork_2():

    con = [{
        "input": {
            "process": "__init__",
            "lane": 0
        },
        "output": {
            "process": "spades",
            "lane": 1
        }
    }, {
        "input": {
            "process": "__init__",
            "lane": 0
        },
        "output": {
            "process": "integrity_coverage",
            "lane": 2
        }
    }]

    nf = eg.NextflowGenerator(con, "teste.nf", process_map)
    nf._set_channels()

    assert len(nf.main_raw_inputs["fastq"]["raw_forks"]) == 2
示例#6
0
def test_automatic_dependency_wfork():

    con = [{
        "input": {
            "process": "__init__",
            "lane": 0
        },
        "output": {
            "process": "spades",
            "lane": 1
        }
    }, {
        "input": {
            "process": "__init__",
            "lane": 0
        },
        "output": {
            "process": "integrity_coverage",
            "lane": 2
        }
    }]

    nf = eg.NextflowGenerator(con, "teste.nf", process_map)

    assert nf.processes[1].template == "integrity_coverage"
示例#7
0
def implicit_link_2():

    con = [{
        "input": {
            "process": "__init__",
            "lane": 1
        },
        "output": {
            "process": "integrity_coverage",
            "lane": 1
        }
    }, {
        "input": {
            "process": "integrity_coverage",
            "lane": 1
        },
        "output": {
            "process": "spades",
            "lane": 1
        }
    }, {
        "input": {
            "process": "spades",
            "lane": 1
        },
        "output": {
            "process": "assembly_mapping",
            "lane": 1
        }
    }]

    return eg.NextflowGenerator(con, "teste.nf", process_map)
示例#8
0
def test_extra_inputs_3():

    con = [{
        "input": {
            "process": "__init__",
            "lane": 1
        },
        "output": {
            "process": "integrity_coverage",
            "lane": 1
        }
    }, {
        "input": {
            "process": "integrity_coverage",
            "lane": 1
        },
        "output": {
            "process": "fastqc={'extra_input':'teste'}",
            "lane": 1
        }
    }]

    nf = eg.NextflowGenerator(con, "teste.nf", process_map)
    nf._set_channels()

    assert [list(nf.extra_inputs.keys())[0],
            nf.extra_inputs["teste"]["input_type"],
            nf.extra_inputs["teste"]["channels"]] == \
           ["teste", "fastq", ["EXTRA_fastqc_1_2"]]
示例#9
0
def test_run_time_directives():

    con = [{
        "input": {
            "process": "__init__",
            "lane": 1
        },
        "output": {
            "process": "integrity_coverage",
            "lane": 1
        }
    }, {
        "input": {
            "process": "integrity_coverage",
            "lane": 1
        },
        "output": {
            "process": "fastqc={'cpus':'3'}",
            "lane": 1
        }
    }]

    nf = eg.NextflowGenerator(con, "teste.nf", process_map)

    assert nf.processes[2].directives["fastqc2"]["cpus"] == "3"
示例#10
0
def test_invalid_process():

    con = [{"input": {"process": "__init__", "lane": 1},
            "output": {"process": "invalid", "lane": 1}}]

    with pytest.raises(SystemExit):
        eg.NextflowGenerator(con, "teste.nf")
示例#11
0
def test_extra_inputs_invalid_2():

    con = [{
        "input": {
            "process": "__init__",
            "lane": 1
        },
        "output": {
            "process": "integrity_coverage",
            "lane": 1
        }
    }, {
        "input": {
            "process": "integrity_coverage",
            "lane": 1
        },
        "output": {
            "process": "spades={'extra_input':'teste'}",
            "lane": 1
        }
    }, {
        "input": {
            "process": "spades",
            "lane": 1
        },
        "output": {
            "process": "abricate={'extra_input':'teste'}",
            "lane": 1
        }
    }]

    nf = eg.NextflowGenerator(con, "teste.nf", process_map)

    with pytest.raises(SystemExit):
        nf._set_channels()
示例#12
0
def test_run_time_directives_full():

    con = [{
        "input": {
            "process": "__init__",
            "lane": 1
        },
        "output": {
            "process": "integrity_coverage",
            "lane": 1
        }
    }, {
        "input": {
            "process": "integrity_coverage",
            "lane": 1
        },
        "output": {
            "process": "fastqc={'cpus':'3','memory':'4GB',"
            "'container':'img','version':'1'}",
            "lane": 1
        }
    }]

    nf = eg.NextflowGenerator(con, "teste.nf", process_map)

    assert [nf.processes[2].directives["fastqc2"]["cpus"],
            nf.processes[2].directives["fastqc2"]["memory"],
            nf.processes[2].directives["fastqc2"]["container"],
            nf.processes[2].directives["fastqc2"]["version"]] == \
           ["3", "4GB", "img", "1"]
示例#13
0
def test_not_automatic_dependency():

    con = [{"input": {"process": "__init__", "lane": 1},
            "output": {"process": "spades", "lane": 1}}]

    with pytest.raises(SystemExit):
        eg.NextflowGenerator(con, "teste.nf", auto_dependency=False)
示例#14
0
def test_extra_inputs_2():

    con = [{
        "input": {
            "process": "__init__",
            "lane": 1
        },
        "output": {
            "process": "integrity_coverage",
            "lane": 1
        }
    }, {
        "input": {
            "process": "integrity_coverage",
            "lane": 1
        },
        "output": {
            "process": "spades",
            "lane": 1
        }
    }, {
        "input": {
            "process": "spades",
            "lane": 1
        },
        "output": {
            "process": "abricate={'extra_input':'teste'}",
            "lane": 1
        }
    }]

    nf = eg.NextflowGenerator(con, "teste.nf", process_map)

    assert nf.processes[3].extra_input == "teste"
示例#15
0
def test_automatic_dependency_2():

    con = [{"input": {"process": "__init__", "lane": 1},
            "output": {"process": "spades", "lane": 1}}]

    nf = eg.NextflowGenerator(con, "teste.nf")

    assert nf.processes[1].output_channel == nf.processes[2].input_channel
示例#16
0
def single_con_multi_raw():

    con = [{"input": {"process": "__init__", "lane": 1},
            "output": {"process": "assembly_mapping", "lane": 1}},
           {"input": {"process": "assembly_mapping", "lane": 1},
            "output": {"process": "pilon", "lane": 1}}]

    return eg.NextflowGenerator(con, "teste.nf")
示例#17
0
def test_run_time_directives_invalid():

    con = [{"input": {"process": "__init__", "lane": 1},
            "output": {"process": "integrity_coverage", "lane": 1}},
           {"input": {"process": "integrity_coverage", "lane": 1},
            "output": {"process": "fastqc={'cpus'", "lane": 1}}]

    with pytest.raises(SystemExit):
        eg.NextflowGenerator(con, "teste.nf")
示例#18
0
def test_connections_ignore_type():

    con = [{"input": {"process": "__init__", "lane": 1},
            "output": {"process": "skesa", "lane": 1}},
           {"input": {"process": "skesa", "lane": 1},
            "output": {"process": "patho_typing", "lane": 1}}
           ]

    eg.NextflowGenerator(con, "teste.nf")
示例#19
0
def single_con():

    con = [{"input": {"process": "__init__", "lane": 1},
            "output": {"process": "integrity_coverage", "lane": 1}},
           {"input": {"process": "integrity_coverage", "lane": 1},
            "output": {"process": "fastqc", "lane": 1}}
           ]

    return eg.NextflowGenerator(con, "teste.nf")
示例#20
0
def test_automatic_dependency_3():

    con = [{"input": {"process": "__init__", "lane": 1},
            "output": {"process": "spades", "lane": 1}}]

    nf = eg.NextflowGenerator(con, "teste.nf")

    assert [nf.processes[1].parent_lane, nf.processes[2].parent_lane] == \
           [None, 1]
示例#21
0
def test_extra_inputs_1():

    con = [{"input": {"process": "__init__", "lane": 1},
            "output": {"process": "integrity_coverage", "lane": 1}},
           {"input": {"process": "integrity_coverage", "lane": 1},
            "output": {"process": "fastqc={'extra_input':'teste'}", "lane": 1}}]

    nf = eg.NextflowGenerator(con, "teste.nf")

    assert nf.processes[2].extra_input == "teste"
示例#22
0
def test_connections_invalid():

    con = [{"input": {"process": "__init__", "lane": 1},
            "output": {"process": "spades", "lane": 1}},
           {"input": {"process": "spades", "lane": 1},
            "output": {"process": "integrity_coverage", "lane": 1}}
           ]

    with pytest.raises(SystemExit):
        eg.NextflowGenerator(con, "teste.nf")
示例#23
0
def test_extra_inputs_invalid():

    con = [{"input": {"process": "__init__", "lane": 1},
            "output": {"process": "integrity_coverage", "lane": 1}},
           {"input": {"process": "integrity_coverage", "lane": 1},
            "output": {"process": "fastqc={'extra_input':'default'}", "lane": 1}}]

    nf = eg.NextflowGenerator(con, "teste.nf")

    with pytest.raises(SystemExit):
        nf._set_channels()
示例#24
0
def test_patlas_compiler_channels_empty():

    con = [{"input": {"process": "__init__", "lane": 1},
            "output": {"process": "trimmomatic", "lane": 1}}]

    nf = eg.NextflowGenerator(con, "teste.nf")

    nf._set_channels()
    nf._set_compiler_channels()

    assert len(nf.compilers["patlas_consensus"]["channels"]) == 0
示例#25
0
def raw_forks():

    con = [{"input": {"process": "__init__", "lane": 0},
            "output": {"process": "integrity_coverage", "lane": 1}},
           {"input": {"process": "integrity_coverage", "lane": 1},
            "output": {"process": "fastqc", "lane": 1}},
           {"input": {"process": "__init__", "lane": 0},
            "output": {"process": "patho_typing", "lane": 2}},
           {"input": {"process": "__init__", "lane": 0},
            "output": {"process": "seq_typing", "lane": 3}}]

    return eg.NextflowGenerator(con, "teste.nf")
示例#26
0
def test_simple_init():

    con = [{"input": {"process": "__init__", "lane": 1},
            "output": {"process": "{}", "lane": 1}}]

    for p in process_map:

        con[0]["output"]["process"] = p
        nf = eg.NextflowGenerator(con, "teste/teste.nf",
                                  ignore_dependencies=True)

        assert [len(nf.processes), nf.processes[1].template] == \
            [2, p]
示例#27
0
def single_fork():

    con = [{"input": {"process": "__init__", "lane": 1},
            "output": {"process": "integrity_coverage", "lane": 1}},
           {"input": {"process": "integrity_coverage", "lane": 1},
            "output": {"process": "spades", "lane": 2}},
           {"input": {"process": "integrity_coverage", "lane": 1},
            "output": {"process": "skesa", "lane": 3}},
           {'input': {'process': 'spades', 'lane': 2},
            'output': {'process': 'abricate', 'lane': 2}},
           {'input': {'process': 'skesa', 'lane': 3},
            'output': {'process': 'abricate', 'lane': 3}}]

    return eg.NextflowGenerator(con, "teste.nf")
示例#28
0
def single_con_fasta():

    con = [{
        "input": {
            "process": "__init__",
            "lane": 1
        },
        "output": {
            "process": "abricate",
            "lane": 1
        }
    }]

    return eg.NextflowGenerator(con, "teste.nf", process_map)
示例#29
0
def single_status():

    con = [{
        "input": {
            "process": "__init__",
            "lane": 1
        },
        "output": {
            "process": "skesa",
            "lane": 1
        }
    }]

    return eg.NextflowGenerator(con, "teste.nf", process_map)
示例#30
0
def test_extra_inputs_default():

    con = [{"input": {"process": "__init__", "lane": 1},
            "output": {"process": "integrity_coverage", "lane": 1}},
           {"input": {"process": "integrity_coverage", "lane": 1},
            "output": {"process": "spades", "lane": 1}},
           {"input": {"process": "spades", "lane": 1},
            "output": {"process": "abricate={'extra_input':'default'}", "lane": 1}}
           ]

    nf = eg.NextflowGenerator(con, "teste.nf")
    nf._set_channels()

    assert [list(nf.extra_inputs.keys())[0],
            nf.extra_inputs["fasta"]["input_type"],
            nf.extra_inputs["fasta"]["channels"]] == \
           ["fasta", "fasta", ["EXTRA_abricate_1_3"]]