Ejemplo n.º 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")
Ejemplo n.º 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)
Ejemplo n.º 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")
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)