<classpathentry kind="lib" path="lib/biojava-core-4.1.0.jar"/>
<classpathentry kind="lib" path="lib/biojava-ontology-4.1.0.jar"/>
<classpathentry kind="lib" path="lib/groovy-all-2.4.6-indy.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/forester"/>
<classpathentry kind="output" path="classes"/>
</classpath>
<name>Jalview Release 2.7</name>
<comment></comment>
<projects>
+ <project>forester</project>
</projects>
<buildSpec>
<buildCommand>
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
+org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=52
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0
org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0
+org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0
org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
+org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=false
org.eclipse.jdt.core.formatter.comment.format_block_comments=false
org.eclipse.jdt.core.formatter.comment.format_header=false
org.eclipse.jdt.core.formatter.comment.format_html=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
org.eclipse.jdt.core.formatter.indentation.size=8
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
+org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
org.eclipse.jdt.core.formatter.tabulation.char=space
org.eclipse.jdt.core.formatter.tabulation.size=2
org.eclipse.jdt.core.formatter.use_on_off_tags=true
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
+org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true
org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
+org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter
eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
formatter_profile=_Jalview
-formatter_settings_version=12
+formatter_settings_version=13
org.eclipse.jdt.ui.ignorelowercasenames=true
org.eclipse.jdt.ui.importorder=jalview;java;javax;org;com;
org.eclipse.jdt.ui.ondemandthreshold=99
Vector<SequenceNode> node;
- private AlignmentView seqStrings;
+ private AlignmentView seqStrings; // redundant? (see seqData)
/**
* Constructor
protected void init(AlignmentView seqView, int start, int end)
{
- this.node = new Vector<SequenceNode>();
+ this.node = new Vector<>();
if (seqView != null)
{
this.seqData = seqView;
*/
void makeLeaves()
{
- clusters = new Vector<BitSet>();
+ clusters = new Vector<>();
for (int i = 0; i < noseqs; i++)
{
sn.setElement(sequences[i]);
sn.setName(sequences[i].getName());
node.addElement(sn);
+
BitSet bs = new BitSet();
bs.set(i);
clusters.addElement(bs);
--- /dev/null
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($Version-Rel$)
+ * Copyright (C) $Year-Rel$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.analysis;
+
+import jalview.analysis.scoremodels.ScoreModels;
+import jalview.api.analysis.ScoreModelI;
+import jalview.api.analysis.SimilarityParamsI;
+import jalview.gui.AlignViewport;
+
+/**
+ * @author kjvanderheide
+ *
+ */
+public class TreeCalculator extends Thread// add threading
+{
+ SimilarityParamsI similarityParams;
+
+ String treeType;
+
+ String scoreModelName; // if tree computed
+
+ /**
+ *
+ * @param treeAlgo
+ * @param substitutionMatrix
+ * @param calculateParams
+ */
+ public TreeCalculator(String treeAlgo, String substitutionMatrix,
+ SimilarityParamsI calculateParams)
+ {
+ this.treeType = treeAlgo;
+ this.scoreModelName = substitutionMatrix;
+ this.similarityParams = calculateParams;
+ }
+
+ /**
+ *
+ * @param alignViewport
+ * @return
+ */
+ public TreeBuilder makeTree(AlignViewport alignViewport)
+ {
+ ScoreModelI sm = ScoreModels.getInstance().getScoreModel(scoreModelName,
+ alignViewport.getAlignPanel());
+
+ TreeBuilder builtTree = treeType.equals(TreeBuilder.NEIGHBOUR_JOINING)
+ ? new NJTree(alignViewport, sm, similarityParams)
+ : new AverageDistanceTree(alignViewport, sm, similarityParams);
+
+ return builtTree;
+
+ }
+
+ public SimilarityParamsI getSimilarityParams()
+ {
+ return similarityParams;
+ }
+
+ public void setSimilarityParams(SimilarityParamsI similarityParams)
+ {
+ this.similarityParams = similarityParams;
+ }
+
+ public String getTreeType()
+ {
+ return treeType;
+ }
+
+ public void setTreeType(String treeType)
+ {
+ this.treeType = treeType;
+ }
+
+ public String getScoreModelName()
+ {
+ return scoreModelName;
+ }
+
+ public void setScoreModelName(String scoreModelName)
+ {
+ this.scoreModelName = scoreModelName;
+ }
+
+
+
+
+}
public TreeModel(SequenceI[] seqs, AlignmentView odata,
NewickFile treefile)
{
- this(seqs, treefile.getTree(), treefile.HasDistances(),
- treefile.HasBootstrap(), treefile.HasRootDistance());
+ this(seqs, treefile.getTree(), treefile.hasDistances(),
+ treefile.hasBootstrap(), treefile.hasRootDistance());
seqData = odata;
associateLeavesToSequences(seqs);
this(tree.getSequences(), tree.getTopNode(), tree.hasDistances(),
tree.hasBootstrap(), tree.hasRootDistance());
seqData = tree.getOriginalData();
+
}
/**
SequenceNode j;
SequenceI nam;
String realnam;
- Vector<SequenceI> one2many = new Vector<SequenceI>();
+ Vector<SequenceI> one2many = new Vector<>();
// int countOne2Many = 0;
while (i < leaves.size())
{
*/
public Vector<SequenceNode> findLeaves(SequenceNode nd)
{
- Vector<SequenceNode> leaves = new Vector<SequenceNode>();
+ Vector<SequenceNode> leaves = new Vector<>();
findLeaves(nd, leaves);
return leaves;
}
*/
public List<SequenceNode> groupNodes(float threshold)
{
- List<SequenceNode> groups = new ArrayList<SequenceNode>();
+ List<SequenceNode> groups = new ArrayList<>();
_groupNodes(groups, getTopNode(), threshold);
return groups;
}
{
// Set default view, paying lip service to any overriding tree view
// parameter settings
- boolean showDist = newtree.HasDistances()
+ boolean showDist = newtree.hasDistances()
&& av.applet.getDefaultParameter("showTreeDistances",
- newtree.HasDistances());
- boolean showBoots = newtree.HasBootstrap()
+ newtree.hasDistances());
+ boolean showBoots = newtree.hasBootstrap()
&& av.applet.getDefaultParameter("showTreeBootstraps",
- newtree.HasBootstrap());
+ newtree.hasBootstrap());
distanceMenu.setState(showDist);
bootstrapMenu.setState(showBoots);
treeCanvas.setShowBootstrap(showBoots);
--- /dev/null
+package jalview.ext.archaeopteryx;
+
+public class AlignToArchaeopteryxConverter
+{
+
+}
--- /dev/null
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.ext.archaeopteryx;
+
+import java.util.Collection;
+
+interface AlignToTreeViewerConverterI
+{
+ public void rootNode(Object node);
+
+ public Object makeTreeNode(String nodeName);
+
+ public Object addNodeChild(Object childNode, Object parentNode);
+
+ public Collection<?> getNodes();
+
+}
--- /dev/null
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+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 ArchaeopteryxNewickInit
+{
+ private String filePath = "/tmp/jalviewtree.nwk";
+
+ private TreeModel tree;
+
+ private NewickFile newickTree;
+
+ public ArchaeopteryxNewickInit(TreeModel jalviewTreeModel)
+ {
+ this.tree = jalviewTreeModel;
+ this.newickTree = treeToNewick(tree);
+ }
+
+ public ArchaeopteryxNewickInit(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);
+
+ 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());
+
+ return newickTree;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package jalview.ext.archaeopteryx;
+
+import jalview.analysis.TreeBuilder;
+import jalview.datamodel.SequenceI;
+import jalview.math.MatrixI;
+
+import org.forester.io.parsers.SymmetricalDistanceMatrixParser;
+import org.forester.msa.Msa;
+import org.forester.phylogeny.Phylogeny;
+import org.forester.phylogeny.PhylogenyNode;
+
+public class ArchaeopteryxTreeBuilder // cannot inherit
+ // TreeBuilder as that
+ // demands the use of
+ // SequenceNode (instead
+ // of PhylogenyNode)
+{
+ protected SequenceI[] sequences;
+
+ private Phylogeny aptxTree;
+
+ private PhylogenyNode rootNode;
+
+ protected MatrixI distances;
+
+ protected Msa msa;
+
+ protected SymmetricalDistanceMatrixParser distanceParser = SymmetricalDistanceMatrixParser
+ .createInstance();
+
+
+ public ArchaeopteryxTreeBuilder()
+ {
+
+ this.rootNode = new PhylogenyNode();
+ this.aptxTree = new Phylogeny();
+
+ }
+
+ public ArchaeopteryxTreeBuilder(PhylogenyNode treeRoot)
+ {
+
+ this.rootNode = treeRoot;
+ this.aptxTree = new Phylogeny();
+
+ }
+
+ public Phylogeny buildAptxTree(TreeBuilder tree)
+ {
+ this.sequences = tree.getSequences();
+ aptxTree.setName("word");
+ return buildAptxTree(sequences);
+
+ }
+
+ public Phylogeny buildAptxTree(SequenceI[] sequences)
+ {
+
+ for (SequenceI sequence : sequences)
+ {
+ PhylogenyNode treeNode = new PhylogenyNode();
+ treeNode.setName(sequence.getName());
+ rootNode.addAsChild(treeNode);
+
+ }
+
+ aptxTree.setRoot(rootNode);
+ return aptxTree;
+
+ }
+
+ /**
+ * Formats a localised title for the tree panel, like
+ * <p>
+ * Neighbour Joining Using BLOSUM62
+ * <p>
+ * For a tree loaded from file, just uses the file name
+ *
+ * @return
+ */
+ // public String getPanelTitle()
+ // {
+ // if (treeTitle != null)
+ // {
+ // return treeTitle;
+ // }
+ // else
+ // {
+ // /*
+ // * i18n description of Neighbour Joining or Average Distance method
+ // */
+ // String treecalcnm = MessageManager
+ // .getString("label.tree_calc_" + treeType.toLowerCase());
+ //
+ // /*
+ // * short score model name (long description can be too long)
+ // */
+ // String smn = substitutionMatrix;
+ //
+ // /*
+ // * put them together as <method> Using <model>
+ // */
+ // final String ttl = MessageManager
+ // .formatMessage("label.treecalc_title", treecalcnm, smn);
+ // return ttl;
+ // }
+ // }
+}
--- /dev/null
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.ext.archaeopteryx;
+
+interface TreeViewerBindingI
+{
+
+}
import jalview.analysis.Dna;
import jalview.analysis.ParseProperties;
import jalview.analysis.SequenceIdMatcher;
+import jalview.analysis.TreeModel;
import jalview.api.AlignExportSettingI;
import jalview.api.AlignViewControllerGuiI;
import jalview.api.AlignViewControllerI;
import jalview.api.FeatureSettingsControllerI;
import jalview.api.SplitContainerI;
import jalview.api.ViewStyleI;
-import jalview.api.analysis.SimilarityParamsI;
import jalview.bin.Cache;
import jalview.bin.Jalview;
import jalview.commands.CommandI;
viewport.followSelection = listenToViewSelections.isSelected();
}
+
/**
* Constructs a tree panel and adds it to the desktop
*
- * @param type
- * tree type (NJ or AV)
- * @param modelName
- * name of score model used to compute the tree
- * @param options
- * parameters for the distance or similarity calculation
+ * @param params
+ * @param treeAlgo
+ *
+ * @param tree
+ *
+ *
*/
- void newTreePanel(String type, String modelName,
- SimilarityParamsI options)
+ void newTreePanel(TreeModel tree, String treeAlgo,
+ String substitutionMatrix)
{
String frameTitle = "";
TreePanel tp;
}
}
- tp = new TreePanel(alignPanel, type, modelName, options);
+ tp = new TreePanel(alignPanel, tree, treeAlgo, substitutionMatrix);
frameTitle = tp.getPanelTitle() + (onSelection ? " on region" : "");
frameTitle += " from ";
final JMenu seqsrchmenu = new JMenu("Sequence Database Search");
final JMenu analymenu = new JMenu("Analysis");
final JMenu dismenu = new JMenu("Protein Disorder");
+ final JMenu phylogenmenu = new JMenu("Phylogenetic inference");
+
// JAL-940 - only show secondary structure prediction services from
// the legacy server
if (// Cache.getDefault("SHOW_JWS1_SERVICES", true)
wsmenu.add(secstrmenu);
wsmenu.add(dismenu);
wsmenu.add(analymenu);
+ wsmenu.add(phylogenmenu);
// No search services yet
// wsmenu.add(seqsrchmenu);
package jalview.gui;
import jalview.analysis.TreeBuilder;
+import jalview.analysis.TreeCalculator;
+import jalview.analysis.TreeModel;
import jalview.analysis.scoremodels.ScoreModels;
import jalview.analysis.scoremodels.SimilarityParams;
import jalview.api.analysis.ScoreModelI;
import jalview.api.analysis.SimilarityParamsI;
import jalview.datamodel.SequenceGroup;
+import jalview.ext.archaeopteryx.ArchaeopteryxTreeBuilder;
import jalview.util.MessageManager;
import java.awt.BorderLayout;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
+import org.forester.archaeopteryx.Archaeopteryx;
+import org.forester.phylogeny.Phylogeny;
+
/**
* A dialog where a user can choose and action Tree or PCA calculation options
*/
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,
protected void calculate_actionPerformed()
{
boolean doPCA = pca.isSelected();
- String modelName = modelNames.getSelectedItem().toString();
+ String substitutionMatrix = modelNames.getSelectedItem().toString();
SimilarityParamsI params = getSimilarityParameters(doPCA);
if (doPCA)
{
- openPcaPanel(modelName, params);
+ openPcaPanel(substitutionMatrix, params);
}
else
{
- openTreePanel(modelName, params);
+
+ String treeAlgo = determineTreeAlgo();
+ TreeCalculator treeCalculator = new TreeCalculator(treeAlgo,
+ substitutionMatrix, params);
+ TreeBuilder calculatedTree = treeCalculator
+ .makeTree(af.getViewport());
+ TreeModel tree = new TreeModel(calculatedTree);
+ openTreePanel(tree, treeAlgo, substitutionMatrix);
+
+ ArchaeopteryxTreeBuilder aptxTreeBuilder = new ArchaeopteryxTreeBuilder();
+ Phylogeny aptxTree = aptxTreeBuilder.buildAptxTree(calculatedTree);
+ Archaeopteryx.createApplication(aptxTree);
+
+
}
// closeFrame();
}
- /**
- * Open a new Tree panel on the desktop
- *
- * @param modelName
- * @param params
- */
- protected void openTreePanel(String modelName, SimilarityParamsI params)
+ 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;
}
+ }
- String treeType = neighbourJoining.isSelected()
- ? TreeBuilder.NEIGHBOUR_JOINING
- : TreeBuilder.AVERAGE_DISTANCE;
- af.newTreePanel(treeType, modelName, params);
+ /**
+ * Open a new Tree panel on the desktop
+ *
+ * @param tree
+ * @param params
+ * @param treeAlgo
+ */
+ protected void openTreePanel(TreeModel tree, String treeAlgo,
+ String substitutionMatrix)
+ {
+ /*
+ * 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());
+
+ af.newTreePanel(tree, treeAlgo, substitutionMatrix);
}
/**
*/
boolean matchGap = doPCA ? false : treeMatchGaps;
+
return new SimilarityParams(includeGapGap, matchGap, includeGapResidue,
matchOnShortestLength);
}
package jalview.gui;
import jalview.analysis.AlignmentSorter;
-import jalview.analysis.AverageDistanceTree;
-import jalview.analysis.NJTree;
-import jalview.analysis.TreeBuilder;
import jalview.analysis.TreeModel;
-import jalview.analysis.scoremodels.ScoreModels;
-import jalview.api.analysis.ScoreModelI;
-import jalview.api.analysis.SimilarityParamsI;
import jalview.bin.Cache;
import jalview.commands.CommandI;
import jalview.commands.OrderCommand;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
import jalview.datamodel.SequenceNode;
+import jalview.ext.archaeopteryx.ArchaeopteryxNewickInit;
import jalview.io.JalviewFileChooser;
import jalview.io.JalviewFileView;
import jalview.io.NewickFile;
*/
public class TreePanel extends GTreePanel
{
- String treeType;
+ String substitutionMatrix;
- String scoreModelName; // if tree computed
+ String treeType;
String treeTitle; // if tree loaded
- SimilarityParamsI similarityParams;
-
TreeCanvas treeCanvas;
TreeModel tree;
* Creates a new TreePanel object.
*
* @param ap
- * @param type
- * @param modelName
- * @param options
+ * @param tree
+ * @param treeType
+ * @param substitutionMatrix
*/
- public TreePanel(AlignmentPanel ap, String type, String modelName,
- SimilarityParamsI options)
+ public TreePanel(AlignmentPanel ap, TreeModel tree, String treeType,
+ String substitutionMatrix)
{
super();
- this.similarityParams = options;
- initTreePanel(ap, type, modelName, null, null);
+ this.treeType = treeType;
+ this.substitutionMatrix = substitutionMatrix;
+ this.tree = tree;
+ initNewTreePanel(ap, tree);
// We know this tree has distances. JBPNote TODO: prolly should add this as
// a userdefined default
// showDistances(true);
}
+ /**
+ * Creates a new TreePanel object.
+ *
+ * @param alignPanel
+ * @param newtree
+ * @param theTitle
+ * @param inputData
+ */
public TreePanel(AlignmentPanel alignPanel, NewickFile newtree,
String theTitle, AlignmentView inputData)
{
super();
this.treeTitle = theTitle;
- initTreePanel(alignPanel, null, null, newtree, inputData);
+ initLoadedTreePanel(alignPanel, newtree, inputData);
}
public AlignmentI getAlignment()
return treeCanvas.av;
}
- void initTreePanel(AlignmentPanel ap, String type, String modelName,
+ void initNewTreePanel(AlignmentPanel ap, TreeModel tree)
+ {
+ buildTreeCanvas(ap);
+
+ TreeLoader tl = new TreeLoader(null, null);
+ tl.start();
+
+ }
+ void initLoadedTreePanel(AlignmentPanel ap,
NewickFile newTree, AlignmentView inputData)
{
+ buildTreeCanvas(ap);
- av = ap.av;
- this.treeType = type;
- this.scoreModelName = modelName;
+ TreeLoader tl = new TreeLoader(newTree, inputData);
+ tl.start();
+ }
+
+public void buildTreeCanvas(AlignmentPanel ap) {
+ av = ap.av;
treeCanvas = new TreeCanvas(this, ap, scrollPane);
scrollPane.setViewportView(treeCanvas);
+
PaintRefresher.Register(this, ap.av.getSequenceSetId());
buildAssociatedViewMenu();
}
});
- TreeLoader tl = new TreeLoader(newTree, inputData);
- tl.start();
+
+
}
class TreeLoader extends Thread
{
- private NewickFile newtree;
+ private NewickFile newTree;
private AlignmentView odata = null;
public TreeLoader(NewickFile newickFile, AlignmentView inputData)
{
- this.newtree = newickFile;
+ this.newTree = newickFile;
this.odata = inputData;
- if (newickFile != null)
+ if (newTree != null)
{
// Must be outside run(), as Jalview2XML tries to
// update distance/bootstrap visibility at the same time
- showBootstrap(newickFile.HasBootstrap());
- showDistances(newickFile.HasDistances());
+ showBootstrap(newTree.hasBootstrap());
+ showDistances(newTree.hasDistances());
+
}
+
}
@Override
public void run()
{
- if (newtree != null)
+ if (newTree != null)
{
tree = new TreeModel(av.getAlignment().getSequencesArray(), odata,
- newtree);
+ newTree);
if (tree.getOriginalData() == null)
{
originalSeqData.setVisible(false);
}
+
+
+
}
- else
- {
- ScoreModelI sm = ScoreModels.getInstance()
- .getScoreModel(scoreModelName, treeCanvas.ap);
- TreeBuilder njtree = treeType.equals(TreeBuilder.NEIGHBOUR_JOINING)
- ? new NJTree(av, sm, similarityParams)
- : new AverageDistanceTree(av, sm, similarityParams);
- tree = new TreeModel(njtree);
- showDistances(true);
- }
+ showTree(tree);
+ }
+
+ public void showTree(TreeModel tree)
+ {
tree.reCount(tree.getTopNode());
tree.findHeight(tree.getTopNode());
treeCanvas.setTree(tree);
treeCanvas.repaint();
+
av.setCurrentTree(tree);
if (av.getSortByTree())
{
sortByTree_actionPerformed();
}
+
+ ArchaeopteryxNewickInit archae = new ArchaeopteryxNewickInit(tree);
+ archae.startArchaeopteryx();
}
}
if (treeCanvas.applyToAllViews)
{
- final ArrayList<CommandI> commands = new ArrayList<CommandI>();
+ final ArrayList<CommandI> commands = new ArrayList<>();
for (AlignmentPanel ap : PaintRefresher
.getAssociatedPanels(av.getSequenceSetId()))
{
*
* @return
*/
- public String getPanelTitle()
+ public String getPanelTitle() // to be moved/fixed
{
if (treeTitle != null)
{
return treeTitle;
}
-
- /*
- * i18n description of Neighbour Joining or Average Distance method
- */
- String treecalcnm = MessageManager
- .getString("label.tree_calc_" + treeType.toLowerCase());
-
- /*
- * short score model name (long description can be too long)
- */
- String smn = scoreModelName;
-
- /*
- * put them together as <method> Using <model>
- */
- final String ttl = MessageManager.formatMessage("label.treecalc_title",
- treecalcnm, smn);
- return ttl;
+ else
+ {
+ /*
+ * i18n description of Neighbour Joining or Average Distance method
+ */
+ String treecalcnm = MessageManager
+ .getString("label.tree_calc_" + treeType.toLowerCase());
+
+ /*
+ * short score model name (long description can be too long)
+ */
+ String smn = substitutionMatrix;
+
+ /*
+ * put them together as <method> Using <model>
+ */
+ final String ttl = MessageManager
+ .formatMessage("label.treecalc_title", treecalcnm, smn);
+ return ttl;
+ }
}
}
--- /dev/null
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($Version-Rel$)
+ * Copyright (C) $Year-Rel$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.gui;
+
+/**
+ * @author kjvanderheide
+ *
+ */
+public class TreeParams implements OptsParametersContainerI
+{
+
+ @Override
+ public void refreshParamLayout()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void argSetModified(Object modifiedElement, boolean b)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+}
{
SequenceNode root;
- private boolean HasBootstrap = false;
+ private boolean hasBootstrap = false;
- private boolean HasDistances = false;
+ private boolean hasDistances = false;
- private boolean RootHasDistance = false;
+ private boolean rootHasDistance = false;
// File IO Flags
- boolean ReplaceUnderscores = false;
+ boolean replaceUnderscores = false;
boolean printRootInfo = true;
*/
public NewickFile(SequenceNode newtree, boolean bootstrap)
{
- HasBootstrap = bootstrap;
+ hasBootstrap = bootstrap;
root = newtree;
}
boolean distances)
{
root = newtree;
- HasBootstrap = bootstrap;
- HasDistances = distances;
+ hasBootstrap = bootstrap;
+ hasDistances = distances;
}
/**
boolean distances, boolean rootdistance)
{
root = newtree;
- HasBootstrap = bootstrap;
- HasDistances = distances;
- RootHasDistance = rootdistance;
+ hasBootstrap = bootstrap;
+ hasDistances = distances;
+ rootHasDistance = rootdistance;
}
/**
// @tree annotations
// These are set automatically by the reader
- public boolean HasBootstrap()
+ public boolean hasBootstrap()
{
- return HasBootstrap;
+ return hasBootstrap;
}
/**
*
* @return DOCUMENT ME!
*/
- public boolean HasDistances()
+ public boolean hasDistances()
{
- return HasDistances;
+ return hasDistances;
}
- public boolean HasRootDistance()
+ public boolean hasRootDistance()
{
- return RootHasDistance;
+ return rootHasDistance;
}
/**
{
if (nodename == null)
{
- if (ReplaceUnderscores)
+ if (replaceUnderscores)
{
nodename = uqnodename.stringMatched(1).replace('_', ' ');
}
{
bootstrap = (new Integer(nbootstrap.stringMatched(1)))
.intValue();
- HasBootstrap = true;
+ hasBootstrap = true;
} catch (Exception e)
{
Error = ErrorStringrange(Error, "Can't parse bootstrap value",
try
{
distance = (new Float(ndist.stringMatched(1))).floatValue();
- HasDistances = true;
+ hasDistances = true;
nodehasdistance = true;
} catch (Exception e)
{
// Write node info here
c.setName(nodename);
// Trees without distances still need a render distance
- c.dist = (HasDistances) ? distance : DefDistance;
+ c.dist = (hasDistances) ? distance : DefDistance;
// be consistent for internal bootstrap defaults too
- c.setBootstrap((HasBootstrap) ? bootstrap : DefBootstrap);
+ c.setBootstrap((hasBootstrap) ? bootstrap : DefBootstrap);
if (c == realroot)
{
- RootHasDistance = nodehasdistance; // JBPNote This is really
+ rootHasDistance = nodehasdistance; // JBPNote This is really
// UGLY!!! Ensure root node gets
// its given distance
}
{
// Find a place to put the leaf
SequenceNode newnode = new SequenceNode(null, c, nodename,
- (HasDistances) ? distance : DefDistance,
- (HasBootstrap) ? bootstrap : DefBootstrap, false);
+ (hasDistances) ? distance : DefDistance,
+ (hasBootstrap) ? bootstrap : DefBootstrap, false);
parseNHXNodeProps(c, commentString2);
commentString2 = null;
// Insert a dummy node for polytomy
// dummy nodes have distances
SequenceNode newdummy = new SequenceNode(null, c, null,
- (HasDistances ? 0 : DefDistance), 0, true);
+ (hasDistances ? 0 : DefDistance), 0, true);
newdummy.SetChildren(c.left(), newnode);
c.setLeft(newdummy);
}
// (root.right()!=null && root.isDummy())
root = (SequenceNode) root.right().detach(); // remove the imaginary root.
- if (!RootHasDistance)
+ if (!rootHasDistance)
{
- root.dist = (HasDistances) ? 0 : DefDistance;
+ root.dist = (hasDistances) ? 0 : DefDistance;
}
}
v = iv.intValue(); // jalview only does integer bootstraps
// currently
c.setBootstrap(v);
- HasBootstrap = true;
+ hasBootstrap = true;
}
// more codes here.
} catch (Exception e)
{
synchronized (this)
{
- boolean boots = this.HasBootstrap;
- this.HasBootstrap = withbootstraps;
+ boolean boots = this.hasBootstrap;
+ this.hasBootstrap = withbootstraps;
String rv = print();
- this.HasBootstrap = boots;
+ this.hasBootstrap = boots;
return rv;
}
{
synchronized (this)
{
- boolean dists = this.HasDistances;
- this.HasDistances = withdists;
+ boolean dists = this.hasDistances;
+ this.hasDistances = withdists;
String rv = print(withbootstraps);
- this.HasDistances = dists;
+ this.hasDistances = dists;
return rv;
}
private String printNodeField(SequenceNode c)
{
return ((c.getName() == null) ? "" : nodeName(c.getName()))
- + ((HasBootstrap) ? ((c.getBootstrap() > -1)
+ + ((hasBootstrap) ? ((c.getBootstrap() > -1)
? ((c.getName() != null ? " " : "") + c.getBootstrap())
: "") : "")
- + ((HasDistances) ? (":" + c.dist) : "");
+ + ((hasDistances) ? (":" + c.dist) : "");
}
/**
{
return (printRootInfo)
? (((root.getName() == null) ? "" : nodeName(root.getName()))
- + ((HasBootstrap)
+ + ((hasBootstrap)
? ((root.getBootstrap() > -1)
? ((root.getName() != null ? " " : "")
+ +root.getBootstrap())
: "")
: "")
- + ((RootHasDistance) ? (":" + root.dist) : ""))
+ + ((rootHasDistance) ? (":" + root.dist) : ""))
: "";
}
SequenceNode tree = nf.getTree();
AssertJUnit.assertTrue(stage + "Null Tree", tree != null);
stage = "Creating newick file from testTree " + treename;
- String gentree = new NewickFile(tree).print(nf.HasBootstrap(),
- nf.HasDistances());
+ String gentree = new NewickFile(tree).print(nf.hasBootstrap(),
+ nf.hasDistances());
AssertJUnit.assertTrue(stage + "Empty string generated",
gentree != null && gentree.trim().length() > 0);
stage = "Parsing regenerated testTree " + treename;