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
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
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
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
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
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"
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)
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"]]
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"
def test_invalid_process(): con = [{"input": {"process": "__init__", "lane": 1}, "output": {"process": "invalid", "lane": 1}}] with pytest.raises(SystemExit): eg.NextflowGenerator(con, "teste.nf")
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()
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"]
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)
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"
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
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")
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")
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")
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")
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]
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"
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")
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()
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
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")
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]
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")
def single_con_fasta(): con = [{ "input": { "process": "__init__", "lane": 1 }, "output": { "process": "abricate", "lane": 1 } }] return eg.NextflowGenerator(con, "teste.nf", process_map)
def single_status(): con = [{ "input": { "process": "__init__", "lane": 1 }, "output": { "process": "skesa", "lane": 1 } }] return eg.NextflowGenerator(con, "teste.nf", process_map)
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"]]