Пример #1
0
 def setUp(self):
     self.empty = ProteinSequence('')
     self.p1 = ProteinSequence('GREG')
     self.p2 = ProteinSequence('PRTEINSEQNCE',
                               id="test-seq-2",
                               description="A test sequence")
     self.p3 = ProteinSequence('PROTEIN',
                               id="bad-seq-1",
                               description="Not a protein sequence")
Пример #2
0
 def test_iupac_characters(self):
     exp = {
         'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'K', 'L', 'M', 'N',
         'P', 'Q', 'R', 'S', 'T', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b',
         'c', 'd', 'e', 'f', 'g', 'h', 'i', 'k', 'l', 'm', 'n', 'p', 'q',
         'r', 's', 't', 'v', 'w', 'x', 'y', 'z'
     }
     self.assertEqual(self.p1.iupac_characters(), exp)
     self.assertEqual(ProteinSequence.iupac_characters(), exp)
Пример #3
0
 def setUp(self):
     self.empty = ProteinSequence('')
     self.p1 = ProteinSequence('GREG')
     self.p2 = ProteinSequence(
         'PRTEINSEQNCE', id="test-seq-2",
         description="A test sequence")
     self.p3 = ProteinSequence(
         'PROTEIN', id="bad-seq-1",
         description="Not a protein sequence")
Пример #4
0
 def test_iupac_characters(self):
     exp = {
         'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'K', 'L', 'M', 'N',
         'P', 'Q', 'R', 'S', 'T', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c',
         'd', 'e', 'f', 'g', 'h', 'i', 'k', 'l', 'm', 'n', 'p', 'q', 'r',
         's', 't', 'v', 'w', 'x', 'y', 'z'
     }
     self.assertEqual(self.p1.iupac_characters(), exp)
     self.assertEqual(ProteinSequence.iupac_characters(), exp)
