Exemple #1
0
 def test_is_aligned(self):
     system = System(self.cfg, "T2SS", 10)
     gene_ref = Gene(self.cfg, 'sctJ_FLG', system, self.profile_registry)
     gene = Gene(self.cfg, 'sctJ', system, self.profile_registry)
     homolog = Homolog( gene, gene_ref)
     self.assertFalse( homolog.is_aligned() )
     homolog = Homolog(gene, gene_ref, aligned = True  )
     self.assertTrue( homolog.is_aligned() )
Exemple #2
0
 def test_get_homologs(self):
     system_foo = System(self.cfg, "foo", 10)
     system_bar = System(self.cfg, "bar", 10)
     gene = Gene(self.cfg, 'sctN', system_foo, self.profile_registry)
     sctJ_FLG = Gene(self.cfg, 'sctJ_FLG', system_foo,
                     self.profile_registry)
     sctJ = Gene(self.cfg, 'sctJ', system_bar, self.profile_registry)
     homolog_1 = Homolog(sctJ_FLG, gene)
     gene.add_homolog(homolog_1)
     homolog_2 = Homolog(sctJ, gene)
     gene.add_homolog(homolog_2)
     self.assertEqual(gene.get_homologs(), [homolog_1, homolog_2])
Exemple #3
0
 def test_add_homolog(self):
     system_foo = System(self.cfg, "foo", 10)
     system_bar = System(self.cfg, "bar", 10)
     gene = Gene(self.cfg, 'sctJ_FLG', system_foo, self.profile_registry)
     gene_ref = Gene(self.cfg, 'sctJ', system_bar, self.profile_registry)
     homolog = Homolog(self.cfg, gene, gene_ref)
     gene.add_homolog(homolog)
     self.assertEqual(len(gene.homologs), 1)
     self.assertEqual(gene.homologs[0], homolog)
 def test_is_aligned(self):
     system = System(self.cfg, "T2SS", 10)
     gene_ref = Gene(self.cfg, 'sctJ_FLG', system, self.profile_registry)
     gene = Gene(self.cfg, 'sctJ', system, self.profile_registry)
     homolog = Homolog(gene, gene_ref)
     self.assertFalse(homolog.is_aligned())
     homolog = Homolog(gene, gene_ref, aligned=True)
     self.assertTrue(homolog.is_aligned())
Exemple #5
0
    def test_str(self):
        """
        """
        system_foo = System(self.cfg, "foo", 10)
        gene = Gene(self.cfg, 'sctJ_FLG', system_foo, self.profile_registry)
        system_bar = System(self.cfg, "bar", 20)
        gene_homolog = Gene(self.cfg, 'sctJ', system_bar,
                            self.profile_registry)
        homolog = Homolog(gene_homolog, gene, self.cfg)
        gene.add_homolog(homolog)
        s = """name : sctJ_FLG
inter_gene_max_space: 10
    homologs: sctJ"""
        self.assertEqual(str(gene), s)
    def test_get_gene_ref(self):
        system = System(self.cfg, "foo", 10)
        gene_name = 'sctJ_FLG'
        gene_ref = Gene(self.cfg, gene_name, system, self.profile_registry)
        homolog_name = 'sctJ'
        gene_homolg = Gene(self.cfg, homolog_name, system,
                           self.profile_registry)
        homolog = Homolog(gene_homolg, gene_ref)
        gene_ref.add_homolog(homolog)

        for meth in (system.add_forbidden_gene, system.add_accessory_gene,
                     system.add_mandatory_gene):
            system._mandatory_genes = []
            system._accessory_genes = []
            system._forbidden_genes = []
            meth(gene_ref)
            self.assertEqual(gene_ref, system.get_gene_ref(homolog))
        self.assertIsNone(system.get_gene_ref(gene_ref))
        gene_ukn = Gene(self.cfg, 'abc', system, self.profile_registry)
        self.assertRaises(KeyError, system.get_gene_ref, gene_ukn)
    def test_get_gene(self):
        system = System(self.cfg, "foo", 10)
        gene_name = 'sctJ_FLG'
        gene = Gene(self.cfg, gene_name, system, self.profile_registry)
        for meth in (system.add_forbidden_gene, system.add_accessory_gene,
                     system.add_mandatory_gene):
            system._mandatory_genes = []
            system._accessory_genes = []
            system._forbidden_genes = []
            meth(gene)
            self.assertEqual(gene, system.get_gene(gene_name))

        self.assertRaises(KeyError, system.get_gene, 'bar')

        homolog_name = 'sctJ'
        gene_homolog = Gene(self.cfg, homolog_name, system,
                            self.profile_registry)
        homolog = Homolog(gene_homolog, gene)
        gene.add_homolog(homolog)
        for meth in (system.add_forbidden_gene, system.add_accessory_gene,
                     system.add_mandatory_gene):
            system._mandatory_genes = []
            system._accessory_genes = []
            system._forbidden_genes = []
            meth(gene)
            self.assertEqual(homolog, system.get_gene(homolog_name))

        analog_name = 'sctC'
        gene_analog = Gene(self.cfg, analog_name, system,
                           self.profile_registry)
        analog = Analog(gene_analog, gene)
        gene.add_analog(analog)
        for meth in (system.add_forbidden_gene, system.add_accessory_gene,
                     system.add_mandatory_gene):
            system._mandatory_genes = []
            system._accessory_genes = []
            system._forbidden_genes = []
            meth(gene)
            self.assertEqual(analog, system.get_gene(analog_name))
 def test_delegation(self):
     system = System(self.cfg, "T2SS", 10)
     gene_ref = Gene(self.cfg, 'sctJ_FLG', system, self.profile_registry)
     gene = Gene(self.cfg, 'sctJ', system, self.profile_registry)
     homolog = Homolog(gene, gene_ref)
     self.assertEqual(homolog.system, system)
 def test_gene_ref(self):
     system = System(self.cfg, "T2SS", 10)
     gene_ref = Gene(self.cfg, 'sctJ_FLG', system, self.profile_registry)
     gene = Gene(self.cfg, 'sctJ', system, self.profile_registry)
     homolog_1 = Homolog(gene, gene_ref)
     self.assertEqual(homolog_1.gene_ref, gene_ref)