示例#1
0
def test_comp_het_one_parent_2kids():
    """
    test that we cant have a candidate when a parent is HOM_REF at both sites.
    """
    mom._i = 0
    kid._i = 1
    kid2._i = 2
    kid.dad = None
    kid.mom = None
    kid.mom = mom
    efam = EvalFamily(Family([mom, kid, kid2], '2kids'))
    efam.gt_types = [Family.HOM_REF, Family.HET, Family.HET]

    res = efam.comp_het_pair([Family.HOM_REF, Family.HET, Family.HET],
                             ["T/T", "T/C", "T/C"],
                             [Family.HOM_REF, Family.HET, Family.HET],
                             ["A/A", "A/C", "A/C"], [False] * 3, [False] * 3,
                             "T",
                             "C",
                             "A",
                             "C",
                             fast_mode=False,
                             allow_unaffected=True)

    assert not res['candidate'], res
示例#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
示例#3
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
示例#4
0
def test_comp_het_all_hets():

    efam = EvalFamily(Family([dad, mom, kid], 'triox'))

    efam.gt_types = [Family.HET] * 3

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

    assert res['candidate']
    assert res['priority'] == 3
示例#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()
示例#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()
示例#7
0
def test_comp_het_one_parent():
    mom._i = 0
    kid._i = 1
    kid.dad = None
    kid.mom = None
    efam = EvalFamily(Family([mom, kid], 'pair_mom'))
    efam.gt_types = [Family.HET] * 2
    res = efam.comp_het_pair([Family.HET] * 2, ["A/C"] * 2, [Family.HET] * 2,
                             ["A/C"] * 2, [False] * 2, [False] * 2, "A", "C",
                             "A", "C")
    assert res['candidate']
    assert res['priority'] == 3, res['priority']

    res = efam.comp_het_pair([Family.HOM_REF, Family.HET] * 2, ["A/A", "A/C"],
                             [Family.HET, Family.HET], ["A/C"] * 2,
                             [False] * 2, [False] * 2, "A", "C", "A", "C")
    assert res['candidate']
    assert res['priority'] == 2, res['priority']

    res = efam.comp_het_pair([Family.HOM_REF, Family.HOM_REF] * 2,
                             ["A/A", "A/A"], [Family.HET, Family.HET],
                             ["A/C"] * 2, [False] * 2, [False] * 2, "A", "C",
                             "A", "C")
    assert not res['candidate']
示例#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