def test_ignore_equal(self): p = AttributesParser('=', ignore=['chromosome', 'junk']) record = 'chromosome=1;ID=id0;junk=drawer' t = list(p.tokenize(record)) self.assertEqual(t, [ 'chromosome', '=', '1', ';', 'ID', '=', 'id0', ';', 'junk', '=', 'drawer' ]) attributes = p(record) self.assertEqual(attributes, 1) self.assertIn('ID', p.terms) self.assertEqual(p.terms['ID'][0], 'id0') self.assertNotIn('chromosome', p.terms) self.assertEqual(p.reserved['chromosome'], 0)
def test_gff_extra_semicolons(self): p = AttributesParser('=') t = list(p.tokenize(' a=1;; b="b"; ')) self.assertEqual(t, ['a', '=', '1', ';', 'b', '=', '"b"', ';'])
def test_gtf_extra_spaces(self): p = AttributesParser(' ') t = list(p.tokenize(' a 1; b "b"; ')) self.assertEqual(t, ['a', ' ', '1', ';', 'b', ' ', '"b"', ';'])
def test_embedded_sep(self): p = AttributesParser(' ') t = list(p.tokenize('a "b;c"; d 1')) self.assertEqual(t, ['a', ' ', '"b;c"', ';', 'd', ' ', '1'])
def test_quoting_missing(self): p = AttributesParser(' ') self.assertRaises(ValueError, list, p.tokenize('a "b'))
def test_gff_value_with_spaces(self): p = AttributesParser('=') t = list(p.tokenize('mol_type=genomic DNA')) self.assertEqual(t, ['mol_type', '=', 'genomic DNA'])