def test_mendelian_from_ivan_2():
    # AC AA AC mendel
    assert FV.check_mendelian_trio(np.array([0, 1]), np.array([0, 0]),
                                   np.array([0, 1]), 0)

    assert FV.check_mendelian_trio(np.array([0, 1]), np.array([0, 0]),
                                   np.array([0, 1]), 1)
def test_weird_mendel_from_ivan_4():
    # AC AT CT mendel
    assert not FV.check_mendelian_trio(np.array([0, 1]), np.array([0, 2]),
                                       np.array([1, 2]), 0)
    assert FV.check_mendelian_trio(np.array([0, 1]), np.array([0, 2]),
                                   np.array([1, 2]), 1)
    assert FV.check_mendelian_trio(np.array([0, 1]), np.array([0, 2]),
                                   np.array([1, 2]), 2)
def test_denovo_check_5():
    # GG, GG -> AC
    assert FV.check_denovo_trio(np.array([2, 2]), np.array([2, 2]),
                                np.array([0, 1]), 0)
    assert FV.check_denovo_trio(np.array([2, 2]), np.array([2, 2]),
                                np.array([0, 1]), 1)
    assert not FV.check_denovo_trio(np.array([2, 2]), np.array([2, 2]),
                                    np.array([0, 1]), 2)
def test_denovo_check_6():
    # CC,CC -> GC
    assert FV.check_denovo_trio(np.array([1, 1]), np.array([1, 1]),
                                np.array([2, 1]), 2)
    assert not FV.check_denovo_trio(np.array([1, 1]), np.array([1, 1]),
                                    np.array([2, 1]), 1)
    assert not FV.check_denovo_trio(np.array([1, 1]), np.array([1, 1]),
                                    np.array([2, 1]), 0)
def test_omission_check_1():
    # CC, AA -> AA
    assert FV.check_omission_trio(np.array([1, 1]), np.array([0, 0]),
                                  np.array([0, 0]), 1)
    assert not FV.check_omission_trio(np.array([1, 1]), np.array([0, 0]),
                                      np.array([0, 0]), 0)
    assert not FV.check_denovo_trio(np.array([1, 1]), np.array([0, 0]),
                                    np.array([0, 0]), 0)
    assert not FV.check_denovo_trio(np.array([1, 1]), np.array([0, 0]),
                                    np.array([0, 0]), 1)
def test_omission_and_denovo():
    # AA,CC -> AA
    trio = [
        np.array([1, 1]),  # p1
        np.array([1, 1]),  # p2
        np.array([0, 1]),  # ch
    ]

    # FIXME:
    assert not FA.check_omission_trio(*trio, allele_index=1)
    # assert not FA.check_denovo_trio(*trio, allele_index=0)
    # assert FA.check_mendelian_trio(*trio, allele_index=0)

    assert FA.check_denovo_trio(*trio, allele_index=0)
def test_mixed_check_1():
    # AA,CC -> GG
    trio = [
        np.array([1, 1]),
        np.array([0, 0]),
        np.array([2, 2]),
    ]
    assert not FV.check_denovo_trio(*trio, allele_index=0)
    assert not FV.check_denovo_trio(*trio, allele_index=1)
    assert FV.check_denovo_trio(*trio, allele_index=2)

    assert FV.check_omission_trio(*trio, allele_index=0)
    assert FV.check_omission_trio(*trio, allele_index=1)
    assert not FV.check_omission_trio(*trio, allele_index=2)

    assert not FV.check_mendelian_trio(*trio, allele_index=0)
    assert not FV.check_mendelian_trio(*trio, allele_index=1)
    assert not FV.check_mendelian_trio(*trio, allele_index=2)
def test_mixed_check_4():
    # AA,CC -> AG
    trio = [
        np.array([1, 1]),  # p1
        np.array([0, 0]),  # p2
        np.array([0, 2]),  # ch
    ]
    assert not FV.check_denovo_trio(*trio, allele_index=0)
    assert not FV.check_denovo_trio(*trio, allele_index=1)
    assert FV.check_denovo_trio(*trio, allele_index=2)

    assert not FV.check_omission_trio(*trio, allele_index=0)
    assert FV.check_omission_trio(*trio, allele_index=1)
    assert not FV.check_omission_trio(*trio, allele_index=2)

    assert FV.check_mendelian_trio(*trio, allele_index=0)
    assert not FV.check_mendelian_trio(*trio, allele_index=1)
    assert not FV.check_mendelian_trio(*trio, allele_index=2)
Beispiel #9
0
def test_allele_best_state(
    chromosome,
    position,
    reference,
    alternative,
    allele_index,
    allele_count,
    genotype,
    expected,
    sample_family,
):

    fa = FamilyAllele(
        SummaryAllele(
            chromosome, position, reference, alternative, 0, allele_index, {},
        ),
        sample_family,
        genotype,
        None,
    )
    fa.update_attributes({"allele_count": allele_count})
    assert np.array_equal(fa.best_state, expected)
