diff --git a/src/java/tdg09/Analyse.java b/src/java/tdg09/Analyse.java index 62ac890..2039347 100644 --- a/src/java/tdg09/Analyse.java +++ b/src/java/tdg09/Analyse.java @@ -269,7 +269,15 @@ private void validate(Tree tree, Alignment alignment) { System.out.printf("Alignment:\n SequenceCount: %s\n SiteCount: %s\n\n", alignment.getSequenceCount(), alignment.getSiteCount()); } - // 2. Check that all taxa have an assigned group and all groups are used + // 2. Check that group names have the right length + for (String group : options.groups) { + if (group.length() > 2) { + System.out.println("ERROR: Group names must be at most two characters long."); + System.exit(1); + } + } + + // 3. Check that all taxa have an assigned group and all groups are used List taxa = Lists.newArrayList(); Set usedGroups = Sets.newHashSet(); diff --git a/src/java/tdg09/trees/TreeNodeLabeller.java b/src/java/tdg09/trees/TreeNodeLabeller.java index 1b3e633..7e4f2ae 100644 --- a/src/java/tdg09/trees/TreeNodeLabeller.java +++ b/src/java/tdg09/trees/TreeNodeLabeller.java @@ -12,6 +12,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.Collections; /** * Takes a tree where taxa have been prefixed by a two-letter partition/group identifier and traverses the tree to @@ -90,6 +91,10 @@ public SimpleTree label(Tree t) { } // now the only remaining unknown nodes are those that neighbour two different clades (and the root node) + + // Iterate over unknownNodes in reverse to make sure the parent nodes are labelled before child nodes + Collections.reverse(unknownNodes); + for (Node n : unknownNodes) { // the name of this hostshift node = parent node name (remember, could be the root node = leave unlabelled) if (n.getParent() != null) {