X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Fdevelopment%2FDevelopmentTools.java;h=9c26d2cf8c4ba9ec0c68ab15eaf43b7c15121063;hb=b5fe992f707cdad84255eb85040effbee97d61b3;hp=d41194a7fe3e67526a188d0023f5219ca0494893;hpb=eccc2fdb674f76be1815fd7984295661bff8a2be;p=jalview.git diff --git a/forester/java/src/org/forester/development/DevelopmentTools.java b/forester/java/src/org/forester/development/DevelopmentTools.java index d41194a..9c26d2c 100644 --- a/forester/java/src/org/forester/development/DevelopmentTools.java +++ b/forester/java/src/org/forester/development/DevelopmentTools.java @@ -5,7 +5,7 @@ // Copyright (C) 2008-2009 Christian M. Zmasek // Copyright (C) 2008-2009 Burnham Institute for Medical Research // All rights reserved -// +// // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either @@ -15,18 +15,19 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. -// +// // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // 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(); } }