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 ForesterTreeParser implements ExternalTreeParserI<MainFrame>
17 private final String filePath;
19 private final File file;
21 public ForesterTreeParser(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 ForesterTreeParser(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();
52 public MainFrame loadTree()
54 String[] AptxArgs = new String[] { "-c",
55 "_aptx_jalview_configuration_file", filePath };
56 MainFrame aptx = Archaeopteryx.main(AptxArgs);
57 ArchaeopteryxInit.bindFrameToJalview(aptx);
66 * Mostly refactored from Archaeopteryx.main() and
67 * MainFrameApplication.readPhylogeniesFromFile()
69 // boolean nhx_or_nexus = false;
70 // Configuration config = new Configuration(
71 // "_aptx_jalview_configuration_file", false, false, false);
74 // final PhylogenyParser p = ParserUtils.createParserDependingOnFileType(
75 // file, config.isValidatePhyloXmlAgainstSchema());
77 // if (p instanceof NHXParser)
79 // nhx_or_nexus = true;
80 // final NHXParser nhx = (NHXParser) p;
81 // nhx.setReplaceUnderscores(false);
82 // nhx.setIgnoreQuotes(false);
83 // nhx.setTaxonomyExtraction(config.getTaxonomyExtraction());
85 // else if (p instanceof NexusPhylogeniesParser)
87 // nhx_or_nexus = true;
88 // final NexusPhylogeniesParser nex = (NexusPhylogeniesParser) p;
89 // nex.setReplaceUnderscores(config.isReplaceUnderscoresInNhParsing());
90 // nex.setIgnoreQuotes(false);
92 // else if (p instanceof PhyloXmlParser)
96 // Phylogeny[] phylogenies = PhylogenyMethods.readPhylogenies(p, file);
98 // && config.isInternalNumberAreConfidenceForNhParsing())
100 // for (final Phylogeny phy : phylogenies)
102 // PhylogenyMethods.transferInternalNodeNamesToConfidence(phy, "");
108 // catch (IOException e)
110 // // TODO Auto-generated catch block
111 // e.printStackTrace();