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)
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)
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)
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)
def test_no_constructor(self): with self.assertRaisesRegex(ValueError, r"`constructor`"): _clustal_to_tabular_msa(self.valid_clustal_out[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))
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))
def test_tabular_msa_to_clustal_with_empty_input(self): result = _clustal_to_tabular_msa(StringIO(), constructor=CustomSequence) self.assertEqual(dict(result), {})
def test_no_constructor(self): with self.assertRaisesRegex(ValueError, "`constructor`"): _clustal_to_tabular_msa(self.valid_clustal_out[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))