def test_distant(): p = Ped(op.join(HERE, 'peddy/tests/test-unknown-gma.ped')) d = p.relatedness_coefficient('kid1', 'cousin1') assert d == 0.125, d d = p.relatedness_coefficient('kid1', 'aunt') assert d == 0.25, d d = p.relatedness_coefficient('cousin1', 'aunt') assert d == 0.5, d d = p.relatedness_coefficient('mom', 'aunt') assert d == 0.5, d r = p.relation('kid1', 'cousin1') assert r == 'cousins', r r = p.relation('kid1', 'grandma') assert r == 'grandchild', r r = p.relation('kid1', 'aunt') assert r == 'niece/nephew', r # because we don't know that the uncle is related r = p.relation('kid1', 'uncle') assert r == 'related at unknown level', r r = p.relation('cousin1', 'mom') assert r == 'niece/nephew', r r = p.relation('cousin1', 'dad') # because we don't know that the dad is related assert r == 'related at unknown level', r
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
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
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
def test_relatedness_coefficient_missing_gparent(): p = Ped(open(os.path.join(HERE, "peddy/tests/test.fam.ped"))) # uncle v = p.relatedness_coefficient('101806-101806', '101811-101811') assert v == 0.25, v v = p.relatedness_coefficient('101806-101806', '101809-101809') assert v == 0.25, v # parent-child v = p.relatedness_coefficient('101806-101806', '101653-101653') assert v == 0.5, v p = Ped(open(os.path.join(HERE, "peddy/tests/test.fam2.ped"))) v = p.relatedness_coefficient('101806-101806', '101811-101811') assert v == 0.25, v v = p.relatedness_coefficient('101806-101806', '101809-101809') assert v == 0.25, v # parent-child v = p.relatedness_coefficient('101806-101806', '101653-101653') assert v == 0.5, v