def test_GivenLongSequencesWithDiffAboveThreshold_AreNotRefLike(self): sequences = ["AATTA", "AATTT", "TATTA", "GCGGG"] seqlen = len(sequences[0]) self.assertTrue(seqlen >= LENGTH_THRESHOLD) self.assertEqual(get_one_ref_like_threshold_distance(seqlen), 1) self.assertEqual(get_majority_string(sequences), "AATTA") self.assertFalse(sequences_are_one_reference_like(sequences))
def test_GivenLongSequencesWithDiffBelowThreshold_AreRefLike(self): sequences = ["AATTA", "AATTT", "TATTA"] # Sequences are above length threshold seqlen = len(sequences[0]) self.assertTrue(seqlen >= LENGTH_THRESHOLD) # We tolerate up to one diff against majority string self.assertEqual(get_one_ref_like_threshold_distance(seqlen), 1) # Here's the majority string self.assertEqual(get_majority_string(sequences), "AATTA") # No sequence is > distance threshold from the majority string self.assertTrue(sequences_are_one_reference_like(sequences))
def test_majority_string_correct(self): actual = get_majority_string(self.sequences) expected = "GGGGCGGGCCC" self.assertEqual(actual, expected)
def test_get_all_distances_to_majority_string(self): majority_string = get_majority_string(self.sequences) actual = list(get_distances(self.sequences, majority_string)) expected = [11, 11, 0, 1, 1, 0] self.assertEqual(actual, expected)
def test_majority_string_bad_lengths_fails(self): sequences = ["AAA-", "AT-", "AAAA"] with self.assertRaises(ValueError): get_majority_string(sequences)