Example #1
0
    def test_invalid_lengths(self):
        fh = StringIO("CLUSTAL\n"
                      "\n\n"
                      "abc             GCAU\n"
                      "def             -----\n")

        with self.assertRaisesRegex(ClustalFormatError, r"not aligned"):
            _clustal_to_tabular_msa(fh, constructor=CustomSequence)
Example #2
0
    def test_invalid_lengths(self):
        fh = StringIO(
            "CLUSTAL\n"
            "\n\n"
            "abc             GCAU\n"
            "def             -----\n")

        with self.assertRaisesRegex(ClustalFormatError, "not aligned"):
            _clustal_to_tabular_msa(fh, constructor=CustomSequence)
Example #3
0
 def test_valid_tabular_msa_to_clustal_and_clustal_to_tabular_msa(self):
     for valid_out in self.valid_clustal_out:
         result_before = _clustal_to_tabular_msa(valid_out,
                                                 constructor=CustomSequence)
         with StringIO() as fh:
             _tabular_msa_to_clustal(result_before, fh)
             fh.seek(0)
             result_after = _clustal_to_tabular_msa(
                 fh, constructor=CustomSequence)
         self.assertEqual(result_before, result_after)
Example #4
0
 def test_valid_tabular_msa_to_clustal_and_clustal_to_tabular_msa(self):
     for valid_out in self.valid_clustal_out:
         result_before = _clustal_to_tabular_msa(
                 valid_out, constructor=CustomSequence)
         with StringIO() as fh:
             _tabular_msa_to_clustal(result_before, fh)
             fh.seek(0)
             result_after = _clustal_to_tabular_msa(
                     fh, constructor=CustomSequence)
         self.assertEqual(result_before, result_after)
Example #5
0
 def test_no_constructor(self):
     with self.assertRaisesRegex(ValueError, r"`constructor`"):
         _clustal_to_tabular_msa(self.valid_clustal_out[0])
Example #6
0
 def test_invalid_tabular_msa_to_clustal_and_clustal_to_tabular_msa(self):
     for invalid_out in self.invalid_clustal_out:
         with self.assertRaises(ClustalFormatError):
             dict(
                 _clustal_to_tabular_msa(invalid_out,
                                         constructor=CustomSequence))
Example #7
0
    def test_tabular_msa_to_clustal_with_bad_input(self):
        BAD = StringIO('\n'.join(['dshfjsdfhdfsj', 'hfsdjksdfhjsdf']))

        with self.assertRaises(ClustalFormatError):
            dict(_clustal_to_tabular_msa(BAD, constructor=CustomSequence))
Example #8
0
 def test_tabular_msa_to_clustal_with_empty_input(self):
     result = _clustal_to_tabular_msa(StringIO(),
                                      constructor=CustomSequence)
     self.assertEqual(dict(result), {})
Example #9
0
 def test_no_constructor(self):
     with self.assertRaisesRegex(ValueError, "`constructor`"):
         _clustal_to_tabular_msa(self.valid_clustal_out[0])
Example #10
0
 def test_invalid_tabular_msa_to_clustal_and_clustal_to_tabular_msa(self):
     for invalid_out in self.invalid_clustal_out:
         with self.assertRaises(ClustalFormatError):
             dict(_clustal_to_tabular_msa(invalid_out,
                                          constructor=CustomSequence))
Example #11
0
    def test_tabular_msa_to_clustal_with_bad_input(self):
        BAD = StringIO('\n'.join(['dshfjsdfhdfsj', 'hfsdjksdfhjsdf']))

        with self.assertRaises(ClustalFormatError):
            dict(_clustal_to_tabular_msa(BAD, constructor=CustomSequence))
Example #12
0
 def test_tabular_msa_to_clustal_with_empty_input(self):
     result = _clustal_to_tabular_msa(StringIO(),
                                      constructor=CustomSequence)
     self.assertEqual(dict(result), {})