1 package jalview.ext.forester.io;
3 import jalview.ext.archaeopteryx.ArchaeopteryxInit;
6 import java.io.IOException;
8 import org.forester.archaeopteryx.Archaeopteryx;
9 import org.forester.archaeopteryx.MainFrame;
10 import org.forester.util.ForesterUtil;
12 public class TreeParser
14 private final String filePath;
16 private final File file;
18 public TreeParser(String treeFilePath)
20 final String possibleError = ForesterUtil.isReadableFile(treeFilePath);
21 if (possibleError != null)
25 filePath = treeFilePath;
26 file = new File(filePath);
31 public TreeParser(File treeFile) throws IOException
33 final String possibleError = ForesterUtil.isReadableFile(treeFile);
34 if (possibleError != null)
39 filePath = file.getCanonicalPath();
43 public void loadTree()
45 String[] AptxArgs = new String[] { "-c",
46 "_aptx_jalview_configuration_file", filePath };
47 MainFrame aptx = Archaeopteryx.main(AptxArgs);
48 ArchaeopteryxInit.bindFrameToJalview(aptx);
55 * Mostly refactored from Archaeopteryx.main() and
56 * MainFrameApplication.readPhylogeniesFromFile()
58 // boolean nhx_or_nexus = false;
59 // Configuration config = new Configuration(
60 // "_aptx_jalview_configuration_file", false, false, false);
63 // final PhylogenyParser p = ParserUtils.createParserDependingOnFileType(
64 // file, config.isValidatePhyloXmlAgainstSchema());
66 // if (p instanceof NHXParser)
68 // nhx_or_nexus = true;
69 // final NHXParser nhx = (NHXParser) p;
70 // nhx.setReplaceUnderscores(false);
71 // nhx.setIgnoreQuotes(false);
72 // nhx.setTaxonomyExtraction(config.getTaxonomyExtraction());
74 // else if (p instanceof NexusPhylogeniesParser)
76 // nhx_or_nexus = true;
77 // final NexusPhylogeniesParser nex = (NexusPhylogeniesParser) p;
78 // nex.setReplaceUnderscores(config.isReplaceUnderscoresInNhParsing());
79 // nex.setIgnoreQuotes(false);
81 // else if (p instanceof PhyloXmlParser)
85 // Phylogeny[] phylogenies = PhylogenyMethods.readPhylogenies(p, file);
87 // && config.isInternalNumberAreConfidenceForNhParsing())
89 // for (final Phylogeny phy : phylogenies)
91 // PhylogenyMethods.transferInternalNodeNamesToConfidence(phy, "");
97 // catch (IOException e)
99 // // TODO Auto-generated catch block
100 // e.printStackTrace();