def test_should_get_distance_return_the_correct_values_if_there_are_no_gaps(self):
        matrix = Blosum62()

        self.assertEqual(-1, matrix.get_distance('A', 'R'))
        self.assertEqual(-3, matrix.get_distance('N', 'F'))
        self.assertEqual(-2, matrix.get_distance('X', 'C'))
        self.assertEqual(+4, matrix.get_distance('I', 'I'))
        self.assertEqual(+4, matrix.get_distance('V', 'V'))
Beispiel #2
0
    def test_most_frequent_A_with_BLOSUM62(self):
        # setup
        sequences = MSA(['AA', 'AC', 'AC'])

        # results
        result = Star(sequences, Blosum62()).compute()
        expected = 30

        # check
        self.assertEqual(expected, result)
Beispiel #3
0
    def test_only_gaps_with_BLOSUM62(self):
        # setup
        sequences = MSA(['---', '---'])

        # results
        result = SumOfPairs(sequences, Blosum62()).compute()
        expected = 3

        # check
        self.assertEqual(expected, result)
Beispiel #4
0
    def test_basic_score_with_gaps_BLOSUM62(self):
        # setup
        sequences = MSA(['FA', 'A-'])

        # results
        result = SumOfPairs(sequences, Blosum62()).compute()
        expected = -10

        # check
        self.assertEqual(expected, result)
Beispiel #5
0
def run_all_scores(msa: list) -> None:
    align_sequences = list(pair[1] for pair in msa)
    sequences_id = list(pair[0] for pair in msa)

    # Percentage of non-gaps and totally conserved columns
    non_gaps = PercentageOfNonGaps()
    totally_conserved_columns = PercentageOfTotallyConservedColumns()

    percentage = non_gaps.compute(align_sequences)
    conserved = totally_conserved_columns.compute(align_sequences)
    print("Percentage of non-gaps: {0} %".format(percentage))
    print("Percentage of totally conserved columns: {0}".format(conserved))

    # Entropy
    value = Entropy().compute(align_sequences=align_sequences)
    print("Entropy score: {0}".format(value))

    # Sum of pairs
    value = SumOfPairs(Blosum62()).compute(align_sequences=align_sequences)
    print("SumOfPairs score (Blosum62): {0}".format(value))

    value = SumOfPairs(PAM250()).compute(align_sequences=align_sequences)
    print("SumOfPairs score (PAM250): {0}".format(value))

    value = SumOfPairs(FileMatrix('PAM380.txt')).compute(align_sequences=align_sequences)
    print("SumOfPairs score (PAM380): {0}".format(value))

    # Star
    value = Star(Blosum62()).compute(align_sequences=align_sequences)
    print("Star score (Blosum62): {0}".format(value))

    value = Star(PAM250()).compute(align_sequences=align_sequences)
    print("Star score (PAM250): {0}".format(value))

    # STRIKE
    value = Strike().compute(align_sequences=align_sequences,
                             sequences_id=sequences_id,
                             chains=['A', 'E', 'A', 'A'])
    print("STRIKE score: {0}".format(value))
    def test_should_get_distance_return_the_gap_penalty_if_a_char_is_a_gap(self):
        matrix = Blosum62()

        self.assertEqual(matrix.gap_penalty, matrix.get_distance('A', '-'))
        self.assertEqual(matrix.gap_penalty, matrix.get_distance('-', 'B'))
    def test_should_constructor__modify_the_gap_penalty(self):
        matrix = Blosum62(-10)

        self.assertEqual(-10, matrix.gap_penalty)
    def test_should_default_gap_penalty_be_minus_eight(self):
        matrix = Blosum62()

        self.assertEqual(-8, matrix.gap_penalty)
    def test_should_get_distance_throw_an_exception_if_a_char_is_invalid(self):
        matrix = Blosum62()

        with self.assertRaises(Exception):
            matrix.get_distance('J', 'A')
    def test_should_get_distance_return_one_if_the_two_chars_are_gaps(self):
        matrix = Blosum62()

        self.assertEqual(1, matrix.get_distance('-', '-'))
Beispiel #11
0
 def setUp(self):
     self.sumofpairs_PAM250 = SumOfPairs(PAM250())
     self.sumofpairs_Blosum62 = SumOfPairs(Blosum62())
Beispiel #12
0
 def setUp(self):
     self.star_PAM250 = Star(PAM250())
     self.star_Blosum62 = Star(Blosum62())