From: kjvdheide Date: Tue, 12 Dec 2017 18:03:37 +0000 (+0000) Subject: JAL-2874 added filtering when a subtree is selected X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=b39c593c3799dc8a2ec799ce015c86d201d43da7;p=jalview.git JAL-2874 added filtering when a subtree is selected --- diff --git a/src/jalview/ext/archaeopteryx/AptxInit.java b/src/jalview/ext/archaeopteryx/AptxInit.java index 6fcc37c..9d248d0 100644 --- a/src/jalview/ext/archaeopteryx/AptxInit.java +++ b/src/jalview/ext/archaeopteryx/AptxInit.java @@ -496,7 +496,7 @@ public final class AptxInit MainFrame aptxApp = Archaeopteryx.createApplication(aptxTree, APTX_CONFIG, treeTitle); - adaptAptxGui(aptxApp); + LoadedTreeSequenceAssociation bindAptxNodes = new LoadedTreeSequenceAssociation( jalviewAlignport.getAlignment().getSequencesArray(), aptxTree); bindAptxNodes.associateLeavesToSequences(); @@ -506,6 +506,7 @@ public final class AptxInit bindAptxNodes.getNodesWithAlignment()); bindTreeViewFrameToJalview(aptxApp); + adaptAptxGui(aptxApp); return aptxApp; } @@ -593,9 +594,21 @@ public final class AptxInit { menu.addSeparator(); JMenuItem sortByTree = new JMenuItem("Sort alignment by tree"); + JMenuItem refreshJalview = new JMenuItem( + "Filter alignment to show only currently visible sequences"); + + refreshJalview.setFont(menu.getFont()); + menu.add(sortByTree); + menu.add(refreshJalview); + + sortByTree.setFont(menu.getFont()); sortByTree.setVisible(false); // don't show unless it's actually - // possible + // possible + + refreshJalview.addActionListener(activeAptx.get(aptxFrame)); + + } } diff --git a/src/jalview/ext/archaeopteryx/JalviewBinding.java b/src/jalview/ext/archaeopteryx/JalviewBinding.java index 6969821..11aab2b 100644 --- a/src/jalview/ext/archaeopteryx/JalviewBinding.java +++ b/src/jalview/ext/archaeopteryx/JalviewBinding.java @@ -177,7 +177,28 @@ public final class JalviewBinding @Override public void actionPerformed(ActionEvent e) { - // aptxFrame.actionPerformed(e); + if (treeView.isCurrentTreeIsSubtree()) + { + LoadedTreeSequenceAssociation bindAptxNodes = new LoadedTreeSequenceAssociation( + parentAvport.getAlignment().getSequencesArray(), + treeView.getPhylogeny()); + bindAptxNodes.associateLeavesToSequences(); + sequencesBoundToNodes = bindAptxNodes.getAlignmentWithNodes(); + nodesBoundToSequences = bindAptxNodes.getNodesWithAlignment(); + AptxInit.bindNodesToJalviewSequences(aptxFrame, parentAvport, + sequencesBoundToNodes, nodesBoundToSequences); + + + for (SequenceI seq : parentAvport.getAlignment().getSequencesArray()) + { + if (!sequencesBoundToNodes.containsKey(seq)) + { + parentAvport.hideSequence(new SequenceI[] { seq }); + } + } + } + + } @@ -192,6 +213,8 @@ public final class JalviewBinding */ public void run() { + + final PhylogenyNode node = treeView.findNode(e.getX(), e.getY()); if (node != null) { @@ -203,11 +226,12 @@ public final class JalviewBinding } showNodeSelectionOnAlign(node); + } else { - partitionTree(e.getX()); + } PaintRefresher.Refresh(treeView, parentAvport.getSequenceSetId()); treeView.repaint(); @@ -296,6 +320,7 @@ public final class JalviewBinding furthestNodeX = furthestNode.getXcoord(); rootX = tree.getRoot().getXcoord(); + // don't bother if 0 distance tree or clicked x lies outside of tree if (furthestNodeX != rootX && !(x > furthestNodeX)) { diff --git a/src/jalview/ext/archaeopteryx/LoadedTreeSequenceAssociation.java b/src/jalview/ext/archaeopteryx/LoadedTreeSequenceAssociation.java index 86f27d1..0c83036 100644 --- a/src/jalview/ext/archaeopteryx/LoadedTreeSequenceAssociation.java +++ b/src/jalview/ext/archaeopteryx/LoadedTreeSequenceAssociation.java @@ -16,13 +16,13 @@ import org.forester.phylogeny.iterators.PhylogenyNodeIterator; public class LoadedTreeSequenceAssociation implements ExternalLoadedTreeAssociationI { - SequenceI[] alignSequences; + private SequenceI[] alignSequences; - Phylogeny tree; + private Phylogeny tree; - Map alignmentWithNodes; + private Map alignmentWithNodes; - Map nodesWithAlignment; + private Map nodesWithAlignment; public LoadedTreeSequenceAssociation(SequenceI[] alignmentSequences, Phylogeny aptxTree)