-Subproject commit 5642da5f473ab9ae57fee86c0cb3b33525a2e916
+Subproject commit 835739d782b7099677aadf653ecc682cf74fc87f
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.datamodel.SequenceNode;
+import jalview.ext.treeviewer.ExternalTreeI;
+import jalview.ext.treeviewer.ExternalTreeNodeI;
import jalview.util.QuickSort;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import org.forester.phylogeny.Phylogeny;
-import org.forester.phylogeny.PhylogenyNode;
-import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
-
/**
* Routines for manipulating the order of a multiple sequence alignment TODO:
* this class retains some global states concerning sort-order which should be
static TreeModel lastTree = null;
- static Phylogeny lastAptxTree = null;
+ static ExternalTreeI lastExternalTree = null;
static boolean sortTreeAscending = true;
- private static List<SequenceI> getOrderByTree(Phylogeny aptxTree,
- Map<PhylogenyNode, SequenceI> nodesWithBoundSeqs)
+ private static List<SequenceI> getOrderByTree(ExternalTreeI aptxTree,
+ Map<ExternalTreeNodeI, SequenceI> nodesWithBoundSeqs)
{
List<SequenceI> seqsByTreeOrder = new ArrayList<>();
if (!aptxTree.isEmpty())
{
- for (final PhylogenyNodeIterator iter = aptxTree
- .iteratorPreorder(); iter.hasNext();)
+ for (final Iterator<ExternalTreeNodeI> iter = aptxTree
+ .iterateInPreOrder(); iter.hasNext();)
{
- PhylogenyNode treeNode = iter.next();
+ ExternalTreeNodeI treeNode = iter.next();
seqsByTreeOrder.add(nodesWithBoundSeqs.get(treeNode));
}
* tree which has
*/
public static void sortByTree(AlignmentI align,
- Map<PhylogenyNode, SequenceI> aptxNodesWithSeqs,
- Phylogeny aptxTree) throws IllegalArgumentException
+ Map<ExternalTreeNodeI, SequenceI> nodesBoundToSequences,
+ ExternalTreeI externalTreeI) throws IllegalArgumentException
{
- List<SequenceI> tmp = getOrderByTree(aptxTree, aptxNodesWithSeqs);
+ List<SequenceI> tmp = getOrderByTree(externalTreeI, nodesBoundToSequences);
if (!tmp.isEmpty())
{
- if (lastAptxTree != aptxTree)
+ if (lastExternalTree != externalTreeI)
{
sortTreeAscending = true;
- lastAptxTree = aptxTree;
+ lastExternalTree = externalTreeI;
}
else
{
--- /dev/null
+package jalview.ext.archaeopteryx;
+
+import org.forester.archaeopteryx.Configuration;
+
+public class AptxConfig
+{
+ private final Configuration config;
+
+ public AptxConfig(Configuration aptxConfig)
+ {
+ config = aptxConfig;
+ }
+
+}
--- /dev/null
+package jalview.ext.archaeopteryx;
+
+import jalview.ext.treeviewer.ExternalTreeControlsI;
+
+import org.forester.archaeopteryx.ControlPanel;
+
+public class AptxControlPanel implements ExternalTreeControlsI
+{
+ ControlPanel aptxCp;
+
+ public AptxControlPanel(ControlPanel aptxControlPanel)
+ {
+ aptxCp = aptxControlPanel;
+
+ }
+
+ @Override
+ public void defaultSettings()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void displayEntireTree()
+ {
+ aptxCp.showWhole();
+
+ }
+
+}
package jalview.ext.archaeopteryx;
-import jalview.ext.treeviewer.ExternalTreePanelI;
-import jalview.ext.treeviewer.ExternalTreeViewerI;
+import jalview.ext.treeviewer.ExternalTreeControlsI;
+import jalview.ext.treeviewer.ExternalTreeFrame;
+import jalview.ext.treeviewer.ExternalTreeI;
+import jalview.ext.treeviewer.ExternalTreePanel;
+
+import java.awt.Component;
+
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.JSeparator;
import org.forester.archaeopteryx.MainFrame;
-public class Aptx implements ExternalTreeViewerI
+public class AptxFrame extends ExternalTreeFrame
{
- private final MainFrame aptxApp;
+ private final MainFrame aptxFrame;
- public Aptx(MainFrame aptx)
+ public AptxFrame(MainFrame aptx)
{
- aptxApp = aptx;
+ aptxFrame = aptx;
+ adaptAptxGui(aptxFrame);
+ }
+ /**
+ * Hides certain redundant Archaeopteryx GUI elements such as the menu items
+ * for reading in trees and adds extra items related to Jalview such as the
+ * tree sorting item.
+ *
+ *
+ * @param aptxFrame
+ */
+ private void adaptAptxGui(MainFrame aptxFrame)
+ {
+ JMenuBar frameBar = aptxFrame.getJMenuBar();
+ for (int i = 0; i < frameBar.getMenuCount(); i++)
+ {
+ JMenu menu = frameBar.getMenu(i);
+ if (menu.getText().startsWith("File"))
+ {
+ // hide all "Read from ..." and "New" menu items and any Separators that
+ // come directly after them
+ Component previousMenuItem = null;
+ for (Component menuItem : menu.getMenuComponents())
+ {
+ if (previousMenuItem instanceof JMenuItem)
+ {
+ if (((JMenuItem) previousMenuItem).getText().startsWith("Read")
+ || ((JMenuItem) previousMenuItem).getText()
+ .startsWith("New"))
+ {
+ previousMenuItem.setVisible(false);
+
+ if (menuItem instanceof JSeparator)
+ {
+ menuItem.setVisible(false);
+ }
+ }
+ }
+ previousMenuItem = menuItem;
+ }
+ }
+ else if (menu.getText().startsWith("Inference"))
+ {
+ menu.setVisible(false);
+ }
+ else if (menu.getText().startsWith("View"))
+ {
+ menu.addSeparator();
+ JMenuItem sortMenuItem = new JMenuItem("Sort alignment by tree");
+ sortMenuItem.setVisible(false);
+ menu.add(sortMenuItem);
+ }
+
+ }
+ aptxFrame.validate();
}
@Override
- public ExternalTreePanelI getTreePanel()
+ public ExternalTreePanel getTreePanel()
{
- ExternalTreePanelI aptxPanel = new AptxTreePanel(
- aptxApp.getMainPanel().getCurrentTreePanel());
+ ExternalTreePanel aptxPanel = new AptxTreePanel(
+ aptxFrame.getMainPanel().getCurrentTreePanel());
return aptxPanel;
}
-}
+
+ @Override
+ public void switchTreePanel(int panelIndex)
+ {
+ aptxFrame.getMainPanel().getTabbedPane().getTabComponentAt(panelIndex);
+
+ }
+
+ @Override
+ public ExternalTreeI getTree()
+ {
+ return new Tree(
+ aptxFrame.getMainPanel().getCurrentTreePanel().getPhylogeny());
+ }
+
+ @Override
+ public void checkMultipleTrees()
+ {
+ aptxFrame.activateSaveAllIfNeeded();
+
+ }
+
+ @Override
+ public int getNumberOfTrees()
+ {
+ return aptxFrame.getMainPanel().getTabbedPane().getTabCount();
+ }
+
+ @Override
+ public ExternalTreeControlsI getTreeControls()
+ {
+ return new AptxControlPanel(aptxFrame.getMainPanel().getControlPanel());
+ }
+}
\ No newline at end of file
import jalview.analysis.TreeBuilder;
import jalview.datamodel.SequenceI;
+import jalview.ext.treeviewer.ExternalLoadedTreeAssociationI;
import jalview.ext.treeviewer.ExternalTreeBuilderI;
+import jalview.ext.treeviewer.ExternalTreeFrame;
+import jalview.ext.treeviewer.ExternalTreeI;
+import jalview.ext.treeviewer.ExternalTreeNodeI;
import jalview.ext.treeviewer.ExternalTreeViewerBindingI;
import jalview.gui.Desktop;
import jalview.gui.JvOptionPane;
import jalview.util.MessageManager;
import jalview.viewmodel.AlignmentViewport;
-import java.awt.Component;
import java.awt.Dimension;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.Map;
-import javax.swing.JMenu;
-import javax.swing.JMenuBar;
-import javax.swing.JMenuItem;
-import javax.swing.JSeparator;
-
import org.forester.archaeopteryx.AptxUtil;
-import org.forester.archaeopteryx.Archaeopteryx;
import org.forester.archaeopteryx.Configuration;
-import org.forester.archaeopteryx.MainFrame;
import org.forester.archaeopteryx.webservices.PhylogeniesWebserviceClient;
import org.forester.archaeopteryx.webservices.WebserviceUtil;
import org.forester.io.parsers.PhylogenyParser;
import org.forester.io.parsers.util.ParserUtils;
import org.forester.phylogeny.Phylogeny;
import org.forester.phylogeny.PhylogenyMethods;
-import org.forester.phylogeny.PhylogenyNode;
import org.forester.phylogeny.data.Identifier;
import org.forester.util.ForesterUtil;
*/
public final class AptxInit
{
- private final static Configuration APTX_CONFIG = new Configuration(
+ public final static Configuration APTX_CONFIG = new Configuration(
"_aptx_jalview_configuration_file",
false, false, false);
private final static NHXParser.TAXONOMY_EXTRACTION TAXONOMY_EXTRACTION = APTX_CONFIG
.getTaxonomyExtraction();
- private static Map<MainFrame, JalviewBinding> activeAptx = new HashMap<>();
+ private static Map<ExternalTreeFrame, ExternalTreeViewerBindingI> activeAptx = new HashMap<>();
- public static MainFrame createInstanceFromCalculation(
+ public static ExternalTreeFrame createInstanceFromCalculation(
final TreeBuilder calculatedTree)
{
- ExternalTreeBuilderI<Phylogeny, PhylogenyNode> aptxTreeBuilder = new AptxTreeBuilder(
+ ExternalTreeBuilderI aptxTreeBuilder = new AptxTreeBuilder(
calculatedTree);
- Phylogeny aptxTree = aptxTreeBuilder.buildTree();
+ ExternalTreeI aptxTree = aptxTreeBuilder.buildTree();
- MainFrame aptxApp = createAptxFrame(aptxTree,
+ ExternalTreeFrame aptxApp = createAptxFrame(aptxTree,
calculatedTree.getAvport(), null);
return aptxApp;
* @throws IOException
* @throws FileNotFoundException
*/
- public static MainFrame[] createInstancesFromFile(String filePath,
+ public static ExternalTreeFrame[] createInstancesFromFile(
+ String filePath,
AlignmentViewport viewport)
throws FileNotFoundException, IOException
{
Desktop.instance.startLoading(filePath);
}
boolean nhx_or_nexus = false;
- final PhylogenyParser parser = ParserUtils.createParserDependingOnFileType(
+ final PhylogenyParser parser = ParserUtils
+ .createParserDependingOnFileType(
treeFile, VALIDATE_PHYLOXML_XSD);
if (parser instanceof NHXParser)
{
JvOptionPane.WARNING_MESSAGE );
}
}
- Phylogeny[] trees = PhylogenyMethods.readPhylogenies(parser, treeFile);
- MainFrame[] aptxFrames = new MainFrame[trees.length];
+ Phylogeny[] trees = PhylogenyMethods.readPhylogenies(parser,
+ treeFile);
+ ExternalTreeFrame[] aptxFrames = new ExternalTreeFrame[trees.length];
for (int i = 0; i < trees.length; i++)
{
- Phylogeny tree = trees[i];
+ Phylogeny aptxPhylogeny = trees[i];
if (nhx_or_nexus && INTERNAL_NUMBERS_AS_CONFIDENCE)
{
- PhylogenyMethods.transferInternalNodeNamesToConfidence(tree, "");
+ PhylogenyMethods.transferInternalNodeNamesToConfidence(aptxPhylogeny,
+ "");
}
String treeTitle = treeFile.getName() + "[" + i + "]";
- tree.setName(treeTitle);
- aptxFrames[i] = createAptxFrame(tree, viewport, treeTitle);
+ aptxPhylogeny.setName(treeTitle);
+ Tree aptxTree = new Tree(aptxPhylogeny);
+ aptxFrames[i] = createAptxFrame(aptxTree, viewport, treeTitle);
}
if (Desktop.instance != null)
}
- public static MainFrame[] createInstancesFromUrl(URL treeUrl,
+ public static ExternalTreeFrame[] createInstancesFromUrl(URL treeUrl,
AlignmentViewport viewport)
throws FileNotFoundException, IOException, RuntimeException
{
REPLACE_NHX_UNDERSCORES, INTERNAL_NUMBERS_AS_CONFIDENCE,
TAXONOMY_EXTRACTION, MIDPOINT_REROOT);
- MainFrame[] aptxFrames = new MainFrame[trees.length];
+ ExternalTreeFrame[] aptxFrames = new ExternalTreeFrame[trees.length];
for (int i = 0; i < trees.length; i++)
{
- Phylogeny tree = trees[i];
- aptxFrames[i] = createAptxFrame(tree, viewport, treeTitle);
+ Phylogeny aptxTree = trees[i];
+ Tree jalviewTree = new Tree(aptxTree);
+ aptxFrames[i] = createAptxFrame(jalviewTree, viewport, treeTitle);
}
if (Desktop.instance != null)
* @param viewport
* @return
*/
- public static MainFrame[] createInstancesFromDb(
+ public static ExternalTreeFrame[] createInstancesFromDb(
PhylogeniesWebserviceClient treeDbClient, String identifier,
AlignmentViewport viewport)
{
{ identifier }),
MessageManager.getString("label.invalid_url"),
JvOptionPane.ERROR_MESSAGE);
- return new MainFrame[0];
+ return new ExternalTreeFrame[0];
}
identifier = id + "";
}
}
if ((trees != null) && (trees.length > 0))
{
- for (final Phylogeny phylogeny : trees)
+ for (final Phylogeny aptxTree : trees)
{
- if (!phylogeny.isEmpty())
+ if (!aptxTree.isEmpty())
{
if (treeDbClient.getName().equals(WebserviceUtil.TREE_FAM_NAME))
{
- phylogeny.setRerootable(false);
- phylogeny.setRooted(true);
+ aptxTree.setRerootable(false);
+ aptxTree.setRooted(true);
}
if (treeDbClient.getProcessingInstructions() != null)
{
try
{
- WebserviceUtil.processInstructions(treeDbClient, phylogeny);
+ WebserviceUtil.processInstructions(treeDbClient,
+ aptxTree);
} catch (final PhyloXmlDataFormatException e)
{
JvOptionPane.showInternalMessageDialog(Desktop.desktop,
{
try
{
- PhylogenyMethods.transferNodeNameToField(phylogeny,
+ PhylogenyMethods.transferNodeNameToField(aptxTree,
treeDbClient.getNodeField(), false);
} catch (final PhyloXmlDataFormatException e)
{
JvOptionPane.ERROR_MESSAGE);
}
}
- phylogeny.setIdentifier(
+ aptxTree.setIdentifier(
new Identifier(identifier, treeDbClient.getName()));
// _main_frame.getJMenuBar().remove(_main_frame.getHelpMenu());
- // _main_frame.getMenuBarOfMainFrame()
+ // _main_frame.getMenuBarOfExternalTreeFrameI()
// .add(_main_frame.getHelpMenu());
- // _main_frame.getMainPanel().addPhylogenyInNewTab(phylogeny,
+ // _main_frame.getMainPanel().addExternalTreeIInNewTab(ExternalTreeI,
// _main_frame.getConfiguration(),
// new File(url.getFile()).getName(), url.toString());
- MainFrame aptxApp = createAptxFrame(phylogeny, viewport,
+ Tree jalviewTree = new Tree(aptxTree);
+
+ ExternalTreeFrame aptxApp = createAptxFrame(jalviewTree,
+ viewport,
url.getFile());
String my_name_for_file = "";
- if (!ForesterUtil.isEmpty(phylogeny.getName()))
+ if (!ForesterUtil.isEmpty(jalviewTree.getTreeName()))
{
- my_name_for_file = new String(phylogeny.getName())
+ my_name_for_file = new String(jalviewTree.getTreeName())
.replaceAll(" ", "_");
}
- else if (phylogeny.getIdentifier() != null)
+ else if (aptxTree.getIdentifier() != null)
{
final StringBuffer sb = new StringBuffer();
if (!ForesterUtil
- .isEmpty(phylogeny.getIdentifier().getProvider()))
+ .isEmpty(aptxTree.getIdentifier().getProvider()))
{
- sb.append(phylogeny.getIdentifier().getProvider());
+ sb.append(aptxTree.getIdentifier().getProvider());
sb.append("_");
}
- sb.append(phylogeny.getIdentifier().getValue());
+ sb.append(aptxTree.getIdentifier().getValue());
my_name_for_file = new String(
sb.toString().replaceAll(" ", "_"));
}
- aptxApp.getMainPanel().getCurrentTreePanel()
+ aptxApp.getTreePanel()
.setTreeFile(new File(my_name_for_file));
- AptxUtil.lookAtSomeTreePropertiesForAptxControlSettings(
- phylogeny, aptxApp.getMainPanel().getControlPanel(),
- APTX_CONFIG);
- // _main_frame.getMainPanel().getControlPanel().showWhole();
+ // AptxUtil.lookAtSomeTreePropertiesForAptxControlSettings(
+ // aptxTree, aptxApp.getMainPanel().getControlPanel(),
+ // APTX_CONFIG);
+ aptxApp.getTreeControls().displayEntireTree();
- aptxApp.activateSaveAllIfNeeded();
+ aptxApp.checkMultipleTrees();
}
}
}
- public static MainFrame createAptxFrame(
- final Phylogeny aptxTree,
+ public static ExternalTreeFrame createAptxFrame(
+ final ExternalTreeI aptxTree,
final AlignmentViewport jalviewAlignport, String treeTitle)
{
if (APTX_CONFIG == null || APTX_CONFIG.isCouldReadConfigFile() == false)
}
}
- MainFrame aptxApp = Archaeopteryx.createApplication(aptxTree,
- APTX_CONFIG, treeTitle);
+ ExternalTreeFrame aptxApp = aptxTree.createInstanceFromTree(treeTitle);
- adaptAptxGui(aptxApp);
- LoadedTreeSequenceAssociation bindAptxNodes = new LoadedTreeSequenceAssociation(
+ ExternalLoadedTreeAssociationI bindAptxNodes = new LoadedTreeSequenceAssociation(
jalviewAlignport.getAlignment().getSequencesArray(), aptxTree);
bindAptxNodes.associateLeavesToSequences();
bindAptxNodes.getNodesWithAlignment());
bindTreeViewFrameToJalview(aptxApp);
+ // adaptAptxGui(aptxApp); //moved to AptxFrame
return aptxApp;
}
- public static ExternalTreeViewerBindingI<?> bindNodesToJalviewSequences(
- final MainFrame aptxApp,
+ public static ExternalTreeViewerBindingI bindNodesToJalviewSequences(
+ final ExternalTreeFrame aptxApp,
final AlignmentViewport jalviewAlignViewport,
- final Map<SequenceI, PhylogenyNode> alignMappedToNodes,
- final Map<PhylogenyNode, SequenceI> nodesMappedToAlign)
+ final Map<SequenceI, ExternalTreeNodeI> alignMappedToNodes,
+ final Map<ExternalTreeNodeI, SequenceI> nodesMappedToAlign)
{
JalviewBinding treeBinding = new JalviewBinding(aptxApp,
jalviewAlignViewport,
}
- public static MainFrame bindTreeViewFrameToJalview(
- final MainFrame aptxApp)
+ public static ExternalTreeFrame bindTreeViewFrameToJalview(
+ final ExternalTreeFrame aptxApp)
{
int width = 400;
int height = 550;
// aptxApp.setFont(Desktop.instance.getFont());
// aptxApp.getMainPanel().setFont(Desktop.instance.getFont());
String frameTitle = MessageManager.getString("label.aptx_title");
- File treeFile = aptxApp.getMainPanel().getCurrentTreePanel()
- .getTreeFile();
+ File treeFile = aptxApp.getTreePanel().getTreeFile();
if (treeFile != null)
{
frameTitle += MessageManager.formatMessage("label.aptx_title_append",
}
- /**
- * Hides certain redundant Archaeopteryx GUI elements such as the menu items
- * for reading in trees and adds extra items related to Jalview such as the
- * tree sorting item.
- *
- *
- * @param aptxFrame
- */
- private static void adaptAptxGui(MainFrame aptxFrame)
- {
- JMenuBar frameBar = aptxFrame.getJMenuBar();
- for (int i = 0; i < frameBar.getMenuCount();i++) {
- JMenu menu = frameBar.getMenu(i);
-
- if (menu.getText().contains("File"))
- {
- // hide all "Read from ..." and "New" menu items and any Separators that
- // come directly after them
- Component previousMenuItem = null;
- for (Component menuItem : menu.getMenuComponents()) {
- if (previousMenuItem instanceof JMenuItem)
- {
- if (((JMenuItem) previousMenuItem).getText().startsWith("Read")
- || ((JMenuItem) previousMenuItem).getText()
- .startsWith("New"))
- {
- previousMenuItem.setVisible(false);
-
- if (menuItem instanceof JSeparator)
- {
- menuItem.setVisible(false);
- }
- }
- }
- previousMenuItem = menuItem;
- }
- }
- else if (menu.getText().contains("Inference"))
- {
- menu.setVisible(false);
- }
- else if (menu.getText().contains("View"))
- {
- menu.addSeparator();
- menu.add(new JMenuItem("Sort alignment by tree"));
- }
-
- }
- aptxFrame.validate();
- }
- public static Map<MainFrame, JalviewBinding> getAllAptxFrames()
+ public static Map<ExternalTreeFrame, ExternalTreeViewerBindingI> getAllAptxFrames()
{
return activeAptx;
}
import jalview.analysis.TreeBuilder;
import jalview.datamodel.SequenceI;
-import jalview.ext.forester.DataConversions;
import jalview.ext.forester.ForesterMatrix;
import jalview.ext.treeviewer.ExternalTreeBuilderI;
+import jalview.ext.treeviewer.ExternalTreeI;
+import jalview.ext.treeviewer.ExternalTreeNodeI;
import jalview.util.MappingUtils;
import jalview.util.MessageManager;
import org.forester.evoinference.matrix.distance.DistanceMatrix;
import org.forester.phylogeny.Phylogeny;
import org.forester.phylogeny.PhylogenyNode;
-import org.forester.phylogeny.data.NodeData;
-import org.forester.phylogeny.data.Sequence;
/**
* Class for converting trees made in Jalview (through TreeBuilder) to trees
*
*/
public class AptxTreeBuilder
- implements ExternalTreeBuilderI<Phylogeny, PhylogenyNode>
+ implements ExternalTreeBuilderI
{
protected final SequenceI[] sequences;
public String treeTitle;
- private final Phylogeny aptxTree;
+ private final ExternalTreeI aptxTree;
- private PhylogenyNode rootNode;
+ private ExternalTreeNodeI rootNode;
- private final Map<SequenceI, PhylogenyNode> alignmentWithNodes;
+ private final Map<SequenceI, ExternalTreeNodeI> alignmentWithNodes;
- private final Map<PhylogenyNode, SequenceI> nodesWithAlignment;
+ private final Map<ExternalTreeNodeI, SequenceI> nodesWithAlignment;
public AptxTreeBuilder(final TreeBuilder calculatedTree)
{
distances = ForesterMatrix.convertJalviewToForester(
jalviewTree.getDistances(), sequences);
- aptxTree = new Phylogeny();
- rootNode = new PhylogenyNode();
+ aptxTree = new Tree(new Phylogeny());
+ rootNode = new TreeNode(new PhylogenyNode());
int amountOfSequences = distances.getSize();
alignmentWithNodes = new HashMap<>(amountOfSequences);
}
@Override
- public Phylogeny buildTree(final PhylogenyNode treeRoot)
+ public ExternalTreeI buildTree(final ExternalTreeNodeI treeRoot)
{
if (treeRoot != null)
@Override
- public Phylogeny buildTree()
+ public ExternalTreeI buildTree()
{
for (SequenceI sequence : sequences)
{
- Sequence seq = DataConversions
- .createForesterSequence(sequence, true);
- PhylogenyNode sequenceNode = new PhylogenyNode(sequence.getName());
- NodeData nodeData = sequenceNode.getNodeData();
- nodeData.setSequence(seq);
+ ExternalTreeNodeI sequenceNode = new TreeNode(
+ new PhylogenyNode(sequence.getName()));
+
+ sequenceNode.setSequence(sequence);
MappingUtils.putWithDuplicationCheck(nodesWithAlignment,
sequenceNode, sequence);
aptxTree.setRoot(rootNode);
treeTitle = generateTreeName();
- aptxTree.setName(treeTitle);
+ aptxTree.setTreeName(treeTitle);
return aptxTree;
}
@Override
- public Map<SequenceI, PhylogenyNode> getAlignmentBoundNodes()
+ public Map<SequenceI, ExternalTreeNodeI> getAlignmentBoundNodes()
{
return alignmentWithNodes;
}
@Override
- public Map<PhylogenyNode, SequenceI> getNodesBoundAlignment()
+ public Map<ExternalTreeNodeI, SequenceI> getNodesBoundAlignment()
{
return nodesWithAlignment;
}
- private Phylogeny clusterNodes()
- {
- return aptxTree;
- }
/**
* Formats a localised title for the tree panel, like
* <p>
return ttl;
}
}
+
+
}
package jalview.ext.archaeopteryx;
-import jalview.ext.treeviewer.ExternalTreePanelI;
+import jalview.ext.treeviewer.ExternalTreeI;
+import jalview.ext.treeviewer.ExternalTreeNodeI;
+import jalview.ext.treeviewer.ExternalTreePanel;
-public class AptxTreePanel implements ExternalTreePanelI
+import java.io.File;
+import java.util.Set;
+
+public class AptxTreePanel extends ExternalTreePanel
{
private final org.forester.archaeopteryx.TreePanel treeView;
treeView = aptxTreePanel;
}
+
+ @Override
+ public void setTreeFile(File file)
+ {
+ treeView.setTreeFile(file);
+ }
+
+ @Override
+ public ExternalTreeI getTree()
+ {
+ return new Tree(treeView.getPhylogeny());
+ }
+
+ @Override
+ public File getTreeFile()
+ {
+ return treeView.getTreeFile();
+ }
+
+ @Override
+ public ExternalTreeNodeI findNode(int x, int y)
+ {
+ return new TreeNode(treeView.findNode(x, y));
+ }
+
+ @Override
+ public void setMatchingNodes(Set<Long> hashSet)
+ {
+ treeView.setFoundNodes0(hashSet);
+
+ }
+
+ @Override
+ public Set<Long> getMatchingNodes()
+ {
+ return treeView.getFoundNodes0();
+ }
}
import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
+import jalview.ext.treeviewer.ExternalTreeFrame;
+import jalview.ext.treeviewer.ExternalTreeI;
+import jalview.ext.treeviewer.ExternalTreeNodeI;
+import jalview.ext.treeviewer.ExternalTreePanel;
import jalview.ext.treeviewer.ExternalTreeViewerBindingI;
import jalview.gui.AlignViewport;
import jalview.gui.AlignmentPanel;
import java.util.Map;
import java.util.Set;
-import javax.swing.JTabbedPane;
import javax.swing.SwingUtilities;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
-import org.forester.archaeopteryx.MainFrame;
-import org.forester.phylogeny.Phylogeny;
-import org.forester.phylogeny.PhylogenyMethods;
-import org.forester.phylogeny.PhylogenyNode;
-import org.forester.phylogeny.data.BranchColor;
-
/**
* Class for binding the Archaeopteryx tree viewer to the Jalview alignment that
* it originates from, meaning that selecting sequences in the tree viewer also
*
*/
public final class JalviewBinding
- implements ExternalTreeViewerBindingI<PhylogenyNode>
+ implements ExternalTreeViewerBindingI
{
- private final MainFrame aptxFrame;
+ private final ExternalTreeFrame aptxFrame;
- private org.forester.archaeopteryx.TreePanel treeView;
+ private ExternalTreePanel treeView;
private AlignmentViewport parentAvport;
- private final JTabbedPane treeTabs;
-
private final StructureSelectionManager ssm;
private AlignmentPanel[] associatedPanels;
- private Map<SequenceI, PhylogenyNode> sequencesBoundToNodes;
+ private Map<SequenceI, ExternalTreeNodeI> sequencesBoundToNodes;
- private Map<PhylogenyNode, SequenceI> nodesBoundToSequences;
+ private Map<ExternalTreeNodeI, SequenceI> nodesBoundToSequences;
private float rootX;
* map with tree nodes and matching sequences used to calculate the
* tree as key, value pair respectively.
*/
- public JalviewBinding(final MainFrame archaeopteryx,
+ public JalviewBinding(final ExternalTreeFrame archaeopteryx,
final AlignmentViewport jalviewAlignmentViewport,
- final Map<SequenceI, PhylogenyNode> alignMappedToNodes,
- final Map<PhylogenyNode, SequenceI> nodesMappedToAlign)
+ final Map<SequenceI, ExternalTreeNodeI> alignMappedToNodes,
+ final Map<ExternalTreeNodeI, SequenceI> nodesMappedToAlign)
{
- if (archaeopteryx.getMainPanel().getTabbedPane().getTabCount() > 1)
+ if (archaeopteryx.getNumberOfTrees() > 1)
{
JvOptionPane.showMessageDialog(Desktop.desktop,
MessageManager.getString("label.tabs_detected_archaeopteryx"),
sequencesBoundToNodes = alignMappedToNodes;
nodesBoundToSequences = nodesMappedToAlign;
- treeView = archaeopteryx.getMainPanel().getCurrentTreePanel();
- treeTabs = archaeopteryx.getMainPanel().getTabbedPane();
+ treeView = archaeopteryx.getTreePanel();
ssm = parentAvport.getStructureSelectionManager();
ssm.addSelectionListener(this);
});
- treeTabs.addChangeListener(new ChangeListener()
- {
-
- @Override
- public void stateChanged(ChangeEvent e)
- {
-
- SwingUtilities.invokeLater(new Runnable()
- {
-
- @Override
- /**
- * Resend the selection to the tree view when tabs get switched, this
- * has to be buried in invokeLater as Forester first resets the tree
- * view on switching tabs, without invokeLater this would get called
- * before Forester resets which would nullify the selection.
- */
- public void run()
- {
- treeView = archaeopteryx.getMainPanel().getCurrentTreePanel();
- parentAvport.sendSelection();
- // PaintRefresher.Refresh(treeView,
- // parentAvport.getSequenceSetId());
-
- }
- });
-
- }
-
- });
+ // treeTabs.addChangeListener(new ChangeListener()
+ // {
+ //
+ // @Override
+ // public void stateChanged(ChangeEvent e)
+ // {
+ //
+ // SwingUtilities.invokeLater(new Runnable()
+ // {
+ //
+ // @Override
+ // /**
+ // * Resend the selection to the tree view when tabs get switched, this
+ // * has to be buried in invokeLater as Forester first resets the tree
+ // * view on switching tabs, without invokeLater this would get called
+ // * before Forester resets which would nullify the selection.
+ // */
+ // public void run()
+ // {
+ // treeView = archaeopteryx.getMainPanel().getCurrentTreePanel();
+ // parentAvport.sendSelection();
+ // // PaintRefresher.Refresh(treeView,
+ // // parentAvport.getSequenceSetId());
+ //
+ // }
+ // });
+ //
+ // }
+ //
+ // });
}
*/
public void run()
{
- final PhylogenyNode node = treeView.findNode(e.getX(), e.getY());
+ final ExternalTreeNodeI node = treeView.findNode(e.getX(),
+ e.getY());
if (node != null)
{
if ((e.getModifiers() & InputEvent.SHIFT_MASK) == 0) // clear previous
if (source == parentAvport) // check if source is alignment from where the
// tree originates
{
- treeView.setFoundNodes0(
+ treeView.setMatchingNodes(
new HashSet<Long>(seqsel.getSequences().size()));
for (SequenceI selectedSequence : seqsel.getSequences())
{
- PhylogenyNode matchingNode = sequencesBoundToNodes.get(selectedSequence);
+ ExternalTreeNodeI matchingNode = sequencesBoundToNodes
+ .get(selectedSequence);
if (matchingNode != null)
{
- treeView.getFoundNodes0().add(matchingNode.getId());
+ treeView.getMatchingNodes().add(matchingNode.getId());
- if (!matchingNode.getBranchData().isHasBranchColor())
- {
- // Color foundNodesColour = treeView.getTreeColorSet()
- // .getFoundColor0();
- // matchingNode.getBranchData()
- // .setBranchColor(new BranchColor(foundNodesColour));
-
- }
+ // if (!matchingNode.getBranchData().isHasBranchColor())
+ // {
+ // // Color foundNodesColour = treeView.getTreeColorSet()
+ // // .getFoundColor0();
+ // // matchingNode.getBranchData()
+ // // .setBranchColor(new BranchColor(foundNodesColour));
+ //
+ // }
}
*/
public void partitionTree(final int x)
{
- Phylogeny tree = treeView.getPhylogeny();
+ ExternalTreeI tree = treeView.getTree();
if (!tree.isEmpty())
{
// should be calculated on each partition as the tree can theoretically
// change in the meantime
- PhylogenyNode furthestNode = PhylogenyMethods
- .calculateNodeWithMaxDistanceToRoot(tree);
+ ExternalTreeNodeI furthestNode = tree.getFurthestNode();
furthestNodeX = furthestNode.getXcoord();
rootX = tree.getRoot().getXcoord();
if (furthestNodeX != rootX && !(x > furthestNodeX))
{
float threshold = (x - rootX) / (furthestNodeX - rootX);
- List<PhylogenyNode> foundNodes = getNodesAboveThreshold(threshold,
+ List<ExternalTreeNodeI> foundNodes = getNodesAboveThreshold(
+ threshold,
tree.getRoot());
}
}
- public List<PhylogenyNode> getNodesAboveThreshold(double threshold,
- PhylogenyNode node)
+ public List<ExternalTreeNodeI> getNodesAboveThreshold(double threshold,
+ ExternalTreeNodeI node)
{
- List<PhylogenyNode> nodesAboveThreshold = new ArrayList<>();
+ List<ExternalTreeNodeI> nodesAboveThreshold = new ArrayList<>();
parentAvport.setSelectionGroup(null);
parentAvport.getAlignment().deleteAllGroups();
* @param node
* @return
*/
- private List<PhylogenyNode> colourNodesAboveThreshold(
- List<PhylogenyNode> nodeList, double threshold,
- PhylogenyNode node)
+ private List<ExternalTreeNodeI> colourNodesAboveThreshold(
+ List<ExternalTreeNodeI> nodeList, double threshold,
+ ExternalTreeNodeI node)
{
- for (PhylogenyNode childNode : node.getDescendants())
+ for (ExternalTreeNodeI childNode : node.getDirectChildren())
{
- childNode.getBranchData()
- .setBranchColor(new BranchColor(Color.black));
+ childNode.setBranchColor(Color.black);
float nodeCutoff = (childNode.getXcoord() - rootX)
/ (furthestNodeX - rootX);
Color randomColour = new Color((int) (Math.random() * 255),
(int) (Math.random() * 255), (int) (Math.random() * 255));
- childNode.getBranchData()
- .setBranchColor(new BranchColor(randomColour));
+ childNode.setBranchColor(randomColour);
List<SequenceI> groupSeqs = new ArrayList<>();
SequenceI seq = nodesBoundToSequences.get(childNode);
parentAvport.setSequenceColour(seq, randomColour);
}
- List<PhylogenyNode> descendantNodes = PhylogenyMethods
- .getAllDescendants(childNode);
+ List<ExternalTreeNodeI> descendantNodes = childNode
+ .getAllDescendants();
// .forEach instead?
- for (PhylogenyNode descNode : descendantNodes)
+ for (ExternalTreeNodeI descNode : descendantNodes)
{
seq = nodesBoundToSequences.get(descNode);
if (seq != null)
parentAvport.setSequenceColour(seq, randomColour);
}
- descNode.getBranchData()
- .setBranchColor(new BranchColor(randomColour));
+ descNode.setBranchColor(randomColour);
}
if (groupSeqs != null)
* does)
*/
@Override
- public void showNodeSelectionOnAlign(final PhylogenyNode node)
+ public void showNodeSelectionOnAlign(final ExternalTreeNodeI node)
{
if (node.isInternal())
@Override
- public void showMatchingSequence(final PhylogenyNode nodeToMatch)
+ public void showMatchingSequence(final ExternalTreeNodeI nodeToMatch)
{
SequenceI matchingSequence = nodesBoundToSequences.get(nodeToMatch);
if (matchingSequence != null)
{
long nodeId = nodeToMatch.getId();
- addOrRemoveInSet(treeView.getFoundNodes0(), nodeId);
+ addOrRemoveInSet(treeView.getMatchingNodes(), nodeId);
treeSelectionChanged(matchingSequence);
parentAvport.sendSelection();
}
@Override
- public void showMatchingChildSequences(final PhylogenyNode parentNode)
+ public void showMatchingChildSequences(final ExternalTreeNodeI parentNode)
{
// redundancy here, Forester already iterates through tree to get all
// descendants
- List<PhylogenyNode> childNodes = PhylogenyMethods
- .getAllDescendants(parentNode);
+ List<ExternalTreeNodeI> childNodes = parentNode.getAllDescendants();
- for (PhylogenyNode childNode : childNodes)
+ for (ExternalTreeNodeI childNode : childNodes)
{
// childNode.getBranchData().setBranchColor(new BranchColor(Color.BLUE));
if (matchingSequence != null)
{
long nodeId = childNode.getId();
- addOrRemoveInSet(treeView.getFoundNodes0(), nodeId);
+ addOrRemoveInSet(treeView.getMatchingNodes(), nodeId);
treeSelectionChanged(matchingSequence);
}
+ @Override
public CommandI sortAlignmentIn(AlignmentPanel ap)
{
// TODO: move to alignment view controller
{
AlignmentSorter.sortByTree(viewport.getAlignment(),
nodesBoundToSequences,
- treeView.getPhylogeny());
+ treeView.getTree());
CommandI undo;
undo = new OrderCommand("Tree Sort", oldOrder,
viewport.getAlignment());
import jalview.analysis.SequenceIdMatcher;
import jalview.datamodel.SequenceI;
-import jalview.ext.forester.DataConversions;
import jalview.ext.treeviewer.ExternalLoadedTreeAssociationI;
+import jalview.ext.treeviewer.ExternalTreeI;
+import jalview.ext.treeviewer.ExternalTreeNodeI;
import jalview.util.MappingUtils;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.Map;
-import org.forester.phylogeny.Phylogeny;
-import org.forester.phylogeny.PhylogenyNode;
-import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
public class LoadedTreeSequenceAssociation
implements ExternalLoadedTreeAssociationI
{
SequenceI[] alignSequences;
- Phylogeny tree;
+ ExternalTreeI tree;
- Map<SequenceI, PhylogenyNode> alignmentWithNodes;
+ Map<SequenceI, ExternalTreeNodeI> alignmentWithNodes;
- Map<PhylogenyNode, SequenceI> nodesWithAlignment;
+ Map<ExternalTreeNodeI, SequenceI> nodesWithAlignment;
public LoadedTreeSequenceAssociation(SequenceI[] alignmentSequences,
- Phylogeny aptxTree)
+ ExternalTreeI aptxTree)
{
alignSequences = alignmentSequences;
tree = aptxTree;
if (!tree.isEmpty())
{
- for (final PhylogenyNodeIterator iter = tree.iteratorPreorder(); iter
+ for (final Iterator<ExternalTreeNodeI> iter = tree
+ .iterateInPreOrder(); iter
.hasNext();)
{
- PhylogenyNode treeNode = iter.next();
- nodeSequenceName = treeNode.getName();
+ ExternalTreeNodeI treeNode = iter.next();
+ nodeSequenceName = treeNode.getNodeName();
nodeSequence = algnIds.findIdMatch(nodeSequenceName);
if (nodeSequence != null)
{
- org.forester.phylogeny.data.Sequence foresterNodeSeq = DataConversions
- .createForesterSequence(nodeSequence, true);
- treeNode.getNodeData().setSequence(foresterNodeSeq);
+
+ treeNode.setSequence(nodeSequence);
MappingUtils.putWithDuplicationCheck(alignmentWithNodes,
nodeSequence, treeNode);
- public Map<SequenceI, PhylogenyNode> getAlignmentWithNodes()
+ public Map<SequenceI, ExternalTreeNodeI> getAlignmentWithNodes()
{
return alignmentWithNodes;
}
- public Map<PhylogenyNode, SequenceI> getNodesWithAlignment()
+ public Map<ExternalTreeNodeI, SequenceI> getNodesWithAlignment()
{
return nodesWithAlignment;
}
- // {
- // SequenceIdMatcher algnIds = new SequenceIdMatcher(seqs);
- //
- // List<PhylogenyNode> leaves = aptxTree.getExternalNodes();
- //
- // int namesleft = seqs.length;
- // SequenceI nodeSequence;
- // String nodeSequenceName;
- // List<SequenceI> one2many = new ArrayList<>();
- // int countOne2Many = 0;
- //
- // for (PhylogenyNode treeNode : leaves)
- // {
- // nodeSequenceName = treeNode.getName();
- // nodeSequence = null;
- //
- // if (namesleft > -1)
- // {
- // nodeSequence = algnIds.findIdMatch(nodeSequenceName);
- // }
- //
- // if (nodeSequence != null)
- // {
- // org.forester.phylogeny.data.Sequence foresterNodeSeq =
- // ForesterDataConversions.createForesterSequence(nodeSequence, true);
- //
- // treeNode.getNodeData().setSequence(foresterNodeSeq);
- // if (one2many.contains(nodeSequence))
- // {
- // countOne2Many++;
- // if (jalview.bin.Cache.log.isDebugEnabled())
- // {
- // jalview.bin.Cache.log.debug("One 2 many relationship for"
- // +nodeSequence.getName());
- // }
- // }
- // else
- // {
- // one2many.add(nodeSequence);
- // namesleft--;
- // }
- // }
- // else
- // {
- // treeNode.setCollapse(true); // collapse nodes that couldn't be connected
- // // to a sequence
- //
- //
- // // treeNode.setElement( new Sequence(nodeSequenceName,
- // "THISISAPLACEHOLDER"));
- // // treeNode.setPlaceholder(true);
- // }
- // }
- // if (jalview.bin.Cache.log.isDebugEnabled() && countOne2Many > 0)
- // {
- // jalview.bin.Cache.log.debug("There were " + countOne2Many
- // + "alignment sequence ids (out of" + one2many.size()
- // + " unique ids) linked to two or more leaves.");
- // }
- // one2many.clear();
- //
- // }
}
package jalview.ext.archaeopteryx;
+import jalview.ext.treeviewer.ExternalTreeFrame;
import jalview.ext.treeviewer.ExternalTreeI;
import jalview.ext.treeviewer.ExternalTreeNodeI;
+import java.util.Iterator;
+
+import org.forester.archaeopteryx.Archaeopteryx;
import org.forester.phylogeny.Phylogeny;
+import org.forester.phylogeny.PhylogenyMethods;
+import org.forester.phylogeny.PhylogenyNode;
public class Tree implements ExternalTreeI
{
tree = aptxTree;
}
- @Override
- public Phylogeny getOriginalTree()
- {
- return tree;
-
- }
@Override
public ExternalTreeNodeI getRoot()
{
return tree.getAllExternalNodeNames();
}
+
+ @Override
+ public void setRerootable(boolean b)
+ {
+ tree.setRerootable(b);
+
+ }
+
+ @Override
+ public void setRooted(boolean b)
+ {
+ tree.setRooted(b);
+
+ }
+
+ @Override
+ public boolean isEmpty()
+ {
+ return tree.isEmpty();
+ }
+
+ @Override
+ public String getTreeName()
+ {
+ return tree.getName();
+ }
+
+ @Override
+ public void setRoot(ExternalTreeNodeI rootNode)
+ {
+ PhylogenyNode treeRoot = new PhylogenyNode(rootNode.getNodeName());
+ // expand this
+ tree.setRoot(treeRoot);
+
+ }
+
+ @Override
+ public double getHeight(boolean adjustForCollapsedSubtrees)
+ {
+ return tree.calculateHeight(adjustForCollapsedSubtrees);
+ }
+
+ @Override
+ public Iterator<ExternalTreeNodeI> iterateInPreOrder()
+ {
+ Iterator<ExternalTreeNodeI> iter = new TreeIterator(
+ tree.iteratorPreorder());
+ return iter;
+ }
+
+ @Override
+ public Iterator<ExternalTreeNodeI> iterateInLevelOrder()
+ {
+ Iterator<ExternalTreeNodeI> iter = new TreeIterator(
+ tree.iteratorLevelOrder());
+ return iter;
+ }
+
+ @Override
+ public Iterator<ExternalTreeNodeI> iterateInPostOrder()
+ {
+ Iterator<ExternalTreeNodeI> iter = new TreeIterator(
+ tree.iteratorPostorder());
+ return iter;
+ }
+
+ @Override
+ public ExternalTreeNodeI getFurthestNode()
+ {
+ PhylogenyNode furthestNode = PhylogenyMethods
+ .calculateNodeWithMaxDistanceToRoot(tree);
+ return new TreeNode(furthestNode);
+ }
+
+ @Override
+ public ExternalTreeFrame createInstanceFromTree(String instanceTitle)
+ {
+ return new AptxFrame(Archaeopteryx.createApplication(tree,
+ AptxInit.APTX_CONFIG,
+ instanceTitle));
+ }
}
--- /dev/null
+package jalview.ext.archaeopteryx;
+
+import jalview.ext.treeviewer.ExternalTreeNodeI;
+
+import java.util.Iterator;
+
+import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
+
+public class TreeIterator implements Iterator<ExternalTreeNodeI>
+{
+ private final PhylogenyNodeIterator iter;
+
+ public TreeIterator(PhylogenyNodeIterator aptxIterator)
+ {
+ iter = aptxIterator;
+ }
+
+ @Override
+ public boolean hasNext()
+ {
+ return iter.hasNext();
+ }
+
+ @Override
+ public ExternalTreeNodeI next()
+ {
+ ExternalTreeNodeI node = new TreeNode(iter.next());
+ return node;
+ }
+
+}
package jalview.ext.archaeopteryx;
+import jalview.datamodel.SequenceI;
+import jalview.ext.forester.DataConversions;
import jalview.ext.treeviewer.ExternalTreeNodeI;
+import java.awt.Color;
import java.util.List;
+import org.forester.phylogeny.PhylogenyMethods;
import org.forester.phylogeny.PhylogenyNode;
+import org.forester.phylogeny.data.BranchColor;
public class TreeNode implements ExternalTreeNodeI
{
private final PhylogenyNode node;
+ private SequenceI nodeSeq;
+
public TreeNode(PhylogenyNode aptxNode)
{
node = aptxNode;
+
}
+
@Override
- public PhylogenyNode getOriginalNode()
+ public String getNodeName()
{
- return node;
+ return node.getName();
}
@Override
- public String getNodeName()
+ public List<ExternalTreeNodeI> getAllDescendants()
{
- return node.getName();
+ List<PhylogenyNode> descNodes = PhylogenyMethods
+ .getAllDescendants(node);
+ return DataConversions.getConvertedTreeNodes(descNodes);
+
}
@Override
- public List<ExternalTreeNodeI> getChildren()
+ public List<ExternalTreeNodeI> getExternalDescendants()
{
- // return node.getDescendants();
- return null;
+ List<PhylogenyNode> extDescNodes = node.getAllExternalDescendants();
+ return DataConversions.getConvertedTreeNodes(extDescNodes);
+ }
+
+ @Override
+ public List<ExternalTreeNodeI> getDirectChildren()
+ {
+ List<PhylogenyNode> childNodes = node.getDescendants();
+ return DataConversions.getConvertedTreeNodes(childNodes);
+ }
+
+
+
+ @Override
+ public void setSequence(SequenceI seq)
+ {
+ nodeSeq = seq;
+ org.forester.phylogeny.data.Sequence foresterFormatSeq = DataConversions
+ .createForesterSequence(seq, true);
+ node.getNodeData().setSequence(foresterFormatSeq);
+
+ }
+
+ @Override
+ public SequenceI getSequence()
+ {
+ return nodeSeq;
+ // ideally this would return a converted node.getNodeData().getSequence()
}
+ @Override
+ public void addAsChild(ExternalTreeNodeI childNode)
+ {
+ PhylogenyNode aptxNode = new PhylogenyNode(childNode.getNodeName());
+
+ // expand on this
+ node.addAsChild(aptxNode);
+
+ }
+
+ @Override
+ public long getId()
+ {
+ return node.getId();
+ }
+
+ @Override
+ public float getXcoord()
+ {
+ return node.getXcoord();
+ }
+
+ @Override
+ public void setBranchColor(Color branchColor)
+ {
+ node.getBranchData().setBranchColor(new BranchColor(branchColor));
+
+ }
+
+ @Override
+ public boolean isInternal()
+ {
+ return node.isInternal();
+ }
}
package jalview.ext.forester;
import jalview.datamodel.SequenceI;
+import jalview.ext.archaeopteryx.TreeNode;
+import jalview.ext.treeviewer.ExternalTreeNodeI;
import jalview.math.MatrixI;
+import java.util.ArrayList;
+import java.util.List;
+
import org.forester.evoinference.matrix.distance.DistanceMatrix;
import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException;
+import org.forester.phylogeny.PhylogenyNode;
public final class DataConversions
{
return foresterMatrix;
}
+
+ public static List<ExternalTreeNodeI> getConvertedTreeNodes(
+ List<PhylogenyNode> aptxNodes)
+ {
+ List<ExternalTreeNodeI> jalviewNodes = new ArrayList<>();
+ for (PhylogenyNode aptxNode : aptxNodes)
+ {
+ jalviewNodes.add(new TreeNode(aptxNode));
+ }
+ return jalviewNodes;
+ }
}
package jalview.ext.treeviewer;
+import jalview.datamodel.SequenceI;
+
+import java.util.Map;
+
/**
* Interface for associating the leaves of a loaded in (not calculated) tree to
* the alignment sequences in Jalview.
public interface ExternalLoadedTreeAssociationI
{
public void associateLeavesToSequences();
+
+ public Map<SequenceI, ExternalTreeNodeI> getAlignmentWithNodes();
+
+ public Map<ExternalTreeNodeI, SequenceI> getNodesWithAlignment();
}
import java.util.Map;
/**
- * Note that this will take anything as a Tree or TreeNode object as no
- * assumptions can be made about the inheritance structure of Tree or TreeNode
- * (besides being Objects).
- *
* @author kjvanderheide
*
- * @param <T>
- * Tree object that the tree viewer requires.
- * @param <N>
- * Tree node object that the tree viewer requires.
*/
-public interface ExternalTreeBuilderI<T, N>
+public interface ExternalTreeBuilderI
{
- public T buildTree(N treeRoot);
+ public ExternalTreeI buildTree(ExternalTreeNodeI treeRoot);
- public T buildTree();
+ public ExternalTreeI buildTree();
- public Map<SequenceI, N> getAlignmentBoundNodes();
+ public Map<SequenceI, ExternalTreeNodeI> getAlignmentBoundNodes();
- public Map<N, SequenceI> getNodesBoundAlignment();
+ public Map<ExternalTreeNodeI, SequenceI> getNodesBoundAlignment();
public String generateTreeName();
--- /dev/null
+package jalview.ext.treeviewer;
+
+public interface ExternalTreeControlsI
+{
+ public void defaultSettings();
+
+ public void displayEntireTree();
+
+}
--- /dev/null
+package jalview.ext.treeviewer;
+
+import javax.swing.JInternalFrame;
+
+public abstract class ExternalTreeFrame extends JInternalFrame
+{
+ public abstract ExternalTreePanel getTreePanel();
+
+ public abstract void switchTreePanel(int panelIndex);
+
+ public abstract ExternalTreeI getTree();
+
+ public abstract void checkMultipleTrees();
+
+ public abstract int getNumberOfTrees();
+
+ public abstract ExternalTreeControlsI getTreeControls();
+
+}
package jalview.ext.treeviewer;
+import java.util.Iterator;
+
public interface ExternalTreeI
{
- public void setTreeName(String name);
-
- public <T> T getOriginalTree();
-
public ExternalTreeNodeI getRoot();
public ExternalTreeNodeI getNodeWithName(String name);
+ public ExternalTreeNodeI getFurthestNode();
+
public String[] getAllLeafNames();
+ public void setTreeName(String treeTitle);
+
+ public void setRerootable(boolean b);
+
+ public void setRooted(boolean b);
+
+ public boolean isEmpty();
+
+ public String getTreeName();
+
+ public void setRoot(ExternalTreeNodeI rootNode);
+
+ public double getHeight(boolean adjustForCollapsedSubtrees);
+
+ public Iterator<ExternalTreeNodeI> iterateInPreOrder();
+
+ public Iterator<ExternalTreeNodeI> iterateInLevelOrder();
+
+ public Iterator<ExternalTreeNodeI> iterateInPostOrder();
+
+ public ExternalTreeFrame createInstanceFromTree(String instanceTitle);
+
}
--- /dev/null
+package jalview.ext.treeviewer;
+
+public interface ExternalTreeIteratorI
+{
+
+}
package jalview.ext.treeviewer;
+import jalview.datamodel.SequenceI;
+
+import java.awt.Color;
import java.util.List;
public interface ExternalTreeNodeI
{
- public <N> N getOriginalNode();
+ final static int nodeCount = 0;
public String getNodeName();
- public List<ExternalTreeNodeI> getChildren();
+ public List<ExternalTreeNodeI> getAllDescendants();
+
+ public List<ExternalTreeNodeI> getExternalDescendants();
+
+ public List<ExternalTreeNodeI> getDirectChildren();
+
+ public void setSequence(SequenceI seq);
+
+ public SequenceI getSequence();
+
+ public void addAsChild(ExternalTreeNodeI childNode);
+
+ public long getId();
+
+ public float getXcoord();
+
+ public void setBranchColor(Color branchColor);
+
+ public boolean isInternal();
+
+ public static int getTotalNodes()
+ {
+ return nodeCount;
+ }
}
--- /dev/null
+package jalview.ext.treeviewer;
+
+import java.io.File;
+import java.util.Set;
+
+import javax.swing.JPanel;
+
+public abstract class ExternalTreePanel extends JPanel
+{
+
+ public abstract void setTreeFile(File file);
+
+ public abstract File getTreeFile();
+
+ public abstract ExternalTreeI getTree();
+
+ public abstract ExternalTreeNodeI findNode(int x, int y);
+
+ public abstract void setMatchingNodes(Set<Long> matchingNodes);
+
+ public abstract Set<Long> getMatchingNodes();
+}
+++ /dev/null
-package jalview.ext.treeviewer;
-
-public interface ExternalTreePanelI
-{
-
-}
*/
package jalview.ext.treeviewer;
+import jalview.commands.CommandI;
import jalview.datamodel.SequenceI;
+import jalview.gui.AlignmentPanel;
import jalview.structure.SelectionListener;
import jalview.structure.SelectionSource;
/**
*
* Interface for binding a tree viewer to Jalview alignments. Assumes a tree
- * viewer will both want to receive and send selection events. Note that this
- * will take anything as a TreeNode object as no assumptions can be made about
- * the inheritance structure of the TreeNode (besides being an Object).
+ * viewer will both want to receive and send selection events.
*
* @author kjvanderheide
*
- * @param <N>
- * Tree node object.
+ *
*/
-public interface ExternalTreeViewerBindingI<N>
+public interface ExternalTreeViewerBindingI
extends ActionListener, MouseListener, SelectionListener,
SelectionSource
{
* corresponding sequence in the Jalview alignment view. If an internal node
* is selected all child sequences get highlighted as well.
*/
- public void showNodeSelectionOnAlign(N node);
+ public void showNodeSelectionOnAlign(ExternalTreeNodeI node);
public void treeSelectionChanged(SequenceI sequence);
- public void showMatchingSequence(N nodeToMatch);
+ public void showMatchingSequence(ExternalTreeNodeI nodeToMatch);
- public void showMatchingChildSequences(N parentNode);
+ public void showMatchingChildSequences(ExternalTreeNodeI parentNode);
public void sortByTree_actionPerformed();
+ public CommandI sortAlignmentIn(AlignmentPanel alignPanel);
+
}
--- /dev/null
+package jalview.ext.treeviewer;
+
+public interface ExternalTreeViewerConfigI
+{
+
+}
+++ /dev/null
-package jalview.ext.treeviewer;
-
-public interface ExternalTreeViewerI
-{
- public ExternalTreePanelI getTreePanel();
-
-}
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.ext.archaeopteryx.AptxInit;
-import jalview.ext.archaeopteryx.JalviewBinding;
import jalview.ext.forester.io.SupportedTreeFileFilter;
import jalview.ext.forester.io.TreeParser;
+import jalview.ext.treeviewer.ExternalTreeFrame;
+import jalview.ext.treeviewer.ExternalTreeViewerBindingI;
import jalview.gui.ColourMenuHelper.ColourChangeListener;
import jalview.gui.ViewSelectionMenu.ViewSetProvider;
import jalview.io.AlignmentProperties;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.StringTokenizer;
import java.util.Vector;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
-import org.forester.archaeopteryx.MainFrame;
import org.forester.archaeopteryx.webservices.PhylogeniesWebserviceClient;
import org.forester.archaeopteryx.webservices.WebservicesManager;
.get(viewport.getSequenceSetId());
List<TreePanel> treePanels = new ArrayList<>();
- Map<MainFrame, JalviewBinding> aptxFrames = AptxInit.getAllAptxFrames();
+ Map<ExternalTreeFrame, ExternalTreeViewerBindingI> aptxFrames = AptxInit
+ .getAllAptxFrames();
for (Component comp : comps)
{
sortByTreeMenu.setVisible(true);
- for (Map.Entry<MainFrame, JalviewBinding> aptxFrameWithBinding : aptxFrames
+ for (Entry<ExternalTreeFrame, ExternalTreeViewerBindingI> aptxFrameWithBinding : aptxFrames
.entrySet())
{
- MainFrame aptxFrame = aptxFrameWithBinding.getKey();
- JalviewBinding binding = aptxFrameWithBinding.getValue();
+ ExternalTreeFrame aptxFrame = aptxFrameWithBinding.getKey();
+ ExternalTreeViewerBindingI binding = aptxFrameWithBinding.getValue();
// future support for multiple tabs
// for (org.forester.archaeopteryx.TreePanel aptxTree : aptxFrame
// .getMainPanel().getTreePanels())
{
final JMenuItem item = new JMenuItem(
- aptxFrame.getMainPanel().getCurrentTreePanel()
- .getPhylogeny().getName());
+ aptxFrame.getTree().getTreeName());
item.addActionListener(new ActionListener()
{
import jalview.datamodel.SequenceCollectionI;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
+import jalview.ext.treeviewer.ExternalTreeI;
import jalview.renderer.ResidueShader;
import jalview.renderer.ResidueShaderI;
import jalview.schemes.ColourSchemeI;
changeSupport = null;
ranges = null;
currentTree = null;
+ currentExtTree = null;
selectionGroup = null;
setAlignment(null);
}
protected TreeModel currentTree = null;
+ protected ExternalTreeI currentExtTree = null;
+
@Override
public boolean hasSearchResults()
{
{
return currentTree;
}
+
+ public ExternalTreeI getCurrentExtTree()
+ {
+ return currentExtTree;
+ }
+
+ public void setCurrentExtTree(ExternalTreeI externalTree)
+ {
+ currentExtTree = externalTree;
+ }
+
}