Пример #1
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)
Пример #2
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)
Пример #3
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))