Пример #5
0
 def test_iupac_degeneracies(self):
     exp = {
         'B': set(['D', 'N']), 'Z': set(['E', 'Q']),
         'X': set(['A', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'K', 'L', 'M',
                   'N', 'P', 'Q', 'R', 'S', 'T', 'V', 'W', 'Y']),
         'b': set(['d', 'n']), 'z': set(['e', 'q']),
         'x': set(['a', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'k', 'l', 'm',
                   'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'y']),
     }
     self.assertEqual(self.p1.iupac_degeneracies(), exp)
     self.assertEqual(ProteinSequence.iupac_degeneracies(), exp)
Пример #6
0
    def test_alignment_to_fastq_kwargs_passed(self):
        for components, kwargs_expected_fp in self.valid_files:
            for kwargs, expected_fp in kwargs_expected_fp:
                obj = Alignment([
                    ProteinSequence(c[2],
                                    id=c[0],
                                    description=c[1],
                                    quality=c[3]) for c in components
                ])

                fh = StringIO()
                _alignment_to_fastq(obj, fh, **kwargs)
                observed = fh.getvalue()
                fh.close()

                with open(expected_fp, 'U') as f:
                    expected = f.read()

                self.assertEqual(observed, expected)
Пример #7
0
 def test_iupac_degeneracies(self):
     exp = {
         'B':
         set(['D', 'N']),
         'Z':
         set(['E', 'Q']),
         'X':
         set([
             'A', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'K', 'L', 'M', 'N',
             'P', 'Q', 'R', 'S', 'T', 'V', 'W', 'Y'
         ]),
         'b':
         set(['d', 'n']),
         'z':
         set(['e', 'q']),
         'x':
         set([
             'a', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'k', 'l', 'm', 'n',
             'p', 'q', 'r', 's', 't', 'v', 'w', 'y'
         ]),
     }
     self.assertEqual(self.p1.iupac_degeneracies(), exp)
     self.assertEqual(ProteinSequence.iupac_degeneracies(), exp)
Пример #8
0
 def test_iupac_degenerate_characters(self):
     exp = set(['B', 'X', 'Z', 'b', 'x', 'z'])
     self.assertEqual(self.p1.iupac_degenerate_characters(), exp)
     self.assertEqual(ProteinSequence.iupac_degenerate_characters(), exp)
Пример #9
0
 def test_iupac_standard_characters(self):
     exp = set("ACDEFGHIKLMNPQRSTVWYacdefghiklmnpqrstvwy")
     self.assertEqual(self.p1.iupac_standard_characters(), exp)
     self.assertEqual(ProteinSequence.iupac_standard_characters(), exp)
Пример #10
0
class ProteinSequenceTests(TestCase):

    def setUp(self):
        self.empty = ProteinSequence('')
        self.p1 = ProteinSequence('GREG')
        self.p2 = ProteinSequence(
            'PRTEINSEQNCE', id="test-seq-2",
            description="A test sequence")
        self.p3 = ProteinSequence(
            'PROTEIN', id="bad-seq-1",
            description="Not a protein sequence")

    def test_alphabet(self):
        exp = {
            'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'K', 'L', 'M', 'N',
            'P', 'Q', 'R', 'S', 'T', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c',
            'd', 'e', 'f', 'g', 'h', 'i', 'k', 'l', 'm', 'n', 'p', 'q', 'r',
            's', 't', 'v', 'w', 'x', 'y', 'z'
        }

        self.assertEqual(self.p1.alphabet(), exp)
        self.assertEqual(ProteinSequence.alphabet(), exp)

    def test_gap_alphabet(self):
        self.assertEqual(self.p1.gap_alphabet(), set('-.'))

    def test_iupac_standard_characters(self):
        exp = set("ACDEFGHIKLMNPQRSTVWYacdefghiklmnpqrstvwy")
        self.assertEqual(self.p1.iupac_standard_characters(), exp)
        self.assertEqual(ProteinSequence.iupac_standard_characters(), exp)

    def test_iupac_degeneracies(self):
        exp = {
            'B': set(['D', 'N']), 'Z': set(['E', 'Q']),
            'X': set(['A', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'K', 'L', 'M',
                      'N', 'P', 'Q', 'R', 'S', 'T', 'V', 'W', 'Y']),
            'b': set(['d', 'n']), 'z': set(['e', 'q']),
            'x': set(['a', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'k', 'l', 'm',
                      'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'y']),
        }
        self.assertEqual(self.p1.iupac_degeneracies(), exp)
        self.assertEqual(ProteinSequence.iupac_degeneracies(), exp)

    def test_iupac_degenerate_characters(self):
        exp = set(['B', 'X', 'Z', 'b', 'x', 'z'])
        self.assertEqual(self.p1.iupac_degenerate_characters(), exp)
        self.assertEqual(ProteinSequence.iupac_degenerate_characters(), exp)

    def test_iupac_characters(self):
        exp = {
            'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'K', 'L', 'M', 'N',
            'P', 'Q', 'R', 'S', 'T', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b',
            'c', 'd', 'e', 'f', 'g', 'h', 'i', 'k', 'l', 'm', 'n', 'p', 'q',
            'r', 's', 't', 'v', 'w', 'x', 'y', 'z'
        }
        self.assertEqual(self.p1.iupac_characters(), exp)
        self.assertEqual(ProteinSequence.iupac_characters(), exp)

    def test_nondegenerates(self):
        exp = [ProteinSequence('AD'), ProteinSequence('AN')]
        # Sort based on sequence string, as order is not guaranteed.
        obs = sorted(ProteinSequence('AB').nondegenerates(), key=str)
        self.assertEqual(obs, exp)
Пример #11
0
 def test_iupac_standard_characters(self):
     exp = set("ACDEFGHIKLMNPQRSTVWYacdefghiklmnpqrstvwy")
     self.assertEqual(self.p1.iupac_standard_characters(), exp)
     self.assertEqual(ProteinSequence.iupac_standard_characters(), exp)
Пример #12
0
class ProteinSequenceTests(TestCase):
    def setUp(self):
        self.empty = ProteinSequence('')
        self.p1 = ProteinSequence('GREG')
        self.p2 = ProteinSequence('PRTEINSEQNCE',
                                  id="test-seq-2",
                                  description="A test sequence")
        self.p3 = ProteinSequence('PROTEIN',
                                  id="bad-seq-1",
                                  description="Not a protein sequence")

    def test_alphabet(self):
        exp = {
            'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'K', 'L', 'M', 'N',
            'P', 'Q', 'R', 'S', 'T', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c',
            'd', 'e', 'f', 'g', 'h', 'i', 'k', 'l', 'm', 'n', 'p', 'q', 'r',
            's', 't', 'v', 'w', 'x', 'y', 'z'
        }

        self.assertEqual(self.p1.alphabet(), exp)
        self.assertEqual(ProteinSequence.alphabet(), exp)

    def test_gap_alphabet(self):
        self.assertEqual(self.p1.gap_alphabet(), set('-.'))

    def test_iupac_standard_characters(self):
        exp = set("ACDEFGHIKLMNPQRSTVWYacdefghiklmnpqrstvwy")
        self.assertEqual(self.p1.iupac_standard_characters(), exp)
        self.assertEqual(ProteinSequence.iupac_standard_characters(), exp)

    def test_iupac_degeneracies(self):
        exp = {
            'B':
            set(['D', 'N']),
            'Z':
            set(['E', 'Q']),
            'X':
            set([
                'A', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'K', 'L', 'M', 'N',
                'P', 'Q', 'R', 'S', 'T', 'V', 'W', 'Y'
            ]),
            'b':
            set(['d', 'n']),
            'z':
            set(['e', 'q']),
            'x':
            set([
                'a', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'k', 'l', 'm', 'n',
                'p', 'q', 'r', 's', 't', 'v', 'w', 'y'
            ]),
        }
        self.assertEqual(self.p1.iupac_degeneracies(), exp)
        self.assertEqual(ProteinSequence.iupac_degeneracies(), exp)

    def test_iupac_degenerate_characters(self):
        exp = set(['B', 'X', 'Z', 'b', 'x', 'z'])
        self.assertEqual(self.p1.iupac_degenerate_characters(), exp)
        self.assertEqual(ProteinSequence.iupac_degenerate_characters(), exp)

    def test_iupac_characters(self):
        exp = {
            'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'K', 'L', 'M', 'N',
            'P', 'Q', 'R', 'S', 'T', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c',
            'd', 'e', 'f', 'g', 'h', 'i', 'k', 'l', 'm', 'n', 'p', 'q', 'r',
            's', 't', 'v', 'w', 'x', 'y', 'z'
        }
        self.assertEqual(self.p1.iupac_characters(), exp)
        self.assertEqual(ProteinSequence.iupac_characters(), exp)

    def test_nondegenerates(self):
        exp = [ProteinSequence('AD'), ProteinSequence('AN')]
        # Sort based on sequence string, as order is not guaranteed.
        obs = sorted(ProteinSequence('AB').nondegenerates(), key=str)
        self.assertEqual(obs, exp)
Пример #13
0
 def test_nondegenerates(self):
     exp = [ProteinSequence('AD'), ProteinSequence('AN')]
     # Sort based on sequence string, as order is not guaranteed.
     obs = sorted(ProteinSequence('AB').nondegenerates(), key=str)
     self.assertEqual(obs, exp)
Пример #14
0
 def test_iupac_degenerate_characters(self):
     exp = set(['B', 'X', 'Z', 'b', 'x', 'z'])
     self.assertEqual(self.p1.iupac_degenerate_characters(), exp)
     self.assertEqual(ProteinSequence.iupac_degenerate_characters(), exp)