1 package jalview.ext.forester.io;
3 import jalview.ext.archaeopteryx.ArchaeopteryxInit;
4 import jalview.gui.Desktop;
5 import jalview.gui.JvOptionPane;
6 import jalview.util.MessageManager;
9 import java.io.IOException;
11 import org.forester.archaeopteryx.Archaeopteryx;
12 import org.forester.archaeopteryx.MainFrame;
13 import org.forester.util.ForesterUtil;
15 public class TreeParser
17 private final String filePath;
19 private final File file;
21 public TreeParser(final String treeFilePath)
23 final String possibleError = ForesterUtil.isReadableFile(treeFilePath);
24 if (possibleError != null)
26 JvOptionPane.showMessageDialog(Desktop.desktop, possibleError,
27 MessageManager.getString("label.problem_reading_tree_file"),
28 JvOptionPane.WARNING_MESSAGE);
31 filePath = treeFilePath;
32 file = new File(filePath);
37 public TreeParser(final File treeFile) throws IOException
39 final String possibleError = ForesterUtil.isReadableFile(treeFile);
40 if (possibleError != null)
42 JvOptionPane.showMessageDialog(Desktop.desktop, possibleError,
43 MessageManager.getString("label.problem_reading_tree_file"),
44 JvOptionPane.WARNING_MESSAGE);
48 filePath = file.getCanonicalPath();
51 public MainFrame loadTree()
53 String[] AptxArgs = new String[] { "-c",
54 "_aptx_jalview_configuration_file", filePath };
55 MainFrame aptx = Archaeopteryx.main(AptxArgs);
56 ArchaeopteryxInit.bindFrameToJalview(aptx);
64 * Mostly refactored from Archaeopteryx.main() and
65 * MainFrameApplication.readPhylogeniesFromFile()
67 // boolean nhx_or_nexus = false;
68 // Configuration config = new Configuration(
69 // "_aptx_jalview_configuration_file", false, false, false);
72 // final PhylogenyParser p = ParserUtils.createParserDependingOnFileType(
73 // file, config.isValidatePhyloXmlAgainstSchema());
75 // if (p instanceof NHXParser)
77 // nhx_or_nexus = true;
78 // final NHXParser nhx = (NHXParser) p;
79 // nhx.setReplaceUnderscores(false);
80 // nhx.setIgnoreQuotes(false);
81 // nhx.setTaxonomyExtraction(config.getTaxonomyExtraction());
83 // else if (p instanceof NexusPhylogeniesParser)
85 // nhx_or_nexus = true;
86 // final NexusPhylogeniesParser nex = (NexusPhylogeniesParser) p;
87 // nex.setReplaceUnderscores(config.isReplaceUnderscoresInNhParsing());
88 // nex.setIgnoreQuotes(false);
90 // else if (p instanceof PhyloXmlParser)
94 // Phylogeny[] phylogenies = PhylogenyMethods.readPhylogenies(p, file);
96 // && config.isInternalNumberAreConfidenceForNhParsing())
98 // for (final Phylogeny phy : phylogenies)
100 // PhylogenyMethods.transferInternalNodeNamesToConfidence(phy, "");
106 // catch (IOException e)
108 // // TODO Auto-generated catch block
109 // e.printStackTrace();