Example #1
0
 def test_only_labels(self):
     """MinimalRdbParser should return empty list from file w/o seqs"""
     # should fail if strict (the default)
     self.assertRaises(RecordError, list,
                       MinimalRdbParser(self.labels, strict=True))
     # if not strict, should skip the records
     self.assertEqual(list(MinimalRdbParser(self.labels, strict=False)), [])
Example #2
0
 def test_multiple_bad(self):
     """MinimalRdbParser should complain or skip bad records"""
     self.assertRaises(RecordError, list, MinimalRdbParser(self.twogood))
     f = list(MinimalRdbParser(self.twogood, strict=False))
     self.assertEqual(len(f), 2)
     a, b = f
     self.assertEqual(a, (["seq:mit"], "ACU"))
     self.assertEqual(b, (["seq:pla"], "AAA"))
Example #3
0
    def test_single(self):
        """MinimalRdbParser should read single record as (header,seq) tuple"""
        res = list(MinimalRdbParser(self.oneseq))
        self.assertEqual(len(res), 1)
        first = res[0]
        self.assertEqual(first, (["seq:H.Sapiens"], "AGUCAUCUAGAUHCAUHC"))

        res = list(MinimalRdbParser(self.multiline))
        self.assertEqual(len(res), 1)
        first = res[0]
        self.assertEqual(first, (["seq:H.Sapiens"], "AGUCAUUAGAUHCAUHC"))
Example #4
0
 def test_multiple(self):
     """MinimalRdbParser should read multiple record correctly"""
     res = list(MinimalRdbParser(self.threeseq))
     self.assertEqual(len(res), 3)
     a, b, c = res
     self.assertEqual(a, (["seq:bac"], "AGU"))
     self.assertEqual(b, (["seq:mit"], "ACU"))
     self.assertEqual(c, (["seq:pla"], "AAA"))
Example #5
0
 def test_strange(self):
     """MRP: handle strange char. according to constr. and strip off '*'"""
     f = list(MinimalRdbParser(self.strange))
     obs = f[0]
     exp = (["seq:bac"], "ACGUXxAaKkoo---")
     self.assertEqual(obs, exp)
Example #6
0
 def test_empty(self):
     """MinimalRdbParser should return empty list from file w/o seqs"""
     self.assertEqual(list(MinimalRdbParser(self.empty)), [])
     self.assertEqual(list(MinimalRdbParser(self.nolabels, strict=False)),
                      [])
     self.assertRaises(RecordError, list, MinimalRdbParser(self.nolabels))