forked from cjb/libnewicktree
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME
62 lines (45 loc) · 1.95 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
What's this?
============
It's a Newick tree parser:
http://en.wikipedia.org/wiki/Newick_format
This code is *entirely* taken from the TreeJuxtaposer project at:
http://olduvai.sourceforge.net/tj/index.shtml
I refactored the code to separate UI drawing from parsing and Tree
creation, so this code is purely for Newick parsing and tree generation.
How can I use it?
================
You could do something like this:
Tree treeoflife;
int current_depth = 0;
void setup() {
BufferedReader r = createReader("treeoflife.tree");
TreeParser tp = new TreeParser(r);
treeoflife = tp.tokenize(1, "treeoflife", null);
int tree_height = treeoflife.getHeight();
System.out.println("largest tree height is: " + tree_height);
recursive_print(0, 0);
}
void recursive_print (int currkey, int currdepth) {
TreeNode currNode = treeoflife.getNodeByKey(currkey);
int numChildren = currNode.numberChildren();
for (int i = 0; i < numChildren; i++) {
int childkey = currNode.getChild(i).key;
TreeNode childnode = treeoflife.getNodeByKey(childkey);
System.out.println("child name is: " + childnode.getName()
+ " depth is: " + currdepth);
recursive_print(childkey, currdepth+1);
}
}
Who uses it?
============
The need for a standalone parser came from the tree explorer at:
http://exploretree.org/
What license is it available under?
===================================
The TreeJuxtaposer code is under the BSD license, so this code is too.
Who should I contact with a bug report?
=======================================
Since I stripped out anything that wasn't necessary for exploretree, you
could first see if what you need is present in the main TreeJuxtaposer
source. If the bug is only in this library, please contact me at
chris-libnewick@printf.net instead of bugging the TreeJuxtaposer folks.