rio - gsdir work...
[jalview.git] / forester / java / src / org / forester / phylogeny / Phylogeny.java
index 5649a5b..b41f5fa 100644 (file)
@@ -157,6 +157,8 @@ public class Phylogeny {
     public Phylogeny copy() {
         return copy( _root );
     }
+    
+  
 
     /**
      * Returns a deep copy of this Phylogeny.
@@ -414,10 +416,10 @@ public class Phylogeny {
         }
         final List<PhylogenyNode> nodes = getNodes( name );
         if ( ( nodes == null ) || ( nodes.size() < 1 ) ) {
-            throw new IllegalArgumentException( "node named [" + name + "] not found" );
+            throw new IllegalArgumentException( "node named \"" + name + "\" not found" );
         }
         if ( nodes.size() > 1 ) {
-            throw new IllegalArgumentException( "node named [" + name + "] not unique" );
+            throw new IllegalArgumentException( "node named \"" + name + "\" not unique" );
         }
         return nodes.get( 0 );
     }
@@ -556,6 +558,22 @@ public class Phylogeny {
         return c;
     }
 
+    public int getNumberOfInternalNodes() {
+        if ( isEmpty() ) {
+            return 0;
+        }
+        int c = 0;
+        for( final PhylogenyNodeIterator iter = iteratorPreorder(); iter.hasNext(); ) {
+            if ( iter.next().isInternal() ) {
+                ++c;
+            }
+        }
+        if ( !isRooted() ) {
+            --c;
+        }
+        return c;
+    }
+
     /**
      * Returns the sum of external Nodes of this Phylogeny (int).
      */
@@ -1057,7 +1075,7 @@ public class Phylogeny {
 
     public void setRoot( final PhylogenyNode n ) {
         _root = n;
-    } // setRoot( PhylogenyNode )
+    } 
 
     /**
      * Sets whether this Phylogeny is rooted or not.