Exemplo n.º 1
0
 def test_correct_json(self):
     file_mock = StringIO(
         '{"GP": 1, "SAME": 2, "DIFF": 3, "MAX_SEQ_LENGTH": 4, "MAX_PATHS": 5}'
     )
     config = Needelman_Wunch.Config(file_mock)
     self.assertEqual(config.gap_penalty, 1)
     self.assertEqual(config.same_reward, 2)
     self.assertEqual(config.diff_penalty, 3)
     self.assertEqual(config.max_seq_length, 4)
     self.assertEqual(config.max_paths, 5)
Exemplo n.º 2
0
 def test_diff_length_seq(self):
     config_file_mock = StringIO(
         '{"GP": -2, "SAME": 2, "DIFF": -3, "MAX_SEQ_LENGTH": 10, "MAX_PATHS": 5}'
     )
     config = Needelman_Wunch.Config(config_file_mock)
     seq1 = 'ADB'
     seq2 = 'AB'
     table = Needelman_Wunch.NwTable(seq1, seq2, config)
     paths_generator = table.path_generator()
     score, paths = next(paths_generator)
     self.assertEqual(score, 2)
     self.assertSequenceEqual(paths, ('ADB', 'A_B'))
     with self.assertRaises(StopIteration):
         next(paths_generator)
Exemplo n.º 3
0
 def test_output_limit(self):
     config_file_mock = StringIO(
         '{"GP": -2, "SAME": 2, "DIFF": -5, "MAX_SEQ_LENGTH": 10, "MAX_PATHS": 1}'
     )
     expected_seqs = {('AB_', 'A_D'), ('A_B', 'AD_')}
     config = Needelman_Wunch.Config(config_file_mock)
     seq1 = 'AB'
     seq2 = 'AD'
     table = Needelman_Wunch.NwTable(seq1, seq2, config)
     paths_generator = table.path_generator()
     score1, out_seqs1 = next(paths_generator)
     self.assertEqual(score1, -2)
     self.assertTrue({out_seqs1}.issubset(expected_seqs))
     with self.assertRaises(StopIteration):
         next(paths_generator)
Exemplo n.º 4
0
 def test_long_sequences(self):
     # get all output paths
     # sample comes from internet
     config_file_mock = StringIO(
         '{"GP": -2, "SAME": 1, "DIFF": -1, "MAX_SEQ_LENGTH": 15, "MAX_PATHS": 1000}'
     )
     expected_seq = {('GAA__CGA_ACGTAACC', 'CAAGACGACACG_AAC_')}
     config = Needelman_Wunch.Config(config_file_mock)
     seq1 = 'GAACGAACGTAACC'
     seq2 = 'CAAGACGACACGAAC'
     pats_set = set()
     table = Needelman_Wunch.NwTable(seq1, seq2, config)
     for score, paths in table.path_generator():
         self.assertEqual(score, 0)
         pats_set.add(paths)
     self.assertTrue(expected_seq.issubset(pats_set))
Exemplo n.º 5
0
 def test_lack_value(self):
     file_mock = StringIO(
         '{"SAME": 2, "DIFF": 3, "MAX_SEQ_LENGTH": 4, "MAX_PATHS": 5}')
     with self.assertRaises(Needelman_Wunch.InputError):
         Needelman_Wunch.Config(file_mock)
Exemplo n.º 6
0
 def test_not_json(self):
     file_mock = StringIO('jnaiolfubsiao')
     with self.assertRaises(Needelman_Wunch.InputError):
         Needelman_Wunch.Config(file_mock)