(no commit message)
[jalview.git] / forester / java / src / org / forester / development / DevelopmentTools.java
index 9cb5e77..9c26d2c 100644 (file)
 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 //
 // Contact: phylosoft @ gmail . com
-// WWW: www.phylosoft.org/forester
+// WWW: https://sites.google.com/site/cmzmasek/home/software/forester
 
 package org.forester.development;
 
 import java.util.Random;
 
+import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException;
 import org.forester.phylogeny.Phylogeny;
 import org.forester.phylogeny.PhylogenyMethods;
 import org.forester.phylogeny.PhylogenyNode;
@@ -35,7 +36,7 @@ public final class DevelopmentTools {
 
     /**
      * Creates a completely unbalanced Phylogeny with i external nodes.
-     * 
+     *
      * @return a newly created unbalanced Phylogeny
      */
     // public static Phylogeny createUnbalancedTree( int i ) {
@@ -45,7 +46,7 @@ public final class DevelopmentTools {
     // try {
     // PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
     // t1 = factory.create( ":S=", new SimpleNHXParser() );
-    //            
+    //
     // t1.setRooted( true );
     //
     // for ( int j = 1; j < i; ++j ) {
@@ -70,7 +71,7 @@ public final class DevelopmentTools {
     /**
      * Creates a completely balanced rooted phylogeny with a given number of levels and
      * children per node.
-     * 
+     *
      * @param levels
      * @param children_per_node
      * @return a completely balanced rooted phylogeny
@@ -133,7 +134,12 @@ public final class DevelopmentTools {
         PhylogenyNode n = t.getFirstExternalNode();
         int j = t.getRoot().getNumberOfExternalNodes();
         while ( n != null ) {
-            PhylogenyMethods.setTaxonomyCode( n, j + "" );
+            try {
+                PhylogenyMethods.setTaxonomyCode( n, j + "" );
+            }
+            catch ( final PhyloXmlDataFormatException e ) {
+                e.printStackTrace();
+            }
             j--;
             n = n.getNextExternalNode();
         }
@@ -159,7 +165,7 @@ public final class DevelopmentTools {
     /**
      * Sets the species names of the external Nodes of Phylogeny t to a random
      * positive integer number between (and including) min and max.
-     * 
+     *
      * @param t
      *            whose external species names are to be randomized
      * @param min
@@ -176,8 +182,13 @@ public final class DevelopmentTools {
         final Random r = new Random();
         PhylogenyNode n = t.getFirstExternalNode();
         while ( n != null ) {
-            final String code = ( ( Math.abs( r.nextInt() ) % ( ma - mi + 1 ) ) + mi ) + "";
-            PhylogenyMethods.setTaxonomyCode( n, code );
+            final String code = ( ( Math.abs( r.nextInt() ) % ( ( ma - mi ) + 1 ) ) + mi ) + "";
+            try {
+                PhylogenyMethods.setTaxonomyCode( n, code );
+            }
+            catch ( final PhyloXmlDataFormatException e ) {
+                e.printStackTrace();
+            }
             n = n.getNextExternalNode();
         }
     }