def test_auto_dom_extended(): fam = make_fam2() efam = EvalFamily(fam) assert [f.affected for f in efam.subjects] == [False, True, True, False, True, False] efam.gt_types = [Family.HOM_REF, Family.HET, Family.HET, Family.HOM_REF, Family.HET, Family.HOM_REF] assert efam.auto_dom() # unaffected is het: efam.gt_types[0] = Family.HET assert not efam.auto_dom() assert efam.auto_dom(only_affected=False) efam.gt_types[0] = Family.HOM_REF assert efam.auto_dom() efam.gt_depths = [9] * 6 assert not efam.auto_dom(min_depth=10) # check with no unaffecteds for f in efam.subjects: f.affected = True assert not efam.auto_dom() # check with all unaffecteds for f in efam.subjects: f.affected = False assert not efam.auto_dom()
def test_auto_dom_extended(): fam = make_fam2() efam = EvalFamily(fam) assert [f.affected for f in efam.subjects] == [False, True, True, False, True, False] efam.gt_types = [ Family.HOM_REF, Family.HET, Family.HET, Family.HOM_REF, Family.HET, Family.HOM_REF ] assert efam.auto_dom() # unaffected is het: efam.gt_types[0] = Family.HET assert not efam.auto_dom() assert efam.auto_dom(only_affected=False) efam.gt_types[0] = Family.HOM_REF assert efam.auto_dom() efam.gt_depths = [9] * 6 assert not efam.auto_dom(min_depth=10) # check with no unaffecteds for f in efam.subjects: f.affected = True assert not efam.auto_dom() # check with all unaffecteds for f in efam.subjects: f.affected = False assert not efam.auto_dom()
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
def test_auto_rec_extended(): fam = make_fam1() efam = EvalFamily(fam) efam.gt_types = [ Family.HET, Family.HET, Family.HOM_ALT, Family.HET, Family.HET, Family.HET ] assert efam.auto_rec() #if grandpa is affected it is no longer autosomal recessive efam.subjects[5].affected = True assert not efam.auto_rec() efam.subjects[5].affected = False # set both kids to hom_alt: efam.gt_types[3] = Family.HOM_ALT assert not efam.auto_rec() assert efam.auto_rec(only_affected=False) # set unaffected kid back: efam.gt_types[3] = Family.HET # expected that is is auto_rec assert efam.auto_rec() # but it's not if we set all depths to 9 and have min_depth of 10 efam.gt_depths = [9] * 6 assert not efam.auto_rec(min_depth=10) efam.gt_depths[2] = 1000 # even if affected has high depth assert not efam.auto_rec(min_depth=10) # passes if we meet the minimum depth efam.gt_depths = [100] * 6 assert efam.auto_rec(min_depth=10) # check if we have no affecteds: efam.subjects[2].affected = False assert not efam.auto_rec(min_depth=10)
def test_auto_rec_extended(): fam = make_fam1() efam = EvalFamily(fam) efam.gt_types = [Family.HET, Family.HET, Family.HOM_ALT, Family.HET, Family.HET, Family.HET] assert efam.auto_rec() #if grandpa is affected it is no longer autosomal recessive efam.subjects[5].affected = True assert not efam.auto_rec() efam.subjects[5].affected = False # set both kids to hom_alt: efam.gt_types[3] = Family.HOM_ALT assert not efam.auto_rec() assert efam.auto_rec(only_affected=False) # set unaffected kid back: efam.gt_types[3] = Family.HET # expected that is is auto_rec assert efam.auto_rec() # but it's not if we set all depths to 9 and have min_depth of 10 efam.gt_depths = [9] * 6 assert not efam.auto_rec(min_depth=10) efam.gt_depths[2] = 1000 # even if affected has high depth assert not efam.auto_rec(min_depth=10) # passes if we meet the minimum depth efam.gt_depths = [100] * 6 assert efam.auto_rec(min_depth=10) # check if we have no affecteds: efam.subjects[2].affected = False assert not efam.auto_rec(min_depth=10)
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