Beispiel #1
0
 def test_procreate_child_child_chromosome_set(self):
     chromosome_m1, chromosome_f1 = 'AC', 'GA'
     chromosome_m2, chromosome_f2 = 'CT', 'TG'
     # set up father chromosome
     father = a2.Male(build_id('m'))
     father.set_by_pos(17, 42, chromosome_m1)
     father.set_by_pos(10, 84, chromosome_m2)
     self.assertEqual(chromosome_m1, father.get_by_pos(17, 42),
                      'Failed to set father chromosome "%s" to %d-%d.' % (chromosome_m1, 17, 42))
     self.assertEqual(chromosome_m2, father.get_by_pos(10, 84),
                      'Failed to set father chromosome "%s" to %d-%d.' % (chromosome_m2, 10, 84))
     # set up mother chromosome
     mother = a2.Female(build_id('f'))
     mother.set_by_pos(17, 42, chromosome_f1)
     mother.set_by_pos(10, 84, chromosome_f2)
     self.assertEqual(chromosome_f1, mother.get_by_pos(17, 42),
                      'Failed to set mother chromosome "%s" to %d-%d.' % (chromosome_f1, 17, 42))
     self.assertEqual(chromosome_f2, mother.get_by_pos(10, 84),
                      'Failed to set mother chromosome "%s" to %d-%d.' % (chromosome_f2, 10, 84))
     # set up binder chromosome
     binder = a2.Binder()
     binder.set_sex('F')
     binder.set_by_pos(17, 42, 'RM')
     binder.set_by_pos(10, 84, 'LM')
     # procreate child
     child = mother.procreate(father, binder)
     self.assertIsNotNone(child, 'Failed to procreate child. No Female object is created.')
     self.assertTrue(isinstance(child, a2.Female), 'Type check failed, procreated child should be a Female object.')
     self.assertEqual('AA', child.get_by_pos(17, 42), 'Child chromosome at %d-%d is incorrect.' % (17, 42))
     self.assertEqual('TT', child.get_by_pos(10, 84), 'Child chromosome at %d-%d is incorrect.' % (10, 84))
Beispiel #2
0
 def test_set_by_pos_boundary_index_and_check_child_index(self):
     chromosome_m1, chromosome_f1 = 'CT', 'AC'
     chromosome_m2, chromosome_f2 = 'AG', 'GT'
     # set up father chromosome
     father = a2.Male(build_id('m'))
     father.set_by_pos(0, 42, chromosome_m1)
     father.set_by_pos(22, 84, chromosome_m2)
     # self.assertEqual(chromosome_m1, father.get_by_pos(0, 42),
     #                  'Failed to set father chromosome "%s" to %d-%d.' % (chromosome_m1, 0, 42))
     # self.assertEqual(chromosome_m2, father.get_by_pos(22, 84),
     #                  'Failed to set father chromosome "%s" to %d-%d.' % (chromosome_m2, 22, 84))
     # set up mother chromosome
     mother = a2.Female(build_id('f'))
     mother.set_by_pos(0, 42, chromosome_f1)
     mother.set_by_pos(22, 84, chromosome_f2)
     # self.assertEqual(chromosome_f1, mother.get_by_pos(0, 42),
     #                  'Failed to set mother chromosome "%s" to %d-%d.' % (chromosome_f1, 0, 42))
     # self.assertEqual(chromosome_f2, mother.get_by_pos(22, 84),
     #                  'Failed to set mother chromosome "%s" to %d-%d.' % (chromosome_f2, 22, 84))
     # set up binder chromosome
     binder = a2.Binder()
     binder.set_sex('M')
     binder.set_by_pos(0, 42, 'RM')
     binder.set_by_pos(22, 84, 'LM')
     # procreate child
     child = mother.procreate(father, binder)
     # self.assertIsNotNone(child, 'Failed to procreate child (Male). No Male object is created.')
     # self.assertTrue(isinstance(child, a2.Male), 'Type check failed, procreated child should be a Male object.')
     self.assertEqual('CC', child.get_by_pos(0, 42), 'Child chromosome at %d-%d is incorrect.' % (0, 42))
     self.assertEqual('GG', child.get_by_pos(22, 84), 'Child chromosome at %d-%d is incorrect.' % (22, 84))
Beispiel #3
0
 def test_procreate_no_child_chromosome_set(self):
     father = a2.Male(build_id('m'))
     mother = a2.Female(build_id('f'))
     binder = a2.Binder()
     binder.set_sex('F')
     child = mother.procreate(father, binder)
     self.assertIsNotNone(child, 'Failed to procreate child (Female). No Female object is created.')
     self.assertFalse(isinstance(child, a2.Male), 'Type check failed, procreated child should be a Male object.')
     self.assertTrue(isinstance(child, a2.Female), 'Type check failed, procreated child should not be a Female object.')
Beispiel #4
0
 def test_query_set_by_pos(self):
     chromosome = build_chromosome()
     # set up father
     father = a2.Male(build_id('m'))
     father.set_by_pos(17, 42, chromosome)
     # set up query
     query = a2.Query()
     query.set_by_pos(17, 42, chromosome)
     self.assertTrue(father.test(query),
                     'Failed to test the query. Chromosome "%s" is set to (%d-%d)' % (chromosome, 17, 42))
Beispiel #5
0
 def test_query_same_chromosome_diff_sex_chromosome_pair(self):
     chromosome = build_chromosome()
     # set up father
     father = a2.Male(build_id('m'))
     father.set_by_pos(11, 42, chromosome)
     # set up query
     query = a2.Query()
     query.set_by_pos(22, 42, chromosome)
     self.assertFalse(father.test(query),
                      'Failed to test the query. Chromosome is "%s". Father chromosome is set to (%d-%d), but query chromosome is set to (%d-%d)'
                      % (chromosome, 11, 42, 22, 42))
Beispiel #6
0
 def test_init(self):
     self.assertIsNotNone(a2.Male(build_id('m')), 'Failed to create Male object.')
Beispiel #7
0
 def setUp(self):
     self.male = a2.Male(build_id('male'))