Пример #1
0
    def test_compute_of_two_gapped_seqs(self):
        # setup
        sequences = MSA(["-----", "-----"])

        # results
        expected = 0
        result = Entropy(sequences).compute()

        # check
        self.assertEqual(expected, result)
Пример #2
0
    def test_should_print_class_name(self):
        # setup
        sumofpairs = SumOfPairs().get_name()
        star = Star().get_name()
        entropy = Entropy().get_name()

        # check
        self.assertEqual("SumOfPairs", sumofpairs)
        self.assertEqual("Star", star)
        self.assertEqual("Entropy", entropy)
Пример #3
0
    def test_compute_of_four_seqs_with_no_gaps(self):
        # setup
        sequences = MSA(["ACGT", "ACGT", "TGCA", "TGCA"])

        # results
        expected = -2.77
        result = round(Entropy(sequences).compute(), 2)

        # check
        self.assertEqual(expected, result)
Пример #4
0
    def test_compute_of_three_seqs_with_gaps(self):
        # setup
        sequences = MSA(["A-TGCAAT-G", "-CT-CCAT-A", "-TTAT-CTG-"])

        # results
        expected = -6.94
        result = round(Entropy(sequences).compute(), 2)

        # check
        self.assertEqual(expected, result)
Пример #5
0
    def test_get_entropy_of_a_column_with_gaps(self):
        # setup
        d = {"-": 0.8, "A": 0.2}

        # results
        result = round(Entropy.get_entropy(d), 1)
        expected = -0.5

        # check
        self.assertEqual(expected, result)
Пример #6
0
    def test_get_dictionary_of_a_gapped_column(self):
        # setup
        column = ["-", "-", "-", "-", "-"]

        # results
        expected = {"-": 1}
        result = Entropy.get_words_frequencies(column)

        # check
        self.assertEqual(expected, result)
Пример #7
0
    def test_get_entropy_of_a_gapped_column(self):
        # setup
        d = {"-": 1}

        # results
        expected = 0
        result = Entropy.get_entropy(d)

        # check
        self.assertEqual(expected, result)
Пример #8
0
    def test_get_dictionary_of_a_gapped_column(self):
        # setup
        column = ["-", "-", "-", "-", "-"]

        # results
        expected = {"-": 1}
        result = Entropy.get_words_frequencies(column)

        # check
        self.assertEqual(expected, result)
Пример #9
0
    def test_get_entropy_of_a_gapped_column(self):
        # setup
        d = {"-": 1}

        # results
        expected = 0
        result = Entropy.get_entropy(d)

        # check
        self.assertEqual(expected, result)
Пример #10
0
    def test_get_entropy_of_a_column_with_gaps(self):
        # setup
        d = {"-": 0.8, "A": 0.2}

        # results
        result = round(Entropy.get_entropy(d), 1)
        expected = -0.5

        # check
        self.assertEqual(expected, result)
Пример #11
0
    def test_get_dictionary_of_a_five_letter_column(self):
        # setup
        column = ["-", "A", "C", "G", "T"]
        tot_seqs = len(column)

        # results
        expected = {"-": 1 / tot_seqs, "A": 1 / tot_seqs, "C": 1 / tot_seqs, "G": 1 / tot_seqs, "T": 1 / tot_seqs}
        result = Entropy.get_words_frequencies(column)

        # check
        self.assertEqual(expected, result)
Пример #12
0
    def test_get_dictionary_of_a_five_letter_column(self):
        # setup
        column = ["-", "A", "C", "G", "T"]
        tot_seqs = len(column)

        # results
        expected = {
            "-": 1 / tot_seqs,
            "A": 1 / tot_seqs,
            "C": 1 / tot_seqs,
            "G": 1 / tot_seqs,
            "T": 1 / tot_seqs
        }
        result = Entropy.get_words_frequencies(column)

        # check
        self.assertEqual(expected, result)
Пример #13
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))
Пример #14
0
 def setUp(self):
     self.ent = Entropy()
Пример #15
0
class EntropyTestCases(unittest.TestCase):
    def setUp(self):
        self.ent = Entropy()

    def test_get_entropy_of_a_column_with_gaps(self):
        # setup
        d = {"-": 0.8, "A": 0.2}

        # results
        result = round(self.ent.get_column_entropy(d), 1)
        expected = -0.5

        # check
        self.assertEqual(expected, result)

    def test_get_entropy_of_a_gapped_column(self):
        # setup
        d = {"-": 1}

        # results
        expected = 0
        result = self.ent.get_column_entropy(d)

        # check
        self.assertEqual(expected, result)

    def test_get_dictionary_of_a_five_letter_column(self):
        # setup
        column = ["-", "A", "C", "G", "T"]
        tot_seqs = len(column)

        # results
        expected = {
            "-": 1 / tot_seqs,
            "A": 1 / tot_seqs,
            "C": 1 / tot_seqs,
            "G": 1 / tot_seqs,
            "T": 1 / tot_seqs
        }
        result = self.ent.get_words_frequencies(column)

        # check
        self.assertEqual(expected, result)

    def test_get_dictionary_of_a_gapped_column(self):
        # setup
        column = ["-", "-", "-", "-", "-"]

        # results
        expected = {"-": 1}
        result = self.ent.get_words_frequencies(column)

        # check
        self.assertEqual(expected, result)

    def test_compute_of_four_seqs_with_no_gaps(self):
        # setup
        sequences = ["ACGT", "ACGT", "TGCA", "TGCA"]

        # results
        expected = -2.77
        result = round(self.ent.compute(sequences), 2)

        # check
        self.assertEqual(expected, result)

    def test_compute_of_three_seqs_with_gaps(self):
        # setup
        sequences = ["A-TGCAAT-G", "-CT-CCAT-A", "-TTAT-CTG-"]

        # results
        expected = -6.94
        result = round(self.ent.compute(sequences), 2)

        # check
        self.assertEqual(expected, result)

    def test_compute_of_two_gapped_seqs(self):
        # setup
        sequences = ["-----", "-----"]

        # results
        expected = 0
        result = self.ent.compute(sequences)

        # check
        self.assertEqual(expected, result)