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)), [])
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"))
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"))
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"))
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)
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))