コード例 #1
0
def test_NA10860_debug(monkeypatch, solver):
    file = script_path("aldy.tests.resources/NA10860.bam")
    with tmpfile(suffix=".tar.gz") as tmp:
        with tmpfile(mode="w") as out, tmpfile(mode="w") as out_log:
            out.close()
            out_log.close()
            assert_file(
                monkeypatch,
                file,
                solver,
                EXPECTED_NA10860 + "Preparing debug archive...",
                {"--debug": tmp.name[:-7], "--log": out_log.name, "--output": out.name},
            )
            with open(script_path("aldy.tests.resources/NA10860.out.expected")) as f:
                expected = f.read()
            with open(out.name) as f:
                produced = f.read()
            assert produced == expected
            # Check logs
            with open(out_log.name) as f:
                log = f.read()
            s = "    rs1058172    42523528.C>T    3267G>A    "
            s += "(cov=  21, cn= 0.9; impact=R365H)\n"
            s = "[major] status= optimal; opt= 1.48; solution= 1x*4.021, 1x*4J, 1x*61\n"
            assert s in log

        out = subprocess.check_output(f"tar tzf {tmp.name}", shell=True).decode("utf-8")
        out = "\n".join(sorted(out.strip().split("\n")))
        assert out == EXPECTED_NA10860_DEBUG_TAR.strip()
コード例 #2
0
ファイル: test_full.py プロジェクト: twesigomwedavid/aldy
def test_NA10860_debug(monkeypatch, solver):
    file = script_path("aldy.tests.resources/NA10860.bam")
    with tmpfile(suffix=".tar.gz") as tmp:
        with tmpfile(mode="w") as out, tmpfile(mode="w") as out_log:
            out.close()
            out_log.close()
            assert_file(
                monkeypatch,
                file,
                solver,
                EXPECTED_NA10860 + "Preparing debug archive...",
                {
                    "--debug": tmp.name[:-7],
                    "--log": out_log.name,
                    "--output": out.name
                },
            )
            with open(script_path(
                    "aldy.tests.resources/NA10860.out.expected")) as f:
                expected = f.read()
            with open(out.name) as f:
                produced = f.read()
            assert produced == expected
            # Check logs
            with open(out_log.name) as f:
                log = f.read()
            s = "Major solver: MajorSol[1.33; sol=(1x*4, 1x*4.f, 1x*61); "
            s += "cn=CNSol[6.73; sol=(2x*1,1x*61); "
            s += "cn=3333333333333322222_2|333333333333334444444]"
            assert s in log

        out = subprocess.check_output(f"tar tzf {tmp.name}",
                                      shell=True).decode("utf-8")
        out = "\n".join(sorted(out.strip().split("\n")))
        assert out == EXPECTED_NA10860_DEBUG_TAR.strip()
コード例 #3
0
def test_NA10860_vcf_out(monkeypatch, solver):
    file = script_path("aldy.tests.resources/NA10860.bam")
    with tmpfile(suffix=".vcf", mode="w") as out:
        out.close()
        assert_file(monkeypatch, file, solver, EXPECTED_NA10860, {"--output": out.name})
        with open(script_path("aldy.tests.resources/NA10860.vcf.expected")) as f:
            expected = f.read()
        with open(out.name) as f:
            produced = f.read()
        assert produced == expected.replace("aldy-v3.1", f"aldy-v{__version__}")
コード例 #4
0
def test_NA07000_phase(monkeypatch, solver):
    file = script_path("aldy.tests.resources/NA07000_SLCO1B1.vcf.gz")
    assert_file(
        monkeypatch,
        file,
        solver,
        EXPECTED_NA07000_PHASE,
        {
            "--max-minor-solutions": "1",
            "--gene": "SLCO1B1",
            "--phase": script_path("aldy.tests.resources/NA07000_SLCO1B1.phase"),
        },
        warn=True,
    )
