createColourFromName if not specified
[jalview.git] / src / jalview / analysis / NJTree.java
index 97b8519..40dfc9b 100755 (executable)
@@ -60,6 +60,10 @@ public class NJTree
     Object leaves = null;\r
     int start;\r
     int end;\r
+    boolean hasDistances = true; // normal case for jalview trees\r
+       boolean hasBootstrap = false; // normal case for jalview trees\r
+\r
+    private boolean hasRootDistance = true;\r
 \r
     /**\r
      * Creates a new NJTree object.\r
@@ -81,6 +85,11 @@ public class NJTree
     public NJTree(SequenceI[] seqs, NewickFile treefile)\r
     {\r
         top = treefile.getTree();\r
+\r
+        hasDistances = treefile.HasDistances();\r
+        hasBootstrap = treefile.HasBootstrap();\r
+        hasRootDistance = treefile.HasRootDistance();\r
+\r
         maxheight = findHeight(top);\r
 \r
         SequenceIdMatcher algnIds = new SequenceIdMatcher(seqs);\r
@@ -251,14 +260,14 @@ public class NJTree
     {\r
         while (noClus > 2)\r
         {\r
-           /* if (type.equals("NJ"))\r
+            if (type.equals("NJ"))\r
             {\r
-                float mind = findMinNJDistance();\r
+                findMinNJDistance();\r
             }\r
             else\r
             {\r
-                float mind = findMinDistance();\r
-            }*/\r
+                findMinDistance();\r
+            }\r
 \r
             Cluster c = joinClusters(mini, minj);\r
 \r
@@ -273,7 +282,7 @@ public class NJTree
         boolean onefound = false;\r
 \r
         int one = -1;\r
-        //int two = -1;\r
+        int two = -1;\r
 \r
         for (int i = 0; i < noseqs; i++)\r
         {\r
@@ -281,7 +290,7 @@ public class NJTree
             {\r
                 if (onefound == false)\r
                 {\r
-                    //two = i;\r
+                    two = i;\r
                     onefound = true;\r
                 }\r
                 else\r
@@ -291,7 +300,7 @@ public class NJTree
             }\r
         }\r
 \r
-       // Cluster c = joinClusters(one, two);\r
+        joinClusters(one, two);\r
         top = (SequenceNode) (node.elementAt(one));\r
 \r
         reCount(top);\r
@@ -375,11 +384,6 @@ public class NJTree
     public void findNewNJDistances(SequenceNode tmpi, SequenceNode tmpj,\r
         float dist)\r
     {\r
-        //float ih = 0;\r
-       // float jh = 0;\r
-\r
-        //SequenceNode sni = tmpi;\r
-        //SequenceNode snj = tmpj;\r
 \r
         tmpi.dist = ((dist + ri) - rj) / 2;\r
         tmpj.dist = (dist - tmpi.dist);\r
@@ -469,8 +473,6 @@ public class NJTree
      */\r
     public void findClusterNJDistance(int i, int j)\r
     {\r
-        //int noi = ((Cluster) cluster.elementAt(i)).value.length;\r
-        //int noj = ((Cluster) cluster.elementAt(j)).value.length;\r
 \r
         // New distances from cluster to others\r
         float[] newdist = new float[noseqs];\r
@@ -665,7 +667,7 @@ public class NJTree
                     AlignSeq as = new AlignSeq(sequence[i], sequence[j], "pep");\r
                     as.calcScoreMatrix();\r
                     as.traceAlignment();\r
-                    as.printAlignment();\r
+                    as.printAlignment(System.out);\r
                     distance[i][j] = (float) as.maxscore;\r
 \r
                     if (max < distance[i][j])\r
@@ -1141,6 +1143,27 @@ public class NJTree
     {\r
         return top;\r
     }\r
+    /**\r
+     *\r
+     * @return true if tree has real distances\r
+     */\r
+    public boolean isHasDistances() {\r
+      return hasDistances;\r
+    }\r
+\r
+    /**\r
+     *\r
+     * @return true if tree has real bootstrap values\r
+     */\r
+    public boolean isHasBootstrap() {\r
+      return hasBootstrap;\r
+    }\r
+\r
+  public boolean isHasRootDistance()\r
+  {\r
+    return hasRootDistance;\r
+  }\r
+\r
 }\r
 \r
 \r
@@ -1164,3 +1187,4 @@ class Cluster
         this.value = value;\r
     }\r
 }\r
+\r