From 788ddbd8e113cd4f9694aee779c5b5dcca26e30b Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Sat, 25 Apr 2020 11:38:29 -0700 Subject: feat: updated fasta code to allow for iteration --- sys/libbio/test.c | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) (limited to 'sys/libbio/test.c') diff --git a/sys/libbio/test.c b/sys/libbio/test.c index 115ee46..14f2b06 100644 --- a/sys/libbio/test.c +++ b/sys/libbio/test.c @@ -5,9 +5,8 @@ // ----------------------------------------------------------------------- // Point of entry for testing - -int -main() +error +test·newick() { error err; bio·Tree t; @@ -36,3 +35,40 @@ main() 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"); + } +} + -- cgit v1.2.1