コード例 #5
0
def test_profile(monkeypatch, capsys):
    lines = []

    def log_info(*args):
        s = str.format(*args)
        lines.append(s)

    monkeypatch.setattr(log, "info", log_info)

    main(["profile", script_path("aldy.tests.resources/NA10860.bam")])
    lines = escape_ansi("\n".join(lines)).strip()
    assert lines == EXPECTED_PROFILE.strip()

    captured = capsys.readouterr()
    with open(script_path("aldy.tests.resources/NA10860.profile")) as f:
        expected = f.read()
    assert captured.out == expected
コード例 #6
0
def test_fix_insertions(monkeypatch, solver):
    file = script_path("aldy.tests.resources/INS.dump")
    assert_file(
        monkeypatch,
        file,
        solver,
        EXPECTED_INS,
        {"--profile": "pgrnseq-v3", "--max-minor-solutions": "1"},
    )
コード例 #7
0
def test_hard_fusion(monkeypatch, solver):
    file = script_path("aldy.tests.resources/HARD.dump")
    assert_file(
        monkeypatch,
        file,
        solver,
        EXPECTED_HARD_FUSION,
        {"--profile": "pgrnseq-v1", "--fusion-penalty": "5"},
    )
コード例 #8
0
ファイル: test_full.py プロジェクト: twesigomwedavid/aldy
def assert_show(monkeypatch, expected, params=None):
    lines = []

    def log_info(*args):
        s = str.format(*args)
        lines.append(s)

    monkeypatch.setattr(log, "info", log_info)

    args = ["show", "--gene", script_path("aldy.tests.resources/toy.yml")]
    main(args + (params or []))
    expected = expected.strip()
    lines = escape_ansi("\n".join(lines)).strip()
    assert lines == expected
コード例 #9
0
ファイル: test_query.py プロジェクト: 0xTCG/aldy
def assert_show(monkeypatch,
                expected,
                query=None,
                gene="aldy.tests.resources/toy.yml"):
    lines = []

    def log_info(*args):
        s = str.format(*args)
        lines.append(s)

    monkeypatch.setattr(log, "info", log_info)

    args = ["q", script_path(gene)]
    if query:
        args[1] += "*" + query
    main(args)
    expected = expected.strip()
    lines = escape_ansi("\n".join(lines)).strip()
    assert lines == expected
コード例 #10
0
 def read_data(path):
     with open(script_path(path)) as f:
         data = f.read()
         data = ast.literal_eval(data)
         return data
コード例 #11
0
def real_gene():
    return Gene(script_path("aldy.resources.genes/cyp2d6.yml"))
コード例 #12
0
def toy_gene():
    return Gene(script_path("aldy.tests.resources/toy.yml"))
コード例 #13
0
def test_NA10860_hg38(monkeypatch, solver):
    file = script_path("aldy.tests.resources/NA10860_hg38.bam")
    assert_file(
        monkeypatch, file, solver, EXPECTED_NA10860.replace("NA10860", "NA10860_hg38")
    )
コード例 #14
0
def test_NA10860(monkeypatch, solver):
    file = script_path("aldy.tests.resources/NA10860.bam")
    assert_file(monkeypatch, file, solver, EXPECTED_NA10860)
コード例 #15
0
def test_NA10860_gap(monkeypatch, solver):
    file = script_path("aldy.tests.resources/NA10860.bam")
    assert_file(monkeypatch, file, solver, EXPECTED_NA10860_GAP, {"--gap": "0.1"})
コード例 #16
0
def test_NA10860_cn(monkeypatch, solver):
    file = script_path("aldy.tests.resources/NA10860.bam")
    assert_file(monkeypatch, file, solver, EXPECTED_NA10860_CN, {"--cn": "1,1"})
コード例 #17
0
def test_hard(monkeypatch, solver):
    file = script_path("aldy.tests.resources/HARD.dump")
    assert_file(monkeypatch, file, solver, EXPECTED_HARD, {"--profile": "pgrnseq-v1"})