Phylogeny inference lab 2

This is practice building parts that you will need for the assignment.

Binary Tree classes

Make Java classes suitable for phylogenetic trees. In these trees, the leaves represent observed taxonomic units (OTUs). There will always be at least one leaf. Let's say there are n leaves. The internal nodes represent hypothetical taxonomic units (HTUs). There will always be exactly n-1 of them. Each internal node has exactly two children, although the order of the children does not matter.

You will need:

  1. An abstract TU_Tree class. You will find that each node except the very top one will need a parent. If n=1 the top node will be an OTU, otherwise it will be an HTU. If a node has a parent, the parent will be an HTU.
  2. An HTU_Node class, having two children, each of which might be either an OTU_Node or an HTU_Node.
  3. An OTU_Node class, which needs something to record exactly which of many observed taxonomic units it represents. That might as well be some kind of integer.

You will need some way to print a tree. The first handout has a section on Newick format. This might as well be the definition of the usual Java toString() method.

You will want to be able to create trees, maintaining the invariant that if p has a left or right child c then p is c's parent.

The full thing

We need more than just a tree. We need to be able to choose a node of a tree at random. So we want something that contains both a TU_Tree and an array (or perhaps an ArrayList) of references to the nodes of the tree. So

  1. A Phylogeny class, having a TU_Tree member and an array or ArrayList member.

The operations we want on these objects are