def get_genotypes(variant, individuals): """Create genotype objects Create Genotype objects for all individuals and return them in a dictionary Args: variant (dict): A variant dict individuals (list): A list with strings that are individual id:s Returns: genotype_dict (dict): A dictionary with individual id:s as strings and Genptype objects as keys """ gt_format = variant.get('FORMAT', '').split(':') genotype_dict = {} for individual in individuals: gt_info = variant[individual].split(':') gt_call = dict(zip(gt_format, gt_info)) #Create a genotype object for this individual genotype_dict[individual] = Genotype(**gt_call) return genotype_dict
def test_family_one_affected(): """Test healthy parents and an affected proband """ # family = get_family(family_file=FAMILY_FILE) family_lines = [ "#FamilyID\tSampleID\tFather\tMother\tSex\tPhenotype\n", "1\tproband\tfather\tmother\t1\t2\n", "1\tmother\t0\t0\t2\t1\n", "1\tfather\t0\t0\t1\t1\n" ] family = get_family(family_lines=family_lines) recessive_variant = {'genotypes': {}} recessive_variant['genotypes']['proband'] = Genotype(**{'GT': '1/1'}) recessive_variant['genotypes']['father'] = Genotype(**{'GT': '0/1'}) recessive_variant['genotypes']['mother'] = Genotype(**{'GT': '0/0'}) assert check_recessive(variant=recessive_variant, family=family, strict=False) == True
def test_x_affected_homozygote_female(): """Test an affected homozygote male""" family_lines = [ "#FamilyID\tSampleID\tFather\tMother\tSex\tPhenotype\n", "1\tproband\t0\t0\t2\t2\n" ] family = get_family(family_lines=family_lines) homozygote_variant = {'genotypes': {}} homozygote_variant['genotypes']['proband'] = Genotype(**{'GT': '1/1'}) assert check_X_recessive(variant=homozygote_variant, family=family) == True
def test_x_healthy_recessive_male(): """Test a healthy recessive male """ family_lines = [ "#FamilyID\tSampleID\tFather\tMother\tSex\tPhenotype\n", "1\tproband\t0\t0\t1\t1\n" ] family = get_family(family_lines=family_lines) recessive_variant = {'genotypes': {}} recessive_variant['genotypes']['proband'] = Genotype(**{'GT': '0/1'}) assert check_X_recessive(variant=recessive_variant, family=family) == False
def test_dominant_affected_male_ref_call(): """Test an affected ref call male""" family_lines = [ "#FamilyID\tSampleID\tFather\tMother\tSex\tPhenotype\n", "1\tproband\t0\t0\t1\t2\n" ] family = get_family(family_lines=family_lines) homozygote_variant = {'genotypes': {}} homozygote_variant['genotypes']['proband'] = Genotype(**{'GT': '0/0'}) assert check_dominant(variant=homozygote_variant, family=family) == False
def test_dominant_affected_recessive_male(): """Test a sick male """ family_lines = [ "#FamilyID\tSampleID\tFather\tMother\tSex\tPhenotype\n", "1\tproband\t0\t0\t1\t2\n" ] family = get_family(family_lines=family_lines) recessive_variant = {'genotypes': {}} recessive_variant['genotypes']['proband'] = Genotype(**{'GT': '0/1'}) assert check_dominant(variant=recessive_variant, family=family) == True
def test_x_healthy_female_ref_call(): """Test an healthy female ref call""" family_lines = [ "#FamilyID\tSampleID\tFather\tMother\tSex\tPhenotype\n", "1\tproband\t0\t0\t2\t1\n" ] family = get_family(family_lines=family_lines) homozygote_variant = {'genotypes': {}} homozygote_variant['genotypes']['proband'] = Genotype(**{'GT': '0/0'}) assert check_X_dominant(variant=homozygote_variant, family=family) == True
def test_x_healthy_homozygote_male(): """Test an healthy homozygote male""" family_lines = [ "#FamilyID\tSampleID\tFather\tMother\tSex\tPhenotype\n", "1\tproband\t0\t0\t1\t1\n" ] family = get_family(family_lines=family_lines) homozygote_variant = {'genotypes': {}} homozygote_variant['genotypes']['proband'] = Genotype(**{'GT': '1/1'}) assert check_X_dominant(variant=homozygote_variant, family=family) == False
def test_x_affected_recessive_female(): """Test a sick heterozygote female Females needs to bo hom alt to follow pattern """ family_lines = [ "#FamilyID\tSampleID\tFather\tMother\tSex\tPhenotype\n", "1\tproband\t0\t0\t2\t2\n" ] family = get_family(family_lines=family_lines) recessive_variant = {'genotypes': {}} recessive_variant['genotypes']['proband'] = Genotype(**{'GT': '0/1'}) assert check_X_recessive(variant=recessive_variant, family=family) == False
def test_x_affected_no_call_male(): """Test a sick male with no gt call This should be true since there is no information that contradicts the model """ family_lines = [ "#FamilyID\tSampleID\tFather\tMother\tSex\tPhenotype\n", "1\tproband\t0\t0\t1\t2\n" ] family = get_family(family_lines=family_lines) no_call_variant = {'genotypes': {}} no_call_variant['genotypes']['proband'] = Genotype(**{'GT': './.'}) assert check_X_recessive(variant=no_call_variant, family=family) == True
def test_dominant_healthy_recessive_male_reduced_penetrance(): """Test a healthy heterozygote female Females needs to bo hom alt to follow pattern """ family_lines = [ "#FamilyID\tSampleID\tFather\tMother\tSex\tPhenotype\n", "1\tproband\t0\t0\t1\t1\n" ] family = get_family(family_lines=family_lines) recessive_variant = {'genotypes': {}} recessive_variant['genotypes']['proband'] = Genotype(**{'GT': '0/1'}) recessive_variant['reduced_penetrance'] = True assert check_dominant(variant=recessive_variant, family=family) == True
def test_dominant_affected_no_call_male_strict(): """Test a sick male with no gt call This should not be true since we allways need 'proof' for an inheritance pattern if strict mode. """ family_lines = [ "#FamilyID\tSampleID\tFather\tMother\tSex\tPhenotype\n", "1\tproband\t0\t0\t1\t2\n" ] family = get_family(family_lines=family_lines) no_call_variant = {'genotypes': {}} no_call_variant['genotypes']['proband'] = Genotype(**{'GT': './.'}) assert check_dominant(variant=no_call_variant, family=family, strict=True) == False