better reproduction of compact newick files (removal of unecessary spaces)
authorjprocter <Jim Procter>
Fri, 14 Sep 2007 15:25:15 +0000 (15:25 +0000)
committerjprocter <Jim Procter>
Fri, 14 Sep 2007 15:25:15 +0000 (15:25 +0000)
src/jalview/io/NewickFile.java

index 5775072..aa9a129 100755 (executable)
@@ -45,7 +45,7 @@ public class NewickFile
 
   // File IO Flags
   boolean ReplaceUnderscores = false;
-  boolean printRootInfo = false;
+  boolean printRootInfo = true;
   private com.stevesoft.pat.Regex[] NodeSafeName = new com.stevesoft.pat.Regex[]
       {
       new com.stevesoft.pat.Regex().perlCode("m/[\\[,:'()]/"), // test for requiring quotes
@@ -211,7 +211,7 @@ public class NewickFile
     String nodename = null;
 
     float DefDistance = (float) 0.001; // @param Default distance for a node - very very small
-    int DefBootstrap = 0; // @param Default bootstrap for a node
+    int DefBootstrap = -1; // @param Default bootstrap for a node
 
     float distance = DefDistance;
     int bootstrap = DefBootstrap;
@@ -385,7 +385,7 @@ public class NewickFile
             {
             if (nbootstrap.stringMatched(1).equals(uqnodename.stringMatched(1)))
               {
-                nodename=""; // no nodename here.
+                nodename=null; // no nodename here.
               }
             if (nodename==null || nodename.length()==0 || nbootstrap.matchedFrom(1) > (uqnodename.matchedFrom(1) + 
                       uqnodename.stringMatched().length()))
@@ -499,14 +499,6 @@ public class NewickFile
                 }
               }
             }
-            else
-            {
-              if (nf.charAt(fcp)=='[') {
-                
-              }
-            
-                // else : We do nothing if ';' is encountered.
-            }
           }
 
           // Reset new node properties to obvious fakes
@@ -695,7 +687,7 @@ public class NewickFile
   {
     return ( (c.getName() == null) ? "" : nodeName(c.getName())) +
         ( (HasBootstrap)
-         ? ( (c.getBootstrap() > -1) ? (" " + c.getBootstrap()) : "") : "") +
+         ? ( (c.getBootstrap() > -1) ? ((c.getName()!=null ? " " : "")+ c.getBootstrap()) : "") : "") +
         ( (HasDistances) ? (":" + c.dist) : "");
   }
 
@@ -711,7 +703,8 @@ public class NewickFile
     return (printRootInfo)
         ? ( ( (root.getName() == null) ? "" : nodeName(root.getName())) +
            ( (HasBootstrap)
-            ? ( (root.getBootstrap() > -1) ? (" " + root.getBootstrap()) : "") :
+            ? ( (root.getBootstrap() > -1) ? ((root.getName()!=null ? " " : "")+
+                    + root.getBootstrap()) : "") :
             "") +
            ( (RootHasDistance) ? (":" + root.dist) : "")) : "";
   }