def test_no_active_sample(self):
     ss = samples_selection_factory(db='test', groups={})
     try:
         var = GenotypesFilterDominant(ss).apply(self.variants).variants
     except ValueError as ve:
         self.fail("Calling genotype filter with no active samples raised an error: " + str(ve))
     self.assertEqual(len(var), 0)
    def test_compound_non_commutative(self):
        """The goal is to test the non-cummutativity of applying compound het then some other filter,
        or the contrary.
        Not certain about the final number, but at least it should go without an error."""
        variants = variants_collection_factory(db='test')
        ss = samples_selection_factory(db='test',
                                       groups={
                                           'affected': ['09818', '09819'],
                                           'not_affected': ['09960', '09961']
                                       })

        filter_coll = variant_filters_collection_factory([
            ('filter', '=', 'PASS'),
            ('aaf_1kg_all', '<=', '0.01'),
            ('genotype', '=', 'compound_het'),
        ], ss)
        var = filter_coll.apply(variants).variants
        self.assertEqual(len(var), 13)

        filter_coll = variant_filters_collection_factory([
            ('genotype', '=', 'compound_het'),
            ('filter', '=', 'PASS'),
            ('aaf_1kg_all', '<=', '0.01'),
        ], ss)
        var = filter_coll.apply(variants).variants
        self.assertEqual(len(var), 0)
 def test_no_active_sample(self):
     ss = samples_selection_factory(db='test', groups={})
     try:
         var = GenotypesFilterDominant(ss).apply(self.variants).variants
     except ValueError as ve:
         self.fail(
             "Calling genotype filter with no active samples raised an error: "
             + str(ve))
     self.assertEqual(len(var), 0)
 def test_missing_group1(self):
     """An empty required group results in no variant passing."""
     ss = samples_selection_factory(db='test',
                                    groups={
                                        "affected": [],
                                        "not_affected": ['09969']
                                    })
     var = GenotypesFilterDominant(ss).apply(self.variants).variants
     self.assertEqual(len(var), 0)
 def test_compound_Lucie_FNDC1(self):
     """These 2(3) variants are annotated on different transcripts of the same gene,
     and because of the group_by(transcript_id), the compound was not found.
     Check here that it is fixed.
     """
     ss = samples_selection_factory(db='test',
         groups = {'affected': ['101563','101591'], 'not_affected':['101564','101565']})
     variants = variants_collection_factory(db='test',
         qs=Variant.objects.using('test').filter(gene_symbol='FNDC1'))
     ## To select them directly:
     #variants = variants_collection_factory(
     #    Variants.objects.using('test').filter(start__in=['159653504','159653634']), db='test')
     var = GenotypesFilterCompoundHeterozygous(ss).apply(variants).variants
     self.assertEqual(len(var), 3)
 def test_Xlinked_Norine_BMX(self):
     """This gene has no X-linked variant"""
     db = 'lgueneau'
     ss = samples_selection_factory(db=db,
         groups = {'affected': ['09818','09819'], 'not_affected':['09960','09961']})
     qs = Variant.objects.using(db).filter(gene_symbol__in=['BMX'], chrom='chrX')
     # Using GenotypesFilterXLinked.apply()
     variants = variants_collection_factory(db=db, qs=qs)
     var = GenotypesFilterXLinked(ss).apply(variants).variants
     self.assertEqual(len(var), 0)
     # Using FilterCollection.apply()
     fc = FiltersCollection([GenotypesFilterXLinked(ss)])
     var = fc.apply(initqs=qs, db=db).variants
     self.assertEqual(len(var), 0)
 def test_Xlinked_Lucie_ASMTL(self):
     """This gene has 2 X-linked variants"""
     db = 'lgueneau'
     ss = samples_selection_factory(db=db,
         groups = {'affected': ['09818','09819'], 'not_affected':['09960','09961']})
     qs = Variant.objects.using(db).filter(gene_symbol__in=['ASMTL','CSF2RA','PPP2R3B','TM4SF2'], chrom='chrX')
     # Using GenotypesFilterXLinked.apply()
     variants = variants_collection_factory(db=db, qs=qs)
     print(GenotypesFilterXLinked(ss).conditions_vector)
     var = GenotypesFilterXLinked(ss).apply(variants).variants
     self.assertEqual(len(var), 5)
     # Using FilterCollection.apply()
     fc = FiltersCollection([GenotypesFilterXLinked(ss)])
     var = fc.apply(initqs=qs, db=db).variants
     self.assertEqual(len(var), 5)
 def test_Xlinked_Norine_BMX(self):
     """This gene has no X-linked variant"""
     db = 'lgueneau'
     ss = samples_selection_factory(db=db,
                                    groups={
                                        'affected': ['09818', '09819'],
                                        'not_affected': ['09960', '09961']
                                    })
     qs = Variant.objects.using(db).filter(gene_symbol__in=['BMX'],
                                           chrom='chrX')
     # Using GenotypesFilterXLinked.apply()
     variants = variants_collection_factory(db=db, qs=qs)
     var = GenotypesFilterXLinked(ss).apply(variants).variants
     self.assertEqual(len(var), 0)
     # Using FilterCollection.apply()
     fc = FiltersCollection([GenotypesFilterXLinked(ss)])
     var = fc.apply(initqs=qs, db=db).variants
     self.assertEqual(len(var), 0)
 def test_compound_Lucie_FNDC1(self):
     """These 2(3) variants are annotated on different transcripts of the same gene,
     and because of the group_by(transcript_id), the compound was not found.
     Check here that it is fixed.
     """
     ss = samples_selection_factory(db='test',
                                    groups={
                                        'affected': ['101563', '101591'],
                                        'not_affected':
                                        ['101564', '101565']
                                    })
     variants = variants_collection_factory(
         db='test',
         qs=Variant.objects.using('test').filter(gene_symbol='FNDC1'))
     ## To select them directly:
     #variants = variants_collection_factory(
     #    Variants.objects.using('test').filter(start__in=['159653504','159653634']), db='test')
     var = GenotypesFilterCompoundHeterozygous(ss).apply(variants).variants
     self.assertEqual(len(var), 3)
 def test_Xlinked_Lucie_ASMTL(self):
     """This gene has 2 X-linked variants"""
     db = 'lgueneau'
     ss = samples_selection_factory(db=db,
                                    groups={
                                        'affected': ['09818', '09819'],
                                        'not_affected': ['09960', '09961']
                                    })
     qs = Variant.objects.using(db).filter(
         gene_symbol__in=['ASMTL', 'CSF2RA', 'PPP2R3B', 'TM4SF2'],
         chrom='chrX')
     # Using GenotypesFilterXLinked.apply()
     variants = variants_collection_factory(db=db, qs=qs)
     print(GenotypesFilterXLinked(ss).conditions_vector)
     var = GenotypesFilterXLinked(ss).apply(variants).variants
     self.assertEqual(len(var), 5)
     # Using FilterCollection.apply()
     fc = FiltersCollection([GenotypesFilterXLinked(ss)])
     var = fc.apply(initqs=qs, db=db).variants
     self.assertEqual(len(var), 5)
    def test_compound_non_commutative(self):
        """The goal is to test the non-cummutativity of applying compound het then some other filter,
        or the contrary.
        Not certain about the final number, but at least it should go without an error."""
        variants = variants_collection_factory(db='test')
        ss = samples_selection_factory(db='test',
            groups = {'affected': ['09818','09819'], 'not_affected':['09960','09961']})

        filter_coll = variant_filters_collection_factory([
            ('filter', '=', 'PASS'),
            ('aaf_1kg_all', '<=', '0.01'),
            ('genotype', '=', 'compound_het'),
        ], ss)
        var = filter_coll.apply(variants).variants
        self.assertEqual(len(var), 13)

        filter_coll = variant_filters_collection_factory([
            ('genotype', '=', 'compound_het'),
            ('filter', '=', 'PASS'),
            ('aaf_1kg_all', '<=', '0.01'),
        ], ss)
        var = filter_coll.apply(variants).variants
        self.assertEqual(len(var), 0)
