def _do_test(self, content, expected): e = [ deepcopy(i) for i in NewickEventFactory(tokenizer=NewickTokenizer( stream=StringIO(content))) ] # print(e) self.assertEqual(e, expected)
def parse_newick(newick=None, stream=None, filepath=None, _class=TreeWithPathsInEdges): from peyotl.utility.tokenizer import NewickEventFactory, NewickTokenizer nt = NewickTokenizer(stream=stream, newick=newick, filepath=filepath) nef = NewickEventFactory(tokenizer=nt) return _class(newick_events=nef)
def testOddQuotes(self): content = "((h_ ,'p)h p,g()[],:_)hpg;" tok = NewickTokenizer(StringIO(content)) content = "((h_ ,'p')h p,'g()[]',:_')hpg;" tok = NewickTokenizer(StringIO(content)) self.assertRaises(Exception, tok.tokens)
def _do_test(self, content, expected): self.assertEqual([i for i in NewickTokenizer(StringIO(content))], expected)