JAL-2805 reorganized code, tree building goes through AptxInit for now
[jalview.git] / src / jalview / ext / forester / io / TreeParser.java
1 // package jalview.ext.forester.io;
2 //
3 // import jalview.ext.archaeopteryx.AptxInit;
4 // import jalview.ext.archaeopteryx.JalviewBinding;
5 // import jalview.ext.archaeopteryx.LoadedTreeAssociation;
6 // import jalview.ext.treeviewer.ExternalTreeParserI;
7 // import jalview.gui.Desktop;
8 // import jalview.gui.JvOptionPane;
9 // import jalview.util.MessageManager;
10 // import jalview.viewmodel.AlignmentViewport;
11 //
12 // import java.io.File;
13 // import java.io.IOException;
14 //
15 // import org.forester.archaeopteryx.Archaeopteryx;
16 // import org.forester.archaeopteryx.MainFrame;
17 // import org.forester.util.ForesterUtil;
18 //
19 // public class TreeParser implements ExternalTreeParserI<MainFrame>
20 // {
21 // private final String filePath;
22 //
23 // private final File file;
24 //
25 // public TreeParser(final String treeFilePath)
26 // {
27 // final String possibleError = ForesterUtil.isReadableFile(treeFilePath);
28 // if (possibleError != null)
29 // {
30 // JvOptionPane.showMessageDialog(Desktop.desktop, possibleError,
31 // MessageManager.getString("label.problem_reading_tree_file"),
32 // JvOptionPane.WARNING_MESSAGE);
33 //
34 // }
35 // filePath = treeFilePath;
36 // file = new File(filePath);
37 //
38 //
39 // }
40 //
41 // public TreeParser(final File treeFile) throws IOException
42 // {
43 // final String possibleError = ForesterUtil.isReadableFile(treeFile);
44 // if (possibleError != null)
45 // {
46 // JvOptionPane.showMessageDialog(Desktop.desktop, possibleError,
47 // MessageManager.getString("label.problem_reading_tree_file"),
48 // JvOptionPane.WARNING_MESSAGE);
49 //
50 // }
51 // file = treeFile;
52 // filePath = file.getCanonicalPath();
53 // }
54 //
55 // @Override
56 // public MainFrame loadTreeFile(AlignmentViewport viewport)
57 // {
58 // String[] AptxArgs = new String[] { "-c",
59 // "_aptx_jalview_configuration_file", filePath };
60 // MainFrame aptx = Archaeopteryx.main(AptxArgs);
61 //
62 // LoadedTreeAssociation bindAptxNodes = new LoadedTreeAssociation(
63 // viewport.getAlignment().getSequencesArray(),
64 // aptx.getMainPanel().getCurrentTreePanel().getPhylogeny());
65 //
66 // bindAptxNodes.associateLeavesToSequences();
67 //
68 // new JalviewBinding(aptx, viewport, bindAptxNodes.getAlignmentWithNodes(),
69 // bindAptxNodes.getNodesWithAlignment());
70 //
71 // AptxInit.bindFrameToJalview(aptx);
72 //
73 // return aptx;
74 //
75 //
76 // }
77 // //
78 // // void readPhylogeniesFromURL() {
79 // // URL url = null;
80 // // Phylogeny[] phys = null;
81 // // final String message = "Please enter a complete URL, for example
82 // // \"http://purl.org/phylo/treebase/phylows/study/TB2:S15480?format=nexus\"";
83 // // final String url_string = JOptionPane
84 // // .showInputDialog( this,
85 // // message,
86 // // "Use URL/webservice to obtain a phylogeny",
87 // // JOptionPane.QUESTION_MESSAGE );
88 // // boolean nhx_or_nexus = false;
89 // // if ( ( url_string != null ) && ( url_string.length() > 0 ) ) {
90 // // try {
91 // // url = new URL( url_string );
92 // // PhylogenyParser parser = null;
93 // // if ( url.getHost().toLowerCase().indexOf( "tolweb" ) >= 0 ) {
94 // // parser = new TolParser();
95 // // }
96 // // else {
97 // // parser = ParserUtils
98 // // .createParserDependingOnUrlContents( url,
99 // // getConfiguration().isValidatePhyloXmlAgainstSchema() );
100 // // }
101 // // if ( parser instanceof NexusPhylogeniesParser ) {
102 // // nhx_or_nexus = true;
103 // // }
104 // // else if ( parser instanceof NHXParser ) {
105 // // nhx_or_nexus = true;
106 // // }
107 // // if ( _mainpanel.getCurrentTreePanel() != null ) {
108 // // _mainpanel.getCurrentTreePanel().setWaitCursor();
109 // // }
110 // // else {
111 // // _mainpanel.setWaitCursor();
112 // // }
113 // // final PhylogenyFactory factory =
114 // ParserBasedPhylogenyFactory.getInstance();
115 // // phys = factory.create( url.openStream(), parser );
116 // // }
117 // // catch ( final MalformedURLException e ) {
118 // // JOptionPane.showMessageDialog( this,
119 // // "Malformed URL: " + url + "\n" + e.getLocalizedMessage(),
120 // // "Malformed URL",
121 // // JOptionPane.ERROR_MESSAGE );
122 // // }
123 // // catch ( final IOException e ) {
124 // // JOptionPane.showMessageDialog( this,
125 // // "Could not read from " + url + "\n"
126 // // + ForesterUtil.wordWrap( e.getLocalizedMessage(), 80 ),
127 // // "Failed to read URL",
128 // // JOptionPane.ERROR_MESSAGE );
129 // // }
130 // // catch ( final Exception e ) {
131 // // JOptionPane.showMessageDialog( this,
132 // // ForesterUtil.wordWrap( e.getLocalizedMessage(), 80 ),
133 // // "Unexpected Exception",
134 // // JOptionPane.ERROR_MESSAGE );
135 // // }
136 // // finally {
137 // // if ( _mainpanel.getCurrentTreePanel() != null ) {
138 // // _mainpanel.getCurrentTreePanel().setArrowCursor();
139 // // }
140 // // else {
141 // // _mainpanel.setArrowCursor();
142 // // }
143 // // }
144 // // if ( ( phys != null ) && ( phys.length > 0 ) ) {
145 // // if ( nhx_or_nexus &&
146 // // getOptions().isInternalNumberAreConfidenceForNhParsing() ) {
147 // // for( final Phylogeny phy : phys ) {
148 // // PhylogenyMethods.transferInternalNodeNamesToConfidence( phy, "" );
149 // // }
150 // // }
151 // // AptxUtil.addPhylogeniesToTabs( phys,
152 // // new File( url.getFile() ).getName(),
153 // // new File( url.getFile() ).toString(),
154 // // getConfiguration(),
155 // // getMainPanel() );
156 // // _mainpanel.getControlPanel().showWhole();
157 // // }
158 // // }
159 // // activateSaveAllIfNeeded();
160 // // System.gc();
161 // // }
162 //
163 // }
164 //
165 //
166 //
167 //
168 //
169 //