1 package jalview.ext.archaeopteryx;
3 import jalview.analysis.TreeBuilder;
4 import jalview.datamodel.SequenceI;
5 import jalview.gui.Desktop;
6 import jalview.viewmodel.AlignmentViewport;
8 import java.awt.Dimension;
11 import org.forester.archaeopteryx.Archaeopteryx;
12 import org.forester.archaeopteryx.MainFrame;
13 import org.forester.phylogeny.Phylogeny;
14 import org.forester.phylogeny.PhylogenyNode;
17 * Static class for creating Archaeopteryx tree viewer instances from calculated
18 * trees and letting them be bound to Jalview.
20 * @author kjvanderheide
23 public final class ArchaeopteryxInit
26 * Test method, should generally not be used as it does not bind the tree to
32 public static MainFrame createUnboundInstance(final Phylogeny aptxTree)
34 Phylogeny[] aptxTrees = { aptxTree };
35 return createAptxFrame(aptxTrees);
38 // public static MainFrame createInstance(final Phylogeny[] aptxTrees,
39 // AlignmentViewport jalviewAlignmentView)
41 // return createAptxFrameInJalview(aptxTrees);
45 // public static MainFrame createInstance(final Phylogeny aptxTree,
46 // final AlignmentViewport jalviewAlignmentView)
48 // Phylogeny[] aptxTrees = { aptxTree }; // future possibility to load in
49 // // several trees simultaneously
50 // return createAptxFrameInJalview(aptxTrees);
54 public static MainFrame createInstance(
55 final TreeBuilder calculatedTree) // very dense method, to be split up
57 ExternalTreeBuilderI<Phylogeny, PhylogenyNode> aptxTreeBuilder = new ArchaeopteryxTreeBuilder(
60 Phylogeny aptxTree = aptxTreeBuilder.buildTree();
61 Phylogeny[] aptxTrees = { aptxTree }; // future possibility to load in
62 // several trees simultaneously
64 MainFrame aptxApp = createAptxFrame(aptxTrees);
66 bindNodesToJalviewSequences(aptxApp, calculatedTree.getAvport(),
67 aptxTreeBuilder.getAlignmentBoundNodes(),
68 aptxTreeBuilder.getNodesBoundAlignment());
69 return bindFrameToJalview(aptxApp);
76 public static MainFrame createAptxFrame(
77 final Phylogeny[] aptxTrees)
79 MainFrame aptxApp = Archaeopteryx.createApplication(aptxTrees,
80 "_aptx_jalview_configuration_file", null);
84 public static ExternalTreeViewerBindingI<?> bindNodesToJalviewSequences(
85 final MainFrame aptxApp,
86 final AlignmentViewport jalviewAlignViewport,
87 final Map<SequenceI, PhylogenyNode> alignMappedToNodes,
88 final Map<PhylogenyNode, SequenceI> nodesMappedToAlign)
90 return new AptxBinding(aptxApp, jalviewAlignViewport,
91 alignMappedToNodes, nodesMappedToAlign);
95 public static MainFrame bindFrameToJalview(final MainFrame aptxApp)
99 aptxApp.setMinimumSize(new Dimension(width, height));
101 Desktop.addInternalFrame(aptxApp, "Archaeopteryx Tree View", true,
102 width, height, true, true);