Ejemplo n.º 1
0
def test_x_dom_parents():

    mom = Sample('mom', affected=False, sex='female')
    dad = Sample('dad', affected=False, sex='male')
    kid = Sample('kid', affected=True, sex='female')

    kid.mom, kid.dad = mom, dad

    efam = EvalFamily(Family([dad, mom, kid], 'trio'))
    efam.gt_types = [Family.HOM_REF, Family.HOM_REF, Family.HET]

    # neither parent is het
    assert not efam.x_dom()

    # neither parent is affected
    efam.gt_types = [Family.HET, Family.HOM_REF, Family.HET]
    assert not efam.x_dom()

    dad.affected = True
    assert efam.x_dom()


    # for male, only mom must be affected
    kid.sex = 'male'
    assert not efam.x_dom()
Ejemplo n.º 2
0
def make_fam(n_affecteds, n_unaffecteds, n_unknowns, id="xxx"):

    samples = []
    for i in range(n_affecteds):
        samples.append(
            Sample('affected_%d' % i,
                   affected=True,
                   sex=random.randint(1, 2),
                   name='affected_%d' % i))
    for i in range(n_unaffecteds):
        samples.append(
            Sample('unaffected_%d' % i,
                   affected=False,
                   sex=random.randint(1, 2),
                   name='affected_%d' % i))
    for i in range(n_unknowns):
        samples.append(
            Sample('unknown_%d' % i,
                   affected=None,
                   sex=random.randint(1, 2),
                   name='affected_%d' % i))

    for i in range(int((n_affecteds + n_affecteds + n_unknowns) / 2)):

        sample = random.choice(samples)
        if random.random() < 0.9:
            try:
                sample.dad = random.choice([
                    s for s in samples if not s == sample and s.sex == 'male'
                ])
            except IndexError:
                pass
        if random.random() < 0.9:
            try:
                sample.mom = random.choice([
                    s for s in samples if not s == sample and s.sex == 'female'
                ])
            except IndexError:
                pass

    fam = EvalFamily(Family(samples, 'fam_%s' % id))
    fam.gt_types = [random.randrange(0, 4) for _ in range(len(samples))]
    fam.gt_depths = [random.randrange(0, 100) for _ in range(len(samples))]
    fam.gt_phred_ll_homref = [
        random.randrange(0, 100) for _ in range(len(samples))
    ]
    fam.gt_phred_ll_het = [
        random.randrange(0, 100) for _ in range(len(samples))
    ]
    fam.gt_phred_ll_homalt = [
        random.randrange(0, 100) for _ in range(len(samples))
    ]
    fam.gt_quals = [random.randrange(5, 100) for _ in range(len(samples))]
    return fam
Ejemplo n.º 3
0
def test_x_rec():

    mom = Sample('mom_1239NIH', affected=False, sex='female')
    dad = Sample('dad_1240NIH', affected=False, sex='male')
    kid_aff = Sample('kidaff_1238NIH', affected=True, sex='female')

    kid_aff.mom = mom
    kid_aff.dad = dad

    efam = EvalFamily(Family([dad, mom, kid_aff], 'oler-trio'))
    # mom should be a carrier
    efam.gt_types = [Family.HOM_REF, Family.HOM_REF, Family.HOM_ALT]
    assert efam.x_rec()
Ejemplo n.º 4
0
def test_comp_het_singleton():
    kid = Sample('kid', affected=True)

    efam = EvalFamily(Family([kid], 'singleton'))
    efam.gt_types = [Family.HET]

    res = efam.comp_het_pair([Family.HET], ["A/C"], [Family.HET], ["A/C"],
                             [False], [False], "A", "C", "A", "C")

    assert res['candidate']
    assert res['priority'] == 2, res
Ejemplo n.º 5
0
def test_x_rec():

    mom = Sample('mom_1239NIH', affected=False, sex='female')
    dad = Sample('dad_1240NIH', affected=False, sex='male')
    kid_aff = Sample('kidaff_1238NIH', affected=True, sex='female')

    kid_aff.mom = mom
    kid_aff.dad = dad

    efam = EvalFamily(Family([dad, mom, kid_aff], 'oler-trio'))
    # mom should be a carrier
    efam.gt_types = [Family.HOM_REF, Family.HOM_REF, Family.HOM_ALT]
    assert efam.x_rec()
Ejemplo n.º 6
0
def test_x_dom_parents():

    mom = Sample('mom', affected=False, sex='female')
    dad = Sample('dad', affected=False, sex='male')
    kid = Sample('kid', affected=True, sex='female')

    kid.mom, kid.dad = mom, dad

    efam = EvalFamily(Family([dad, mom, kid], 'trio'))
    efam.gt_types = [Family.HOM_REF, Family.HOM_REF, Family.HET]

    # neither parent is het
    assert not efam.x_dom()

    # neither parent is affected
    efam.gt_types = [Family.HET, Family.HOM_REF, Family.HET]
    assert not efam.x_dom()

    dad.affected = True
    assert efam.x_dom()

    # for male, only mom must be affected
    kid.sex = 'male'
    assert not efam.x_dom()
Ejemplo n.º 7
0
from __future__ import print_function
import sys
from inheritance import Sample, Family, EvalFamily


mom = Sample('mom', affected=False)
dad = Sample('dad', affected=False)
kid = Sample('kid', affected=True)

kid.mom, kid.dad = mom, dad

fam = Family([mom, dad, kid], 'a')

def make_fam1():
    # only 1 affected kid.
    fam = Family.from_ped("""\
#family_id  sample_id   paternal_id maternal_id sex phenotype
1   dad   0   0   1  1
1   mom   grandpa   grandma   2  1
1   kid   dad   mom   1  2
1   kid2   dad   mom   1  1
1   grandma 0   0     2  1
1   grandpa 0   0     1  1""")
    return fam

def make_fam2():
    # 1 affected kid, parent, grandparent
    fam = Family.from_ped("""\
#family_id  sample_id   paternal_id maternal_id sex phenotype
1   dad   0   0   1  1
1   mom   grandpa   grandma   2  2
Ejemplo n.º 8
0
from __future__ import print_function
import sys
from inheritance import Sample, Family, EvalFamily

mom = Sample('mom', affected=False)
dad = Sample('dad', affected=False)
kid = Sample('kid', affected=True)

kid.mom, kid.dad = mom, dad

fam = Family([mom, dad, kid], 'a')


def make_fam1():
    # only 1 affected kid.
    fam = Family.from_ped("""\
#family_id  sample_id   paternal_id maternal_id sex phenotype
1   dad   0   0   1  1
1   mom   grandpa   grandma   2  1
1   kid   dad   mom   1  2
1   kid2   dad   mom   1  1
1   grandma 0   0     2  1
1   grandpa 0   0     1  1""")
    return fam


def make_fam2():
    # 1 affected kid, parent, grandparent
    fam = Family.from_ped("""\
#family_id  sample_id   paternal_id maternal_id sex phenotype
1   dad   0   0   1  1