def test_super_weird_denovo_omission_mix_from_ivan_2():
    # AA AC TG denovo
    trio = [
        np.array([0, 0]),
        np.array([0, 1]),
        np.array([2, 3]),
    ]
    assert FV.check_omission_trio(*trio, allele_index=0)
    assert not FV.check_omission_trio(*trio, allele_index=1)
    assert not FV.check_omission_trio(*trio, allele_index=2)
    assert not FV.check_omission_trio(*trio, allele_index=3)

    assert not FV.check_denovo_trio(*trio, allele_index=0)
    assert not FV.check_denovo_trio(*trio, allele_index=1)
    assert FV.check_denovo_trio(*trio, allele_index=2)
    assert FV.check_denovo_trio(*trio, allele_index=3)
def test_weird_denovo_from_ivan_1_4():
    # AC AA GA denovo
    assert FV.check_denovo_trio(np.array([0, 1]), np.array([0, 0]),
                                np.array([2, 0]), 2)
    assert not FV.check_denovo_trio(np.array([0, 1]), np.array([0, 0]),
                                    np.array([2, 0]), 0)
    assert not FV.check_denovo_trio(np.array([0, 1]), np.array([0, 0]),
                                    np.array([2, 0]), 1)
    assert not FV.check_omission_trio(np.array([0, 1]), np.array([0, 0]),
                                      np.array([2, 0]), 2)
    assert not FV.check_omission_trio(np.array([0, 1]), np.array([0, 0]),
                                      np.array([2, 0]), 0)
    assert not FV.check_omission_trio(np.array([0, 1]), np.array([0, 0]),
                                      np.array([2, 0]), 1)
def test_weird_denovo_from_ivan_4():
    # AC AC CG denovo
    assert FV.check_denovo_trio(np.array([0, 1]), np.array([0, 1]),
                                np.array([1, 2]), 2)
    assert not FV.check_denovo_trio(np.array([0, 1]), np.array([0, 1]),
                                    np.array([1, 2]), 0)
    assert not FV.check_denovo_trio(np.array([0, 1]), np.array([0, 1]),
                                    np.array([1, 2]), 1)
    assert not FV.check_omission_trio(np.array([0, 1]), np.array([0, 1]),
                                      np.array([1, 2]), 2)
    assert not FV.check_omission_trio(np.array([0, 1]), np.array([0, 1]),
                                      np.array([1, 2]), 0)
    assert not FV.check_omission_trio(np.array([0, 1]), np.array([0, 1]),
                                      np.array([1, 2]), 1)
def test_denovo_check_4():
    # CC, CC -> AA
    assert FV.check_denovo_trio(np.array([1, 1]), np.array([1, 1]),
                                np.array([0, 0]), 0)
    assert not FV.check_denovo_trio(np.array([1, 1]), np.array([1, 1]),
                                    np.array([0, 0]), 1)
def test_denovo_check_1():
    # AA, AA -> AC
    assert FV.check_denovo_trio(np.array([0, 0]), np.array([0, 0]),
                                np.array([0, 1]), 1)
    assert not FV.check_denovo_trio(np.array([0, 0]), np.array([0, 0]),
                                    np.array([0, 1]), 0)
def test_omission_check_4():
    # AA,CC -> CC
    assert FV.check_omission_trio(np.array([1, 1]), np.array([0, 0]),
                                  np.array([1, 1]), 0)
    assert not FV.check_omission_trio(np.array([1, 1]), np.array([0, 0]),
                                      np.array([1, 1]), 1)
def test_mendelian_from_ivan_5():
    # AC AC CC mendel
    assert FV.check_mendelian_trio(np.array([0, 1]), np.array([0, 1]),
                                   np.array([1, 1]), 1)
    assert not FV.check_mendelian_trio(np.array([0, 1]), np.array([0, 1]),
                                       np.array([1, 1]), 0)
def test_denovo_and_omission_from_ivan_1():
    # AA AA AC denovo
    assert FV.check_denovo_trio(np.array([0, 0]), np.array([0, 0]),
                                np.array([0, 1]), 1)
    assert not FV.check_denovo_trio(np.array([0, 0]), np.array([0, 0]),
                                    np.array([0, 1]), 0)
def test_denovo_check_2():
    # AA, AA -> CA
    assert FV.check_denovo_trio(np.array([0, 0]), np.array([0, 0]),
                                np.array([1, 0]), 1)
    assert not FV.check_denovo_trio(np.array([0, 0]), np.array([0, 0]),
                                    np.array([1, 0]), 0)
def test_denovo_and_omission_from_ivan_4():
    # AA CC CC omission
    assert FV.check_omission_trio(np.array([0, 0]), np.array([1, 1]),
                                  np.array([1, 1]), 0)
    assert not FV.check_omission_trio(np.array([0, 0]), np.array([1, 1]),
                                      np.array([1, 1]), 1)