Esempio n. 12
0
 def setUp(self):
     self.ss = samples_selection_factory(TESTDB, groups='ped')
     self.variants = variants_collection_factory(TESTDB)
     self.N = len(self.variants)
 def test_missing_parents(self):
     """Missing the parents results in no variant passing."""
     ss = samples_selection_factory(db='test',
                                    groups={"affected": ['09818', '09819']})
     var = GenotypesFilterDeNovo(ss).apply(self.variants).variants
     self.assertEqual(len(var), 0)
 def test_missing_group1(self):
     """An empty required group results in no variant passing."""
     ss = samples_selection_factory(db='test', groups={"affected": [], "not_affected": ['09969']})
     var = GenotypesFilterDominant(ss).apply(self.variants).variants
     self.assertEqual(len(var), 0)
Esempio n. 15
0
 def test_add_genotypes_selection(self):
     v = Variant(chrom="chr1", start=12, transcript='ENST00000430354')
     ss = samples_selection_factory('test', groups={})
     exp = expose_variant(v)
     exp = add_genotypes_selection(exp, ss)
Esempio n. 16
0
 def setUp(self):
     self.ss = samples_selection_factory(TESTDB, groups='ped')
     self.variants = variants_collection_factory(TESTDB)
     self.N = len(self.variants)
Esempio n. 17
0
 def test_add_genotypes_selection(self):
     v = Variant(chrom="chr1", start=12, transcript='ENST00000430354')
     ss = samples_selection_factory('test', groups={})
     exp = expose_variant(v)
     exp = add_genotypes_selection(exp, ss)
 def test_missing_parents(self):
     """Missing the parents results in no variant passing."""
     ss = samples_selection_factory(db='test', groups={"affected": ['09818','09819']})
     var = GenotypesFilterDeNovo(ss).apply(self.variants).variants
     self.assertEqual(len(var), 0)
Esempio n. 19
0
 def setUp(self):
     self.ss = samples_selection_factory(db='test',
         groups = {'affected': ['09818','09819'], 'not_affected':['09960','09961']})
     self.qfilter = QualityFilter(op='>=', val='50')
     self.compound = GenotypesFilterCompoundHeterozygous(self.ss)
Esempio n. 20
0
 def setUp(self):
     self.ss = samples_selection_factory(db='test',
         groups = {'affected': ['09818','09819'], 'not_affected':['09960','09961']})
     self.qfilter = QualityFilter(op='>=', val='50')
     self.dominant = GenotypesFilterDominant(self.ss)
 def setUp(self):
     self.f = GenotypesFilterDoNothing(samples_selection_factory(db='test'))
 def setUp(self):
     self.f = GenotypesFilterDoNothing(samples_selection_factory(db='test'))
 def setUp(self):
     self.var = variants_collection_factory(db='test')
     self.ss = samples_selection_factory(db='test')