예제 #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"]]