package jalview.ext.forester.io; import jalview.ext.archaeopteryx.ArchaeopteryxInit; import jalview.gui.Desktop; import jalview.gui.JvOptionPane; import jalview.util.MessageManager; import java.io.File; import java.io.IOException; import org.forester.archaeopteryx.Archaeopteryx; import org.forester.archaeopteryx.MainFrame; import org.forester.util.ForesterUtil; public class ForesterTreeParser implements ExternalTreeParserI { private final String filePath; private final File file; public ForesterTreeParser(final String treeFilePath) { final String possibleError = ForesterUtil.isReadableFile(treeFilePath); if (possibleError != null) { JvOptionPane.showMessageDialog(Desktop.desktop, possibleError, MessageManager.getString("label.problem_reading_tree_file"), JvOptionPane.WARNING_MESSAGE); } filePath = treeFilePath; file = new File(filePath); } public ForesterTreeParser(final File treeFile) throws IOException { final String possibleError = ForesterUtil.isReadableFile(treeFile); if (possibleError != null) { JvOptionPane.showMessageDialog(Desktop.desktop, possibleError, MessageManager.getString("label.problem_reading_tree_file"), JvOptionPane.WARNING_MESSAGE); } file = treeFile; filePath = file.getCanonicalPath(); } @Override public MainFrame loadTree() { String[] AptxArgs = new String[] { "-c", "_aptx_jalview_configuration_file", filePath }; MainFrame aptx = Archaeopteryx.main(AptxArgs); ArchaeopteryxInit.bindFrameToJalview(aptx); return aptx; } } /** * Mostly refactored from Archaeopteryx.main() and * MainFrameApplication.readPhylogeniesFromFile() */ // boolean nhx_or_nexus = false; // Configuration config = new Configuration( // "_aptx_jalview_configuration_file", false, false, false); // try // { // final PhylogenyParser p = ParserUtils.createParserDependingOnFileType( // file, config.isValidatePhyloXmlAgainstSchema()); // // if (p instanceof NHXParser) // { // nhx_or_nexus = true; // final NHXParser nhx = (NHXParser) p; // nhx.setReplaceUnderscores(false); // nhx.setIgnoreQuotes(false); // nhx.setTaxonomyExtraction(config.getTaxonomyExtraction()); // } // else if (p instanceof NexusPhylogeniesParser) // { // nhx_or_nexus = true; // final NexusPhylogeniesParser nex = (NexusPhylogeniesParser) p; // nex.setReplaceUnderscores(config.isReplaceUnderscoresInNhParsing()); // nex.setIgnoreQuotes(false); // } // else if (p instanceof PhyloXmlParser) // { // // } // Phylogeny[] phylogenies = PhylogenyMethods.readPhylogenies(p, file); // if (nhx_or_nexus // && config.isInternalNumberAreConfidenceForNhParsing()) // { // for (final Phylogeny phy : phylogenies) // { // PhylogenyMethods.transferInternalNodeNamesToConfidence(phy, ""); // // } // } // } // // catch (IOException e) // { // // TODO Auto-generated catch block // e.printStackTrace(); // } // }