Beispiel #1
0
 def test_parse_nodes(self):
     self.assertEqual(parse_nodes(self.data),
                      [('Rosalind_0498', 'AAATAAA'),
                       ('Rosalind_2391', 'AAATTTT'),
                       ('Rosalind_2323', 'TTTTCCC'),
                       ('Rosalind_0442', 'AAATCCC'),
                       ('Rosalind_5013', 'GGGTGGG')])
Beispiel #2
0
 def test_directional_multiple(self):
     labeled = parse_nodes(self.data)
     comparer = compare_multiple(labeled)
     current, overlaps = next(comparer)
     path = overlaps.pop(0)
     self.assertEqual(directional(current, path),
                      ('Rosalind_0498', 'Rosalind_2391'))
Beispiel #3
0
 def test_pick_best_matches(self): #note that the current scoring includes identity matches that might be irrelevant
     labeled = parse_nodes(self.data)
     sample = list(compare_multiple(labeled))[0]
     current = sample[0]
     overlaps = sample[1]
     scored_pairs = make_score_dict(current, overlaps)
     best_pair = pick_best_matches(scored_pairs)
     self.assertEqual(best_pair, (('Rosalind_0498', 'AAATAAA'), ('Rosalind_0442', 'AAATCCC')))
Beispiel #4
0
 def test_make_score_dict(self):
     labeled = parse_nodes(self.data)
     sample = list(compare_multiple(labeled))[0]
     current = sample[0]
     overlaps = sample[1]
     scored_pairs = make_score_dict(current, overlaps)
     self.assertNotIn((current, current), scored_pairs.keys())
     self.assertEqual(len(scored_pairs), 2)
     self.assertEqual(sorted(scored_pairs.values()), [1, 2])
Beispiel #5
0
 def test_make_score_dict(self):
     labeled = parse_nodes(self.data)
     sample = list(compare_multiple(labeled))[0]
     current = sample[0]
     overlaps = sample[1]
     scored_pairs = make_score_dict(current, overlaps)
     self.assertNotIn((current, current), scored_pairs.keys())
     self.assertEqual(len(scored_pairs), 2)
     self.assertEqual(sorted(scored_pairs.values()), [1, 2])
Beispiel #6
0
 def test_get_o3_matches_short_seq(self):
     self.longMessage = True #for debugging without truncation
     labeled = parse_nodes(self.data)
     #print(labeled)
     actual = compare_all_pairs_both_ways(labeled)
     expected = [('Rosalind_2391', 'Rosalind_2323'),
                 ('Rosalind_0498', 'Rosalind_2391'),
                 ('Rosalind_0498', 'Rosalind_0442')]
     self.assertEqual(set(expected), set(actual), msg='{0},{1}'.format(expected, actual))
Beispiel #7
0
 def test_compare_multiple(self):
     self.longMessage = True  #for debugging without truncation
     labeled = parse_nodes(self.data)
     actual = compare_multiple(labeled)
     expected = [('Rosalind_0498', 'Rosalind_2391'),
                 ('Rosalind_2391', 'Rosalind_2323'),
                 ('Rosalind_0498', 'Rosalind_0442')]
     self.assertEqual(set(expected),
                      set(actual),
                      msg='{0},{1}'.format(expected, actual))
Beispiel #8
0
 def test_compare_base_count_sums(self):
     """
     simplest way only works for simplest examples.
     """
     labeled = parse_nodes(self.data)
     sample = list(compare_multiple(labeled))[0]
     current = sample[0]
     overlaps = sample[1]
     self.assertEqual(compare_base_counts(current, overlaps[0]), 1)
     self.assertEqual(compare_base_counts(current, overlaps[1]), 2)
     self.assertEqual(compare_base_counts(overlaps[0], overlaps[1]), 0)
Beispiel #9
0
 def test_directional_best_pair(self):
     labeled = parse_nodes(self.data)
     sample = list(compare_multiple(labeled))[0]
     current = sample[0]
     overlaps = sample[1]
     scored_pairs = make_score_dict(current, overlaps)
     self.assertNotIn((current, current), scored_pairs.keys())
     best_pair = pick_best_matches(scored_pairs)
     self.assertNotIn((current, current), list(best_pair))
     tup = directional(list(best_pair)[0], list(best_pair)[1])
     self.assertEqual(tup, ('Rosalind_0498', 'Rosalind_0442'))
Beispiel #10
0
 def test_compare_base_count_sums(self):
     """
     simplest way only works for simplest examples.
     """
     labeled = parse_nodes(self.data)
     sample = list(compare_multiple(labeled))[0]
     current = sample[0]
     overlaps = sample[1]
     self.assertEqual(compare_base_counts(current, overlaps[0]), 1)
     self.assertEqual(compare_base_counts(current, overlaps[1]), 2)
     self.assertEqual(compare_base_counts(overlaps[0], overlaps[1]), 0)
Beispiel #11
0
 def test_directional_best_pair(self):
     labeled = parse_nodes(self.data)
     sample = list(compare_multiple(labeled))[0]
     current = sample[0]
     overlaps = sample[1]
     scored_pairs = make_score_dict(current, overlaps)
     self.assertNotIn((current, current), scored_pairs.keys())
     best_pair = pick_best_matches(scored_pairs)
     self.assertNotIn((current, current), list(best_pair))
     tup = directional(list(best_pair)[0], list(best_pair)[1])
     self.assertEqual(tup, ('Rosalind_0498', 'Rosalind_0442'))
Beispiel #12
0
 def test_pick_best_matches(
     self
 ):  #note that the current scoring includes identity matches that might be irrelevant
     labeled = parse_nodes(self.data)
     sample = list(compare_multiple(labeled))[0]
     current = sample[0]
     overlaps = sample[1]
     scored_pairs = make_score_dict(current, overlaps)
     best_pair = pick_best_matches(scored_pairs)
     self.assertEqual(best_pair, (('Rosalind_0498', 'AAATAAA'),
                                  ('Rosalind_0442', 'AAATCCC')))
Beispiel #13
0
 def test_compare_multiple(self):
     self.longMessage = True #for debugging without truncation
     labeled = parse_nodes(self.data)
     actual = compare_multiple(labeled)
     expected = [('Rosalind_0498', 'Rosalind_2391'), ('Rosalind_2391', 'Rosalind_2323'), ('Rosalind_0498', 'Rosalind_0442')]
     self.assertEqual(set(expected), set(actual), msg='{0},{1}'.format(expected, actual))
Beispiel #14
0
 def test_parse_nodes(self):
     self.assertEqual(parse_nodes(self.data), [('Rosalind_0498', 'AAATAAA'),
                                                  ('Rosalind_2391', 'AAATTTT'),
                                                  ('Rosalind_2323', 'TTTTCCC'),
                                                  ('Rosalind_0442', 'AAATCCC'),
                                                  ('Rosalind_5013', 'GGGTGGG')])
Beispiel #15
0
 def test_directional_multiple(self):
     labeled = parse_nodes(self.data)
     comparer = compare_multiple(labeled)
     current, overlaps = next(comparer)
     path = overlaps.pop(0)
     self.assertEqual(directional(current, path), ('Rosalind_0498', 'Rosalind_2391'))