1 /*******************************************************************************
2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $(date) The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
20 *******************************************************************************/
21 package jalview.ext.archaeopteryx;
23 import jalview.analysis.TreeModel;
24 import jalview.io.NewickFile;
27 import java.io.FileNotFoundException;
28 import java.io.IOException;
29 import java.io.PrintWriter;
31 import org.forester.archaeopteryx.Archaeopteryx;
33 public class ArchaeopteryxInit
35 private String filePath = "/tmp/jalviewtree.nwk";
37 private TreeModel tree;
39 private NewickFile newickTree;
41 public ArchaeopteryxInit(TreeModel jalviewTreeModel)
43 this.tree = jalviewTreeModel;
44 this.newickTree = treeToNewick(tree);
47 public ArchaeopteryxInit(NewickFile newickTreeModel)
49 this.newickTree = newickTreeModel;
52 public void startArchaeopteryx()
54 String newickOutput = newickTree.print(newickTree.hasBootstrap(),
55 newickTree.hasDistances(), newickTree.hasRootDistance());
57 File newickFile = new File(filePath);
62 writer = new PrintWriter(newickFile);
63 writer.println(newickOutput);
65 // System.out.println(writer.checkError());
68 String[] commandLineArgs = { "-open", newickFile.getCanonicalPath() };
69 Archaeopteryx.main(commandLineArgs);
71 } catch (FileNotFoundException e)
73 // TODO Auto-generated catch block
75 } catch (IOException e)
77 // TODO Auto-generated catch block
85 public String getFilePath()
90 public void setFilePath(String newFilePath)
92 this.filePath = newFilePath;
95 public TreeModel getTree()
100 public void setTree(TreeModel newTree)
105 public NewickFile getNewickTree()
110 public void setNewickTree(NewickFile newNewickTree)
112 this.newickTree = newNewickTree;
115 public static NewickFile treeToNewick(TreeModel tree)
117 NewickFile newickTree = new NewickFile(tree.getTopNode(),
118 tree.hasBootstrap(), tree.hasDistances(),
119 tree.hasRootDistance());
120 /* System.out.println(newickTree.print(tree.hasBootstrap(),
121 tree.hasDistances(), tree.hasRootDistance()));
123 System.out.println(newickTree.print(newickTree.hasBootstrap(),
124 newickTree.hasDistances(), newickTree.hasRootDistance()));*/