Exemple #1
0
def test_relatedness_coefficient():
    kid = Sample('fam1', 'kid', 'dad', 'mom', '2', '2')
    dad = Sample('fam1', 'dad', '-9', '-9', '1', '2')
    mom = Sample('fam1', 'mom', '-9', '-9', '2', '2')
    gma = Sample('fam1', 'gma', '-9', '-9', '2', '2')
    ggma = Sample('fam1', 'ggma', '-9', '-9', '2', '2')
    kid.mom = mom
    kid.dad = dad
    mom.mom = gma
    gma.mom = ggma

    unrelated = Sample('fam1', 'un', '-9', '-9', '2', '2')

    from io import StringIO
    p = Ped(StringIO())
    p.families['fam1'] = Family([kid, mom, dad, gma, ggma, unrelated])
    rel = p.relatedness_coefficient("mom", "dad")
    assert rel == 0.0, rel
    d = p.relatedness_coefficient("mom", "kid")
    assert d == 0.5, d
    d = p.relatedness_coefficient("dad", "gma")
    assert d == 0.0, d

    d = p.relatedness_coefficient("mom", "gma")
    assert d == 0.5, d

    d = p.relatedness_coefficient("kid", "gma")
    assert d == 0.25, d

    d = p.relatedness_coefficient("kid", "ggma")
    assert d == 0.125, d

    assert p.relatedness_coefficient("mom", "mom") == 1.0
Exemple #2
0
def test_relatedness_coefficient_missing_parent():

    gma = Sample('X28935', 'gma', '-9', '-9', '2', '1')
    mom = Sample('X28935', 'mom', '-9', 'gma', '2', '1')
    dad = Sample('X28935', 'dad', '-9', '-9', '1', '1')

    kid1 = Sample('X28935', 'kid1', '-9', 'mom', '1', '1')
    kid2 = Sample('X28935', 'kid2', '-9', 'mom', '2', '1')

    kid1 = Sample('X28935', 'kid1', 'dad', 'mom', '1', '1')
    kid2 = Sample('X28935', 'kid2', 'dad', 'mom', '2', '1')

    kid1.mom = mom
    kid2.mom = mom
    mom.mom = gma
    kid1.dad = dad
    kid2.dad = dad

    from io import StringIO
    p = Ped(StringIO())
    p.families['X28935'] = Family([kid1, kid2, mom, gma])  #, dad])

    assert "siblings" in p.relation('kid1', 'kid2'), p.relation('kid1', 'kid2')

    v = p.relatedness_coefficient('kid1', 'kid2')
    assert v == 0.5, v

    v = p.relatedness_coefficient('gma', 'kid2')
    assert v == 0.25, v

    v = p.relatedness_coefficient('gma', 'kid1')
    assert v == 0.25, v

    v = p.relatedness_coefficient('gma', 'mom')
    assert v == 0.5, v
Exemple #3
0
def test_relation():
    kid = Sample('fam1', 'kid', 'dad', 'mom', '2', '2')
    dad = Sample('fam1', 'dad', '-9', '-9', '1', '2')
    mom = Sample('fam1', 'mom', '-9', '-9', '2', '2')
    kid.mom = mom
    kid.dad = dad

    from io import StringIO
    p = Ped(StringIO())
    p.families['fam1'] = Family([kid, mom, dad])
    assert p.relation("mom", "dad") == "mom-dad"
Exemple #4
0
def test_family():
    kid = Sample('fam1', 'kid', 'dad', 'mom', '2', '2')
    mom = Sample('fam1', 'mom', '-9', '-9', '2', '2')
    dad = Sample('fam1', 'dad', '-9', '-9', '1', '2')

    f = Family([kid, mom, dad])

    assert mom.kids == [kid]
    assert dad.kids == [kid]

    assert kid.dad == dad
    assert kid.mom == mom

    assert list(f.affecteds) == [kid, mom, dad], list(f.affecteds)
    assert list(f.unaffecteds) == []

    assert list(f) == [kid, mom, dad]