Exemple #1
0
def test_ariba_stop_codon_sa(request):
    test_data = os.path.abspath(globals()["test_data"])
    conf_dir = pjoin(test_data,"gene_extractor/sa")
    data_dir = pjoin(request.config.getoption('--large-test-data'),"sa/sast300")
    pkg_data = resources.get_pkg_data_dir("MICGENT")
    cwl_dir = pjoin(pkg_data,"cwl")
    cwl_wf = pjoin(cwl_dir,"ariba_run.cwl")
    conda_env = request.config.getoption('--conda-env-ngs-mstb')
    with helpers.mkchdir("ariba_stop_codon_sa"):
        runner_conf = make_extractor_runner_conf(conda_env,runner_no_retry=True,leave_workdir=True) #batchSystem="Torque",
        inp_reads = [ path_to_cwl_file(os.path.join(data_dir,"SMA807030_S1_L001_R{}_001.fastq.gz".format(i_read))) \
            for i_read in (1,2) ] # SMA1927338_S1_L001_R1_001.fastq.gz
        wf_inp = os.path.abspath("wf_inp.yaml")
        inp = dict(
            reads_1 = inp_reads[0],
            reads_2 = inp_reads[1],
            threads = 8,
            serial = True,
            debug = True,
            SampleID = "SMA807030",
            prepareref_tgz = path_to_cwl_file(pjoin(conf_dir,"ref_HA.arbref.tar"))
            )
        yaml_util.dump_yaml(inp,wf_inp)
        cmd = ("python -m MICGENT.cwl_runner --config cwl_runner.yaml "
            "run-toil --logLevel DEBUG "
            "{cwl_wf} {wf_inp}").format(**locals())
        check_call(shlex.split(cmd))
Exemple #2
0
def test_ariba_skewed_cov_filter_rsv(request):
    test_data = os.path.abspath(globals()["test_data"])
    conf_dir = pjoin(test_data,"gene_extractor/rsv")
    data_dir = pjoin(request.config.getoption('--large-test-data'),"rsv/SA2018")
    pkg_data = resources.get_pkg_data_dir("MICGENT")
    cwl_dir = pjoin(pkg_data,"cwl")
    cwl_wf = pjoin(cwl_dir,"ariba_run.cwl")
    conda_env = request.config.getoption('--conda-env-ngs-mstb')
    with helpers.mkchdir("ariba_run_skewed_cov_filter_rsv"):
        runner_conf = make_extractor_runner_conf(conda_env,runner_no_retry=True,leave_workdir=True)
        inp_reads = [ path_to_cwl_file(os.path.join(data_dir,"SMA589764_S1_L001_R{}_001.fastq.gz".format(i_read))) \
            for i_read in (1,2) ]
        wf_inp = os.path.abspath("wf_inp.yaml")
        inp = dict(
            reads_1 = inp_reads[0],
            reads_2 = inp_reads[1],
            assembly_cov = 1000000,
            assembly_cov_min = 10,
            assembler = "plugin",
            plugin_asm_options = 'python -m MICGENT.ariba_asm_plugin asm-for-skewed-coverage --extra-args "{deterministic: true}"',
            threads = 8,
            serial = True,
            debug = True,
            SampleID = "SMA589764",
            prepareref_tgz = path_to_cwl_file(pjoin(conf_dir,"ref_AB_single.trimmed.arbref.tgz"))
            )
        yaml_util.dump_yaml(inp,wf_inp)
        cmd = ("python -m MICGENT.cwl_runner --config cwl_runner.yaml "
            "run-toil --logLevel DEBUG "
            "{cwl_wf} {wf_inp}").format(**locals())
        check_call(shlex.split(cmd))
Exemple #3
0
def test_clean_reads_small_sa(request):
    test_data = os.path.abspath(globals()["test_data"])
    data_dir = pjoin(request.config.getoption('--large-test-data'),"sa/sast2")
    pkg_data = resources.get_pkg_data_dir("MICGENT")
    cwl_dir = pjoin(pkg_data,"cwl")
    cwl_wf = pjoin(cwl_dir,"clean_reads_qc.cwl")
    conda_env = request.config.getoption('--conda-env-ngs-mstb')
    with helpers.mkchdir("clean_reads_small_sa"):
        runner_conf = make_extractor_runner_conf(conda_env,runner_no_retry=True,batchSystem="singleMachine")
        inp_reads = [ path_to_cwl_file(os.path.join(data_dir,"SMA1828869_S1_L001_R{}_001.fastq.gz".format(i_read))) \
            for i_read in (1,2) ] # SMA1927338_S1_L001_R1_001.fastq.gz
        wf_inp = os.path.abspath("wf_inp.yaml")
        inp = dict(
            SampleID = "SASMA1828869",
            inp_seq1 = inp_reads[0],
            inp_seq2 = inp_reads[1],
            threads = 8
            )
        yaml_util.dump_yaml(inp,wf_inp)
        cmd = ("python -m MICGENT.cwl_runner --config cwl_runner.yaml "
            "run-toil --logLevel DEBUG "
            "{cwl_wf} {wf_inp}").format(**locals())
        check_call(shlex.split(cmd))
Exemple #4
0
def test_file_sig_cmp_msg():
    """Test config file interface and error message generation in signature comparisons"""
    test_fn = "test.txt"
    sig_conf_fn = "sig.yaml"
    test_sig_fn = "test.sig"
    key_other = "65757ffsswgw8g"
    with open(test_fn,"w") as out:
        out.write("FFUGJGJHGJGYNVNVvhgjgjyg76868uyu\n")
    yaml_util.dump_yaml(dict(file_sig_cmp_msg=dict(key=key_other)),sig_conf_fn)
    test_sig = sig.file_sig(test_fn,out_file=test_sig_fn)
    sig.file_sig_cmp_msg(sig_file=test_sig_fn,inp_file=test_fn)
    with pytest.raises(SystemExit):
        sig.file_sig_cmp_msg(sig_file=test_sig_fn,inp_file=test_fn,key=key_other)
    with subprocess.Popen(["python","-m","MICGENT.sig","--config",sig_conf_fn,"file-sig-cmp-msg",
        "--msg","Sig mismatch",test_sig_fn,test_fn],stderr=subprocess.PIPE,universal_newlines=True) as p:
        p.wait() # works around bug in Python 3.6 context manager - can get p.returncode None
        assert p.returncode != 0, "Expected a return code indicating caught error"
        assert p.stderr.read().strip() == "Sig mismatch", "Error message is not what was expected"
    sig.file_sig(test_fn,key=key_other,out_file=test_sig_fn)
    with subprocess.Popen(["python","-m","MICGENT.sig","--config",sig_conf_fn,"file-sig-cmp-msg",
        "--msg","Sig mismatch",test_sig_fn,test_fn],stderr=subprocess.PIPE,universal_newlines=True) as p:
        p.wait()  # works around bug in Python 3.6 context manager - can get p.returncode None
        assert p.returncode == 0, "Expected a return code indicating caught error"        
        assert p.stderr.read().strip() != "Sig mismatch", "Error message is not what was expected"