Tree io modifications, including support for polytomous trees by the
[jalview.git] / src / jalview / datamodel / SequenceNode.java
index 6e35ee3..905bd15 100755 (executable)
@@ -9,13 +9,46 @@ public class SequenceNode extends BinaryNode {
   public float height;\r
   public float ycount;\r
   public Color color = Color.black;\r
-\r
+  public boolean dummy = false;\r
   public SequenceNode() {\r
     super();\r
   }\r
-  \r
+\r
   public SequenceNode(Object val, SequenceNode parent, float dist,String name) {\r
     super(val,parent,name);\r
     this.dist = dist;\r
   }\r
+  public SequenceNode(Object val, SequenceNode parent, String name, float dist, int bootstrap, boolean dummy) {\r
+    super(val,parent,name);\r
+    this.dist = dist;\r
+    this.bootstrap = bootstrap;\r
+    this.dummy = dummy;\r
+  }\r
+\r
+\r
+  /**\r
+   * @param dummy true if node is created for the representation of polytomous trees\r
+   */\r
+\r
+  public boolean isDummy() {\r
+    return dummy;\r
+  }\r
+  public boolean setDummy(boolean newstate) {\r
+    boolean oldstate = dummy;\r
+    dummy = newstate;\r
+    return oldstate;\r
+  }\r
+\r
+  /**\r
+   * ascends the tree but doesn't stop until a non-dummy node is discovered.\r
+   * This will probably break if the tree is a mixture of BinaryNodes and SequenceNodes.\r
+   */\r
+\r
+  public SequenceNode AscendTree() {\r
+    SequenceNode c = this;\r
+    do {\r
+      c = (SequenceNode) c.parent();\r
+    } while (c!=null && c.dummy);\r
+    return c;\r
+  }\r
 }\r