1 package jalview.ext.archaeopteryx;
3 import jalview.analysis.TreeModel;
4 import jalview.io.NewickFile;
7 import java.io.FileNotFoundException;
8 import java.io.IOException;
9 import java.io.PrintWriter;
11 import org.forester.archaeopteryx.Archaeopteryx;
13 public class ArchaeopteryxInit
15 private String filePath = "/tmp/jalviewtree.nwk";
17 private TreeModel tree;
19 private NewickFile newickTree;
21 public ArchaeopteryxInit(TreeModel jalviewTreeModel)
23 this.tree = jalviewTreeModel;
24 this.newickTree = treeToNewick(tree);
27 public ArchaeopteryxInit(NewickFile newickTreeModel)
29 this.newickTree = newickTreeModel;
32 public void startArchaeopteryx()
34 String newickOutput = newickTree.print(newickTree.hasBootstrap(),
35 newickTree.hasDistances(), newickTree.hasRootDistance());
37 File newickFile = new File(filePath);
42 writer = new PrintWriter(newickFile);
43 writer.println(newickOutput);
45 // System.out.println(writer.checkError());
48 String[] commandLineArgs = { "-open", newickFile.getCanonicalPath() };
49 Archaeopteryx.main(commandLineArgs);
51 } catch (FileNotFoundException e)
53 // TODO Auto-generated catch block
55 } catch (IOException e)
57 // TODO Auto-generated catch block
65 public String getFilePath()
70 public void setFilePath(String newFilePath)
72 this.filePath = newFilePath;
75 public TreeModel getTree()
80 public void setTree(TreeModel newTree)
85 public NewickFile getNewickTree()
90 public void setNewickTree(NewickFile newNewickTree)
92 this.newickTree = newNewickTree;
95 public static NewickFile treeToNewick(TreeModel tree)
97 NewickFile newickTree = new NewickFile(tree.getTopNode(),
98 tree.hasBootstrap(), tree.hasDistances(),
99 tree.hasRootDistance());
100 /* System.out.println(newickTree.print(tree.hasBootstrap(),
101 tree.hasDistances(), tree.hasRootDistance()));
103 System.out.println(newickTree.print(newickTree.hasBootstrap(),
104 newickTree.hasDistances(), newickTree.hasRootDistance()));*/