in pprogress...
[jalview.git] / forester_applications / src / org / forester / applications / wiki_examples.java
1
2 package org.forester.applications;
3
4 import java.awt.Color;
5 import java.io.File;
6 import java.io.IOException;
7 import java.util.HashMap;
8 import java.util.Map;
9
10 import org.forester.archaeopteryx.Archaeopteryx;
11 import org.forester.io.parsers.PhylogenyParser;
12 import org.forester.io.parsers.util.ParserUtils;
13 import org.forester.phylogeny.Phylogeny;
14 import org.forester.phylogeny.PhylogenyMethods;
15 import org.forester.phylogeny.data.BranchColor;
16 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
17
18 public class wiki_examples {
19
20     public static void main( final String[] args ) {
21         // Reading-in of (a) tree(s) from a file.
22         final File treefile = new File( args[ 0 ] );
23         PhylogenyParser parser = null;
24         try {
25             parser = ParserUtils.createParserDependingOnFileType( treefile, true );
26         }
27         catch ( final IOException e ) {
28             e.printStackTrace();
29         }
30         Phylogeny[] phys = null;
31         try {
32             phys = PhylogenyMethods.readPhylogenies( parser, treefile );
33         }
34         catch ( final IOException e ) {
35             e.printStackTrace();
36         }
37         final Phylogeny phy = phys[ 0 ];
38         // Read node->color map into a map
39         final Map<String, Color> colors = new HashMap<String, Color>();
40         // read it in from file...
41         // Iterate over nodes and set colors from 'colors' map
42         for( final PhylogenyNodeIterator it = phy.iteratorPostorder(); it.hasNext(); ) {
43             // if node-name (?) in 'colors' map
44             it.next().getBranchData().setBranchColor( new BranchColor( colors.get( "xx" ) ) );
45         }
46         // For testing, use Aptx...
47         Archaeopteryx.createApplication( phy );
48         // Finally, create
49     }
50 }