// 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;
/**
* Creates a completely unbalanced Phylogeny with i external nodes.
- *
+ *
* @return a newly created unbalanced Phylogeny
*/
// public static Phylogeny createUnbalancedTree( int i ) {
// try {
// PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
// t1 = factory.create( ":S=", new SimpleNHXParser() );
- //
+ //
// t1.setRooted( true );
//
// for ( int j = 1; j < i; ++j ) {
/**
* 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
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();
}
/**
* 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
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();
}
}