org.forester.applications.wiki_examples Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of forester Show documentation
Show all versions of forester Show documentation
Applications and software libraries for evolutionary biology and comparative genomics research
The newest version!
package org.forester.applications;
import java.awt.Color;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.forester.archaeopteryx.Archaeopteryx;
import org.forester.io.parsers.PhylogenyParser;
import org.forester.io.parsers.util.ParserUtils;
import org.forester.phylogeny.Phylogeny;
import org.forester.phylogeny.PhylogenyMethods;
import org.forester.phylogeny.data.BranchColor;
import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
public class wiki_examples {
public static void main( final String[] args ) {
// Reading-in of (a) tree(s) from a file.
final File treefile = new File( args[ 0 ] );
PhylogenyParser parser = null;
try {
parser = ParserUtils.createParserDependingOnFileType( treefile, true );
}
catch ( final IOException e ) {
e.printStackTrace();
}
Phylogeny[] phys = null;
try {
phys = PhylogenyMethods.readPhylogenies( parser, treefile );
}
catch ( final IOException e ) {
e.printStackTrace();
}
final Phylogeny phy = phys[ 0 ];
// Read node->color map into a map
final Map colors = new HashMap();
// read it in from file...
// Iterate over nodes and set colors from 'colors' map
for( final PhylogenyNodeIterator it = phy.iteratorPostorder(); it.hasNext(); ) {
// if node-name (?) in 'colors' map
it.next().getBranchData().setBranchColor( new BranchColor( colors.get( "xx" ) ) );
}
// For testing, use Aptx...
Archaeopteryx.createApplication( phy );
// Finally, create
}
}