#include #include #include // ----------------------------------------------------------------------- // Point of entry for testing error test·newick() { error err; bio·Tree t; mem·Arena *mem; Stream *fd[2]; io·Peeker rdr; io·Putter wtr; mem·Allocator al; mem = mem·newarena(mem·sys, nil); rdr = (io·Peeker){.get = &io·getbyte, .unget = &io·ungetbyte}; wtr = (io·Putter){.put = &io·putbyte, .putstr = &io·putstring}; al = (mem·Allocator) { .alloc = &mem·arenaalloc, .free = nil, }; fd[0] = io·open("/home/nolln/root/data/test/example.nwk", "r"); fd[1] = io·open("/home/nolln/root/data/test/example.proc.nwk", "w"); t = bio·readnewick(rdr, fd[0], al, mem); err = bio·writenewick(t, wtr, fd[1]); io·flush(fd[1]); io·close(fd[0]); io·close(fd[1]); return 0; } error test·fasta() { error err; Stream *fd; bio·Seq seq; bio·FastaReader *rdr; fd = io·open("/home/nolln/root/data/test/zika.fa", "r"); rdr = bio·newfastareader((io·Reader){.read = &io·read}, fd, mem·sys, nil); err = 0; while (!err) { err = bio·readfasta(rdr, &seq); if (!err) { printf(">%s\n", seq.name); } } io·close(fd); return err <= 0 ? 0 : 1; } error main() { error err; if (err = test·newick(), err) { errorf("test fail: newick"); } if (err = test·fasta(), err) { errorf("test fail: fasta"); } }