<commit_before>from unittest import TestCase

import pyproteome as pyp


class MotifTest(TestCase):
    def setUp(self):
        self.motif = pyp.Motif("O..x.-+")

    def test_match(self):
        self.assertIn("IEFtFER", self.motif)
        self.assertIn("LEFsFER", self.motif)
        self.assertIn("VEFtFER", self.motif)
        self.assertIn("MEFsFER", self.motif)

        self.assertIn("IEFsFER", self.motif)
        self.assertIn("IEFtFER", self.motif)

        self.assertIn("IEFsFER", self.motif)
        self.assertIn("IEFsFEK", self.motif)

    def test_no_match(self):
        self.assertNotIn("QEFtFER", self.motif)
        self.assertNotIn("HEFsFER", self.motif)
        self.assertNotIn("EEFtFER", self.motif)
        self.assertNotIn("DEFsFER", self.motif)

        self.assertNotIn("IEFYFER", self.motif)
        self.assertNotIn("IEFSFER", self.motif)
        self.assertNotIn("IEFTFER", self.motif)

        self.assertNotIn("IEFsFED", self.motif)
        self.assertNotIn("IEFsFEE", self.motif)


class GenerateNMersTest(TestCase):
    def setUp(self):
        self.sequence = pyp.Sequence(
            pep_seq="GEPNVsyICSR",
            protein_matches=[
                pyp.ProteinMatch(
                    protein=pyp.Protein(
                        accession="Q9WV60",
                    ),
                    rel_pos=209,
                    exact=True,
                ),
            ],
        )
        self.sequence.modifications = pyp.Modifications(<commit_msg>Added a test for testing if motifs match one another<commit_after>from unittest import TestCase

import pyproteome as pyp


class MotifTest(TestCase):
    def setUp(self):
        self.motif = pyp.Motif("O..x.-+")

    def test_match(self):
        self.assertIn("IEFtFER", self.motif)
        self.assertIn("LEFsFER", self.motif)
        self.assertIn("VEFtFER", self.motif)
        self.assertIn("MEFsFER", self.motif)

        self.assertIn("IEFsFER", self.motif)
        self.assertIn("IEFtFER", self.motif)

        self.assertIn("IEFsFER", self.motif)
        self.assertIn("IEFsFEK", self.motif)

    def test_no_match(self):
        self.assertNotIn("QEFtFER", self.motif)
        self.assertNotIn("HEFsFER", self.motif)
        self.assertNotIn("EEFtFER", self.motif)
        self.assertNotIn("DEFsFER", self.motif)

        self.assertNotIn("IEFYFER", self.motif)
        self.assertNotIn("IEFSFER", self.motif)
        self.assertNotIn("IEFTFER", self.motif)

        self.assertNotIn("IEFsFED", self.motif)
        self.assertNotIn("IEFsFEE", self.motif)

    def test_match_motif(self):
        # Motifs will match themselves and any more specific motifs, though
        # they will not match less specific motifs
        self.assertTrue(self.motif.match("O..x.-+"))
        self.assertTrue(self.motif.match("O..x.E+"))
        self.assertTrue(self.motif.match("O..s.-+"))
        self.assertTrue(self.motif.match("O..t.-+"))
        self.assertTrue(self.motif.match("M..x.-+"))
        self.assertTrue(self.motif.match("O..x.-K"))

        self.assertFalse(self.motif.match("...x.-+"))
        self.assertFalse(self.motif.match("O....-+"))
        self.assertFalse(self.motif.match("O..x..+"))
        self.assertFalse(self.motif.match("O..x.-."))


class GenerateNMersTest(TestCase):
    def setUp(self):
        self.sequence = pyp.Sequence(
            pep_seq="GEPNVsyICSR",
            protein_matches=[
                pyp.ProteinMatch(
                    protein=pyp.Protein(
                        accession="Q9WV60",
                    ),
                    rel_pos=209,
                    exact=True,
                ),
            ],
        )
        self.sequence.modifications = pyp.Modifications(
{'fraction_non_alphanumeric': 0.13955984970477725, 'fraction_numerical': 0.00322061191626409, 'mean_word_length': 2.1345668629100083, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6863122', 'n_tokens_mistral': 1277, 'n_tokens_neox': 1214, 'n_words': 171}