From: kjvdheide Date: Wed, 8 Nov 2017 17:53:17 +0000 (+0000) Subject: JAL-2794 Cleaning up tree conversion, sequences are now in the tree X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=6cf0755d3de2f853a2b697230302e3c785694ad3;p=jalview.git JAL-2794 Cleaning up tree conversion, sequences are now in the tree --- diff --git a/src/jalview/ext/archaeopteryx/ArchaeopteryxTreeConverter.java b/src/jalview/ext/archaeopteryx/ArchaeopteryxTreeConverter.java index 93a9341..58c5728 100644 --- a/src/jalview/ext/archaeopteryx/ArchaeopteryxTreeConverter.java +++ b/src/jalview/ext/archaeopteryx/ArchaeopteryxTreeConverter.java @@ -2,28 +2,34 @@ package jalview.ext.archaeopteryx; import jalview.analysis.TreeBuilder; import jalview.datamodel.SequenceI; +import jalview.ext.forester.ForesterConversions; import jalview.ext.forester.ForesterMatrix; import jalview.util.MessageManager; +import java.util.HashMap; +import java.util.Map; + 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; -public class ArchaeopteryxTreeConverter +public class ArchaeopteryxTreeConverter // implements PhylogenyFactory { protected final SequenceI[] sequences; - private Phylogeny aptxTree; - - private PhylogenyNode rootNode; - protected final DistanceMatrix distances; protected final TreeBuilder jalviewTree; public String treeTitle; + private final Phylogeny aptxTree; + + private PhylogenyNode rootNode; + private final Map alignmentBoundNodes; public ArchaeopteryxTreeConverter(final TreeBuilder calculatedTree) { @@ -33,13 +39,19 @@ public class ArchaeopteryxTreeConverter jalviewTree.getDistances(), sequences); aptxTree = new Phylogeny(); rootNode = new PhylogenyNode(); + alignmentBoundNodes = new HashMap<>( + distances.getSize()); + } public Phylogeny buildAptxTree(final PhylogenyNode treeRoot) { - rootNode = treeRoot; + if (treeRoot != null) + { + rootNode = treeRoot; + } buildAptxTree(); @@ -47,17 +59,25 @@ public class ArchaeopteryxTreeConverter } + public Phylogeny buildAptxTree() { - // test loop + for (SequenceI sequence : sequences) { + Sequence seq = ForesterConversions + .createForesterSequence(sequence); PhylogenyNode sequenceNode = new PhylogenyNode(sequence.getName()); + NodeData nodeData = sequenceNode.getNodeData(); + nodeData.setSequence(seq); + + alignmentBoundNodes.put(sequence, sequenceNode); rootNode.addAsChild(sequenceNode); } - aptxTree.setRoot(rootNode); + aptxTree.setRoot(rootNode); + treeTitle = generateTreeName(); aptxTree.setName(treeTitle); @@ -65,13 +85,16 @@ public class ArchaeopteryxTreeConverter } + public Map getAlignmentBoundNodes() + { + return alignmentBoundNodes; + } + private Phylogeny clusterNodes() { return aptxTree; } - - /** * Formats a localised title for the tree panel, like *

@@ -81,7 +104,8 @@ public class ArchaeopteryxTreeConverter * * @return */ - public String generateTreeName() + public String generateTreeName() // Move this and add selection region to the + // title when applicable { if (treeTitle != null) // will currently never happen, loaded tree file will // take a different path