1 package jalview.ext.forester.io;
3 import jalview.ext.archaeopteryx.AptxBinding;
4 import jalview.ext.archaeopteryx.AptxNodeAssociation;
5 import jalview.ext.archaeopteryx.ArchaeopteryxInit;
6 import jalview.gui.Desktop;
7 import jalview.gui.JvOptionPane;
8 import jalview.util.MessageManager;
9 import jalview.viewmodel.AlignmentViewport;
12 import java.io.IOException;
14 import org.forester.archaeopteryx.Archaeopteryx;
15 import org.forester.archaeopteryx.MainFrame;
16 import org.forester.util.ForesterUtil;
18 public class ForesterTreeParser implements ExternalTreeParserI<MainFrame>
20 private final String filePath;
22 private final File file;
24 public ForesterTreeParser(final String treeFilePath)
26 final String possibleError = ForesterUtil.isReadableFile(treeFilePath);
27 if (possibleError != null)
29 JvOptionPane.showMessageDialog(Desktop.desktop, possibleError,
30 MessageManager.getString("label.problem_reading_tree_file"),
31 JvOptionPane.WARNING_MESSAGE);
34 filePath = treeFilePath;
35 file = new File(filePath);
40 public ForesterTreeParser(final File treeFile) throws IOException
42 final String possibleError = ForesterUtil.isReadableFile(treeFile);
43 if (possibleError != null)
45 JvOptionPane.showMessageDialog(Desktop.desktop, possibleError,
46 MessageManager.getString("label.problem_reading_tree_file"),
47 JvOptionPane.WARNING_MESSAGE);
51 filePath = file.getCanonicalPath();
55 public MainFrame loadTree(AlignmentViewport viewport)
57 String[] AptxArgs = new String[] { "-c",
58 "_aptx_jalview_configuration_file", filePath };
59 MainFrame aptx = Archaeopteryx.main(AptxArgs);
61 AptxNodeAssociation bindAptxNodes = new AptxNodeAssociation(
62 viewport.getAlignment().getSequencesArray(),
63 aptx.getMainPanel().getCurrentTreePanel().getPhylogeny());
65 bindAptxNodes.associateLeavesToSequences();
66 new AptxBinding(aptx, viewport, bindAptxNodes.getAlignmentWithNodes(),
67 bindAptxNodes.getNodesWithAlignment());
69 ArchaeopteryxInit.bindFrameToJalview(aptx);