def test_get_parental_var_snv(self): ''' check that get_parental_var() works correctly for SNVs ''' sex = 'F' var = create_snv(sex, '0/1') mom = Person('fam_id', 'mom', '0', '0', 'F', '1', '/PATH') parental = [] # try to get a matching variant for a mother. This will create a default # variant for a missing parental genotype self.assertEqual( get_parental_var(var, parental, mom), SNV(chrom="1", position=150, id=".", ref="A", alts="G", qual='1000', filter="PASS", info=str(var.info), format="GT", sample="0/0", gender="female", mnv_code=None)) # now see if we can pick up a variant where it does exist mother_var = create_snv(sex, '0/0') self.assertEqual(get_parental_var(var, [mother_var], mom), mother_var)
def setUp(self): """ define a family and variant, and start the Autosomal class """ # generate a test family sex = "F" mom_aff = "1" dad_aff = "1" self.trio = self.create_family(sex, mom_aff, dad_aff) # generate a test variant child = create_snv(sex, "0/1") mom = create_snv("F", "0/0") dad = create_snv("M", "0/0") var = TrioGenotypes(child.get_chrom(), child.get_position(), child, mom, dad) self.variants = [var] # make sure we've got known genes data self.known_gene = { "inh": ["Monoallelic"], "confirmed_status": ["confirmed dd gene"] } self.inh = Autosomal(self.variants, self.trio, self.known_gene, "1001") self.inh.is_lof = var.child.is_lof()
def test_check_variant_without_parents_female(self): """ test that check_variant_without_parents() works correctly for female """ var = TrioGenotypes('X', 100, create_snv('F', "1/0"), None, None) self.inh.set_trio_genotypes(var) # check for X-linked dominant inheritance self.assertEqual(self.inh.check_variant_without_parents("X-linked dominant"), "single_variant") self.assertEqual(self.inh.log_string, "allosomal without parents") var = TrioGenotypes('X', 100, create_snv('F', "1/1"), create_snv('F', "0/0"), create_snv('M', "0/0")) self.inh.set_trio_genotypes(var) self.assertEqual(self.inh.check_variant_without_parents("X-linked dominant"), "single_variant") # and check for hemizygous inheritance var = TrioGenotypes('X', 100, create_snv('F', "1/0"), create_snv('F', "0/0"), create_snv('M', "0/0")) self.inh.set_trio_genotypes(var) self.assertEqual(self.inh.check_variant_without_parents("Hemizygous"), "hemizygous") var = TrioGenotypes('X', 100, create_snv('F', "1/1"), create_snv('F', "0/0"), create_snv('M', "0/0")) self.inh.set_trio_genotypes(var) self.assertEqual(self.inh.check_variant_without_parents("Hemizygous"), "single_variant")
def test_check_variant_without_parents_female(self): """ test that check_variant_without_parents() works correctly for female """ var = TrioGenotypes('X', 100, create_snv('F', "1/0"), None, None) self.inh.set_trio_genotypes(var) # check for X-linked dominant inheritance self.assertEqual( self.inh.check_variant_without_parents("X-linked dominant"), "single_variant") self.assertEqual(self.inh.log_string, "allosomal without parents") var = TrioGenotypes('X', 100, create_snv('F', "1/1"), create_snv('F', "0/0"), create_snv('M', "0/0")) self.inh.set_trio_genotypes(var) self.assertEqual( self.inh.check_variant_without_parents("X-linked dominant"), "single_variant") # and check for hemizygous inheritance var = TrioGenotypes('X', 100, create_snv('F', "1/0"), create_snv('F', "0/0"), create_snv('M', "0/0")) self.inh.set_trio_genotypes(var) self.assertEqual(self.inh.check_variant_without_parents("Hemizygous"), "hemizygous") var = TrioGenotypes('X', 100, create_snv('F', "1/1"), create_snv('F', "0/0"), create_snv('M', "0/0")) self.inh.set_trio_genotypes(var) self.assertEqual(self.inh.check_variant_without_parents("Hemizygous"), "single_variant")
def setUp(self): """ define a family and variant, and start the Allosomal class """ # generate a test family child_gender = "F" mom_aff = "1" dad_aff = "1" self.trio = self.create_family(child_gender, mom_aff, dad_aff) # generate a test variant child = create_snv(child_gender, "0/1", chrom='X', pos=150, extra_info='HGNC=TEST;MAX_AF=0.0005') mom = create_snv("F", "0/0", chrom='X', pos=150) dad = create_snv("M", "0/0", chrom='X', pos=150) self.variants = [TrioGenotypes('X', '150', child, mom, dad)] self.report = Report(None, None, None) Info.set_populations([ "AFR_AF", "AMR_AF", "ASN_AF", "DDD_AF", "EAS_AF", "ESP_AF", "EUR_AF", "MAX_AF", "SAS_AF", "UK10K_cohort_AF" ])
def create_var(self, chrom='1', position='150', sex='F', child_geno='0/1'): ''' generate a test variant ''' child = create_snv(sex, child_geno, chrom=chrom, pos=position) mom = create_snv("F", "0/0", chrom=chrom, pos=position) dad = create_snv("M", "0/0", chrom=chrom, pos=position) return TrioGenotypes(child.get_chrom(), child.get_position(), child, mom, dad)
def create_variant(self, chrom="1", position="150", sex='F', cq=None, geno=['0/1', '0/0', '0/0']): """ creates a TrioGenotypes variant """ # generate a test variant child = create_snv(sex, geno[0], cq, chrom=chrom, pos=position) mom = create_snv("F", geno[1], cq, chrom=chrom, pos=position) dad = create_snv("M", geno[2], cq, chrom=chrom, pos=position) return TrioGenotypes(chrom, position, child, mom, dad)
def test_check_homozygous_male(self): """ test that check_homozygous() works correctly for males """ # check for trio with de novo on male X chrom var = TrioGenotypes('X', 100, create_snv('M', "1/1"), create_snv('F', "0/0"), create_snv('M', "0/0")) trio = self.create_family('male', '1', '1') self.inh = Allosomal([var], trio, self.known_gene, "TEST") self.inh.set_trio_genotypes(var) self.assertEqual(self.inh.check_homozygous("X-linked dominant"), "single_variant") self.assertEqual(self.inh.log_string, "male X chrom de novo") # check for trio = 210, with unaffected mother var = TrioGenotypes('X', 100, create_snv('M', "1/1"), create_snv('F', "1/0"), create_snv('M', "0/0")) self.inh.set_trio_genotypes(var) self.assertEqual(self.inh.check_homozygous("X-linked dominant"), "single_variant") self.assertEqual( self.inh.log_string, "male X chrom inherited from het mother or hom affected mother") # check for trio = 210, with affected mother, which should also pass self.inh.mother_affected = True self.assertEqual(self.inh.check_homozygous("X-linked dominant"), "single_variant") self.assertEqual( self.inh.log_string, "male X chrom inherited from het mother or hom affected mother") # check for trio = 220, with affected mother var = TrioGenotypes('X', 100, create_snv('M', "1/1"), create_snv('F', "1/1"), create_snv('M', "0/0")) self.inh.set_trio_genotypes(var) self.assertEqual(self.inh.check_homozygous("X-linked dominant"), "single_variant") self.assertEqual( self.inh.log_string, "male X chrom inherited from het mother or hom affected mother") # check for trio = 220, with unaffected mother, which should not pass self.inh.mother_affected = False self.assertEqual(self.inh.check_homozygous("X-linked dominant"), "nothing") self.assertEqual(self.inh.log_string, "variant not compatible with being causal") # check that homozygous X-linked over-dominance doesn't pass self.assertEqual(self.inh.check_homozygous("X-linked over-dominance"), 'nothing') # check we raise errors with unknown inheritance modes with self.assertRaises(ValueError): self.inh.check_homozygous("Digenic")
def test_get_parental_var_snv(self): ''' check that get_parental_var() works correctly for SNVs ''' sex = 'F' var = create_snv(sex, '0/1') mom = Person('fam_id', 'mom', '0', '0', 'F', '1', '/PATH') parental = [] # try to get a matching variant for a mother. This will create a default # variant for a missing parental genotype self.assertEqual(self.vcf_loader.get_parental_var(var, parental, mom), SNV(chrom="1", position=150, id=".", ref="A", alts="G", filter="PASS", info=var.get_info_as_string(), format="GT", sample="0/0", gender="female", mnv_code=None)) # now see if we can pick up a variant where it does exist mother_var = create_snv(sex, '0/0') self.assertEqual(self.vcf_loader.get_parental_var(var, [mother_var], mom), mother_var)
def test_check_homozygous_male(self): """ test that check_homozygous() works correctly for males """ # check for trio with de novo on male X chrom var = TrioGenotypes('X', 100, create_snv('M', "1/1"), create_snv('F', "0/0"), create_snv('M', "0/0")) trio = self.create_family('male', '1', '1') self.inh = Allosomal([var], trio, self.known_gene, "TEST") self.inh.set_trio_genotypes(var) self.assertEqual(self.inh.check_homozygous("X-linked dominant"), "single_variant") self.assertEqual(self.inh.log_string, "male X chrom de novo") # check for trio = 210, with unaffected mother var = TrioGenotypes('X', 100, create_snv('M', "1/1"), create_snv('F', "1/0"), create_snv('M', "0/0")) self.inh.set_trio_genotypes(var) self.assertEqual(self.inh.check_homozygous("X-linked dominant"), "single_variant") self.assertEqual(self.inh.log_string, "male X chrom inherited from het mother or hom affected mother") # check for trio = 210, with affected mother, which should also pass self.inh.mother_affected = True self.assertEqual(self.inh.check_homozygous("X-linked dominant"), "single_variant") self.assertEqual(self.inh.log_string, "male X chrom inherited from het mother or hom affected mother") # check for trio = 220, with affected mother var = TrioGenotypes('X', 100, create_snv('M', "1/1"), create_snv('F', "1/1"), create_snv('M', "0/0")) self.inh.set_trio_genotypes(var) self.assertEqual(self.inh.check_homozygous("X-linked dominant"), "single_variant") self.assertEqual(self.inh.log_string, "male X chrom inherited from het mother or hom affected mother") # check for trio = 220, with unaffected mother, which should not pass self.inh.mother_affected = False self.assertEqual(self.inh.check_homozygous("X-linked dominant"), "nothing") self.assertEqual(self.inh.log_string, "variant not compatible with being causal") # check that homozygous X-linked over-dominance doesn't pass self.assertEqual(self.inh.check_homozygous("X-linked over-dominance"), 'nothing') # check we raise errors with unknown inheritance modes with self.assertRaises(ValueError): self.inh.check_homozygous("Digenic")
def test_check_heterozygous_affected_father(self): """ test that check_heterozygous() works correctly for affected fathers """ # set the father as non-ref genotype and unaffected var = TrioGenotypes('X', 100, create_snv('F', "1/0"), create_snv('F', "0/0"), create_snv('M', "1/1")) self.inh.set_trio_genotypes(var) # check that the het proband, with het unaffected father is passes self.assertEqual(self.inh.check_heterozygous("X-linked dominant"), "nothing") self.assertEqual(self.inh.log_string, "variant not compatible with being causal") # check that the het proband, with het affected father is captured self.inh.father_affected = True self.assertEqual(self.inh.check_heterozygous("X-linked dominant"), "single_variant") self.assertEqual(self.inh.log_string, "x chrom transmitted from aff, other parent non-carrier or aff") # check that when the other parent is also non-ref, the variant is no # longer captured, unless the parent is affected var = TrioGenotypes('X', 100, create_snv('F', "1/0"), create_snv('F', "1/0"), create_snv('M', "1/1")) self.inh.set_trio_genotypes(var) self.assertEqual(self.inh.check_heterozygous("X-linked dominant"), "nothing") self.assertEqual(self.inh.log_string, "variant not compatible with being causal") self.inh.mother_affected = True self.inh.check_heterozygous("X-linked dominant") self.assertEqual(self.inh.log_string, "x chrom transmitted from aff, other parent non-carrier or aff")
def test_check_heterozygous_de_novo(self): """ test that check_heterozygous() works correctly for de novos """ # all of these tests are run for female X chrom de novos, since male # X chrom hets don't exist var = TrioGenotypes('X', 100, create_snv('F', "1/0"), create_snv('F', "0/0"), create_snv('M', "0/0")) self.inh.set_trio_genotypes(var) # check for X-linked dominant inheritance self.assertEqual(self.inh.check_heterozygous("X-linked dominant"), "single_variant") self.assertEqual(self.inh.log_string, "female x chrom de novo") # check for biallelic inheritance self.assertEqual(self.inh.check_heterozygous("Hemizygous"), "single_variant") # check for X-linked over dominance self.assertEqual(self.inh.check_heterozygous("X-linked over-dominance"), 'single_variant') # check we raise errors with unknown inheritance modes with self.assertRaises(ValueError): self.inh.check_heterozygous("Digenic") genos = {'0': '0/0', '1': '1/0', '2': '1/1'} for (child, mom, dad) in ["102", "110", "112", "122"]: var = TrioGenotypes('X', 100, create_snv('F', genos[child]), create_snv('F', genos[mom]), create_snv('M', genos[dad])) self.inh.set_trio_genotypes(var) self.inh.check_heterozygous("X-linked dominant") self.assertNotEqual(self.inh.log_string, "female x chrom de novo")
def test_check_heterozygous_affected_mother(self): """ test that check_heterozygous() works correctly for affected mothers """ # check that trio with het affected mother is captured var = TrioGenotypes('X', 100, create_snv('F', "1/0"), create_snv('F', "1/0"), create_snv('M', "0/0")) self.inh.set_trio_genotypes(var) self.inh.mother_affected = True self.assertEqual(self.inh.check_heterozygous("X-linked dominant"), "single_variant") self.assertEqual( self.inh.log_string, "x chrom transmitted from aff, other parent non-carrier or aff") # check that when the other parent is also non-ref, the variant is no # longer captured, unless the parent is affected var = TrioGenotypes('X', 100, create_snv('F', "1/0"), create_snv('F', "1/0"), create_snv('M', "1/1")) self.inh.set_trio_genotypes(var) self.assertEqual(self.inh.check_heterozygous("X-linked dominant"), "nothing") self.assertEqual(self.inh.log_string, "variant not compatible with being causal") self.inh.father_affected = True self.inh.check_heterozygous("X-linked dominant") self.assertEqual( self.inh.log_string, "x chrom transmitted from aff, other parent non-carrier or aff") # and check that hemizgygous vars return as "compound_het" self.assertEqual(self.inh.check_heterozygous("Hemizygous"), "compound_het")
def setUp(self): """ define a family and variant, and start the Allosomal class """ # generate a test family child_gender = "F" mom_aff = "1" dad_aff = "1" self.trio = self.create_family(child_gender, mom_aff, dad_aff) # generate a test variant child = create_snv(child_gender, "0/1", chrom='X', pos=150, extra_info='HGNC=TEST;MAX_AF=0.0005') mom = create_snv("F", "0/0", chrom='X', pos=150) dad = create_snv("M", "0/0", chrom='X', pos=150) self.variants = [TrioGenotypes('X', '150', child, mom, dad)] self.report = Report(None, None, None) Info.set_populations(["AFR_AF", "AMR_AF", "ASN_AF", "DDD_AF", "EAS_AF", "ESP_AF", "EUR_AF", "MAX_AF", "SAS_AF", "UK10K_cohort_AF"])
def setUp(self): """ define a family and variant, and start the Allosomal class """ # generate a test family child_gender = "F" mom_aff = "1" dad_aff = "1" self.trio = self.create_family(child_gender, mom_aff, dad_aff) # generate a test variant child = create_snv(child_gender, "0/1") mom = create_snv("F", "0/0") dad = create_snv("M", "0/0") var = TrioGenotypes(child.get_chrom(), child.get_position(), child, mom, dad) self.variants = [var] # make sure we've got known genes data self.known_gene = {"inh": ["Monoallelic"], "confirmed_status": ["confirmed dd gene"]} self.inh = Allosomal(self.variants, self.trio, self.known_gene, "1001") self.inh.is_lof = var.child.is_lof()
def test_check_variant_without_parents_male(self): """ test that check_variant_without_parents() works correctly for males """ var = TrioGenotypes('X', 100, create_snv('M', "1/1"), None, None) trio = self.create_family('male', '1', '1') self.inh = Allosomal([var], trio, self.known_gene, "TEST") self.inh.set_trio_genotypes(var) # check for X-linked dominant inheritance self.assertEqual(self.inh.check_variant_without_parents("X-linked dominant"), "single_variant") # and check for hemizygous inheritance self.assertEqual(self.inh.check_variant_without_parents("Hemizygous"), "single_variant")
def test_check_variant_without_parents_male(self): """ test that check_variant_without_parents() works correctly for males """ var = TrioGenotypes('X', 100, create_snv('M', "1/1"), None, None) trio = self.create_family('male', '1', '1') self.inh = Allosomal([var], trio, self.known_gene, "TEST") self.inh.set_trio_genotypes(var) # check for X-linked dominant inheritance self.assertEqual( self.inh.check_variant_without_parents("X-linked dominant"), "single_variant") # and check for hemizygous inheritance self.assertEqual(self.inh.check_variant_without_parents("Hemizygous"), "single_variant")
def test_check_heterozygous_de_novo(self): """ test that check_heterozygous() works correctly for de novos """ # all of these tests are run for female X chrom de novos, since male # X chrom hets don't exist var = TrioGenotypes('X', 100, create_snv('F', "1/0"), create_snv('F', "0/0"), create_snv('M', "0/0")) self.inh.set_trio_genotypes(var) # check for X-linked dominant inheritance self.assertEqual(self.inh.check_heterozygous("X-linked dominant"), "single_variant") self.assertEqual(self.inh.log_string, "female x chrom de novo") # check for biallelic inheritance self.assertEqual(self.inh.check_heterozygous("Hemizygous"), "single_variant") # check for X-linked over dominance self.assertEqual( self.inh.check_heterozygous("X-linked over-dominance"), 'single_variant') # check we raise errors with unknown inheritance modes with self.assertRaises(ValueError): self.inh.check_heterozygous("Digenic") genos = {'0': '0/0', '1': '1/0', '2': '1/1'} for (child, mom, dad) in ["102", "110", "112", "122"]: var = TrioGenotypes('X', 100, create_snv('F', genos[child]), create_snv('F', genos[mom]), create_snv('M', genos[dad])) self.inh.set_trio_genotypes(var) self.inh.check_heterozygous("X-linked dominant") self.assertNotEqual(self.inh.log_string, "female x chrom de novo")