aboutsummaryrefslogtreecommitdiff
path: root/sys/libbio/test.c
diff options
context:
space:
mode:
authorNicholas Noll <nbnoll@eml.cc>2020-05-03 20:20:22 -0700
committerNicholas Noll <nbnoll@eml.cc>2020-05-03 20:20:22 -0700
commit4b2ea2ca00eea7feea036b7642c0c1443b8f77a1 (patch)
tree5cdd635bd8240a6857258a056e3932e00966bfff /sys/libbio/test.c
parent6b739739968a0cc9b4d9909d8f4ffec30f4461dd (diff)
removed buggy qsort header and implemented myself
Diffstat (limited to 'sys/libbio/test.c')
-rw-r--r--sys/libbio/test.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/sys/libbio/test.c b/sys/libbio/test.c
index 8054864..da29c84 100644
--- a/sys/libbio/test.c
+++ b/sys/libbio/test.c
@@ -99,6 +99,8 @@ test·newick()
io·Peeker rdr;
io·Putter wtr;
+ bio·Node **end, **it, **list;
+
heap = mem·makearena(mem·sys, nil);
rdr = (io·Peeker){.get = &io·getbyte, .unget = &io·ungetbyte};
wtr = (io·Putter){.put = &io·putbyte, .putstr = &io·putstring};
@@ -109,8 +111,22 @@ test·newick()
t.h = heap;
t.heap = (mem·Allocator){ .alloc = &mem·arenaalloc, .free = nil, };
- err = bio·readnewick(rdr, fd[0], &t);
+ if (err = bio·readnewick(rdr, fd[0], &t), err) {
+ errorf("failed to read newick");
+ return 1;
+ }
+ printf("number of children: %d\n", t.root->nchild);
+
phylo·ladderize(t.root);
+
+ list = mem·arenaalloc(heap, t.nleaf, sizeof(**list));
+ phylo·getleafs(t, list);
+ for (it = list, end = list + t.nleaf; it != end; ++it) {
+ printf("Leaf '%s'\n", (*it)->name);
+ }
+
+ bio·Node *path[100];
+ // phylo·diameter(t, path);
printf("Loaded tree with %d leafs and %d nodes\n", t.nleaf, t.root->nnode);
err = bio·writenewick(t, wtr, fd[1]);