Esempio n. 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))
Esempio n. 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))
Esempio n. 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.')
Esempio n. 4
0
 def test_query_diff_chromosome_same_pair_position(self):
     chromosome1, chromosome2 = 'AG', 'CT'
     # set up father
     mother = a2.Female(build_id('f'))
     mother.set_by_pos(17, 42, chromosome1)
     # set up query
     query = a2.Query()
     query.set_by_pos(17, 42, chromosome2)
     self.assertFalse(mother.test(query),
                      'Failed to test the query. Both chromosome is set to (%d-%d), but Mother chromosome is "%s", Query chromosome is "%s".'
                      % (17, 42, chromosome1, chromosome2))
Esempio n. 5
0
 def test_query_set_by_marker(self):
     chromosome = random.choice(NUCLEOTIDE) + 'G'
     marker = build_marker()
     # setup mother
     mother = a2.Female(build_id('f'))
     mother.set_by_pos(9, 76, chromosome)
     # set up query
     query = a2.Query()
     query.set_marker(marker, 9, 76)
     query.set_by_marker(marker, '3G')
     self.assertTrue(mother.test(query),
                     'Failed to test the query. Chromosome "%s" is set to (%d-%d)' % (chromosome, 9, 76))
Esempio n. 6
0
 def test_init(self):
     self.assertIsNotNone(a2.Female(build_id('f')), 'Failed to create Female object.')
Esempio n. 7
0
 def setUp(self):
     self.female = a2.Female(build_id('female'))