--- /dev/null
+package jalview.ext.archaeopteryx;
+
+
+interface AlignmentToTreeViewerI
+{
+
+}
--- /dev/null
+package jalview.ext.archaeopteryx;
+
+import jalview.analysis.TreeModel;
+import jalview.io.NewickFile;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import org.forester.archaeopteryx.Archaeopteryx;
+
+public class ArchaeopteryxInit
+{
+ private String filePath = "/tmp/jalviewtree.nwk";
+
+ private TreeModel tree;
+
+ private NewickFile newickTree;
+
+ public ArchaeopteryxInit(TreeModel jalviewTreeModel)
+ {
+ this.tree = jalviewTreeModel;
+ this.newickTree = treeToNewick(tree);
+ }
+
+ public ArchaeopteryxInit(NewickFile newickTreeModel)
+ {
+ this.newickTree = newickTreeModel;
+ }
+
+ public void startArchaeopteryx()
+ {
+ String newickOutput = newickTree.print(newickTree.hasBootstrap(),
+ newickTree.hasDistances(), newickTree.hasRootDistance());
+
+ File newickFile = new File(filePath);
+ PrintWriter writer;
+
+ try
+ {
+ writer = new PrintWriter(newickFile);
+ writer.println(newickOutput);
+
+ // System.out.println(writer.checkError());
+ writer.close();
+
+ String[] commandLineArgs = { "-open", newickFile.getCanonicalPath() };
+ Archaeopteryx.main(commandLineArgs);
+
+ } catch (FileNotFoundException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+
+ }
+
+
+ public String getFilePath()
+ {
+ return filePath;
+ }
+
+ public void setFilePath(String newFilePath)
+ {
+ this.filePath = newFilePath;
+ }
+
+ public TreeModel getTree()
+ {
+ return tree;
+ }
+
+ public void setTree(TreeModel newTree)
+ {
+ this.tree = newTree;
+ }
+
+ public NewickFile getNewickTree()
+ {
+ return newickTree;
+ }
+
+ public void setNewickTree(NewickFile newNewickTree)
+ {
+ this.newickTree = newNewickTree;
+ }
+
+ public static NewickFile treeToNewick(TreeModel tree)
+ {
+ NewickFile newickTree = new NewickFile(tree.getTopNode(),
+ tree.hasBootstrap(), tree.hasDistances(),
+ tree.hasRootDistance());
+ /* System.out.println(newickTree.print(tree.hasBootstrap(),
+ tree.hasDistances(), tree.hasRootDistance()));
+
+ System.out.println(newickTree.print(newickTree.hasBootstrap(),
+ newickTree.hasDistances(), newickTree.hasRootDistance()));*/
+
+ return newickTree;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package jalview.ext.archaeopteryx;
+
+interface TreeViewerBindingI
+{
+
+}
viewport.followSelection = listenToViewSelections.isSelected();
}
+
/**
* Constructs a tree panel and adds it to the desktop
*
final ComboBoxTooltipRenderer renderer = new ComboBoxTooltipRenderer();
- List<String> tips = new ArrayList<String>();
+ List<String> tips = new ArrayList<>();
/**
* Constructor
*/
protected JComboBox<String> buildModelOptionsList()
{
- final JComboBox<String> scoreModelsCombo = new JComboBox<String>();
+ final JComboBox<String> scoreModelsCombo = new JComboBox<>();
scoreModelsCombo.setRenderer(renderer);
/*
{
Object curSel = comboBox.getSelectedItem();
toolTips.clear();
- DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>();
+ DefaultComboBoxModel<String> model = new DefaultComboBoxModel<>();
/*
* now we can actually add entries to the combobox,
}
else
{
+ calculateTree();
openTreePanel(modelName, params);
}
// closeFrame();
}
- /**
- * Open a new Tree panel on the desktop
- *
- * @param modelName
- * @param params
- */
- protected void openTreePanel(String modelName, SimilarityParamsI params)
+ protected void calculateTree()
+ {
+
+ }
+ protected String determineTreeAlgo() // to be modified & expanded
+ {
+ String treeAlgorithm = neighbourJoining.isSelected()
+ ? TreeBuilder.NEIGHBOUR_JOINING
+ : TreeBuilder.AVERAGE_DISTANCE;
+
+ return treeAlgorithm;
+
+ }
+
+ protected void checkEnoughSequences(AlignViewport viewport)
{
- /*
- * gui validation shouldn't allow insufficient sequences here, but leave
- * this check in in case this method gets exposed programmatically in future
- */
- AlignViewport viewport = af.getViewport();
SequenceGroup sg = viewport.getSelectionGroup();
if (sg != null && sg.getSize() < MIN_TREE_SELECTION)
{
JvOptionPane.WARNING_MESSAGE);
return;
}
+ }
+
+ /**
+ * Open a new Tree panel on the desktop
+ *
+ */
+ protected void openTreePanel(String modelName, SimilarityParamsI params)
+ {
+ /*
+ * gui validation shouldn't allow insufficient sequences here, but leave
+ * this check in in case this method gets exposed programmatically in future
+ */
+ checkEnoughSequences(af.getViewport());
+
+ String treeType = determineTreeAlgo();
- String treeType = neighbourJoining.isSelected()
- ? TreeBuilder.NEIGHBOUR_JOINING
- : TreeBuilder.AVERAGE_DISTANCE;
af.newTreePanel(treeType, modelName, params);
}
*/
boolean matchGap = doPCA ? false : treeMatchGaps;
+
return new SimilarityParams(includeGapGap, matchGap, includeGapResidue,
matchOnShortestLength);
}
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
import jalview.datamodel.SequenceNode;
-import jalview.ext.archaeopteryx.Testo;
+import jalview.ext.archaeopteryx.ArchaeopteryxInit;
import jalview.io.JalviewFileChooser;
import jalview.io.JalviewFileView;
import jalview.io.NewickFile;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.beans.PropertyChangeEvent;
-import java.io.File;
import java.io.FileOutputStream;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
{
originalSeqData.setVisible(false);
}
+
+ ArchaeopteryxInit archae = new ArchaeopteryxInit(newtree);
+ archae.startArchaeopteryx();
+
}
else
{
: new AverageDistanceTree(av, sm, similarityParams);
tree = new TreeModel(njtree);
showDistances(true);
+
+ ArchaeopteryxInit archae = new ArchaeopteryxInit(tree);
+ archae.startArchaeopteryx();
+
}
tree.reCount(tree.getTopNode());
treeCanvas.setTree(tree);
treeCanvas.repaint();
- Testo test = new Testo();
- NewickFile newickTree = test.treeToNewick(tree);
- File newickAsFile = test.newickToArchaeopteryx(newickTree);
- try
- {
- String[] archaeCommandlineArgs = {
- "-open", newickAsFile.getCanonicalPath() };
- test.startArchaeopteryx(archaeCommandlineArgs);
- } catch (IOException e)
- {
- e.printStackTrace();
- }
av.setCurrentTree(tree);
if (av.getSortByTree())
{