JAL-2805 First try at loading tree through Forester by calling Aptx main
[jalview.git] / src / jalview / ext / forester / io / TreeParser.java
1 package jalview.ext.forester.io;
2
3 import jalview.ext.archaeopteryx.ArchaeopteryxInit;
4
5 import java.io.File;
6 import java.io.IOException;
7
8 import org.forester.archaeopteryx.Archaeopteryx;
9 import org.forester.archaeopteryx.MainFrame;
10 import org.forester.util.ForesterUtil;
11
12 public class TreeParser
13 {
14   private final String filePath;
15
16   private final File file;
17
18   public TreeParser(String treeFilePath)
19   {
20     final String possibleError = ForesterUtil.isReadableFile(treeFilePath);
21     if (possibleError != null)
22     {
23       // something
24     }
25     filePath = treeFilePath;
26     file = new File(filePath);
27
28
29   }
30
31   public TreeParser(File treeFile) throws IOException
32   {
33     final String possibleError = ForesterUtil.isReadableFile(treeFile);
34     if (possibleError != null)
35     {
36       // something
37     }
38     file = treeFile;
39     filePath = file.getCanonicalPath();
40   }
41
42
43   public void loadTree()
44   {
45     String[] AptxArgs = new String[] { "-c",
46         "_aptx_jalview_configuration_file", filePath };
47     MainFrame aptx = Archaeopteryx.main(AptxArgs);
48     ArchaeopteryxInit.bindFrameToJalview(aptx);
49
50
51   }
52 }
53
54 /**
55  * Mostly refactored from Archaeopteryx.main() and
56  * MainFrameApplication.readPhylogeniesFromFile()
57  */
58 // boolean nhx_or_nexus = false;
59 // Configuration config = new Configuration(
60 // "_aptx_jalview_configuration_file", false, false, false);
61 // try
62 // {
63 // final PhylogenyParser p = ParserUtils.createParserDependingOnFileType(
64 // file, config.isValidatePhyloXmlAgainstSchema());
65 //
66 // if (p instanceof NHXParser)
67 // {
68 // nhx_or_nexus = true;
69 // final NHXParser nhx = (NHXParser) p;
70 // nhx.setReplaceUnderscores(false);
71 // nhx.setIgnoreQuotes(false);
72 // nhx.setTaxonomyExtraction(config.getTaxonomyExtraction());
73 // }
74 // else if (p instanceof NexusPhylogeniesParser)
75 // {
76 // nhx_or_nexus = true;
77 // final NexusPhylogeniesParser nex = (NexusPhylogeniesParser) p;
78 // nex.setReplaceUnderscores(config.isReplaceUnderscoresInNhParsing());
79 // nex.setIgnoreQuotes(false);
80 // }
81 // else if (p instanceof PhyloXmlParser)
82 // {
83 //
84 // }
85 // Phylogeny[] phylogenies = PhylogenyMethods.readPhylogenies(p, file);
86 // if (nhx_or_nexus
87 // && config.isInternalNumberAreConfidenceForNhParsing())
88 // {
89 // for (final Phylogeny phy : phylogenies)
90 // {
91 // PhylogenyMethods.transferInternalNodeNamesToConfidence(phy, "");
92 //
93 // }
94 // }
95 // }
96 //
97 // catch (IOException e)
98 // {
99 // // TODO Auto-generated catch block
100 // e.printStackTrace();
101 // }
102 // }
103
104
105
106
107
108